diff options
author | Rory Bradford <roryrjb@gmail.com> | 2019-12-18 18:50:25 +0000 |
---|---|---|
committer | Rory Bradford <roryrjb@gmail.com> | 2019-12-18 18:50:25 +0000 |
commit | d76a0fc9922bf35f879a73081d1291292c64331a (patch) | |
tree | 4b54ab3ab47eb86faca6ac3e4cff9d9f1181d711 /Makefile | |
parent | 6a656b7d622aea9687403c798dfba33789f1b4db (diff) | |
download | rf-d76a0fc9922bf35f879a73081d1291292c64331a.tar.gz |
Tweak make flags for additional C safety
As well as adding some obvious memory safety flags to the compiler also add some initial tests with valgrind. Signed-off-by: Rory Bradford <roryrjb@gmail.com>
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/Makefile b/Makefile index f92f5a3..cb78c69 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,23 @@ +.POSIX: +.SUFFIXES: .c .o + BIN = rf OBJS = rf.o MANPAGE = rf.1 -CC ?= gcc +CC = cc DEPS = config.h LIBS = INC = CFLAGS := ${CFLAGS} -CFLAGS += -Wall -O2 -fstack-protector-strong -D_FORTIFY_SOURCE=2 $(INC) $(LIBS) +CFLAGS += -ansi \ + -Wpedantic \ + -Wall \ + -Werror=format-security \ + -Werror=implicit-function-declaration \ + -O2 \ + -fstack-protector-strong \ + -fpie \ + -D_FORTIFY_SOURCE=2 $(INC) $(LIBS) PREFIX ?= /usr/local build: $(BIN) @@ -14,7 +25,18 @@ build: $(BIN) $(BIN): $(OBJS) $(CC) $(BIN).c $(CFLAGS) -o $(BIN) -%.o : %.c $(DEPS) +debug: $(OBJS) + $(CC) $(BIN).c $(CFLAGS) -g -o $(BIN) + +test: clean debug + valgrind -s --leak-check=full --show-leak-kinds=all --track-origins=yes --error-exitcode=1 ./$(BIN) ^$ + valgrind -s --leak-check=full --show-leak-kinds=all --track-origins=yes --error-exitcode=1 ./$(BIN) ^$$ + valgrind -s --leak-check=full --show-leak-kinds=all --track-origins=yes --error-exitcode=1 ./$(BIN) rf + +static: $(OBJS) + $(CC) $(BIN).c $(CFLAGS) -static -o $(BIN) + +%.o: %.c $(DEPS) $(CC) -c -o $@ $< $(CFLAGS) install: build |