summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2020-12-16 15:18:17 -0500
committerTavian Barnes <tavianator@tavianator.com>2020-12-16 15:23:09 -0500
commitecf6a45612e2398a5dd72c89f7971f903442054e (patch)
treec28200ed1efcbca6e1537d55871f15dbb8efa4b8 /Makefile
parent986a206965da3f5bf6fd11d3285b5e19b6e066d1 (diff)
downloadbfs-ecf6a45612e2398a5dd72c89f7971f903442054e.tar.xz
Makefile: Avoid rebuilding everything for make release main.o
To do this we need to only add the release: default dependency if no non-flag goals are specified on the command line. While I'm at it, simplify and coalesce a few recipes.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile45
1 files changed, 25 insertions, 20 deletions
diff --git a/Makefile b/Makefile
index 77fad91..9a73451 100644
--- a/Makefile
+++ b/Makefile
@@ -109,9 +109,24 @@ ALL_LDLIBS = $(LOCAL_LDLIBS) $(LDLIBS)
ALL_FLAGS := $(CC) : $(ALL_CFLAGS) : $(ALL_LDFLAGS) : $(ALL_LDLIBS)
$(shell ./flags.sh $(ALL_FLAGS))
+# Goals that make binaries
+BIN_GOALS := bfs tests/mksock tests/trie tests/xtimegm
+
+# Goals that are treated like flags by this Makefile
+FLAG_GOALS := asan msan ubsan gcov release
+
+# These are the remaining non-flag goals
+GOALS := $(filter-out $(FLAG_GOALS),$(MAKECMDGOALS))
+
+# Build the default goal if only flag goals are specified
+FLAG_PREREQS :=
+ifndef GOALS
+FLAG_PREREQS += default
+endif
+
default: bfs
-all: bfs tests/mksock tests/trie tests/xtimegm
+all: $(BIN_GOALS)
bfs: \
bar.o \
@@ -136,31 +151,21 @@ bfs: \
trie.o \
typo.o \
util.o
- $(CC) $(ALL_LDFLAGS) $^ $(ALL_LDLIBS) -o $@
-
-asan: bfs
- @:
-ubsan: bfs
- @:
-msan: bfs
- @:
-gcov: bfs
- @:
-release: bfs
- @:
tests/mksock: tests/mksock.o
- $(CC) $(ALL_LDFLAGS) $^ -o $@
-
tests/trie: trie.o tests/trie.o
- $(CC) $(ALL_LDFLAGS) $^ -o $@
-
tests/xtimegm: time.o tests/xtimegm.o
- $(CC) $(ALL_LDFLAGS) $^ -o $@
+
+$(BIN_GOALS):
+ $(CC) $(ALL_LDFLAGS) $^ $(ALL_LDLIBS) -o $@
%.o: %.c .flags
$(CC) $(ALL_CFLAGS) -c $< -o $@
+# Make sure that "make release" builds everything, but "make release main.o" doesn't
+$(FLAG_GOALS): $(FLAG_PREREQS)
+ @:
+
check: check-trie check-xtimegm check-bfs check-dfs check-ids check-eds
check-trie: tests/trie
@@ -184,7 +189,7 @@ endif
+$(MAKE) -B check $(DISTCHECK_FLAGS)
clean:
- $(RM) bfs *.[od] *.gcda *.gcno tests/mksock tests/trie tests/xtimegm tests/*.[od] tests/*.gcda tests/*.gcno
+ $(RM) $(BIN_GOALS) *.[od] *.gcda *.gcno tests/*.[od] tests/*.gcda tests/*.gcno
install:
$(MKDIR) $(DESTDIR)$(PREFIX)/bin
@@ -196,6 +201,6 @@ uninstall:
$(RM) $(DESTDIR)$(PREFIX)/bin/bfs
$(RM) $(DESTDIR)$(MANDIR)/man1/bfs.1
-.PHONY: all asan ubsan msan release check check-trie check-xtimegm distcheck clean install uninstall
+.PHONY: default all $(FLAG_GOALS) check check-trie check-xtimegm distcheck clean install uninstall
-include $(wildcard *.d)