summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2022-04-18 22:13:03 -0400
committerTavian Barnes <tavianator@tavianator.com>2022-04-18 22:13:03 -0400
commitae20140e651f14721cf870b3910421135dbcc3d5 (patch)
treece608a942dea9b7b4294f2c3300a900630ecc850
parente75f86a9f5f42147cd974b510d547eec6a1fc518 (diff)
downloadbfs-ae20140e651f14721cf870b3910421135dbcc3d5.tar.xz
Makefile: Use a recipe to update .flags rather than $(shell)
This means we don't need to generate .flags unless we're actually building a target that needs it, which is important for thing like $ sudo make install that used to inconveniently create a root-owned .flags file.
-rw-r--r--Makefile12
1 files changed, 4 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index d2c0258..8fe13a7 100644
--- a/Makefile
+++ b/Makefile
@@ -169,10 +169,6 @@ ALL_CFLAGS = $(ALL_CPPFLAGS) $(LOCAL_CFLAGS) $(CFLAGS) $(EXTRA_CFLAGS) $(DEPFLAG
ALL_LDFLAGS = $(ALL_CFLAGS) $(LOCAL_LDFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS)
ALL_LDLIBS = $(LOCAL_LDLIBS) $(LDLIBS) $(EXTRA_LDLIBS)
-# Save the full set of flags to rebuild everything when they change
-ALL_FLAGS := $(CC) : $(ALL_CFLAGS) : $(ALL_LDFLAGS) : $(ALL_LDLIBS)
-$(shell ./flags.sh $(ALL_FLAGS))
-
# Goals that make binaries
BIN_GOALS := bfs build/tests/mksock build/tests/trie build/tests/xtimegm
@@ -241,9 +237,9 @@ build/%.o: src/%.c .flags | build
build/tests/%.o: tests/%.c .flags | build/tests
$(CC) $(ALL_CFLAGS) -c $< -o $@
-# Need a rule for .flags to convince make to apply the above pattern rule if
-# .flags didn't exist when make was run
-.flags:
+# Save the full set of flags to rebuild everything when they change
+.flags: FORCE
+ @./flags.sh $(CC) : $(ALL_CFLAGS) : $(ALL_LDFLAGS) : $(ALL_LDLIBS)
# Make sure that "make release" builds everything, but "make release main.o" doesn't
$(FLAG_GOALS): $(FLAG_PREREQS)
@@ -284,7 +280,7 @@ uninstall:
$(RM) $(DESTDIR)$(MANDIR)/man1/bfs.1
$(RM) $(DESTDIR)$(PREFIX)/bin/bfs
-.PHONY: default all $(FLAG_GOALS) check $(CHECKS) distcheck clean install uninstall
+.PHONY: default all $(FLAG_GOALS) check $(CHECKS) distcheck clean install uninstall FORCE
.SUFFIXES: