configure.in 7.61 KB
Newer Older
1
dnl -*-shell-script-*-
2
dnl $Id$
3

Niels Möller's avatar
Niels Möller committed
4
5
dnl Process this file with autoconf to produce a configure script.
AC_INIT(keyexchange.h)
Niels Möller's avatar
Niels Möller committed
6

Niels Möller's avatar
Niels Möller committed
7
8
dnl No real versioning yet, use dated snapshots instead.
dnl AM_INIT_AUTOMAKE(lsh, snapshot-`date +%Y-%m-%d`)
Niels Möller's avatar
Niels Möller committed
9
AM_INIT_AUTOMAKE(lsh, snapshot-esyscmd([date +%Y-%m-%d]))
Niels Möller's avatar
Niels Möller committed
10

Niels Möller's avatar
Niels Möller committed
11
AM_CONFIG_HEADER(config.h)
Niels Möller's avatar
Niels Möller committed
12

13
14
15
16
17
18
19
20
21
22
23
24
# We want an absolute path to the source-dir.
case "$srcdir" in
    /*)
    ;;
    *)
	oldsrcdir="$srcdir"
	srcdir="`cd \"$srcdir\";pwd`"
	AC_MSG_WARN([ Converted $oldsrcdir to $srcdir,
If this does not work, please use an absolute path to the configure script. ])
    ;;
esac

Niels Möller's avatar
Niels Möller committed
25
# We want to compile the crypto lib for use with lsh
26
CPPFLAGS="$CPPFLAGS -I$srcdir/include -I$srcdir -DLSH"
Niels Möller's avatar
Niels Möller committed
27

28
29
30
31
# GNU libc defaults to supplying the ISO C library functions only. 
# initgroups() and strsignal() are extensions; the _GNU_SOURCE define
# enables these extensions.
# Enable it on all systems; no problems have been reported with it so far.
Niels Möller's avatar
Niels Möller committed
32
33
34

CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"

35
36
dnl Check options
AC_ARG_WITH(debug_alloc,
37
38
  [--with-debug-alloc    sanity check memory allocation and casts],,
  [with_debug_alloc=yes])
39

40
41
42
43
44
if test x$with_debug_alloc = xyes ; then
  AC_DEFINE(DEBUG_ALLOC)
fi

AC_ARG_WITH(zlib,
45
46
  [--with-zlib    use zlib compression],,
  [with_zlib=yes])
47
48
49
50

dnl Checking this variable is delayed until we have checked if zlib is
dnl actually available.

51
52
53
54
55
56
AC_ARG_WITH(sshd1,
  [--with-sshd1[=PROGRAM]    support fallback to SSH1 daemon (broken)])

dnl Checking this variable is delayed until we have checked if an SSH1
dnl server is actually available.

57
AC_ARG_WITH(idea,
58
59
  [--with-idea    support the patent-encumbered IDEA algorithm],,
  [with_idea=no])
60
61
62
63

if test x$with_idea = xyes ; then
  AC_DEFINE(WITH_IDEA)
fi
64

Niels Möller's avatar
Niels Möller committed
65
66
67
dnl Checks for programs.
AC_PROG_CC
AC_PROG_MAKE_SET
Niels Möller's avatar
Niels Möller committed
68
AC_PROG_RANLIB
69
70
71
72
73
AM_PROG_CC_STDC

if test x$am_cv_prog_cc_stdc = xno ; then
  AC_ERROR([the C compiler doesn't handle ANSI-C])
fi
Niels Möller's avatar
Niels Möller committed
74
75

dnl Checks for libraries.
76
AC_CHECK_LIB(gmp, mpz_set_d,,
77
dnl Some debian systems have both gmp1 and gmp2.
78
    [AC_CHECK_LIB(gmp2, mpz_set_d,,
79
80
	AC_ERROR([GMP is missing (ftp://ftp.gnu.org/pub/gnu/gmp-2.0.2.tar.gz)]))])

81
AC_CHECK_LIB(z, inflate,, [with_zlib=no])
82
83
AC_CHECK_LIB(crypt, crypt)
AC_CHECK_LIB(xnet, inet_addr)
84
AC_CHECK_LIB(nsl, gethostbyname)
85
AC_CHECK_LIB(socket, setsockopt)
Niels Möller's avatar
Niels Möller committed
86
87
88

dnl Checks for header files.
AC_HEADER_STDC
89

90
dnl Some debian systems have both gmp and gmp2.
91
dnl This will probably not work right if both gmp.h and gmp2/gmp.h exists,
92
dnl and gmp.h is too old (i.e GMP-1.x).
93
94
95
96
97
gmp_header_found=no
AC_CHECK_HEADERS(gmp.h gmp2/gmp.h, [gmp_header_found=yes; break])
if test "$gmp_header_found" = no; then
  AC_ERROR([Neither gmp.h nor gmp2/gmp.h found])
fi
98
  
99
AC_CHECK_HEADERS(fcntl.h strings.h sys/time.h unistd.h)
100
AC_CHECK_HEADERS(shadow.h)
101
AC_CHECK_HEADERS(zlib.h,, [with_zlib=no])
102
103
104
105
106
107

dnl Should we use zlib?

if test x$with_zlib = xyes ; then
  AC_DEFINE(WITH_ZLIB)
fi
Niels Möller's avatar
Niels Möller committed
108

109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
dnl Find the SSH1 daemon; try 'sshd1' first; if it fails, look for 'sshd'
if test x$with_sshd1 = xyes ; then
  AC_DEFINE(SSH1_FALLBACK)
  dnl We have to provide an additional path: regular users seldomly have
  dnl the sbin directories in their $PATH.
  AC_PATH_PROG(SSHD1BIN, sshd1, [],
    $PATH:/usr/local/sbin:/usr/local/etc:/usr/sbin:/usr/etc:/sbin:/etc)
  if test x$SSHD1BIN = x ; then
    AC_PATH_PROG(SSHD1BIN, sshd, [],
      $PATH:/usr/local/sbin:/usr/local/etc:/usr/sbin:/usr/etc:/sbin:/etc)
  fi
  if test x$SSHD1BIN = x ; then
    AC_MSG_ERROR([
You requested SSH1 fallback support (--with-sshd1), but no sshd1 could be found.
You can
- supply the location of sshd1, i.e. --with-sshd1=/home/foo/sbin/sshd ,
- install sshd1 (ftp://ftp.cs.hut.fi/pub/ssh/); note that it is not free
  software, or
- configure --without-sshd1 .
])
  fi

  dnl OK. We've found an SSH1 daemon. Now we need to make sure it is
  dnl recent enough to be used as a fallback daemon. This means it has to
  dnl support the -V option, which tells it not to read the client version 
  dnl string as lshd has already done that, and which supplies that version
  dnl string.
  AC_MSG_CHECKING(if $SSHD1BIN has the -V compatibility flag)
changequote(<<, >>)dnl
  if ($SSHD1BIN -h 2>&1 ; true) | grep '^[ \t]*-V' > /dev/null ; then
changequote([, ])dnl
    AC_MSG_RESULT(yes)
  else
    AC_MSG_ERROR([
Found SSH1 daemon ]$SSHD1BIN[, but it does not support the -V option.
This means we cannot use it as a fallback daemon. Please install a more recent 
SSH1 daemon (ftp://ftp.cs.hut.fi/pub/ssh/), or configure --without-sshd1 .])
  fi
  AC_DEFINE_UNQUOTED(SSHD1,"$SSHD1BIN")
fi

Niels Möller's avatar
Niels Möller committed
150
dnl Checks for typedefs, structures, and compiler characteristics.
151
152
AC_C_CONST
AC_TYPE_UID_T
Niels Möller's avatar
Niels Möller committed
153
AC_TYPE_SIZE_T
154
155
AC_HEADER_TIME

Niels Möller's avatar
Niels Möller committed
156
157
158
AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(long, 4)
Niels Möller's avatar
Niels Möller committed
159
160
dnl FIXME: We should check that a pid_t fits in an int
	
Niels Möller's avatar
Niels Möller committed
161
dnl Checks for library functions.
162
163
164
165
AC_FUNC_ALLOCA
AC_FUNC_MEMCMP
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(select socket strerror strtol)
166
AC_CHECK_FUNCS(getspnam)
167
AC_CHECK_FUNCS(vsnprintf)
Niels Möller's avatar
Niels Möller committed
168

169
AC_CHECK_FUNCS(poll,,[LIBOBJS = jpoll.c $LIBOBJS])
Niels Möller's avatar
Niels Möller committed
170

171
172
173
174
175
176
dnl This macro is mentioned in the automake manual, but where is it
dnl supposed to be defined?
dnl AC_REPLACE_GNU_GETOPT

AC_CHECK_FUNCS(getopt_long,,[LIBOBJS = getopt.c getopt1.c $LIBOBJS])

177
dnl Check for broken shutdown
178
179
AC_CACHE_CHECK(for working shutdown on AF_UNIX sockets,
	       lsh_cv_func_shutdown_works_on_unix_sockets,
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
[
AC_TRY_RUN([
#include <stdio.h>

#include <errno.h>

#include <sys/types.h>
#include <sys/socket.h>

#include <signal.h>

#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

/* Creates a one-way socket connection. Returns 1 on success, 0 on
 * failure. fds[0] is for reading, fds[1] for writing (like for the
 * pipe() system call). */
static int make_pipe(int *fds)
{

#ifndef SHUT_RD
#define SHUT_RD 0
#define SHUT_WR 1
#define SHUT_RDWR 2
#endif

  if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds) < 0)
    {
      fprintf(stderr, "socketpair() failed: %s\n", strerror(errno));
      return 0;
    }
  fprintf(stderr, "Created socket pair. Using fd:s %d <-- %d\n", fds[0], fds[1]);

  if(shutdown(fds[0], SHUT_WR) < 0)
    {
216
217
      fprintf(stderr, "shutdown(%d, SHUT_WR) failed: %s\n",
	      fds[0], strerror(errno));
218
219
220
221
      return 0;
    }
  if (shutdown(fds[1], SHUT_RD) < 0)
    {
222
223
      fprintf(stderr, "shutdown(%d, SHUT_RD) failed: %s\n",
	      fds[1], strerror(errno));
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
      return 0;
    }

  return 1;
}

int main(int argc, char **argv)
{
  int fds[2];
  
  if (!make_pipe(fds))
    exit(1);

  if (signal(SIGPIPE, SIG_IGN) == SIG_ERR)
    {
239
      fprintf(stderr, "signal failed.\n");
240
241
242
243
244
245
246
247
248
      exit(1);
    }

  if ( (write(fds[1], "foo", 3) < 0)
       && (errno == EPIPE))
    exit(1);

  exit(0);
}
249
250
251
], lsh_cv_func_shutdown_works_on_unix_sockets=yes,
   lsh_cv_func_shutdown_works_on_unix_sockets=no,
   lsh_cv_func_shutdown_works_on_unix_sockets=yes)])
252

253
if test x$lsh_cv_func_shutdown_works_on_unix_sockets = xyes ; then
254
255
256
    AC_DEFINE(SHUTDOWN_WORKS_WITH_UNIX_SOCKETS)
fi

257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
dnl Check for gcc's __attribute__ construction
AC_CACHE_CHECK(for __attribute__,
	       lsh_cv_c_attribute,
[ AC_TRY_COMPILE([
#include <stdlib.h>
],
[
static void foo(void) __attribute__ ((noreturn));

static void __attribute__ ((noreturn))
foo(void)
{
  exit(1);
}
],
lsh_cv_c_attribute=yes,
lsh_cv_c_attribute=no)])

if test "$lsh_cv_c_attribute" = "yes"; then
  AC_DEFINE(HAVE_ATTRIBUTE)
fi

279
280
# Set these flags *last*, or else the test programs won't compile
if test x$GCC = xyes ; then
281
    CFLAGS="$CFLAGS -Wall -W \
Niels Möller's avatar
Niels Möller committed
282
283
284
 -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes \
 -Waggregate-return \
 -Wpointer-arith -Wbad-function-cast -Wnested-externs"
285

286
287
# Don't enable -Wcast-align as it results in tons of warnings in the
# DES code. And when using stdio.
288

289
fi
Niels Möller's avatar
Niels Möller committed
290

Niels Möller's avatar
Niels Möller committed
291
AC_OUTPUT(Makefile lib/Makefile include/Makefile doc/Makefile)