From: Niki Roo Date: Thu, 27 Jun 2024 14:59:43 +0000 (+0200) Subject: makefiles X-Git-Url: http://git.nikiroo.be/?a=commitdiff_plain;h=1c3044c56cb58890730407ba39675fcf9342d8d1;p=cutils.git makefiles --- diff --git a/Makefile b/Makefile index a71c67a..d3398f0 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ # Simply pass everything to makefile.d, but calling from "../" -.PHONY: MK all install uninstall clean mrpropre mrpropre \ +.PHONY: all build install uninstall clean mrpropre mrpropre \ + run test run-test run-test-more default \ utils check net -$(MAKECMDGOALS): MK -MK: +default $(MAKECMDGOALS): @$(MAKE) --no-print-directory -C ../ -f $(CURDIR)/makefile.d \ $(MAKECMDGOALS) diff --git a/makefile.d b/makefile.d index 566d1b7..4231fce 100644 --- a/makefile.d +++ b/makefile.d @@ -2,11 +2,13 @@ # Note: gnu99 (instead of c99) required for libcutils-net NAME = cutils +NAMES = $(NAME) check net srcdir = cutils dstdir = ../bin CFLAGS += -Wall -pedantic -I./ -std=gnu99 CXXFLAGS += -Wall -pedantic -I./ +# LDFLAGS += -lcheck PREFIX = /usr/local ifdef DEBUG @@ -14,23 +16,32 @@ CFLAGS += -ggdb -O0 CXXFLAGS += -ggdb -O0 endif -.PHONY: all install uninstall clean mrpropre mrpropre \ - utils check net +.PHONY: all build install uninstall clean mrpropre mrpropre \ + $(NAMES) -all: utils check net +SOURCES=$(wildcard $(srcdir)/*.c) +HEADERS=$(wildcard $(srcdir)/*.h) +OBJECTS=$(SOURCES:%.c=%.o) -utils: $(dstdir)/libcutils.o +# Main targets -check: $(dstdir)/libcutils-check.o +all: build -net: $(dstdir)/libcutils-net.o +build: $(NAMES) -SOURCES=$(wildcard $(srcdir)/*.c) -HEADERS=$(wildcard $(srcdir)/*.h) -OBJECTS=$(SOURCES:%.c=%.o) +cutils: $(dstdir)/libcutils.o +check: $(dstdir)/libcutils-check.o +net: $(dstdir)/libcutils-net.o +################ +# Dependencies # +################ +# OBJECTS+=$(dstdir)/libcutils.o +# $(dstdir)/libcutils.o: +# $(MAKE) --no-print-directory -C cutils/ cutils $(srcdir)/array.o: $(srcdir)/array.[ch] $(srcdir)/desktop.o: $(srcdir)/desktop.[ch] $(srcdir)/array.h +################ $(dstdir)/libcutils.o: $(OBJECTS) mkdir -p $(dstdir) @@ -51,7 +62,7 @@ debug: $(MAKE) -f $(srcdir)/makefile.d DEBUG=1 clean: - rm -f $(srcdir)/*.o $(srcdir)/check/*.o $(srcdir)/net/*.o + rm -f $(srcdir)/*.o $(srcdir)/*/*.o mrproper: mrpropre @@ -62,6 +73,7 @@ mrpropre: clean rmdir $(dstdir) 2>/dev/null || true install: + mkdir -p "$(PREFIX)/lib" cp $(dstdir)/libcutils.o "$(PREFIX)/lib/libcutils.a" cp $(dstdir)/libcutils-check.o "$(PREFIX)/lib/libcutils-check.a" cp $(dstdir)/libcutils-net.o "$(PREFIX)/lib/libcutils-net.a" @@ -75,10 +87,12 @@ uninstall: rm "$(PREFIX)/lib/libcutils.a" rm "$(PREFIX)/lib/libcutils-check.a" rm "$(PREFIX)/lib/libcutils-net.a" + rmdir "$(PREFIX)/lib/" 2>/dev/null rm "$(PREFIX)/include/$(srcdir)/net/"*.h rm "$(PREFIX)/include/$(srcdir)/check/"*.h rm "$(PREFIX)/include/$(srcdir)/"*.h rmdir "$(PREFIX)/include/$(srcdir)/net" 2>/dev/null rmdir "$(PREFIX)/include/$(srcdir)/check" 2>/dev/null rmdir "$(PREFIX)/include/$(srcdir)" 2>/dev/null + rmdir "$(PREFIX)/include/" 2>/dev/null