Buildsys2
[henge/webcc.git] / src / .make / buildc_emcc.mk
index 800722c..2ac5546 100644 (file)
@@ -5,26 +5,35 @@
 ##################################################
 #Compile Overrides for web
 ##################################################
-#redefine EXE directory for web platform
-EXEDIR    := $(BINDIR)/web/js
-#EMCC targets .js "executables"
-APPSUFFIX := .js
-#EMCC provides ports of each of these, so remove them
-#and recalculate CLIBS
-LIBS     := $(filter-out SDL2 SDL2_image SDL2_ttf, $(LIBS))
-CLIBS    := $(patsubst %,-l%,$(LIBS))
-#Override targets to make .bc files
-CTARG    := $(CTARG:.o=.bc)
+#EMCC compiles with llvm
+CARCH   := llvm
+#EMCC outputs to javascript
+APPSUF  := .js
+#Place JS binary output in dist/js
+CBINDIR := $(DISTDIR)/js
+#Object files are in LLVM bitcode format
+COBJSUF := .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 remaining 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)
+#Override the linker sed script to find our string
+LDSED := sed -e 's!.*rary \"\([a-zA-Z0-9\.]*\)\".*!\1!g'
+##################################################
+#Emscripten Ports
+#To be replaced.  Emscripten's ports are not
+#maintained well.
+##################################################
+EMPORTS := SDL2 SDL2_image SDL2_ttf
+ifdef EMPORTS
+#Remove EMPORTS from the linker
+CLIBS := $(filter-out $(EMPORTS), $(CLIBS))
+#Add supported ports to CFLAGS
+CFLAGS  += -s USE_SDL=2 -s USE_SDL_IMAGE=2 -s USE_SDL_TTF=2
+endif
+
+#Override Automake vars (for building libs)
+AMGEN  := emconfigure ./autogen.sh
+AMCONF := emconfigure ./configure
 AMMAKE := emmake
 
 #Set up emscripten APPFLAGS
@@ -35,28 +44,4 @@ APPFLAGS += -s FORCE_FILESYSTEM=1
 
 #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)