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.
32 AC_DEFINE(HAVE_LINUX, 1, [Linux])
36 AC_DEFINE(HAVE_MINGW, 1, [MinGW])
37 LIBS="$LIBS -lws2_32 -lgdi32 -lcrypt32"
41 AM_CONDITIONAL(LINUX, test "$linux" = true)
42 AM_CONDITIONAL(MINGW, test "$mingw" = true)
46 if test -d /sw/include ; then
47 CPPFLAGS="$CPPFLAGS -I/sw/include"
49 if test -d /sw/lib ; then
50 LIBS="$LIBS -L/sw/lib"
53 dnl Compiler hardening flags
54 dnl No -fstack-protector-all because it doesn't work on all platforms or architectures.
56 AC_ARG_ENABLE([hardening], AS_HELP_STRING([--disable-hardening], [disable compiler and linker hardening flags]))
57 AS_IF([test "x$enable_hardening" != "xno"],
58 [AX_CHECK_COMPILE_FLAG([-DFORTIFY_SOURCE=2], [CPPFLAGS="$CPPFLAGS -DFORITFY_SOURCE=2"])
59 AX_CHECK_COMPILE_FLAG([-fno-strict-overflow], [CPPFLAGS="$CPPFLAGS -fno-strict-overflow"])
60 AX_CHECK_COMPILE_FLAG([-fwrapv], [CPPFLAGS="$CPPFLAGS -fwrapv"])
63 AX_CHECK_LINK_FLAG([-Wl,--dynamicbase], [LDFLAGS="$LDFLAGS -Wl,--dynamicbase"])
64 AX_CHECK_LINK_FLAG([-Wl,--nxcompat], [LDFLAGS="$LDFLAGS -Wl,--nxcompat"])
67 AX_CHECK_COMPILE_FLAG([-fPIE], [CPPFLAGS="$CPPFLAGS -fPIE"])
68 AX_CHECK_COMPILE_FLAG([-fPIC], [CPPFLAGS="$CPPFLAGS -fPIC"])
69 AX_CHECK_LINK_FLAG([-pie], [LDFLAGS="$LDFLAGS -pie"])
72 AX_CHECK_LINK_FLAG([-Wl,-z,relro], [LDFLAGS="$LDFLAGS -Wl,-z,relro"])
73 AX_CHECK_LINK_FLAG([-Wl,-z,now], [LDFLAGS="$LDFLAGS -Wl,-z,now"])
77 dnl Checks for header files.
78 dnl We do this in multiple stages, because unlike Linux all the other operating systems really suck and don't include their own dependencies.
81 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])
82 AC_CHECK_HEADERS([time.h],
83 [], [], [#include "src/have.h"]
86 dnl Checks for typedefs, structures, and compiler characteristics.
94 MeshLink_ATTRIBUTE(__malloc__)
95 MeshLink_ATTRIBUTE(__warn_unused_result__)
97 AC_CHECK_TYPES([socklen_t, struct addrinfo, struct sockaddr_in6], , ,
98 [#include "src/have.h"]
101 dnl Checks for library functions.
103 AC_CHECK_FUNCS([asprintf fchmod fork get_current_dir_name gettimeofday random select strdup strerror time usleep],
104 [], [], [#include "src/have.h"]
107 dnl Support for SunOS
109 AC_CHECK_FUNC(socket, [], [
110 AC_CHECK_LIB(socket, connect)
112 AC_CHECK_FUNC(gethostbyname, [], [
113 AC_CHECK_LIB(nsl, gethostbyname)
116 AC_CHECK_DECLS([freeaddrinfo, gai_strerror, getaddrinfo, getnameinfo],
117 [], [], [#include "src/have.h"]
122 dnl These are defined in files in m4/
126 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile m4/Makefile test/Makefile examples/Makefile])