1 dnl Process this file with autoconf to produce a configure script.
4 AC_INIT([MeshLink], [0.1])
6 DX_INIT_DOXYGEN([MeshLink], [$(top_srcdir)/Doxyfile])
7 AM_INIT_AUTOMAKE([std-options subdir-objects nostdinc silent-rules -Wall])
8 AC_CONFIG_HEADERS([config.h])
9 AC_CONFIG_MACRO_DIR([m4])
10 AM_SILENT_RULES([yes])
12 # Enable GNU extensions.
13 # Define this here, not in acconfig's @TOP@ section, since definitions
14 # in the latter don't make it into the configure-time tests.
15 AC_USE_SYSTEM_EXTENSIONS
16 AC_DEFINE([__USE_BSD], 1, [Enable BSD extensions])
17 AC_DEFINE([_POSIX_C_SOURCE], 200809L, [Enable POSIX features])
18 AC_DEFINE([_DARWIN_C_SOURCE], 1, [Enable Darwin features])
20 dnl Checks for programs.
39 AC_DEFINE(HAVE_LINUX, 1, [Linux])
43 AC_DEFINE(HAVE_MINGW, 1, [MinGW])
44 LIBS="$LIBS -lws2_32 -lgdi32 -lcrypt32"
47 LIBS="$LIBS -framework Foundation -framework SystemConfiguration"
51 AM_CONDITIONAL(LINUX, test "$linux" = true)
52 AM_CONDITIONAL(MINGW, test "$mingw" = true)
56 if test -d /sw/include ; then
57 CPPFLAGS="$CPPFLAGS -I/sw/include"
59 if test -d /sw/lib ; then
60 LIBS="$LIBS -L/sw/lib"
63 AX_CHECK_COMPILE_FLAG([-std=c11], [CFLAGS="$CFLAGS -std=c11"])
65 dnl Compiler hardening flags
66 dnl No -fstack-protector-all because it doesn't work on all platforms or architectures.
68 AC_ARG_ENABLE([hardening], AS_HELP_STRING([--disable-hardening], [disable compiler and linker hardening flags]))
69 AS_IF([test "x$enable_hardening" != "xno"],
70 [CPPFLAGS="$CPPFLAGS -Wall -W -pedantic"
71 AX_CHECK_COMPILE_FLAG([-DFORTIFY_SOURCE=2], [CPPFLAGS="$CPPFLAGS -DFORITFY_SOURCE=2"])
72 AX_CHECK_COMPILE_FLAG([-fwrapv], [CPPFLAGS="$CPPFLAGS -fwrapv"],
73 [AX_CHECK_COMPILE_FLAG([-fno-strict-overflow], [CPPFLAGS="$CPPFLAGS -fno-strict-overflow"])]
77 AX_CHECK_LINK_FLAG([-Wl,--dynamicbase], [LDFLAGS="$LDFLAGS -Wl,--dynamicbase"])
78 AX_CHECK_LINK_FLAG([-Wl,--nxcompat], [LDFLAGS="$LDFLAGS -Wl,--nxcompat"])
81 AX_CHECK_COMPILE_FLAG([-fPIC], [CPPFLAGS="$CPPFLAGS -fPIC"])
84 AX_CHECK_LINK_FLAG([-Wl,-z,relro], [LDFLAGS="$LDFLAGS -Wl,-z,relro"])
85 AX_CHECK_LINK_FLAG([-Wl,-z,now], [LDFLAGS="$LDFLAGS -Wl,-z,now"])
86 AX_CHECK_COMPILE_FLAG([-Wextra -pedantic -Wreturn-type -Wold-style-definition -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wshadow -Wbad-function-cast -Wwrite-strings -fdiagnostics-show-option -fstrict-aliasing -Wmissing-noreturn], [CPPFLAGS="$CPPFLAGS -Wextra -pedantic -Wreturn-type -Wold-style-definition -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wredundant-decls -Wshadow -Wbad-function-cast -Wwrite-strings -fdiagnostics-show-option -fstrict-aliasing -Wmissing-noreturn"])
91 AC_ARG_ENABLE([utcp_debug], AS_HELP_STRING([--enable-utcp-debug], [compile utcp with debug output]))
92 AS_IF([test "x$enable_utcp_debug" = "xyes"],
93 [AX_CHECK_COMPILE_FLAG([-DUTCP_DEBUG], [CPPFLAGS="$CPPFLAGS -DUTCP_DEBUG"])
97 dnl Blackbox test suite
98 PKG_CHECK_MODULES([CMOCKA], [cmocka >= 1.1.0], [cmocka=true], [cmocka=false])
99 PKG_CHECK_MODULES([LXC], [lxc >= 2.0.0], [lxc=true], [lxc=false])
100 AM_CONDITIONAL(BLACKBOX_TESTS, test "$cmocka" = true -a "$lxc" = true)
103 dnl Additional example code
104 PKG_CHECK_MODULES([NCURSES], [ncurses >= 5], [curses=true], [curses=false])
105 AC_ARG_ENABLE([monitor_code],
106 [AS_HELP_STRING([--enable-monitor-code], [Add monitor example code to the build])],
107 [AS_IF([test "x$enable_monitor_code" = "xyes"], [monitor_code=true], [monitor_code=false])],
110 AM_CONDITIONAL(MONITOR, test "$monitor_code" = true)
112 dnl Install test binaries
113 AC_ARG_ENABLE([install_tests],
114 [AS_HELP_STRING([--enable-install-tests], [include test binaries in installation])],
115 [AS_IF([test "x$enable_install_tests" = "xyes"], [install_tests=true], [install_tests=false])],
116 [install_tests=false]
119 AM_CONDITIONAL(INSTALL_TESTS, test "$install_tests" = true)
121 dnl Checks for header files.
122 dnl We do this in multiple stages, because unlike Linux all the other operating systems really suck and don't include their own dependencies.
124 AC_CHECK_HEADERS([syslog.h sys/file.h sys/param.h sys/resource.h sys/socket.h sys/time.h sys/un.h sys/wait.h netdb.h arpa/inet.h dirent.h curses.h ifaddrs.h stdatomic.h])
126 dnl Checks for typedefs, structures, and compiler characteristics.
127 MeshLink_ATTRIBUTE(__malloc__)
128 MeshLink_ATTRIBUTE(__warn_unused_result__)
130 dnl Checks for library functions.
131 AC_CHECK_FUNCS([asprintf fchmod flock fork gettimeofday random pselect select setns strdup usleep getifaddrs freeifaddrs],
132 [], [], [#include "$srcdir/src/have.h"]
135 dnl Support for SunOS
137 AC_CHECK_FUNC(socket, [], [
138 AC_CHECK_LIB(socket, connect)