From d87617f212d9dff8d5033b81e19a0740846999fe Mon Sep 17 00:00:00 2001 From: Chris Koeritz Date: Mon, 3 Oct 2016 16:02:59 -0400 Subject: [PATCH] may have fixed annoying make clean bugs discovered that i was reinvoking the make for any cleaning process, just in order to set the CLEAN flag. that's really terribly broken. luckily found the eval command which i can run inside a target to change the value of an existing environment variable. perfect. now in the base clam rules and not getting weird problems from using OTHER_CLEANS --- nucleus/applications/bundler/makefile | 47 +++++++++---------- .../bundler/makefile.bundle_creator | 24 ++++++++++ .../{makefile.stub => makefile.unpacker_stub} | 13 +++++ production/feisty_meow_config.ini | 2 +- scripts/clam/cpp/buildor_gen_deps.sh | 5 ++ scripts/clam/cpp/rules.def | 40 ++++++++++++---- scripts/clam/cpp/variables.def | 2 +- scripts/clam/rules.def | 18 ++++--- scripts/clam/variables.def | 13 +++-- 9 files changed, 118 insertions(+), 46 deletions(-) create mode 100644 nucleus/applications/bundler/makefile.bundle_creator rename nucleus/applications/bundler/{makefile.stub => makefile.unpacker_stub} (69%) diff --git a/nucleus/applications/bundler/makefile b/nucleus/applications/bundler/makefile index 9985446c..fec2e553 100644 --- a/nucleus/applications/bundler/makefile +++ b/nucleus/applications/bundler/makefile @@ -1,29 +1,28 @@ -CONSOLE_MODE = true +include variables.def -include cpp/variables.def +# had to move to this style for these two +# since having a makefile call another was doing +# really unpredictable things, where the makefile +# passed to the -f of make was actually dragging +# in bits from the main makefile. this was +# tested even by saying: +# make -f makefile.stub clean +# which totally isolates it to the stub file, but +# the main makefile was still being pulled in. +# hopefully this approach of having a neutral outer +# maker will get rid of that broken behavior. -PROJECT = app_bundle -TYPE = application -SOURCE = common_bundle.cpp -ifeq "$(OMIT_VERSIONS)" "" - SOURCE += bundler_version.rc -endif -DEFINITIONS += __BUILD_STATIC_APPLICATION__=t -TARGETS = bundle_creator.exe -LAST_TARGETS += make_stub -ifeq "$(COMPILER)" "VISUAL_CPP" - LOCAL_HEADERS += $(THIRD_PARTY_DIR)/zlib/include - LOCAL_LIBRARIES += $(THIRD_PARTY_DIR)/zlib/lib - LIBS_USED += zlib.lib -else - LIBS_USED += z -endif -OTHER_CLEANS += clean_stub +LAST_TARGETS = maker +OTHER_CLEANS = breaker -include cpp/rules.def +include rules.def + +maker: + $(MAKE) -f makefile.bundle_creator + $(MAKE) -f makefile.unpacker_stub + +breaker: + $(MAKE) CLEAN=t -f makefile.bundle_creator clean + $(MAKE) CLEAN=t -f makefile.unpacker_stub clean -make_stub: - $(MAKE) -f makefile.stub -clean_stub: - $(MAKE) -f makefile.stub NO_DEPS=t clean diff --git a/nucleus/applications/bundler/makefile.bundle_creator b/nucleus/applications/bundler/makefile.bundle_creator new file mode 100644 index 00000000..57ac4333 --- /dev/null +++ b/nucleus/applications/bundler/makefile.bundle_creator @@ -0,0 +1,24 @@ +CONSOLE_MODE = true + +include cpp/variables.def + +PROJECT = app_bundle +TYPE = application +SOURCE = common_bundle.cpp +ifeq "$(OMIT_VERSIONS)" "" + SOURCE += bundler_version.rc +endif +DEFINITIONS += __BUILD_STATIC_APPLICATION__=t +TARGETS = bundle_creator.exe + +#hmmm: these should be done with a USE_ZLIB macro. +ifeq "$(COMPILER)" "VISUAL_CPP" + LOCAL_HEADERS += $(THIRD_PARTY_DIR)/zlib/include + LOCAL_LIBRARIES += $(THIRD_PARTY_DIR)/zlib/lib + LIBS_USED += zlib.lib +else + LIBS_USED += z +endif + +include cpp/rules.def + diff --git a/nucleus/applications/bundler/makefile.stub b/nucleus/applications/bundler/makefile.unpacker_stub similarity index 69% rename from nucleus/applications/bundler/makefile.stub rename to nucleus/applications/bundler/makefile.unpacker_stub index 74af1a0c..ad646b9a 100644 --- a/nucleus/applications/bundler/makefile.stub +++ b/nucleus/applications/bundler/makefile.unpacker_stub @@ -10,6 +10,12 @@ ifeq "$(OMIT_VERSIONS)" "" endif DEFINITIONS += __BUILD_STATIC_APPLICATION__=t TARGETS = unpacker_stub.exe + +LAST_TARGETS = show_makefilename +OTHER_CLEANS = mocko + +#hmmm: why on earth is this gunk not already available +# in some specialized vcpp variable? yuck! ifeq "$(COMPILER)" "VISUAL_CPP" LIBS_USED += libcmt.lib shlwapi.lib zlib.lib LOAD_FLAG_PREFIX += -nodefaultlib:msvcrt.lib @@ -22,3 +28,10 @@ endif include cpp/rules.def +show_makefilename: + echo hey the makeflags are $(MAKEFLAGS) + + +mocko: + echo got to other cleans + diff --git a/production/feisty_meow_config.ini b/production/feisty_meow_config.ini index f696d801..6efb11de 100644 --- a/production/feisty_meow_config.ini +++ b/production/feisty_meow_config.ini @@ -3,7 +3,7 @@ # specifies the version of the code that is being constructed here. major=2 minor=140 -revision=82 +revision=84 build=0 # specifies the remainder of the version record info. diff --git a/scripts/clam/cpp/buildor_gen_deps.sh b/scripts/clam/cpp/buildor_gen_deps.sh index c44132c4..c70fe48b 100755 --- a/scripts/clam/cpp/buildor_gen_deps.sh +++ b/scripts/clam/cpp/buildor_gen_deps.sh @@ -13,6 +13,11 @@ # of the License online. Please send any updates to "fred@gruntose.com". # ############################################################################### +if [ ! -z "$CLEAN" ]; then + echo "in cleaning mode, will not build dependencies." + exit 0 +fi + # this script finds all of the headers used by a cpp file and outputs a # list of other cpp files that are probably needed for building it. diff --git a/scripts/clam/cpp/rules.def b/scripts/clam/cpp/rules.def index 722cb7a0..73efdfd4 100644 --- a/scripts/clam/cpp/rules.def +++ b/scripts/clam/cpp/rules.def @@ -360,6 +360,8 @@ ifeq "$(CLEAN)" "" ifneq "$(findstring __BUILD_STATIC_APPLICATION__, $(DEFINITIONS))" "" # generate static build dependencies for all targets in the makefile. GENERATED_DEPS_LIST = $(TARGETS:%.exe=%.gendeps) +else + GENERATED_DEPS_LIST = endif endif @@ -424,10 +426,12 @@ endif # $(CATCHER)$(CC) $(COMPILER_FLAGS) -c $< $(OBJECT_NAME_FLAG)$(TEMP)/$@ #endif +ifeq "$(CLEAN)" "" # recreate dependencies for static applications. %.gendeps: %.cpp @echo "Generating Static Deps: $*.cpp" $(CATCHER)$(CLAM_DIR)/cpp/buildor_gen_deps.sh "$*.cpp" +endif ############################################################################ @@ -663,7 +667,7 @@ endif ifneq "$(CLEAN)" "" NO_DEPS = t # no dependencies get left when we are cleaning up. - $(shell rm -f $(DEPS_FILE)) +# $(shell rm -f $(DEPS_FILE)) endif ifneq "$(NO_COMPILE)" "" # non compiling projects do not need dependencies. @@ -675,17 +679,10 @@ ifneq "$(REBUILD)" "" $(shell rm -f $(DEPS_FILE)) endif -# includes the auto-dependency information. the dependency file is checked -# for being up-to-date. if not, it gets rebuilt and the make is restarted. -ifeq "$(CLEAN)" "" - ifeq "$(NO_DEPS)" "" - include $(DEPS_FILE) - endif -endif - # preserves intermediate files from being deleted. ifeq "$(CLEAN)" "" -.PRECIOUS: $(OBJECT_DIR)/%.obj $(OBJECT_DIR)/%.res $(OBJECT_DIR)/%.resources +.PRECIOUS: $(OBJECT_DIR)/%.obj $(OBJECT_DIR)/%.res $(OBJECT_DIR)/%.resources $(OBJECT_DIR)/%.deps +#hmmm: added above deps. maybe not right. endif # zaps things when they could not be created correctly. @@ -703,6 +700,7 @@ ifneq "$(NO_DEPS)" "" $(DEPS_FILE): $(PARAMETER_FILE) else + ifeq "$(CLEAN)" "" deps: $(DEPS_FILE) # this causes the dependency file to be regenerated if the sources or libs @@ -734,6 +732,12 @@ else # $(CATCHER)$(CLAM_BINARY_DIR)/makedep$(EXE_END) $(DEPENDENCY_DEFINITIONS:%=-D%) $(DEPENDENCY_ADDITIONS) -f$@ -o.obj -p$(OBJECT_DIR)/ -w 420 $(COMPILER_HEADER_DIR:%=-X%) $(THIRD_PARTY_DIR:%=-X%) -- $(COMPILER_FLAGS) $(SOURCE) $(EXE_CPPS) @echo $@ >$(SUBMAKE_FLAG) endif # non-compile. + else # cleaning. + # makes the dependencies a no-op for cleaning. + deps: $(PARAMETER_FILE) + + $(DEPS_FILE): $(PARAMETER_FILE) + endif endif # no-deps. ############################################################################ @@ -745,6 +749,22 @@ check_requirements: ############################################################################ +# includes the auto-dependency information. the dependency file is checked +# for being up-to-date. if not, it gets rebuilt and the make is restarted. +ifeq "$(CLEAN)" "" + ifeq "$(NO_DEPS)" "" + + # thank the buddha for this bit of code, or at least thank this page: + # http://stackoverflow.com/questions/5553352/how-do-i-check-if-file-exists-in-makefile + ifneq ("$(wildcard $(DEPS_FILE))","") + include $(DEPS_FILE) + endif + + endif +endif + +############################################################################ + # calls the script for preparing output directories and such. pre_compilation: $(HIDESH)$(CLAM_DIR)/cpp/preconditions.sh diff --git a/scripts/clam/cpp/variables.def b/scripts/clam/cpp/variables.def index baa42e1f..222a9d6d 100644 --- a/scripts/clam/cpp/variables.def +++ b/scripts/clam/cpp/variables.def @@ -287,7 +287,7 @@ export DEPS_FILE = $(OUTPUT_PATH)/$(PROJECT).deps # Add the obligatory junk to be cleaned up. Individual compiler sections # should customize this by adding their object output directories. -CLEANUPS += $(ACTUAL_TARGETS) $(OUTPUT_PATH) +CLEANUPS += $(ACTUAL_TARGETS) $(OUTPUT_PATH) $(DEPS_FILE) # "GENDEPS" is a flag that causes dependencies to be generated into # statically built applications. diff --git a/scripts/clam/rules.def b/scripts/clam/rules.def index e9f91b15..a526fb1f 100644 --- a/scripts/clam/rules.def +++ b/scripts/clam/rules.def @@ -110,10 +110,13 @@ exit 0' # files and such that were created by the project. it invokes the makefile # again with the CLEAN variable defined so that this can be passed down into # all subsequent makes. -clean: - $(HIDER)$(MAKE) --silent CLEAN=t ready_to_clean +clean: set_cleaner_variable clean_subdirs $(OTHER_CLEANS) ready_to_clean + # no code here. -ready_to_clean: $(OTHER_CLEANS) clean_subdirs +set_cleaner_variable: + $(eval CLEAN := true) + +ready_to_clean: @echo Whacking [$(CLEANUPS)] $(HIDESH) -c '\ echo the other cleans were: $(OTHER_CLEANS); \ @@ -127,9 +130,12 @@ fi' # "clean_subdirs" travels down each subdirectory and cleans using make. clean_subdirs: $(HIDESH) -c '\ -for i in *; do \ - if [ -d "$$i" ]; then \ - if [ -f "$$i/$(MAKEFILE_NAME)" -a ! "$$i" -ef `pwd` ]; then \ +for smoot87 in *; do \ + if [ -d "$$smoot87" ]; then \ +echo "got inside first check of it being dir: $$smoot87"; \ + if [ -f "$$smoot87/$(MAKEFILE_NAME)" -a ! "$$smoot87" -ef `pwd` ]; then \ +echo "got inside barriers, with filename=$$smoot87 and all conditions met."; \ +echo "the interesting one was: [$(test ! "$$smoot87" -ef `pwd` )]"; \ (cd "$$i"; $(MAKE) --silent NOT_FIRST_MAKE=t -f $(MAKEFILE_NAME) clean); \ else \ echo "Skipping makefile-less directory $$i..."; \ diff --git a/scripts/clam/variables.def b/scripts/clam/variables.def index 1b60dc4d..6acd2056 100644 --- a/scripts/clam/variables.def +++ b/scripts/clam/variables.def @@ -187,14 +187,19 @@ include $(PARAMETER_FILE) ############################################################################ -# "CLEAN" is an powerful flag that affects what clam does. if the flag is +# "CLEAN" is a powerful flag that affects what clam does. if the flag is # non-empty, then nothing will be built and every generated file that is -# known about will be deleted. +# known about will be deleted. it is intended as exported, since then sub- +# shells know that they are cleaning and we do not have to pass them a +# target. +#hmmm: (although we do?) export CLEAN # "CLEANUPS" are things to be removed by the "make clean" command. -#CLEANUPS = +undefine CLEANUPS # OTHER_CLEANS are targets to execute before performing the main clean up. -#OTHER_CLEANS = +# we intentionally reset this here to avoid a polluted variable getting +# to us from a previous make. +undefine OTHER_CLEANS # sets the temporary directory. export CLAM_TMP -- 2.34.1