prototype IR and parser
[henge/webcc.git] / src / .make / buildc_emcc.mk
1 ##################################################
2 #Desc: Web Build System
3 #Author: Mihrtec LLC
4 #Date: 2016
5 ##################################################
6 #Compile Overrides for web
7 ##################################################
8 #EMCC compiles with llvm
9 CARCH := llvm
10 #EMCC outputs to javascript
11 APPSUF := .js
12 #Place JS binary output in dist/js
13 CBINDIR := $(DISTDIR)/js
14 #Object files are in LLVM bitcode format
15 COBJSUF := .bc
16 #Expand the list of plain-text functions into what emcc expects
17 EXPORT_FUNCS := $(patsubst %,'_%',$(EXPORT_FUNCS))
18 EXPORT_LIST := $(shell echo "$(EXPORT_FUNCS)" | sed -e 's@ @, @g')
19 #Override the linker sed script to find our string
20 LDSED := sed -e 's!.*rary \"\([a-zA-Z0-9\.]*\)\".*!\1!g'
21 ##################################################
22 #Emscripten Ports
23 #To be replaced. Emscripten's ports are not
24 #maintained well.
25 ##################################################
26 EMPORTS := SDL2 SDL2_image SDL2_ttf
27 ifdef EMPORTS
28 #Remove EMPORTS from the linker
29 CLIBS := $(filter-out $(EMPORTS), $(CLIBS))
30 #Add supported ports to CFLAGS
31 CFLAGS += -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s USE_SDL_TTF=2
32 endif
33
34 #Override Automake vars (for building libs)
35 AMGEN := emconfigure ./autogen.sh
36 AMCONF := emconfigure ./configure
37 AMMAKE := emmake
38
39 #Set up emscripten APPFLAGS
40 APPFLAGS += --separate-asm
41 APPFLAGS += -s ALLOW_MEMORY_GROWTH=1
42 APPFLAGS += -s FORCE_FILESYSTEM=1
43 #APPLFAGS += --pre-js pre.js
44
45 #Set up emscripten flags for CC
46 CFLAGS += -s EXPORTED_FUNCTIONS="[$(EXPORT_LIST)]"
47