diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 12 | ||||
-rwxr-xr-x | flags.sh | 13 |
3 files changed, 14 insertions, 12 deletions
@@ -1,3 +1,2 @@ -.flags /build/ /bfs @@ -235,18 +235,18 @@ $(BIN_GOALS): build build/tests: $(MKDIR) $@ -build/%.o: src/%.c .flags | build +build/%.o: src/%.c build/FLAGS $(CC) $(ALL_CFLAGS) -c $< -o $@ -build/tests/%.o: tests/%.c .flags | build/tests +build/tests/%.o: tests/%.c build/FLAGS | build/tests $(CC) $(ALL_CFLAGS) -c $< -o $@ # Save the full set of flags to rebuild everything when they change -.flags: FORCE - @./flags.sh $(CC) : $(ALL_CFLAGS) : $(ALL_LDFLAGS) : $(ALL_LDLIBS) +build/FLAGS: FORCE | build + @./flags.sh $@ $(CC) : $(ALL_CFLAGS) : $(ALL_LDFLAGS) : $(ALL_LDLIBS) .PHONY: FORCE -# Make sure that "make release" builds everything, but "make release main.o" doesn't +# Make sure that "make release" builds everything, but "make release build/main.o" doesn't $(FLAG_GOALS): $(FLAG_PREREQS) @: .PHONY: $(FLAG_GOALS) @@ -273,7 +273,7 @@ endif .PHONY: distcheck clean: - $(RM) -r bfs .flags build + $(RM) -r bfs build .PHONY: clean install: @@ -1,11 +1,14 @@ #!/usr/bin/env bash -set -e +set -eu -echo "$@" >.newflags +OUT="$1" +shift -if [ -e .flags ] && cmp -s .flags .newflags; then - rm .newflags +echo "$@" >"$OUT.tmp" + +if [ -e "$OUT" ] && cmp -s "$OUT" "$OUT.tmp"; then + rm "$OUT.tmp" else - mv .newflags .flags + mv "$OUT.tmp" "$OUT" fi |