aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2016-05-03 21:38:14 +0200
committerGravatar Christian Hesse <mail@eworm.de>2016-05-03 21:38:14 +0200
commite8b6f34ad12938dd58b7896d11ec543258ae7167 (patch)
treee7a02814c04f3ddefac310cd4c39df1bccdc4c04
parent59d4ae48a1d3545b909b0d8f89211828eee0d617 (diff)
downloadnullshell-e8b6f34ad12938dd58b7896d11ec543258ae7167.tar.gz
nullshell-e8b6f34ad12938dd58b7896d11ec543258ae7167.tar.zst
fix compiler and linker flags and produce binaries with full RELRO
-rw-r--r--Makefile14
1 files changed, 10 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 411a4f8..568d247 100644
--- a/Makefile
+++ b/Makefile
@@ -1,12 +1,18 @@
# nullshell - do nothing but print asterisks, can be used for login shell
PREFIX := /usr
-CP := cp
+
+# commands
CC := gcc
-MD := markdown
+CP := cp
INSTALL := install
+MD := markdown
RM := rm
-CFLAGS += -std=c11 -O2 -Wall -Werror
+
+# flags
+CFLAGS += -std=c11 -O2 -fPIC -Wall -Werror
+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.0.6
@@ -14,7 +20,7 @@ VERSION := 0.0.6
all: nullshell README.html
nullshell: nullshell.c config.h version.h
- $(CC) $(CFLAGS) $(LDFLAGS) nullshell.c -o nullshell
+ $(CC) $(CFLAGS) $(LDFLAGS) -o nullshell nullshell.c
version.h: $(wildcard .git/HEAD .git/index .git/refs/tags/*) Makefile
echo "#ifndef VERSION" > $@