]> git.meshlink.io Git - meshlink/blob - configure.ac
Added configure option to set UTCP_DEBUG.
[meshlink] / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2
3 AC_PREREQ(2.61)
4 AC_INIT([MeshLink], [0.1])
5 AC_GNU_SOURCE
6 AM_INIT_AUTOMAKE([check-news std-options subdir-objects -Wall])
7 AC_CONFIG_HEADERS([config.h])
8 AC_CONFIG_MACRO_DIR([m4])
9
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.
13 AC_GNU_SOURCE
14 AC_DEFINE([__USE_BSD], 1, [Enable BSD extensions])
15
16 dnl Checks for programs.
17 AC_PROG_CC_C99
18 AC_PROG_CXX
19 AC_PROG_CPP
20 AC_PROG_INSTALL
21 AC_PROG_LN_S
22 AC_PROG_LIBTOOL
23
24 AM_PROG_CC_C_O
25
26 dnl Check and set OS
27
28 AC_CANONICAL_HOST
29
30 case $host_os in
31   *linux*)
32     linux=true
33     AC_DEFINE(HAVE_LINUX, 1, [Linux])
34   ;;
35   *mingw*)
36     mingw=true
37     AC_DEFINE(HAVE_MINGW, 1, [MinGW])
38     LIBS="$LIBS -lws2_32 -lgdi32 -lcrypt32"
39   ;;
40 esac
41
42 AM_CONDITIONAL(LINUX, test "$linux" = true)
43 AM_CONDITIONAL(MINGW, test "$mingw" = true)
44
45 AC_CACHE_SAVE
46
47 if test -d /sw/include ; then
48   CPPFLAGS="$CPPFLAGS -I/sw/include"
49 fi
50 if test -d /sw/lib ; then
51   LIBS="$LIBS -L/sw/lib"
52 fi
53
54 dnl Compiler hardening flags
55 dnl No -fstack-protector-all because it doesn't work on all platforms or architectures.
56
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"])
62    case $host_os in
63      *mingw*)
64        AX_CHECK_LINK_FLAG([-Wl,--dynamicbase], [LDFLAGS="$LDFLAGS -Wl,--dynamicbase"])
65        AX_CHECK_LINK_FLAG([-Wl,--nxcompat], [LDFLAGS="$LDFLAGS -Wl,--nxcompat"])
66        ;;
67      *)
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"])
71        ;;
72    esac
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"])
75   ]
76 );
77
78 dnl UTCP debug flags
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"])
82   ]
83 );
84
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.
87
88 AC_HEADER_STDC
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"]
92 )
93
94 dnl Checks for typedefs, structures, and compiler characteristics.
95 AC_C_CONST
96 AC_C_VOLATILE
97 AC_TYPE_PID_T
98 AC_TYPE_SIZE_T
99 AC_HEADER_TIME
100 AC_STRUCT_TM
101
102 MeshLink_ATTRIBUTE(__malloc__)
103 MeshLink_ATTRIBUTE(__warn_unused_result__)
104
105 AC_CHECK_TYPES([socklen_t, struct addrinfo, struct sockaddr_in6], , ,
106   [#include "src/have.h"]
107 )
108
109 AC_CHECK_TYPES([struct sockaddr_storage], ,AC_MSG_ERROR([System must support struct sockaddr_storage.]),
110   [#include "src/have.h"]
111 )
112
113 dnl Checks for library functions.
114 AC_TYPE_SIGNAL
115 AC_CHECK_FUNCS([asprintf fchmod fork get_current_dir_name gettimeofday random select strdup strerror time usleep],
116   [], [], [#include "src/have.h"]
117 )
118
119 dnl Support for SunOS
120
121 AC_CHECK_FUNC(socket, [], [
122   AC_CHECK_LIB(socket, connect)
123 ])
124 AC_CHECK_FUNC(gethostbyname, [], [
125   AC_CHECK_LIB(nsl, gethostbyname)
126 ])
127
128 AC_CHECK_DECLS([freeaddrinfo, gai_strerror, getaddrinfo, getnameinfo],
129   [], [], [#include "src/have.h"]
130 )
131
132 AC_CACHE_SAVE
133
134 dnl These are defined in files in m4/
135
136 MeshLink_ZLIB
137
138 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile m4/Makefile test/Makefile examples/Makefile])
139
140 AC_OUTPUT