Makefile +Tools
[henge/webcc.git] / src / Makefile
index 894514a..89aba0e 100644 (file)
@@ -15,6 +15,8 @@ APPFLAGS  :=
 APPOBJ    :=
 #Dependencies which must be built before the executable
 APPDEPS   :=
+#Directories containing independent tools
+TOOLS     := apc
 ##################################################
 #Emscripten Info
 ##################################################
@@ -68,6 +70,20 @@ scrub: | clean
 #cancel default %.o behavior for %.d dependency
 %.o : %.c
 
+#construct list of make rules for tools
+ifdef TOOLS
+TOOLTARGS := $(foreach tool,$(TOOLS),$(tool)/$(tool))
+.phony: $(TOOLS)
+$(TOOLS): $(TOOLTARGS)
+
+T = $(notdir $@)
+$(TOOLTARGS): $(TOOLOBJ)
+       $($TCC) $($TFLG) $($TSRC:.c=.o) -o $@
+
+#Put our toolsrc on the ctarg list for generating deps
+CTARG := $(CTARG) $(TOOLOBJ)
+endif
+
 #Generate and evaluate C dependencies
 $(foreach base,$(basename $(sort $(strip $(CTARG)))),\
        $(eval $(strip $(base)$(COBJSUF): $(shell $(subst $BASE,$(base),$(CDEPSCOMMAND)))) $(CDEPS)))