From: ken Date: Wed, 28 Sep 2016 18:49:04 +0000 (-0700) Subject: fixed source-to-source language bug introduced in last modification X-Git-Url: https://www.kengrimes.com/gitweb/?p=henge%2Fwebcc.git;a=commitdiff_plain;h=b1da5106b8db9e5ff0113106d32779cdef43408f fixed source-to-source language bug introduced in last modification --- diff --git a/src/Makefile b/src/Makefile index b5e6754..1f9950f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -86,10 +86,11 @@ c_OBJ := $($(c_C)_OBJ) # binaries. MODULES := $(filter-out $(DRIVER_DIR),$(subst /,,$(shell ls -d */))) +#AWK_REVERSE_SQUASH############################################################## # The following awk program reverses the order of a list while also removing # duplicate entries. The effect of this when run on the dependency tree is that # it will remove duplicates occurring in reverse order, allowing the most deeply -# nested libraries to be built, and linked, first. +# nested libraries to be built, and linked, first. ############################## define AWK_REVERSE_SQUASH = awk \ ' @@ -99,17 +100,21 @@ awk \ print "" } ' +#/AWK_REVERSE_SQUASH############################################################# endef -# Compile any source-to-source languages before executing the majority of make +#PREMAKE_SOURCE_COMPILER######################################################### +# Compile any source-to-source languages before executing the majority of make ## +################################################################################# define PREMAKE_SOURCE_COMPILER = # Find the sources for each source-to-source language $(foreach slang,$(SLANGS), -$(eval SLANG_SRC := $(patsubst ./%,%,$(filter-out .%,$(shell find -name "*.$(slang)")))) +$(eval SLANG_SRC := $(patsubst ./%, %,$(shell find -name "*.$(slang)"))) # Foreach target type in the source-to-source language, add this source's # targets to the list of the current source-to-source language targets -$(foreach trg,$($(slang)_TRG), -$(eval SLANG_TRG += $(SLANG_SRC:%.$(slang)=%.$(if $($(slang)_STEM),$($(slang)_STEM).)$(trg)))) +$(eval undefine SLANG_TRG) +$(eval $(foreach trg,$($(slang)_TRG), +$(eval SLANG_TRG += $(SLANG_SRC:%.$(slang)=%.$(if $($(slang)_STEM),$($(slang)_STEM).)$(trg))))) # Stat the source file's last-modified time to the var SRC_TIME $(foreach src,$(SLANG_SRC), $(eval SRC_TIME := $(shell stat -c %Y $(src))) @@ -133,13 +138,12 @@ $(eval BUILDGOALS := $(filter-out clean scrub purge uninstall,$(MAKECMDGOALS))), $(eval BUILDGOALS := all)) $(if $(and $(BUILDGOALS),$(filter $(OLDER_TIME),$(NEWEST_TRG_TIME))), $(eval SHELL_CMD := cd $(dir $(src)) && $($(slang)_C) $($(slang)_FLAGS) $(notdir $(src))) -$(info SHELL_CMD := cd $(dir $(src)) && $($(slang)_C) $($(slang)_FLAGS) $(notdir $(src))) $(info $(SHELL_CMD) $(shell $(SHELL_CMD))) -) +))) # Put these targets on the MAKE_TARGETS list to be removed during "clean", # regardless of whether or not they were built just now. -$(eval MAKE_TARGETS+= $(SLANG_TRG)) -)) +$(eval MAKE_TARGETS += $(SLANG_TRG)) +#/PREMAKE_SOURCE_COMPILER######################################################## endef # Compile a source language to a language that compiles to binary, but only if # our build rule intends to build some kind of target @@ -158,13 +162,14 @@ define SRC_LANG_FLAGS_OPT_DEPS = $(filter-out \ %:,$(shell $($2_C) $3 $4 -MG $1 2> /dev/null)) endef +#SRC_LANG_RULE################################################################### # Given a source and a language, generate a rule to make the object. The second # invocation of gcc per file lists only its local includes, and filters out # anything already caught. Anything remaining should be considered to be # available in the current working directory of the source file(i.e. if you # '#include "something.h"' in 'mymodule/horseradish.c', you would expect to # include 'mymodule/something.h'. this check lets that happen), otherwise it is -# some kind of user error +# some kind of user error ####################################################### define SRC_LANG_RULE = $(if $($1),,$(eval $1 := t)\ $(eval MOD := $(filter $(MODULES),$(firstword $(subst /, ,$(dir $1)))))\ @@ -178,8 +183,13 @@ $(eval MDEPS := $(shell echo $(MDEPS) | sed -e 's@[a-zA-Z0-9\-\+/]*\.\./include@ $(eval ALLDEPS := $(MDEPS) $(DEPS)),\ $(error Cannot generate deps for: $1, file not found))\ $(eval SRC_OBJ := $(basename $1).$($2_OBJ))\ -$(eval MAKE_TARGETS+= $(SRC_OBJ))\ +$(eval MAKE_TARGETS+= $(SRC_OBJ)) +# Find any deps that aren't built yet, which the compiler has flagged +# as missing, but which we know the expected location of libs for +# this language should have their includes in 'LIBINC_DIR' +$(eval BUILDDEPS := $(filter $($2_LIBS:%=%/%),$(ALLDEPS))) +$(eval ALLDEPS := $(filter-out $(BUILDDEPS),$(ALLDEPS)) $(BUILDDEPS:%=$(LIBINC_DIR)/%)) # Object for $1 $(SRC_OBJ): $(ALLDEPS) $($2_C) $$($2_FLAGS) $(FLG) -c -o $$@ $1 @@ -191,8 +201,10 @@ $(eval MAKE_DIRS += $(dir $(DBG_OBJ)))) $(DBG_OBJ): $(ALLDEPS) | $(dir $(DBG_OBJ)) $($2_C) $$($2_FLAGS) $(FLG) -Og -g$($2_DBG) -c -o $$@ $1 )) +#/SRC_LANG_RULE################################################################## endef +#SRC_LANG_DRVRULE################################################################ # establish a build and link rule given a source driver and language ############ define SRC_LANG_DRVRULE = $(eval DRIVER_NAME := $(basename $(notdir $1))) @@ -278,12 +290,13 @@ $(DRIVER_NAME)-run: $(DRIVER_TARG) $(DRIVER_TARG) $(DRIVER_NAME)-d: $(DRIVER_DBGTARG) -#/SRC_LANG_DRVRULE############################################################## +#/SRC_LANG_DRVRULE############################################################### endef +#MODULE_ARCRULE################################################################## # generate rule for turning an entire module's collection of binary objects into # a single locally-linked (no external -L libs) object (for simplified linking -# modules as static libs). +# modules as static libs).####################################################### define MODULE_ARCRULE = $(eval ARCDEPS := $(filter $1/%.$(c_OBJ),$(foreach lang,$(LANGS),$($(lang)_MOD_TRG))))\ $(eval MAKE_TARGETS+= $1.$(c_AROBJ))\ @@ -298,6 +311,7 @@ $(eval MAKE_TARGETS+= .$(c_DBG)/$1.$(c_AROBJ))\ .$(c_DBG)/$1.$(c_AROBJ): $(DBGARCDEPS) | .$(c_DBG)/ $(c_AR) cr $$@ $$^ ) +#/MODULE_ARCRULE################################################################# endef # LANG_LIB_PARENT_BUILDRULE######################################################