From fa7e389c2915c80fef7d5c66c7807e0965b46f0f Mon Sep 17 00:00:00 2001 From: Niki Roo Date: Tue, 25 Jun 2024 20:08:38 +0200 Subject: [PATCH] improve makefiles --- Makefile | 16 ++++++---------- src/tests/makefile.d | 29 +++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 4100b9c..802ebaf 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ NAME = cutils dstdir = bin .PHONY: all run clean mrpropre mrpropre love debug doc man \ - test tests run-test run-tests run-test-more run-tests-more \ + test run-test run-test-more \ mess-run mess-clean mess-propre mess-doc mess-man \ mess-test mess-run-test mess-run-test-more \ $(NAME) utils net check \ @@ -11,12 +11,13 @@ dstdir = bin all: $(NAME) # Sub makes: +M_OPTS=$(MAKECMDGOALS) --no-print-directory PREFIX=$(PREFIX) MK: - @$(MAKE) -C src/$(NAME) $(MAKECMDGOALS) DEBUG=$(DEBUG) + @$(MAKE) -C src/$(NAME) $(M_OPTS) DEBUG=$(DEBUG) MKTEST: - @$(MAKE) -C src/tests $(MAKECMDGOALS) DEBUG=$(DEBUG) + @$(MAKE) -C src/tests $(M_OPTS) DEBUG=$(DEBUG) MKMAN: - @$(MAKE) -f man.d $(MAKECMDGOALS) NAME=$(NAME) PREFIX=$(PREFIX) + @$(MAKE) -f man.d $(M_OPTS) NAME=$(NAME) # Main buildables $(NAME): utils net check @@ -29,11 +30,8 @@ run: mess-run @echo Nothing to run, this is a library # Test + run test -tests: test test: mess-test MKTEST -run-tests: run-test run-test: mess-run-test MKTEST -run-tests-more: run-test-more run-test-more: mess-run-test-more MKTEST # Doc/man/misc @@ -43,7 +41,7 @@ man: mess-man MKMAN love: @echo " ...not war." debug: - $(MAKE) DEBUG=1 + $(MAKE) $(M_OPTS) DEBUG=1 # Clean clean: mess-clean MK MKTEST @@ -72,10 +70,8 @@ mess-test: @echo ">>>>>>>>>> Building tests for $(NAME)..." mess-run-test: @echo ">>>>>>>>>> Running tests on $(NAME)..." - @echo mess-run-test-more: @echo ">>>>>>>>>> Running more tests on $(NAME)..." - @echo mess-install: @echo ">>>>>>>>>> Installing $(NAME) into $(PREFIX)..." mess-uninstall: diff --git a/src/tests/makefile.d b/src/tests/makefile.d index ba44212..5116e76 100644 --- a/src/tests/makefile.d +++ b/src/tests/makefile.d @@ -15,25 +15,38 @@ endif .PHONY: all install uninstall clean mrpropre mrpropre \ test run run-test run-test-more +SOURCES=$(wildcard $(srcdir)/*.c) +HEADERS=$(wildcard $(srcdir)/*.h) +OBJECTS=$(SOURCES:%.c=%.o) + +################ +# Dependencies # +################ +OBJECTS+=$(dstdir)/libcutils.o +OBJECTS+=$(dstdir)/libcutils-check.o +$(dstdir)/libcutils.o: + $(MAKE) --no-print-directory -C cutils/ utils +$(dstdir)/libcutils-check.o: + $(MAKE) --no-print-directory -C cutils/ check +################ + all: test test: $(dstdir)/tests run: run-test run-test: test - $(dstdir)/tests + @echo + @$(dstdir)/tests run-test-more: test - $(dstdir)/tests --more + @echo + @$(dstdir)/tests --more -SOURCES=$(wildcard $(srcdir)/*.c) -HEADERS=$(wildcard $(srcdir)/*.h) -OBJECTS=$(SOURCES:%.c=%.o) -OBJECTS+=$($(dstdir)/libcutils.o) -$(dstdir)/tests: $(OBJECTS) $(dstdir)/libcutils-check.o +$(dstdir)/tests: $(OBJECTS) mkdir -p $(dstdir) - $(CC) $(CFLAGS) $(LDFLAGS) $(OBJECTS) $(dstdir)/libcutils-check.o -o $@ + $(CC) $(CFLAGS) $(LDFLAGS) $(OBJECTS) -o $@ clean: rm -f $(srcdir)/*.o -- 2.27.0