1 dnl Process this file with autoconf to produce a configure script.
4 AC_INIT([MeshLink], [0.1])
6 AM_INIT_AUTOMAKE([std-options subdir-objects nostdinc silent-rules -Wall])
7 AC_CONFIG_HEADERS([config.h])
8 AC_CONFIG_MACRO_DIR([m4])
11 # Enable GNU extensions.
12 # Define this here, not in acconfig's @TOP@ section, since definitions
13 # in the latter don't make it into the configure-time tests.
15 AC_DEFINE([__USE_BSD], 1, [Enable BSD extensions])
17 dnl Checks for programs.
34 AC_DEFINE(HAVE_LINUX, 1, [Linux])
38 AC_DEFINE(HAVE_MINGW, 1, [MinGW])
39 LIBS="$LIBS -lws2_32 -lgdi32 -lcrypt32"
43 AM_CONDITIONAL(LINUX, test "$linux" = true)
44 AM_CONDITIONAL(MINGW, test "$mingw" = true)
48 if test -d /sw/include ; then
49 CPPFLAGS="$CPPFLAGS -I/sw/include"
51 if test -d /sw/lib ; then
52 LIBS="$LIBS -L/sw/lib"
55 dnl Compiler hardening flags
56 dnl No -fstack-protector-all because it doesn't work on all platforms or architectures.
58 AC_ARG_ENABLE([hardening], AS_HELP_STRING([--disable-hardening], [disable compiler and linker hardening flags]))
59 AS_IF([test "x$enable_hardening" != "xno"],
60 [AX_CHECK_COMPILE_FLAG([-DFORTIFY_SOURCE=2], [CPPFLAGS="$CPPFLAGS -DFORITFY_SOURCE=2"])
61 AX_CHECK_COMPILE_FLAG([-fno-strict-overflow], [CPPFLAGS="$CPPFLAGS -fno-strict-overflow"])
62 AX_CHECK_COMPILE_FLAG([-fwrapv], [CPPFLAGS="$CPPFLAGS -fwrapv"])
65 AX_CHECK_LINK_FLAG([-Wl,--dynamicbase], [LDFLAGS="$LDFLAGS -Wl,--dynamicbase"])
66 AX_CHECK_LINK_FLAG([-Wl,--nxcompat], [LDFLAGS="$LDFLAGS -Wl,--nxcompat"])
69 AX_CHECK_COMPILE_FLAG([-fPIE], [CPPFLAGS="$CPPFLAGS -fPIE"])
70 AX_CHECK_COMPILE_FLAG([-fPIC], [CPPFLAGS="$CPPFLAGS -fPIC"])
71 AX_CHECK_LINK_FLAG([-pie], [LDFLAGS="$LDFLAGS -pie"])
74 AX_CHECK_LINK_FLAG([-Wl,-z,relro], [LDFLAGS="$LDFLAGS -Wl,-z,relro"])
75 AX_CHECK_LINK_FLAG([-Wl,-z,now], [LDFLAGS="$LDFLAGS -Wl,-z,now"])
80 AC_ARG_ENABLE([utcp_debug], AS_HELP_STRING([--enable-utcp-debug], [compile utcp with debug output]))
81 AS_IF([test "x$enable_utcp_debug" = "xyes"],
82 [AX_CHECK_COMPILE_FLAG([-DUTCP_DEBUG], [CPPFLAGS="$CPPFLAGS -DUTCP_DEBUG"])
86 dnl Checks for header files.
87 dnl We do this in multiple stages, because unlike Linux all the other operating systems really suck and don't include their own dependencies.
90 AC_CHECK_HEADERS([stdbool.h 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])
91 AC_CHECK_HEADERS([time.h],
92 [], [], [#include "src/have.h"]
95 dnl Checks for typedefs, structures, and compiler characteristics.
103 MeshLink_ATTRIBUTE(__malloc__)
104 MeshLink_ATTRIBUTE(__warn_unused_result__)
106 AC_CHECK_TYPES([socklen_t, struct addrinfo, struct sockaddr_in6], , ,
107 [#include "src/have.h"]
110 AC_CHECK_TYPES([struct sockaddr_storage], ,AC_MSG_ERROR([System must support struct sockaddr_storage.]),
111 [#include "src/have.h"]
114 dnl Checks for library functions.
116 AC_CHECK_FUNCS([asprintf fchmod fork get_current_dir_name gettimeofday random select strdup strerror time usleep],
117 [], [], [#include "src/have.h"]
120 dnl Support for SunOS
122 AC_CHECK_FUNC(socket, [], [
123 AC_CHECK_LIB(socket, connect)
125 AC_CHECK_FUNC(gethostbyname, [], [
126 AC_CHECK_LIB(nsl, gethostbyname)
129 AC_CHECK_DECLS([freeaddrinfo, gai_strerror, getaddrinfo, getnameinfo],
130 [], [], [#include "src/have.h"]
135 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile m4/Makefile test/Makefile examples/Makefile])