configure.in 19.6 KB
Newer Older
1
dnl -*- mode: shell-script; sh-indentation: 2; -*-
2
dnl $Id$
3

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

7
AM_INIT_AUTOMAKE(lsh, 1.1.0)
Niels Möller's avatar
Niels Möller committed
8

Niels Möller's avatar
Niels Möller committed
9
AM_CONFIG_HEADER(config.h)
Niels Möller's avatar
Niels Möller committed
10

11
12
13
AC_DEFINE_UNQUOTED(PREFIX, "$prefix")


Niels Möller's avatar
Niels Möller committed
14
15
16
17
dnl This macro turns of a the Makefile.in: Makefile.am dependencies, unless
dnl --enable-maintainer-mode is passed to ./configure. But I want
dnl maintainermode to be *on* by default.
dnl AM_MAINTAINER_MODE
18

19
20
21
22
23
24
25
26
27
28
29
30
# 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
31
# We want to compile the crypto lib for use with lsh
Niels Möller's avatar
Niels Möller committed
32
CPPFLAGS="$CPPFLAGS -I$srcdir -I$srcdir/src -I$srcdir/src/symmetric/include -DLSH"
Niels Möller's avatar
Niels Möller committed
33

34
35
36
37
# 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
38
39
40

CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"

41

42
dnl Check options
43
44
45
46
47
AC_ARG_ENABLE(debug_alloc,
  [--disable-debug-alloc    Disable memory allocation sanity checks],,
  [enable_debug_alloc=yes])
  
if test x$enable_debug_alloc = xyes ; then
48
49
50
  AC_DEFINE(DEBUG_ALLOC)
fi

51
52
53
AC_ARG_ENABLE(debug_trace,
  [--disable-debug-trace    Disable tracing support],,
  [enable_debug_trace=yes])
54

55
if test x$enable_debug_trace = xyes ; then
56
57
58
  AC_DEFINE(DEBUG_TRACE)
fi

59
AC_ARG_WITH(zlib,
60
  [--without-zlib    Don't use zlib compression],,
61
  [with_zlib=yes])
62
63
64
65

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

66
67
68
AC_ARG_ENABLE(pty,
  [--without-pty   Disable pty support],,
  [enable_pty=yes])
69

70
if test x$enable_pty = xyes ; then
71
72
73
  AC_DEFINE(WITH_PTY_SUPPORT)
fi

74
AC_ARG_WITH(sshd1,
75
  [--with-sshd1[=PROGRAM]    support fallback to SSH1 daemon],,
76
  [with_sshd1=yes])
77

78
79
80
81
82
83
84
85
86
# Default sshd1 path
if test x$with_sshd1 = xyes ; then
  with_sshd1=/usr/local/sbin/sshd1
fi

if test x$with_sshd1 != xno ; then
  AC_DEFINE(WITH_SSH1_FALLBACK)
  AC_DEFINE_UNQUOTED(SSHD1,"$with_sshd1")
fi
87

88
89
90
AC_ARG_ENABLE(idea,
  [--enable-idea    Support the patent-encumbered IDEA algorithm],,
  [enable_idea=no])
91

92
if test x$enable_idea = xyes ; then
93
94
  AC_DEFINE(WITH_IDEA)
fi
95

96
97
98
99
AC_ARG_ENABLE(srp,
  [--disable-srp    Disable the (experimental) support for SRP],,
  [enable_srp=yes])

100
101
102
103
AC_ARG_ENABLE(kerberos,
  [--disable-kerberos Don't support kerberos],,
  [enable_kerberos=yes])
  
104
105
106
107
if test x$enable_srp = xyes ; then
  AC_DEFINE(WITH_SRP)
fi

108
109
110
AC_ARG_ENABLE(datafellows_workarounds,
  [--disable-datafellows-workarounds    Disable bug-compatibility with SSH Inc's clients and servers],,
  [enable_datafellows_workarounds=yes])
111

112
if test x$enable_datafellows_workarounds = xyes ; then
113
  AC_DEFINE(DATAFELLOWS_WORKAROUNDS)
114
115
fi

116
117
118
AC_ARG_ENABLE(tcp_forward,
  [--disable-tcp-forward        Disable tcp forwarding],,
  [enable_tcp_forward=yes])
119

120
if test x$enable_tcp_forward = xyes ; then
121
122
  AC_DEFINE(WITH_TCP_FORWARD)
fi
123

124
125
126
AC_ARG_ENABLE(x11_forward,
  [--disable-x11-forward        Disable x11 forwarding (proxy only)],,
  [eanble_x11_forward=yes])
127

128
if test x$enable_x11_forward = xyes ; then
129
130
131
  AC_DEFINE(WITH_X11_FORWARD)
fi

132
133
AC_ARG_ENABLE(agent_forward,
  [--disable-agent-forward      Disable auth-agent forwarding (proxy only)],,
134
135
  [with_agent_forward=yes])

136
if test x$disable_agent_forward = xyes ; then
137
138
139
  AC_DEFINE(WITH_AGENT_FORWARD)
fi

140
141
142
AC_ARG_WITH(scheme,
  [--with-scheme[=PROGRAM]    Use a particular scheme implementation],,
  [with_scheme=])
143
144

AC_ARG_WITH(system-argp,
145
  [--without-system-argp    Don't use the system's argp],,
146
  [with_system_argp=yes])
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161

dnl IPv6 support
AC_ARG_ENABLE(ipv6,
  [--disable-ipv6             Disable IPv6 support],,
  [enable_ipv6=yes])

dnl utmp/wtmp logging 
AC_ARG_ENABLE(utmp,
  [--disable-utmp             Disable utmp and wtmp support],,
  [enable_utmp=yes])

if test x$enable_utmp = xyes ; then
  AC_DEFINE(WITH_UTMP)
fi

162
163
164
165
166
167
168
169
AC_ARG_WITH(include-path,
  [--with-include-path        A colon-separated list of directories to search for include files.],,
  [with_include_path=''])

if test x$with_include_path != x ; then
  CPPFLAGS="$CPPFLAGS -I `echo $with_include_path | sed 's/:/ -I /g'`"
fi

170
171
172
173
174
AC_ARG_WITH(lib-path,
  [--with-lib-path            A colon-separated list of directories to search for libraries.],,
  [with_lib_path=''])

if test x$with_lib_path != x ; then
175
  LDFLAGS="-L `echo $with_lib_path | sed 's/:/ -L /g'`"
176
177
178
179
180
181
182
183
184
fi

LSH_RPATH_INIT([`echo $with_lib_path | sed 's/:/ /g'` \
    `echo $exec_prefix | sed "s@^NONE@$prefix/lib@g" | sed "s@^NONE@$ac_default_prefix/lib@g"` \
    /usr/local/lib /sw/local/lib /sw/lib \
    /usr/gnu/lib /opt/gnu/lib /sw/gnu/lib /usr/freeware/lib /usr/pkg/lib])

dnl echo RPATH_CANDIDATE_DIRS = $RPATH_CANDIDATE_DIRS

Niels Möller's avatar
Niels Möller committed
185
186
187
dnl Checks for programs.
AC_PROG_CC
AC_PROG_MAKE_SET
Niels Möller's avatar
Niels Möller committed
188
AC_PROG_RANLIB
189
AM_PROG_CC_STDC
Niels Möller's avatar
Niels Möller committed
190

191
if test "x$am_cv_prog_cc_stdc" = xno ; then
192
193
194
  AC_ERROR([the C compiler doesn't handle ANSI-C])
fi

195
196
197
198
# Use a particular scheme implementation?
if test x$with_scheme != x ; then
  AC_PATH_PROG(SCHEME_PROGRAM, $with_scheme,, $PATH)
else  
199
  AC_PATH_PROGS(SCHEME_PROGRAM, guile scsh,, $PATH)
200
fi
201
202

if test x$SCHEME_PROGRAM = x ; then
203
204
  AC_MSG_WARN([No scheme implementation found.
This is fine as long as you don't modify the source files.])
205
206
207
  SCHEME_PROGRAM=false
fi

208
209
210
SCHEME_NAME=`basename $SCHEME_PROGRAM`
AC_SUBST(SCHEME_NAME)

211
212
AC_PATH_PROG(BASH, bash,, $PATH)
AC_PATH_PROG(GROFF, groff,, $PATH)
213
214
215
216
217
218
219
220
221
222
223
224
AC_PATH_PROG(M4, m4, m4)

AC_CACHE_CHECK([if m4 can handle eight-bit quote characters],
  lsh_cv_prog_m4_quote_8bit,
  [ if test xfoo = x`echo 'change''quote(,)foo' | $M4`; then
      lsh_cv_prog_m4_quote_8bit=yes
    else   
      lsh_cv_prog_m4_quote_8bit=no
    fi])

if test x$lsh_cv_prog_m4_quote_8bit = xno; then
  AC_MSG_WARN(  
225
226
227
[To get the testsuite to work properly, you may need to
upgrade to a better version than GNU m4 1.4, or recompile
it with CFLAGS=-funsigned-char.
228
Latest version is available at <URL: http://www.seindal.dk/rene/gnu/>])
229
  M4="false --"
230
fi
Niels Möller's avatar
Niels Möller committed
231
232
233

dnl Checks for header files.
AC_HEADER_STDC
234

235
dnl Some debian systems have both gmp and gmp2.
236
dnl This will probably not work right if both gmp.h and gmp2/gmp.h exists,
237
dnl and gmp.h is too old (i.e GMP-1.x).
238
239
240
241
242
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
243
  
244
AC_CHECK_HEADERS(fcntl.h strings.h sys/time.h unistd.h)
245
AC_CHECK_HEADERS(shadow.h)
246
247
248
if test x$with_zlib = xyes; then
  AC_CHECK_HEADERS(zlib.h,, [with_zlib=no])
fi
249
AC_CHECK_HEADERS(poll.h sys/poll.h)
250
AC_CHECK_HEADERS(libutil.h)
251
AC_CHECK_HEADERS(crypt.h)
252
253
AC_CHECK_HEADERS(pty.h)
AC_CHECK_HEADERS(stropts.h)
254
AC_CHECK_HEADERS(syslog.h)
255
AC_CHECK_HEADERS(argp.h)
256

257
258
259
AC_CHECK_HEADERS(utmp.h, [have_utmp_h=yes], [have_utmp_h=no])

if test x$have_utmp_h = xyes; then
260
261
262
263
264
265
266
267
268
269
  AC_CHECK_MEMBER([#include <sys/types.h>
#include <utmp.h>], [utmp], [ut_host])
  AC_CHECK_MEMBER([#include <sys/types.h>
#include <utmp.h>], [utmp], [ut_name])
  AC_CHECK_MEMBER([#include <sys/types.h>
#include <utmp.h>], [utmp], [ut_user])
  AC_CHECK_MEMBER([#include <sys/types.h>
#include <utmp.h>], [utmp], [ut_addr])
  AC_CHECK_MEMBER([#include <sys/types.h>
#include <utmp.h>], [utmp], [ut_addr_v6])
270
fi
271

272
273
AC_CHECK_HEADERS(utmpx.h)

274
275
276
277
if test x$enable_kerberos = xyes; then
  AC_CHECK_HEADERS(krb5.h,, [enable_kerberos=no])
fi

278
279
280
281
282
283
dnl Some systems (in particular, Unixware) doesn't have socklen_t, but
dnl uses size_t. Falling back to int will cause some warnings.

dnl AC_CHECK_TYPE doesn't work, probably because the type in
dnl question is not defined in sys/types.h.

284
AC_TYPE_SOCKLEN_T
285

286
287
288
289
290
291
292
293
294
dnl  AC_CACHE_CHECK([for socklen_t in sys/socket.h],
dnl    lsh_cv_type_socklen_t,
dnl    [ AC_EGREP_HEADER(socklen_t, sys/socket.h,
dnl  			 lsh_cv_type_socklen_t=yes,
dnl  			 lsh_cv_type_socklen_t=no]))

dnl if test x$lsh_cv_type_socklen_t = xno ; then
dnl   AC_DEFINE(socklen_t, int)
dnl fi
295

Niels Möller's avatar
Niels Möller committed
296

297
dnl Find the SSH1 daemon; try 'sshd1' first; if it fails, look for 'sshd'
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
dnl ## if test x$with_sshd1 = xyes ; then
dnl ## 	 AC_DEFINE(SSH1_FALLBACK)
dnl ## 	 dnl We have to provide an additional path: regular users seldomly have
dnl ## 	 dnl the sbin directories in their $PATH.
dnl ## 	 AC_PATH_PROG(SSHD1BIN, sshd1, [],
dnl ## 	   $PATH:/usr/local/sbin:/usr/local/etc:/usr/sbin:/usr/etc:/sbin:/etc)
dnl ## 	 if test x$SSHD1BIN = x ; then
dnl ## 	   AC_PATH_PROG(SSHD1BIN, sshd, [],
dnl ## 	     $PATH:/usr/local/sbin:/usr/local/etc:/usr/sbin:/usr/etc:/sbin:/etc)
dnl ## 	 fi
dnl ## 	 if test x$SSHD1BIN = x ; then
dnl ## 	   AC_MSG_ERROR([
dnl ## You requested SSH1 fallback support (--with-sshd1), but no sshd1 could be found.
dnl ## You can
dnl ## - supply the location of sshd1, i.e. --with-sshd1=/home/foo/sbin/sshd ,
dnl ## - install sshd1 (ftp://ftp.cs.hut.fi/pub/ssh/); note that it is not free
dnl ## 	 software, or
dnl ## - configure --without-sshd1 .
dnl ## ])
dnl ## 	 fi
dnl ## 
dnl ## 	 dnl OK. We've found an SSH1 daemon. Now we need to make sure it is
dnl ## 	 dnl recent enough to be used as a fallback daemon. This means it has to
dnl ## 	 dnl support the -V option, which tells it not to read the client version 
dnl ## 	 dnl string as lshd has already done that, and which supplies that version
dnl ## 	 dnl string.
dnl ## 	 AC_MSG_CHECKING(if $SSHD1BIN has the -V compatibility flag)
dnl ## changequote(<<, >>)dnl
dnl ## 	 if ($SSHD1BIN -h 2>&1 ; true) | grep '^[ \t]*-V' > /dev/null ; then
dnl ## changequote([, ])dnl
dnl ## 	   AC_MSG_RESULT(yes)
dnl ## 	 else
dnl ## 	   AC_MSG_ERROR([
dnl ## Found SSH1 daemon ]$SSHD1BIN[, but it does not support the -V option.
dnl ## This means we cannot use it as a fallback daemon. Please install a more recent 
dnl ## SSH1 daemon (ftp://ftp.cs.hut.fi/pub/ssh/), or configure --without-sshd1 .])
dnl ## 	 fi
dnl ## 	 AC_DEFINE_UNQUOTED(SSHD1,"$SSHD1BIN")
dnl ## fi
337

338
339

dnl Checks for libraries.
340
341
342
343
344
345
346
dnl  AC_CHECK_LIBGMP(gmp,,
dnl  dnl Some debian systems have both gmp1 and gmp2.
dnl  	 [AC_CHECK_LIBGMP(gmp2,,
dnl  	     AC_ERROR([GMP is missing (ftp://ftp.gnu.org/pub/gnu/gmp/gmp-2.0.2.tar.gz)]))])

AC_SEARCH_LIBGMP(gmp gmp2,
  LSH_RPATH_FIX,
347
  [AC_ERROR([GMP is missing. Get gmp-2.0.2 or better from ftp://ftp.gnu.org/pub/gnu/gmp]) ])
348
349
350
351
352

if test x$with_zlib = xyes; then
  AC_CHECK_LIB(z, inflate,, [with_zlib=no])
fi

353
354
355
356
if test x$with_zlib = xyes; then
  LSH_RPATH_FIX
fi

357
358
359
360
361
362
363
364
365
366
367
368
369
370
AC_CHECK_LIB(crypt, crypt)
AC_CHECK_LIB(xnet, inet_addr)
AC_CHECK_LIB(nsl, gethostbyname)
AC_CHECK_LIB(socket, setsockopt)
dnl logwtmp is also in libutil
AC_CHECK_LIB(util, openpty)
dnl This macro is new in autoconf-2.13
AC_SEARCH_LIBS(syslog, bsd socket inet, AC_DEFINE(HAVE_SYSLOG))

dnl Should we use zlib?
if test x$with_zlib = xyes ; then
  AC_DEFINE(WITH_ZLIB)
fi

371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
# The kerberos libraries are needed only to support the
# krb-check-passwd program, so we put them $KRB_LIBS, not in the
# ordinary $LIBS.

if test x$enable_kerberos = xyes; then
  AC_CHECK_KRB_LIB(roken, strlcpy)
  AC_CHECK_KRB_LIB(resolv, dn_expand)
  AC_CHECK_KRB_LIB(des, des_cbc_encrypt)
  AC_CHECK_KRB_LIB(asn1, der_get_octet_string)
  AC_CHECK_KRB_LIB(krb5, krb5_cc_gen_new,, [enable_kerberos=no])
fi

if test x$enable_kerberos = xyes; then
  AC_DEFINE(WITH_KERBEROS)
  KRB_PROGRAM=lsh-krb-checkpw
fi

AC_SUBST(KRB_LIBS)
AC_SUBST(KRB_PROGRAM)

Niels Möller's avatar
Niels Möller committed
391
dnl Checks for typedefs, structures, and compiler characteristics.
392
AC_C_CONST
393
AC_C_INLINE
394
AC_TYPE_UID_T
Niels Möller's avatar
Niels Möller committed
395
AC_TYPE_SIZE_T
396
397
AC_HEADER_TIME

Niels Möller's avatar
Niels Möller committed
398
399
400
dnl Needed by the supplied memcmp.c
AC_C_BIGENDIAN

Niels Möller's avatar
Niels Möller committed
401
402
403
AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(long, 4)
Niels Möller's avatar
Niels Möller committed
404
405
dnl FIXME: We should check that a pid_t fits in an int
	
Niels Möller's avatar
Niels Möller committed
406
dnl Checks for library functions.
407
408
409
AC_FUNC_ALLOCA
AC_FUNC_MEMCMP
AC_FUNC_VPRINTF
410
AC_CHECK_FUNCS(select socket strerror strsignal strtol)
411
AC_CHECK_FUNCS(getspnam)
412
AC_CHECK_FUNCS(vsnprintf inet_aton)
413
AC_CHECK_FUNCS(openpty)
414
AC_CHECK_FUNCS(cfmakeraw)
415
AC_CHECK_FUNCS(logwtmp login logout)
416
AC_CHECK_FUNCS(getaddrinfo getnameinfo gai_strerror)
417
418
419
AC_FUNC_GETPGRP
AC_CHECK_FUNCS(syslog)
AC_REPLACE_FUNCS(memxor)
420

421
422
423
424
425
426
427
428
429
430
431
432
433
AC_CACHE_CHECK([if netdb.h defines AI_NUMERICHOST],
  lsh_cv_sys_ai_numerichost,
  [AC_EGREP_CPP(yes,
    [#include <netdb.h>
     #ifdef AI_NUMERICHOST
     yes
     #endif
    ], lsh_cv_sys_ai_numerichost=yes,
       lsh_cv_sys_ai_numerichost=no)])
if test x$lsh_cv_sys_ai_numerichost = xyes ; then
  AC_DEFINE(HAVE_AI_NUMERICHOST)
fi

434
dnl Needed by argp
435
436
437
438
439
440
441
442
AC_CHECK_FUNCS(mempcpy strndup)
AC_CHECK_FUNCS(flockfile putc_unlocked)
AC_CHECK_FUNCS(fputs_unlocked fwrite_unlocked)

AC_CHECK_VAR(program_invocation_name, [#include <errno.h>])
AC_CHECK_VAR(program_invocation_short_name, [#include <errno.h>])

AC_CHECK_FUNCS(poll,,[LIBOBJS="jpoll.o $LIBOBJS"])
Niels Möller's avatar
Niels Möller committed
443

444
445
446
447
dnl This macro is mentioned in the automake manual, but where is it
dnl supposed to be defined?
dnl AC_REPLACE_GNU_GETOPT

448
dnl AC_CHECK_FUNCS(getopt_long,,[LIBOBJS="getopt.o $LIBOBJS"])
Niels Möller's avatar
Niels Möller committed
449
AC_CHECK_FUNCS(getopt_long,,[LIBOBJS="getopt.o getopt1.o $LIBOBJS"])
450

451
# Use system argp only if we can actually link with it.
452
if test x$with_system_argp = xyes ; then
453
  AC_CHECK_FUNCS(argp_parse,, with_system_argp=no)
454
455
fi

456
457
458
459
460
461
# FIXME: If the system already has argp, it's unnecessary to build our own.
# As we want to load the objects into liblsh.a, we list all the objects
# rather than libargp.a.
##  LIBOBJS="$LIBOBJS argp/libargp.a"

if test x$with_system_argp = xno ; then
462
463
464
  LIBOBJS="$LIBOBJS argp/argp-ba.o argp/argp-fmtstream.o \
		    argp/argp-help.o argp/argp-parse.o argp/argp-pin.o argp/argp-pv.o \
		    argp/argp-pvh.o argp/argp-eexst.o"
465
fi
466

467
dnl Check for broken shutdown
468
469
AC_CACHE_CHECK(for working shutdown on AF_UNIX sockets,
	       lsh_cv_func_shutdown_works_on_unix_sockets,
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
[
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

497
  if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0)
498
499
500
501
502
503
504
505
    {
      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)
    {
506
507
      fprintf(stderr, "shutdown(%d, SHUT_WR) failed: %s\n",
	      fds[0], strerror(errno));
508
509
510
511
      return 0;
    }
  if (shutdown(fds[1], SHUT_RD) < 0)
    {
512
513
      fprintf(stderr, "shutdown(%d, SHUT_RD) failed: %s\n",
	      fds[1], strerror(errno));
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
      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)
    {
529
      fprintf(stderr, "signal failed.\n");
530
531
532
533
534
535
536
537
538
      exit(1);
    }

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

  exit(0);
}
539
540
541
], 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)])
542

543
if test x$lsh_cv_func_shutdown_works_on_unix_sockets = xyes ; then
544
545
546
    AC_DEFINE(SHUTDOWN_WORKS_WITH_UNIX_SOCKETS)
fi

547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
AC_CACHE_CHECK(
  [for working UNIX98 ptys],
  lsh_cv_sys_unix98_ptys,
  AC_TRY_RUN([
  /* Try to obtain a working UNIX98-style pty master and slave */
  /* Based on example code from the GNU C library documentation */
  #include <stdlib.h>	/* EXIT_FAILURE, EXIT_SUCCESS, ptsname */
  #include <unistd.h>	/* close(2) */
  
  #include <sys/types.h>	/* open(2) */
  #include <sys/stat.h>	/* - " -   */
  #ifdef HAVE_FCNTL_H
  #  include <fcntl.h>	/* - " -   */
  #endif
  #ifdef HAVE_STROPTS_H
  #  include <stropts.h>	/* isastream() */
  #endif
  
  int main(int argc, char* argv[]) {
    int master, slave;
    char *name;
  
    master = open("/dev/ptmx", O_RDWR); /* PTY master multiplex */
    if (master < 0) {
  	  exit(EXIT_FAILURE);
    }
  
    if (grantpt(master) < 0 || unlockpt(master) < 0)
      goto close_master;
    name = ptsname(master);
    if (name == NULL)
      goto close_master;
  
    slave = open(name, O_RDWR);
    if (slave == -1)
      goto close_master;
  
  #ifdef HAVE_STROPTS_H
    if (isastream(slave))
      {
  	if (ioctl(slave, I_PUSH, "ptem") < 0
  	    || ioctl(slave, I_PUSH, "ldterm") < 0)
  	  goto close_slave;
      }
  #endif
  
    exit(0);
  
  close_slave:
    close (slave);
  
  close_master:
    close (master);
    exit(1);
  }
  ],
  [lsh_cv_sys_unix98_ptys=yes],
  [lsh_cv_sys_unix98_ptys=no],
  dnl FIXME: Pessimistic default for cross compilation.
  [lsh_cv_sys_unix98_ptys=no]))

if test x$lsh_cv_sys_unix98_ptys = xyes; then
  AC_DEFINE(HAVE_UNIX98_PTYS)
fi
  
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
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)])

630
631
if test "x$lsh_cv_c_attribute" = "xyes"; then
  AC_DEFINE(HAVE_GCC_ATTRIBUTE)
632
633
fi

634
635
636
637
638
639
640
641
642
643
644
645
dnl Check for gcc's __FUNCTION__ variable
AC_CACHE_CHECK(for __FUNCTION__,
	       lsh_cv_c_FUNCTION,
  [ AC_TRY_COMPILE(,
      [ void foo(void) { char c = __FUNCTION__[0]; } ],
      lsh_cv_c_FUNCTION=yes,
      lsh_cv_c_FUNCTION=no)])

if test "x$lsh_cv_c_FUNCTION" = "xyes"; then
  AC_DEFINE(HAVE_GCC_FUNCTION)
fi

646
647
648
649
650
651
dnl Check for the offsetof macro
dnl FIXME: This is usually defined in stddef.h

AC_CACHE_CHECK(for offsetof,
	       lsh_cv_c_offsetof,
  [ AC_TRY_COMPILE(,
652
653
      [ #include <stddef.h>
	struct s { int a; int b; };
654
655
656
657
658
659
660
        int foo(void) { return offsetof(struct s, b); }	],
      lsh_cv_c_offsetof=yes,
      lsh_cv_c_offsetof=no)])

if test "x$lsh_cv_c_offsetof" = "xyes"; then
  AC_DEFINE(HAVE_C_OFFSETOF)
fi
661

662
AC_MSG_CHECKING(for BSD pty names)
Niels Möller's avatar
Niels Möller committed
663
664

dnl FIXME: What is most portable, tr -d '\n' or tr -d '\012' ?
665
666
AC_DEFINE_UNQUOTED(PTY_BSD_SCHEME_FIRST_CHARS, "`ls /dev/pty* | cut -c 9-9 | uniq | tr -d '\n'`")
AC_DEFINE_UNQUOTED(PTY_BSD_SCHEME_SECOND_CHARS, "`ls /dev/pty* | cut -c 10-10 | sort | uniq | tr -d '\n'`")
667
668

dnl FIXME: How can we test if the bsd scheme is likely to work?
669
670
671
AC_DEFINE(PTY_BSD_SCHEME)
AC_MSG_RESULT([done])

672
dnl IPv6 support
673
674
675

if test x$enable_ipv6 = xyes ; then
  AC_CACHE_CHECK([if IPv6 is supported],
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
    lsh_cv_sys_ipv6,
    [AC_TRY_RUN([/* AF_INET6 avalable check */
  #include <sys/types.h>
  #include <sys/socket.h>
  int main(int argc, char **argv)
  {
   if (socket(AF_INET6, SOCK_STREAM, 0) < 0)
     exit(1);
   else
     exit(0);
  }
  ], lsh_cv_sys_ipv6=yes,
     lsh_cv_sys_ipv6=no,
     lsh_cv_sys_ipv6=no)])
  
691
692
  if test x$lsh_cv_sys_ipv6 != xyes ; then
    enable_ipv6=no
693
  elif test x$ac_cv_func_getaddrinfo != xyes ; then
694
695
    AC_MSG_WARN([getaddrinfo not found. Disabling IPv6 support])
    enable_ipv6=no
696
  elif test x$ac_cv_func_gai_strerror != xyes ; then
697
698
    AC_MSG_WARN([gai_strerror not found. Disabling IPv6 support])
    enable_ipv6=no
699
  elif test x$lsh_cv_sys_ai_numerichost != xyes ; then
700
701
    AC_MSG_WARN([AI_NUMERICHOST not defined. Disabling IPv6 support])
    enable_ipv6=no
702
703
704
  fi
fi

705
if test x$enable_ipv6 = xyes ; then
706
707
708
  AC_DEFINE(WITH_IPV6)
fi

709
710
# Set these flags *last*, or else the test programs won't compile
if test x$GCC = xyes ; then
711
    CFLAGS="$CFLAGS -ggdb3 -Wall -W \
Niels Möller's avatar
Niels Möller committed
712
713
714
 -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes \
 -Waggregate-return \
 -Wpointer-arith -Wbad-function-cast -Wnested-externs"
715

716
717
# Don't enable -Wcast-align as it results in tons of warnings in the
# DES code. And when using stdio.
718

719
fi
Niels Möller's avatar
Niels Möller committed
720

721
AC_OUTPUT(Makefile doc/Makefile misc/Makefile
722
	  src/Makefile src/argp/Makefile src/scm/Makefile
723
	  src/testsuite/Makefile src/rsync/Makefile
724
725
	  src/symmetric/Makefile src/symmetric/include/Makefile
	  contrib/Makefile contrib/lsh.spec)