aboutsummaryrefslogtreecommitdiff
path: root/debian
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2012-02-15 18:29:37 -0500
committerTheodore Ts'o <tytso@mit.edu>2012-02-17 14:32:18 -0500
commit910fae94a5799de1fdfd180df55ef4d71319e0b7 (patch)
treeda7bbff84a35edebfba5815f585bd238ebb1d086 /debian
parenta204236eafb47e3cd4e9dbc0e810bccd8c9173cc (diff)
downloade2fsprogs-910fae94a5799de1fdfd180df55ef4d71319e0b7.tar.gz
debian: enable use of dpkg-buildflags if present
On newer Debian-based distributions, dpkg-buildflags should be called by the debian rules file to get the appropriate values for CFLAGS, LDFLAGS, etc. This will also allow Debian to build with security hardened build flags, which is a release goal for Debian Wheezy. If dpkg-buildflags is not present, then use some safe defaults (what is currently being set by dpkg-buildpackage in Ubuntu 10.04 LTS, which is a common enough ancient distribution that many people might still care about). Addresses-Debian-Bug: #654457 Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'debian')
-rwxr-xr-xdebian/rules28
1 files changed, 22 insertions, 6 deletions
diff --git a/debian/rules b/debian/rules
index c950cd74..6e498045 100755
--- a/debian/rules
+++ b/debian/rules
@@ -113,6 +113,16 @@ INSTALL_PROGRAM = $(INSTALL) -p -o root -g root -m 0755
#INSTALL_PROGRAM += -s
#endif
+DEFAULT_CFLAGS = -g -O2
+DEFAULT_LDFLAGS = -Wl,-Bsymbolic-functions
+
+CFLAGS = $(shell if dpkg-buildflags >& /dev/null; then \
+ dpkg-buildflags --get CFLAGS; else echo $(DEFAULT_CFLAGS) ; fi)
+LDFLAGS = $(shell if dpkg-buildflags >& /dev/null; then \
+ dpkg-buildflags --get LDFLAGS; else echo $(DEFAULT_LDFLAGS) ; fi)
+CPPFLAGS = $(shell if dpkg-buildflags >& /dev/null; then \
+ dpkg-buildflags --get CPPFLAGS; fi)
+
ifeq (${DEB_HOST_ARCH},alpha)
CFLAGS += -DHAVE_NETINET_IN_H
else
@@ -214,12 +224,12 @@ ${CFGSTDSTAMP}:
ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
cd ${stdbuilddir} && AWK=/usr/bin/awk \
${topdir}/configure ${COMMON_CONF_FLAGS} ${STD_CONF_FLAGS} \
- CFLAGS="${CFLAGS}"
+ CFLAGS="${CFLAGS}" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)"
else
cd ${stdbuilddir} && AWK=/usr/bin/awk CC="${DEB_HOST_GNU_TYPE}-gcc" \
${topdir}/configure ${COMMON_CONF_FLAGS} ${STD_CONF_FLAGS} \
--build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE) \
- CFLAGS="${CFLAGS}"
+ CFLAGS="${CFLAGS}" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)"
endif
# specially-built MIPS libs
@@ -242,12 +252,12 @@ ${CFGBFSTAMP}:
ifeq ($(DEB_BUILD_ARCH),$(DEB_HOST_ARCH))
cd ${bfbuilddir} && AWK=/usr/bin/awk \
${topdir}/configure ${COMMON_CONF_FLAGS} ${BF_CONF_FLAGS} \
- CFLAGS="${CFLAGS} ${BF_CFLAGS}"
+ CFLAGS="${CFLAGS} ${BF_CFLAGS}" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)"
else
cd ${bfbuilddir} && AWK=/usr/bin/awk CC="${DEB_HOST_GNU_TYPE}-gcc" \
${topdir}/configure ${COMMON_CONF_FLAGS} ${BF_CONF_FLAGS} \
--build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE) \
- CFLAGS="${CFLAGS}"
+ CFLAGS="${CFLAGS}" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)"
endif
mkdir -p ${STAMPSDIR}
touch ${CFGBFSTAMP}
@@ -271,7 +281,7 @@ else
cd ${staticbuilddir} && AWK=/usr/bin/awk CC="${DEB_HOST_GNU_TYPE}-gcc" \
${topdir}/configure ${COMMON_CONF_FLAGS} ${STATIC_CONF_FLAGS} \
--build=$(DEB_BUILD_GNU_TYPE) --host=$(DEB_HOST_GNU_TYPE) \
- CFLAGS="${CFLAGS}"
+ CFLAGS="${CFLAGS}" CPPFLAGS="$(CPPFLAGS)" LDFLAGS="$(LDFLAGS)"
endif
mkdir -p ${STAMPSDIR}
touch ${CFGSTATICSTAMP}
@@ -633,4 +643,10 @@ endif
binary: binary-indep binary-arch
-.PHONY: binary binary-arch binary-indep clean checkroot mrproper debian-files
+.PHONY: binary binary-arch binary-indep clean checkroot mrproper \
+ debug_flags debian-files
+
+debug_flags:
+ @echo CFLAGS is $(CFLAGS)
+ @echo LDFLAGS is $(LDFLAGS)
+ @echo CPPFLAGS is $(CPPFLAGS)