From ea97f094a4d990788f06fff3c45922f4f06b45d2 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Tue, 3 May 2016 21:42:07 +0200 Subject: fix compiler and linker flags and produce binaries with full RELRO --- Makefile | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 2f5595a..30dc255 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,25 @@ # paccache - serve pacman cache and redirect via avahi service PREFIX := /usr + +# commands CC := gcc -MD := markdown -INSTALL := install CP := cp -RM := rm +INSTALL := install LN := ln +MD := markdown +RM := rm SED := sed -CFLAGS += -std=c11 -O2 -Wall -Werror -CFLAGS += -lpthread -CFLAGS += $(shell pkg-config --libs --cflags libcurl) -CFLAGS += $(shell pkg-config --libs --cflags avahi-client) -CFLAGS += $(shell pkg-config --libs --cflags libmicrohttpd) -CFLAGS += -liniparser + +# flags +CFLAGS += -std=c11 -O2 -fPIC -Wall -Werror +CFLAGS_EXTRA += -lpthread +CFLAGS_EXTRA += $(shell pkg-config --libs --cflags libcurl) +CFLAGS_EXTRA += $(shell pkg-config --libs --cflags avahi-client) +CFLAGS_EXTRA += $(shell pkg-config --libs --cflags libmicrohttpd) +CFLAGS_EXTRA += -liniparser +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.19 @@ -21,10 +27,10 @@ VERSION := 0.1.19 all: pacredir avahi/pacdbserve.service README.html arch: arch.c arch.h - $(CC) -o arch arch.c + $(CC) $(CFLAGS) $(LDFLAGS) -o arch arch.c pacredir: pacredir.c arch.h pacredir.h config.h version.h - $(CC) $(CFLAGS) $(LDFLAGS) -o pacredir pacredir.c + $(CC) $(CFLAGS) $(CFLAGS_EXTRA) $(LDFLAGS) -o pacredir pacredir.c config.h: $(CP) config.def.h config.h -- cgit v1.2.3-70-g09d2