Put -D and -I flags into CPPFLAGS rather than into CFLAGS; that should

make them apply to C++ as well as C.  That seems to be what the autoconf
documentation suggests:

- Variable: CFLAGS
  Debugging and optimization options for the C compiler. If it is not set
  in the environment when configure runs, the default value is set when
  you call AC_PROG_CC (or empty if you don't). configure uses this
  variable when compiling or linking programs to test for C features.

  If a compiler option affects only the behavior of the preprocessor
  (e.g., -Dname), it should be put into CPPFLAGS instead. If it affects
  only the linker (e.g., -Ldirectory), it should be put into LDFLAGS
  instead. If it affects only the compiler proper, CFLAGS is the natural
  home for it. If an option affects multiple phases of the compiler,
  though, matters get tricky. One approach to put such options directly
  into CC, e.g., CC='gcc -m64'. Another is to put them into both CPPFLAGS
  and LDFLAGS, but not into CFLAGS.

	...

- Variable: CPPFLAGS
  Preprocessor options for the C, C++, Objective C, and Objective C++
  preprocessors and compilers. If it is not set in the environment when
  configure runs, the default value is empty. configure uses this variable
  when preprocessing or compiling programs to test for C, C++, Objective
  C, and Objective C++ features.

  This variable's contents should contain options like -I, -D, and -U that
  affect only the behavior of the preprocessor. Please see the explanation
  of CFLAGS for what you can do if an option affects other phases of the
  compiler as well.

svn path=/trunk/; revision=41593
This commit is contained in:
Guy Harris 2012-03-16 03:27:45 +00:00
parent 08953cee3a
commit 04acb74936
2 changed files with 63 additions and 92 deletions

View File

@ -148,7 +148,7 @@ yes
#endif],
[v6type=$i; v6lib=v6;
v6libdir=/usr/local/v6/lib;
CFLAGS="-I/usr/local/v6/include $CFLAGS"])
CPPFLAGS="-I/usr/local/v6/include $CPPFLAGS"])
;;
toshiba)
AC_EGREP_CPP(yes, [
@ -158,7 +158,7 @@ yes
#endif],
[v6type=$i; v6lib=inet6;
v6libdir=/usr/local/v6/lib;
CFLAGS="-DINET6 $CFLAGS"])
CPPFLAGS="-DINET6 $CPPFLAGS"])
;;
kame)
AC_EGREP_CPP(yes, [
@ -168,7 +168,7 @@ yes
#endif],
[v6type=$i; v6lib=inet6;
v6libdir=/usr/local/v6/lib;
CFLAGS="-DINET6 $CFLAGS"])
CPPFLAGS="-DINET6 $CPPFLAGS"])
;;
inria)
AC_EGREP_CPP(yes, [
@ -176,7 +176,7 @@ yes
#ifdef IPV6_INRIA_VERSION
yes
#endif],
[v6type=$i; CFLAGS="-DINET6 $CFLAGS"])
[v6type=$i; CPPFLAGS="-DINET6 $CPPFLAGS"])
;;
zeta)
AC_EGREP_CPP(yes, [
@ -186,14 +186,14 @@ yes
#endif],
[v6type=$i; v6lib=inet6;
v6libdir=/usr/local/v6/lib;
CFLAGS="-DINET6 $CFLAGS"])
CPPFLAGS="-DINET6 $CPPFLAGS"])
;;
linux)
if test -d /usr/inet6; then
v6type=$i
v6lib=inet6
v6libdir=/usr/inet6
CFLAGS="-DINET6 $CFLAGS"
CPPFLAGS="-DINET6 $CPPFLAGS"
fi
;;
linux-glibc)
@ -204,13 +204,13 @@ yes
yes
#endif
#endif],
[v6type=$i; v6lib=inet6; CFLAGS="-DINET6 $CFLAGS"])
[v6type=$i; v6lib=inet6; CPPFLAGS="-DINET6 $CPPFLAGS"])
;;
solaris8)
if test "`uname -s`" = "SunOS" && test "`uname -r`" = "5.8"; then
v6type=$i
v6lib=inet6
[CFLAGS="-DINET6 -DSOLARIS8_INET6 $CFLAGS"]
[CPPFLAGS="-DINET6 -DSOLARIS8_INET6 $CPPFLAGS"]
fi
;;
esac
@ -361,7 +361,6 @@ AC_DEFUN([AC_WIRESHARK_PCAP_CHECK],
# Found it, and it's usable; use it to get the include flags
# for libpcap.
#
CFLAGS="$CFLAGS `\"$PCAP_CONFIG\" --cflags`"
CPPFLAGS="$CPPFLAGS `\"$PCAP_CONFIG\" --cflags`"
else
#
@ -387,7 +386,6 @@ AC_DEFUN([AC_WIRESHARK_PCAP_CHECK],
do
if test -d $pcap_dir ; then
if test x$pcap_dir != x/usr/include -a x$pcap_dir != x/usr/local/include ; then
CFLAGS="$CFLAGS -I$pcap_dir"
CPPFLAGS="$CPPFLAGS -I$pcap_dir"
fi
found_pcap_dir=" $found_pcap_dir -I$pcap_dir"
@ -409,12 +407,11 @@ AC_DEFUN([AC_WIRESHARK_PCAP_CHECK],
# of that directory to the library search path.
#
# XXX - if there's also a libpcap in a directory that's
# already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't
# make us find the version in the specified directory,
# as the compiler and/or linker will search that other
# directory before it searches the specified directory.
# already in CPPFLAGS or LDFLAGS, this won't make us find
# the version in the specified directory, as the compiler
# and/or linker will search that other directory before it
# searches the specified directory.
#
CFLAGS="$CFLAGS -I$pcap_dir/include"
CPPFLAGS="$CPPFLAGS -I$pcap_dir/include"
AC_WIRESHARK_ADD_DASH_L(LDFLAGS, $pcap_dir/lib)
fi
@ -632,13 +629,11 @@ AC_DEFUN([AC_WIRESHARK_ZLIB_CHECK],
# of that directory to the library search path.
#
# XXX - if there's also a zlib in a directory that's
# already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't
# make us find the version in the specified directory,
# as the compiler and/or linker will search that other
# directory before it searches the specified directory.
# already in CPPFLAGS or LDFLAGS, this won't make us find
# the version in the specified directory, as the compiler
# and/or linker will search that other directory before it
# searches the specified directory.
#
wireshark_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -I$zlib_dir/include"
wireshark_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -I$zlib_dir/include"
wireshark_save_LIBS="$LIBS"
@ -690,9 +685,8 @@ AC_DEFUN([AC_WIRESHARK_ZLIB_CHECK],
if test "x$zlib_dir" != "x"
then
#
# Put the "-I" and "-L" flags for zlib at
# the beginning of CFLAGS, CPPFLAGS, and
# LIBS.
# Put the "-L" flags for zlib at the beginning
# of LIBS.
#
LIBS=""
AC_WIRESHARK_ADD_DASH_L(LIBS, $zlib_dir/lib)
@ -734,12 +728,10 @@ AC_DEFUN([AC_WIRESHARK_ZLIB_CHECK],
fi
else
#
# Restore the versions of CFLAGS, CPPFLAGS,
# and LIBS before we added the "-with-zlib="
# directory, as we didn't actually find
# zlib there.
# Restore the versions of CPPFLAGS and LIBS before
# we added the "-with-zlib=" directory, as we didn't
# actually find zlib there.
#
CFLAGS="$wireshark_save_CFLAGS"
CPPFLAGS="$wireshark_save_CPPFLAGS"
LIBS="$wireshark_save_LIBS"
want_zlib=no
@ -760,13 +752,11 @@ AC_DEFUN([AC_WIRESHARK_LIBLUA_CHECK],[
# of that directory to the library search path.
#
# XXX - if there's also a liblua in a directory that's
# already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't
# make us find the version in the specified directory,
# as the compiler and/or linker will search that other
# directory before it searches the specified directory.
# already in CPPFLAGS or LDFLAGS, this won't make us find
# the version in the specified directory, as the compiler
# and/or linker will search that other directory before it
# searches the specified directory.
#
wireshark_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -I$lua_dir/include"
wireshark_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -I$lua_dir/include"
wireshark_save_LIBS="$LIBS"
@ -778,7 +768,6 @@ AC_DEFUN([AC_WIRESHARK_LIBLUA_CHECK],[
# The user specified no directory in which liblua resides,
# so just add "-llua -lliblua" to the used libs.
#
wireshark_save_CFLAGS="$CFLAGS"
wireshark_save_CPPFLAGS="$CPPFLAGS"
wireshark_save_LDFLAGS="$LDFLAGS"
wireshark_save_LIBS="$LIBS"
@ -826,12 +815,11 @@ AC_DEFUN([AC_WIRESHARK_LIBLUA_CHECK],[
else
AC_MSG_RESULT(not found)
#
# Restore the versions of CFLAGS, CPPFLAGS,
# Restore the versions of CPPFLAGS,
# LDFLAGS, and LIBS before we added the
# "--with-lua=" directory, as we didn't
# actually find lua there.
#
CFLAGS="$wireshark_save_CFLAGS"
CPPFLAGS="$wireshark_save_CPPFLAGS"
LDFLAGS="$wireshark_save_LDFLAGS"
LIBS="$wireshark_save_LIBS"
@ -852,12 +840,11 @@ AC_DEFUN([AC_WIRESHARK_LIBLUA_CHECK],[
],
[
#
# Restore the versions of CFLAGS, CPPFLAGS,
# LDFLAGS, and LIBS before we added the
# "--with-lua=" directory, as we didn't
# actually find lua there.
# Restore the versions of CPPFLAGS, LDFLAGS,
# and LIBS before we added the "--with-lua="
# directory, as we didn't actually find lua
# there.
#
CFLAGS="$wireshark_save_CFLAGS"
CPPFLAGS="$wireshark_save_CPPFLAGS"
LDFLAGS="$wireshark_save_LDFLAGS"
LIBS="$wireshark_save_LIBS"
@ -941,12 +928,11 @@ AC_DEFUN([AC_WIRESHARK_LIBLUA_CHECK],[
want_lua=yes
],[
#
# Restore the versions of CFLAGS, CPPFLAGS,
# LDFLAGS, and LIBS before we added the
# "--with-lua=" directory, as we didn't
# actually find lua there.
# Restore the versions of CPPFLAGS, LDFLAGS,
# and LIBS before we added the "--with-lua="
# directory, as we didn't actually find lua
# there.
#
CFLAGS="$wireshark_save_CFLAGS"
CPPFLAGS="$wireshark_save_CPPFLAGS"
LDFLAGS="$wireshark_save_LDFLAGS"
LIBS="$wireshark_save_LIBS"
@ -960,7 +946,6 @@ AC_DEFUN([AC_WIRESHARK_LIBLUA_CHECK],[
])
])
CFLAGS="$wireshark_save_CFLAGS"
CPPFLAGS="$wireshark_save_CPPFLAGS"
LDFLAGS="$wireshark_save_LDFLAGS"
LIBS="$wireshark_save_LIBS"
@ -984,13 +969,11 @@ AC_DEFUN([AC_WIRESHARK_LIBPORTAUDIO_CHECK],[
# of that directory to the library search path.
#
# XXX - if there's also a libportaudio in a directory that's
# already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't
# make us find the version in the specified directory,
# as the compiler and/or linker will search that other
# directory before it searches the specified directory.
# already in CPPFLAGS or LDFLAGS, this won't make us find
# the version in the specified directory, as the compiler
# and/or linker will search that other directory before it
# searches the specified directory.
#
wireshark_save_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -I$portaudio_dir/include"
wireshark_save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -I$portaudio_dir/include"
wireshark_save_LIBS="$LIBS"
@ -1002,7 +985,6 @@ AC_DEFUN([AC_WIRESHARK_LIBPORTAUDIO_CHECK],[
# The user specified no directory in which libportaudio resides,
# so just add "-lportaudio" to the used libs.
#
wireshark_save_CFLAGS="$CFLAGS"
wireshark_save_CPPFLAGS="$CPPFLAGS"
wireshark_save_LDFLAGS="$LDFLAGS"
wireshark_save_LIBS="$LIBS"
@ -1026,7 +1008,6 @@ AC_DEFUN([AC_WIRESHARK_LIBPORTAUDIO_CHECK],[
#
AC_MSG_ERROR([libportaudio header not found in directory specified in --with-portaudio])
else
CFLAGS="$wireshark_save_CFLAGS"
CPPFLAGS="$wireshark_save_CPPFLAGS"
LDFLAGS="$wireshark_save_LDFLAGS"
LIBS="$wireshark_save_LIBS"
@ -1086,12 +1067,11 @@ AC_DEFUN([AC_WIRESHARK_LIBPORTAUDIO_CHECK],[
want_portaudio=yes
],[
#
# Restore the versions of CFLAGS, CPPFLAGS,
# LDFLAGS, and LIBS before we added the
# "--with-portaudio=" directory, as we didn't
# actually find portaudio there.
# Restore the versions of CPPFLAGS, LDFLAGS, and
# LIBS before we added the "--with-portaudio="
# directory, as we didn't actually find portaudio
# there.
#
CFLAGS="$wireshark_save_CFLAGS"
CPPFLAGS="$wireshark_save_CPPFLAGS"
LDFLAGS="$wireshark_save_LDFLAGS"
LIBS="$wireshark_save_LIBS"
@ -1104,7 +1084,6 @@ AC_DEFUN([AC_WIRESHARK_LIBPORTAUDIO_CHECK],[
want_portaudio=no
])
CFLAGS="$wireshark_save_CFLAGS"
CPPFLAGS="$wireshark_save_CPPFLAGS"
LDFLAGS="$wireshark_save_LDFLAGS"
LIBS="$wireshark_save_LIBS"
@ -1248,7 +1227,6 @@ AC_DEFUN([AC_WIRESHARK_LIBCAP_CHECK],
#
AC_DEFUN([AC_WIRESHARK_KRB5_CHECK],
[
wireshark_save_CFLAGS="$CFLAGS"
wireshark_save_CPPFLAGS="$CPPFLAGS"
if test "x$krb5_dir" != "x"
then
@ -1259,12 +1237,11 @@ AC_DEFUN([AC_WIRESHARK_KRB5_CHECK],
# of that directory to the library search path.
#
# XXX - if there's also a kerberos in a directory that's
# already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't
# make us find the version in the specified directory,
# as the compiler and/or linker will search that other
# directory before it searches the specified directory.
# already in CPPFLAGS or LDFLAGS, this won't make us find
# the version in the specified directory, as the compiler
# and/or linker will search that other directory before it
# searches the specified directory.
#
CFLAGS="$CFLAGS -I$krb5_dir/include"
CPPFLAGS="$CPPFLAGS -I$krb5_dir/include"
ac_heimdal_version=`grep heimdal $krb5_dir/include/krb5.h | head -n 1 | sed 's/^.*heimdal.*$/HEIMDAL/'`
# MIT Kerberos moved krb5.h to krb5/krb5.h starting with release 1.5
@ -1287,7 +1264,6 @@ AC_DEFUN([AC_WIRESHARK_KRB5_CHECK],
then
KRB5_FLAGS=`"$KRB5_CONFIG" --cflags`
KRB5_LIBS=`"$KRB5_CONFIG" --libs`
CFLAGS="$CFLAGS $KRB5_FLAGS"
CPPFLAGS="$CPPFLAGS $KRB5_FLAGS"
#
# If -lcrypto is in KRB5_FLAGS, we require it to build
@ -1423,11 +1399,10 @@ AC_DEFUN([AC_WIRESHARK_KRB5_CHECK],
AC_MSG_ERROR(Usable $ac_krb5_version not found)
else
#
# Restore the versions of CFLAGS and CPPFLAGS
# from before we added the flags for Kerberos.
# Restore the versions of CPPFLAGS from before we
# added the flags for Kerberos.
#
AC_MSG_RESULT(Usable $ac_krb5_version not found - disabling dissection for some kerberos data in packet decoding)
CFLAGS="$wireshark_save_CFLAGS"
CPPFLAGS="$wireshark_save_CPPFLAGS"
KRB5_LIBS=""
want_krb5=no
@ -1475,11 +1450,10 @@ AC_DEFUN([AC_WIRESHARK_KRB5_CHECK],
AC_MSG_ERROR(Kerberos not found)
else
#
# Restore the versions of CFLAGS and CPPFLAGS
# from before we added the flags for Kerberos.
# Restore the versions of CPPFLAGS from before we
# added the flags for Kerberos.
#
AC_MSG_RESULT(Kerberos not found - disabling dissection for some kerberos data in packet decoding)
CFLAGS="$wireshark_save_CFLAGS"
CPPFLAGS="$wireshark_save_CPPFLAGS"
KRB5_LIBS=""
want_krb5=no
@ -1491,10 +1465,9 @@ AC_DEFUN([AC_WIRESHARK_KRB5_CHECK],
# say whether they wanted us to use it but we found
# that we couldn't.
#
# Restore the versions of CFLAGS and CPPFLAGS
# from before we added the flags for Kerberos.
# Restore the versions of CPPFLAGS from before we added
# the flags for Kerberos.
#
CFLAGS="$wireshark_save_CFLAGS"
CPPFLAGS="$wireshark_save_CPPFLAGS"
KRB5_LIBS=""
want_krb5=no

View File

@ -379,7 +379,7 @@ AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wno-error=unused-but-set-variable) ## for now
# annoying warnings.
#
if test "x$CC" != "xclang" ; then
AC_WIRESHARK_GCC_CFLAGS_CHECK(-fexcess-precision=fast)
AC_WIRESHARK_GCC_CFLAGS_CHECK(-fexcess-precision=fast)
fi
AC_WIRESHARK_LDFLAGS_CHECK([-Wl,--as-needed])
@ -391,7 +391,7 @@ AC_WIRESHARK_LDFLAGS_CHECK([-Wl,--as-needed])
#
# If we're running GCC or clang, add '-D_U_="__attribute__((unused))"' to
# CFLAGS as well, so we can use _U_ to flag unused function arguments and
# CPPFLAGS as well, so we can use _U_ to flag unused function arguments and
# not get warnings about them. Otherwise, add '-D_U_=""', so that _U_ used
# to flag an unused function argument will compile with non-GCC, non-clang
# compilers.
@ -399,16 +399,16 @@ AC_WIRESHARK_LDFLAGS_CHECK([-Wl,--as-needed])
# XXX - other compilers?
#
if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
CFLAGS="-D_U_=\"__attribute__((unused))\" $CFLAGS"
CPPFLAGS="-D_U_=\"__attribute__((unused))\" $CPPFLAGS"
else
CFLAGS="-D_U_=\"\" $CFLAGS"
CPPFLAGS="-D_U_=\"\" $CPPFLAGS"
fi
# If we're running GCC or CLang, always use FORTIFY_SOURCE=2
# See: http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html
# Note: FORTIFY_SOURCE is only effective for gcc -O2 (and -O1 ?)
if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
CFLAGS="-D_FORTIFY_SOURCE=2 $CFLAGS"
CPPFLAGS="-D_FORTIFY_SOURCE=2 $CPPFLAGS"
fi
#
@ -635,7 +635,6 @@ if test "x$prefix" != "x" ; then
# Arrange that we search for header files in "$prefix/include", as
# various packages we use may have been installed under "$prefix/include".
#
CFLAGS="$CFLAGS -I$prefix/include"
CPPFLAGS="$CPPFLAGS -I$prefix/include"
#
@ -666,7 +665,6 @@ if test "x$ac_cv_enable_usr_local" = "xyes" ; then
# as various packages we use ("libpcap", "zlib", "adns")
# may have been installed under "/usr/local/include".
#
CFLAGS="$CFLAGS -I/usr/local/include"
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
#
@ -863,27 +861,27 @@ else
# Don't use GLIB_CFLAGS
AM_PATH_GLIB_2_0(2.14.0, , AC_MSG_ERROR(GLib 2.14 or later distribution not found.), gthread gmodule)
CFLAGS="-DGTK_DISABLE_SINGLE_INCLUDES $CFLAGS"
CPPFLAGS="-DGTK_DISABLE_SINGLE_INCLUDES $CPPFLAGS"
## Define GTK_DISABLE_DEPRECATED only if GTK lt 3.2
## GTK 3.2 deprecates GtkVBox & GtkHBox which are currently used extensively by Wireshark.
if test $gtk_config_major_version -eq 2 -o $gtk_config_minor_version -lt 2; then
CFLAGS="-DGTK_DISABLE_DEPRECATED $CFLAGS"
CPPFLAGS="-DGTK_DISABLE_DEPRECATED $CPPFLAGS"
fi
# CFLAGS="-DGDK_DISABLE_DEPRECATED $CFLAGS"
# CPPFLAGS="-DGDK_DISABLE_DEPRECATED $CPPFLAGS"
if test $gtk_config_major_version -eq 2 -a $gtk_config_minor_version -ge 20; then
# Enable GSEAL when building with GTK > 2.20 and < 3.0
# (Versions prior to 2.22 lacked some necessary accessors.)
CFLAGS="-DGSEAL_ENABLE $CFLAGS"
CPPFLAGS="-DGSEAL_ENABLE $CPPFLAGS"
fi
fi
# Error out if a glib header other than a "top level" header
# (glib.h, glib-object.h, gio.h) or certain other headers( e.g.,gmodule.h)
# is used.
CFLAGS="-DG_DISABLE_SINGLE_INCLUDES $CFLAGS"
CPPFLAGS="-DG_DISABLE_SINGLE_INCLUDES $CPPFLAGS"
# Error out on the usage of deprecated glib functions
CFLAGS="-DG_DISABLE_DEPRECATED $CFLAGS"
CPPFLAGS="-DG_DISABLE_DEPRECATED $CPPFLAGS"
#
# Check whether GLib modules are supported, to determine whether we