]> git.proxmox.com Git - libtpms.git/commitdiff
build: do not set -D_FORTIFY_SOURCE=2 when -O0 is set or -O is missing
authorStefan Berger <stefanb@linux.vnet.ibm.com>
Fri, 1 May 2015 16:06:07 +0000 (12:06 -0400)
committerStefan Berger <stefanb@linux.vnet.ibm.com>
Fri, 1 May 2015 16:07:21 +0000 (12:07 -0400)
-D_FORTIFY_SOURCE needs optimization, so we do not set it if -O0 is
set or -O is missing.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
configure.ac
dist/libtpms.spec.in

index 3fb04e2545c4fa9baba1afebca55369881a4215d..2fa9ffb093998bcab495ad8d4cba35f66a7c981b 100644 (file)
@@ -136,7 +136,13 @@ AC_C_INLINE
 AC_TYPE_SIZE_T
 
 HARDENING_CFLAGS="-fstack-protector-strong -Wstack-protector "
-HARDENING_CFLAGS+="-D_FORTIFY_SOURCE=2 "
+
+dnl Must not have -O0 but must have a -O for -D_FORTIFY_SOURCE=2
+TMP1="$(echo $CFLAGS | sed -n 's/.*\(-O0\).*/\1/p')"
+TMP2="$(echo $CFLAGS | sed -n 's/.*\(-O\).*/\1/p')"
+if test -z "$TMP1" && test -n "$TPM2"; then
+    HARDENING_CFLAGS+="-D_FORTIFY_SOURCE=2 "
+fi
 dnl Check ld for 'relro' and 'now'
 if $LD --help 2>&1 | $GREP '\-z relro ' > /dev/null; then
   HARDENING_CFLAGS+="-Wl,-z,relro "
index c003629eab68714469dff11ff0d3fce6966d4b77..b94f56563967068482f81cbb95044ffed9f68f9d 100644 (file)
@@ -28,7 +28,7 @@ BuildRequires:  nss-softokn-freebl-devel >= 3.12.9-2
 BuildRequires:  nss-softokn-freebl-static >= 3.12.9-2
 %endif
 BuildRequires:  nss-softokn-devel >= 3.12.9-2, gmp-devel
-BuildRequires:  pkgconfig gawk
+BuildRequires:  pkgconfig gawk sed
 BuildRequires:  automake autoconf libtool bash coreutils
 Requires:       nss-softokn-freebl >= 3.12.9-2, nss-softokn >= 3.12.9-2
 Requires:       gmp