Makefile +Tools
authorksg <ken@mihrtec.com>
Tue, 30 Aug 2016 03:09:13 +0000 (20:09 -0700)
committerksg <ken@mihrtec.com>
Tue, 30 Aug 2016 03:09:13 +0000 (20:09 -0700)
src/.make/build.mk
src/.make/buildtools.mk [new file with mode: 0644]
src/Makefile

index 12affc7..eb98325 100644 (file)
@@ -3,7 +3,7 @@
 #Author: Mihrtec LLC
 #Date:   2016
 ##################################################
-#Included from ./build.mk
+#Included from Makefile
 #Defines variables used in the make process to
 #compile C files either to
 #native asm through gcc, or web through
 PROJDIR  := ..
 #Output directories for distributables
 DISTDIR  := $(PROJDIR)/dist
-
 #Build rules for each source type
 include .make/buildc.mk
 include .make/buildhtml.mk
 
+#Build rules for tools
+ifdef TOOLS
+include .make/buildtools.mk
+endif
+
 #Set the final target, flags, and objects for app compile
 APPC     := $(CC)
 APPDEPS  := $(strip $(CDEPS) $(CTARG) $(APPDEPS))
diff --git a/src/.make/buildtools.mk b/src/.make/buildtools.mk
new file mode 100644 (file)
index 0000000..d4cdc1d
--- /dev/null
@@ -0,0 +1,17 @@
+##################################################
+#Desc:   Build rules for independent tools
+#Author: Mihrtec LLC
+#Date:   2016
+##################################################
+#Included from ./build.mk
+#sources and flags for tools
+##################################################
+apcCC  := gcc
+apcSRC := $(wildcard apc/*.c)
+apcFLG := $(CFLAGS)
+apcCL  := -r /usr/local/the_march -o $(DISTDIR)/file.asspack
+
+TOOLSUP := $(shell echo '$(TOOLS)' | tr '[:lower:]' '[:upper:]')
+TOOLSRC := $(foreach tool,$(TOOLS),$($(tool)SRC))
+TOOLDEP := $(TOOLSRC:.c=.d)
+TOOLOBJ := $(TOOLSRC:.c=.o)
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)))