From 8f6cd444a2508bf0160e14cbc456c7dd6658494a Mon Sep 17 00:00:00 2001 From: ksg Date: Mon, 29 Aug 2016 20:09:13 -0700 Subject: [PATCH] Makefile +Tools --- src/.make/build.mk | 8 ++++++-- src/.make/buildtools.mk | 17 +++++++++++++++++ src/Makefile | 16 ++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 src/.make/buildtools.mk diff --git a/src/.make/build.mk b/src/.make/build.mk index 12affc7..eb98325 100644 --- a/src/.make/build.mk +++ b/src/.make/build.mk @@ -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 @@ -15,11 +15,15 @@ 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 index 0000000..d4cdc1d --- /dev/null +++ b/src/.make/buildtools.mk @@ -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) diff --git a/src/Makefile b/src/Makefile index 894514a..89aba0e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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))) -- 2.18.0