[build] Test for GNU-style PIE support in toolchain and enable

2008-08-13 Paul P Komkoff Jr <i@stingr.net>

	* configure.ac: add a configure flag and autoconf macro, which will
	  determine if your toolchain supports PIE.
	* */Makefile.am: add corresponding CFLAGS and LDFLAGS into
	  appropriate places.

Signed-off-by: Paul Jakma <paul@quagga.net>
This commit is contained in:
Paul P Komkoff Jr 2008-08-13 16:17:04 +01:00 committed by Paul Jakma
parent d664ae1182
commit 46bc0e432e
12 changed files with 60 additions and 1 deletions

View file

@ -4,6 +4,9 @@ INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib @SNMP_INCLUDES@
DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\" DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
INSTALL_SDATA=@INSTALL@ -m 600 INSTALL_SDATA=@INSTALL@ -m 600
AM_CFLAGS = $(PICFLAGS)
AM_LDFLAGS = $(PILDFLAGS)
noinst_LIBRARIES = libbgp.a noinst_LIBRARIES = libbgp.a
sbin_PROGRAMS = bgpd sbin_PROGRAMS = bgpd

View file

@ -60,9 +60,10 @@ fi
dnl -------------------- dnl --------------------
dnl Check CC and friends dnl Check CC and friends
dnl -------------------- dnl --------------------
AC_LANG([C])
AC_PROG_CC AC_PROG_CC
AC_PROG_CPP AC_PROG_CPP
AM_PROG_CC_C_O
AC_PROG_EGREP AC_PROG_EGREP
dnl autoconf 2.59 appears not to support AC_PROG_SED dnl autoconf 2.59 appears not to support AC_PROG_SED
@ -1395,6 +1396,31 @@ dnl ----------
CONFDATE=`date '+%Y%m%d'` CONFDATE=`date '+%Y%m%d'`
AC_SUBST(CONFDATE) AC_SUBST(CONFDATE)
dnl Conditionally enable PIE support for GNU toolchains.
enable_pie=yes
AC_ARG_ENABLE(pie, AS_HELP_STRING([--disable-pie], [Do not build tools as a Position Independent Executables]))
if test "$enable_pie" = "yes"; then
AC_CACHE_CHECK([whether $CC accepts PIE flags], [ap_cv_cc_pie], [
save_CFLAGS=$CFLAGS
save_LDFLAGS=$LDFLAGS
CFLAGS="$CFLAGS -fPIE"
LDFLAGS="$LDFLAGS -pie"
AC_LINK_IFELSE([AC_LANG_SOURCE([[static int foo[30000]; int main () { return 0; }]])],
[ap_cv_cc_pie=yes], [ap_cv_cc_pie=no]
)
CFLAGS=$save_CFLAGS
LDFLAGS=$save_LDFLAGS
])
if test "$ap_cv_cc_pie" = "yes"; then
PICFLAGS="-fPIE"
PILDFLAGS="-pie"
fi
fi
AC_SUBST(PICFLAGS)
AC_SUBST(PILDFLAGS)
dnl ------------------------------ dnl ------------------------------
dnl set paths for state directory dnl set paths for state directory
dnl ------------------------------ dnl ------------------------------

View file

@ -3,6 +3,9 @@
INCLUDES = @GUILE_CFLAGS@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib INCLUDES = @GUILE_CFLAGS@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib
DEFS = @DEFS@ -I. -I$(srcdir) DEFS = @DEFS@ -I. -I$(srcdir)
AM_CFLAGS = $(PICFLAGS)
AM_LDFLAGS = $(PILDFLAGS)
bin_PROGRAMS = zebra-guile bin_PROGRAMS = zebra-guile
zebra_guile_SOURCES = zebra-guile.c zebra-support.c guile-bgp.c zebra_guile_SOURCES = zebra-guile.c zebra-support.c guile-bgp.c
noinst_HEADERS = zebra-guile.h noinst_HEADERS = zebra-guile.h

View file

@ -5,6 +5,10 @@ INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib \
DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\" DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
INSTALL_SDATA=@INSTALL@ -m 600 INSTALL_SDATA=@INSTALL@ -m 600
LIBS = @LIBS@ LIBS = @LIBS@
AM_CFLAGS = $(PICFLAGS)
AM_LDFLAGS = $(PILDFLAGS)
noinst_LIBRARIES = libisis.a noinst_LIBRARIES = libisis.a
sbin_PROGRAMS = isisd sbin_PROGRAMS = isisd
SUBDIRS = topology SUBDIRS = topology

View file

@ -4,6 +4,9 @@ INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib @SNMP_INCLUDES@
DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\" DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
INSTALL_SDATA=@INSTALL@ -m 600 INSTALL_SDATA=@INSTALL@ -m 600
AM_CFLAGS = $(PICFLAGS)
AM_LDFLAGS = $(PILDFLAGS)
noinst_LIBRARIES = libospf6.a noinst_LIBRARIES = libospf6.a
sbin_PROGRAMS = ospf6d sbin_PROGRAMS = ospf6d

View file

@ -21,4 +21,6 @@ ospfclient_SOURCES = \
ospfclient_LDADD = libospfapiclient.la \ ospfclient_LDADD = libospfapiclient.la \
../ospfd/libospf.la ../lib/libzebra.la @LIBCAP@ ../ospfd/libospf.la ../lib/libzebra.la @LIBCAP@
ospfclient_CFLAGS = $(AM_CFLAGS) $(PICFLAGS)
ospfclient_LDFLAGS = $(AM_LDFLAGS) $(PILDFLAGS)

View file

@ -4,6 +4,9 @@ INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib @SNMP_INCLUDES@
DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\" DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
INSTALL_SDATA=@INSTALL@ -m 600 INSTALL_SDATA=@INSTALL@ -m 600
AM_CFLAGS = $(PICFLAGS)
AM_LDFLAGS = $(PILDFLAGS)
noinst_LIBRARIES = librip.a noinst_LIBRARIES = librip.a
sbin_PROGRAMS = ripd sbin_PROGRAMS = ripd

View file

@ -4,6 +4,9 @@ INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib @SNMP_INCLUDES@
DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\" DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
INSTALL_SDATA=@INSTALL@ -m 600 INSTALL_SDATA=@INSTALL@ -m 600
AM_CFLAGS = $(PICFLAGS)
AM_LDFLAGS = $(PILDFLAGS)
noinst_LIBRARIES = libripng.a noinst_LIBRARIES = libripng.a
sbin_PROGRAMS = ripngd sbin_PROGRAMS = ripngd

View file

@ -1,6 +1,9 @@
INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib INCLUDES = @INCLUDES@ -I.. -I$(top_srcdir) -I$(top_srcdir)/lib
DEFS = @DEFS@ $(LOCAL_OPTS) -DSYSCONFDIR=\"$(sysconfdir)/\" DEFS = @DEFS@ $(LOCAL_OPTS) -DSYSCONFDIR=\"$(sysconfdir)/\"
AM_CFLAGS = $(PICFLAGS)
AM_LDFLAGS = $(PILDFLAGS)
noinst_PROGRAMS = testsig testbuffer testmemory heavy heavywq heavythread \ noinst_PROGRAMS = testsig testbuffer testmemory heavy heavywq heavythread \
aspathtest testprivs teststream testbgpcap ecommtest \ aspathtest testprivs teststream testbgpcap ecommtest \
testbgpmpattr testbgpmpattr

View file

@ -5,6 +5,9 @@ DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)/\"
LIBS = @LIBS@ @CURSES@ @LIBPAM@ LIBS = @LIBS@ @CURSES@ @LIBPAM@
AM_CFLAGS = $(PICFLAGS)
AM_LDFLAGS = $(PILDFLAGS)
bin_PROGRAMS = vtysh bin_PROGRAMS = vtysh
vtysh_SOURCES = vtysh_main.c vtysh.c vtysh_user.c vtysh_config.c vtysh_SOURCES = vtysh_main.c vtysh.c vtysh_user.c vtysh_config.c

View file

@ -3,6 +3,9 @@
INCLUDES = @INCLUDES@ -I$(top_srcdir) -I$(top_srcdir)/lib INCLUDES = @INCLUDES@ -I$(top_srcdir) -I$(top_srcdir)/lib
DEFS = @DEFS@ -DSTATEDIR=\"$(localstatedir)/\" DEFS = @DEFS@ -DSTATEDIR=\"$(localstatedir)/\"
AM_CFLAGS = $(PICFLAGS)
AM_LDFLAGS = $(PILDFLAGS)
sbin_PROGRAMS = watchquagga sbin_PROGRAMS = watchquagga
watchquagga_SOURCES = watchquagga.c watchquagga_SOURCES = watchquagga.c

View file

@ -19,6 +19,9 @@ ioctl_method = @IOCTL_METHOD@
otherobj = $(ioctl_method) $(ipforward) $(if_method) $(if_proc) \ otherobj = $(ioctl_method) $(ipforward) $(if_method) $(if_proc) \
$(rt_method) $(rtread_method) $(kernel_method) $(other_method) $(rt_method) $(rtread_method) $(kernel_method) $(other_method)
AM_CFLAGS = $(PICFLAGS)
AM_LDFLAGS = $(PILDFLAGS)
sbin_PROGRAMS = zebra sbin_PROGRAMS = zebra
noinst_PROGRAMS = testzebra noinst_PROGRAMS = testzebra