1
0
mirror of https://github.com/moparisthebest/curl synced 2024-12-22 08:08:50 -05:00
curl/m4/xc-cc-check.m4
Yang Tse efe4656656 xc-cc-check.m4: re-evaluate exporting and AC_SUBST'ing vars
Notes:

When running a configure script that has nested packages (for example
libcurl's configure with --enable-ares and c-ares sources embedded in
curl tree) and AC_CONFIG_SUBDIRS([nested-subdir]) machinery is used to
automatically run the nested configure script from within the parent
configure script, it happens that the nested _shell_ script will
inherit shell variables exported from the parent _shell_ script.

If for example parent configure script sets and exports LDFLAGS and LIBS
variables with proper values in order to link either a parent library or
program with a library which will be configured and built by a nested
package; It will happen that when the nested configure script runs, the
nested library does not exist yet and _any_ link-test done in the nested
configure will fail, such as those that autoconf macros perform in order
to detect existing compiler and its characteristics, the result is that
the nested configure script will fail with errors such as:

configure: error: C compiler cannot create executables

For now, we no longer export variables previously exported here.

On the other hand, AC_SUBST'ing them is appropriate and even with nested
packages each package's config.status gets its own package values.

So we reinstate AC_SUBST'ing previously AC_SUBST'ed variables.
2013-01-21 21:29:30 +01:00

97 lines
2.9 KiB
Plaintext

#---------------------------------------------------------------------------
#
# xc-cc-check.m4
#
# Copyright (c) 2013 Daniel Stenberg <daniel@haxx.se>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
#---------------------------------------------------------------------------
# serial 1
dnl _XC_PROG_CC_PREAMBLE
dnl -------------------------------------------------
dnl Private macro.
AC_DEFUN([_XC_PROG_CC_PREAMBLE], [
xc_prog_cc_prev_IFS=$IFS
xc_prog_cc_prev_LIBS=$LIBS
xc_prog_cc_prev_CFLAGS=$CFLAGS
xc_prog_cc_prev_LDFLAGS=$LDFLAGS
xc_prog_cc_prev_CPPFLAGS=$CPPFLAGS
])
dnl _XC_PROG_CC_POSTLUDE
dnl -------------------------------------------------
dnl Private macro.
AC_DEFUN([_XC_PROG_CC_POSTLUDE], [
IFS=$xc_prog_cc_prev_IFS
LIBS=$xc_prog_cc_prev_LIBS
CFLAGS=$xc_prog_cc_prev_CFLAGS
LDFLAGS=$xc_prog_cc_prev_LDFLAGS
CPPFLAGS=$xc_prog_cc_prev_CPPFLAGS
AC_SUBST([CC])dnl
AC_SUBST([CPP])dnl
AC_SUBST([LIBS])dnl
AC_SUBST([CFLAGS])dnl
AC_SUBST([LDFLAGS])dnl
AC_SUBST([CPPFLAGS])dnl
])
dnl _XC_PROG_CC
dnl -------------------------------------------------
dnl Private macro.
AC_DEFUN([_XC_PROG_CC], [
AC_REQUIRE([_XC_PROG_CC_PREAMBLE])dnl
AC_REQUIRE([XC_CHECK_USER_FLAGS])dnl
AC_REQUIRE([AC_PROG_INSTALL])dnl
AC_REQUIRE([AC_PROG_CC])dnl
AC_REQUIRE([AM_PROG_CC_C_O])dnl
AC_REQUIRE([AC_PROG_CPP])dnl
AC_REQUIRE([_XC_PROG_CC_POSTLUDE])dnl
])
dnl XC_CHECK_PROG_CC
dnl -------------------------------------------------
dnl Public macro.
dnl
dnl Checks for C compiler and C preprocessor programs,
dnl while doing some previous sanity validation on user
dnl provided LIBS, LDFLAGS, CPPFLAGS and CFLAGS values
dnl that must succeed in order to continue execution.
dnl
dnl This sets variables CC and CPP, while preventing
dnl LIBS, LDFLAGS, CFLAGS, CPPFLAGS and IFS from being
dnl unexpectedly changed by underlying macros.
AC_DEFUN([XC_CHECK_PROG_CC], [
AC_PREREQ([2.50])dnl
AC_BEFORE([$0],[_XC_PROG_CC_PREAMBLE])dnl
AC_BEFORE([$0],[AC_PROG_INSTALL])dnl
AC_BEFORE([$0],[AC_PROG_CC])dnl
AC_BEFORE([$0],[AM_PROG_CC_C_O])dnl
AC_BEFORE([$0],[AC_PROG_CPP])dnl
AC_BEFORE([$0],[AC_PROG_LIBTOOL])dnl
AC_BEFORE([$0],[AM_INIT_AUTOMAKE])dnl
AC_BEFORE([$0],[_XC_PROG_CC_POSTLUDE])dnl
AC_REQUIRE([_XC_PROG_CC])dnl
])