chiark / gitweb /
65997eff1698449b3c180feca72d79b2722b7162
[secnet.git] / configure.in
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 AC_INIT(secnet,0.1.18+,secnet@chiark.greenend.org.uk)
23 AC_CONFIG_SRCDIR(secnet.c)
24 AC_CONFIG_HEADER(config.h)
25
26 AC_PREREQ(2.50)
27 AC_REVISION($Id: configure.in,v 1.4 2002/09/09 22:05:02 steve Exp $)
28
29 AC_LANG_C
30
31 # If fink is on the path then it is assumed we should use it.
32 AC_PATH_PROG([FINK],[fink])
33 if test "x$FINK" != x; then
34   finkdir=`echo $FINK|sed 's,/[[^/]]*/[[^/]]*$,,'`
35   CPPFLAGS="-I$finkdir/include ${CPPFLAGS}"
36   LDFLAGS="-L$finkdir/lib ${LDFLAGS}"
37 fi
38
39 AC_PROG_MAKE_SET
40 AC_PROG_CC
41 AC_PROG_INSTALL
42 AC_PATH_PROG(RM,rm)
43 AC_STDC_HEADERS
44 AC_CHECK_HEADERS([stdint.h inttypes.h])
45 AC_CHECK_HEADERS([net/if.h net/route.h])
46 AC_CHECK_HEADERS([sys/socket.h])
47 AC_CHECK_HEADERS([linux/if_tun.h], [], [], 
48 [#if HAVE_SYS_SOCKET_H
49 # include <sys/socket.h>
50 #endif
51 ])
52 AC_CHECK_HEADERS([stropts.h sys/sockio.h net/if_tun.h])
53 AC_C_BIGENDIAN
54 AC_CHECK_SIZEOF(unsigned long long)
55 AC_CHECK_SIZEOF(unsigned long)
56 AC_CHECK_SIZEOF(unsigned int)
57 AC_CHECK_SIZEOF(unsigned short)
58 AC_CHECK_SIZEOF(unsigned char)
59 AC_PROG_CC_NO_WRITEABLE_STRINGS(WRITESTRINGS)
60
61 AC_ARG_ENABLE(hacky-parallel,
62   [AS_HELP_STRING([--enable-hacky-parallel],
63                   [parallelise slow cryptography (default is no)])], [
64   case "$enableval" in
65   n|0|no) ;;
66   y|1|yes) CFLAGS="$CFLAGS -DHACKY_PARALLEL" ;;
67   *) ;;
68   esac
69 ])
70
71 AC_DEFUN([REQUIRE_HEADER],[AC_CHECK_HEADER($1,,[AC_MSG_ERROR($1 not found)])])
72
73 dnl the order in which libraries is checked is important
74 dnl eg. adns on Solaris 2.5.1 depends on -lnsl and -lsocket
75 AC_CHECK_LIB(gmp,mpz_init_set_str)
76 AC_CHECK_LIB(gmp2,mpz_init_set_str)
77 AC_CHECK_LIB(gmp,__gmpz_init_set_str)
78 REQUIRE_HEADER([gmp.h])
79 dnl Would love to barf if no gmp was found, but how to test? Requiring the header will do for now.
80 SECNET_C_GETFUNC(inet_ntoa,nsl)
81 AC_CHECK_LIB(socket,socket)
82 SECNET_C_GETFUNC(inet_aton,resolv)
83 AC_CHECK_LIB(adns,adns_init)
84 REQUIRE_HEADER([adns.h])
85
86 AC_MSG_NOTICE([Checking requirements for IPv6 support...])
87 enable_ipv6=true
88 m4_define(NO_IPV6,[enable_ipv6=false])
89 AC_CHECK_DECL(AF_INET6,        [],[NO_IPV6],[#include <netinet/in.h>])
90 AC_CHECK_FUNC(adns_addr2text,  [],[NO_IPV6])
91 if $enable_ipv6; then
92     AC_MSG_NOTICE([Enabling IPv6 support])
93     AC_DEFINE(CONFIG_IPV6, 1,
94               [Define to 1 to use IPv6 support in system and adns])
95 else
96     AC_MSG_WARN([Disabling IPv6 support])
97 fi
98
99 AC_OUTPUT(Makefile common.make test-example/Makefile stest/Makefile,
100           echo timestamp >config.stamp)
101
102 AH_TOP([
103 #ifndef _CONFIG_H
104 #define _CONFIG_H
105 ])
106
107 AH_BOTTOM([
108 /* -*- c -*- */
109
110 /* These used to be in config.h.bot, but are now in configure.in. */
111
112 #ifdef HAVE_INTTYPES_H
113 #include <inttypes.h>
114 #else
115 #ifdef HAVE_STDINT_H
116 #include <stdint.h>
117 #else
118 #if SIZEOF_UNSIGNED_LONG_LONG==8
119 typedef unsigned long long uint64_t;
120 typedef long long int64_t;
121 #elif SIZEOF_UNSIGNED_LONG==8
122 typedef unsigned long uint64_t;
123 typedef long int64_t;
124 #else
125 #error I do not know what to use for a uint64_t.
126 #endif
127
128 /* Give us an unsigned 32-bit data type. */
129 #if SIZEOF_UNSIGNED_LONG==4
130 typedef unsigned long uint32_t;
131 typedef long int32_t;
132 #elif SIZEOF_UNSIGNED_INT==4
133 typedef unsigned int uint32_t;
134 typedef int int32_t;
135 #else
136 #error I do not know what to use for a uint32_t.
137 #endif
138
139 /* An unsigned 16-bit data type. */
140 #if SIZEOF_UNSIGNED_INT==2
141 typedef unsigned int uint16_t;
142 typedef int int16_t;
143 #elif SIZEOF_UNSIGNED_SHORT==2
144 typedef unsigned short uint16_t;
145 typedef short int16_t;
146 #else
147 #error I do not know what to use for a uint16_t.
148 #endif
149
150 /* An unsigned 8-bit data type */
151 #if SIZEOF_UNSIGNED_CHAR==1
152 typedef unsigned char uint8_t;
153 #else
154 #error I do not know what to use for a uint8_t.
155 #endif
156 #endif
157 #endif
158
159 #ifdef __GNUC__
160 #define NORETURN(_x) void _x __attribute__ ((noreturn))
161 #define FORMAT(_a,_b,_c) __attribute__ ((format (_a,_b,_c)))
162 #else
163 #define NORETURN(_x) _x
164 #define FORMAT(_a,_b,_c)
165 #endif
166
167 #endif /* _CONFIG_H */
168 ])