From 5382942fc080c0d8f8664f64f0a5709ca9886ccd Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Tue, 24 Mar 2020 15:47:05 -0400 Subject: Makefile: Don't use target-specific variables for configuration targets In things like release: CFLAGS := ... release: bfs CFLAGS is only set for the dependencies of release, so $ make release check doesn't set CFLAGS for tests/mksock. For the same reason, $ make asan ubsan was broken, because only the asan flags would be set for bfs. Fix it by checking MAKECMDGOALS for those targets manually instead. --- Makefile | 45 ++++++++++++++++++++++++++++----------------- 1 file changed, 28 insertions(+), 17 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index bf44cdb..94e9d0c 100644 --- a/Makefile +++ b/Makefile @@ -62,6 +62,24 @@ LOCAL_LDLIBS += -lacl -lcap -lattr -lrt # These libraries are not built with msan, so disable them MSAN_CFLAGS += -DBFS_HAS_SYS_ACL=0 -DBFS_HAS_SYS_CAPABILITY=0 -DBFS_HAS_SYS_XATTR=0 + +DISTCHECK_FLAGS := TEST_FLAGS="--all --sudo" +endif + +ifneq ($(filter asan,$(MAKECMDGOALS)),) +LOCAL_CFLAGS += $(ASAN_CFLAGS) +endif + +ifneq ($(filter msan,$(MAKECMDGOALS)),) +LOCAL_CFLAGS += $(MSAN_CFLAGS) +endif + +ifneq ($(filter ubsan,$(MAKECMDGOALS)),) +LOCAL_CFLAGS += $(UBSAN_CFLAGS) +endif + +ifneq ($(filter release,$(MAKECMDGOALS)),) +CFLAGS := -g $(WFLAGS) -O3 -flto -DNDEBUG endif ALL_CPPFLAGS = $(LOCAL_CPPFLAGS) $(CPPFLAGS) @@ -69,10 +87,6 @@ ALL_CFLAGS = $(ALL_CPPFLAGS) $(LOCAL_CFLAGS) $(CFLAGS) $(DEPFLAGS) ALL_LDFLAGS = $(ALL_CFLAGS) $(LOCAL_LDFLAGS) $(LDFLAGS) ALL_LDLIBS = $(LOCAL_LDLIBS) $(LDLIBS) -ifeq ($(OS),Linux) -DISTCHECK_FLAGS := TEST_FLAGS="--all --sudo" -endif - default: bfs all: bfs tests/mksock @@ -100,17 +114,14 @@ bfs: \ util.o $(CC) $(ALL_LDFLAGS) $^ $(ALL_LDLIBS) -o $@ -asan: LOCAL_CFLAGS += $(ASAN_CFLAGS) asan: bfs - -ubsan: LOCAL_CFLAGS += $(UBSAN_CFLAGS) + @: ubsan: bfs - -msan: LOCAL_CFLAGS += $(MSAN_CFLAGS) + @: msan: bfs - -release: CFLAGS := -g $(WFLAGS) -O3 -flto -DNDEBUG + @: release: bfs + @: tests/mksock: tests/mksock.o $(CC) $(ALL_LDFLAGS) $^ -o $@ @@ -124,13 +135,13 @@ check-%: all ./tests.sh --bfs="$(CURDIR)/bfs -S $*" $(TEST_FLAGS) distcheck: - +$(MAKE) -Bs asan ubsan check $(DISTCHECK_FLAGS) + +$(MAKE) -B asan ubsan check $(DISTCHECK_FLAGS) ifneq ($(OS),Darwin) - +$(MAKE) -Bs msan check CC=clang $(DISTCHECK_FLAGS) - +$(MAKE) -Bs check CFLAGS="-m32" $(DISTCHECK_FLAGS) + +$(MAKE) -B msan check CC=clang $(DISTCHECK_FLAGS) + +$(MAKE) -B check CFLAGS="-m32" $(DISTCHECK_FLAGS) endif - +$(MAKE) -Bs release check $(DISTCHECK_FLAGS) - +$(MAKE) -Bs check $(DISTCHECK_FLAGS) + +$(MAKE) -B release check $(DISTCHECK_FLAGS) + +$(MAKE) -B check $(DISTCHECK_FLAGS) clean: $(RM) bfs *.[od] tests/mksock tests/*.[od] @@ -145,6 +156,6 @@ uninstall: $(RM) $(DESTDIR)$(PREFIX)/bin/bfs $(RM) $(DESTDIR)$(MANDIR)/man1/bfs.1 -.PHONY: all release check distcheck clean install uninstall +.PHONY: all asan ubsan msan release check distcheck clean install uninstall -include $(wildcard *.d) -- cgit v1.2.3