From: Ludovic Rousseau <rousseau@debian.org>
Date: Sat, 3 Feb 2018 10:21:36 +0100
Subject: Use flags set by dpkg-buildflags to enable automatic hardening

---
 makefile | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/makefile b/makefile
index 2197f6c..1544984 100644
--- a/makefile
+++ b/makefile
@@ -1,3 +1,7 @@
+CPPFLAGS:=$(shell dpkg-buildflags --get CPPFLAGS)
+CFLAGS:=$(shell dpkg-buildflags --get CFLAGS)
+LDFLAGS:=$(shell dpkg-buildflags --get LDFLAGS)
+
 #--------------------------------
 # jhead makefile for Unix
 #--------------------------------
@@ -11,10 +15,10 @@ objs = $(OBJ)/jhead.o $(OBJ)/jpgfile.o $(OBJ)/jpgqguess.o $(OBJ)/paths.o \
 	$(OBJ)/exif.o $(OBJ)/iptc.o $(OBJ)/gpsinfo.o $(OBJ)/makernote.o 
 
 $(OBJ)/%.o:$(SRC)/%.c
-	${CC} $(CFLAGS) -c $< -o $@
+	${CC} $(CFLAGS) $(CPPFLAGS) -c $< -o $@
 
 jhead: $(objs) jhead.h
-	${CC} -o jhead $(objs) -lm
+	${CC} $(LDFLAGS) -o jhead $(objs) -lm
 
 clean:
 	rm -f $(objs) jhead
