Commit 33dc62a2 authored by Roy T. Fielding's avatar Roy T. Fielding
Browse files

Completely revamp configure so that it preserves the standard make

variables CPPFLAGS, CFLAGS, CXXFLAGS, LDFLAGS and LIBS by moving
the configure additions to EXTRA_* variables.  Also, allow the user
to specify NOTEST_* values for all of the above, which eliminates the
need for THREAD_CPPFLAGS, THREAD_CFLAGS, and OPTIM.  Fix the setting
of INCLUDES and EXTRA_INCLUDES.  Check flags as they are added to
avoid pointless duplications.  Fix the order in which flags are given
on the compile and link lines.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@88960 13f79535-47bb-0310-9956-ffa450edef68
parent 0b8137d3
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
Changes with Apache 2.0.18-dev

  *) Completely revamp configure so that it preserves the standard make
     variables CPPFLAGS, CFLAGS, CXXFLAGS, LDFLAGS and LIBS by moving
     the configure additions to EXTRA_* variables.  Also, allow the user
     to specify NOTEST_* values for all of the above, which eliminates the
     need for THREAD_CPPFLAGS, THREAD_CFLAGS, and OPTIM.  Fix the setting
     of INCLUDES and EXTRA_INCLUDES.  Check flags as they are added to
     avoid pointless duplications.  Fix the order in which flags are given
     on the compile and link lines.  [Roy Fielding]

  *) Get mod_tls to compile/work better on Windows.  PR #7612
     [Bernhard Schrenk <b.schrenk@improx.com>]

+20 −16
Original line number Diff line number Diff line
@@ -144,7 +144,7 @@
     additional modules mod_rewrite and mod_speling for later loading
     through the DSO mechanism:

     $ CC="pgcc" OPTIM="-O2" \
     $ CC="pgcc" CFLAGS="-O2" \
       ./configure --prefix=/sw/pkg/apache \
                   --enable-rewrite=shared \
                   --enable-speling=shared
@@ -155,14 +155,14 @@

     Reference:

     $ [CC=...]        [CFLAGS_SHLIB=...]           [TARGET=...]
       [OPTIM=...]     [LD_SHLIB=...]
       [CFLAGS=...]    [LDFLAGS_SHLIB=...]        
       [INCLUDES=...]  [LDFLAGS_SHLIB_EXPORT=...] 
       [LDFLAGS=...]   [RANLIB=...]  
       [LIBS=...]      [DEPS=...]
       [NOTEST_CFLAGS=...]
       [NOTEST_LDFLAGS=...]
     $ [CC=...]        [TARGET=...]
       [CPPFLAGS=...]  [NOTEST_CPPFLAGS=...]
       [CFLAGS=...]    [NOTEST_CFLAGS=...]
       [CXXFLAGS=...]  [NOTEST_CXXFLAGS=...]
       [LDFLAGS=...]   [NOTEST_LDFLAGS=...]
       [LIBS=...]      [NOTEST_LIBS=...]
       [INCLUDES=...]  [SHLIB_PATH=...] 

       ./configure
           [--quiet]         [--prefix=DIR]            [--enable-NAME=(shared)]
           [--verbose]       [--exec-prefix=PREFIX]    [--disable-NAME]
@@ -183,14 +183,18 @@
                             [--without-support]       [--suexec-gidmin=GID]
                             [--without-confadjust]    [--suexec-safepath=PATH]
                             [--without-execstrip]
			     [--server-uid=UID]        [--with-maintainter-mode]
			     [--server-uid=UID]
			     [--server-gid=GID]

     Use the CC, OPTIM, CFLAGS, INCLUDES, LDFLAGS, LIBS, CFLAGS_SHLIB,
     LD_SHLIB, LDFLAGS_SHLIB, LDFLAGS_SHLIB_EXPORT, RANLIB, DEPS and
     TARGET environment variables to override and expand the corresponding
     default entries as determined by configure. Use NOTEST_CFLAGS
     and NOTEST_LDFLAGS to add entries that should be used only during
                             [--enable-maintainter-mode]
                             [--enable-debug]

     Use the CC, CPPFLAGS, CFLAGS, CXXFLAGS, LDFLAGS, LIBS, INCLUDES,
     SHLIB_PATH and TARGET environment variables to override or expand the
     corresponding default entries as determined by configure.

     Use NOTEST_CPPFLAGS, NOTEST_CFLAGS, NOTEST_CXXFLAGS, NOTEST_LDFLAGS,
     and NOTEST_LIBS to add entries that should only be used during
     the actual build and compilation of Apache, such as -Werror.

     Use the --prefix=PREFIX and --exec-prefix=EPREFIX options to
@@ -458,7 +462,7 @@
       subscribe to the `new-httpd' mailing list as described at
       http://www.apache.org/foundation/mailinglists.html

     Thanks for running Apache.
     Thanks for running Apache httpd.

                                          The Apache Group
                                          http://www.apache.org/
+15 −15
Original line number Diff line number Diff line
@@ -54,21 +54,32 @@ AC_DEFUN(APACHE_GEN_CONFIG_VARS,[
  APACHE_SUBST(prefix)
  APACHE_SUBST(AWK)
  APACHE_SUBST(CC)
  APACHE_SUBST(CFLAGS)
  APACHE_SUBST(CPPFLAGS)
  APACHE_SUBST(CXX)
  APACHE_SUBST(CPPFLAGS)
  APACHE_SUBST(CFLAGS)
  APACHE_SUBST(CXXFLAGS)
  APACHE_SUBST(LTFLAGS)
  APACHE_SUBST(LDFLAGS)
  APACHE_SUBST(SH_LDFLAGS)
  APACHE_SUBST(HTTPD_LDFLAGS)
  APACHE_SUBST(LIBS)
  APACHE_SUBST(DEFS)
  APACHE_SUBST(INCLUDES)
  APACHE_SUBST(NOTEST_CPPFLAGS)
  APACHE_SUBST(NOTEST_CFLAGS)
  APACHE_SUBST(NOTEST_CXXFLAGS)
  APACHE_SUBST(NOTEST_LDFLAGS)
  APACHE_SUBST(NOTEST_LIBS)
  APACHE_SUBST(EXTRA_CPPFLAGS)
  APACHE_SUBST(EXTRA_CFLAGS)
  APACHE_SUBST(EXTRA_CXXFLAGS)
  APACHE_SUBST(EXTRA_LDFLAGS)
  APACHE_SUBST(EXTRA_LIBS)
  APACHE_SUBST(EXTRA_INCLUDES)
  APACHE_SUBST(LIBTOOL)
  APACHE_SUBST(SHELL)
  APACHE_SUBST(MODULE_DIRS)
  APACHE_SUBST(PORT)
  APACHE_SUBST(NOTEST_CFLAGS)
  APACHE_SUBST(NOTEST_LDFLAGS)
  APACHE_SUBST(CORE_IMPLIB_FILE)
  APACHE_SUBST(CORE_IMPLIB)
  APACHE_SUBST(SH_LIBTOOL)
@@ -102,17 +113,6 @@ AC_DEFUN(APACHE_OUTPUT, [
  APACHE_OUTPUT_FILES="$APACHE_OUTPUT_FILES $1"
])

dnl
dnl AC_ADD_LIBRARY(library)
dnl
dnl add a library to the link line
dnl
AC_DEFUN(AC_ADD_LIBRARY,[
  APACHE_ONCE(LIBRARY, $1, [
    EXTRA_LIBS="$EXTRA_LIBS -l$1"
  ])
])

dnl
dnl AC_CHECK_DEFINE(macro, headerfile)
dnl
+19 −10
Original line number Diff line number Diff line
@@ -56,11 +56,22 @@

include $(top_builddir)/config_vars.mk

# Combine all of the flags together in the proper order so that
# the user-defined flags can always override the configure ones, if needed.
# Note that includes are listed after the flags because -I options have
# left-to-right precedence and CPPFLAGS may include user-defined overrides.
#
ALL_CPPFLAGS = $(DEFS) $(EXTRA_CPPFLAGS) $(NOTEST_CPPFLAGS) $(CPPFLAGS)
ALL_CFLAGS   = $(EXTRA_CFLAGS) $(NOTEST_CFLAGS) $(CFLAGS)
ALL_CXXFLAGS = $(EXTRA_CXXFLAGS) $(NOTEST_CXXFLAGS) $(CXXFLAGS)
ALL_LDFLAGS  = $(EXTRA_LDFLAGS) $(NOTEST_LDFLAGS) $(LDFLAGS)
ALL_LIBS     = $(EXTRA_LIBS) $(NOTEST_LIBS) $(LIBS)
ALL_INCLUDES = $(INCLUDES) $(EXTRA_INCLUDES)

# Compile commands

COMMON_FLAGS = $(DEFS) $(INCLUDES) $(EXTRA_INCLUDES) $(EXTRA_CPPFLAGS) $(CPPFLAGS)
COMPILE      = $(CC)  $(COMMON_FLAGS) $(EXTRA_CFLAGS) $(CFLAGS) $(NOTEST_CFLAGS)
CXX_COMPILE  = $(CXX) $(COMMON_FLAGS) $(EXTRA_CXXFLAGS) $(CXXFLAGS)
COMPILE      = $(CC)  $(ALL_CPPFLAGS) $(ALL_CFLAGS) $(ALL_INCLUDES)
CXX_COMPILE  = $(CXX) $(ALL_CPPFLAGS) $(ALL_CXXFLAGS) $(ALL_INCLUDES)

SH_COMPILE     = $(SH_LIBTOOL) --mode=compile $(COMPILE) -c $< && touch $@
SH_CXX_COMPILE = $(SH_LIBTOOL) --mode=compile $(CXX_COMPILE) -c $< && touch $@
@@ -70,9 +81,9 @@ LT_CXX_COMPILE = $(LIBTOOL) --mode=compile $(CXX_COMPILE) -c $< && touch $@

# Link-related commands

LINK     = $(LIBTOOL) --mode=link $(COMPILE) $(LTFLAGS) $(LDFLAGS) $(NOTEST_LDFLAGS) -o $@
SH_LINK  = $(SH_LIBTOOL) --mode=link $(COMPILE) $(LTFLAGS) $(LDFLAGS) $(EXTRA_LDFLAGS) $(NOTEST_LDFLAGS) $(SH_LDFLAGS) $(CORE_IMPLIB) -o $@
MOD_LINK = $(LIBTOOL) --mode=link $(COMPILE) -module $(LTFLAGS) $(LDFLAGS) $(NOTEST_LDFLAGS) -o $@
LINK     = $(LIBTOOL) --mode=link $(COMPILE) $(LTFLAGS) $(ALL_LDFLAGS) -o $@
SH_LINK  = $(SH_LIBTOOL) --mode=link $(COMPILE) $(LTFLAGS) $(ALL_LDFLAGS) $(SH_LDFLAGS) $(CORE_IMPLIB) -o $@
MOD_LINK = $(LIBTOOL) --mode=link $(COMPILE) -module $(LTFLAGS) $(ALL_LDFLAGS) -o $@

# Cross compile commands

@@ -83,8 +94,6 @@ INSTALL = $(abs_srcdir)/build/install.sh -c
INSTALL_DATA = $(INSTALL) -m 644
INSTALL_PROGRAM = $(INSTALL) -m 755

DEFS = -I. -I$(srcdir) -I$(top_srcdir)/server/mpm/$(MPM_NAME) -I$(top_srcdir)/modules/http

# Suffixes

CXX_SUFFIX = cpp
@@ -214,9 +223,9 @@ distclean-p depend-p clean-p:

depend: depend-recursive
	if test "`echo $(srcdir)/*.c`" != "$(srcdir)'/*.c'"; then \
	    gcc -MM $(COMMON_FLAGS) $(srcdir)/*.c | sed 's/\.o:/.lo:/' > $(builddir)/.deps || true;           \
	    gcc -MM $(ALL_CPPFLAGS) $(ALL_INCLUDES) $(srcdir)/*.c | sed 's/\.o:/.lo:/' > $(builddir)/.deps || true;           \
	fi
#	    test "`echo *.c`" = '*.c' || perl $(top_srcdir)/build/mkdep.perl $(CPP) $(INCLUDES) $(EXTRA_INCLUDES) *.c > .deps
#	    test "`echo *.c`" = '*.c' || perl $(top_srcdir)/build/mkdep.perl $(CPP) $(ALL_CPPFLAGS) $(ALL_INCLUDES) *.c > .deps

clean: clean-recursive clean-x

+67 −33
Original line number Diff line number Diff line
@@ -21,15 +21,53 @@ sinclude(srclib/apr/build/libtool.m4)
sinclude(hints.m4)
sinclude(acinclude.m4)

dnl Save user-defined environment settings for later restoration
dnl
APR_SAVE_THE_ENVIRONMENT(CPPFLAGS)
APR_SAVE_THE_ENVIRONMENT(CFLAGS)
APR_SAVE_THE_ENVIRONMENT(CXXFLAGS)
APR_SAVE_THE_ENVIRONMENT(LDFLAGS)
APR_SAVE_THE_ENVIRONMENT(LIBS)
APR_SAVE_THE_ENVIRONMENT(INCLUDES)

dnl Generate ./config.nice for reproducing runs of configure
dnl
APR_CONFIG_NICE(config.nice)

nl='
'
dnl ## Run configure for packages Apache uses

echo $ac_n "${nl}Configuring Apache Portable Runtime library ...${nl}"

APR_SUBDIR_CONFIG(srclib/apr, "$apache_apr_flags --disable-shared")

echo $ac_n "${nl}Configuring Apache Portable Runtime Utility library...${nl}"

APR_SUBDIR_CONFIG(srclib/apr-util, "--with-apr=../apr --disable-shared")

echo $ac_n "${nl}Configuring PCRE regular expression library ...${nl}"

APR_SUBDIR_CONFIG(srclib/pcre)

echo $ac_n "${nl}Configuring Apache httpd ...${nl}"

echo $ac_n "obtaining flag settings from the sub-configures...${nl}"
. ./srclib/apr/APRVARS

dnl Generate ./config.nice for reproducing runs of configure
dnl Now that we have APR's EXTRA_flags in our environment, move them over
dnl to the normal variables to avoid duplications and use them for testing.
dnl We ignore EXTRA_INCLUDES because our own includes will encompass them.
dnl
APR_CONFIG_NICE(config.nice)
APR_ADDTO(CFLAGS, $EXTRA_CFLAGS)
APR_ADDTO(CPPFLAGS, $EXTRA_CPPFLAGS)
APR_ADDTO(LDFLAGS, $EXTRA_LDFLAGS)
APR_ADDTO(LIBS, $EXTRA_LIBS)
EXTRA_CFLAGS=
EXTRA_CPPFLAGS=
EXTRA_LDFLAGS=
EXTRA_LIBS=
EXTRA_INCLUDES=

dnl XXX we can't just use AC_PREFIX_DEFAULT because that isn't subbed in
dnl by configure until it is too late.  Is that how it should be or not?
@@ -47,6 +85,9 @@ dnl then we are running in VPATH mode.

if test "$abs_builddir" != "$abs_srcdir"; then
  USE_VPATH=1
  APR_ADDTO(INCLUDES, [-I. -I\$(srcdir) -I\$(top_builddir)/os/\$(OS_DIR) -I\$(top_srcdir)/os/\$(OS_DIR) -I\$(top_builddir)/server/mpm/\$(MPM_NAME) -I\$(top_srcdir)/server/mpm/\$(MPM_NAME) -I\$(top_builddir)/modules/http -I\$(top_srcdir)/modules/http -I\$(top_builddir)/include -I\$(top_srcdir)/include -I\$(top_builddir)/srclib/apr/include -I\$(top_srcdir)/srclib/apr/include -I\$(top_builddir)/srclib/apr-util/include -I\$(top_srcdir)/srclib/apr-util/include])
else
  APR_ADDTO(INCLUDES, [-I. -I\$(top_srcdir)/os/\$(OS_DIR) -I\$(top_srcdir)/server/mpm/\$(MPM_NAME) -I\$(top_srcdir)/modules/http -I\$(top_srcdir)/include -I\$(top_srcdir)/srclib/apr/include -I\$(top_srcdir)/srclib/apr-util/include])
fi

AC_CANONICAL_SYSTEM
@@ -89,16 +130,6 @@ AC_PROG_LN_S
AC_CHECK_TOOL(RANLIB, ranlib, true)
dnl AC_PATH_PROG(PERL_PATH, perl)

#
# Play with CPPFLAGS given what was learned from APR_PRELOAD.
#
# XXX: APR only sets this if threads are enabled.  Either APR should be
# fixed to always set it (most likely), or we should test for threads.
#
if test -n "$THREAD_CPPFLAGS"; then
    CPPFLAGS="$CPPFLAGS $THREAD_CPPFLAGS"
fi

dnl various OS checks that apparently set required flags
AC_AIX
AC_ISC_POSIX
@@ -144,40 +175,31 @@ AC_CHECK_LIB(nsl, gethostbyname)
AC_CHECK_LIB(nsl, gethostname)
AC_CHECK_LIB(socket, socket)

AC_ARG_WITH(optim,[  --with-optim="FLAG"       obsolete (use OPTIM environment variable)],
        [AC_MSG_ERROR('option --with-optim is obsolete; use OPTIM environment variable instead')])

AC_ARG_WITH(port,[  --with-port=PORT        Port on which to listen (default is 80)],
        [if test "$withval" = "yes"; then AC_MSG_ERROR('option --with-port requires a value (the TCP port number)'); else PORT="$withval"; fi],
	[PORT=80])

AC_ARG_ENABLE(debug,[  --enable-debug            Turn on debugging and compile time warnings],
        [CFLAGS="$CFLAGS -g"; if test "$GCC" = "yes"; then CFLAGS="$CFLAGS -Wall"; fi])
  [APR_ADDTO(CFLAGS,-g)
   if test "$GCC" = "yes"; then
     APR_ADDTO(CFLAGS,-Wall)
   fi
])dnl

AC_ARG_ENABLE(maintainer-mode,[  --enable-maintainer-mode  Turn on debugging and compile time warnings],
        [CFLAGS="$CFLAGS -g"; if test "$GCC" = "yes"; then CFLAGS="$CFLAGS -Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -DAP_DEBUG"; fi])
  [APR_ADDTO(CFLAGS,-g)
   if test "$GCC" = "yes"; then
     APR_ADDTO(CFLAGS,[-Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -DAP_DEBUG])
   fi
])dnl

APACHE_ENABLE_LAYOUT
APACHE_ENABLE_MODULES

INCLUDES="-I\$(top_srcdir)/include -I\$(top_srcdir)/srclib/apr/include -I\$(top_srcdir)/srclib/apr-util/include"
if test -n "$USE_VPATH"; then
  INCLUDES="$INCLUDES -I\$(top_builddir)/include -I\$(top_builddir)/srclib/apr/include"
fi

dnl reading config stubs
esyscmd(./build/config-stubs .)

INCLUDES="$INCLUDES -I\$(top_srcdir)/os/\$(OS_DIR)"
EXTRA_LIBS="$EXTRA_LIBS $LIBS"
EXTRA_LDFLAGS="$LDFLAGS"
LIBS=""
LDFLAGS=""
APACHE_SUBST(progname)
APACHE_SUBST(EXTRA_CFLAGS)
APACHE_SUBST(EXTRA_LDFLAGS)
APACHE_SUBST(EXTRA_LIBS)
APACHE_SUBST(INCLUDES)
APACHE_SUBST(MPM_LIB)
APACHE_SUBST(OS)
APACHE_SUBST(OS_DIR)
@@ -205,7 +227,7 @@ if test "$apache_need_shared" = "yes"; then
      POST_SHARED_CMDS='rm $(top_builddir)/_APP_'
      ;;
    *os390)
      CFLAGS="$CFLAGS -Wc,DLL,EXPORTALL"
      APR_ADDTO(CFLAGS, [-Wc,DLL,EXPORTALL])
      ;;
  esac
  shared_build="shared-modules"
@@ -292,9 +314,21 @@ fi

dnl get the exported vars from APRUTIL
. ./srclib/apr-util/export_vars.sh
EXTRA_LIBS="$EXTRA_LIBS $APRUTIL_EXPORT_LIBS"
APR_ADDTO(LIBS, $APRUTIL_EXPORT_LIBS)
AP_LIBS="$AP_LIBS $LIBTOOL_LIBS"

dnl ## Finalize the variables
echo $ac_n "${nl}Restore user-defined environment settings...${nl}"

APR_RESTORE_THE_ENVIRONMENT(CPPFLAGS, EXTRA_)
APR_RESTORE_THE_ENVIRONMENT(CFLAGS, EXTRA_)
APR_RESTORE_THE_ENVIRONMENT(CXXFLAGS, EXTRA_)
APR_RESTORE_THE_ENVIRONMENT(LDFLAGS, EXTRA_)
APR_RESTORE_THE_ENVIRONMENT(LIBS, EXTRA_)
APR_RESTORE_THE_ENVIRONMENT(INCLUDES, EXTRA_)

echo $ac_n "${nl}Construct makefiles and header files...${nl}"

APACHE_GEN_CONFIG_VARS

dnl ## Build modules.c
Loading