From 1667ad0a5a99232cc5c1084e3d2cfab96c5d9694 Mon Sep 17 00:00:00 2001 From: Thomas Walker Lynch Date: Tue, 21 Oct 2025 02:49:14 +0000 Subject: [PATCH] putting back former makefile --- developer/make/target_library_cli.mk | 130 ++++++++++-------- ...~615e28cc3e6596ffdf1b39fe2942bd231e5895ae~ | 79 +++++++++++ ...~9c69a16bb0bfbfcf05f181fa83ea40e383541e58~ | 107 ++++++++++++++ ...~b3f0a770f2747b7bf83652f0b085e1549026b398~ | 93 +++++++++++++ 4 files changed, 351 insertions(+), 58 deletions(-) create mode 100644 developer/make/target_library_cli.mk.~615e28cc3e6596ffdf1b39fe2942bd231e5895ae~ create mode 100644 developer/make/target_library_cli.mk.~9c69a16bb0bfbfcf05f181fa83ea40e383541e58~ create mode 100644 developer/make/target_library_cli.mk.~b3f0a770f2747b7bf83652f0b085e1549026b398~ diff --git a/developer/make/target_library_cli.mk b/developer/make/target_library_cli.mk index 1a5a6b8..4a4c203 100644 --- a/developer/make/target_library_cli.mk +++ b/developer/make/target_library_cli.mk @@ -1,93 +1,107 @@ .SUFFIXES: +# make/target_lib_cli.mk — build *.lib.c and *.cli.c +# written for the Harmony skeleton, always invoked from cwd $REPO_HOME/ -# target_library_cli.mk — build *.lib.c → static lib, *.cli.c → executables -# invoked from $REPO_HOME/ (cwd = developer root) +#-------------------------------------------------------------------------------- +# files have two suffixes by convention, e.g.: X.lib.c or Y.cli.c +# -# ---- defaults (override from outer make if desired) -LIBFILE ?= scratchpad/librabbit.a -EXECDIR ?= bin +# warn if there is no compiler +ifeq ($(C),) + @printf "target_lib_cli.mk: no C compiler specified.\n" +endif -# ---- ensure dirs exist -$(shell mkdir -p scratchpad $(EXECDIR)) - -# ---- discover sources (keep only existing src dirs) +# keep only the source directories that are in the file system SRCDIR_LIST := $(wildcard $(SRCDIR_LIST)) -C_SOURCE_LIB := $(foreach dir,$(SRCDIR_LIST),$(wildcard $(dir)/*.lib.c)) -C_SOURCE_EXEC := $(foreach dir,$(SRCDIR_LIST),$(wildcard $(dir)/*.cli.c)) -# ---- derive names -C_BASE_LIB := $(sort $(patsubst %.lib.c,%,$(notdir $(C_SOURCE_LIB)))) -C_BASE_EXEC := $(sort $(patsubst %.cli.c,%,$(notdir $(C_SOURCE_EXEC)))) +# warn if the SRCDIR_list is empty +ifeq ($(SRCDIR_LIST),) + @printf "target_lib_cli.mk: empty SRCDIR_LIST\n" +endif -OBJECT_LIB := $(patsubst %,scratchpad/%.lib.o,$(C_BASE_LIB)) -OBJECT_EXEC := $(patsubst %,scratchpad/%.cli.o,$(C_BASE_EXEC)) -EXEC := $(patsubst %,$(EXECDIR)/%,$(C_BASE_EXEC)) +# duplicate source file names in different directories will cause +# problems with this makefile -# ---- headers/flags -INCFLAG_List := $(foreach dir,$(SRCDIR_LIST),-I $(dir)) -CFLAGS += $(INCFLAG_List) +C_SOURCE_LIB := $(foreach dir, $(SRCDIR_LIST), $(wildcard $(dir)/*.lib.c)) +C_SOURCE_EXEC := $(foreach dir, $(SRCDIR_LIST), $(wildcard $(dir)/*.cli.c)) + +#remove the suffix to get base name +C_BASE_LIB= $(sort $(patsubst %.lib.c, %, $(notdir $(C_SOURCE_LIB)))) +C_BASE_EXEC= $(sort $(patsubst %.cli.c, %, $(notdir $(C_SOURCE_EXEC)))) + +# two sets of object files, one for the lib, and one for the command line interface progs +OBJECT_LIB= $(patsubst %, scratchpad/%.lib.o, $(C_BASE_LIB)) +OBJECT_EXEC= $(patsubst %, scratchpad/%.cli.o, $(C_BASE_EXEC)) -# ---- depfiles -include $(OBJECT_LIB:.o=.d) $(OBJECT_EXEC:.o=.d) -# ---- vpath for multi-dir builds -vpath %.lib.c $(SRCDIR_LIST) -vpath %.cli.c $(SRCDIR_LIST) +# executables are made from EXEC sources +EXEC= $(patsubst %, $(EXECDIR)/%, $(C_BASE_EXEC)) -# ===== targets ===== +# the new C programming style gated sections in source instead of header filesheader +INCFLAG_List := $(foreach dir, $(SRCDIR_LIST), -I $(dir)) +CFLAGS += $(INCFLAG_List) +#-------------------------------------------------------------------------------- +# targets + +# when no target is given make uses the first target, this one .PHONY: usage usage: - @echo example: make library - @echo example: make cli - @echo example: make library cli - @echo example: make all + @echo example usage: make clean + @echo example usage: make library + @echo example usage: make cli + @echo example usage: make library cli .PHONY: version version: - @echo target_library_cli.mk version 7.3 - @if [ -n "$(C)" ]; then $(C) -v; fi; /bin/make -v + @echo makefile version 7.1 + if [ ! -z "$(C)" ]; then $(C) -v; fi + /bin/make -v .PHONY: information information: @printf "· → Unicode middle dot — visible: [%b]\n" "·" - @echo "SRCDIR_LIST: $(SRCDIR_LIST)" - @echo "C_SOURCE_LIB: $(C_SOURCE_LIB)" - @echo "C_SOURCE_EXEC: $(C_SOURCE_EXEC)" - @echo "C_BASE_LIB: $(C_BASE_LIB)" - @echo "C_BASE_EXEC: $(C_BASE_EXEC)" - @echo "OBJECT_LIB: $(OBJECT_LIB)" - @echo "OBJECT_EXEC: $(OBJECT_EXEC)" - @echo "EXEC: $(EXEC)" - @echo "INCFLAG_List: $(INCFLAG_List)" - @echo "LIBFILE: $(LIBFILE)" - @echo "EXECDIR: $(EXECDIR)" - -.PHONY: all -all: library cli + @echo "SRCDIR_LIST: " $(SRCDIR_LIST) + @echo "C_SOURCE_LIB: " $(C_SOURCE_LIB) + @echo "C_SOURCE_EXEC: " $(C_SOURCE_EXEC) + @echo "C_BASE_LIB: " $(C_BASE_LIB) + @echo "C_BASE_EXEC: " $(C_BASE_EXEC) + @echo "OBJECT_LIB: " $(OBJECT_LIB) + @echo "OBJECT_EXEC: " $(OBJECT_EXEC) + @echo "EXEC: " $(EXEC) + @echo "INCFLAG_List: " $(INCFLAG_List) .PHONY: library -library: $(LIBFILE) +library: $(LIBFILE) +#$(LIBFILE): $(OBJECT_LIB) $(DEPFILE) $(LIBFILE): $(OBJECT_LIB) - ar rcs $@ $^ + ar rcs $(LIBFILE) $(OBJECT_LIB) -.PHONY: cli -cli: $(LIBFILE) $(EXEC) -# ===== recipes ===== +.PHONY: cli +#cli: $(LIBFILE) $(DEPFILE) +cli: $(LIBFILE) + make sub_cli -scratchpad/%.lib.o: %.lib.c - $(C) $(CFLAGS) -MMD -MP -MF $(@:.o=.d) -c $< -o $@ +.PHONY: sub_cli +sub_cli: $(EXEC) -scratchpad/%.cli.o: %.cli.c - $(C) $(CFLAGS) -MMD -MP -MF $(@:.o=.d) -c $< -o $@ - -$(EXECDIR)/%: scratchpad/%.cli.o $(LIBFILE) - $(C) -o $@ $< $(LIBFILE) $(LINKFLAGS) +# generally better to use the project local clean scripts, but this will make it so that the make targets can be run again .PHONY: clean clean: rm -f $(LIBFILE) for obj in $(OBJECT_LIB) $(OBJECT_EXEC); do rm -f $$obj $${obj%.o}.d || true; done - for i in $(EXEC); do [ -e $$i ] && rm -f $$i || true; done + for i in $(EXEC); do [ -e $$i ] && rm $$i || true; done + + +# recipes +vpath %.c $(SRCDIR_LIST) +scratchpad/%.o: %.c + $(C) $(CFLAGS) -o $@ -c $< + +$(EXECDIR)/%: scratchpad/%.cli.o $(LIBFILE) + $(C) -o $@ $< $(LIBFILE) $(LINKFLAGS) + diff --git a/developer/make/target_library_cli.mk.~615e28cc3e6596ffdf1b39fe2942bd231e5895ae~ b/developer/make/target_library_cli.mk.~615e28cc3e6596ffdf1b39fe2942bd231e5895ae~ new file mode 100644 index 0000000..1af08db --- /dev/null +++ b/developer/make/target_library_cli.mk.~615e28cc3e6596ffdf1b39fe2942bd231e5895ae~ @@ -0,0 +1,79 @@ +.SUFFIXES + +# ---- phony +.PHONY: usage version information library cli clean + +# ---- defaults (safe fallbacks; override from outer make if desired) +LIBFILE ?= scratchpad/librabbit.a +EXECDIR ?= bin + +# ---- ensure dirs exist (lazy, portable) +$(shell mkdir -p scratchpad $(EXECDIR)) + +# ---- sources → objects +C_SOURCE_LIB := $(foreach dir,$(SRCDIR_LIST),$(wildcard $(dir)/*.lib.c)) +C_SOURCE_EXEC := $(foreach dir,$(SRCDIR_LIST),$(wildcard $(dir)/*.cli.c)) + +C_BASE_LIB := $(sort $(patsubst %.lib.c,%,$(notdir $(C_SOURCE_LIB)))) +C_BASE_EXEC := $(sort $(patsubst %.cli.c,%,$(notdir $(C_SOURCE_EXEC)))) + +OBJECT_LIB := $(patsubst %,scratchpad/%.lib.o,$(C_BASE_LIB)) +OBJECT_EXEC := $(patsubst %,scratchpad/%.cli.o,$(C_BASE_EXEC)) + +EXEC := $(patsubst %,$(EXECDIR)/%,$(C_BASE_EXEC)) + +# ---- headers +INCFLAG_List := $(foreach dir,$(SRCDIR_LIST),-I $(dir)) +CFLAGS += $(INCFLAG_List) + +# ---- depfiles +-include $(OBJECT_LIB:.o=.d) $(OBJECT_EXEC:.o=.d) + +# ---- targets +usage: + @echo example: make library + @echo example: make cli + @echo example: make library cli + +version: + @echo makefile version 7.2 + @if [ -n "$(C)" ]; then $(C) -v; fi; /bin/make -v + +information: + @printf "· → Unicode middle dot — visible: [%b]\n" "·" + @echo "SRCDIR_LIST: $(SRCDIR_LIST)" + @echo "C_SOURCE_LIB: $(C_SOURCE_LIB)" + @echo "C_SOURCE_EXEC: $(C_SOURCE_EXEC)" + @echo "C_BASE_LIB: $(C_BASE_LIB)" + @echo "C_BASE_EXEC: $(C_BASE_EXEC)" + @echo "OBJECT_LIB: $(OBJECT_LIB)" + @echo "OBJECT_EXEC: $(OBJECT_EXEC)" + @echo "EXEC: $(EXEC)" + @echo "INCFLAG_List: $(INCFLAG_List)" + +# library builds the static archive from *.lib.o +library: $(LIBFILE) + +$(LIBFILE): $(OBJECT_LIB) + ar rcs $@ $^ + +# cli builds the executables; NO recursive make +cli: $(LIBFILE) $(EXEC) + +# ---- recipes +vpath %.lib.c $(SRCDIR_LIST) +vpath %.cli.c $(SRCDIR_LIST) + +scratchpad/%.lib.o: %.lib.c + $(C) $(CFLAGS) -MMD -MP -MF $(@:.o=.d) -c $< -o $@ + +scratchpad/%.cli.o: %.cli.c + $(C) $(CFLAGS) -MMD -MP -MF $(@:.o=.d) -c $< -o $@ + +$(EXECDIR)/%: scratchpad/%.cli.o $(LIBFILE) + $(C) -o $@ $< $(LIBFILE) $(LINKFLAGS) + +clean: + rm -f $(LIBFILE) + for obj in $(OBJECT_LIB) $(OBJECT_EXEC); do rm -f $$obj $${obj%.o}.d || true; done + for i in $(EXEC); do [ -e $$i ] && rm -f $$i || true; done diff --git a/developer/make/target_library_cli.mk.~9c69a16bb0bfbfcf05f181fa83ea40e383541e58~ b/developer/make/target_library_cli.mk.~9c69a16bb0bfbfcf05f181fa83ea40e383541e58~ new file mode 100644 index 0000000..e933824 --- /dev/null +++ b/developer/make/target_library_cli.mk.~9c69a16bb0bfbfcf05f181fa83ea40e383541e58~ @@ -0,0 +1,107 @@ +.SUFFIXES: +# make/target_lib_cli.mk — build *.lib.c and *.cli.c +# written for the Harmony skeleton, always invoked from cwd $REPO_HOME/ + +#-------------------------------------------------------------------------------- +# files have two suffixes by convention, e.g.: X.lib.c or Y.cli.c +# + +# bail early if there is no compiler +ifeq ($(C),) + @printf "target_lib_cli.mk: no C compiler specified.\n" +endif + +# keep only the source directories that are in the file system +SRCDIR_LIST := $(wildcard $(SRCDIR_LIST)) + +# bail early if the SRCDIR_list is empty +ifeq ($(SRCDIR_LIST),) + @printf "target_lib_cli.mk: empty SRCDIR_LIST\n" +endif + +# duplicate source file names in different directories will cause +# problems with this makefile + +C_SOURCE_LIB := $(foreach dir, $(SRCDIR_LIST), $(wildcard $(dir)/*.lib.c)) +C_SOURCE_EXEC := $(foreach dir, $(SRCDIR_LIST), $(wildcard $(dir)/*.cli.c)) + +#remove the suffix to get base name +C_BASE_LIB= $(sort $(patsubst %.lib.c, %, $(notdir $(C_SOURCE_LIB)))) +C_BASE_EXEC= $(sort $(patsubst %.cli.c, %, $(notdir $(C_SOURCE_EXEC)))) + +# two sets of object files, one for the lib, and one for the command line interface progs +OBJECT_LIB= $(patsubst %, scratchpad/%.lib.o, $(C_BASE_LIB)) +OBJECT_EXEC= $(patsubst %, scratchpad/%.cli.o, $(C_BASE_EXEC)) + +-include $(OBJECT_LIB:.o=.d) $(OBJECT_EXEC:.o=.d) + +# executables are made from EXEC sources +EXEC= $(patsubst %, $(EXECDIR)/%, $(C_BASE_EXEC)) + +# the new C programming style gated sections in source instead of header filesheader +INCFLAG_List := $(foreach dir, $(SRCDIR_LIST), -I $(dir)) +CFLAGS += $(INCFLAG_List) + +#-------------------------------------------------------------------------------- +# targets + +# when no target is given make uses the first target, this one +.PHONY: usage +usage: + @echo example usage: make clean + @echo example usage: make library + @echo example usage: make cli + @echo example usage: make library cli + +.PHONY: version +version: + @echo makefile version 7.1 + if [ ! -z "$(C)" ]; then $(C) -v; fi + /bin/make -v + +.PHONY: information +information: + @printf "· → Unicode middle dot — visible: [%b]\n" "·" + @echo "SRCDIR_LIST: " $(SRCDIR_LIST) + @echo "C_SOURCE_LIB: " $(C_SOURCE_LIB) + @echo "C_SOURCE_EXEC: " $(C_SOURCE_EXEC) + @echo "C_BASE_LIB: " $(C_BASE_LIB) + @echo "C_BASE_EXEC: " $(C_BASE_EXEC) + @echo "OBJECT_LIB: " $(OBJECT_LIB) + @echo "OBJECT_EXEC: " $(OBJECT_EXEC) + @echo "EXEC: " $(EXEC) + @echo "INCFLAG_List: " $(INCFLAG_List) + +.PHONY: library +library: $(LIBFILE) + +#$(LIBFILE): $(OBJECT_LIB) $(DEPFILE) +$(LIBFILE): $(OBJECT_LIB) + ar rcs $(LIBFILE) $(OBJECT_LIB) + + +.PHONY: cli +#cli: $(LIBFILE) $(DEPFILE) +cli: $(LIBFILE) + make sub_cli + +.PHONY: sub_cli +sub_cli: $(EXEC) + +# generally better to use the project local clean scripts, but this will make it so that the make targets can be run again + +.PHONY: clean +clean: + rm -f $(LIBFILE) + for obj in $(OBJECT_LIB) $(OBJECT_EXEC); do rm -f $$obj $${obj%.o}.d || true; done + for i in $(EXEC); do [ -e $$i ] && rm $$i || true; done + + +# recipes +vpath %.c $(SRCDIR_LIST) +scratchpad/%.o: %.c + $(C) $(CFLAGS) -o $@ -c $< + +$(EXECDIR)/%: scratchpad/%.cli.o $(LIBFILE) + $(C) -o $@ $< $(LIBFILE) $(LINKFLAGS) + diff --git a/developer/make/target_library_cli.mk.~b3f0a770f2747b7bf83652f0b085e1549026b398~ b/developer/make/target_library_cli.mk.~b3f0a770f2747b7bf83652f0b085e1549026b398~ new file mode 100644 index 0000000..1a5a6b8 --- /dev/null +++ b/developer/make/target_library_cli.mk.~b3f0a770f2747b7bf83652f0b085e1549026b398~ @@ -0,0 +1,93 @@ +.SUFFIXES: + +# target_library_cli.mk — build *.lib.c → static lib, *.cli.c → executables +# invoked from $REPO_HOME/ (cwd = developer root) + +# ---- defaults (override from outer make if desired) +LIBFILE ?= scratchpad/librabbit.a +EXECDIR ?= bin + +# ---- ensure dirs exist +$(shell mkdir -p scratchpad $(EXECDIR)) + +# ---- discover sources (keep only existing src dirs) +SRCDIR_LIST := $(wildcard $(SRCDIR_LIST)) +C_SOURCE_LIB := $(foreach dir,$(SRCDIR_LIST),$(wildcard $(dir)/*.lib.c)) +C_SOURCE_EXEC := $(foreach dir,$(SRCDIR_LIST),$(wildcard $(dir)/*.cli.c)) + +# ---- derive names +C_BASE_LIB := $(sort $(patsubst %.lib.c,%,$(notdir $(C_SOURCE_LIB)))) +C_BASE_EXEC := $(sort $(patsubst %.cli.c,%,$(notdir $(C_SOURCE_EXEC)))) + +OBJECT_LIB := $(patsubst %,scratchpad/%.lib.o,$(C_BASE_LIB)) +OBJECT_EXEC := $(patsubst %,scratchpad/%.cli.o,$(C_BASE_EXEC)) +EXEC := $(patsubst %,$(EXECDIR)/%,$(C_BASE_EXEC)) + +# ---- headers/flags +INCFLAG_List := $(foreach dir,$(SRCDIR_LIST),-I $(dir)) +CFLAGS += $(INCFLAG_List) + +# ---- depfiles +-include $(OBJECT_LIB:.o=.d) $(OBJECT_EXEC:.o=.d) + +# ---- vpath for multi-dir builds +vpath %.lib.c $(SRCDIR_LIST) +vpath %.cli.c $(SRCDIR_LIST) + +# ===== targets ===== + +.PHONY: usage +usage: + @echo example: make library + @echo example: make cli + @echo example: make library cli + @echo example: make all + +.PHONY: version +version: + @echo target_library_cli.mk version 7.3 + @if [ -n "$(C)" ]; then $(C) -v; fi; /bin/make -v + +.PHONY: information +information: + @printf "· → Unicode middle dot — visible: [%b]\n" "·" + @echo "SRCDIR_LIST: $(SRCDIR_LIST)" + @echo "C_SOURCE_LIB: $(C_SOURCE_LIB)" + @echo "C_SOURCE_EXEC: $(C_SOURCE_EXEC)" + @echo "C_BASE_LIB: $(C_BASE_LIB)" + @echo "C_BASE_EXEC: $(C_BASE_EXEC)" + @echo "OBJECT_LIB: $(OBJECT_LIB)" + @echo "OBJECT_EXEC: $(OBJECT_EXEC)" + @echo "EXEC: $(EXEC)" + @echo "INCFLAG_List: $(INCFLAG_List)" + @echo "LIBFILE: $(LIBFILE)" + @echo "EXECDIR: $(EXECDIR)" + +.PHONY: all +all: library cli + +.PHONY: library +library: $(LIBFILE) + +$(LIBFILE): $(OBJECT_LIB) + ar rcs $@ $^ + +.PHONY: cli +cli: $(LIBFILE) $(EXEC) + +# ===== recipes ===== + +scratchpad/%.lib.o: %.lib.c + $(C) $(CFLAGS) -MMD -MP -MF $(@:.o=.d) -c $< -o $@ + +scratchpad/%.cli.o: %.cli.c + $(C) $(CFLAGS) -MMD -MP -MF $(@:.o=.d) -c $< -o $@ + +$(EXECDIR)/%: scratchpad/%.cli.o $(LIBFILE) + $(C) -o $@ $< $(LIBFILE) $(LINKFLAGS) + +.PHONY: clean +clean: + rm -f $(LIBFILE) + for obj in $(OBJECT_LIB) $(OBJECT_EXEC); do rm -f $$obj $${obj%.o}.d || true; done + for i in $(EXEC); do [ -e $$i ] && rm -f $$i || true; done -- 2.20.1