]> git.meshlink.io Git - meshlink/blob - configure.ac
Add an example chat program for the C++ API.
[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 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.
80
81 AC_HEADER_STDC
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"]
85 )
86
87 dnl Checks for typedefs, structures, and compiler characteristics.
88 AC_C_CONST
89 AC_C_VOLATILE
90 AC_TYPE_PID_T
91 AC_TYPE_SIZE_T
92 AC_HEADER_TIME
93 AC_STRUCT_TM
94
95 MeshLink_ATTRIBUTE(__malloc__)
96 MeshLink_ATTRIBUTE(__warn_unused_result__)
97
98 AC_CHECK_TYPES([socklen_t, struct addrinfo, struct sockaddr_in6], , ,
99   [#include "src/have.h"]
100 )
101
102 dnl Checks for library functions.
103 AC_TYPE_SIGNAL
104 AC_CHECK_FUNCS([asprintf fchmod fork get_current_dir_name gettimeofday random select strdup strerror time usleep],
105   [], [], [#include "src/have.h"]
106 )
107
108 dnl Support for SunOS
109
110 AC_CHECK_FUNC(socket, [], [
111   AC_CHECK_LIB(socket, connect)
112 ])
113 AC_CHECK_FUNC(gethostbyname, [], [
114   AC_CHECK_LIB(nsl, gethostbyname)
115 ])
116
117 AC_CHECK_DECLS([freeaddrinfo, gai_strerror, getaddrinfo, getnameinfo],
118   [], [], [#include "src/have.h"]
119 )
120
121 AC_CACHE_SAVE
122
123 dnl These are defined in files in m4/
124
125 MeshLink_ZLIB
126
127 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile m4/Makefile test/Makefile examples/Makefile])
128
129 AC_OUTPUT