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"])
78 dnl Checks for header files.
79 dnl We do this in multiple stages, because unlike Linux all the other operating systems really suck and don't include their own dependencies.
82 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])
83 AC_CHECK_HEADERS([time.h],
84 [], [], [#include "src/have.h"]
87 dnl Checks for typedefs, structures, and compiler characteristics.
95 MeshLink_ATTRIBUTE(__malloc__)
96 MeshLink_ATTRIBUTE(__warn_unused_result__)
98 AC_CHECK_TYPES([socklen_t, struct addrinfo, struct sockaddr_in6], , ,
99 [#include "src/have.h"]
102 AC_CHECK_TYPES([struct sockaddr_storage], ,AC_MSG_ERROR([System must support struct sockaddr_storage.]),
103 [#include "src/have.h"]
106 dnl Checks for library functions.
108 AC_CHECK_FUNCS([asprintf fchmod fork get_current_dir_name gettimeofday random select strdup strerror time usleep],
109 [], [], [#include "src/have.h"]
112 dnl Support for SunOS
114 AC_CHECK_FUNC(socket, [], [
115 AC_CHECK_LIB(socket, connect)
117 AC_CHECK_FUNC(gethostbyname, [], [
118 AC_CHECK_LIB(nsl, gethostbyname)
121 AC_CHECK_DECLS([freeaddrinfo, gai_strerror, getaddrinfo, getnameinfo],
122 [], [], [#include "src/have.h"]
127 dnl These are defined in files in m4/
131 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile m4/Makefile test/Makefile examples/Makefile])