hardened build flags - wheezy release goal
Index: open-iscsi/usr/Makefile
===================================================================
--- open-iscsi.orig/usr/Makefile	2012-04-07 19:58:23.341694200 +0530
+++ open-iscsi/usr/Makefile	2012-04-07 20:00:41.622379886 +0530
@@ -28,7 +28,7 @@
 endif
 endif
 
-OPTFLAGS ?= -O2 -g
+OPTFLAGS ?= `dpkg-buildflags --get CFLAGS` `dpkg-buildflags --get CPPFLAGS`
 WARNFLAGS ?= -Wall -Wstrict-prototypes
 CFLAGS += $(OPTFLAGS) $(WARNFLAGS) -I../include -I. -I../utils/open-isns \
 				-D$(OSNAME) $(IPC_CFLAGS)
@@ -54,14 +54,14 @@
 
 iscsid: $(ISCSI_LIB_SRCS) $(INITIATOR_SRCS) $(DISCOVERY_SRCS) \
 	iscsid.o session_mgmt.o discoveryd.o
-	$(CC) $(CFLAGS) $^ -o $@  -L../utils/open-isns -lisns
+	$(CC) $(CFLAGS) $^ -o $@  -L../utils/open-isns -lisns `dpkg-buildflags --get LDFLAGS`
 
 iscsiadm: $(ISCSI_LIB_SRCS) $(DISCOVERY_SRCS) iscsiadm.o session_mgmt.o
-	$(CC) $(CFLAGS) $^ -o $@ -L../utils/open-isns -lisns
+	$(CC) $(CFLAGS) $^ -o $@ -L../utils/open-isns -lisns `dpkg-buildflags --get LDFLAGS`
 
 iscsistart: $(ISCSI_LIB_SRCS) $(INITIATOR_SRCS) $(FW_BOOT_SRCS) \
 		iscsistart.o statics.o
-	$(CC) $(CFLAGS) $^ -o $@
+	$(CC) $(CFLAGS) $^ -o $@ `dpkg-buildflags --get LDFLAGS`
 clean:
 	rm -f *.o $(PROGRAMS) .depend $(LIBSYS)
 
Index: open-iscsi/utils/Makefile
===================================================================
--- open-iscsi.orig/utils/Makefile	2012-04-07 19:54:51.056641535 +0530
+++ open-iscsi/utils/Makefile	2012-04-07 20:01:57.138754352 +0530
@@ -1,12 +1,12 @@
 # This Makefile will work only with GNU make.
 
-CFLAGS += $(OPTFLAGS) -O2 -fno-inline -Wall -Wstrict-prototypes -g
+CFLAGS += $(OPTFLAGS) -fno-inline -Wall -Wstrict-prototypes `dpkg-buildflags --get CFLAGS` `dpkg-buildflags --get CPPFLAGS`
 PROGRAMS = iscsi-iname
 
 all: $(PROGRAMS)
 
 iscsi-iname: md5.o iscsi-iname.o
-	$(CC) $(CFLAGS) $^ $(DBM_LIB) -o $@
+	$(CC) $(CFLAGS) $^ $(DBM_LIB) -o $@ `dpkg-buildflags --get LDFLAGS`
 
 clean:
 	rm -f *.o $(PROGRAMS) .depend
