From: Niki Roo Date: Sun, 30 Jun 2024 11:35:48 +0000 (+0200) Subject: makefile X-Git-Url: https://git.nikiroo.be/?a=commitdiff_plain;h=2aa1098a12a605a3a7d6624e4b4be87e1d302ac4;p=cutils.git makefile --- diff --git a/Makefile b/Makefile index 7b95964..58ae224 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,7 @@ NAME = cutils NAMES = $(NAME) TESTS = tests-cutils +# You may override these when calling make PREFIX = /usr/local dstdir = bin @@ -24,7 +25,8 @@ build: mess-build $(NAMES) test: mess-test $(TESTS) # Main buildables -M_OPTS=$(MAKECMDGOALS) --no-print-directory PREFIX=$(PREFIX) DEBUG=$(DEBUG) +M_OPTS=$(MAKECMDGOALS) --no-print-directory \ + PREFIX=$(PREFIX) DEBUG=$(DEBUG) dstdir=$(abspath $(dstdir)) $(NAMES) $(TESTS): $(MAKE) -C src/$@ $(M_OPTS) @@ -61,7 +63,7 @@ uninstall: mess-uninstall $(NAMES) man # Messages mess-build: @echo - @echo ">>>>>>>>>> Building $(NAMES)..." + @echo ">>>>>>>>>> Building $(NAMES) in $(dstdir)..." mess-run: @echo @echo ">>>>>>>>>> Running $(NAME)..." @@ -79,7 +81,7 @@ mess-man: @echo ">>>>>>>>>> Manual of $(NAME): $(MAKECMDGOALS)..." mess-test: @echo - @echo ">>>>>>>>>> Building all tests: $(TESTS)..." + @echo ">>>>>>>>>> Building all tests in $(dstdir): $(TESTS)..." mess-run-test: @echo @echo ">>>>>>>>>> Running tests: $(TESTS)..." diff --git a/src/cutils b/src/cutils index 70e6676..780c8d0 160000 --- a/src/cutils +++ b/src/cutils @@ -1 +1 @@ -Subproject commit 70e6676e68300c59384ffb1127fd1330e1d644e7 +Subproject commit 780c8d0590a2f34e68ff896058b3b1a89539dcd8 diff --git a/src/tests-cutils/makefile.d b/src/tests-cutils/makefile.d index 65ef31f..77d6cdc 100644 --- a/src/tests-cutils/makefile.d +++ b/src/tests-cutils/makefile.d @@ -3,7 +3,10 @@ NAME = tests-cutils NAMES = $(NAME) srcdir = $(NAME) -dstdir = ../bin + +ifeq ($(dstdir),) +dstdir = $(srcdir)/bin +endif CFLAGS += -Wall -pedantic -I./ -std=c99 CXXFLAGS += -Wall -pedantic -I./ @@ -29,13 +32,23 @@ build: $(NAMES) $(NAME): deps $(dstdir)/$(NAME) +# Test program, so running = running tests +run: run-test +test: build +run-test: test + @echo + $(dstdir)/$(NAME) +run-test-more: test + @echo + $(dstdir)/$(NAME) --more + ################ # Dependencies # ################ ## Libs (if needed) deps: - $(MAKE) --no-print-directory -C cutils/ cutils - $(MAKE) --no-print-directory -C cutils/ check + $(MAKE) dstdir=$(dstdir) --no-print-directory -C cutils/ cutils + $(MAKE) dstdir=$(dstdir) --no-print-directory -C cutils/ check DEPS=$(dstdir)/libcutils.o $(dstdir)/libcutils-check.o ## Headers @@ -49,22 +62,16 @@ $(dstdir)/$(NAME): $(DEPS) $(OBJECTS) mkdir -p $(dstdir) $(CC) $(CFLAGS) $(LDFLAGS) $(DEPS) $(OBJECTS) -o $@ -# Test program, so running = running tests -run: run-test -test: build - -run-test: test - @echo - $(dstdir)/$(NAME) -run-test-more: test - @echo - $(dstdir)/$(NAME) --more - clean: - rm -f $(OBJECTS) $(DEPENDS) + rm -f $(OBJECTS) + rm -f $(DEPENDS) + rm -f $(DEPS) mrproper: mrpropre mrpropre: clean rm -f $(dstdir)/$(NAME) rmdir $(dstdir) 2>/dev/null || true +install uninstall: + @echo Those are tests, nothing to install/uninstall +