# header.
#
# However, it might also happen on some others OSes with some erroneous
- # system manipulations where multiple versions of libcap might co-exist
+ # system manipulations where multiple versions of libpcap might co-exist
# e.g. hand made symbolic link from libpcap.so -> libpcap.so.0.8 but
# having the pcap header version 0.7.
#
LIBS="$ac_save_LIBS"
])
-#
-# AC_WIRESHARK_CHECK_DLADDR
-#
-AC_DEFUN([AC_WIRESHARK_CHECK_DLADDR],
-[
- ac_save_CFLAGS="$CFLAGS"
- ac_save_LIBS="$LIBS"
- CFLAGS="$CFLAGS $GLIB_CFLAGS"
- LIBS="$GLIB_LIBS $LIBS $1"
- AC_TRY_RUN(
-[
-#define _GNU_SOURCE /* required on Linux, sigh */
-#include <dlfcn.h>
-
-int
-main(void)
-{
- Dl_info info;
-
- if (!dladdr((void *)main, &info))
- return 1; /* failure */
- return 0; /* assume success */
-}
-],
- ac_cv_dladdr_finds_executable_path=yes,
- ac_cv_dladdr_finds_executable_path=no,
- [echo $ac_n "cross compiling; assumed OK... $ac_c"
- ac_cv_dladdr_finds_executable_path=yes])
- CFLAGS="$ac_save_CFLAGS"
- LIBS="$ac_save_LIBS"
- if test x$ac_cv_dladdr_finds_executable_path = xyes
- then
- AC_DEFINE(DLADDR_FINDS_EXECUTABLE_PATH, 1, [Define if dladdr can be used to find the path of the executable])
- fi
-])
-
#
# AC_WIRESHARK_ZLIB_CHECK
#
LUA_LIBS="-llua -lm"
LUA_INCLUDES=""
fi
- AC_DEFINE(HAVE_LUA, 1, [Define to use Lua ${lua_ver}])
+ AC_DEFINE(HAVE_LUA, 1, [Define to use Lua])
want_lua=yes
],[
# Lua found
#
LUA_LIBS=" -llua${lua_ver} -lm"
- AC_DEFINE(HAVE_LUA, 1, [Define to use Lua ${lua_ver}])
+ AC_DEFINE(HAVE_LUA, 1, [Define to use Lua])
want_lua=yes
],[
#
CFLAGS="$save_CFLAGS"
])
+dnl
+dnl Check whether, if you pass a valid-for-C-but-not-C++ option to the
+dnl compiler, it fails or just prints a warning message and succeeds.
+dnl Set ac_wireshark_non_cxx_warning_option_error to the appropriate flag
+dnl to force an error if it would otherwise just print a warning message
+dnl and succeed.
+dnl
+AC_DEFUN([AC_WIRESHARK_CHECK_NON_CXX_WARNING_OPTION_ERROR],
+ [
+ AC_MSG_CHECKING([whether the compiler fails when given an warning option not supported for C++])
+ #
+ # Some C+ compilers warn about -Wmissing-prototypes, and some warn
+ # about -Wmissing-declarations. Check both.
+ #
+ AC_LANG_PUSH(C++)
+ save_CXXFLAGS="$CXXFLAGS"
+ for flag in -Wmissing-prototypes -Wmissing-declarations; do
+ CXXFLAGS="$save_CXXFLAGS $flag"
+ AC_TRY_COMPILE(
+ [],
+ [return 0],
+ [
+ #
+ # We're assuming this is g++, where -Werror is the
+ # appropriate option to force the compiler to fail.
+ # Check whether it fails with -Werror.
+ #
+ # NOTE: it's important to put -Werror *before*
+ # the flag, otherwise, when it sees the flag,
+ # it doesn't yet know that warnings should be
+ # treated as errors, and doesn't treat the
+ # "that's C-only" warning as an error.
+ #
+ CXXFLAGS="$save_CXXFLAGS -Werror $flag"
+ AC_TRY_COMPILE(
+ [],
+ [return 0],
+ [
+ #
+ # No, so this option is actually OK
+ # with our C++ compiler.
+ #
+ # (We need an empty command here to
+ # prevent some versions of autoconf
+ # from generating a script with an
+ # empty "then" clause for an if statement.)
+ #
+ :
+ ],
+ [
+ #
+ # Yes, so we need -Werror for the tests.
+ #
+ ac_wireshark_non_cxx_warning_option_error="-Werror"
+ break
+ ])
+ ])
+ done
+ CXXFLAGS="$save_CXXFLAGS"
+ AC_LANG_POP
+ if test x$ac_wireshark_non_cxx_warning_option_error = x; then
+ AC_MSG_RESULT([yes])
+ else
+ AC_MSG_RESULT([no, adding -Werror])
+ fi
+ ])
+
#
# AC_WIRESHARK_COMPILER_FLAGS_CHECK
#
#
# Not C-only; if this can be added to the C++ compiler flags, add them.
#
+ # If the option begins with "-W", add
+ # $ac_wireshark_unknown_warning_option_error, as per the above, and
+ # also add $ac_wireshark_non_cxx_warning_option_error, because at
+ # lease some versions of g++ whine about -Wmissing-prototypes, the
+ # fact that at least one of those versions refuses to warn about
+ # function declarations without an earlier declaration nonwithstanding;
+ # perhaps there's a reason not to warn about that with C++ even though
+ # warning about it can be a Good Idea with C, but it's not obvious to
+ # me).
+ #
AC_MSG_CHECKING(whether we can add $GCC_OPTION to CXXFLAGS)
CXXFLAGS_saved="$CXXFLAGS"
if expr "x$GCC_OPTION" : "x-W.*" >/dev/null
then
- CXXFLAGS="$CXXFLAGS $ac_wireshark_unknown_warning_option_error $GCC_OPTION"
+ CXXFLAGS="$CXXFLAGS $ac_wireshark_unknown_warning_option_error $ac_wireshark_non_cxx_warning_option_error $GCC_OPTION"
elif expr "x$GCC_OPTION" : "x-f.*" >/dev/null
then
CXXFLAGS="$CXXFLAGS -Werror $GCC_OPTION"
if test "(" "$can_add_to_cflags" = "yes" -a "$can_add_to_cxxflags" = "no" ")" \
-o "(" "$can_add_to_cflags" = "no" -a "$can_add_to_cxxflags" = "yes" ")"
then
- AC_MSG_WARN([$CC and $CXX appear to be a mismatched pair])
+ #
+ # Confusingly, some C++ compilers like -Wmissing-prototypes but
+ # don't like -Wmissing-declarations and others like
+ # -Wmissing-declarations but don't like -Wmissing-prototypes,
+ # the fact that the corresponding C compiler likes both. Don't
+ # warn about them.
+ #
+ if test "(" x$GCC_OPTION != x-Wmissing-prototypes ")" \
+ -a "(" x$GCC_OPTION != x-Wmissing-declarations ")"
+ then
+ AC_MSG_WARN([$CC and $CXX appear to be a mismatched pair])
+ fi
fi
else
AC_MSG_RESULT(no)
fi
# ])
])
+
+#
+# AC_WIRESHARK_CLANG_CHECK
+#
+# Check if either our C or C++ compiler is Clang
+#
+AC_DEFUN([AC_WIRESHARK_CLANG_CHECK], [
+
+ AC_MSG_CHECKING(if $CC is Clang)
+ AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE([[
+#ifndef __clang__
+CC is not __clang__
+#endif
+ ]])],
+ [
+ CC_IS_CLANG='yes'
+ CFLAGS="$CFLAGS -Qunused-arguments"
+ ],
+ CC_IS_CLANG='no'
+ )
+ AC_MSG_RESULT($CC_IS_CLANG)
+
+ AC_MSG_CHECKING(if $CXX is Clang)
+ AC_LANG_PUSH([C++])
+ AC_COMPILE_IFELSE([
+ AC_LANG_SOURCE([[
+#ifndef __clang__
+CXX is not __clang__
+#endif
+ ]])],
+ [
+ CXX_IS_CLANG='yes'
+ CXXFLAGS="$CXXFLAGS -Qunused-arguments"
+ ],
+ CXX_IS_CLANG='no'
+ )
+ AC_LANG_POP([C++])
+ AC_MSG_RESULT($CXX_IS_CLANG)
+
+])
+