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