chiark / gitweb /
Build system: Use -lresolv only if inet_aton is not found otherwise.
[secnet] / configure.in
CommitLineData
2fe58dfd
SE
1dnl Process this file with autoconf to produce a configure script.
2
c215a4bc
IJ
3dnl This file is part of secnet.
4dnl See README for full list of copyright holders.
5dnl
6dnl secnet is free software; you can redistribute it and/or modify it
7dnl under the terms of the GNU General Public License as published by
8dnl the Free Software Foundation; either version d of the License, or
9dnl (at your option) any later version.
10dnl
11dnl secnet is distributed in the hope that it will be useful, but
12dnl WITHOUT ANY WARRANTY; without even the implied warranty of
13dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14dnl General Public License for more details.
15dnl
16dnl You should have received a copy of the GNU General Public License
17dnl version 3 along with secnet; if not, see
18dnl https://www.gnu.org/licenses/gpl.html.
19
fe5e9cc4
SE
20sinclude(ac_prog_cc_no_writeable_strings.m4)
21
00152558 22AC_INIT(secnet,0.1.18+,secnet@chiark.greenend.org.uk)
f74f5f43 23AC_CONFIG_SRCDIR(secnet.c)
2fe58dfd
SE
24AC_CONFIG_HEADER(config.h)
25
f74f5f43 26AC_PREREQ(2.50)
3b83c932 27AC_REVISION($Id: configure.in,v 1.4 2002/09/09 22:05:02 steve Exp $)
2fe58dfd
SE
28
29AC_LANG_C
30
44bdf5ac
RK
31# If fink is on the path then it is assumed we should use it.
32AC_PATH_PROG([FINK],[fink])
33if test "x$FINK" != x; then
34 finkdir=`echo $FINK|sed 's,/[[^/]]*/[[^/]]*$,,'`
35 CPPFLAGS="-I$finkdir/include ${CPPFLAGS}"
36 LDFLAGS="-L$finkdir/lib ${LDFLAGS}"
37fi
38
2fe58dfd
SE
39AC_PROG_MAKE_SET
40AC_PROG_CC
974d0468 41AC_PROG_INSTALL
2fe58dfd
SE
42AC_PATH_PROG(RM,rm)
43AC_STDC_HEADERS
f74f5f43
SE
44AC_CHECK_HEADERS([stdint.h inttypes.h])
45AC_CHECK_HEADERS([net/if.h net/route.h])
46AC_CHECK_HEADERS([sys/socket.h])
94ca562b 47AC_CHECK_HEADERS([linux/if_tun.h], [], [],
f74f5f43
SE
48[#if HAVE_SYS_SOCKET_H
49# include <sys/socket.h>
50#endif
51])
52AC_CHECK_HEADERS([stropts.h sys/sockio.h net/if_tun.h])
2fe58dfd 53AC_C_BIGENDIAN
8dea8d37
SE
54AC_CHECK_SIZEOF(unsigned long long)
55AC_CHECK_SIZEOF(unsigned long)
56AC_CHECK_SIZEOF(unsigned int)
57AC_CHECK_SIZEOF(unsigned short)
58AC_CHECK_SIZEOF(unsigned char)
fe5e9cc4 59AC_PROG_CC_NO_WRITEABLE_STRINGS(WRITESTRINGS)
2fe58dfd 60
e1b81bd6
IJ
61AC_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
f74f5f43
SE
71AC_DEFUN([REQUIRE_HEADER],[AC_CHECK_HEADER($1,,[AC_MSG_ERROR($1 not found)])])
72
469fd1d9
SE
73dnl the order in which libraries is checked is important
74dnl eg. adns on Solaris 2.5.1 depends on -lnsl and -lsocket
59635212 75AC_CHECK_LIB(gmp,mpz_init_set_str)
2fe58dfd 76AC_CHECK_LIB(gmp2,mpz_init_set_str)
469fd1d9 77AC_CHECK_LIB(gmp,__gmpz_init_set_str)
f74f5f43
SE
78REQUIRE_HEADER([gmp.h])
79dnl Would love to barf if no gmp was found, but how to test? Requiring the header will do for now.
2fe58dfd 80AC_CHECK_LIB(fl,yywrap)
f74f5f43
SE
81if test "$ac_cv_lib_fl_yywrap" != yes; then
82 AC_MSG_ERROR([A compatible libfl is required])
83fi
469fd1d9 84AC_CHECK_LIB(nsl,inet_ntoa)
469fd1d9 85AC_CHECK_LIB(socket,socket)
695904f2
IJ
86ADNS_C_GETFUNC(inet_aton,resolv,[
87 LIBS="-lresolv $LIBS";
88 AC_MSG_WARN([inet_aton is in libresolv, urgh. Must use -lresolv.])
89])
469fd1d9 90AC_CHECK_LIB(adns,adns_init)
f74f5f43 91REQUIRE_HEADER([adns.h])
2fe58dfd 92
2b8aa340
IJ
93AC_MSG_NOTICE([Checking requirements for IPv6 support...])
94enable_ipv6=true
95m4_define(NO_IPV6,[enable_ipv6=false])
96AC_CHECK_DECL(AF_INET6, [],[NO_IPV6],[#include <netinet/in.h>])
97AC_CHECK_FUNC(adns_addr2text, [],[NO_IPV6])
98if $enable_ipv6; then
99 AC_MSG_NOTICE([Enabling IPv6 support])
100 AC_DEFINE(CONFIG_IPV6, 1,
101 [Define to 1 to use IPv6 support in system and adns])
102else
103 AC_MSG_WARN([Disabling IPv6 support])
104fi
105
8689b3a9 106AC_OUTPUT(Makefile,echo timestamp >stamp-h)
f74f5f43
SE
107
108AH_TOP([
109#ifndef _CONFIG_H
110#define _CONFIG_H
111])
112
113AH_BOTTOM([
114/* -*- c -*- */
115
116/* These used to be in config.h.bot, but are now in configure.in. */
117
118#ifdef HAVE_INTTYPES_H
119#include <inttypes.h>
120#else
121#ifdef HAVE_STDINT_H
122#include <stdint.h>
123#else
124#if SIZEOF_UNSIGNED_LONG_LONG==8
125typedef unsigned long long uint64_t;
126typedef long long int64_t;
127#elif SIZEOF_UNSIGNED_LONG==8
128typedef unsigned long uint64_t;
129typedef long int64_t;
130#else
131#error I do not know what to use for a uint64_t.
132#endif
133
134/* Give us an unsigned 32-bit data type. */
135#if SIZEOF_UNSIGNED_LONG==4
136typedef unsigned long uint32_t;
137typedef long int32_t;
138#elif SIZEOF_UNSIGNED_INT==4
139typedef unsigned int uint32_t;
140typedef int int32_t;
141#else
142#error I do not know what to use for a uint32_t.
143#endif
144
145/* An unsigned 16-bit data type. */
146#if SIZEOF_UNSIGNED_INT==2
147typedef unsigned int uint16_t;
148typedef int int16_t;
149#elif SIZEOF_UNSIGNED_SHORT==2
150typedef unsigned short uint16_t;
151typedef short int16_t;
152#else
153#error I do not know what to use for a uint16_t.
154#endif
155
156/* An unsigned 8-bit data type */
157#if SIZEOF_UNSIGNED_CHAR==1
158typedef unsigned char uint8_t;
159#else
160#error I do not know what to use for a uint8_t.
161#endif
162#endif
163#endif
164
f74f5f43
SE
165#ifdef __GNUC__
166#define NORETURN(_x) void _x __attribute__ ((noreturn))
167#define FORMAT(_a,_b,_c) __attribute__ ((format (_a,_b,_c)))
168#else
169#define NORETURN(_x) _x
170#define FORMAT(_a,_b,_c)
171#endif
172
173#endif /* _CONFIG_H */
174])