Skip to content

Commit

Permalink
Fix up build system to work with emscripten
Browse files Browse the repository at this point in the history
  • Loading branch information
ArcaneNibble committed Nov 15, 2017
1 parent 539cf99 commit 05440e4
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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; \
Expand Down
19 changes: 17 additions & 2 deletions config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion icebram/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion icemulti/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions icepack/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
2 changes: 1 addition & 1 deletion icepll/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 17 additions & 1 deletion icetime/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 05440e4

Please sign in to comment.