]> git.meshlink.io Git - meshlink/blob - configure.ac
remove libmeshlink files
[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_CPP
19 AC_PROG_INSTALL
20 AC_PROG_LN_S
21 AC_PROG_LIBTOOL
22
23 AM_PROG_CC_C_O
24
25 dnl Check and set OS
26
27 AC_CANONICAL_HOST
28
29 case $host_os in
30   *linux*)
31     linux=true
32     AC_DEFINE(HAVE_LINUX, 1, [Linux])
33   ;;
34   *mingw*)
35     mingw=true
36     AC_DEFINE(HAVE_MINGW, 1, [MinGW])
37     LIBS="$LIBS -lws2_32 -lgdi32 -lcrypt32"
38   ;;
39 esac
40
41 AM_CONDITIONAL(LINUX, test "$linux" = true)
42 AM_CONDITIONAL(MINGW, test "$mingw" = true)
43
44 AC_CACHE_SAVE
45
46 if test -d /sw/include ; then
47   CPPFLAGS="$CPPFLAGS -I/sw/include"
48 fi
49 if test -d /sw/lib ; then
50   LIBS="$LIBS -L/sw/lib"
51 fi
52
53 dnl Compiler hardening flags
54 dnl No -fstack-protector-all because it doesn't work on all platforms or architectures.
55
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"])
61    case $host_os in
62      *mingw*)
63        AX_CHECK_LINK_FLAG([-Wl,--dynamicbase], [LDFLAGS="$LDFLAGS -Wl,--dynamicbase"])
64        AX_CHECK_LINK_FLAG([-Wl,--nxcompat], [LDFLAGS="$LDFLAGS -Wl,--nxcompat"])
65        ;;
66      *)
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"])
70        ;;
71    esac
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"])
74   ]
75 );
76
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.
79
80 AC_HEADER_STDC
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"]
84 )
85
86 dnl Checks for typedefs, structures, and compiler characteristics.
87 AC_C_CONST
88 AC_C_VOLATILE
89 AC_TYPE_PID_T
90 AC_TYPE_SIZE_T
91 AC_HEADER_TIME
92 AC_STRUCT_TM
93
94 MeshLink_ATTRIBUTE(__malloc__)
95 MeshLink_ATTRIBUTE(__warn_unused_result__)
96
97 AC_CHECK_TYPES([socklen_t, struct addrinfo, struct sockaddr_in6], , ,
98   [#include "src/have.h"]
99 )
100
101 dnl Checks for library functions.
102 AC_TYPE_SIGNAL
103 AC_CHECK_FUNCS([asprintf fchmod fork get_current_dir_name gettimeofday random select strdup strerror time usleep],
104   [], [], [#include "src/have.h"]
105 )
106
107 dnl Support for SunOS
108
109 AC_CHECK_FUNC(socket, [], [
110   AC_CHECK_LIB(socket, connect)
111 ])
112 AC_CHECK_FUNC(gethostbyname, [], [
113   AC_CHECK_LIB(nsl, gethostbyname)
114 ])
115
116 AC_CHECK_DECLS([freeaddrinfo, gai_strerror, getaddrinfo, getnameinfo],
117   [], [], [#include "src/have.h"]
118 )
119
120 AC_CACHE_SAVE
121
122 dnl These are defined in files in m4/
123
124 MeshLink_ZLIB
125
126 AC_CONFIG_FILES([Makefile src/Makefile doc/Makefile m4/Makefile test/Makefile examples/Makefile])
127
128 AC_OUTPUT