#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))
--- /dev/null
+##################################################
+#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)
APPOBJ :=
#Dependencies which must be built before the executable
APPDEPS :=
+#Directories containing independent tools
+TOOLS := apc
##################################################
#Emscripten Info
##################################################
#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)))