configure.in 17.4 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.
5
AC_INIT([lsh], [1.3.1], [bug-lshbug-lsh@gnu.org]) 
6
7
8

AC_PREREQ(2.50)

9
AC_CONFIG_SRCDIR([src/lsh_types.h])
Niels Möller's avatar
Niels Möller committed
10

11
12
# FIXME: requirements
AM_INIT_AUTOMAKE(lsh, 1.3.1)
Niels Möller's avatar
Niels Möller committed
13

Niels Möller's avatar
Niels Möller committed
14
AM_CONFIG_HEADER(config.h)
Niels Möller's avatar
Niels Möller committed
15

16
# FIXME: Move this to the Makefile, as recommended by the autoconf manual.
17
AC_DEFINE_UNQUOTED(PREFIX, "`echo $prefix | sed "s@^NONE@$ac_default_prefix@"`")
18

19
# NOTE: The definition below is broken.
20
AC_DEFINE_UNQUOTED(SBINDIR, "`echo $sbindir | sed "s@^NONE@$prefix/sbin@" | sed "s@^NONE@$ac_default_prefix@"`")
21

22
23
24
25
26
27
28
29
30
31
32
33
# 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

34
# echo Replacing CPPFLAGS: $CPPFLAGS
35
# FIXME: Should be obsoleted by the nettle library
Niels Möller's avatar
Niels Möller committed
36
# We want to compile the crypto lib for use with lsh
37
# CPPFLAGS="$CPPFLAGS -I$srcdir -I$srcdir/src -I$srcdir/src/symmetric/include -DLSH"
Niels Möller's avatar
Niels Möller committed
38

39
40
41
# src/rsync relies on lsh's definitions of WRITE_UINT32 etc.
CPPFLAGS="-I$srcdir/src -DLSH"

42
43
44
45
# 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
46

47
48
# We can't use AH_VERBATIM for this, as we want _GNU_SOURCE to be defined
# when running configure's test programs.
Niels Möller's avatar
Niels Möller committed
49
50
CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"

51
# Check options
52
AC_ARG_ENABLE(debug_alloc,
53
  AC_HELP_STRING([--enable-debug-alloc], [Enable memory allocation sanity checks]),,
54
  [enable_debug_alloc=no])
55
56
  
if test x$enable_debug_alloc = xyes ; then
57
58
59
  AC_DEFINE(DEBUG_ALLOC)
fi

60
AC_ARG_ENABLE(debug_trace,
61
  AC_HELP_STRING([--enable-debug-trace], [Enable tracing support]),,
62
  [enable_debug_trace=no])
63

64
if test x$enable_debug_trace = xyes ; then
65
66
67
  AC_DEFINE(DEBUG_TRACE)
fi

Niels Möller's avatar
Niels Möller committed
68
AC_ARG_ENABLE(gcov,
69
  AC_HELP_STRING([--enable-gcov], [Instrument for gcov (requires a modern gcc)]),,
Niels Möller's avatar
Niels Möller committed
70
71
  [enable_gcov=no])

72
AC_ARG_WITH(zlib,
73
  AC_HELP_STRING([--without-zlib], [Don't use zlib compression]),,
74
  [with_zlib=yes])
75

76
77
# Checking this variable is delayed until we have checked if zlib is
# actually available.
78

79
AC_ARG_ENABLE(pty,
80
  AC_HELP_STRING([--without-pty], [Disable pty support]),,
81
  [enable_pty=yes])
82

83
if test x$enable_pty = xyes ; then
84
85
86
  AC_DEFINE(WITH_PTY_SUPPORT)
fi

87
AC_ARG_WITH(sshd1,
88
  AC_HELP_STRING([[--with-sshd1[=PROGRAM]]], [support fallback to SSH1 daemon]),,
89
  [with_sshd1=yes])
90

91
92
93
94
95
96
97
98
99
# 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
100

101
AC_ARG_ENABLE(idea,
102
  AC_HELP_STRING([--enable-idea], [Support the patent-encumbered IDEA algorithm]),,
103
  [enable_idea=no])
104

105
if test x$enable_idea = xyes ; then
106
107
  AC_DEFINE(WITH_IDEA)
fi
108

109
AC_ARG_ENABLE(srp,
110
  AC_HELP_STRING([--disable-srp], [Disable the (experimental) support for SRP]),,
111
112
  [enable_srp=yes])

113
AC_ARG_ENABLE(kerberos,
114
  AC_HELP_STRING([--disable-kerberos], [Don't support kerberos]),,
115
116
  [enable_kerberos=yes])
  
117
118
if test x$enable_srp = xyes ; then
  AC_DEFINE(WITH_SRP)
119
  SRP_PROGRAM=srp-gen
120
121
fi

122
123
AC_SUBST(SRP_PROGRAM)

124
AC_ARG_ENABLE(datafellows_workarounds,
125
  AC_HELP_STRING([--disable-datafellows-workarounds], [Disable bug-compatibility with SSH Inc's clients and servers]),,
126
  [enable_datafellows_workarounds=yes])
127

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

132
AC_ARG_ENABLE(tcp_forward,
133
  AC_HELP_STRING([--disable-tcp-forward], [Disable tcp forwarding]),,
134
  [enable_tcp_forward=yes])
135

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

140
AC_ARG_ENABLE(x11_forward,
141
  AC_HELP_STRING([--disable-x11-forward], [Disable x11 forwarding (proxy only)]),,
142
  [eanble_x11_forward=yes])
143

144
if test x$enable_x11_forward = xyes ; then
145
146
147
  AC_DEFINE(WITH_X11_FORWARD)
fi

148
AC_ARG_ENABLE(agent_forward,
149
  AC_HELP_STRING([--disable-agent-forward], [Disable auth-agent forwarding (proxy only)]),,
150
151
  [with_agent_forward=yes])

152
if test x$disable_agent_forward = xyes ; then
153
154
155
  AC_DEFINE(WITH_AGENT_FORWARD)
fi

156
AC_ARG_WITH(scheme,
157
  AC_HELP_STRING([[--with-scheme[=PROGRAM]]], [Use a particular scheme implementation]),,
158
  [with_scheme=])
159
160

AC_ARG_WITH(system-argp,
161
  AC_HELP_STRING([--without-system-argp], [Don't use the system's argp]),,
162
  [with_system_argp=yes])
163

164
# IPv6 support
165
AC_ARG_ENABLE(ipv6,
166
  AC_HELP_STRING([--disable-ipv6], [Disable IPv6 support]),,
167
168
  [enable_ipv6=yes])

169
# utmp/wtmp logging 
170
AC_ARG_ENABLE(utmp,
171
  AC_HELP_STRING([--disable-utmp], [Disable utmp and wtmp support]),,
172
173
174
175
176
177
  [enable_utmp=yes])

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

178
AC_ARG_WITH(include-path,
179
  AC_HELP_STRING([--with-include-path], [A colon-separated list of directories to search for include files]),,
180
181
182
183
184
185
  [with_include_path=''])

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

186
AC_ARG_WITH(lib-path,
187
  AC_HELP_STRING([--with-lib-path], [A colon-separated list of directories to search for libraries]),,
188
189
190
  [with_lib_path=''])

if test x$with_lib_path != x ; then
191
  LDFLAGS="-L `echo $with_lib_path | sed 's/:/ -L /g'`"
192
193
194
195
196
197
198
199
200
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

201
# Checks for programs.
Niels Möller's avatar
Niels Möller committed
202
203
AC_PROG_CC
AC_PROG_MAKE_SET
Niels Möller's avatar
Niels Möller committed
204
AC_PROG_RANLIB
205
AM_PROG_CC_STDC
Niels Möller's avatar
Niels Möller committed
206

207
if test "x$am_cv_prog_cc_stdc" = xno ; then
208
  AC_MSG_ERROR([the C compiler doesn't handle ANSI-C])
209
210
fi

211
212
213
214
# Use a particular scheme implementation?
if test x$with_scheme != x ; then
  AC_PATH_PROG(SCHEME_PROGRAM, $with_scheme,, $PATH)
else  
215
  AC_PATH_PROGS(SCHEME_PROGRAM, guile scsh,, $PATH)
216
fi
217
218

if test x$SCHEME_PROGRAM = x ; then
219
220
  AC_MSG_WARN([No scheme implementation found.
This is fine as long as you don't modify the source files.])
221
222
223
  SCHEME_PROGRAM=false
fi

224
225
226
SCHEME_NAME=`basename $SCHEME_PROGRAM`
AC_SUBST(SCHEME_NAME)

227
228
AC_PATH_PROG(BASH, bash,, $PATH)
AC_PATH_PROG(GROFF, groff,, $PATH)
229
230
231
232
233
234
235
236
237
238
239
240
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(  
241
242
243
[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.
244
Latest version is available at <URL: http://www.seindal.dk/rene/gnu/>])
245
  M4="false --"
246
fi
Niels Möller's avatar
Niels Möller committed
247

248
# Checks for header files.
Niels Möller's avatar
Niels Möller committed
249
AC_HEADER_STDC
250

251
252
253
# Some debian systems have both gmp and gmp2.
# This will probably not work right if both gmp.h and gmp2/gmp.h exists,
# and gmp.h is too old (i.e GMP-1.x).
254
255
256
gmp_header_found=no
AC_CHECK_HEADERS(gmp.h gmp2/gmp.h, [gmp_header_found=yes; break])
if test "$gmp_header_found" = no; then
257
  AC_MSG_ERROR([Neither gmp.h nor gmp2/gmp.h found])
258
fi
259
  
260
AC_CHECK_HEADERS(fcntl.h strings.h sys/time.h unistd.h)
261
AC_CHECK_HEADERS(shadow.h)
262
263
264
if test x$with_zlib = xyes; then
  AC_CHECK_HEADERS(zlib.h,, [with_zlib=no])
fi
265
AC_CHECK_HEADERS(poll.h sys/poll.h)
266
AC_CHECK_HEADERS(libutil.h)
267
AC_CHECK_HEADERS(crypt.h)
268
269
AC_CHECK_HEADERS(pty.h)
AC_CHECK_HEADERS(stropts.h)
270
AC_CHECK_HEADERS(syslog.h)
271
AC_CHECK_HEADERS(argp.h)
272

273
274
275
AC_CHECK_HEADERS(utmp.h, [have_utmp_h=yes], [have_utmp_h=no])

if test x$have_utmp_h = xyes; then
276
277
278
279
280
281
282
283
284
285
286
287
288
  AC_CHECK_MEMBERS([struct utmp.ut_host,
		    struct utmp.ut_name,
		    struct utmp.ut_user,
		    struct utmp.ut_addr,
		    struct utmp.ut_addr_v6],,,
[# if HAVE_UTMP_H
#  include <utmp.h>
# endif

# if HAVE_UTMPX_H
#  include <utmpx.h>
# endif
])
289
fi
290

291
292
AC_CHECK_HEADERS(utmpx.h)

293
294
295
296
if test x$enable_kerberos = xyes; then
  AC_CHECK_HEADERS(krb5.h,, [enable_kerberos=no])
fi

297
298
# Some systems (in particular, Unixware) doesn't have socklen_t, but
# uses size_t. Falling back to int will cause some warnings.
299

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

303
AC_TYPE_SOCKLEN_T
304

305
AC_SEARCH_LIBGMP(gmp gmp2,
306
  [LSH_RPATH_FIX],
307
  [AC_MSG_ERROR([GMP is missing. Get gmp-2.0.2 or better from ftp://ftp.gnu.org/pub/gnu/gmp]) ])
308
309
310
311
312

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

313
314
315
316
if test x$with_zlib = xyes; then
  LSH_RPATH_FIX
fi

317
318
319
320
AC_CHECK_LIB(crypt, crypt)
AC_CHECK_LIB(xnet, inet_addr)
AC_CHECK_LIB(nsl, gethostbyname)
AC_CHECK_LIB(socket, setsockopt)
321
# logwtmp is also in libutil
322
AC_CHECK_LIB(util, openpty)
323
# This macro is new in autoconf-2.13
324
AC_SEARCH_LIBS(syslog, bsd socket inet, [AC_DEFINE(HAVE_SYSLOG)])
325

326
# Should we use zlib?
327
328
329
330
if test x$with_zlib = xyes ; then
  AC_DEFINE(WITH_ZLIB)
fi

331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
# 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
351
352
if test "x$enable_gcov" = "xyes"; then
  CFLAGS="$CFLAGS -ftest-coverage -fprofile-arcs"
353
  AC_DEFINE(WITH_GCOV)
Niels Möller's avatar
Niels Möller committed
354
355
fi

356
# Checks for typedefs, structures, and compiler characteristics.
357
AC_C_CONST
358
AC_C_INLINE
359
AC_TYPE_UID_T
Niels Möller's avatar
Niels Möller committed
360
AC_TYPE_SIZE_T
361
362
AC_HEADER_TIME

363
# Needed by the supplied memcmp.c
Niels Möller's avatar
Niels Möller committed
364
365
AC_C_BIGENDIAN

Niels Möller's avatar
Niels Möller committed
366
367
368
AC_CHECK_SIZEOF(short, 2)
AC_CHECK_SIZEOF(int, 4)
AC_CHECK_SIZEOF(long, 4)
369
370

# FIXME: We should check that a pid_t fits in an int
Niels Möller's avatar
Niels Möller committed
371
	
372
# Checks for library functions.
373
374
375
AC_FUNC_ALLOCA
AC_FUNC_MEMCMP
AC_FUNC_VPRINTF
376
AC_CHECK_FUNCS(select socket strerror strsignal strtol)
377
AC_CHECK_FUNCS(getrusage gettimeofday)
378
AC_CHECK_FUNCS(getspnam)
379
AC_CHECK_FUNCS(vsnprintf inet_aton)
380
AC_CHECK_FUNCS(openpty)
381
AC_CHECK_FUNCS(cfmakeraw)
382
AC_CHECK_FUNCS(logwtmp login logout)
383
AC_CHECK_FUNCS(getaddrinfo getnameinfo gai_strerror)
384
385
386
AC_FUNC_GETPGRP
AC_CHECK_FUNCS(syslog)
AC_REPLACE_FUNCS(memxor)
387

388
# FIXME: Is there a better way in autoconf 2.50?
389
390
391
392
393
394
395
396
397
398
399
400
401
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

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

404
# Test if the libc includes a good enough argp.
405
if test x$with_system_argp = xyes ; then
406
  AC_LIB_ARGP(,with_system_argp=no)
407
408
fi

409
410
411
# We don't use LIBOBJS for this, as the LIBOBJS are added to
# liblsh.a, and we can't add an archive to an archive.
LIBARGP=""
412
if test x$with_system_argp = xno ; then
Niels Möller's avatar
Niels Möller committed
413
  # FIXME: Perhaps it's better to use an absolute path?
414
  LIBARGP="argp/libargp.a"
415
fi
416

417
418
AC_SUBST(LIBARGP)

419
# Check for broken shutdown
420
421
AC_CACHE_CHECK(for working shutdown on AF_UNIX sockets,
	       lsh_cv_func_shutdown_works_on_unix_sockets,
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
[
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

449
  if (socketpair(AF_UNIX, SOCK_STREAM, 0, fds) < 0)
450
451
452
453
454
455
456
457
    {
      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)
    {
458
459
      fprintf(stderr, "shutdown(%d, SHUT_WR) failed: %s\n",
	      fds[0], strerror(errno));
460
461
462
463
      return 0;
    }
  if (shutdown(fds[1], SHUT_RD) < 0)
    {
464
465
      fprintf(stderr, "shutdown(%d, SHUT_RD) failed: %s\n",
	      fds[1], strerror(errno));
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
      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)
    {
481
      fprintf(stderr, "signal failed.\n");
482
483
484
485
486
487
488
489
490
      exit(1);
    }

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

  exit(0);
}
491
492
493
], 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)])
494

495
if test x$lsh_cv_func_shutdown_works_on_unix_sockets = xyes ; then
496
497
498
    AC_DEFINE(SHUTDOWN_WORKS_WITH_UNIX_SOCKETS)
fi

499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
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],
557
  # Pessimistic default for cross compilation.
558
559
560
561
562
563
  [lsh_cv_sys_unix98_ptys=no]))

if test x$lsh_cv_sys_unix98_ptys = xyes; then
  AC_DEFINE(HAVE_UNIX98_PTYS)
fi
  
564
# Check for gcc's __attribute__ construction
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
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)])

582
583
if test "x$lsh_cv_c_attribute" = "xyes"; then
  AC_DEFINE(HAVE_GCC_ATTRIBUTE)
584
585
fi

586
# Check for gcc's __FUNCTION__ variable
587
588
589
590
591
592
593
594
595
596
597
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

598
599
# Check for the offsetof macro
# FIXME: This is usually defined in stddef.h
600
601
602
603

AC_CACHE_CHECK(for offsetof,
	       lsh_cv_c_offsetof,
  [ AC_TRY_COMPILE(,
604
605
      [ #include <stddef.h>
	struct s { int a; int b; };
606
607
608
609
610
611
612
        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
613

614
AC_MSG_CHECKING(for BSD pty names)
Niels Möller's avatar
Niels Möller committed
615

616
# FIXME: What is most portable, tr -d '\n' or tr -d '\012' ?
617
618
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'`")
619

620
# FIXME: How can we test if the bsd scheme is likely to work?
621
622
623
AC_DEFINE(PTY_BSD_SCHEME)
AC_MSG_RESULT([done])

624
# IPv6 support
625
626
627

if test x$enable_ipv6 = xyes ; then
  AC_CACHE_CHECK([if IPv6 is supported],
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
    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)])
  
643
644
  if test x$lsh_cv_sys_ipv6 != xyes ; then
    enable_ipv6=no
645
  elif test x$ac_cv_func_getaddrinfo != xyes ; then
646
647
    AC_MSG_WARN([getaddrinfo not found. Disabling IPv6 support])
    enable_ipv6=no
648
  elif test x$ac_cv_func_gai_strerror != xyes ; then
649
650
    AC_MSG_WARN([gai_strerror not found. Disabling IPv6 support])
    enable_ipv6=no
651
  elif test x$lsh_cv_sys_ai_numerichost != xyes ; then
652
653
    AC_MSG_WARN([AI_NUMERICHOST not defined. Disabling IPv6 support])
    enable_ipv6=no
654
655
656
  fi
fi

657
if test x$enable_ipv6 = xyes ; then
658
659
660
  AC_DEFINE(WITH_IPV6)
fi

661
AC_CONFIG_SUBDIRS(src/argp)
662
AC_CONFIG_SUBDIRS(src/nettle)
663

664
665
# Set these flags *last*, or else the test programs won't compile
if test x$GCC = xyes ; then
666
    CFLAGS="$CFLAGS -ggdb3 -Wall -W \
Niels Möller's avatar
Niels Möller committed
667
668
669
 -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes \
 -Waggregate-return \
 -Wpointer-arith -Wbad-function-cast -Wnested-externs"
670

671
672
# Don't enable -Wcast-align as it results in tons of warnings in the
# DES code. And when using stdio.
673

674
fi
Niels Möller's avatar
Niels Möller committed
675

676
AC_CONFIG_FILES([Makefile doc/Makefile misc/Makefile
677
	  src/Makefile src/scm/Makefile
678
	  src/testsuite/Makefile src/rsync/Makefile
679
	  src/nettle/Makefile
680
681
	  contrib/Makefile contrib/lsh.spec])
AC_OUTPUT