Buildsys2
[henge/webcc.git] / src / Makefile
index 4e22f2f..c6262fd 100644 (file)
@@ -8,7 +8,7 @@
 #Executable name, also passed as -DAPPNAME to compiler
 APPNAME   := the_march
 #Directory in which we expect to find main()
-APPSRC    := core
+APPMODULE := core
 #Compiler flags for the final executable
 APPFLAGS  :=
 #Object files statically linked for the executable
@@ -26,17 +26,20 @@ EMFLAGS      :=
 #Import the build system setup
 include .make/build.mk
 
+#Directories to be constructed
+DIRS := $(sort $(dir $(APPDEPS) $(APPTARG)))
+
 #Targets that don't generate a file
 .PHONY: $(APPNAME) run push dox doc clean scrub all default
 #Define default rules to point to APPNAME
 all default: $(APPTARG)
 
 #Build the executable
-$(APPNAME) $(APPTARG): $(APPDEPS) | $(APPDIRS)
-       $(CC) -o $(APPTARG) $(APPFLAGS) $(APPDEPS)
+$(APPNAME) $(APPTARG): $(DIRS) $(APPDEPS)
+       $(APPC) -o $(APPTARG) $(APPFLAGS) $(APPSRC)
 
 #create directories
-$(APPDIRS):
+$(DIRS):
        @mkdir -p $@
 
 #run the game after making it
@@ -67,7 +70,7 @@ scrub: | clean
 
 #Generate and evaluate C dependencies
 $(foreach base,$(basename $(sort $(strip $(CTARG)))),\
-       $(eval $(strip $(base)$(COBJSUF): $(shell $(subst $BASE,$(base),$(CGENDEP))))))
+       $(eval $(strip $(base)$(COBJSUF): $(shell $(subst $BASE,$(base),$(CDEPSCOMMAND)))) $(CDEPS)))
 
 #new default C build rule
 %.bc %.o: %.c $(CDEPS)
@@ -75,11 +78,13 @@ $(foreach base,$(basename $(sort $(strip $(CTARG)))),\
 
 #construct list of cp rules for each web item
 ifdef WEBTARG
-$(WEBTARG): $(HTMLDIR)/$(filter-out $(EXEDIR),$@)
-       cp -f $< $@
+$(WEBTARG): $(subst $(DISTDIR),$(HTSRCDIR),$(WEBTARG))
+       cp -f $(subst $(DISTDIR),$(HTSRCDIR),$@) $@
 endif
 
-#force including rules for making each lib in this case
+#force including rules for making each lib if
+#we have identified any missing libs
+#(fail if no rule exists)
 ifdef MISSINGLIBS
 include $(foreach lib,$(MISSINGLIBS),.make/lib$(lib).mk)
 endif