Commit 45c4e4ff authored by Joe Orton's avatar Joe Orton
Browse files

* configure.in: Add --enable-pie flag; define PICFLAGS and PILDFLAGS.

* build/rules.mk.in: Factor out BASE_CC and BASE_CXX from COMPILE.
Substitute PICFLAGS into COMPILE and CXX_COMPILE, but not into
{SH,LT}{,_CXX}_COMPILE.  Substitute PILDFLAGS into LINK but not
{SH,MOD}_LINK.

Reviewed by: jerenkrantz


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@126362 13f79535-47bb-0310-9956-ffa450edef68
parent 9d798870
Loading
Loading
Loading
Loading
+4 −0
Changes for CHANGES: 4 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -2,6 +2,10 @@ Changes with Apache 2.1.3
  [Remove entries to the current 2.0 section below, when backported]
  *) Add --enable-pie flag to configure, to build httpd as a Position
     Independent Executable where supported (GCC/binutils).
     [Joe Orton]
  *) proxy_balancer: Add in load-balancing via weighted traffic
     byte count. [Jim Jagielski]
+8 −5
Changes for build/rules.mk.in: 8 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -31,18 +31,21 @@ ALL_INCLUDES = $(INCLUDES) $(EXTRA_INCLUDES)

# Compile commands

COMPILE      = $(CC)  $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(ALL_INCLUDES)
CXX_COMPILE  = $(CXX) $(ALL_CXXFLAGS) $(ALL_CPPFLAGS) $(ALL_INCLUDES)
BASE_CC  = $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(ALL_INCLUDES)
BASE_CXX = $(CXX) $(ALL_CXXFLAGS) $(ALL_CPPFLAGS) $(ALL_INCLUDES)

SH_COMPILE     = $(LIBTOOL) --mode=compile $(COMPILE) @SHLTCFLAGS@ -c $< && touch $@
SH_CXX_COMPILE = $(LIBTOOL) --mode=compile $(CXX_COMPILE) @SHLTCFLAGS@ -c $< && touch $@
COMPILE      = $(BASE_CC) @PICFLAGS@
CXX_COMPILE  = $(BASE_CXX) @PICFLAGS@

SH_COMPILE     = $(LIBTOOL) --mode=compile $(BASE_CC) @SHLTCFLAGS@ -c $< && touch $@
SH_CXX_COMPILE = $(LIBTOOL) --mode=compile $(BASE_CXX) @SHLTCFLAGS@ -c $< && touch $@

LT_COMPILE     = $(LIBTOOL) --mode=compile $(COMPILE) @LTCFLAGS@ -c $< && touch $@
LT_CXX_COMPILE = $(LIBTOOL) --mode=compile $(CXX_COMPILE) @LTCFLAGS@ -c $< && touch $@

# Link-related commands

LINK     = $(LIBTOOL) --mode=link $(CC) $(ALL_CFLAGS) $(LT_LDFLAGS) $(ALL_LDFLAGS) -o $@
LINK     = $(LIBTOOL) --mode=link $(CC) $(ALL_CFLAGS) @PILDFLAGS@ $(LT_LDFLAGS) $(ALL_LDFLAGS) -o $@
SH_LINK  = $(SH_LIBTOOL) --mode=link $(CC) $(ALL_CFLAGS) $(LT_LDFLAGS) $(ALL_LDFLAGS) $(SH_LDFLAGS) $(CORE_IMPLIB) $(SH_LIBS) -o $@
MOD_LINK = $(LIBTOOL) --mode=link $(CC) $(ALL_CFLAGS) -static $(LT_LDFLAGS) $(ALL_LDFLAGS) -o $@

+23 −0
Changes for configure.in: 23 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -394,6 +394,29 @@ AC_ARG_ENABLE(maintainer-mode,APACHE_HELP_STRING(--enable-maintainer-mode,Turn o
  APR_ADDTO(CPPFLAGS, -DAP_DEBUG)
])dnl

dnl Conditionally enable PIE support for GNU toolchains.
AC_ARG_ENABLE(pie,APACHE_HELP_STRING(--enable-pie,Build httpd as a Position Independent Executable))
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_TRY_RUN([static int foo[30000]; int main () { return 0; }],
      [ap_cv_cc_pie=yes], [ap_cv_cc_pie=no], [ap_cv_cc_pie=yes])
     CFLAGS=$save_CFLAGS
     LDFLAGS=$save_LDFLAGS
   ])
   if test "$ap_cv_cc_pie" = "yes"; then
     PICFLAGS="-fPIE"
     PILDFLAGS="-pie"
   else
     AC_ERROR([--enable-pie requested but $CC failed using PIE flags])
   fi
fi
AC_SUBST(PICFLAGS)
AC_SUBST(PILDFLAGS)

prefix="$orig_prefix"
APACHE_ENABLE_MODULES