1 ##################################################
2 #Desc: Web Build System
5 ##################################################
6 #Compile Overrides for web
7 ##################################################
8 #redefine EXE directory for web platform
9 EXEDIR
:= $(BINDIR
)/web
/js
10 #EMCC targets .js "executables"
12 #EMCC provides ports of each of these, so remove them
13 #and recalculate CLIBS
14 LIBS
:= $(filter-out SDL2 SDL2_image SDL2_ttf
, $(LIBS
))
15 CLIBS
:= $(patsubst %,-l
%,$(LIBS
))
16 #Override targets to make .bc files
17 CTARG
:= $(CTARG
:.o
=.bc
)
18 #Expand the list of plain-text functions into what emcc expects
19 EXPORT_FUNCS
:= $(patsubst %,'_%',$(EXPORT_FUNCS
))
20 EXPORT_LIST
:= $(shell echo
"$(EXPORT_FUNCS)" | sed
-e
's@ @, @g')
21 #Mark all remaining libs "missing" since they need to be built for emcc
22 MISSINGLIBS
:= $(LIBS
)
23 #Set XTLibDir to one for bytecodes
24 XTLIBDIR
:= $(XTLIBDIR
)/bc
25 #Override Automake vars
26 AMGEN
:= emconfigure
$(AMGEN
)
27 AMCONF
:= emconfigure
$(AMCONF
)
30 #Set up emscripten APPFLAGS
31 APPFLAGS
+= --separate-asm
32 APPFLAGS
+= -s ALLOW_MEMORY_GROWTH
=1
33 APPFLAGS
+= -s FORCE_FILESYSTEM
=1
34 #APPLFAGS += --pre-js pre.js
36 #Set up emscripten flags for CC
37 CFLAGS
+= -s EXPORTED_FUNCTIONS
="[$(EXPORT_LIST)]"
38 CFLAGS
+= -I
$(XTDIR
) -s USE_SDL
=2 -s USE_SDL_IMAGE
=2 -s USE_SDL_TTF
=2
40 #Directory structure for web targets
41 #Dirs for source files
42 HTSRCDIR
:= $(REPOROOT
)/html
43 JSSRCDIR
:= $(HTSRCDIR
)/js
48 #Discover each type of object supported
49 HTSRC
:= $(wildcard $(HTSRCDIR
)/*.html
)
50 JSSRC
:= $(wildcard $(JSSRCDIR
)/*.js
)
51 WEBSRC
:= $(HTSRC
) $(JSSRC
)
53 #Translate sources into their required targets in APPDIR
54 WEBTARG
:= $(patsubst $(HTSRCDIR
)/%,$(HTDIR
)/%,$(WEBSRC
))
56 #Add APPDEPS for all web objects so they must be created
57 #at build time, before compilation of the main executable
60 #Later, we will use WEBTARG to define rules for "making"
61 #these targets (with a cp action) and cleaning (with rm)