configure: autotools compatibility fixes - step I
authorYang Tse <yangsita@gmail.com>
Sun, 20 Jan 2013 19:23:20 +0000 (20:23 +0100)
committerYang Tse <yangsita@gmail.com>
Sun, 20 Jan 2013 19:23:20 +0000 (20:23 +0100)
Fix proper macro expansion order across autotools versions for
C compiler and preprocessor program checks.

configure.ac
m4/curl-compilers.m4
m4/curl-confopts.m4
m4/xc-cc-check.m4 [new file with mode: 0644]
m4/xc-val-flgs.m4 [new file with mode: 0644]

index 7a51b03..e202600 100644 (file)
@@ -5,7 +5,7 @@
 #                            | (__| |_| |  _ <| |___
 #                             \___|\___/|_| \_\_____|
 #
-# Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+# Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
@@ -125,6 +125,7 @@ fi
 
 dnl figure out the libcurl version
 CURLVERSION=`$SED -ne 's/^#define LIBCURL_VERSION "\(.*\)"/\1/p' ${srcdir}/include/curl/curlver.h`
+XC_CHECK_PROG_CC
 AM_INIT_AUTOMAKE
 AC_MSG_CHECKING([curl version])
 AC_MSG_RESULT($CURLVERSION)
@@ -169,119 +170,6 @@ curl_verbose_msg="enabled (--disable-verbose)"
     init_ssl_msg=${curl_ssl_msg}
 
 dnl
-dnl LIBS should only specify libraries
-dnl
-tst_bad_spec="no"
-for word1 in $LIBS; do
-  case "$word1" in
-    -l* | --library=*)
-      :
-      ;;
-    *)
-      tst_bad_spec="yes"
-      ;;
-  esac
-done
-if test "$tst_bad_spec" = "yes"; then
-  AC_MSG_WARN([invalid LIBS: $LIBS])
-  AC_MSG_ERROR([LIBS may only be used to specify libraries (-lname).])
-fi
-
-dnl
-dnl LDFLAGS should only specify linker flags
-dnl
-tst_bad_msg=""
-tst_bad_spec="no"
-for word1 in $LDFLAGS; do
-  case "$word1" in
-    -D*)
-      tst_bad_spec="yes"
-      tst_bad_msg="not macro definitions. Use CPPFLAGS for these."
-      ;;
-    -U*)
-      tst_bad_spec="yes"
-      tst_bad_msg="not macro suppressions. Use CPPFLAGS for these."
-      ;;
-    -I*)
-      tst_bad_spec="yes"
-      tst_bad_msg="not include directories. Use CPPFLAGS for these."
-      ;;
-    -l* | --library=*)
-      tst_bad_spec="yes"
-      tst_bad_msg="not libraries. Use LIBS for these."
-      ;;
-  esac
-done
-if test "$tst_bad_spec" = "yes"; then
-  AC_MSG_WARN([invalid LDFLAGS: $LDFLAGS])
-  AC_MSG_ERROR([LDFLAGS may only be used to specify linker flags, $tst_bad_msg])
-fi
-
-dnl
-dnl CPPFLAGS should only specify C preprocessor flags
-dnl
-tst_bad_msg=""
-tst_bad_spec="no"
-for word1 in $CPPFLAGS; do
-  case "$word1" in
-    -rpath*)
-      tst_bad_spec="yes"
-      tst_bad_msg="not library runtime directories. Use LDFLAGS for these."
-      ;;
-    -L* | --library-path=*)
-      tst_bad_spec="yes"
-      tst_bad_msg="not library directories. Use LDFLAGS for these."
-      ;;
-    -l* | --library=*)
-      tst_bad_spec="yes"
-      tst_bad_msg="not libraries. Use LIBS for these."
-      ;;
-  esac
-done
-if test "$tst_bad_spec" = "yes"; then
-  AC_MSG_WARN([invalid CPPFLAGS: $CPPFLAGS])
-  AC_MSG_ERROR([CPPFLAGS may only be used to specify C preprocessor flags, $tst_bad_msg])
-fi
-
-dnl
-dnl CFLAGS should only specify C compiler flags
-dnl
-tst_bad_msg=""
-tst_bad_spec="no"
-for word1 in $CFLAGS; do
-  case "$word1" in
-    -D*)
-      tst_bad_spec="yes"
-      tst_bad_msg="not macro definitions. Use CPPFLAGS for these."
-      ;;
-    -U*)
-      tst_bad_spec="yes"
-      tst_bad_msg="not macro suppressions. Use CPPFLAGS for these."
-      ;;
-    -I*)
-      tst_bad_spec="yes"
-      tst_bad_msg="not include directories. Use CPPFLAGS for these."
-      ;;
-    -rpath*)
-      tst_bad_spec="yes"
-      tst_bad_msg="not library runtime directories. Use LDFLAGS for these."
-      ;;
-    -L* | --library-path=*)
-      tst_bad_spec="yes"
-      tst_bad_msg="not library directories. Use LDFLAGS for these."
-      ;;
-    -l* | --library=*)
-      tst_bad_spec="yes"
-      tst_bad_msg="not libraries. Use LIBS for these."
-      ;;
-  esac
-done
-if test "$tst_bad_spec" = "yes"; then
-  AC_MSG_WARN([invalid CFLAGS: $CFLAGS])
-  AC_MSG_ERROR([CFLAGS may only be used to specify C compiler flags, $tst_bad_msg])
-fi
-
-dnl
 dnl Save some initial values the user might have provided
 dnl
 INITIAL_LDFLAGS=$LDFLAGS
@@ -296,7 +184,6 @@ dnl Get system canonical name
 AC_DEFINE_UNQUOTED(OS, "${host}", [cpu-machine-OS])
 
 dnl Checks for programs.
-CURL_CHECK_PROG_CC
 
 dnl Our curl_off_t internal and external configure settings
 CURL_CONFIGURE_CURL_OFF_T
@@ -3615,100 +3502,7 @@ squeeze CURL_NETWORK_AND_TIME_LIBS
 squeeze SUPPORT_FEATURES
 squeeze SUPPORT_PROTOCOLS
 
-dnl
-dnl Some sanity checks for LIBS, LDFLAGS, CPPFLAGS and CFLAGS values that
-dnl configure is going to feed into makefiles generated by automake. Due
-dnl to automake placement and usage of these variables we have to follow
-dnl its rules or we may get funny results later on at make-time.
-dnl
-
-dnl
-dnl LIBS should only specify libraries
-dnl
-AC_MSG_NOTICE([using LIBS: $LIBS])
-tst_bad_spec="no"
-for word1 in $LIBS; do
-  case "$word1" in
-    -l* | --library=*)
-      :
-      ;;
-    *)
-      tst_bad_spec="yes"
-      ;;
-  esac
-done
-if test "$tst_bad_spec" = "yes"; then
-  AC_MSG_WARN([oops, LIBS should only specify libraries.])
-fi
-
-dnl
-dnl LDFLAGS should only specify linker flags
-dnl
-AC_MSG_NOTICE([using LDFLAGS: $LDFLAGS])
-tst_bad_msg="oops, LDFLAGS should only specify linker flags, not"
-for word1 in $LDFLAGS; do
-  case "$word1" in
-    -D*)
-      AC_MSG_WARN([$tst_bad_msg macro definitions. Use CPPFLAGS for: $word1])
-      ;;
-    -U*)
-      AC_MSG_WARN([$tst_bad_msg macro suppressions. Use CPPFLAGS for: $word1])
-      ;;
-    -I*)
-      AC_MSG_WARN([$tst_bad_msg include directories. Use CPPFLAGS for: $word1])
-      ;;
-    -l* | --library=*)
-      AC_MSG_WARN([$tst_bad_msg libraries. Use LIBS for: $word1])
-      ;;
-  esac
-done
-
-dnl
-dnl CPPFLAGS should only specify C preprocessor flags
-dnl
-AC_MSG_NOTICE([using CPPFLAGS: $CPPFLAGS])
-tst_bad_msg="oops, CPPFLAGS should only specify C preprocessor flags, not"
-for word1 in $CPPFLAGS; do
-  case "$word1" in
-    -rpath*)
-      AC_MSG_WARN([$tst_bad_msg library runtime directories. Use LDFLAGS for: $word1])
-      ;;
-    -L* | --library-path=*)
-      AC_MSG_WARN([$tst_bad_msg library directories. Use LDFLAGS for: $word1])
-      ;;
-    -l* | --library=*)
-      AC_MSG_WARN([$tst_bad_msg libraries. Use LIBS for: $word1])
-      ;;
-  esac
-done
-
-dnl
-dnl CFLAGS should only specify C compiler flags
-dnl
-AC_MSG_NOTICE([using CFLAGS: $CFLAGS])
-tst_bad_msg="oops, CFLAGS should only specify C compiler flags, not"
-for word1 in $CFLAGS; do
-  case "$word1" in
-    -D*)
-      AC_MSG_WARN([$tst_bad_msg macro definitions. Use CPPFLAGS for: $word1])
-      ;;
-    -U*)
-      AC_MSG_WARN([$tst_bad_msg macro suppressions. Use CPPFLAGS for: $word1])
-      ;;
-    -I*)
-      AC_MSG_WARN([$tst_bad_msg include directories. Use CPPFLAGS for: $word1])
-      ;;
-    -rpath*)
-      AC_MSG_WARN([$tst_bad_msg library runtime directories. Use LDFLAGS for: $word1])
-      ;;
-    -L* | --library-path=*)
-      AC_MSG_WARN([$tst_bad_msg library directories. Use LDFLAGS for: $word1])
-      ;;
-    -l* | --library=*)
-      AC_MSG_WARN([$tst_bad_msg libraries. Use LIBS for: $word1])
-      ;;
-  esac
-done
+XC_CHECK_BUILD_FLAGS
 
 if test "x$want_curldebug_assumed" = "xyes" &&
   test "x$want_curldebug" = "xyes" && test "x$USE_ARES" = "x1"; then
index 0879a48..ddbabbd 100644 (file)
@@ -5,7 +5,7 @@
 #                            | (__| |_| |  _ <| |___
 #                             \___|\___/|_| \_\_____|
 #
-# Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+# Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
@@ -21,7 +21,7 @@
 #***************************************************************************
 
 # File version for 'aclocal' use. Keep it a single number.
-# serial 64
+# serial 65
 
 
 dnl CURL_CHECK_COMPILER
@@ -1264,20 +1264,6 @@ AC_DEFUN([CURL_CHECK_NO_UNDEFINED], [
 ])
 
 
-dnl CURL_CHECK_PROG_CC
-dnl -------------------------------------------------
-dnl Check for compiler program, preventing CFLAGS and
-dnl CPPFLAGS from being unexpectedly changed.
-
-AC_DEFUN([CURL_CHECK_PROG_CC], [
-  ac_save_CFLAGS="$CFLAGS"
-  ac_save_CPPFLAGS="$CPPFLAGS"
-  AC_PROG_CC
-  CFLAGS="$ac_save_CFLAGS"
-  CPPFLAGS="$ac_save_CPPFLAGS"
-])
-
-
 dnl CURL_CHECK_COMPILER_HALT_ON_ERROR
 dnl -------------------------------------------------
 dnl Verifies if the compiler actually halts after the
index 1f792e4..44b018e 100644 (file)
@@ -5,7 +5,7 @@
 #                            | (__| |_| |  _ <| |___
 #                             \___|\___/|_| \_\_____|
 #
-# Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+# Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
@@ -21,7 +21,7 @@
 #***************************************************************************
 
 # File version for 'aclocal' use. Keep it a single number.
-# serial 18
+# serial 19
 
 dnl CURL_CHECK_OPTION_THREADED_RESOLVER
 dnl -------------------------------------------------
@@ -145,7 +145,7 @@ dnl variable want_debug value as appropriate.
 AC_DEFUN([CURL_CHECK_OPTION_DEBUG], [
   AC_BEFORE([$0],[CURL_CHECK_OPTION_WARNINGS])dnl
   AC_BEFORE([$0],[CURL_CHECK_OPTION_CURLDEBUG])dnl
-  AC_BEFORE([$0],[CURL_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,
@@ -177,7 +177,7 @@ dnl shell variable want_optimize value as appropriate.
 
 AC_DEFUN([CURL_CHECK_OPTION_OPTIMIZE], [
   AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
-  AC_BEFORE([$0],[CURL_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,
@@ -326,7 +326,7 @@ dnl shell variable want_warnings as appropriate.
 AC_DEFUN([CURL_CHECK_OPTION_WARNINGS], [
   AC_REQUIRE([CURL_CHECK_OPTION_DEBUG])dnl
   AC_BEFORE([$0],[CURL_CHECK_OPTION_WERROR])dnl
-  AC_BEFORE([$0],[CURL_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,
diff --git a/m4/xc-cc-check.m4 b/m4/xc-cc-check.m4
new file mode 100644 (file)
index 0000000..5e5af9c
--- /dev/null
@@ -0,0 +1,102 @@
+#---------------------------------------------------------------------------
+#
+# 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
+  export CC
+  export CPP
+  export LIBS
+  export CFLAGS
+  export LDFLAGS
+  export 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
+])
+
diff --git a/m4/xc-val-flgs.m4 b/m4/xc-val-flgs.m4
new file mode 100644 (file)
index 0000000..81d1eac
--- /dev/null
@@ -0,0 +1,243 @@
+#---------------------------------------------------------------------------
+#
+# xc-val-flgs.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_CHECK_VAR_LIBS
+dnl -------------------------------------------------
+dnl Private macro.
+
+AC_DEFUN([_XC_CHECK_VAR_LIBS], [
+  xc_bad_var_libs=no
+  for xc_word in $LIBS; do
+    case "$xc_word" in
+      -l* | --library=*)
+        :
+        ;;
+      *)
+        xc_bad_var_libs=yes
+        ;;
+    esac
+  done
+  if test $xc_bad_var_libs = yes; then
+    AC_MSG_NOTICE([using LIBS: $LIBS])
+    AC_MSG_NOTICE([LIBS error: LIBS may only be used to specify libraries (-lname).])
+  fi
+])
+
+
+dnl _XC_CHECK_VAR_LDFLAGS
+dnl -------------------------------------------------
+dnl Private macro.
+
+AC_DEFUN([_XC_CHECK_VAR_LDFLAGS], [
+  xc_bad_var_ldflags=no
+  for xc_word in $LDFLAGS; do
+    case "$xc_word" in
+      -D*)
+        xc_bad_var_ldflags=yes
+        ;;
+      -U*)
+        xc_bad_var_ldflags=yes
+        ;;
+      -I*)
+        xc_bad_var_ldflags=yes
+        ;;
+      -l* | --library=*)
+        xc_bad_var_ldflags=yes
+        ;;
+    esac
+  done
+  if test $xc_bad_var_ldflags = yes; then
+    AC_MSG_NOTICE([using LDFLAGS: $LDFLAGS])
+    xc_bad_var_msg="LDFLAGS error: LDFLAGS may only be used to specify linker flags, not"
+    for xc_word in $LDFLAGS; do
+      case "$xc_word" in
+        -D*)
+          AC_MSG_NOTICE([$xc_bad_var_msg macro definitions. Use CPPFLAGS for: $xc_word])
+          ;;
+        -U*)
+          AC_MSG_NOTICE([$xc_bad_var_msg macro suppressions. Use CPPFLAGS for: $xc_word])
+          ;;
+        -I*)
+          AC_MSG_NOTICE([$xc_bad_var_msg include directories. Use CPPFLAGS for: $xc_word])
+          ;;
+        -l* | --library=*)
+          AC_MSG_NOTICE([$xc_bad_var_msg libraries. Use LIBS for: $xc_word])
+          ;;
+      esac
+    done
+  fi
+])
+
+
+dnl _XC_CHECK_VAR_CPPFLAGS
+dnl -------------------------------------------------
+dnl Private macro.
+
+AC_DEFUN([_XC_CHECK_VAR_CPPFLAGS], [
+  xc_bad_var_cppflags=no
+  for xc_word in $CPPFLAGS; do
+    case "$xc_word" in
+      -rpath*)
+        xc_bad_var_cppflags=yes
+        ;;
+      -L* | --library-path=*)
+        xc_bad_var_cppflags=yes
+        ;;
+      -l* | --library=*)
+        xc_bad_var_cppflags=yes
+        ;;
+    esac
+  done
+  if test $xc_bad_var_cppflags = yes; then
+    AC_MSG_NOTICE([using CPPFLAGS: $CPPFLAGS])
+    xc_bad_var_msg="CPPFLAGS error: CPPFLAGS may only be used to specify C preprocessor flags, not"
+    for xc_word in $CPPFLAGS; do
+      case "$xc_word" in
+        -rpath*)
+          AC_MSG_NOTICE([$xc_bad_var_msg library runtime directories. Use LDFLAGS for: $xc_word])
+          ;;
+        -L* | --library-path=*)
+          AC_MSG_NOTICE([$xc_bad_var_msg library directories. Use LDFLAGS for: $xc_word])
+          ;;
+        -l* | --library=*)
+          AC_MSG_NOTICE([$xc_bad_var_msg libraries. Use LIBS for: $xc_word])
+          ;;
+      esac
+    done
+  fi
+])
+
+
+dnl _XC_CHECK_VAR_CFLAGS
+dnl -------------------------------------------------
+dnl Private macro.
+
+AC_DEFUN([_XC_CHECK_VAR_CFLAGS], [
+  xc_bad_var_cflags=no
+  for xc_word in $CFLAGS; do
+    case "$xc_word" in
+      -D*)
+        xc_bad_var_cflags=yes
+        ;;
+      -U*)
+        xc_bad_var_cflags=yes
+        ;;
+      -I*)
+        xc_bad_var_cflags=yes
+        ;;
+      -rpath*)
+        xc_bad_var_cflags=yes
+        ;;
+      -L* | --library-path=*)
+        xc_bad_var_cflags=yes
+        ;;
+      -l* | --library=*)
+        xc_bad_var_cflags=yes
+        ;;
+    esac
+  done
+  if test $xc_bad_var_cflags = yes; then
+    AC_MSG_NOTICE([using CFLAGS: $CFLAGS])
+    xc_bad_var_msg="CFLAGS error: CFLAGS may only be used to specify C compiler flags, not"
+    for xc_word in $CFLAGS; do
+      case "$xc_word" in
+        -D*)
+          AC_MSG_NOTICE([$xc_bad_var_msg macro definitions. Use CPPFLAGS for: $xc_word])
+          ;;
+        -U*)
+          AC_MSG_NOTICE([$xc_bad_var_msg macro suppressions. Use CPPFLAGS for: $xc_word])
+          ;;
+        -I*)
+          AC_MSG_NOTICE([$xc_bad_var_msg include directories. Use CPPFLAGS for: $xc_word])
+          ;;
+        -rpath*)
+          AC_MSG_NOTICE([$xc_bad_var_msg library runtime directories. Use LDFLAGS for: $xc_word])
+          ;;
+        -L* | --library-path=*)
+          AC_MSG_NOTICE([$xc_bad_var_msg library directories. Use LDFLAGS for: $xc_word])
+          ;;
+        -l* | --library=*)
+          AC_MSG_NOTICE([$xc_bad_var_msg libraries. Use LIBS for: $xc_word])
+          ;;
+      esac
+    done
+  fi
+])
+
+
+dnl XC_CHECK_USER_FLAGS
+dnl -------------------------------------------------
+dnl Public macro.
+dnl
+dnl Performs some sanity checks for LIBS, LDFLAGS,
+dnl CPPFLAGS and CFLAGS values that the user might
+dnl have set. When checks fails, user is noticed
+dnl about errors detected in all of them and script
+dnl execution is halted.
+dnl
+dnl Intended to be used early in configure script.
+
+AC_DEFUN([XC_CHECK_USER_FLAGS], [
+  AC_PREREQ([2.50])dnl
+  AC_BEFORE([$0],[XC_CHECK_PROG_CC])dnl
+  dnl check order below matters
+  _XC_CHECK_VAR_LIBS
+  _XC_CHECK_VAR_LDFLAGS
+  _XC_CHECK_VAR_CPPFLAGS
+  _XC_CHECK_VAR_CFLAGS
+  if test $xc_bad_var_libs = yes ||
+     test $xc_bad_var_cflags = yes ||
+     test $xc_bad_var_ldflags = yes ||
+     test $xc_bad_var_cppflags = yes; then
+     AC_MSG_ERROR([Can not continue. Fix errors mentioned immediately above this line.])
+  fi
+])
+
+
+dnl XC_CHECK_BUILD_FLAGS
+dnl -------------------------------------------------
+dnl Public macro.
+dnl
+dnl Performs some sanity checks for LIBS, LDFLAGS,
+dnl CPPFLAGS and CFLAGS values that the configure
+dnl script might have set. When checks fails, user
+dnl is noticed about errors detected in all of them
+dnl but script continues execution.
+dnl
+dnl Intended to be used very late in configure script.
+
+AC_DEFUN([XC_CHECK_BUILD_FLAGS], [
+  AC_PREREQ([2.50])dnl
+  dnl check order below matters
+  _XC_CHECK_VAR_LIBS
+  _XC_CHECK_VAR_LDFLAGS
+  _XC_CHECK_VAR_CPPFLAGS
+  _XC_CHECK_VAR_CFLAGS
+  if test $xc_bad_var_libs = yes ||
+     test $xc_bad_var_cflags = yes ||
+     test $xc_bad_var_ldflags = yes ||
+     test $xc_bad_var_cppflags = yes; then
+     AC_MSG_WARN([Continuing even with errors mentioned immediately above this line.])
+  fi
+])
+