################################################## #Desc: Web Build System #Author: Mihrtec LLC #Date: 2016 ################################################## #Compile Overrides for web ################################################## #redefine EXE directory for web platform EXEDIR := $(BINDIR)/web/js APPSUFFIX := .js #Override targets to make .bc files LIBS := $(filter-out SDL2 SDL2_image SDL2_ttf, $(LIBS)) CLIBS := $(patsubst %,-l%,$(LIBS)) CTARG := $(CTARG:.o=.bc) #Expand the list of plain-text functions into what emcc expects EXPORT_FUNCS := $(patsubst %,'_%',$(EXPORT_FUNCS)) EXPORT_LIST := $(shell echo "$(EXPORT_FUNCS)" | sed -e 's@ @, @g') #Mark all libs "missing" since they need to be built for emcc MISSINGLIBS := $(LIBS) #Set XTLibDir to one for bytecodes XTLIBDIR := $(XTLIBDIR)/bc #Override Automake vars AMGEN := emconfigure $(AMGEN) AMCONF := emconfigure $(AMCONF) AMMAKE := emmake #Set up emscripten APPFLAGS APPFLAGS += --separate-asm APPFLAGS += -s ALLOW_MEMORY_GROWTH=1 APPFLAGS += -s FORCE_FILESYSTEM=1 #APPLFAGS += --pre-js pre.js #Set up emscripten flags for CC CFLAGS += -s EXPORTED_FUNCTIONS="[$(EXPORT_LIST)]" CFLAGS += -I$(XTDIR) -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s USE_SDL_TTF=2 #Directory structure for web targets #Dirs for source files HTSRCDIR := $(REPOROOT)/html JSSRCDIR := $(HTSRCDIR)/js #Dirs for targets HTDIR := $(EXEDIR) JSDIR := $(HTDIR)/js #Discover each type of object supported HTSRC := $(wildcard $(HTSRCDIR)/*.html) JSSRC := $(wildcard $(JSSRCDIR)/*.js) WEBSRC := $(HTSRC) $(JSSRC) #Translate sources into their required targets in APPDIR WEBTARG := $(patsubst $(HTSRCDIR)/%,$(HTDIR)/%,$(WEBSRC)) #Add APPDEPS for all web objects so they must be created #at build time, before compilation of the main executable APPDEPS += $(WEBOBJ) #Later, we will use WEBTARG to define rules for "making" #these targets (with a cp action) and cleaning (with rm)