aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2016-05-03 21:42:07 +0200
committerGravatar Christian Hesse <mail@eworm.de>2016-05-03 21:42:07 +0200
commitea97f094a4d990788f06fff3c45922f4f06b45d2 (patch)
tree642cf151d97275fe16f38f1fb7aa5f74d3b8e8b0 /Makefile
parent5e22af74295aadbf4e3ca3efbaf97a0b982cd52b (diff)
downloadpacredir-ea97f094a4d990788f06fff3c45922f4f06b45d2.tar.gz
pacredir-ea97f094a4d990788f06fff3c45922f4f06b45d2.tar.zst
fix compiler and linker flags and produce binaries with full RELRO
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile28
1 files changed, 17 insertions, 11 deletions
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