1 dnl Process this file with autoconf to produce a configure script.
4 AC_INIT([MeshLink], [0.1])
6 AM_INIT_AUTOMAKE([check-news std-options subdir-objects -Wall])
7 AC_CONFIG_HEADERS([config.h])
8 AC_CONFIG_MACRO_DIR([m4])
10 # Enable GNU extensions.
11 # Define this here, not in acconfig's @TOP@ section, since definitions
12 # in the latter don't make it into the configure-time tests.
14 AC_DEFINE([__USE_BSD], 1, [Enable BSD extensions])
16 dnl Checks for programs.
33 AC_DEFINE(HAVE_LINUX, 1, [Linux])
37 AC_DEFINE(HAVE_MINGW, 1, [MinGW])
38 LIBS="$LIBS -lws2_32 -lgdi32 -lcrypt32"
42 AM_CONDITIONAL(LINUX, test "$linux" = true)
43 AM_CONDITIONAL(MINGW, test "$mingw" = true)
47 if test -d /sw/include ; then
48 CPPFLAGS="$CPPFLAGS -I/sw/include"
50 if test -d /sw/lib ; then
51 LIBS="$LIBS -L/sw/lib"
54 dnl Compiler hardening flags
55 dnl No -fstack-protector-all because it doesn't work on all platforms or architectures.
57 AC_ARG_ENABLE([hardening], AS_HELP_STRING([--disable-hardening], [disable compiler and linker hardening flags]))
58 AS_IF([test "x$enable_hardening" != "xno"],
59 [AX_CHECK_COMPILE_FLAG([-DFORTIFY_SOURCE=2], [CPPFLAGS="$CPPFLAGS -DFORITFY_SOURCE=2"])
60 AX_CHECK_COMPILE_FLAG([-fno-strict-overflow], [CPPFLAGS="$CPPFLAGS -fno-strict-overflow"])
61 AX_CHECK_COMPILE_FLAG([-fwrapv], [CPPFLAGS="$CPPFLAGS -fwrapv"])
64 AX_CHECK_LINK_FLAG([-Wl,--dynamicbase], [LDFLAGS="$LDFLAGS -Wl,--dynamicbase"])
65 AX_CHECK_LINK_FLAG([-Wl,--nxcompat], [LDFLAGS="$LDFLAGS -Wl,--nxcompat"])
68 AX_CHECK_COMPILE_FLAG([-fPIE], [CPPFLAGS="$CPPFLAGS -fPIE"])
69 AX_CHECK_COMPILE_FLAG([-fPIC], [CPPFLAGS="$CPPFLAGS -fPIC"])
70 AX_CHECK_LINK_FLAG([-pie], [LDFLAGS="$LDFLAGS -pie"])
73 AX_CHECK_LINK_FLAG([-Wl,-z,relro], [LDFLAGS="$LDFLAGS -Wl,-z,relro"])
74 AX_CHECK_LINK_FLAG([-Wl,-z,now], [LDFLAGS="$LDFLAGS -Wl,-z,now"])
79 AC_ARG_ENABLE([utcp_debug], AS_HELP_STRING([--enable-utcp-debug], [compile utcp with debug output]))
80 AS_IF([test "x$enable_utcp_debug" = "xyes"],
81 [AX_CHECK_COMPILE_FLAG([-DUTCP_DEBUG], [CPPFLAGS="$CPPFLAGS -DUTCP_DEBUG"])
85 dnl Checks for header files.
86 dnl We do this in multiple stages, because unlike Linux all the other operating systems really suck and don't include their own dependencies.
89 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])
90 AC_CHECK_HEADERS([time.h],
91 [], [], [#include "src/have.h"]
94 dnl Checks for typedefs, structures, and compiler characteristics.
102 MeshLink_ATTRIBUTE(__malloc__)
103 MeshLink_ATTRIBUTE(__warn_unused_result__)
105 AC_CHECK_TYPES([socklen_t, struct addrinfo, struct sockaddr_in6], , ,
106 [#include "src/have.h"]
109 AC_CHECK_TYPES([struct sockaddr_storage], ,AC_MSG_ERROR([System must support struct sockaddr_storage.]),
110 [#include "src/have.h"]
113 dnl Checks for library functions.
115 AC_CHECK_FUNCS([asprintf fchmod fork get_current_dir_name gettimeofday random select strdup strerror time usleep],
116 [], [], [#include "src/have.h"]
119 dnl Support for SunOS
121 AC_CHECK_FUNC(socket, [], [
122 AC_CHECK_LIB(socket, connect)
124 AC_CHECK_FUNC(gethostbyname, [], [
125 AC_CHECK_LIB(nsl, gethostbyname)
128 AC_CHECK_DECLS([freeaddrinfo, gai_strerror, getaddrinfo, getnameinfo],
129 [], [], [#include "src/have.h"]
134 dnl These are defined in files in m4/
138 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile m4/Makefile test/Makefile examples/Makefile])