From 16118356180d868e8c9dac3cf9854c2a8fbe1cc1 Mon Sep 17 00:00:00 2001 From: Philippe Gerum Date: Sat, 8 Jun 2019 19:41:45 +0200 Subject: [PATCH] build: fix various target inter-dependencies --- Makefile | 2 +- commands/Makefile | 6 +++--- config.mk | 4 +++- include/Makefile | 22 +++++++++++----------- lib/Makefile | 4 +--- tests/Makefile | 7 +++++-- utils/Makefile | 6 ++---- 7 files changed, 26 insertions(+), 25 deletions(-) diff --git a/Makefile b/Makefile index bfe5dff..9b4c0ae 100644 --- a/Makefile +++ b/Makefile @@ -11,4 +11,4 @@ $(MAIN_GOALS): output-Makefile lib: include -tests utils: lib +tests utils commands: lib diff --git a/commands/Makefile b/commands/Makefile index ec9d5c1..5f63f1f 100644 --- a/commands/Makefile +++ b/commands/Makefile @@ -13,9 +13,9 @@ CMD_CPPFLAGS := $(BASE_CPPFLAGS) -I. -I$(O_DIR)/../include CMD_CFLAGS := $(CMD_CPPFLAGS) $(BASE_CFLAGS) override CFLAGS := $(CMD_CFLAGS) $(CFLAGS) -$(TARGETS): output-Makefile +$(TARGETS): -all: $(TARGETS) +all: output-Makefile $(TARGETS) install: all $(call inst-cmd,commands, \ @@ -29,7 +29,7 @@ install: all name=evl-$$hlp; \ $(INSTALL) -D $(O_DIR)/$$hlp $(DESTDIR)/$(libexecdir)/$$name; done) -clean clobber mrproper: +clean clobber mrproper: output-Makefile $(Q)$(RM) -f $(TARGETS) $(DEPFILES) $(O_DIR)/%: %.c diff --git a/config.mk b/config.mk index 8f4d393..9e32b72 100644 --- a/config.mk +++ b/config.mk @@ -121,4 +121,6 @@ ifneq ($(O_DIR), $(CURDIR)) fi endif -.PHONY: _all $(MAIN_GOALS) $(TARGETS) output-Makefile +FORCE: + +.PHONY: _all $(MAIN_GOALS) output-Makefile FORCE diff --git a/include/Makefile b/include/Makefile index e87115b..79a34ae 100644 --- a/include/Makefile +++ b/include/Makefile @@ -6,26 +6,26 @@ O_UAPI = $(O_DIR)/uapi TARGETS := uapi -$(TARGETS): output-Makefile +uapi: $(O_UAPI) -uapi: $(O_DIR)/.uapi_stamp $(O_UAPI) - -$(O_DIR)/.uapi_stamp $(O_DIR)/uapi: +$(O_UAPI): $(O_DIR)/.uapi_stamp $(Q)$(MKDIR_P) $(O_UAPI) $(Q)$(RM) -f $(O_UAPI)/asm $(O_UAPI)/evl - $(Q)if test -r $(UAPI)/Makefile; then \ + $(Q)if test -r $(UAPI)/Kbuild; then \ $(LN_S) $(UAPI)/arch/$(ARCH)/include/uapi/asm $(O_UAPI)/asm; \ $(LN_S) $(UAPI)/include/uapi/evl $(O_UAPI)/evl; \ - else \ + elif test \! -L $(O_UAPI)/asm; then \ $(LN_S) $(UAPI)/asm $(O_UAPI)/asm; \ $(LN_S) $(UAPI)/evl $(O_UAPI)/evl; \ - fi; \ - touch $@ + fi -all: uapi +$(O_DIR)/.uapi_stamp: FORCE + @touch $@ -# Remove the UAPI links. Careful with removing $(O_DIR)/uapi, just in case. -clean clobber mrproper: +all: output-Makefile $(TARGETS) + +# Remove the UAPI links. Careful with removing $(O_UAPI), just in case. +clean clobber mrproper: output-Makefile $(Q)$(RM) -f $(O_DIR)/.uapi_stamp $(O_UAPI)/asm $(O_UAPI)/evl $(Q)test -d $(O_UAPI) && $(RMDIR_SAFE) $(O_UAPI) || : diff --git a/lib/Makefile b/lib/Makefile index 689a0f2..f6aa299 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -26,9 +26,7 @@ override CFLAGS := $(LIB_CFLAGS) $(CFLAGS) override LDFLAGS := $(LDFLAGS) -lpthread -lrt -$(TARGETS): output-Makefile - -all: $(TARGETS) +all: output-Makefile $(TARGETS) install: all $(call inst-cmd,$(SOLIBNAME),$(INSTALL) -D $(O_DIR)/$(SOLIBNAME) $(DESTDIR)/$(libdir)/$(SOLIBNAME)) diff --git a/tests/Makefile b/tests/Makefile index 85453c7..1719122 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -7,7 +7,9 @@ ALLSRC := $(wildcard *.c) HELPSRC := helpers.c HELPOBJ := $(O_DIR)/helpers.o TESTSRC := $(filter-out $(HELPSRC),$(ALLSRC)) +FPSRC := fault.c TARGETS = $(TESTSRC:%.c=$(O_DIR)/%) +NEEDLIBM = $(FPSRC:%.c=$(O_DIR)/%) DEPFILES = $(ALLSRC:%.c=$(O_DIR)/%.d) TEST_CPPFLAGS := $(BASE_CPPFLAGS) \ @@ -20,10 +22,11 @@ override CFLAGS := $(TEST_CFLAGS) $(CFLAGS) TEST_LDFLAGS := $(O_DIR)/../lib/libevl.so.$(EVL_IVERSION) -lpthread -lrt override LDFLAGS := $(TEST_LDFLAGS) $(LDFLAGS) +$(NEEDLIBM): override LDFLAGS += -lm -all: $(TARGETS) +all: output-Makefile $(TARGETS) -$(TARGETS): output-Makefile $(HELPOBJ) +$(TARGETS): $(HELPOBJ) install: all $(Q)for bin in $(TESTSRC:%.c=%); do \ diff --git a/utils/Makefile b/utils/Makefile index 793d3d4..97083d4 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -19,16 +19,14 @@ override CFLAGS := $(UTIL_CFLAGS) $(CFLAGS) UTIL_LDFLAGS := $(O_DIR)/../lib/libevl.so.$(EVL_IVERSION) -lpthread -lrt override LDFLAGS := $(UTIL_LDFLAGS) $(LDFLAGS) -$(TARGETS): output-Makefile - -all: $(TARGETS) +all: output-Makefile $(TARGETS) install: all $(Q)for bin in $(BINARIES); do \ $(INSTALL) -D $(O_DIR)/$$bin $(DESTDIR)/$(bindir)/$$bin; \ done -clean clobber mrproper: +clean clobber mrproper: output-Makefile $(Q)$(RM) -f $(TARGETS) $(DEPFILES) $(O_DIR)/%: %.c