]> git.proxmox.com Git - mirror_frr.git/blobdiff - configure.ac
Merge pull request #3189 from opensourcerouting/libunwind
[mirror_frr.git] / configure.ac
index e6ca7d95893ee5ff1732fac5109e9b31212543a4..60d3a876a8bbef66ed535f0f019c77fa94d07b0b 100755 (executable)
@@ -57,7 +57,7 @@ AM_CONDITIONAL([BUILD_CLIPPY], [$build_clippy])
 
 # Disable portability warnings -- our automake code (in particular
 # common.am) uses some constructs specific to gmake.
-AM_INIT_AUTOMAKE([1.12 -Wno-portability])
+AM_INIT_AUTOMAKE([1.12 -Wno-portability foreign])
 m4_ifndef([AM_SILENT_RULES], [m4_define([AM_SILENT_RULES],[])])
 AM_SILENT_RULES([yes])
 AC_CONFIG_HEADERS(config.h)
@@ -203,7 +203,15 @@ elif test "x${enable_dev_build}" = "xyes"; then
       AC_C_FLAG([-g3])
       AC_C_FLAG([-O0])
    fi
+   if test "x${enable_lua}" = "xyes"; then
+      AC_CHECK_LIB([lua], [lua_newstate],
+      [LIBS="$LIBS -llua"])
+      AC_DEFINE(HAVE_LUA,,Lua enabled for development)
+   fi
 else
+   if test "x${enable_lua}" = "xyes"; then
+      AC_MSG_ERROR([Lua is not meant to be built/used outside of development at this time])
+   fi
    if test "z$orig_cflags" = "z"; then
       AC_C_FLAG([-g])
       AC_C_FLAG([-Os], [
@@ -231,6 +239,7 @@ if test x"${enable_gcc_ultra_verbose}" = x"yes" ; then
   AC_C_FLAG([-Wunreachable-code])
   AC_C_FLAG([-Wpacked])
   AC_C_FLAG([-Wpadded])
+  AC_C_FLAG([-Wshadow])
 else
   AC_C_FLAG([-Wno-unused-result])
 fi
@@ -301,7 +310,18 @@ AC_CHECK_TOOL(AR, ar)
 dnl -------
 dnl libtool
 dnl -------
+AC_ARG_ENABLE(static-bin,
+  AS_HELP_STRING([--enable-static-bin], [link binaries statically]))
 LT_INIT
+_LT_CONFIG_LIBTOOL([
+  patch -N -i "${srcdir}/m4/libtool-whole-archive.patch" libtool >&AS_MESSAGE_LOG_FD || \
+    AC_MSG_WARN([Could not patch libtool for static linking support.  Loading modules into a statically linked daemon will fail.])
+])
+if test "$enable_static_bin" = "yes"; then
+  AC_LDFLAGS="-static"
+fi
+AC_SUBST(AC_LDFLAGS)
+AM_CONDITIONAL([STATIC_BIN], [test "x$enable_static_bin" = "xyes"])
 
 dnl ----------------------
 dnl Packages configuration
@@ -453,6 +473,9 @@ fi
 AC_ARG_ENABLE([dev_build],
     AS_HELP_STRING([--enable-dev-build], [build for development]))
 
+AC_ARG_ENABLE([lua],
+    AS_HELP_STRING([--enable-lua], [Build Lua scripting]))
+
 if test x"${enable_time_check}" != x"no" ; then
   if test x"${enable_time_check}" = x"yes" -o x"${enable_time_check}" = x ; then
     AC_DEFINE(CONSUMED_TIME_CHECK,5000000,Consumed Time Check)
@@ -729,6 +752,20 @@ if test "x$with_pkg_git_version" = "xyes"; then
 fi
 AM_CONDITIONAL([GIT_VERSION], [test "x$with_pkg_git_version" = "xyes"])
 
+AC_CHECK_TOOL([OBJCOPY], [objcopy], [:])
+AC_CACHE_CHECK([for .interp value to use], [frr_cv_interp], [
+  frr_cv_interp=""
+  AC_LINK_IFELSE([AC_LANG_SOURCE([[int main() { return 0; }]])], [
+    if $OBJCOPY -j.interp -Obinary conftest conftest.interp; then
+      frr_cv_interp="`xargs -0 echo < conftest.interp`"
+    fi
+    test -f conftest.interp && rm conftest.interp
+  ])
+])
+if test -n "$frr_cv_interp"; then
+  AC_DEFINE_UNQUOTED(INTERP, ["$frr_cv_interp"], [.interp value])
+fi
+
 dnl ------------------------------------
 dnl Check C keywords and standard  types
 dnl ------------------------------------
@@ -815,6 +852,11 @@ int main(int argc, char **argv) {
   ])
 ])
 
+AC_CHECK_HEADERS([pthread_np.h],,, [
+#include <pthread.h>
+])
+AC_CHECK_FUNCS([pthread_setname_np pthread_set_name_np])
+
 dnl Utility macro to avoid retyping includes all the time
 m4_define([FRR_INCLUDES],
 [#ifdef SUNOS_5
@@ -916,10 +958,6 @@ case "$host_os" in
     AC_CHECK_LIB(socket, main)
     AC_CHECK_LIB(nsl, main)
     AC_CHECK_LIB(umem, main)
-    AC_CHECK_FUNCS([printstack], [
-      AC_DEFINE([HAVE_PRINTSTACK],1,[Solaris printstack])
-      AC_DEFINE([HAVE_STACK_TRACE],1,[Stack symbols decode functionality])
-    ])
     CURSES=-lcurses
     SOLARIS="solaris"
     ;;
@@ -1120,6 +1158,7 @@ if test x"$LIBM" = x ; then
   AC_MSG_WARN([Unable to find working pow function - bgpd may not link])
 fi
 LIBS="$TMPLIBS"
+
 AC_SUBST(LIBM)
 
 AC_CHECK_FUNCS([ppoll], [
@@ -1310,8 +1349,13 @@ FRR_INCLUDES
 ])dnl
 
 dnl disable doc check
-AC_CHECK_PROGS([SPHINXBUILD], [sphinx-build sphinx-build3 sphinx-build2], [no])
-AM_CONDITIONAL(DOC, test "${enable_doc}" != "no")
+AC_CHECK_PROGS([SPHINXBUILD], [sphinx-build sphinx-build3 sphinx-build2], [/bin/false])
+if test "$SPHINXBUILD" = "/bin/false"; then
+  if test "${enable_doc}" = "yes"; then
+    AC_MSG_ERROR([Documentation was explicitly requested with --enable-doc but sphinx-build is not available. Please disable docs or install sphinx.])
+  fi
+fi
+AM_CONDITIONAL(DOC, test "${enable_doc}" != "no" -a "$SPHINXBUILD" != "/bin/false")
 AM_CONDITIONAL(DOC_HTML, test "${enable_doc_html}" = "yes")
 
 dnl --------------------
@@ -1763,17 +1807,31 @@ dnl check for glibc 'backtrace'
 dnl --------------------------- 
 if test x"${enable_backtrace}" != x"no" ; then
   backtrace_ok=no
-  AC_CHECK_HEADER([execinfo.h], [
-    AC_SEARCH_LIBS([backtrace], [execinfo], [
-      AC_DEFINE(HAVE_GLIBC_BACKTRACE,,[Glibc backtrace])
-      AC_DEFINE(HAVE_STACK_TRACE,,[Stack symbol decoding])
-      backtrace_ok=yes
-    ],, [-lm])
+  PKG_CHECK_MODULES([UNWIND], [libunwind], [
+    AC_DEFINE(HAVE_LIBUNWIND, 1, [libunwind])
+    backtrace_ok=yes
+  ], [
+    case "$host_os" in
+    sunos* | solaris2*)
+      AC_CHECK_FUNCS([printstack], [
+        AC_DEFINE([HAVE_PRINTSTACK], 1, [Solaris printstack])
+        backtrace_ok=yes
+      ])
+      ;;
+    esac
+    if test "$backtrace_ok" = no; then
+      AC_CHECK_HEADER([execinfo.h], [
+        AC_SEARCH_LIBS([backtrace], [execinfo], [
+          AC_DEFINE(HAVE_GLIBC_BACKTRACE, 1, [Glibc backtrace])
+          backtrace_ok=yes
+        ],, [-lm])
+      ])
+    fi
   ])
 
   if test x"${enable_backtrace}" = x"yes" -a x"${backtrace_ok}" = x"no"; then
     dnl user explicitly requested backtrace but we failed to find support
-    AC_MSG_FAILURE([failed to find backtrace support])
+    AC_MSG_FAILURE([failed to find backtrace or libunwind support])
   fi
 fi
 
@@ -1784,13 +1842,16 @@ dnl order to check no alternative allocator
 dnl has been specified, which might not provide
 dnl mallinfo, e.g. such as Umem on Solaris.
 dnl -----------------------------------------
-AC_CHECK_HEADERS([malloc.h malloc/malloc.h],,, [FRR_INCLUDES])
+AC_CHECK_HEADERS([malloc.h malloc_np.h malloc/malloc.h],,, [FRR_INCLUDES])
 
 AC_CACHE_CHECK([whether mallinfo is available], [frr_cv_mallinfo], [
   AC_LINK_IFELSE([AC_LANG_PROGRAM([FRR_INCLUDES [
 #ifdef HAVE_MALLOC_H
 #include <malloc.h>
 #endif
+#ifdef HAVE_MALLOC_NP_H
+#include <malloc_np.h>
+#endif
 #ifdef HAVE_MALLOC_MALLOC_H
 #include <malloc/malloc.h>
 #endif
@@ -1912,6 +1973,7 @@ for I in 1 2 3 4 5 6 7 8 9 10; do
        eval vtysh_bin="\"$vtysh_bin\""
 done
 AC_DEFINE_UNQUOTED(VTYSH_BIN_PATH, "$vtysh_bin",path to vtysh binary)
+AC_SUBST(vtysh_bin)
 
 CFG_SYSCONF="$sysconfdir"
 CFG_SBIN="$sbindir"
@@ -1978,6 +2040,7 @@ AC_CONFIG_FILES([
          pkgsrc/eigrpd.sh])
 
 AC_CONFIG_FILES([vtysh/extract.pl],[chmod +x vtysh/extract.pl])
+AC_CONFIG_FILES([tools/frr],[chmod +x tools/frr])
 
 AC_CONFIG_COMMANDS([lib/route_types.h], [
        dst="${ac_abs_top_builddir}/lib/route_types.h"
@@ -2036,6 +2099,6 @@ The above user and group must have read/write access to the state file
 directory and to the config files in the config file directory."
 
 if test "${enable_doc}" != "no";then
-  AS_IF([test "x$SPHINXBUILD" = xno],
+  AS_IF([test "$SPHINXBUILD" = /bin/false],
      AC_MSG_WARN(sphinx-build is missing but required to build documentation))
 fi