configure.ac 128 KB
Newer Older
1
# $Id: configure.ac,v 1.536 2013/08/04 11:48:41 dtucker Exp $
2 3 4 5 6 7 8 9 10 11 12 13 14 15
#
# Copyright (c) 1999-2004 Damien Miller
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16

Tim Rice's avatar
Tim Rice committed
17
AC_INIT([OpenSSH], [Portable], [openssh-unix-dev@mindrot.org])
18
AC_REVISION($Revision: 1.536 $)
19
AC_CONFIG_SRCDIR([ssh.c])
Tim Rice's avatar
Tim Rice committed
20
AC_LANG([C])
21

Tim Rice's avatar
Tim Rice committed
22
AC_CONFIG_HEADER([config.h])
23
AC_PROG_CC
24
AC_CANONICAL_HOST
25
AC_C_BIGENDIAN
26

27
# Checks for programs.
28
AC_PROG_AWK
29
AC_PROG_CPP
30
AC_PROG_RANLIB
31
AC_PROG_INSTALL
32
AC_PROG_EGREP
Tim Rice's avatar
Tim Rice committed
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
AC_PATH_PROG([AR], [ar])
AC_PATH_PROG([CAT], [cat])
AC_PATH_PROG([KILL], [kill])
AC_PATH_PROGS([PERL], [perl5 perl])
AC_PATH_PROG([SED], [sed])
AC_SUBST([PERL])
AC_PATH_PROG([ENT], [ent])
AC_SUBST([ENT])
AC_PATH_PROG([TEST_MINUS_S_SH], [bash])
AC_PATH_PROG([TEST_MINUS_S_SH], [ksh])
AC_PATH_PROG([TEST_MINUS_S_SH], [sh])
AC_PATH_PROG([SH], [sh])
AC_PATH_PROG([GROFF], [groff])
AC_PATH_PROG([NROFF], [nroff])
AC_PATH_PROG([MANDOC], [mandoc])
AC_SUBST([TEST_SHELL], [sh])
Damien Miller's avatar
Damien Miller committed
49

50 51 52 53 54 55 56 57 58 59 60
dnl select manpage formatter
if test "x$MANDOC" != "x" ; then
	MANFMT="$MANDOC"
elif test "x$NROFF" != "x" ; then
	MANFMT="$NROFF -mandoc"
elif test "x$GROFF" != "x" ; then
	MANFMT="$GROFF -mandoc -Tascii"
else
	AC_MSG_WARN([no manpage formatted found])
	MANFMT="false"
fi
Tim Rice's avatar
Tim Rice committed
61
AC_SUBST([MANFMT])
62

63
dnl for buildpkg.sh
Tim Rice's avatar
Tim Rice committed
64
AC_PATH_PROG([PATH_GROUPADD_PROG], [groupadd], [groupadd],
65
	[/usr/sbin${PATH_SEPARATOR}/etc])
Tim Rice's avatar
Tim Rice committed
66
AC_PATH_PROG([PATH_USERADD_PROG], [useradd], [useradd],
67
	[/usr/sbin${PATH_SEPARATOR}/etc])
Tim Rice's avatar
Tim Rice committed
68
AC_CHECK_PROG([MAKE_PACKAGE_SUPPORTED], [pkgmk], [yes], [no])
69
if test -x /sbin/sh; then
Tim Rice's avatar
Tim Rice committed
70
	AC_SUBST([STARTUP_SCRIPT_SHELL], [/sbin/sh])
71
else
Tim Rice's avatar
Tim Rice committed
72
	AC_SUBST([STARTUP_SCRIPT_SHELL], [/bin/sh])
73
fi
74

75 76 77
# System features
AC_SYS_LARGEFILE

78 79 80 81
if test -z "$AR" ; then
	AC_MSG_ERROR([*** 'ar' missing, please install or fix your \$PATH ***])
fi

82 83
# Use LOGIN_PROGRAM from environment if possible
if test ! -z "$LOGIN_PROGRAM" ; then
Tim Rice's avatar
Tim Rice committed
84
	AC_DEFINE_UNQUOTED([LOGIN_PROGRAM_FALLBACK], ["$LOGIN_PROGRAM"],
85 86
		[If your header files don't define LOGIN_PROGRAM,
		then use this (detected) from environment and PATH])
87 88
else
	# Search for login
Tim Rice's avatar
Tim Rice committed
89
	AC_PATH_PROG([LOGIN_PROGRAM_FALLBACK], [login])
90
	if test ! -z "$LOGIN_PROGRAM_FALLBACK" ; then
Tim Rice's avatar
Tim Rice committed
91
		AC_DEFINE_UNQUOTED([LOGIN_PROGRAM_FALLBACK], ["$LOGIN_PROGRAM_FALLBACK"])
92 93 94
	fi
fi

Tim Rice's avatar
Tim Rice committed
95
AC_PATH_PROG([PATH_PASSWD_PROG], [passwd])
96
if test ! -z "$PATH_PASSWD_PROG" ; then
Tim Rice's avatar
Tim Rice committed
97
	AC_DEFINE_UNQUOTED([_PATH_PASSWD_PROG], ["$PATH_PASSWD_PROG"],
98
		[Full path of your "passwd" program])
99 100
fi

101 102 103
if test -z "$LD" ; then
	LD=$CC
fi
Tim Rice's avatar
Tim Rice committed
104
AC_SUBST([LD])
105

106
AC_C_INLINE
107

Tim Rice's avatar
Tim Rice committed
108
AC_CHECK_DECL([LLONG_MAX], [have_llong_max=1], , [#include <limits.h>])
109 110 111 112 113 114 115 116 117 118
AC_CHECK_DECL([SYSTR_POLICY_KILL], [have_systr_policy_kill=1], , [
	#include <sys/types.h>
	#include <sys/param.h>
	#include <dev/systrace.h>
])
AC_CHECK_DECL([RLIMIT_NPROC],
    [AC_DEFINE([HAVE_RLIMIT_NPROC], [], [sys/resource.h has RLIMIT_NPROC])], , [
	#include <sys/types.h>
	#include <sys/resource.h>
])
119 120 121 122
AC_CHECK_DECL([PR_SET_NO_NEW_PRIVS], [have_linux_no_new_privs=1], , [
	#include <sys/types.h>
	#include <linux/prctl.h>
])
123
use_stack_protector=1
Tim Rice's avatar
Tim Rice committed
124
AC_ARG_WITH([stackprotect],
125
    [  --without-stackprotect  Don't use compiler's stack protection], [
126 127 128 129
    if test "x$withval" = "xno"; then
	use_stack_protector=0
    fi ])

130

131
if test "$GCC" = "yes" || test "$GCC" = "egcs"; then
132 133 134 135
	OSSH_CHECK_CFLAG_COMPILE([-Qunused-arguments -Werror],
	    [-Qunused-arguments])
	OSSH_CHECK_CFLAG_COMPILE([-Wunknown-warning-option -Werror],
	    [-Wno-unknown-warning-option])
136 137 138 139 140
	OSSH_CHECK_CFLAG_COMPILE([-Wall])
	OSSH_CHECK_CFLAG_COMPILE([-Wpointer-arith])
	OSSH_CHECK_CFLAG_COMPILE([-Wuninitialized])
	OSSH_CHECK_CFLAG_COMPILE([-Wsign-compare])
	OSSH_CHECK_CFLAG_COMPILE([-Wformat-security])
141
	OSSH_CHECK_CFLAG_COMPILE([-Wsizeof-pointer-memaccess])
142 143 144
	OSSH_CHECK_CFLAG_COMPILE([-Wpointer-sign], [-Wno-pointer-sign])
	OSSH_CHECK_CFLAG_COMPILE([-Wunused-result], [-Wno-unused-result])
	OSSH_CHECK_CFLAG_COMPILE([-fno-strict-aliasing])
145
	OSSH_CHECK_CFLAG_COMPILE([-D_FORTIFY_SOURCE=2])
Tim Rice's avatar
Tim Rice committed
146
	AC_MSG_CHECKING([gcc version])
147
	GCC_VER=`$CC -v 2>&1 | $AWK '/gcc version /{print $3}'`
148
	case $GCC_VER in
149 150 151 152 153
		1.*) no_attrib_nonnull=1 ;;
		2.8* | 2.9*)
		     no_attrib_nonnull=1
		     ;;
		2.*) no_attrib_nonnull=1 ;;
154
		*) ;;
155
	esac
Tim Rice's avatar
Tim Rice committed
156
	AC_MSG_RESULT([$GCC_VER])
157

Tim Rice's avatar
Tim Rice committed
158
	AC_MSG_CHECKING([if $CC accepts -fno-builtin-memset])
159 160
	saved_CFLAGS="$CFLAGS"
	CFLAGS="$CFLAGS -fno-builtin-memset"
Tim Rice's avatar
Tim Rice committed
161 162 163 164
	AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <string.h> ]],
			[[ char b[10]; memset(b, 0, sizeof(b)); ]])],
		[ AC_MSG_RESULT([yes]) ],
		[ AC_MSG_RESULT([no])
165
		  CFLAGS="$saved_CFLAGS" ]
Tim Rice's avatar
Tim Rice committed
166
	)
167

168
	# -fstack-protector-all doesn't always work for some GCC versions
169
	# and/or platforms, so we test if we can.  If it's not supported
170
	# on a given platform gcc will emit a warning so we use -Werror.
171 172
	if test "x$use_stack_protector" = "x1"; then
	    for t in -fstack-protector-all -fstack-protector; do
Tim Rice's avatar
Tim Rice committed
173
		AC_MSG_CHECKING([if $CC supports $t])
174 175
		saved_CFLAGS="$CFLAGS"
		saved_LDFLAGS="$LDFLAGS"
176 177 178
		CFLAGS="$CFLAGS $t -Werror"
		LDFLAGS="$LDFLAGS $t -Werror"
		AC_LINK_IFELSE(
Tim Rice's avatar
Tim Rice committed
179 180 181 182 183 184
			[AC_LANG_PROGRAM([[ #include <stdio.h> ]],
			[[
	char x[256];
	snprintf(x, sizeof(x), "XXX");
			 ]])],
		    [ AC_MSG_RESULT([yes])
185 186
		      CFLAGS="$saved_CFLAGS $t"
		      LDFLAGS="$saved_LDFLAGS $t"
Tim Rice's avatar
Tim Rice committed
187
		      AC_MSG_CHECKING([if $t works])
188
		      AC_RUN_IFELSE(
Tim Rice's avatar
Tim Rice committed
189 190 191 192 193 194
			[AC_LANG_PROGRAM([[ #include <stdio.h> ]],
			[[
	char x[256];
	snprintf(x, sizeof(x), "XXX");
			]])],
			[ AC_MSG_RESULT([yes])
195
			  break ],
Tim Rice's avatar
Tim Rice committed
196
			[ AC_MSG_RESULT([no]) ],
197 198
			[ AC_MSG_WARN([cross compiling: cannot test])
			  break ]
199
		      )
200
		    ],
Tim Rice's avatar
Tim Rice committed
201
		    [ AC_MSG_RESULT([no]) ]
202 203 204 205 206
		)
		CFLAGS="$saved_CFLAGS"
		LDFLAGS="$saved_LDFLAGS"
	    done
	fi
207

208 209 210 211 212
	if test -z "$have_llong_max"; then
		# retry LLONG_MAX with -std=gnu99, needed on some Linuxes
		unset ac_cv_have_decl_LLONG_MAX
		saved_CFLAGS="$CFLAGS"
		CFLAGS="$CFLAGS -std=gnu99"
Tim Rice's avatar
Tim Rice committed
213
		AC_CHECK_DECL([LLONG_MAX],
214 215 216 217 218
		    [have_llong_max=1],
		    [CFLAGS="$saved_CFLAGS"],
		    [#include <limits.h>]
		)
	fi
219 220
fi

221 222 223 224 225 226 227 228 229 230 231 232
AC_MSG_CHECKING([if compiler allows __attribute__ on return types])
AC_COMPILE_IFELSE(
    [AC_LANG_PROGRAM([[
#include <stdlib.h>
__attribute__((__unused__)) static void foo(void){return;}]],
    [[ exit(0); ]])],
    [ AC_MSG_RESULT([yes]) ],
    [ AC_MSG_RESULT([no])
      AC_DEFINE(NO_ATTRIBUTE_ON_RETURN_TYPE, 1,
	 [compiler does not accept __attribute__ on return types]) ]
)

233
if test "x$no_attrib_nonnull" != "x1" ; then
Tim Rice's avatar
Tim Rice committed
234
	AC_DEFINE([HAVE_ATTRIBUTE__NONNULL__], [1], [Have attribute nonnull])
235 236
fi

Tim Rice's avatar
Tim Rice committed
237
AC_ARG_WITH([rpath],
238 239
	[  --without-rpath         Disable auto-added -R linker paths],
	[
240
		if test "x$withval" = "xno" ; then
241 242 243 244 245 246 247 248
			need_dash_r=""
		fi
		if test "x$withval" = "xyes" ; then
			need_dash_r=1
		fi
	]
)

249
# Allow user to specify flags
Tim Rice's avatar
Tim Rice committed
250
AC_ARG_WITH([cflags],
251 252 253 254 255 256 257 258
	[  --with-cflags           Specify additional flags to pass to compiler],
	[
		if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
		    test "x${withval}" != "xyes"; then
			CFLAGS="$CFLAGS $withval"
		fi
	]
)
Tim Rice's avatar
Tim Rice committed
259
AC_ARG_WITH([cppflags],
260 261 262 263 264 265 266 267
	[  --with-cppflags         Specify additional flags to pass to preprocessor] ,
	[
		if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
		    test "x${withval}" != "xyes"; then
			CPPFLAGS="$CPPFLAGS $withval"
		fi
	]
)
Tim Rice's avatar
Tim Rice committed
268
AC_ARG_WITH([ldflags],
269 270 271 272 273 274 275 276
	[  --with-ldflags          Specify additional flags to pass to linker],
	[
		if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
		    test "x${withval}" != "xyes"; then
			LDFLAGS="$LDFLAGS $withval"
		fi
	]
)
Tim Rice's avatar
Tim Rice committed
277
AC_ARG_WITH([libs],
278 279 280 281 282 283 284 285
	[  --with-libs             Specify additional libraries to link with],
	[
		if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
		    test "x${withval}" != "xyes"; then
			LIBS="$LIBS $withval"
		fi
	]
)
Tim Rice's avatar
Tim Rice committed
286
AC_ARG_WITH([Werror],
287 288 289 290 291 292 293 294 295 296 297
	[  --with-Werror           Build main code with -Werror],
	[
		if test -n "$withval"  &&  test "x$withval" != "xno"; then
			werror_flags="-Werror"
			if test "x${withval}" != "xyes"; then
				werror_flags="$withval"
			fi
		fi
	]
)

Tim Rice's avatar
Tim Rice committed
298
AC_CHECK_HEADERS([ \
299 300 301 302 303
	bstring.h \
	crypt.h \
	crypto/sha2.h \
	dirent.h \
	endian.h \
304
	elf.h \
305 306 307 308 309 310 311 312
	features.h \
	fcntl.h \
	floatingpoint.h \
	getopt.h \
	glob.h \
	ia.h \
	iaf.h \
	limits.h \
313
	locale.h \
314 315 316 317 318 319 320 321
	login.h \
	maillock.h \
	ndir.h \
	net/if_tun.h \
	netdb.h \
	netgroup.h \
	pam/pam_appl.h \
	paths.h \
322
	poll.h \
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339
	pty.h \
	readpassphrase.h \
	rpc/types.h \
	security/pam_appl.h \
	sha2.h \
	shadow.h \
	stddef.h \
	stdint.h \
	string.h \
	strings.h \
	sys/audit.h \
	sys/bitypes.h \
	sys/bsdtty.h \
	sys/cdefs.h \
	sys/dir.h \
	sys/mman.h \
	sys/ndir.h \
340
	sys/poll.h \
341 342 343 344 345 346 347
	sys/prctl.h \
	sys/pstat.h \
	sys/select.h \
	sys/stat.h \
	sys/stream.h \
	sys/stropts.h \
	sys/strtio.h \
348
	sys/statvfs.h \
349 350 351 352 353 354
	sys/sysmacros.h \
	sys/time.h \
	sys/timers.h \
	time.h \
	tmpdir.h \
	ttyent.h \
Tim Rice's avatar
Tim Rice committed
355
	ucred.h \
356 357 358 359 360 361 362
	unistd.h \
	usersec.h \
	util.h \
	utime.h \
	utmp.h \
	utmpx.h \
	vis.h \
Tim Rice's avatar
Tim Rice committed
363
])
364 365

# lastlog.h requires sys/time.h to be included first on Solaris
Tim Rice's avatar
Tim Rice committed
366
AC_CHECK_HEADERS([lastlog.h], [], [], [
367 368 369 370 371 372
#ifdef HAVE_SYS_TIME_H
# include <sys/time.h>
#endif
])

# sys/ptms.h requires sys/stream.h to be included first on Solaris
Tim Rice's avatar
Tim Rice committed
373
AC_CHECK_HEADERS([sys/ptms.h], [], [], [
374 375 376 377 378 379
#ifdef HAVE_SYS_STREAM_H
# include <sys/stream.h>
#endif
])

# login_cap.h requires sys/types.h on NetBSD
Tim Rice's avatar
Tim Rice committed
380
AC_CHECK_HEADERS([login_cap.h], [], [], [
381 382 383
#include <sys/types.h>
])

384
# older BSDs need sys/param.h before sys/mount.h
Tim Rice's avatar
Tim Rice committed
385
AC_CHECK_HEADERS([sys/mount.h], [], [], [
386 387 388
#include <sys/param.h>
])

389 390
# Android requires sys/socket.h to be included before sys/un.h
AC_CHECK_HEADERS([sys/un.h], [], [], [
391
#include <sys/types.h>
392
#include <sys/socket.h>
393 394
])

395 396 397
# Messages for features tested for in target-specific section
SIA_MSG="no"
SPC_MSG="no"
398
SP_MSG="no"
399

400
# Check for some target-specific stuff
401
case "$host" in
402
*-*-aix*)
403 404 405 406 407
	# Some versions of VAC won't allow macro redefinitions at
	# -qlanglevel=ansi, and autoconf 2.60 sometimes insists on using that
	# particularly with older versions of vac or xlc.
	# It also throws errors about null macro argments, but these are
	# not fatal.
Tim Rice's avatar
Tim Rice committed
408
	AC_MSG_CHECKING([if compiler allows macro redefinitions])
409
	AC_COMPILE_IFELSE(
Tim Rice's avatar
Tim Rice committed
410
	    [AC_LANG_PROGRAM([[
411
#define testmacro foo
Tim Rice's avatar
Tim Rice committed
412 413 414 415
#define testmacro bar]],
	    [[ exit(0); ]])],
	    [ AC_MSG_RESULT([yes]) ],
	    [ AC_MSG_RESULT([no])
416 417 418 419 420 421 422
	      CC="`echo $CC | sed 's/-qlanglvl\=ansi//g'`"
	      LD="`echo $LD | sed 's/-qlanglvl\=ansi//g'`"
	      CFLAGS="`echo $CFLAGS | sed 's/-qlanglvl\=ansi//g'`"
	      CPPFLAGS="`echo $CPPFLAGS | sed 's/-qlanglvl\=ansi//g'`"
	    ]
	)

423
	AC_MSG_CHECKING([how to specify blibpath for linker ($LD)])
424
	if (test -z "$blibpath"); then
425
		blibpath="/usr/lib:/lib"
426 427
	fi
	saved_LDFLAGS="$LDFLAGS"
428 429 430 431 432 433
	if test "$GCC" = "yes"; then
		flags="-Wl,-blibpath: -Wl,-rpath, -blibpath:"
	else
		flags="-blibpath: -Wl,-blibpath: -Wl,-rpath,"
	fi
	for tryflags in $flags ;do
434 435
		if (test -z "$blibflags"); then
			LDFLAGS="$saved_LDFLAGS $tryflags$blibpath"
Tim Rice's avatar
Tim Rice committed
436 437
			AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
			[blibflags=$tryflags], [])
438 439 440
		fi
	done
	if (test -z "$blibflags"); then
Tim Rice's avatar
Tim Rice committed
441
		AC_MSG_RESULT([not found])
442 443
		AC_MSG_ERROR([*** must be able to specify blibpath on AIX - check config.log])
	else
Tim Rice's avatar
Tim Rice committed
444
		AC_MSG_RESULT([$blibflags])
445
	fi
446
	LDFLAGS="$saved_LDFLAGS"
447
	dnl Check for authenticate.  Might be in libs.a on older AIXes
Tim Rice's avatar
Tim Rice committed
448
	AC_CHECK_FUNC([authenticate], [AC_DEFINE([WITH_AIXAUTHENTICATE], [1],
449
		[Define if you want to enable AIX4's authenticate function])],
Tim Rice's avatar
Tim Rice committed
450 451
		[AC_CHECK_LIB([s], [authenticate],
			[ AC_DEFINE([WITH_AIXAUTHENTICATE])
452 453 454
				LIBS="$LIBS -ls"
			])
		])
455
	dnl Check for various auth function declarations in headers.
456
	AC_CHECK_DECLS([authenticate, loginrestrictions, loginsuccess,
457
	    passwdexpired, setauthdb], , , [#include <usersec.h>])
458
	dnl Check if loginfailed is declared and takes 4 arguments (AIX >= 5.2)
Tim Rice's avatar
Tim Rice committed
459 460 461 462 463 464 465 466 467 468 469
	AC_CHECK_DECLS([loginfailed],
	    [AC_MSG_CHECKING([if loginfailed takes 4 arguments])
	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <usersec.h> ]],
		[[ (void)loginfailed("user","host","tty",0); ]])],
		[AC_MSG_RESULT([yes])
		AC_DEFINE([AIX_LOGINFAILED_4ARG], [1],
			[Define if your AIX loginfailed() function
			takes 4 arguments (AIX >= 5.2)])], [AC_MSG_RESULT([no])
	    ])],
	    [],
	    [#include <usersec.h>]
470
	)
Tim Rice's avatar
Tim Rice committed
471 472 473
	AC_CHECK_FUNCS([getgrset setauthdb])
	AC_CHECK_DECL([F_CLOSEM],
	    AC_DEFINE([HAVE_FCNTL_CLOSEM], [1], [Use F_CLOSEM fcntl for closefrom]),
474 475 476 477
	    [],
	    [ #include <limits.h>
	      #include <fcntl.h> ]
	)
478
	check_for_aix_broken_getaddrinfo=1
Tim Rice's avatar
Tim Rice committed
479 480
	AC_DEFINE([BROKEN_REALPATH], [1], [Define if you have a broken realpath.])
	AC_DEFINE([SETEUID_BREAKS_SETUID], [1],
481
	    [Define if your platform breaks doing a seteuid before a setuid])
Tim Rice's avatar
Tim Rice committed
482 483
	AC_DEFINE([BROKEN_SETREUID], [1], [Define if your setreuid() is broken])
	AC_DEFINE([BROKEN_SETREGID], [1], [Define if your setregid() is broken])
484
	dnl AIX handles lastlog as part of its login message
Tim Rice's avatar
Tim Rice committed
485 486
	AC_DEFINE([DISABLE_LASTLOG], [1], [Define if you don't want to use lastlog])
	AC_DEFINE([LOGIN_NEEDS_UTMPX], [1],
487
		[Some systems need a utmpx entry for /bin/login to work])
Tim Rice's avatar
Tim Rice committed
488
	AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV],
489 490
		[Define to a Set Process Title type if your system is
		supported by bsd-setproctitle.c])
Tim Rice's avatar
Tim Rice committed
491
	AC_DEFINE([SSHPAM_CHAUTHTOK_NEEDS_RUID], [1],
492
	    [AIX 5.2 and 5.3 (and presumably newer) require this])
Tim Rice's avatar
Tim Rice committed
493
	AC_DEFINE([PTY_ZEROREAD], [1], [read(1) can return 0 for a non-closed fd])
494
	AC_DEFINE([PLATFORM_SYS_DIR_UID], 2, [System dirs owned by bin (uid 2)])
495
	;;
496 497 498 499
*-*-android*)
	AC_DEFINE([DISABLE_UTMP], [1], [Define if you don't want to use utmp])
	AC_DEFINE([DISABLE_WTMP], [1], [Define if you don't want to use wtmp])
	;;
500
*-*-cygwin*)
501
	check_for_libcrypt_later=1
502
	LIBS="$LIBS /usr/lib/textreadmode.o"
Tim Rice's avatar
Tim Rice committed
503 504 505
	AC_DEFINE([HAVE_CYGWIN], [1], [Define if you are on Cygwin])
	AC_DEFINE([USE_PIPES], [1], [Use PIPES instead of a socketpair()])
	AC_DEFINE([DISABLE_SHADOW], [1],
506
		[Define if you want to disable shadow passwords])
Tim Rice's avatar
Tim Rice committed
507
	AC_DEFINE([NO_X11_UNIX_SOCKETS], [1],
508
		[Define if X11 doesn't support AF_UNIX sockets on that system])
Tim Rice's avatar
Tim Rice committed
509
	AC_DEFINE([NO_IPPORT_RESERVED_CONCEPT], [1],
510 511
		[Define if the concept of ports only accessible to
		superusers isn't known])
Tim Rice's avatar
Tim Rice committed
512
	AC_DEFINE([DISABLE_FD_PASSING], [1],
513 514
		[Define if your platform needs to skip post auth
		file descriptor passing])
Tim Rice's avatar
Tim Rice committed
515 516
	AC_DEFINE([SSH_IOBUFSZ], [65535], [Windows is sensitive to read buffer size])
	AC_DEFINE([FILESYSTEM_NO_BACKSLASH], [1], [File names may not contain backslash characters]) 
517
	;;
518
*-*-dgux*)
Tim Rice's avatar
Tim Rice committed
519
	AC_DEFINE([IP_TOS_IS_BROKEN], [1],
520
		[Define if your system choked on IP TOS setting])
Tim Rice's avatar
Tim Rice committed
521 522 523
	AC_DEFINE([SETEUID_BREAKS_SETUID])
	AC_DEFINE([BROKEN_SETREUID])
	AC_DEFINE([BROKEN_SETREGID])
524
	;;
525
*-*-darwin*)
Tim Rice's avatar
Tim Rice committed
526 527
	AC_MSG_CHECKING([if we have working getaddrinfo])
	AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <mach-o/dyld.h>
528 529 530 531
main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
		exit(0);
	else
		exit(1);
Tim Rice's avatar
Tim Rice committed
532 533 534 535 536 537 538 539 540 541 542 543 544
}
			]])],
	[AC_MSG_RESULT([working])],
	[AC_MSG_RESULT([buggy])
	AC_DEFINE([BROKEN_GETADDRINFO], [1],
		[getaddrinfo is broken (if present)])
	],
	[AC_MSG_RESULT([assume it is working])])
	AC_DEFINE([SETEUID_BREAKS_SETUID])
	AC_DEFINE([BROKEN_SETREUID])
	AC_DEFINE([BROKEN_SETREGID])
	AC_DEFINE([BROKEN_GLOB], [1], [OS X glob does not do what we expect])
	AC_DEFINE_UNQUOTED([BIND_8_COMPAT], [1],
545
		[Define if your resolver libs need this for getrrsetbyname])
Tim Rice's avatar
Tim Rice committed
546 547
	AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
	AC_DEFINE([SSH_TUN_COMPAT_AF], [1],
548
	    [Use tunnel device compatibility to OpenBSD])
Tim Rice's avatar
Tim Rice committed
549
	AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
550
	    [Prepend the address family to IP tunnel traffic])
551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574
	AC_MSG_CHECKING([if we have the Security Authorization Session API])
	AC_TRY_COMPILE([#include <Security/AuthSession.h>],
		[SessionCreate(0, 0);],
		[ac_cv_use_security_session_api="yes"
		 AC_DEFINE([USE_SECURITY_SESSION_API], [1], 
			[platform has the Security Authorization Session API])
		 LIBS="$LIBS -framework Security"
		 AC_MSG_RESULT([yes])],
		[ac_cv_use_security_session_api="no"
		 AC_MSG_RESULT([no])])
	AC_MSG_CHECKING([if we have an in-memory credentials cache])
	AC_TRY_COMPILE(
		[#include <Kerberos/Kerberos.h>],
		[cc_context_t c;
		 (void) cc_initialize (&c, 0, NULL, NULL);],
		[AC_DEFINE([USE_CCAPI], [1], 
			[platform uses an in-memory credentials cache])
		 LIBS="$LIBS -framework Security"
		 AC_MSG_RESULT([yes])
		 if test "x$ac_cv_use_security_session_api" = "xno"; then
			AC_MSG_ERROR([*** Need a security framework to use the credentials cache API ***])
		fi],
		[AC_MSG_RESULT([no])]
	)
Tim Rice's avatar
Tim Rice committed
575 576 577
	m4_pattern_allow([AU_IPv])
	AC_CHECK_DECL([AU_IPv4], [], 
	    AC_DEFINE([AU_IPv4], [0], [System only supports IPv4 audit records])
578
	    [#include <bsm/audit.h>]
Tim Rice's avatar
Tim Rice committed
579
	AC_DEFINE([LASTLOG_WRITE_PUTUTXLINE], [1],
580
	    [Define if pututxline updates lastlog too])
581
	)
582 583 584
	AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV],
		[Define to a Set Process Title type if your system is
		supported by bsd-setproctitle.c])
585 586
	AC_CHECK_FUNCS([sandbox_init])
	AC_CHECK_HEADERS([sandbox.h])
587
	;;
588 589 590
*-*-dragonfly*)
	SSHDLIBS="$SSHDLIBS -lcrypt"
	;;
591 592
*-*-haiku*) 
    LIBS="$LIBS -lbsd "
Tim Rice's avatar
Tim Rice committed
593 594
    AC_CHECK_LIB([network], [socket])
    AC_DEFINE([HAVE_U_INT64_T])
595 596
    MANTYPE=man 
    ;; 
597 598
*-*-hpux*)
	# first we define all of the options common to all HP-UX releases
599
	CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
600
	IPADDR_IN_DISPLAY=yes
Tim Rice's avatar
Tim Rice committed
601 602
	AC_DEFINE([USE_PIPES])
	AC_DEFINE([LOGIN_NO_ENDOPT], [1],
603
	    [Define if your login program cannot handle end of options ("--")])
Tim Rice's avatar
Tim Rice committed
604 605
	AC_DEFINE([LOGIN_NEEDS_UTMPX])
	AC_DEFINE([LOCKED_PASSWD_STRING], ["*"],
606
		[String used in /etc/passwd to denote locked account])
Tim Rice's avatar
Tim Rice committed
607
	AC_DEFINE([SPT_TYPE], [SPT_PSTAT])
608
	AC_DEFINE([PLATFORM_SYS_DIR_UID], 2, [System dirs owned by bin (uid 2)])
609
	maildir="/var/mail"
610
	LIBS="$LIBS -lsec"
Tim Rice's avatar
Tim Rice committed
611 612
	AC_CHECK_LIB([xnet], [t_error], ,
	    [AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***])])
613 614 615 616 617 618 619 620 621

	# next, we define all of the options specific to major releases
	case "$host" in
	*-*-hpux10*)
		if test -z "$GCC"; then
			CFLAGS="$CFLAGS -Ae"
		fi
		;;
	*-*-hpux11*)
Tim Rice's avatar
Tim Rice committed
622
		AC_DEFINE([PAM_SUN_CODEBASE], [1],
623 624 625
			[Define if you are using Solaris-derived PAM which
			passes pam_messages to the conversation function
			with an extra level of indirection])
Tim Rice's avatar
Tim Rice committed
626
		AC_DEFINE([DISABLE_UTMP], [1],
627
			[Define if you don't want to use utmp])
Tim Rice's avatar
Tim Rice committed
628
		AC_DEFINE([USE_BTMP], [1], [Use btmp to log bad logins])
629 630 631 632 633 634 635 636
		check_for_hpux_broken_getaddrinfo=1
		check_for_conflicting_getspnam=1
		;;
	esac

	# lastly, we define options specific to minor releases
	case "$host" in
	*-*-hpux10.26)
Tim Rice's avatar
Tim Rice committed
637
		AC_DEFINE([HAVE_SECUREWARE], [1],
638 639
			[Define if you have SecureWare-based
			protected password database])
640 641 642 643
		disable_ptmx_check=yes
		LIBS="$LIBS -lsecpw"
		;;
	esac
644
	;;
645
*-*-irix5*)
646
	PATH="$PATH:/usr/etc"
Tim Rice's avatar
Tim Rice committed
647
	AC_DEFINE([BROKEN_INET_NTOA], [1],
648 649
		[Define if you system's inet_ntoa is busted
		(e.g. Irix gcc issue)])
Tim Rice's avatar
Tim Rice committed
650 651 652 653
	AC_DEFINE([SETEUID_BREAKS_SETUID])
	AC_DEFINE([BROKEN_SETREUID])
	AC_DEFINE([BROKEN_SETREGID])
	AC_DEFINE([WITH_ABBREV_NO_TTY], [1],
654 655
		[Define if you shouldn't strip 'tty' from your
		ttyname in [uw]tmp])
Tim Rice's avatar
Tim Rice committed
656
	AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
657 658
	;;
*-*-irix6*)
659
	PATH="$PATH:/usr/etc"
Tim Rice's avatar
Tim Rice committed
660
	AC_DEFINE([WITH_IRIX_ARRAY], [1],
661 662
		[Define if you have/want arrays
		(cluster-wide session managment, not C arrays)])
Tim Rice's avatar
Tim Rice committed
663
	AC_DEFINE([WITH_IRIX_PROJECT], [1],
664
		[Define if you want IRIX project management])
Tim Rice's avatar
Tim Rice committed
665
	AC_DEFINE([WITH_IRIX_AUDIT], [1],
666
		[Define if you want IRIX audit trails])
Tim Rice's avatar
Tim Rice committed
667
	AC_CHECK_FUNC([jlimit_startjob], [AC_DEFINE([WITH_IRIX_JOBS], [1],
668
		[Define if you want IRIX kernel jobs])])
Tim Rice's avatar
Tim Rice committed
669 670 671 672 673 674 675
	AC_DEFINE([BROKEN_INET_NTOA])
	AC_DEFINE([SETEUID_BREAKS_SETUID])
	AC_DEFINE([BROKEN_SETREUID])
	AC_DEFINE([BROKEN_SETREGID])
	AC_DEFINE([BROKEN_UPDWTMPX], [1], [updwtmpx is broken (if present)])
	AC_DEFINE([WITH_ABBREV_NO_TTY])
	AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
676
	;;
677 678
*-*-k*bsd*-gnu | *-*-kopensolaris*-gnu)
	check_for_libcrypt_later=1
Tim Rice's avatar
Tim Rice committed
679 680 681 682 683
	AC_DEFINE([PAM_TTY_KLUDGE])
	AC_DEFINE([LOCKED_PASSWD_PREFIX], ["!"])
	AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
	AC_DEFINE([_PATH_BTMP], ["/var/log/btmp"], [log for bad login attempts])
	AC_DEFINE([USE_BTMP], [1], [Use btmp to log bad logins])
684
	;;
685 686
*-*-linux*)
	no_dev_ptmx=1
687
	check_for_libcrypt_later=1
688
	check_for_openpty_ctty_bug=1
Tim Rice's avatar
Tim Rice committed
689
	AC_DEFINE([PAM_TTY_KLUDGE], [1],
690
		[Work around problematic Linux PAM modules handling of PAM_TTY])
Tim Rice's avatar
Tim Rice committed
691
	AC_DEFINE([LOCKED_PASSWD_PREFIX], ["!"],
692
		[String used in /etc/passwd to denote locked account])
Tim Rice's avatar
Tim Rice committed
693 694
	AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
	AC_DEFINE([LINK_OPNOTSUPP_ERRNO], [EPERM],
695 696
		[Define to whatever link() returns for "not supported"
		if it doesn't return EOPNOTSUPP.])
Tim Rice's avatar
Tim Rice committed
697 698 699
	AC_DEFINE([_PATH_BTMP], ["/var/log/btmp"], [log for bad login attempts])
	AC_DEFINE([USE_BTMP])
	AC_DEFINE([LINUX_OOM_ADJUST], [1], [Adjust Linux out-of-memory killer])
700
	inet6_default_4in6=yes
701
	case `uname -r` in
702
	1.*|2.0.*)
Tim Rice's avatar
Tim Rice committed
703
		AC_DEFINE([BROKEN_CMSG_TYPE], [1],
704
			[Define if cmsg_type is not passed correctly])
705 706
		;;
	esac
707
	# tun(4) forwarding compat code
Tim Rice's avatar
Tim Rice committed
708
	AC_CHECK_HEADERS([linux/if_tun.h])
709
	if test "x$ac_cv_header_linux_if_tun_h" = "xyes" ; then
Tim Rice's avatar
Tim Rice committed
710
		AC_DEFINE([SSH_TUN_LINUX], [1],
711
		    [Open tunnel devices the Linux tun/tap way])
Tim Rice's avatar
Tim Rice committed
712
		AC_DEFINE([SSH_TUN_COMPAT_AF], [1],
713
		    [Use tunnel device compatibility to OpenBSD])
Tim Rice's avatar
Tim Rice committed
714
		AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
715 716
		    [Prepend the address family to IP tunnel traffic])
	fi
717 718
	AC_CHECK_HEADERS([linux/seccomp.h linux/filter.h linux/audit.h], [],
	    [], [#include <linux/types.h>])
719
	AC_CHECK_FUNCS([prctl])
720 721
	AC_MSG_CHECKING([for seccomp architecture])
	seccomp_audit_arch=
722 723
	case "$host" in
	x86_64-*)
724
		seccomp_audit_arch=AUDIT_ARCH_X86_64
725 726
		;;
	i*86-*)
727
		seccomp_audit_arch=AUDIT_ARCH_I386
728
		;;
729 730 731
        arm*-*)
		seccomp_audit_arch=AUDIT_ARCH_ARM
                ;;
732
	esac
733 734 735 736 737 738 739
	if test "x$seccomp_audit_arch" != "x" ; then
		AC_MSG_RESULT(["$seccomp_audit_arch"])
                AC_DEFINE_UNQUOTED([SECCOMP_AUDIT_ARCH], [$seccomp_audit_arch],
                    [Specify the system call convention in use])
	else
		AC_MSG_RESULT([architecture not supported])
	fi
740
	;;
741
mips-sony-bsd|mips-sony-newsos4)
Tim Rice's avatar
Tim Rice committed
742
	AC_DEFINE([NEED_SETPGRP], [1], [Need setpgrp to acquire controlling tty])
743 744
	SONY=1
	;;
745
*-*-netbsd*)
746
	check_for_libcrypt_before=1
747
	if test "x$withval" != "xno" ; then
748 749
		need_dash_r=1
	fi
Tim Rice's avatar
Tim Rice committed
750
	AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
751
	AC_CHECK_HEADER([net/if_tap.h], ,
Tim Rice's avatar
Tim Rice committed
752 753
	    AC_DEFINE([SSH_TUN_NO_L2], [1], [No layer 2 tunnel support]))
	AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
754
	    [Prepend the address family to IP tunnel traffic])
755
	;;
756 757
*-*-freebsd*)
	check_for_libcrypt_later=1
Tim Rice's avatar
Tim Rice committed
758 759
	AC_DEFINE([LOCKED_PASSWD_PREFIX], ["*LOCKED*"], [Account locked with pw(1)])
	AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
760
	AC_CHECK_HEADER([net/if_tap.h], ,
Tim Rice's avatar
Tim Rice committed
761 762
	    AC_DEFINE([SSH_TUN_NO_L2], [1], [No layer 2 tunnel support]))
	AC_DEFINE([BROKEN_GLOB], [1], [FreeBSD glob does not do what we need])
763
	AC_DEFINE([BROKEN_STRNVIS], [1], [FreeBSD strnvis does not do what we need])
764
	;;
765
*-*-bsdi*)
Tim Rice's avatar
Tim Rice committed
766 767 768
	AC_DEFINE([SETEUID_BREAKS_SETUID])
	AC_DEFINE([BROKEN_SETREUID])
	AC_DEFINE([BROKEN_SETREGID])
769
	;;
770 771
*-next-*)
	conf_lastlog_location="/usr/adm/lastlog"
772 773
	conf_utmp_location=/etc/utmp
	conf_wtmp_location=/usr/adm/wtmp
774
	maildir=/usr/spool/mail
Tim Rice's avatar
Tim Rice committed
775 776 777 778
	AC_DEFINE([HAVE_NEXT], [1], [Define if you are on NeXT])
	AC_DEFINE([BROKEN_REALPATH])
	AC_DEFINE([USE_PIPES])
	AC_DEFINE([BROKEN_SAVED_UIDS], [1], [Needed for NeXT])
779
	;;
780
*-*-openbsd*)
Tim Rice's avatar
Tim Rice committed
781 782 783 784
	AC_DEFINE([HAVE_ATTRIBUTE__SENTINEL__], [1], [OpenBSD's gcc has sentinel])
	AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD's gcc has bounded])
	AC_DEFINE([SSH_TUN_OPENBSD], [1], [Open tunnel devices the OpenBSD way])
	AC_DEFINE([SYSLOG_R_SAFE_IN_SIGHAND], [1],
785
	    [syslog_r function is safe to use in in a signal handler])
786
	;;
787
*-*-solaris*)
788
	if test "x$withval" != "xno" ; then
789 790
		need_dash_r=1
	fi
Tim Rice's avatar
Tim Rice committed
791 792 793
	AC_DEFINE([PAM_SUN_CODEBASE])
	AC_DEFINE([LOGIN_NEEDS_UTMPX])
	AC_DEFINE([LOGIN_NEEDS_TERM], [1],
794 795
		[Some versions of /bin/login need the TERM supplied
		on the commandline])
Tim Rice's avatar
Tim Rice committed
796 797
	AC_DEFINE([PAM_TTY_KLUDGE])
	AC_DEFINE([SSHPAM_CHAUTHTOK_NEEDS_RUID], [1],
798 799
		[Define if pam_chauthtok wants real uid set
		to the unpriv'ed user])
Tim Rice's avatar
Tim Rice committed
800
	AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
801
	# Pushing STREAMS modules will cause sshd to acquire a controlling tty.
Tim Rice's avatar
Tim Rice committed
802
	AC_DEFINE([SSHD_ACQUIRES_CTTY], [1],
803 804
		[Define if sshd somehow reacquires a controlling TTY
		after setsid()])
Tim Rice's avatar
Tim Rice committed
805
	AC_DEFINE([PASSWD_NEEDS_USERNAME], [1], [must supply username to passwd
806
		in case the name is longer than 8 chars])
Tim Rice's avatar
Tim Rice committed
807
	AC_DEFINE([BROKEN_TCGETATTR_ICANON], [1], [tcgetattr with ICANON may hang])
808
	external_path_file=/etc/default/login
andre's avatar
andre committed
809 810
	# hardwire lastlog location (can't detect it on some versions)
	conf_lastlog_location="/var/adm/lastlog"
Tim Rice's avatar
Tim Rice committed
811
	AC_MSG_CHECKING([for obsolete utmp and wtmp in solaris2.x])
812 813
	sol2ver=`echo "$host"| sed -e 's/.*[[0-9]]\.//'`
	if test "$sol2ver" -ge 8; then
Tim Rice's avatar
Tim Rice committed
814 815 816
		AC_MSG_RESULT([yes])
		AC_DEFINE([DISABLE_UTMP])
		AC_DEFINE([DISABLE_WTMP], [1],
817
			[Define if you don't want to use wtmp])
818
	else
Tim Rice's avatar
Tim Rice committed
819
		AC_MSG_RESULT([no])
820
	fi
Tim Rice's avatar
Tim Rice committed
821
	AC_ARG_WITH([solaris-contracts],
822 823
		[  --with-solaris-contracts Enable Solaris process contracts (experimental)],
		[
Tim Rice's avatar
Tim Rice committed
824 825
		AC_CHECK_LIB([contract], [ct_tmpl_activate],
			[ AC_DEFINE([USE_SOLARIS_PROCESS_CONTRACTS], [1],
826 827 828 829 830
				[Define if you have Solaris process contracts])
			  SSHDLIBS="$SSHDLIBS -lcontract"
			  SPC_MSG="yes" ], )
		],
	)
Tim Rice's avatar
Tim Rice committed
831
	AC_ARG_WITH([solaris-projects],
832 833
		[  --with-solaris-projects Enable Solaris projects (experimental)],
		[
Tim Rice's avatar
Tim Rice committed
834 835
		AC_CHECK_LIB([project], [setproject],
			[ AC_DEFINE([USE_SOLARIS_PROJECTS], [1],
836 837 838 839 840
				[Define if you have Solaris projects])
			SSHDLIBS="$SSHDLIBS -lproject"
			SP_MSG="yes" ], )
		],
	)
841
	TEST_SHELL=$SHELL	# let configure find us a capable shell
842
	;;
843
*-*-sunos4*)
844
	CPPFLAGS="$CPPFLAGS -DSUNOS4"
Tim Rice's avatar
Tim Rice committed
845 846
	AC_CHECK_FUNCS([getpwanam])
	AC_DEFINE([PAM_SUN_CODEBASE])
847 848 849
	conf_utmp_location=/etc/utmp
	conf_wtmp_location=/var/adm/wtmp
	conf_lastlog_location=/var/adm/lastlog
Tim Rice's avatar
Tim Rice committed
850
	AC_DEFINE([USE_PIPES])
851
	;;
852
*-ncr-sysv*)
853
	LIBS="$LIBS -lc89"
Tim Rice's avatar
Tim Rice committed
854 855 856 857 858
	AC_DEFINE([USE_PIPES])
	AC_DEFINE([SSHD_ACQUIRES_CTTY])
	AC_DEFINE([SETEUID_BREAKS_SETUID])
	AC_DEFINE([BROKEN_SETREUID])
	AC_DEFINE([BROKEN_SETREGID])
859
	;;
860
*-sni-sysv*)
861
	# /usr/ucblib MUST NOT be searched on ReliantUNIX
Tim Rice's avatar
Tim Rice committed
862
	AC_CHECK_LIB([dl], [dlsym], ,)
863
	# -lresolv needs to be at the end of LIBS or DNS lookups break
Tim Rice's avatar
Tim Rice committed
864
	AC_CHECK_LIB([resolv], [res_query], [ LIBS="$LIBS -lresolv" ])
Damien Miller's avatar
Damien Miller committed
865
	IPADDR_IN_DISPLAY=yes
Tim Rice's avatar
Tim Rice committed
866 867 868 869 870 871
	AC_DEFINE([USE_PIPES])
	AC_DEFINE([IP_TOS_IS_BROKEN])
	AC_DEFINE([SETEUID_BREAKS_SETUID])
	AC_DEFINE([BROKEN_SETREUID])
	AC_DEFINE([BROKEN_SETREGID])
	AC_DEFINE([SSHD_ACQUIRES_CTTY])
872
	external_path_file=/etc/default/login
873 874 875
	# /usr/ucblib/libucb.a no longer needed on ReliantUNIX
	# Attention: always take care to bind libsocket and libnsl before libc,
	# otherwise you will find lots of "SIOCGPGRP errno 22" on syslog
876
	;;
877
# UnixWare 1.x, UnixWare 2.x, and others based on code from Univel.
878
*-*-sysv4.2*)
Tim Rice's avatar
Tim Rice committed
879 880 881 882 883 884
	AC_DEFINE([USE_PIPES])
	AC_DEFINE([SETEUID_BREAKS_SETUID])
	AC_DEFINE([BROKEN_SETREUID])
	AC_DEFINE([BROKEN_SETREGID])
	AC_DEFINE([PASSWD_NEEDS_USERNAME], [1], [must supply username to passwd])
	AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
885
	TEST_SHELL=$SHELL	# let configure find us a capable shell
886
	;;
887
# UnixWare 7.x, OpenUNIX 8
888
*-*-sysv5*)
889
	CPPFLAGS="$CPPFLAGS -Dvsnprintf=_xvsnprintf -Dsnprintf=_xsnprintf"
Tim Rice's avatar
Tim Rice committed
890 891 892 893 894 895 896
	AC_DEFINE([UNIXWARE_LONG_PASSWORDS], [1], [Support passwords > 8 chars])
	AC_DEFINE([USE_PIPES])
	AC_DEFINE([SETEUID_BREAKS_SETUID])
	AC_DEFINE([BROKEN_GETADDRINFO])
	AC_DEFINE([BROKEN_SETREUID])
	AC_DEFINE([BROKEN_SETREGID])
	AC_DEFINE([PASSWD_NEEDS_USERNAME])
897
	TEST_SHELL=$SHELL	# let configure find us a capable shell
898 899
	case "$host" in
	*-*-sysv5SCO_SV*)	# SCO OpenServer 6.x
900
		maildir=/var/spool/mail
Tim Rice's avatar
Tim Rice committed
901
		AC_DEFINE([BROKEN_LIBIAF], [1],
902
			[ia_uinfo routines not supported by OS yet])
Tim Rice's avatar
Tim Rice committed
903 904 905 906 907 908
		AC_DEFINE([BROKEN_UPDWTMPX])
		AC_CHECK_LIB([prot], [getluid], [ LIBS="$LIBS -lprot"
			AC_CHECK_FUNCS([getluid setluid], , , [-lprot])
			AC_DEFINE([HAVE_SECUREWARE])
			AC_DEFINE([DISABLE_SHADOW])
			], , )
909
		;;
Tim Rice's avatar
Tim Rice committed
910
	*)	AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
911
		check_for_libcrypt_later=1
912
		;;
913
	esac
914
	;;
915 916
*-*-sysv*)
	;;
917
# SCO UNIX and OEM versions of SCO UNIX
918
*-*-sco3.2v4*)
919
	AC_MSG_ERROR("This Platform is no longer supported.")
920
	;;
921
# SCO OpenServer 5.x
922
*-*-sco3.2v5*)
923 924 925
	if test -z "$GCC"; then
		CFLAGS="$CFLAGS -belf"
	fi
926
	LIBS="$LIBS -lprot -lx -ltinfo -lm"
927
	no_dev_ptmx=1
Tim Rice's avatar
Tim Rice committed
928 929 930 931 932 933 934 935 936 937 938 939
	AC_DEFINE([USE_PIPES])
	AC_DEFINE([HAVE_SECUREWARE])
	AC_DEFINE([DISABLE_SHADOW])
	AC_DEFINE([DISABLE_FD_PASSING])
	AC_DEFINE([SETEUID_BREAKS_SETUID])
	AC_DEFINE([BROKEN_GETADDRINFO])
	AC_DEFINE([BROKEN_SETREUID])
	AC_DEFINE([BROKEN_SETREGID])
	AC_DEFINE([WITH_ABBREV_NO_TTY])
	AC_DEFINE([BROKEN_UPDWTMPX])
	AC_DEFINE([PASSWD_NEEDS_USERNAME])
	AC_CHECK_FUNCS([getluid setluid])
940
	MANTYPE=man
941
	TEST_SHELL=$SHELL	# let configure find us a capable shell
942
	SKIP_DISABLE_LASTLOG_DEFINE=yes
943
	;;
944
*-*-unicosmk*)
Tim Rice's avatar
Tim Rice committed
945
	AC_DEFINE([NO_SSH_LASTLOG], [1],
946
		[Define if you don't want to use lastlog in session.c])
Tim Rice's avatar
Tim Rice committed
947 948 949 950 951
	AC_DEFINE([SETEUID_BREAKS_SETUID])
	AC_DEFINE([BROKEN_SETREUID])
	AC_DEFINE([BROKEN_SETREGID])
	AC_DEFINE([USE_PIPES])
	AC_DEFINE([DISABLE_FD_PASSING])
952 953 954
	LDFLAGS="$LDFLAGS"
	LIBS="$LIBS -lgen -lrsc -lshare -luex -lacm"
	MANTYPE=cat
955
	;;
956
*-*-unicosmp*)
Tim Rice's avatar
Tim Rice committed
957 958 959 960 961 962
	AC_DEFINE([SETEUID_BREAKS_SETUID])
	AC_DEFINE([BROKEN_SETREUID])
	AC_DEFINE([BROKEN_SETREGID])
	AC_DEFINE([WITH_ABBREV_NO_TTY])
	AC_DEFINE([USE_PIPES])
	AC_DEFINE([DISABLE_FD_PASSING])
963
	LDFLAGS="$LDFLAGS"
964
	LIBS="$LIBS -lgen -lacid -ldb"
965 966
	MANTYPE=cat
	;;
967
*-*-unicos*)
Tim Rice's avatar
Tim Rice committed
968 969 970 971 972 973
	AC_DEFINE([SETEUID_BREAKS_SETUID])
	AC_DEFINE([BROKEN_SETREUID])
	AC_DEFINE([BROKEN_SETREGID])
	AC_DEFINE([USE_PIPES])
	AC_DEFINE([DISABLE_FD_PASSING])
	AC_DEFINE([NO_SSH_LASTLOG])
974 975 976
	LDFLAGS="$LDFLAGS -Wl,-Dmsglevel=334:fatal"
	LIBS="$LIBS -lgen -lrsc -lshare -luex -lacm"
	MANTYPE=cat
977
	;;
978
*-dec-osf*)
Tim Rice's avatar
Tim Rice committed
979
	AC_MSG_CHECKING([for Digital Unix SIA])
980
	no_osfsia=""
Tim Rice's avatar
Tim Rice committed
981
	AC_ARG_WITH([osfsia],
982 983 984
		[  --with-osfsia           Enable Digital Unix SIA],
		[
			if test "x$withval" = "xno" ; then
Tim Rice's avatar
Tim Rice committed
985
				AC_MSG_RESULT([disabled])
986 987 988 989 990
				no_osfsia=1
			fi
		],
	)
	if test -z "$no_osfsia" ; then
991
		if test -f /etc/sia/matrix.conf; then
Tim Rice's avatar
Tim Rice committed
992 993
			AC_MSG_RESULT([yes])
			AC_DEFINE([HAVE_OSF_SIA], [1],
994 995
				[Define if you have Digital Unix Security
				Integration Architecture])
Tim Rice's avatar
Tim Rice committed
996
			AC_DEFINE([DISABLE_LOGIN], [1],
997 998
				[Define if you don't want to use your
				system's login() call])
Tim Rice's avatar
Tim Rice committed
999
			AC_DEFINE([DISABLE_FD_PASSING])
1000
			LIBS="$LIBS -lsecurity -ldb -lm -laud"
1001
			SIA_MSG="yes"
1002
		else
Tim Rice's avatar
Tim Rice committed
1003 1004
			AC_MSG_RESULT([no])
			AC_DEFINE([LOCKED_PASSWD_SUBSTR], ["Nologin"],
1005
			  [String used in /etc/passwd to denote locked account])
1006 1007
		fi
	fi
Tim Rice's avatar
Tim Rice committed
1008 1009 1010 1011 1012
	AC_DEFINE([BROKEN_GETADDRINFO])
	AC_DEFINE([SETEUID_BREAKS_SETUID])
	AC_DEFINE([BROKEN_SETREUID])
	AC_DEFINE([BROKEN_SETREGID])
	AC_DEFINE([BROKEN_READV_COMPARISON], [1], [Can't do comparisons on readv])
1013
	;;
1014

1015
*-*-nto-qnx*)
Tim Rice's avatar
Tim Rice committed
1016 1017 1018 1019 1020
	AC_DEFINE([USE_PIPES])
	AC_DEFINE([NO_X11_UNIX_SOCKETS])
	AC_DEFINE([DISABLE_LASTLOG])
	AC_DEFINE([SSHD_ACQUIRES_CTTY])
	AC_DEFINE([BROKEN_SHADOW_EXPIRE], [1], [QNX shadow support is broken])
1021
	enable_etc_default_login=no	# has incompatible /etc/default/login
1022 1023
	case "$host" in
	*-*-nto-qnx6*)
Tim Rice's avatar
Tim Rice committed
1024
		AC_DEFINE([DISABLE_FD_PASSING])
1025 1026
		;;
	esac
1027
	;;
1028 1029

*-*-ultrix*)
Tim Rice's avatar
Tim Rice committed
1030 1031 1032 1033
	AC_DEFINE([BROKEN_GETGROUPS], [1], [getgroups(0,NULL) will return -1])
	AC_DEFINE([BROKEN_MMAP], [1], [Ultrix mmap can't map files])
	AC_DEFINE([NEED_SETPGRP])
	AC_DEFINE([HAVE_SYS_SYSLOG_H], [1], [Force use of sys/syslog.h on Ultrix])
1034
	;;
1035 1036 1037

*-*-lynxos)
        CFLAGS="$CFLAGS -D__NO_INCLUDE_WARN__"
Tim Rice's avatar
Tim Rice committed
1038
        AC_DEFINE([BROKEN_SETVBUF], [1], [LynxOS has broken setvbuf() implementation])
1039
        ;;
1040 1041
esac

Tim Rice's avatar
Tim Rice committed
1042 1043 1044
AC_MSG_CHECKING([compiler and flags for sanity])
AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]], [[ exit(0); ]])],
	[	AC_MSG_RESULT([yes]) ],
1045
	[
Tim Rice's avatar
Tim Rice committed
1046
		AC_MSG_RESULT([no])
1047
		AC_MSG_ERROR([*** compiler cannot create working executables, check config.log ***])
1048 1049
	],
	[	AC_MSG_WARN([cross compiling: not checking compiler sanity]) ]
1050 1051
)

1052
dnl Checks for header files.
1053
# Checks for libraries.
Tim Rice's avatar
Tim Rice committed
1054 1055
AC_CHECK_FUNC([yp_match], , [AC_CHECK_LIB([nsl], [yp_match])])
AC_CHECK_FUNC([setsockopt], , [AC_CHECK_LIB([socket], [setsockopt])])
1056

1057
dnl IRIX and Solaris 2.5.1 have dirname() in libgen
Tim Rice's avatar
Tim Rice committed
1058 1059
AC_CHECK_FUNCS([dirname], [AC_CHECK_HEADERS([libgen.h])] , [
	AC_CHECK_LIB([gen], [dirname], [
1060 1061 1062 1063
		AC_CACHE_CHECK([for broken dirname],
			ac_cv_have_broken_dirname, [
			save_LIBS="$LIBS"
			LIBS="$LIBS -lgen"
1064 1065
			AC_RUN_IFELSE(
				[AC_LANG_SOURCE([[
1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079
#include <libgen.h>
#include <string.h>

int main(int argc, char **argv) {
    char *s, buf[32];

    strncpy(buf,"/etc", 32);
    s = dirname(buf);
    if (!s || strncmp(s, "/", 32) != 0) {
	exit(1);
    } else {
	exit(0);
    }
}
1080 1081 1082
				]])],
				[ ac_cv_have_broken_dirname="no" ],
				[ ac_cv_have_broken_dirname="yes" ],
1083 1084 1085 1086 1087 1088
				[ ac_cv_have_broken_dirname="no" ],
			)
			LIBS="$save_LIBS"
		])
		if test "x$ac_cv_have_broken_dirname" = "xno" ; then
			LIBS="$LIBS -lgen"
Tim Rice's avatar
Tim Rice committed
1089 1090
			AC_DEFINE([HAVE_DIRNAME])
			AC_CHECK_HEADERS([libgen.h])
1091 1092 1093 1094
		fi
	])
])

Tim Rice's avatar
Tim Rice committed
1095 1096 1097 1098
AC_CHECK_FUNC([getspnam], ,
	[AC_CHECK_LIB([gen], [getspnam], [LIBS="$LIBS -lgen"])])
AC_SEARCH_LIBS([basename], [gen], [AC_DEFINE([HAVE_BASENAME], [1],
	[Define if you have the basename function.])])
1099

1100
dnl zlib is required
Tim Rice's avatar
Tim Rice committed
1101
AC_ARG_WITH([zlib],
1102
	[  --with-zlib=PATH        Use zlib in PATH],
1103 1104 1105
	[ if test "x$withval" = "xno" ; then
		AC_MSG_ERROR([*** zlib is required ***])
	  elif test "x$withval" != "xyes"; then
1106 1107
		if test -d "$withval/lib"; then
			if test -n "${need_dash_r}"; then
1108
				LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
1109
			else
1110
				LDFLAGS="-L${withval}/lib ${LDFLAGS}"
1111 1112 1113
			fi
		else
			if test -n "${need_dash_r}"; then
1114
				LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
1115
			else
1116
				LDFLAGS="-L${withval} ${LDFLAGS}"
1117 1118 1119
			fi
		fi
		if test -d "$withval/include"; then
1120
			CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
1121
		else
1122
			CPPFLAGS="-I${withval} ${CPPFLAGS}"
1123
		fi
1124
	fi ]
1125 1126
)

Tim Rice's avatar
Tim Rice committed
1127 1128
AC_CHECK_HEADER([zlib.h], ,[AC_MSG_ERROR([*** zlib.h missing - please install first or check config.log ***])])
AC_CHECK_LIB([z], [deflate], ,
1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140
	[
		saved_CPPFLAGS="$CPPFLAGS"
		saved_LDFLAGS="$LDFLAGS"
		save_LIBS="$LIBS"
		dnl Check default zlib install dir
		if test -n "${need_dash_r}"; then
			LDFLAGS="-L/usr/local/lib -R/usr/local/lib ${saved_LDFLAGS}"
		else
			LDFLAGS="-L/usr/local/lib ${saved_LDFLAGS}"
		fi
		CPPFLAGS="-I/usr/local/include ${saved_CPPFLAGS}"
		LIBS="$LIBS -lz"
Tim Rice's avatar
Tim Rice committed
1141
		AC_TRY_LINK_FUNC([deflate], [AC_DEFINE([HAVE_LIBZ])],
1142 1143 1144 1145 1146 1147
			[
				AC_MSG_ERROR([*** zlib missing - please install first or check config.log ***])
			]
		)
	]
)
1148

Tim Rice's avatar
Tim Rice committed
1149
AC_ARG_WITH([zlib-version-check],
1150 1151 1152 1153 1154 1155 1156
	[  --without-zlib-version-check Disable zlib version check],
	[  if test "x$withval" = "xno" ; then
		zlib_check_nonfatal=1
	   fi
	]
)

Tim Rice's avatar
Tim Rice committed
1157 1158
AC_MSG_CHECKING([for possibly buggy zlib])
AC_RUN_IFELSE([AC_LANG_PROGRAM([[
1159
#include <stdio.h>
1160
#include <stdlib.h>
1161
#include <zlib.h>
Tim Rice's avatar
Tim Rice committed
1162 1163
	]],
	[[
1164 1165 1166
	int a=0, b=0, c=0, d=0, n, v;
	n = sscanf(ZLIB_VERSION, "%d.%d.%d.%d", &a, &b, &c, &d);
	if (n != 3 && n != 4)
1167
		exit(1);
1168 1169 1170 1171 1172
	v = a*1000000 + b*10000 + c*100 + d;
	fprintf(stderr, "found zlib version %s (%d)\n", ZLIB_VERSION, v);

	/* 1.1.4 is OK */
	if (a == 1 && b == 1 && c >= 4)
1173
		exit(0);
1174

1175 1176
	/* 1.2.3 and up are OK */
	if (v >= 1020300)
1177 1178
		exit(0);

1179
	exit(2);
1180
	]])],
Tim Rice's avatar
Tim Rice committed
1181 1182
	AC_MSG_RESULT([no]),
	[ AC_MSG_RESULT([yes])
1183 1184 1185 1186 1187 1188
	  if test -z "$zlib_check_nonfatal" ; then
		AC_MSG_ERROR([*** zlib too old - check config.log ***
Your reported zlib version has known security problems.  It's possible your
vendor has fixed these problems without changing the version number.  If you
are sure this is the case, you can disable the check by running
"./configure --without-zlib-version-check".
1189
If you are in doubt, upgrade zlib to version 1.2.3 or greater.
1190
See http://www.gzip.org/zlib/ for details.])
1191 1192 1193
	  else
		AC_MSG_WARN([zlib version may have security problems])
	  fi
1194 1195
	],
	[	AC_MSG_WARN([cross compiling: not checking zlib version]) ]
1196
)
1197

1198
dnl UnixWare 2.x
Tim Rice's avatar
Tim Rice committed
1199 1200
AC_CHECK_FUNC([strcasecmp],
	[], [ AC_CHECK_LIB([resolv], [strcasecmp], [LIBS="$LIBS -lresolv"]) ]
1201
)
Tim Rice's avatar
Tim Rice committed
1202 1203
AC_CHECK_FUNCS([utimes],
	[], [ AC_CHECK_LIB([c89], [utimes], [AC_DEFINE([HAVE_UTIMES])
1204
					LIBS="$LIBS -lc89"]) ]
1205
)
1206

1207
dnl    Checks for libutil functions
1208
AC_CHECK_HEADERS([bsd/libutil.h libutil.h])
1209
AC_SEARCH_LIBS([fmt_scaled], [util bsd])
1210
AC_SEARCH_LIBS([scan_scaled], [util bsd])
1211 1212 1213 1214 1215
AC_SEARCH_LIBS([login], [util bsd])
AC_SEARCH_LIBS([logout], [util bsd])
AC_SEARCH_LIBS([logwtmp], [util bsd])
AC_SEARCH_LIBS([openpty], [util bsd])
AC_SEARCH_LIBS([updwtmp], [util bsd])
1216
AC_CHECK_FUNCS([fmt_scaled scan_scaled login logout openpty updwtmp logwtmp])
1217

1218 1219
AC_FUNC_STRFTIME

1220
# Check for ALTDIRFUNC glob() extension
Tim Rice's avatar
Tim Rice committed
1221 1222
AC_MSG_CHECKING([for GLOB_ALTDIRFUNC support])
AC_EGREP_CPP([FOUNDIT],
1223 1224 1225 1226 1227
	[
		#include <glob.h>
		#ifdef GLOB_ALTDIRFUNC
		FOUNDIT
		#endif
1228
	],
1229
	[
Tim Rice's avatar
Tim Rice committed
1230
		AC_DEFINE([GLOB_HAS_ALTDIRFUNC], [1],
1231 1232
			[Define if your system glob() function has
			the GLOB_ALTDIRFUNC extension])
Tim Rice's avatar
Tim Rice committed
1233
		AC_MSG_RESULT([yes])
1234 1235
	],
	[
Tim Rice's avatar
Tim Rice committed
1236
		AC_MSG_RESULT([no])
1237 1238
	]
)
1239

1240
# Check for g.gl_matchc glob() extension
Tim Rice's avatar
Tim Rice committed
1241 1242 1243
AC_MSG_CHECKING([for gl_matchc field in glob_t])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <glob.h> ]],
	[[ glob_t g; g.gl_matchc = 1; ]])],
1244
	[
Tim Rice's avatar
Tim Rice committed
1245
		AC_DEFINE([GLOB_HAS_GL_MATCHC], [1],
1246 1247
			[Define if your system glob() function has
			gl_matchc options in glob_t])
Tim Rice's avatar
Tim Rice committed
1248 1249 1250 1251
		AC_MSG_RESULT([yes])
	], [
		AC_MSG_RESULT([no])
])
1252

1253
# Check for g.gl_statv glob() extension
Tim Rice's avatar
Tim Rice committed
1254 1255
AC_MSG_CHECKING([for gl_statv and GLOB_KEEPSTAT extensions for glob])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <glob.h> ]], [[
1256 1257 1258 1259 1260
#ifndef GLOB_KEEPSTAT
#error "glob does not support GLOB_KEEPSTAT extension"
#endif
glob_t g;
g.gl_statv = NULL;
Tim Rice's avatar
Tim Rice committed
1261
]])],
1262
	[
Tim Rice's avatar
Tim Rice committed
1263
		AC_DEFINE([GLOB_HAS_GL_STATV], [1],
1264 1265
			[Define if your system glob() function has
			gl_statv options in glob_t])
Tim Rice's avatar
Tim Rice committed
1266 1267 1268 1269 1270
		AC_MSG_RESULT([yes])
	], [
		AC_MSG_RESULT([no])
	
])
1271

Tim Rice's avatar
Tim Rice committed
1272
AC_CHECK_DECLS([GLOB_NOMATCH], , , [#include <glob.h>])
1273

1274
AC_MSG_CHECKING([whether struct dirent allocates space for d_name])
1275
AC_RUN_IFELSE(
Tim Rice's avatar
Tim Rice committed
1276
	[AC_LANG_PROGRAM([[
1277
#include <sys/types.h>
Tim Rice's avatar
Tim Rice committed
1278 1279 1280 1281
#include <dirent.h>]],
	[[
	struct dirent d;
	exit(sizeof(d.d_name)<=sizeof(char));
1282
	]])],
Tim Rice's avatar
Tim Rice committed
1283
	[AC_MSG_RESULT([yes])],
1284
	[
Tim Rice's avatar
Tim Rice committed
1285