Skip to content

Commit

Permalink
configure: autotools compatibility fixes - step I
Browse files Browse the repository at this point in the history
Fix proper macro expansion order across autotools versions for
C compiler and preprocessor program checks.
  • Loading branch information
yangtse committed Jan 23, 2013
1 parent dc6c864 commit 037656b
Show file tree
Hide file tree
Showing 5 changed files with 351 additions and 27 deletions.
10 changes: 5 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ if test -f ${srcdir}/ares_build.h; then
rm -f ${srcdir}/ares_build.h
fi

AM_INIT_AUTOMAKE

dnl
dnl Detect the canonical host and target build environment
dnl
Expand All @@ -79,9 +77,9 @@ AC_CANONICAL_HOST
dnl Get system canonical name
AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])

CARES_CHECK_PROG_CC
AM_PROG_CC_C_O
AC_PROG_INSTALL
XC_CHECK_PROG_CC

AM_INIT_AUTOMAKE

dnl This defines _ALL_SOURCE for AIX
CARES_CHECK_AIX_ALL_SOURCE
Expand Down Expand Up @@ -864,5 +862,7 @@ squeeze LIBS

squeeze CARES_PRIVATE_LIBS

XC_CHECK_BUILD_FLAGS

AC_CONFIG_FILES([Makefile libcares.pc])
AC_OUTPUT
18 changes: 2 additions & 16 deletions m4/cares-compilers.m4
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#***************************************************************************
#
# Copyright (C) 2009-2012 by Daniel Stenberg et al
# Copyright (C) 2009-2013 by Daniel Stenberg et al
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted, provided
Expand All @@ -15,7 +15,7 @@
#***************************************************************************

# File version for 'aclocal' use. Keep it a single number.
# serial 73
# serial 74


dnl CARES_CHECK_COMPILER
Expand Down Expand Up @@ -1296,20 +1296,6 @@ AC_DEFUN([CARES_CHECK_NO_UNDEFINED], [
])


dnl CARES_CHECK_PROG_CC
dnl -------------------------------------------------
dnl Check for compiler program, preventing CFLAGS and
dnl CPPFLAGS from being unexpectedly changed.

AC_DEFUN([CARES_CHECK_PROG_CC], [
ac_save_CFLAGS="$CFLAGS"
ac_save_CPPFLAGS="$CPPFLAGS"
AC_PROG_CC
CFLAGS="$ac_save_CFLAGS"
CPPFLAGS="$ac_save_CPPFLAGS"
])


dnl CARES_CHECK_COMPILER_HALT_ON_ERROR
dnl -------------------------------------------------
dnl Verifies if the compiler actually halts after the
Expand Down
11 changes: 5 additions & 6 deletions m4/cares-confopts.m4
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#***************************************************************************
# $Id$
#
# Copyright (C) 2008 - 2012 by Daniel Stenberg et al
# Copyright (C) 2008 - 2013 by Daniel Stenberg et al
#
# Permission to use, copy, modify, and distribute this software and its
# documentation for any purpose and without fee is hereby granted, provided
Expand All @@ -16,7 +15,7 @@
#***************************************************************************

# File version for 'aclocal' use. Keep it a single number.
# serial 10
# serial 11


dnl CARES_CHECK_OPTION_CURLDEBUG
Expand Down Expand Up @@ -67,7 +66,7 @@ dnl variable want_debug value as appropriate.
AC_DEFUN([CARES_CHECK_OPTION_DEBUG], [
AC_BEFORE([$0],[CARES_CHECK_OPTION_WARNINGS])dnl
AC_BEFORE([$0],[CARES_CHECK_OPTION_CURLDEBUG])dnl
AC_BEFORE([$0],[CARES_CHECK_PROG_CC])dnl
AC_BEFORE([$0],[XC_CHECK_PROG_CC])dnl
AC_MSG_CHECKING([whether to enable debug build options])
OPT_DEBUG_BUILD="default"
AC_ARG_ENABLE(debug,
Expand Down Expand Up @@ -132,7 +131,7 @@ dnl shell variable want_optimize value as appropriate.

AC_DEFUN([CARES_CHECK_OPTION_OPTIMIZE], [
AC_REQUIRE([CARES_CHECK_OPTION_DEBUG])dnl
AC_BEFORE([$0],[CARES_CHECK_PROG_CC])dnl
AC_BEFORE([$0],[XC_CHECK_PROG_CC])dnl
AC_MSG_CHECKING([whether to enable compiler optimizer])
OPT_COMPILER_OPTIMIZE="default"
AC_ARG_ENABLE(optimize,
Expand Down Expand Up @@ -229,7 +228,7 @@ dnl shell variable want_warnings as appropriate.
AC_DEFUN([CARES_CHECK_OPTION_WARNINGS], [
AC_REQUIRE([CARES_CHECK_OPTION_DEBUG])dnl
AC_BEFORE([$0],[CARES_CHECK_OPTION_WERROR])dnl
AC_BEFORE([$0],[CARES_CHECK_PROG_CC])dnl
AC_BEFORE([$0],[XC_CHECK_PROG_CC])dnl
AC_MSG_CHECKING([whether to enable strict compiler warnings])
OPT_COMPILER_WARNINGS="default"
AC_ARG_ENABLE(warnings,
Expand Down
96 changes: 96 additions & 0 deletions m4/xc-cc-check.m4
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#---------------------------------------------------------------------------
#
# 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
])

Loading

0 comments on commit 037656b

Please sign in to comment.