diff --git a/Makefile b/Makefile index 79e7a7f2f88..518e08cf29a 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ -include config.mk - SUBDIRS = icebox icepack iceprog icemulti icepll icetime icebram +include config.mk + all clean install uninstall: for dir in $(SUBDIRS); do \ $(MAKE) -C $$dir $@ || exit; \ diff --git a/config.mk b/config.mk index d6daca6eebf..7b3b4943e45 100644 --- a/config.mk +++ b/config.mk @@ -6,12 +6,18 @@ PKG_CONFIG ?= pkg-config C_STD ?= c99 CXX_STD ?= c++11 +ifeq ($(EMCC),1) +OPT_LEVEL ?= 2 +DBG_LEVEL ?= +else OPT_LEVEL ?= 0 +DBG_LEVEL ?= -ggdb +endif WARN_LEVEL ?= all LDLIBS = -lm -lstdc++ -CFLAGS += -MD -O$(OPT_LEVEL) -ggdb -W$(WARN_LEVEL) -std=$(C_STD) -I$(PREFIX)/include -CXXFLAGS += -MD -O$(OPT_LEVEL) -ggdb -W$(WARN_LEVEL) -std=$(CXX_STD) -I$(PREFIX)/include +CFLAGS += -MD -O$(OPT_LEVEL) $(DBG_LEVEL) -W$(WARN_LEVEL) -std=$(C_STD) -I$(PREFIX)/include +CXXFLAGS += -MD -O$(OPT_LEVEL) $(DBG_LEVEL) -W$(WARN_LEVEL) -std=$(CXX_STD) -I$(PREFIX)/include DESTDIR ?= CHIPDB_SUBDIR ?= icebox @@ -22,3 +28,12 @@ CXX = /usr/local/src/mxe/usr/bin/i686-w64-mingw32.static-gcc CC = $(CXX) PKG_CONFIG = /usr/local/src/mxe/usr/bin/i686-w64-mingw32.static-pkg-config endif + +ifeq ($(EMCC),1) +EXE = .js +CC = emcc +CXX = emcc +PREFIX = / +LDFLAGS = -O2 --memory-init-file 0 -s TOTAL_MEMORY=64*1024*1024 +SUBDIRS = icebox icepack icemulti icepll icetime icebram +endif diff --git a/icebram/Makefile b/icebram/Makefile index 3904926e9c2..34801da3c9c 100644 --- a/icebram/Makefile +++ b/icebram/Makefile @@ -20,7 +20,7 @@ uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/icebram$(EXE) clean: - rm -f icebram + rm -f icebram$(EXE) rm -f icebram.exe rm -f demo.* demo_*.* rm -f *.o *.d diff --git a/icemulti/Makefile b/icemulti/Makefile index 530215881c1..7e2fe1c1cf2 100644 --- a/icemulti/Makefile +++ b/icemulti/Makefile @@ -17,7 +17,7 @@ uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/icemulti$(EXE) clean: - rm -f icemulti + rm -f icemulti$(EXE) rm -f icemulti.exe rm -f *.o *.d diff --git a/icepack/Makefile b/icepack/Makefile index 65d4c9a5fa4..3e8c774216e 100644 --- a/icepack/Makefile +++ b/icepack/Makefile @@ -10,8 +10,8 @@ all: icepack$(EXE) iceunpack$(EXE) icepack$(EXE): icepack.o $(CXX) -o $@ $(LDFLAGS) $^ $(LDLIBS) -iceunpack: icepack - ln -sf icepack iceunpack +iceunpack$(EXE): icepack$(EXE) + ln -sf icepack$(EXE) iceunpack$(EXE) iceunpack.exe: # no iceunpack.exe, use icepack -u @@ -26,8 +26,8 @@ uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/iceunpack$(EXE) clean: - rm -f icepack - rm -f iceunpack + rm -f icepack$(EXE) + rm -f iceunpack$(EXE) rm -f icepack.exe rm -f *.o *.d diff --git a/icepll/Makefile b/icepll/Makefile index 87eabfa6f63..13a1d81c586 100644 --- a/icepll/Makefile +++ b/icepll/Makefile @@ -17,7 +17,7 @@ uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/icepll$(EXE) clean: - rm -f icepll + rm -f icepll$(EXE) rm -f icepll.exe rm -f *.o *.d diff --git a/icetime/Makefile b/icetime/Makefile index 5e959c7a159..d0581535db8 100644 --- a/icetime/Makefile +++ b/icetime/Makefile @@ -8,6 +8,22 @@ endif all: icetime$(EXE) +ifeq ($(EXE),.js) +icetime$(EXE): | share/$(CHIPDB_SUBDIR)/chipdb-384.txt share/$(CHIPDB_SUBDIR)/chipdb-1k.txt share/$(CHIPDB_SUBDIR)/chipdb-8k.txt + +share/$(CHIPDB_SUBDIR)/chipdb-384.txt: ../icebox/chipdb-384.txt + mkdir -p share/$(CHIPDB_SUBDIR) + cp $< $@ +share/$(CHIPDB_SUBDIR)/chipdb-1k.txt: ../icebox/chipdb-1k.txt + mkdir -p share/$(CHIPDB_SUBDIR) + cp $< $@ +share/$(CHIPDB_SUBDIR)/chipdb-8k.txt: ../icebox/chipdb-8k.txt + mkdir -p share/$(CHIPDB_SUBDIR) + cp $< $@ + +override LDFLAGS += --embed-file share +endif + icetime$(EXE): icetime.o $(CXX) -o $@ $(LDFLAGS) $^ $(LDLIBS) @@ -46,7 +62,7 @@ test: test0 test1 test2 test3 test4 test5 test6 test7 test8 test9 show: show0 show1 show2 show3 show4 show5 show6 show7 show8 show9 clean: - rm -f icetime icetime.exe timings.inc *.o *.d + rm -f icetime$(EXE) icetime.exe timings.inc *.o *.d rm -rf test[0-9]* -include *.d