chiark / gitweb /
make-secnet-sites: Fix error handling if caller is in wrong group
[secnet.git] / configure.ac
1 dnl Process this file with autoconf to produce a configure script.
2
3 dnl This file is part of secnet.
4 dnl See README for full list of copyright holders.
5 dnl
6 dnl secnet is free software; you can redistribute it and/or modify it
7 dnl under the terms of the GNU General Public License as published by
8 dnl the Free Software Foundation; either version 3 of the License, or
9 dnl (at your option) any later version.
10 dnl 
11 dnl secnet is distributed in the hope that it will be useful, but
12 dnl WITHOUT ANY WARRANTY; without even the implied warranty of
13 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 dnl General Public License for more details.
15 dnl 
16 dnl You should have received a copy of the GNU General Public License
17 dnl version 3 along with secnet; if not, see
18 dnl https://www.gnu.org/licenses/gpl.html.
19
20 sinclude(ac_prog_cc_no_writeable_strings.m4)
21
22 m4_include(subdirmk/subdirmk.ac)
23
24 AC_INIT(secnet,0.1.18+,secnet@chiark.greenend.org.uk)
25 AC_CONFIG_SRCDIR(secnet.c)
26 AC_CONFIG_HEADER(config.h)
27
28 SUBDIRMK_SUBDIRS([test-example mtest stest base91s])
29
30 AC_PREREQ(2.50)
31 AC_REVISION($Id: configure.in,v 1.4 2002/09/09 22:05:02 steve Exp $)
32
33 AC_LANG_C
34
35 # If fink is on the path then it is assumed we should use it.
36 AC_PATH_PROG([FINK],[fink])
37 if test "x$FINK" != x; then
38   finkdir=`echo $FINK|sed 's,/[[^/]]*/[[^/]]*$,,'`
39   CPPFLAGS="-I$finkdir/include ${CPPFLAGS}"
40   LDFLAGS="-L$finkdir/lib ${LDFLAGS}"
41 fi
42
43 # This is quite unpleasant.  It turns out that most header checking
44 # macros call AC_INCLUDES_DEFAULT.  By default AC_INCLUDES_DEFAULT
45 # implies AC_HEADER_STDC and a bunch of conditional includes.  But
46 # these header checks are obsolete as the documentation for
47 # AC_HEADER_STDC says.  Instead, define AC_INCLUDES_DEFAULT ourselves.
48 # The list of headers below is the list from `(autoconf) Default
49 # Includes' (filtered by hand for the modern ones rather than the
50 # fallbacks).  We must include $1 because AC_INCLUDES_DEFAULT is
51 # called with an argument giving the check-specific haders.
52 m4_define([AC_INCLUDES_DEFAULT],[
53           # include <sys/types.h>
54           # include <sys/stat.h>
55           # include <stdlib.h>
56           # include <stddef.h>
57           # include <string.h>
58           # include <inttypes.h>
59           # include <stdint.h>
60           # include <unistd.h>
61 $1
62 ])
63
64 AC_PROG_MAKE_SET
65 AC_PROG_CC
66 AC_PROG_INSTALL
67 AC_CHECK_HEADERS([net/if.h net/route.h])
68 AC_CHECK_HEADERS([sys/socket.h])
69 AC_CHECK_HEADERS([linux/if_tun.h], [], [], 
70 [#if HAVE_SYS_SOCKET_H
71 # include <sys/socket.h>
72 #endif
73 ])
74 AC_CHECK_HEADERS([stropts.h sys/sockio.h net/if_tun.h])
75 AC_C_BIGENDIAN
76 AC_PROG_CC_NO_WRITEABLE_STRINGS(WRITESTRINGS)
77
78 AC_ARG_ENABLE(hacky-parallel,
79   [AS_HELP_STRING([--enable-hacky-parallel],
80                   [parallelise slow cryptography (default is no)])], [
81   case "$enableval" in
82   n|0|no) ;;
83   y|1|yes) CFLAGS="$CFLAGS -DHACKY_PARALLEL" ;;
84   *) ;;
85   esac
86 ])
87
88 AC_DEFUN([REQUIRE_HEADER],[AC_CHECK_HEADER($1,,[AC_MSG_ERROR($1 not found)])])
89
90 dnl the order in which libraries is checked is important
91 dnl eg. adns on Solaris 2.5.1 depends on -lnsl and -lsocket
92 AC_CHECK_LIB(gmp,mpz_init_set_str)
93 AC_CHECK_LIB(gmp2,mpz_init_set_str)
94 AC_CHECK_LIB(gmp,__gmpz_init_set_str)
95 REQUIRE_HEADER([gmp.h])
96 dnl Would love to barf if no gmp was found, but how to test? Requiring the header will do for now.
97 SECNET_C_GETFUNC(inet_ntoa,nsl)
98 AC_CHECK_LIB(socket,socket)
99 SECNET_C_GETFUNC(inet_aton,resolv)
100 AC_CHECK_LIB(adns,adns_init)
101 REQUIRE_HEADER([adns.h])
102
103 AC_CHECK_FUNCS([fmemopen funopen])
104
105 dnl gcc 4.9.2 (jessie) requires -std=gnu11 to cope with for (int i=...
106 dnl but we do not want to pass that everywhere because we don't want
107 dnl to nail down the C dialect this way.  Why oh why oh why.
108 m4_define([for_gcc_std],[
109 void x(void) { for (int i=0; i<1; i++) { } }
110 ])
111 AC_CACHE_CHECK([required gcc -std flag],[secnet_cv_gcc_std_flag],[
112     secnet_cv_gcc_std_flag=""
113     AC_COMPILE_IFELSE([AC_LANG_SOURCE(for_gcc_std)],[],[
114         old_cflags="$CFLAGS"
115         CFLAGS="$CFLAGS -std=gnu11"
116         AC_COMPILE_IFELSE([AC_LANG_SOURCE(for_gcc_std)],[
117             secnet_cv_gcc_std_flag=" -std=gnu11"
118         ],[
119             AC_MSG_RESULT([failure!])
120             AC_MSG_ERROR([cannot get test program to compile],1)
121         ])
122         CFLAGS="$old_cflags"
123     ])
124 ])
125 CFLAGS="$CFLAGS$secnet_cv_gcc_std_flag"
126
127 AC_MSG_NOTICE([Checking requirements for IPv6 support...])
128 enable_ipv6=true
129 m4_define(NO_IPV6,[enable_ipv6=false])
130 AC_CHECK_DECL(AF_INET6,        [],[NO_IPV6],[#include <netinet/in.h>])
131 AC_CHECK_FUNC(adns_addr2text,  [],[NO_IPV6])
132 if $enable_ipv6; then
133     AC_MSG_NOTICE([Enabling IPv6 support])
134     AC_DEFINE(CONFIG_IPV6, 1,
135               [Define to 1 to use IPv6 support in system and adns])
136 else
137     AC_MSG_WARN([Disabling IPv6 support])
138 fi
139
140 SUBDIRMK_MAKEFILES(common.make)
141
142 AC_OUTPUT(,
143           echo timestamp >config.stamp)
144
145 AH_TOP([
146 #ifndef _CONFIG_H
147 #define _CONFIG_H
148 ])
149
150 AH_BOTTOM([
151 /* -*- c -*- */
152
153 /* These used to be in config.h.bot, but are now in configure.in. */
154
155 #ifdef __GNUC__
156 #define NORETURN(_x) void _x __attribute__ ((noreturn))
157 #define FORMAT(_a,_b,_c) __attribute__ ((format (_a,_b,_c)))
158 #else
159 #define NORETURN(_x) _x
160 #define FORMAT(_a,_b,_c)
161 #endif
162
163 #endif /* _CONFIG_H */
164 ])