From aa50460e28b790329ed0e4530a35b85936aaf73a Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 3 May 2016 21:28:20 +0200 Subject: fix compiler and linker flags and produce binaries with full RELRO --- Makefile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 26bd783..d3c93db 100644 --- a/Makefile +++ b/Makefile @@ -1,22 +1,30 @@ # nthash - Generate NT Hash PREFIX := /usr + +# commands CC := gcc MD := markdown ECHO := echo GREP := grep INSTALL := install RM := rm -CFLAGS += -std=c11 -O2 -Wall -Werror + +# flags +CFLAGS += -std=c11 -O2 -fPIC -Wall -Werror # Debian has the libs but no pkg-config file. Fall back to hard coded # "-lnettle" if pkg-config fails. CFLAGS += $(shell pkg-config --cflags --libs nettle 2>/dev/null || echo "-lnettle") +LDFLAGS += -Wl,-z,now -Wl,-z,relro -pie + +# this is just a fallback in case you do not use git but downloaded +# a release tarball... VERSION := 0.1.6 all: nthash README.html nthash: nthash.c - $(CC) $(CFLAGS) -o nthash $(LDFLAGS) nthash.c + $(CC) $(CFLAGS) $(LDFLAGS) -o nthash nthash.c README.html: README.md $(MD) README.md > README.html -- cgit v1.2.3-70-g09d2