📄 click.m4
字号:
dnl -*- mode: shell-script; -*-dnldnl Common Click configure.in functionsdnldnldnl CLICK_INITdnl Initialize Click configure functionality. Must be called beforednl CC or CXX are defined.dnl Check whether the user specified which compilers we should use.dnl If so, we don't screw with their choices later.dnlAC_DEFUN([CLICK_INIT], [ ac_user_cc=; test -n "$CC" && ac_user_cc=y ac_user_kernel_cc=; test -n "$KERNEL_CC" && ac_user_kernel_cc=y ac_user_cxx=; test -n "$CXX" && ac_user_cxx=y ac_user_build_cxx=; test -n "$BUILD_CXX" && ac_user_build_cxx=y ac_user_kernel_cxx=; test -n "$KERNEL_CXX" && ac_user_kernel_cxx=y ac_user_depcflags=; test -n "$DEPCFLAGS" && ac_user_depcflags=y ac_compile_with_warnings=y conf_auxdir=$1 AC_SUBST(conf_auxdir)])dnldnl CLICK_PROG_CCdnl Find the C compiler, and make sure it is suitable.dnlAC_DEFUN([CLICK_PROG_CC], [ AC_REQUIRE([AC_PROG_CC]) ac_base_cc="$CC" test -z "$ac_user_cc" -a -n "$GCC" -a -n "$ac_compile_with_warnings" && \ CC="$CC -W -Wall" test -z "$ac_user_cc" -a -n "$GCC" -a -n "$ac_compile_with_warnings" -a -z "$ac_user_depcflags" && \ DEPCFLAGS="-MD" AC_SUBST(DEPCFLAGS) CFLAGS_NDEBUG=`echo "$CFLAGS" | sed 's/-g//'` AC_SUBST(CFLAGS_NDEBUG)])dnldnl CLICK_PROG_CXXdnl Find the C++ compiler, and make sure it is suitable.dnlAC_DEFUN([CLICK_PROG_CXX], [ AC_REQUIRE([AC_PROG_CXX]) dnl work around Autoconf 2.53, which #includes <stdlib.h> inappropriately if grep __cplusplus confdefs.h >/dev/null 2>&1; then sed 's/#ifdef __cplusplus/#if defined(__cplusplus) \&\& !defined(__KERNEL__)/' < confdefs.h > confdefs.h~ mv confdefs.h~ confdefs.h fi if test -z "$GXX"; then AC_MSG_WARN([=========================================Your C++ compiler ($CXX) is not a GNU C++ compiler!Either set the 'CXX' environment variable to tell me wherea GNU C++ compiler is, or compile at your own risk.(This code uses a few GCC extensions and GCC-specific compiler options,and Linux header files are GCC-specific.)=========================================]) fi AC_LANG_CPLUSPLUS if test -n "$GXX"; then changequote(<<,>>)GXX_VERSION=`$CXX --version | head -1 | sed 's/^[^0-9]*\([0-9.]*\).*/\1/'` GXX_MAJOR=`echo $GXX_VERSION | sed 's/\..*//'` GXX_MINOR=`echo $GXX_VERSION | sed 's/^[^.]*\.\([^.]*\).*/\1/'`changequote([,]) if test $GXX_MAJOR -lt 2 -o \( $GXX_MAJOR -eq 2 -a $GXX_MINOR -le 7 \); then AC_MSG_ERROR([=========================================Your GNU C++ compiler ($CXX) is too old!Either download a newer compiler, or tell me to use a different compilerby setting the 'CXX' environment variable and rerunning me.=========================================]) fi fi dnl check for <new> and <new.h> AC_CACHE_CHECK([whether <new> works], [ac_cv_good_new_hdr], [ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <new>]], [[ int a; int *b = new(&a) int; return 0;]])], [ac_cv_good_new_hdr=yes], [ac_cv_good_new_hdr=no])]) if test "$ac_cv_good_new_hdr" = yes; then AC_DEFINE([HAVE_NEW_HDR], [1], [Define if <new> exists and works.]) else AC_CACHE_CHECK([whether <new.h> works], [ac_cv_good_new_h], [ AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <new.h>]], [[ int a; int *b = new(&a) int; return 0;]])], [ac_cv_good_new_h=yes], [ac_cv_good_new_h=no])]) if test "$ac_cv_good_new_h" = yes; then AC_DEFINE([HAVE_NEW_H], [1], [Define if <new.h> exists and works.]) fi fi dnl check for -fvtable-thunks VTABLE_THUNKS= test -n "$GXX" && test "$GXX_MAJOR" -lt 3 && VTABLE_THUNKS=-fvtable-thunks dnl define correct warning options CXX_WARNINGS= test -z "$ac_user_cxx" -a -n "$GXX" -a -n "$ac_compile_with_warnings" && \ CXX_WARNINGS='-W -Wall' ac_base_cxx="$CXX" test -z "$ac_user_cxx" -a -n "$GXX" -a -n "$ac_compile_with_warnings" && \ CXX="$CXX $CXX_WARNINGS -fno-exceptions -fno-rtti $VTABLE_THUNKS" CXXFLAGS_NDEBUG=`echo "$CXXFLAGS" | sed 's/-g//'` AC_SUBST(CXXFLAGS_NDEBUG)])dnldnl CLICK_PROG_BUILD_CXXdnl Prepare the C++ compiler for the build host.dnlAC_DEFUN([CLICK_PROG_BUILD_CXX], [ dnl This doesn't really work, but it's close. ac_base_build_cxx="$CXX" test -z "$ac_user_build_cxx" -a -n "$ac_compile_with_warnings" && \ BUILD_CXX="$BUILD_CXX $CXX_WARNINGS -fno-exceptions -fno-rtti $VTABLE_THUNKS"])dnldnl CLICK_PROG_KERNEL_CCdnl Prepare the kernel-ready C compiler.dnlAC_DEFUN([CLICK_PROG_KERNEL_CC], [ AC_REQUIRE([CLICK_PROG_CC]) test -z "$ac_user_kernel_cc" && \ KERNEL_CC="$ac_base_cc" test -z "$ac_user_kernel_cc" -a -n "$GCC" -a -n "$ac_compile_with_warnings" && \ KERNEL_CC="$ac_base_cc -w $CXX_WARNINGS" AC_SUBST(KERNEL_CC)])dnldnl CLICK_PROG_KERNEL_CXXdnl Prepare the kernel-ready C++ compiler.dnlAC_DEFUN([CLICK_PROG_KERNEL_CXX], [ AC_REQUIRE([CLICK_PROG_CXX]) test -z "$ac_user_kernel_cxx" && \ KERNEL_CXX="$ac_base_cxx" test -z "$ac_user_kernel_cxx" -a -n "$GXX" -a -n "$ac_compile_with_warnings" && \ KERNEL_CXX="$ac_base_cxx -w $CXX_WARNINGS -fno-exceptions -fno-rtti $VTABLE_THUNKS" AC_SUBST(KERNEL_CXX)])dnldnl CLICK_CHECK_DYNAMIC_LINKINGdnl Defines HAVE_DYNAMIC_LINKING and DL_LIBS if <dlfcn.h> and -ldl exist dnl and work. Also defines LDMODULEFLAGS, the flags to pass to the linkerdnl when building a loadable module.dnlAC_DEFUN([CLICK_CHECK_DYNAMIC_LINKING], [ DL_LIBS= AC_CHECK_HEADERS(dlfcn.h, ac_have_dlfcn_h=yes, ac_have_dlfcn_h=no) AC_CHECK_FUNC(dlopen, ac_have_dlopen=yes, [AC_CHECK_LIB(dl, dlopen, [ac_have_dlopen=yes; DL_LIBS="-ldl"], ac_have_dlopen=no)]) if test "x$ac_have_dlopen" = xyes -a "x$ac_have_dlfcn_h" = xyes; then AC_DEFINE([HAVE_DYNAMIC_LINKING], [1], [Define if dynamic linking is possible.]) ac_have_dynamic_linking=yes fi AC_SUBST(DL_LIBS) AC_MSG_CHECKING(compiler flags for building loadable modules) LDMODULEFLAGS=-shared if test "x$ac_have_dynamic_linking" = xyes; then if echo "$ac_cv_target" | grep apple-darwin >/dev/null 2>&1; then LDMODULEFLAGS='-bundle -flat_namespace -undefined suppress' fi fi AC_MSG_RESULT($LDMODULEFLAGS) AC_SUBST(LDMODULEFLAGS)])dnldnl CLICK_CHECK_BUILD_DYNAMIC_LINKINGdnl Defines HAVE_DYNAMIC_LINKING and DL_LIBS if <dlfcn.h> and -ldl exist dnl and work, on the build system. Must have done CLICK_CHECK_DYNAMIC_LINKINGdnl already.dnlAC_DEFUN([CLICK_CHECK_BUILD_DYNAMIC_LINKING], [ saver="CXX='$CXX' CXXCPP='$CXXCPP' ac_cv_header_dlfcn_h='$ac_cv_header_dlfcn_h' ac_cv_func_dlopen='$ac_cv_func_dlopen' ac_cv_lib_dl_dlopen='$ac_cv_lib_dl_dlopen'" CXX="$BUILD_CXX"; CXXCPP="$BUILD_CXX -E" unset ac_cv_header_dlfcn_h ac_cv_func_dlopen ac_cv_lib_dl_dlopen BUILD_DL_LIBS= AC_CHECK_HEADERS(dlfcn.h, ac_build_have_dlfcn_h=yes, ac_build_have_dlfcn_h=no) AC_CHECK_FUNC(dlopen, ac_build_have_dlopen=yes, [AC_CHECK_LIB(dl, dlopen, [ac_build_have_dlopen=yes; BUILD_DL_LIBS="-ldl"], ac_have_dlopen=no)]) if test "x$ac_build_have_dlopen" = xyes -a "x$ac_build_have_dlfcn_h" = xyes; then ac_build_have_dynamic_linking=yes fi if test "x$ac_build_have_dynamic_linking" != "x$ac_have_dynamic_linking"; then AC_MSG_ERROR([=========================================Build system and host system don't have the same dynamic linking state!=========================================]) fi AC_SUBST(BUILD_DL_LIBS) eval "$saver"])dnldnl CLICK_CHECK_LIBPCAPdnl Finds header files and libraries for libpcap.dnlAC_DEFUN([CLICK_CHECK_LIBPCAP], [ dnl header files HAVE_PCAP=yes if test "${PCAP_INCLUDES-NO}" = NO; then AC_CACHE_CHECK(for pcap.h, ac_cv_pcap_header_path, [ AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <pcap.h>]])], ac_cv_pcap_header_path="found", [ac_cv_pcap_header_path='not found' test -r /usr/local/include/pcap/pcap.h && \ ac_cv_pcap_header_path='-I/usr/local/include/pcap' test -r /usr/include/pcap/pcap.h && \ ac_cv_pcap_header_path='-I/usr/include/pcap'])]) if test "$ac_cv_pcap_header_path" = 'not found'; then HAVE_PCAP= elif test "$ac_cv_pcap_header_path" != 'found'; then PCAP_INCLUDES="$ac_cv_pcap_header_path" fi fi if test "$HAVE_PCAP" = yes; then AC_CACHE_CHECK(whether pcap.h works, ac_cv_working_pcap_h, [ saveflags="$CPPFLAGS" CPPFLAGS="$saveflags $PCAP_INCLUDES" AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <pcap.h>]])], ac_cv_working_pcap_h=yes, ac_cv_working_pcap_h=no) CPPFLAGS="$saveflags"]) test "$ac_cv_working_pcap_h" != yes && HAVE_PCAP= fi if test "$HAVE_PCAP" = yes; then saveflags="$CPPFLAGS" CPPFLAGS="$saveflags $PCAP_INCLUDES" AC_CACHE_CHECK(for bpf_timeval in pcap.h, ac_cv_bpf_timeval, AC_EGREP_HEADER(bpf_timeval, pcap.h, ac_cv_bpf_timeval=yes, ac_cv_bpf_timeval=no)) if test "$ac_cv_bpf_timeval" = yes; then AC_DEFINE([HAVE_BPF_TIMEVAL], [1], [Define if <pcap.h> uses bpf_timeval.]) fi AC_CHECK_DECLS(pcap_setnonblock, [], [], [#include <pcap.h>]) CPPFLAGS="$saveflags" fi test "$HAVE_PCAP" != yes && PCAP_INCLUDES= AC_SUBST(PCAP_INCLUDES) dnl libraries if test "$HAVE_PCAP" = yes; then if test "${PCAP_LIBS-NO}" = NO; then AC_CACHE_CHECK([for -lpcap], [ac_cv_pcap_library_path], [ saveflags="$LDFLAGS" savelibs="$LIBS" LIBS="$savelibs -lpcap $SOCKET_LIBS" AC_LANG_C AC_LINK_IFELSE([AC_LANG_CALL([[]], [[pcap_open_live]])], [ac_cv_pcap_library_path="found"], [LDFLAGS="$saveflags -L/usr/local/lib" AC_LINK_IFELSE([AC_LANG_CALL([[]], [[pcap_open_live]])], [ac_cv_pcap_library_path="-L/usr/local/lib"], [ac_cv_pcap_library_path="not found"])]) LDFLAGS="$saveflags" LIBS="$savelibs"]) else AC_CACHE_CHECK([for -lpcap in "$PCAP_LIBS"], [ac_cv_pcap_library_path], [ saveflags="$LDFLAGS" LDFLAGS="$saveflags $PCAP_LIBS" savelibs="$LIBS" LIBS="$savelibs -lpcap $SOCKET_LIBS" AC_LANG_C AC_LINK_IFELSE([AC_LANG_CALL([[]], [[pcap_open_live]])], [ac_cv_pcap_library_path="$PCAP_LIBS"], [ac_cv_pcap_library_path="not found"]) LDFLAGS="$saveflags" LIBS="$savelibs"]) fi if test "$ac_cv_pcap_library_path" = "found"; then PCAP_LIBS='-lpcap' elif test "$ac_cv_pcap_library_path" != "not found"; then PCAP_LIBS="$ac_cv_pcap_library_path -lpcap" else HAVE_PCAP= fi fi test "$HAVE_PCAP" != yes && PCAP_LIBS= AC_SUBST(PCAP_LIBS) if test "$HAVE_PCAP" = yes; then AC_DEFINE([HAVE_PCAP], [1], [Define if you have -lpcap and pcap.h.]) saveflags="$LDFLAGS" LDFLAGS="$saveflags $PCAP_LIBS" AC_CHECK_FUNCS(pcap_setnonblock) LDFLAGS="$saveflags" fi])dnldnl CLICK_PROG_INSTALLdnl Substitute both INSTALL and INSTALL_IF_CHANGED.dnlAC_DEFUN([CLICK_PROG_INSTALL], [ AC_REQUIRE([AC_PROG_INSTALL]) AC_MSG_CHECKING(whether install accepts -C) echo X > conftest.1 if $INSTALL -C conftest.1 conftest.2 >/dev/null 2>&1; then INSTALL_IF_CHANGED='$(INSTALL) -C' AC_MSG_RESULT(yes) else INSTALL_IF_CHANGED='$(INSTALL)' AC_MSG_RESULT(no) fi rm -f conftest.1 conftest.2 AC_SUBST(INSTALL_IF_CHANGED)])dnldnl CLICK_PROG_AUTOCONFdnl Substitute AUTOCONF.dnlAC_DEFUN([CLICK_PROG_AUTOCONF], [ AC_MSG_CHECKING(for working autoconf) AUTOCONF="${AUTOCONF-autoconf}" if ($AUTOCONF --version) < /dev/null > conftest.out 2>&1; then if test `head -1 conftest.out | sed 's/.*2\.\([[0-9]]*\).*/\1/'` -ge 13 2>/dev/null; then AC_MSG_RESULT(found) else AUTOCONF='$(conf_auxdir)/missing autoconf' AC_MSG_RESULT(old) fi else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -