From: Niki Roo Date: Sun, 30 Jun 2024 09:36:12 +0000 (+0200) Subject: makefile X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=b56984c18d057545654fb22147ed913d4e30c720;p=cutils.git makefile --- diff --git a/src/cutils b/src/cutils index 9e29e2f..5b43528 160000 --- a/src/cutils +++ b/src/cutils @@ -1 +1 @@ -Subproject commit 9e29e2f55d36a2e05a3420825b8ecc33006a45eb +Subproject commit 5b43528760ac0faf92931578d3801d6f8d4708fa diff --git a/src/tests-cutils/makefile.d b/src/tests-cutils/makefile.d index c42debe..3ee2928 100644 --- a/src/tests-cutils/makefile.d +++ b/src/tests-cutils/makefile.d @@ -1,6 +1,7 @@ # Note: 99+ required for for-loop initial declaration (CentOS 6) NAME = tests-cutils +NAMES = $(NAME) srcdir = $(NAME) dstdir = ../bin @@ -15,7 +16,7 @@ CXXFLAGS += -ggdb -O0 endif .PHONY: all build install uninstall clean mrpropre mrpropre \ - $(NAME) test run run-test run-test-more + $(NAME) deps test run run-test run-test-more SOURCES=$(wildcard $(srcdir)/*.c) HEADERS=$(wildcard $(srcdir)/*.h) @@ -25,24 +26,29 @@ OBJECTS=$(SOURCES:%.c=%.o) all: build -build: $(NAME) +build: $(NAMES) -$(NAME): $(dstdir)/$(NAME) +$(NAME): deps $(dstdir)/$(NAME) ################ # Dependencies # ################ -OBJECTS+=$(dstdir)/libcutils.o -OBJECTS+=$(dstdir)/libcutils-check.o -$(dstdir)/libcutils.o: +## Libs (if needed) +deps: $(MAKE) --no-print-directory -C cutils/ cutils -$(dstdir)/libcutils-check.o: $(MAKE) --no-print-directory -C cutils/ check +DEPS=$(dstdir)/libcutils.o $(dstdir)/libcutils-check.o + +## Headers +DEPENDS=$(SOURCES:%.c=%.d) +-include $(DEPENDS) +%.o: %.c + $(CC) $(CCFLAGS) -MMD -MP -c $< -o $@ ################ -$(dstdir)/$(NAME): $(OBJECTS) +$(dstdir)/$(NAME): $(DEPS) $(OBJECTS) mkdir -p $(dstdir) - $(CC) $(CFLAGS) $(LDFLAGS) $(OBJECTS) -o $@ + $(CC) $(CFLAGS) $(LDFLAGS) $(DEPS) $(OBJECTS) -o $@ # Test program, so running = running tests run: run-test @@ -56,7 +62,7 @@ run-test-more: test @$(dstdir)/$(NAME) --more clean: - rm -f $(srcdir)/*.o $(srcdir)/*/*.o + rm -f $(OBJECTS) $(DEPENDS) mrproper: mrpropre mrpropre: clean