summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile84
1 files changed, 44 insertions, 40 deletions
diff --git a/Makefile b/Makefile
index afd3c77..49a3a87 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
############################################################################
# bfs #
-# Copyright (C) 2015-2021 Tavian Barnes <tavianator@tavianator.com> #
+# Copyright (C) 2015-2023 Tavian Barnes <tavianator@tavianator.com> #
# #
# Permission to use, copy, modify, and/or distribute this software for any #
# purpose with or without fee is hereby granted. #
@@ -174,6 +174,10 @@ 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)
+# Default make target
+bfs: $(BIN)/bfs
+.PHONY: bfs
+
# Goals that are treated like flags by this Makefile
FLAG_GOALS := asan lsan msan tsan ubsan gcov release
@@ -186,18 +190,10 @@ ifndef GOALS
FLAG_PREREQS += bfs
endif
-# The different search strategies that we test
-STRATEGIES := bfs dfs ids eds
-STRATEGY_CHECKS := $(STRATEGIES:%=check-%)
-
-# All the different checks we run
-CHECKS := $(STRATEGY_CHECKS) check-trie check-xtimegm
-
-# Custom test flags for distcheck
-DISTCHECK_FLAGS := -s TEST_FLAGS="--sudo --verbose=skipped"
-
-bfs: $(BIN)/bfs
-.PHONY: bfs
+# Make sure that "make release" builds everything, but "make release obj/src/main.o" doesn't
+$(FLAG_GOALS): $(FLAG_PREREQS)
+ @:
+.PHONY: $(FLAG_GOALS)
all: \
$(BIN)/bfs \
@@ -207,7 +203,26 @@ all: \
$(BIN)/tests/xtouch
.PHONY: all
-$(BIN)/bfs: \
+$(BIN)/%:
+ @$(MKDIR) $(@D)
+ +$(CC) $(ALL_LDFLAGS) $^ $(ALL_LDLIBS) -o $@
+
+$(OBJ)/%.o: %.c $(OBJ)/FLAGS
+ @$(MKDIR) $(@D)
+ $(CC) $(ALL_CFLAGS) -c $< -o $@
+
+# Save the full set of flags to rebuild everything when they change
+$(OBJ)/FLAGS.new:
+ @$(MKDIR) $(@D)
+ @echo $(CC) : $(ALL_CFLAGS) : $(ALL_LDFLAGS) : $(ALL_LDLIBS) >$@
+.PHONY: $(OBJ)/FLAGS.new
+
+# Only update obj/FLAGS if obj/FLAGS.new is different
+$(OBJ)/FLAGS: $(OBJ)/FLAGS.new
+ @test -e $@ && cmp -s $@ $< && rm $< || mv $< $@
+
+# All object files except the entry point
+LIBBFS := \
$(OBJ)/src/bar.o \
$(OBJ)/src/bfstd.o \
$(OBJ)/src/bftw.o \
@@ -220,7 +235,6 @@ $(BIN)/bfs: \
$(OBJ)/src/eval.o \
$(OBJ)/src/exec.o \
$(OBJ)/src/fsade.o \
- $(OBJ)/src/main.o \
$(OBJ)/src/mtab.o \
$(OBJ)/src/opt.o \
$(OBJ)/src/parse.o \
@@ -233,33 +247,15 @@ $(BIN)/bfs: \
$(OBJ)/src/xspawn.o \
$(OBJ)/src/xtime.o
-$(BIN)/tests/mksock: $(OBJ)/tests/mksock.o
-$(BIN)/tests/trie: $(OBJ)/src/trie.o $(OBJ)/tests/trie.o
-$(BIN)/tests/xtimegm: $(OBJ)/src/xtime.o $(OBJ)/tests/xtimegm.o
-$(BIN)/tests/xtouch: $(OBJ)/src/xtime.o $(OBJ)/tests/xtouch.o
-
-$(BIN)/%:
- @$(MKDIR) $(@D)
- +$(CC) $(ALL_LDFLAGS) $^ $(ALL_LDLIBS) -o $@
-
-$(OBJ)/%.o: %.c $(OBJ)/FLAGS
- @$(MKDIR) $(@D)
- $(CC) $(ALL_CFLAGS) -c $< -o $@
-
-# Save the full set of flags to rebuild everything when they change
-$(OBJ)/FLAGS.new:
- @$(MKDIR) $(@D)
- @echo $(CC) : $(ALL_CFLAGS) : $(ALL_LDFLAGS) : $(ALL_LDLIBS) >$@
-.PHONY: $(OBJ)/FLAGS.new
+# The main executable
+$(BIN)/bfs: $(OBJ)/src/main.o $(LIBBFS)
-# Only update obj/FLAGS if obj/FLAGS.new is different
-$(OBJ)/FLAGS: $(OBJ)/FLAGS.new
- @test -e $@ && cmp -s $@ $< && rm $< || mv $< $@
+# The different search strategies that we test
+STRATEGIES := bfs dfs ids eds
+STRATEGY_CHECKS := $(STRATEGIES:%=check-%)
-# Make sure that "make release" builds everything, but "make release obj/src/main.o" doesn't
-$(FLAG_GOALS): $(FLAG_PREREQS)
- @:
-.PHONY: $(FLAG_GOALS)
+# All the different checks we run
+CHECKS := $(STRATEGY_CHECKS) check-trie check-xtimegm
check: $(CHECKS)
.PHONY: check $(CHECKS)
@@ -270,6 +266,14 @@ $(STRATEGY_CHECKS): check-%: $(BIN)/bfs $(BIN)/tests/mksock $(BIN)/tests/xtouch
check-trie check-xtimegm: check-%: $(BIN)/tests/%
$<
+$(BIN)/tests/mksock: $(OBJ)/tests/mksock.o $(LIBBFS)
+$(BIN)/tests/trie: $(OBJ)/tests/trie.o $(LIBBFS)
+$(BIN)/tests/xtimegm: $(OBJ)/tests/xtimegm.o $(LIBBFS)
+$(BIN)/tests/xtouch: $(OBJ)/tests/xtouch.o $(LIBBFS)
+
+# Custom test flags for distcheck
+DISTCHECK_FLAGS := -s TEST_FLAGS="--sudo --verbose=skipped"
+
distcheck:
+$(MAKE) -B asan ubsan check $(DISTCHECK_FLAGS)
ifneq ($(OS),Darwin)