aboutsummaryrefslogtreecommitdiffstats
path: root/configure.in
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2011-04-20 08:37:45 +0000
committerGuy Harris <guy@alum.mit.edu>2011-04-20 08:37:45 +0000
commitb9d4c025d148a3da297920cb0b3accaa0305d807 (patch)
tree013bd258cc3cc2e4729cfb7f6ef0477eeeb1dbc9 /configure.in
parentbe832727cdc2fd7f0765d817495e3ee2c931d2f8 (diff)
Instead of having GCC and CLANG variables, just have
ac_supports_gcc_flags and ac_supports_W_linker_passthrough flags, the first of which, for now, we set for GCC and clang, and the latter of which we set for GCC, clang, and xlc (probably true for some other compilers as well). Rename AC_WIRESHARK_GCC_LDFLAGS_CHECK to AC_WIRESHARK_LDFLAGS_CHECK, as it's not checking for anything GCC-specific. (Leave AC_WIRESHARK_GCC_CFLAGS_CHECK unrenamed for now, as the flags we test with it are originally GCC flags that clang also supports for GCC compatibility.) Fix some string-equality tests to use = rather than ==; the former is what the test/[ command uses. Don't turn on "-no-cpp-precomp" for clang - it whines if you do. svn path=/trunk/; revision=36731
Diffstat (limited to 'configure.in')
-rw-r--r--configure.in74
1 files changed, 54 insertions, 20 deletions
diff --git a/configure.in b/configure.in
index 2c25d18849..af25cb94a1 100644
--- a/configure.in
+++ b/configure.in
@@ -128,15 +128,37 @@ AC_SUBST(XSLTPROC)
AC_SUBST(XMLLINT)
#
-# Set CLANG if the compiler is clang, to handle compiler options
-# supported both by GCC and clang. (This does *not* include
-# -no-cpp-precomp; clang says "clang: warning: argument unused during
-# compilation: '-no-cpp-precomp'" if you use it.)
+# Set "ac_supports_gcc_flags" if the compiler is known to support GCC-style
+# flags such as -pedantic, -W warning flags and -f feature flags. Currently,
+# we assume GCC and clang do; other compilers should be added here.
#
-if test "x$GCC" != "xyes" ; then
- if test "x$CC" = "xclang" ; then
- CLANG=yes
- fi
+# This is done to avoid getting tripped up by compilers that support
+# those flags but give them a different meaning.
+#
+if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
+ ac_supports_gcc_flags=yes
+fi
+
+#
+# Set "ac_supports_W_linker_passthrough" if the compiler is known to
+# support "-Wl,{options}" to pass options through to the linker.
+# Currently, we assume GCC, xlc, and clang do; other compilers should
+# be added here.
+#
+if test "x$GCC" = "xyes" -o "x$CC" = "xxlc" -o "x$CC" = "xclang" ; then
+ ac_supports_W_linker_passthrough=yes
+fi
+
+#
+# Set "ac_supports_attribute_unused" if the compiler is known to
+# support "__attribute__(unused)".
+# Currently, we assume GCC and clang do; other compilers should
+# be added here.
+#
+# XXX - do this with a compiler test?
+#
+if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
+ ac_supports_W_linker_passthrough=yes
fi
if test "x$CC_FOR_BUILD" = x
@@ -345,12 +367,12 @@ AC_WIRESHARK_GCC_CFLAGS_CHECK(-Wformat-security)
# Use the faster pre gcc 4.5 floating point precision
AC_WIRESHARK_GCC_CFLAGS_CHECK(-fexcess-precision=fast)
-AC_WIRESHARK_GCC_LDFLAGS_CHECK([-Wl,--as-needed])
-###AC_WIRESHARK_GCC_LDFLAGS_CHECK([-Wl,-M])
-###AC_WIRESHARK_GCC_LDFLAGS_CHECK([-Wl,--cref])
-# AC_WIRESHARK_GCC_LDFLAGS_CHECK([-flto])
-# AC_WIRESHARK_GCC_LDFLAGS_CHECK([-fwhopr])
-# AC_WIRESHARK_GCC_LDFLAGS_CHECK([-fwhole-program])
+AC_WIRESHARK_LDFLAGS_CHECK([-Wl,--as-needed])
+###AC_WIRESHARK_LDFLAGS_CHECK([-Wl,-M])
+###AC_WIRESHARK_LDFLAGS_CHECK([-Wl,--cref])
+# AC_WIRESHARK_LDFLAGS_CHECK([-flto])
+# AC_WIRESHARK_LDFLAGS_CHECK([-fwhopr])
+# AC_WIRESHARK_LDFLAGS_CHECK([-fwhole-program])
#
# If we're running GCC or clang, add '-D_U_="__attribute__((unused))"' to
@@ -361,14 +383,15 @@ AC_WIRESHARK_GCC_LDFLAGS_CHECK([-Wl,--as-needed])
#
# XXX - other compilers?
#
-if test "x$GCC" = "xyes" -o "x$CLANG" = "xyes" ; then
+if test "x$GCC" = "xyes" -o "x$CC" = "xclang" ; then
CFLAGS="-D_U_=\"__attribute__((unused))\" $CFLAGS"
else
CFLAGS="-D_U_=\"\" $CFLAGS"
fi
#
-# If we're running GCC or clang, enable a barrier "stop on warning".
+# If the compiler supports GCC-style flags, enable a barrier "stop on
+# warning".
# This barrier is set for a very large part of the code. However, it is
# typically not set for "generated" code (flex, ans2wrs, idl2wrs, ...)
#
@@ -378,7 +401,7 @@ AC_ARG_ENABLE(warnings-as-errors,
AC_HELP_STRING( [--enable-warnings-as-errors],
[Treat warnings as errors (only for GCC or clang). @<:@default=yes@:>@]),
[
- if test \( "x$GCC" = "xyes" -o "x$CLANG" = "xyes" \) -a "x$enableval" == "xyes" -a "x$wireshark_extra_gcc_flags" != "xyes"; then
+ if test "x$ac_supports_gcc_flags" = "xyes" -a "x$enableval" = "xyes" -a "x$wireshark_extra_gcc_flags" != "xyes"; then
with_warnings_as_errors="yes"
AC_MSG_RESULT(yes)
else
@@ -386,7 +409,7 @@ AC_ARG_ENABLE(warnings-as-errors,
AC_MSG_RESULT(no)
fi
],
- if test \( "x$GCC" = "xyes" -o "x$CLANG" = "xyes" \) -a "x$wireshark_extra_gcc_flags" = "x" -a "x$warnings_as_errors_default" = "xyes"; then
+ if test "x$ac_supports_gcc_flags" = "xyes" -a "x$wireshark_extra_gcc_flags" = "x" -a "x$warnings_as_errors_default" = "xyes"; then
with_warnings_as_errors="yes"
AC_MSG_RESULT(yes)
else
@@ -444,8 +467,19 @@ else
# apparently-legal code won't compile with its precompiled
# headers.
#
- CFLAGS="-no-cpp-precomp $CFLAGS"
- AC_MSG_RESULT(Apple GCC - added -no-cpp-precomp)
+ # On the other hand, if it's called "clang", it's not a
+ # GCC derivative, and it whines if you pass it
+ # -no-cpp-precomp.
+ #
+ if test "x$CC" != "xclang" ; then
+ CFLAGS="-no-cpp-precomp $CFLAGS"
+ AC_MSG_RESULT(Apple GCC - added -no-cpp-precomp)
+ else
+ #
+ # Clang, clang, clang went the trolley....
+ #
+ AC_MSG_RESULT(none needed)
+ fi
;;
*)
AC_MSG_RESULT(none needed)