diff options
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -11,15 +11,22 @@ CMD_OBJ = $(CMD_SRC:%=$(OBJ_DIR)/%.o) TST_SRC = $(wildcard $(TST_DIR)/*.c) TST_RUN = $(TST_SRC:$(TST_DIR)/%.c=$(OBJ_DIR)/test_runner/%) +TST_OBJ = $(TST_SRC:$(TST_DIR)/%.c=$(OBJ_DIR)/$(TST_DIR)/%.c.o) CC_SRC = $(wildcard $(SRC_DIR)/*.c) CC_OBJ = $(CC_SRC:%=$(OBJ_DIR)/%.o) +# -MMD writes a makefile of the headers each object actually includes. Without +# it, editing src/authz.h rebuilds nothing: the objects still match their .c +# files, so `make test' passes against a binary that is not the code on disk. CFLAGS = -std=c99 -Wall -Wextra -Wpedantic -I$(SRC_DIR) CFLAGS += -D_POSIX_C_SOURCE=200809L +CFLAGS += -MMD -MP CFLAGS += -g LDFLAGS = +DEPS = $(CC_OBJ:.o=.d) $(CMD_OBJ:.o=.d) $(TST_OBJ:.o=.d) + $(OBJ_DIR)/%.c.o: %.c @mkdir -p $(@D) $(CC) $(CFLAGS) -o $@ -c $< @@ -50,7 +57,7 @@ test: $(PROG) $(TST_RUN) .PHONY: sanitizer sanitizer: CFLAGS := -std=c99 -Wall -Wextra -Wpedantic -I$(SRC_DIR) \ -D_POSIX_C_SOURCE=200809L -O1 -g -fsanitize=address,undefined \ - -fno-omit-frame-pointer + -fno-omit-frame-pointer -MMD -MP sanitizer: LDFLAGS := -fsanitize=address,undefined sanitizer: test @@ -101,3 +108,7 @@ clean: @$(RM) -rf obj/ @$(RM) -rf $(TST_DIR)/tmp @$(RM) $(PROG) + +# Included last: the .d files only exist after something has been compiled, and +# a missing one is not an error. +-include $(DEPS) |
