xref: /openssh-portable/configure.ac (revision 493339a9)
14fefe24cSDamien Miller#
24fefe24cSDamien Miller# Copyright (c) 1999-2004 Damien Miller
34fefe24cSDamien Miller#
44fefe24cSDamien Miller# Permission to use, copy, modify, and distribute this software for any
54fefe24cSDamien Miller# purpose with or without fee is hereby granted, provided that the above
64fefe24cSDamien Miller# copyright notice and this permission notice appear in all copies.
74fefe24cSDamien Miller#
84fefe24cSDamien Miller# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
94fefe24cSDamien Miller# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
104fefe24cSDamien Miller# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
114fefe24cSDamien Miller# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
124fefe24cSDamien Miller# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
134fefe24cSDamien Miller# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
144fefe24cSDamien Miller# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
158ad995fdSTim Rice
16648f8765STim RiceAC_INIT([OpenSSH], [Portable], [openssh-unix-dev@mindrot.org])
17a2f3ae38SSebastian Andrzej SiewiorAC_CONFIG_MACRO_DIR([m4])
188ad995fdSTim RiceAC_CONFIG_SRCDIR([ssh.c])
19648f8765STim RiceAC_LANG([C])
208ad995fdSTim Rice
21e5591161SDarren TuckerAC_CONFIG_HEADERS([config.h])
22c90a7928SDarren TuckerAC_PROG_CC([cc gcc])
23586f9bd2SDarren Tucker
24f812a36cSDamien Miller# XXX relax this after reimplementing logit() etc.
25586f9bd2SDarren TuckerAC_MSG_CHECKING([if $CC supports C99-style variadic macros])
26586f9bd2SDarren TuckerAC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
27586f9bd2SDarren Tuckerint f(int a, int b, int c) { return a + b + c; }
28586f9bd2SDarren Tucker#define F(a, ...) f(a, __VA_ARGS__)
296d2564b9SDarren Tucker]], [[return F(1, 2, -3);]])],
30586f9bd2SDarren Tucker	[ AC_MSG_RESULT([yes]) ],
31586f9bd2SDarren Tucker	[ AC_MSG_ERROR([*** OpenSSH requires support for C99-style variadic macros]) ]
32586f9bd2SDarren Tucker)
338ad995fdSTim Rice
34771b7795SDarren TuckerAC_CANONICAL_HOST
35771b7795SDarren TuckerAC_C_BIGENDIAN
36771b7795SDarren Tucker
378ad995fdSTim Rice# Checks for programs.
38167bd9cfSDarren TuckerAC_PROG_AWK
398ad995fdSTim RiceAC_PROG_CPP
408ad995fdSTim RiceAC_PROG_RANLIB
418ad995fdSTim RiceAC_PROG_INSTALL
42fd80ddcbSTim RiceAC_PROG_EGREP
436c8a2464SDarren TuckerAC_PROG_MKDIR_P
44408f4c2aSDarren TuckerAC_CHECK_TOOLS([AR], [ar])
45648f8765STim RiceAC_PATH_PROG([CAT], [cat])
46648f8765STim RiceAC_PATH_PROG([KILL], [kill])
47648f8765STim RiceAC_PATH_PROG([SED], [sed])
48648f8765STim RiceAC_PATH_PROG([TEST_MINUS_S_SH], [bash])
49648f8765STim RiceAC_PATH_PROG([TEST_MINUS_S_SH], [ksh])
50648f8765STim RiceAC_PATH_PROG([TEST_MINUS_S_SH], [sh])
51648f8765STim RiceAC_PATH_PROG([SH], [sh])
52648f8765STim RiceAC_PATH_PROG([GROFF], [groff])
53285546b7SDarren TuckerAC_PATH_PROG([NROFF], [nroff awf])
54648f8765STim RiceAC_PATH_PROG([MANDOC], [mandoc])
55648f8765STim RiceAC_SUBST([TEST_SHELL], [sh])
568ad995fdSTim Rice
57285546b7SDarren Tuckerdnl select manpage formatter to be used to build "cat" format pages.
5830a69e7bSDamien Millerif test "x$MANDOC" != "x" ; then
5930a69e7bSDamien Miller	MANFMT="$MANDOC"
6030a69e7bSDamien Millerelif test "x$NROFF" != "x" ; then
6130a69e7bSDamien Miller	MANFMT="$NROFF -mandoc"
6230a69e7bSDamien Millerelif test "x$GROFF" != "x" ; then
6330a69e7bSDamien Miller	MANFMT="$GROFF -mandoc -Tascii"
6430a69e7bSDamien Millerelse
656fd4aa2aSDarren Tucker	AC_MSG_WARN([no manpage formatter found])
6630a69e7bSDamien Miller	MANFMT="false"
6730a69e7bSDamien Millerfi
68648f8765STim RiceAC_SUBST([MANFMT])
6930a69e7bSDamien Miller
706f1f758cSTim Ricednl for buildpkg.sh
71648f8765STim RiceAC_PATH_PROG([PATH_GROUPADD_PROG], [groupadd], [groupadd],
726f1f758cSTim Rice	[/usr/sbin${PATH_SEPARATOR}/etc])
73648f8765STim RiceAC_PATH_PROG([PATH_USERADD_PROG], [useradd], [useradd],
746f1f758cSTim Rice	[/usr/sbin${PATH_SEPARATOR}/etc])
75648f8765STim RiceAC_CHECK_PROG([MAKE_PACKAGE_SUPPORTED], [pkgmk], [yes], [no])
76fbea7640SDarren Tuckerif test -x /sbin/sh; then
77648f8765STim Rice	AC_SUBST([STARTUP_SCRIPT_SHELL], [/sbin/sh])
78fbea7640SDarren Tuckerelse
79648f8765STim Rice	AC_SUBST([STARTUP_SCRIPT_SHELL], [/bin/sh])
80fbea7640SDarren Tuckerfi
816f1f758cSTim Rice
828ad995fdSTim Rice# System features
838ad995fdSTim RiceAC_SYS_LARGEFILE
848ad995fdSTim Rice
858ad995fdSTim Riceif test -z "$AR" ; then
868ad995fdSTim Rice	AC_MSG_ERROR([*** 'ar' missing, please install or fix your \$PATH ***])
878ad995fdSTim Ricefi
888ad995fdSTim Rice
89648f8765STim RiceAC_PATH_PROG([PATH_PASSWD_PROG], [passwd])
9023bc8d0bSDarren Tuckerif test ! -z "$PATH_PASSWD_PROG" ; then
91648f8765STim Rice	AC_DEFINE_UNQUOTED([_PATH_PASSWD_PROG], ["$PATH_PASSWD_PROG"],
927df8d39aSTim Rice		[Full path of your "passwd" program])
9323bc8d0bSDarren Tuckerfi
9423bc8d0bSDarren Tucker
95f2c06ab8SDarren Tuckerdnl Since autoconf doesn't support it very well,  we no longer allow users to
96f2c06ab8SDarren Tuckerdnl override LD, however keeping the hook here for now in case there's a use
97f2c06ab8SDarren Tuckerdnl use case we overlooked and someone needs to re-enable it.  Unless a good
98f2c06ab8SDarren Tuckerdnl reason is found we'll be removing this in future.
99f2c06ab8SDarren TuckerLD="$CC"
100648f8765STim RiceAC_SUBST([LD])
1018ad995fdSTim Rice
1028ad995fdSTim RiceAC_C_INLINE
10367b3703dSDarren Tucker
104648f8765STim RiceAC_CHECK_DECL([LLONG_MAX], [have_llong_max=1], , [#include <limits.h>])
105e9dc9863SDarren TuckerAC_CHECK_DECL([LONG_LONG_MAX], [have_long_long_max=1], , [#include <limits.h>])
10669ff1df9SDamien MillerAC_CHECK_DECL([SYSTR_POLICY_KILL], [have_systr_policy_kill=1], , [
10769ff1df9SDamien Miller	#include <sys/types.h>
10869ff1df9SDamien Miller	#include <sys/param.h>
10969ff1df9SDamien Miller	#include <dev/systrace.h>
11069ff1df9SDamien Miller])
11169ff1df9SDamien MillerAC_CHECK_DECL([RLIMIT_NPROC],
11269ff1df9SDamien Miller    [AC_DEFINE([HAVE_RLIMIT_NPROC], [], [sys/resource.h has RLIMIT_NPROC])], , [
11369ff1df9SDamien Miller	#include <sys/types.h>
11469ff1df9SDamien Miller	#include <sys/resource.h>
11569ff1df9SDamien Miller])
116e0956e38SDamien MillerAC_CHECK_DECL([PR_SET_NO_NEW_PRIVS], [have_linux_no_new_privs=1], , [
117e0956e38SDamien Miller	#include <sys/types.h>
118e0956e38SDamien Miller	#include <linux/prctl.h>
119e0956e38SDamien Miller])
120868ea1eaSDamien Miller
12172ef7c14SDamien Milleropenssl=yes
12272ef7c14SDamien MillerAC_ARG_WITH([openssl],
12372ef7c14SDamien Miller	[  --without-openssl       Disable use of OpenSSL; use only limited internal crypto **EXPERIMENTAL** ],
12472ef7c14SDamien Miller	[  if test "x$withval" = "xno" ; then
12572ef7c14SDamien Miller		openssl=no
12672ef7c14SDamien Miller	   fi
12772ef7c14SDamien Miller	]
12872ef7c14SDamien Miller)
12972ef7c14SDamien MillerAC_MSG_CHECKING([whether OpenSSL will be used for cryptography])
13072ef7c14SDamien Millerif test "x$openssl" = "xyes" ; then
13172ef7c14SDamien Miller	AC_MSG_RESULT([yes])
13272ef7c14SDamien Miller	AC_DEFINE_UNQUOTED([WITH_OPENSSL], [1], [use libcrypto for cryptography])
13372ef7c14SDamien Millerelse
13472ef7c14SDamien Miller	AC_MSG_RESULT([no])
13572ef7c14SDamien Millerfi
13672ef7c14SDamien Miller
137b7918afdSDarren Tuckeruse_stack_protector=1
138fd994379SDarren Tuckeruse_toolchain_hardening=1
139648f8765STim RiceAC_ARG_WITH([stackprotect],
140b7918afdSDarren Tucker    [  --without-stackprotect  Don't use compiler's stack protection], [
141b7918afdSDarren Tucker    if test "x$withval" = "xno"; then
142b7918afdSDarren Tucker	use_stack_protector=0
143b7918afdSDarren Tucker    fi ])
144fd994379SDarren TuckerAC_ARG_WITH([hardening],
145fd994379SDarren Tucker    [  --without-hardening     Don't use toolchain hardening flags], [
146fd994379SDarren Tucker    if test "x$withval" = "xno"; then
147fd994379SDarren Tucker	use_toolchain_hardening=0
148fd994379SDarren Tucker    fi ])
149b7918afdSDarren Tucker
150fd994379SDarren Tucker# We use -Werror for the tests only so that we catch warnings like "this is
151fd994379SDarren Tucker# on by default" for things like -fPIE.
152fd994379SDarren TuckerAC_MSG_CHECKING([if $CC supports -Werror])
153fd994379SDarren Tuckersaved_CFLAGS="$CFLAGS"
154fd994379SDarren TuckerCFLAGS="$CFLAGS -Werror"
155fd994379SDarren TuckerAC_COMPILE_IFELSE([AC_LANG_SOURCE([[int main(void) { return 0; }]])],
156fd994379SDarren Tucker	[ AC_MSG_RESULT([yes])
157fd994379SDarren Tucker	  WERROR="-Werror"],
158fd994379SDarren Tucker	[ AC_MSG_RESULT([no])
159fd994379SDarren Tucker	  WERROR="" ]
160fd994379SDarren Tucker)
161fd994379SDarren TuckerCFLAGS="$saved_CFLAGS"
162134d02a4SDamien Miller
1638ad995fdSTim Riceif test "$GCC" = "yes" || test "$GCC" = "egcs"; then
164d9048861SDarren Tucker	OSSH_CHECK_CFLAG_COMPILE([-pipe])
165fd994379SDarren Tucker	OSSH_CHECK_CFLAG_COMPILE([-Wunknown-warning-option])
166e0e7e3d0SDamien Miller	OSSH_CHECK_CFLAG_COMPILE([-Wno-error=format-truncation])
167e0e7e3d0SDamien Miller	OSSH_CHECK_CFLAG_COMPILE([-Qunused-arguments])
168b176362dSDamien Miller	OSSH_CHECK_CFLAG_COMPILE([-Wall])
169e0e7e3d0SDamien Miller	OSSH_CHECK_CFLAG_COMPILE([-Wextra])
170b176362dSDamien Miller	OSSH_CHECK_CFLAG_COMPILE([-Wpointer-arith])
171b176362dSDamien Miller	OSSH_CHECK_CFLAG_COMPILE([-Wuninitialized])
172b176362dSDamien Miller	OSSH_CHECK_CFLAG_COMPILE([-Wsign-compare])
173b176362dSDamien Miller	OSSH_CHECK_CFLAG_COMPILE([-Wformat-security])
174abbc7a7cSDarren Tucker	OSSH_CHECK_CFLAG_COMPILE([-Wsizeof-pointer-memaccess])
175b176362dSDamien Miller	OSSH_CHECK_CFLAG_COMPILE([-Wpointer-sign], [-Wno-pointer-sign])
17689fc3f41SDarren Tucker	OSSH_CHECK_CFLAG_COMPILE([-Wunused-parameter], [-Wno-unused-parameter])
177b176362dSDamien Miller	OSSH_CHECK_CFLAG_COMPILE([-Wunused-result], [-Wno-unused-result])
1786cf1c400SDarren Tucker	OSSH_CHECK_CFLAG_COMPILE([-Wimplicit-fallthrough])
179b176362dSDamien Miller	OSSH_CHECK_CFLAG_COMPILE([-fno-strict-aliasing])
180fd994379SDarren Tucker    if test "x$use_toolchain_hardening" = "x1"; then
1813377df00SDarren Tucker	OSSH_CHECK_CFLAG_COMPILE([-mretpoline]) # clang
182174bed68SDarren Tucker	OSSH_CHECK_LDFLAG_LINK([-Wl,-z,retpolineplt])
183161af8f5SDamien Miller	OSSH_CHECK_CFLAG_COMPILE([-D_FORTIFY_SOURCE=2])
184fd994379SDarren Tucker	OSSH_CHECK_LDFLAG_LINK([-Wl,-z,relro])
185fd994379SDarren Tucker	OSSH_CHECK_LDFLAG_LINK([-Wl,-z,now])
186fd994379SDarren Tucker	OSSH_CHECK_LDFLAG_LINK([-Wl,-z,noexecstack])
1875c2ff5e3SDamien Miller	# NB. -ftrapv expects certain support functions to be present in
1885c2ff5e3SDamien Miller	# the compiler library (libgcc or similar) to detect integer operations
1895c2ff5e3SDamien Miller	# that can overflow. We must check that the result of enabling it
1905c2ff5e3SDamien Miller	# actually links. The test program compiled/linked includes a number
1915c2ff5e3SDamien Miller	# of integer operations that should exercise this.
1925c2ff5e3SDamien Miller	OSSH_CHECK_CFLAG_LINK([-ftrapv])
193fd994379SDarren Tucker    fi
194648f8765STim Rice	AC_MSG_CHECKING([gcc version])
1953f9545eeSDarren Tucker	GCC_VER=`$CC -v 2>&1 | $AWK '/gcc version /{print $3}'`
1963db1e3fcSTim Rice	case $GCC_VER in
197391de5c0SDarren Tucker		1.*) no_attrib_nonnull=1 ;;
198391de5c0SDarren Tucker		2.8* | 2.9*)
199391de5c0SDarren Tucker		     no_attrib_nonnull=1
200391de5c0SDarren Tucker		     ;;
201391de5c0SDarren Tucker		2.*) no_attrib_nonnull=1 ;;
202f032435dSDarren Tucker		*) ;;
2033db1e3fcSTim Rice	esac
204648f8765STim Rice	AC_MSG_RESULT([$GCC_VER])
205de3cb0a3SDamien Miller
206648f8765STim Rice	AC_MSG_CHECKING([if $CC accepts -fno-builtin-memset])
207330c93f6SDarren Tucker	saved_CFLAGS="$CFLAGS"
208330c93f6SDarren Tucker	CFLAGS="$CFLAGS -fno-builtin-memset"
209648f8765STim Rice	AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <string.h> ]],
210648f8765STim Rice			[[ char b[10]; memset(b, 0, sizeof(b)); ]])],
211648f8765STim Rice		[ AC_MSG_RESULT([yes]) ],
212648f8765STim Rice		[ AC_MSG_RESULT([no])
213330c93f6SDarren Tucker		  CFLAGS="$saved_CFLAGS" ]
214330c93f6SDarren Tucker	)
215330c93f6SDarren Tucker
216b7918afdSDarren Tucker	# -fstack-protector-all doesn't always work for some GCC versions
217fe1cf97eSDarren Tucker	# and/or platforms, so we test if we can.  If it's not supported
2187df2e400SDamien Miller	# on a given platform gcc will emit a warning so we use -Werror.
219b7918afdSDarren Tucker	if test "x$use_stack_protector" = "x1"; then
220fd994379SDarren Tucker	    for t in -fstack-protector-strong -fstack-protector-all \
221fd994379SDarren Tucker		    -fstack-protector; do
222648f8765STim Rice		AC_MSG_CHECKING([if $CC supports $t])
223319b3d9bSDarren Tucker		saved_CFLAGS="$CFLAGS"
224e1c4c542SDarren Tucker		saved_LDFLAGS="$LDFLAGS"
225fe1cf97eSDarren Tucker		CFLAGS="$CFLAGS $t -Werror"
226fe1cf97eSDarren Tucker		LDFLAGS="$LDFLAGS $t -Werror"
227fe1cf97eSDarren Tucker		AC_LINK_IFELSE(
2289239a18fSDarren Tucker			[AC_LANG_PROGRAM([[
2299239a18fSDarren Tucker	#include <stdio.h>
2309239a18fSDarren Tucker	int func (int t) {char b[100]; snprintf(b,sizeof b,"%d",t); return t;}
2319239a18fSDarren Tucker			 ]],
232648f8765STim Rice			[[
233648f8765STim Rice	char x[256];
2349239a18fSDarren Tucker	snprintf(x, sizeof(x), "XXX%d", func(1));
235648f8765STim Rice			 ]])],
236648f8765STim Rice		    [ AC_MSG_RESULT([yes])
237fe1cf97eSDarren Tucker		      CFLAGS="$saved_CFLAGS $t"
238fe1cf97eSDarren Tucker		      LDFLAGS="$saved_LDFLAGS $t"
239648f8765STim Rice		      AC_MSG_CHECKING([if $t works])
240b7918afdSDarren Tucker		      AC_RUN_IFELSE(
2419239a18fSDarren Tucker			[AC_LANG_PROGRAM([[
2429239a18fSDarren Tucker	#include <stdio.h>
2439239a18fSDarren Tucker	int func (int t) {char b[100]; snprintf(b,sizeof b,"%d",t); return t;}
2449239a18fSDarren Tucker			]],
245648f8765STim Rice			[[
246648f8765STim Rice	char x[256];
2479239a18fSDarren Tucker	snprintf(x, sizeof(x), "XXX%d", func(1));
248648f8765STim Rice			]])],
249648f8765STim Rice			[ AC_MSG_RESULT([yes])
250b7918afdSDarren Tucker			  break ],
251648f8765STim Rice			[ AC_MSG_RESULT([no]) ],
252b7918afdSDarren Tucker			[ AC_MSG_WARN([cross compiling: cannot test])
253b7918afdSDarren Tucker			  break ]
254b7918afdSDarren Tucker		      )
255b7918afdSDarren Tucker		    ],
256648f8765STim Rice		    [ AC_MSG_RESULT([no]) ]
257b7918afdSDarren Tucker		)
258e1c4c542SDarren Tucker		CFLAGS="$saved_CFLAGS"
259e1c4c542SDarren Tucker		LDFLAGS="$saved_LDFLAGS"
260b7918afdSDarren Tucker	    done
261b7918afdSDarren Tucker	fi
262319b3d9bSDarren Tucker
26367b3703dSDarren Tucker	if test -z "$have_llong_max"; then
26467b3703dSDarren Tucker		# retry LLONG_MAX with -std=gnu99, needed on some Linuxes
26567b3703dSDarren Tucker		unset ac_cv_have_decl_LLONG_MAX
266de3cb0a3SDamien Miller		saved_CFLAGS="$CFLAGS"
267de3cb0a3SDamien Miller		CFLAGS="$CFLAGS -std=gnu99"
268648f8765STim Rice		AC_CHECK_DECL([LLONG_MAX],
26967b3703dSDarren Tucker		    [have_llong_max=1],
27067b3703dSDarren Tucker		    [CFLAGS="$saved_CFLAGS"],
27167b3703dSDarren Tucker		    [#include <limits.h>]
272de3cb0a3SDamien Miller		)
2738ad995fdSTim Rice	fi
27467b3703dSDarren Tuckerfi
2758ad995fdSTim Rice
276951b53b1SDarren TuckerAC_MSG_CHECKING([if compiler allows __attribute__ on return types])
277951b53b1SDarren TuckerAC_COMPILE_IFELSE(
278951b53b1SDarren Tucker    [AC_LANG_PROGRAM([[
279951b53b1SDarren Tucker#include <stdlib.h>
280951b53b1SDarren Tucker__attribute__((__unused__)) static void foo(void){return;}]],
281951b53b1SDarren Tucker    [[ exit(0); ]])],
282951b53b1SDarren Tucker    [ AC_MSG_RESULT([yes]) ],
283951b53b1SDarren Tucker    [ AC_MSG_RESULT([no])
284951b53b1SDarren Tucker      AC_DEFINE(NO_ATTRIBUTE_ON_RETURN_TYPE, 1,
285951b53b1SDarren Tucker	 [compiler does not accept __attribute__ on return types]) ]
286951b53b1SDarren Tucker)
287951b53b1SDarren Tucker
2881323f120SDarren TuckerAC_MSG_CHECKING([if compiler allows __attribute__ prototype args])
2891323f120SDarren TuckerAC_COMPILE_IFELSE(
2901323f120SDarren Tucker    [AC_LANG_PROGRAM([[
2911323f120SDarren Tucker#include <stdlib.h>
2921323f120SDarren Tuckertypedef void foo(const char *, ...) __attribute__((format(printf, 1, 2)));]],
2931323f120SDarren Tucker    [[ exit(0); ]])],
2941323f120SDarren Tucker    [ AC_MSG_RESULT([yes]) ],
2951323f120SDarren Tucker    [ AC_MSG_RESULT([no])
2961323f120SDarren Tucker      AC_DEFINE(NO_ATTRIBUTE_ON_PROTOTYPE_ARGS, 1,
29710479cc2SDamien Miller	 [compiler does not accept __attribute__ on prototype args]) ]
2981323f120SDarren Tucker)
2991323f120SDarren Tucker
30048d0d7a4SDarren TuckerAC_MSG_CHECKING([if compiler supports variable length arrays])
30148d0d7a4SDarren TuckerAC_COMPILE_IFELSE(
30248d0d7a4SDarren Tucker    [AC_LANG_PROGRAM([[#include <stdlib.h>]],
30348d0d7a4SDarren Tucker    [[ int i; for (i=0; i<3; i++){int a[i]; a[i-1]=0;} exit(0); ]])],
30448d0d7a4SDarren Tucker    [ AC_MSG_RESULT([yes])
30548d0d7a4SDarren Tucker      AC_DEFINE(VARIABLE_LENGTH_ARRAYS, [1],
30648d0d7a4SDarren Tucker	 [compiler supports variable length arrays]) ],
30748d0d7a4SDarren Tucker    [ AC_MSG_RESULT([no]) ]
30848d0d7a4SDarren Tucker)
30948d0d7a4SDarren Tucker
310391de5c0SDarren Tuckerif test "x$no_attrib_nonnull" != "x1" ; then
311648f8765STim Rice	AC_DEFINE([HAVE_ATTRIBUTE__NONNULL__], [1], [Have attribute nonnull])
312391de5c0SDarren Tuckerfi
313391de5c0SDarren Tucker
314648f8765STim RiceAC_ARG_WITH([rpath],
31588368a30STim Rice	[  --without-rpath         Disable auto-added -R linker paths],
31688368a30STim Rice	[
31788368a30STim Rice		if test "x$withval" = "xno" ; then
3182f0bad2bSDarren Tucker			rpath_opt=""
3192f0bad2bSDarren Tucker		elif test "x$withval" = "xyes" ; then
3202f0bad2bSDarren Tucker			rpath_opt="-R"
3212f0bad2bSDarren Tucker		else
3222f0bad2bSDarren Tucker			rpath_opt="$withval"
32388368a30STim Rice		fi
32488368a30STim Rice	]
32588368a30STim Rice)
32688368a30STim Rice
3271cfab23bSTim Rice# Allow user to specify flags
328648f8765STim RiceAC_ARG_WITH([cflags],
3291cfab23bSTim Rice	[  --with-cflags           Specify additional flags to pass to compiler],
3301cfab23bSTim Rice	[
3311cfab23bSTim Rice		if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
3321cfab23bSTim Rice		    test "x${withval}" != "xyes"; then
3331cfab23bSTim Rice			CFLAGS="$CFLAGS $withval"
3341cfab23bSTim Rice		fi
3351cfab23bSTim Rice	]
3361cfab23bSTim Rice)
337de35c382SDamien Miller
338de35c382SDamien MillerAC_ARG_WITH([cflags-after],
339de35c382SDamien Miller	[  --with-cflags-after     Specify additional flags to pass to compiler after configure],
340de35c382SDamien Miller	[
341de35c382SDamien Miller		if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
342de35c382SDamien Miller		    test "x${withval}" != "xyes"; then
343de35c382SDamien Miller			CFLAGS_AFTER="$withval"
344de35c382SDamien Miller		fi
345de35c382SDamien Miller	]
346de35c382SDamien Miller)
347648f8765STim RiceAC_ARG_WITH([cppflags],
3481cfab23bSTim Rice	[  --with-cppflags         Specify additional flags to pass to preprocessor] ,
3491cfab23bSTim Rice	[
3501cfab23bSTim Rice		if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
3511cfab23bSTim Rice		    test "x${withval}" != "xyes"; then
3521cfab23bSTim Rice			CPPFLAGS="$CPPFLAGS $withval"
3531cfab23bSTim Rice		fi
3541cfab23bSTim Rice	]
3551cfab23bSTim Rice)
356648f8765STim RiceAC_ARG_WITH([ldflags],
3571cfab23bSTim Rice	[  --with-ldflags          Specify additional flags to pass to linker],
3581cfab23bSTim Rice	[
3591cfab23bSTim Rice		if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
3601cfab23bSTim Rice		    test "x${withval}" != "xyes"; then
3611cfab23bSTim Rice			LDFLAGS="$LDFLAGS $withval"
3621cfab23bSTim Rice		fi
3631cfab23bSTim Rice	]
3641cfab23bSTim Rice)
365de35c382SDamien MillerAC_ARG_WITH([ldflags-after],
366de35c382SDamien Miller	[  --with-ldflags-after    Specify additional flags to pass to linker after configure],
367de35c382SDamien Miller	[
368de35c382SDamien Miller		if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
369de35c382SDamien Miller		    test "x${withval}" != "xyes"; then
370de35c382SDamien Miller			LDFLAGS_AFTER="$withval"
371de35c382SDamien Miller		fi
372de35c382SDamien Miller	]
373de35c382SDamien Miller)
374648f8765STim RiceAC_ARG_WITH([libs],
3751cfab23bSTim Rice	[  --with-libs             Specify additional libraries to link with],
3761cfab23bSTim Rice	[
3771cfab23bSTim Rice		if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
3781cfab23bSTim Rice		    test "x${withval}" != "xyes"; then
3791cfab23bSTim Rice			LIBS="$LIBS $withval"
3801cfab23bSTim Rice		fi
3811cfab23bSTim Rice	]
3821cfab23bSTim Rice)
383648f8765STim RiceAC_ARG_WITH([Werror],
3841cfab23bSTim Rice	[  --with-Werror           Build main code with -Werror],
3851cfab23bSTim Rice	[
3861cfab23bSTim Rice		if test -n "$withval"  &&  test "x$withval" != "xno"; then
3871cfab23bSTim Rice			werror_flags="-Werror"
3881cfab23bSTim Rice			if test "x${withval}" != "xyes"; then
3891cfab23bSTim Rice				werror_flags="$withval"
3901cfab23bSTim Rice			fi
3911cfab23bSTim Rice		fi
3921cfab23bSTim Rice	]
3931cfab23bSTim Rice)
3941cfab23bSTim Rice
395648f8765STim RiceAC_CHECK_HEADERS([ \
3961ff130daSDamien Miller	blf.h \
3971cfab23bSTim Rice	bstring.h \
3981cfab23bSTim Rice	crypt.h \
3991cfab23bSTim Rice	crypto/sha2.h \
4001cfab23bSTim Rice	dirent.h \
4011cfab23bSTim Rice	endian.h \
40291f40d85SDamien Miller	elf.h \
4036310ef27SDarren Tucker	err.h \
4041cfab23bSTim Rice	features.h \
4051cfab23bSTim Rice	fcntl.h \
4061cfab23bSTim Rice	floatingpoint.h \
4070e3c5bc5SDarren Tucker	fnmatch.h \
4081cfab23bSTim Rice	getopt.h \
4091cfab23bSTim Rice	glob.h \
4101cfab23bSTim Rice	ia.h \
4111cfab23bSTim Rice	iaf.h \
412b59162daSDarren Tucker	ifaddrs.h \
4136d725687SDarren Tucker	inttypes.h \
414f3f2cc83SDarren Tucker	langinfo.h \
4151cfab23bSTim Rice	limits.h \
416ae133d4bSDarren Tucker	locale.h \
4171cfab23bSTim Rice	login.h \
4181cfab23bSTim Rice	maillock.h \
4191cfab23bSTim Rice	ndir.h \
4201cfab23bSTim Rice	net/if_tun.h \
4211cfab23bSTim Rice	netdb.h \
4221cfab23bSTim Rice	netgroup.h \
4231cfab23bSTim Rice	pam/pam_appl.h \
4241cfab23bSTim Rice	paths.h \
425febf0f56SDarren Tucker	poll.h \
4261cfab23bSTim Rice	pty.h \
4271cfab23bSTim Rice	readpassphrase.h \
4281cfab23bSTim Rice	rpc/types.h \
4291cfab23bSTim Rice	security/pam_appl.h \
4301cfab23bSTim Rice	sha2.h \
4311cfab23bSTim Rice	shadow.h \
4321cfab23bSTim Rice	stddef.h \
4331cfab23bSTim Rice	stdint.h \
4341cfab23bSTim Rice	string.h \
4351cfab23bSTim Rice	strings.h \
4361cfab23bSTim Rice	sys/bitypes.h \
4377f23f421SDarren Tucker	sys/byteorder.h \
4381cfab23bSTim Rice	sys/bsdtty.h \
4391cfab23bSTim Rice	sys/cdefs.h \
4401cfab23bSTim Rice	sys/dir.h \
441f8854741SDamien Miller	sys/file.h \
4421cfab23bSTim Rice	sys/mman.h \
443ce066f68SDarren Tucker	sys/label.h \
4441cfab23bSTim Rice	sys/ndir.h \
4457c92a65aSDarren Tucker	sys/poll.h \
4461cfab23bSTim Rice	sys/prctl.h \
4471cfab23bSTim Rice	sys/pstat.h \
4485ee3fb5aSDarren Tucker	sys/ptrace.h \
449afa6e79bSDamien Miller	sys/random.h \
4501cfab23bSTim Rice	sys/select.h \
4511cfab23bSTim Rice	sys/stat.h \
4521cfab23bSTim Rice	sys/stream.h \
4531cfab23bSTim Rice	sys/stropts.h \
4541cfab23bSTim Rice	sys/strtio.h \
4555b2e2ba9SDarren Tucker	sys/statvfs.h \
4561cfab23bSTim Rice	sys/sysmacros.h \
4571cfab23bSTim Rice	sys/time.h \
4581cfab23bSTim Rice	sys/timers.h \
45911057564SDarren Tucker	sys/vfs.h \
4601cfab23bSTim Rice	time.h \
4611cfab23bSTim Rice	tmpdir.h \
4621cfab23bSTim Rice	ttyent.h \
463aa8954f1STim Rice	ucred.h \
4641cfab23bSTim Rice	unistd.h \
4651cfab23bSTim Rice	usersec.h \
4661cfab23bSTim Rice	util.h \
4671cfab23bSTim Rice	utime.h \
4681cfab23bSTim Rice	utmp.h \
4691cfab23bSTim Rice	utmpx.h \
4701cfab23bSTim Rice	vis.h \
471f3f2cc83SDarren Tucker	wchar.h \
472648f8765STim Rice])
4731cfab23bSTim Rice
474ce066f68SDarren Tucker# On some platforms (eg SunOS4) sys/audit.h requires sys/[time|types|label.h]
475ce066f68SDarren Tucker# to be included first.
476ce066f68SDarren TuckerAC_CHECK_HEADERS([sys/audit.h], [], [], [
477ce066f68SDarren Tucker#ifdef HAVE_SYS_TIME_H
478ce066f68SDarren Tucker# include <sys/time.h>
479ce066f68SDarren Tucker#endif
480ce066f68SDarren Tucker#ifdef HAVE_SYS_TYPES_H
481ce066f68SDarren Tucker# include <sys/types.h>
482ce066f68SDarren Tucker#endif
483ce066f68SDarren Tucker#ifdef HAVE_SYS_LABEL_H
484ce066f68SDarren Tucker# include <sys/label.h>
485ce066f68SDarren Tucker#endif
486ce066f68SDarren Tucker])
487ce066f68SDarren Tucker
488dd9d9b33SDarren Tucker# sys/capsicum.h requires sys/types.h
489dd9d9b33SDarren TuckerAC_CHECK_HEADERS([sys/capsicum.h], [], [], [
490dd9d9b33SDarren Tucker#ifdef HAVE_SYS_TYPES_H
491dd9d9b33SDarren Tucker# include <sys/types.h>
492dd9d9b33SDarren Tucker#endif
493dd9d9b33SDarren Tucker])
494dd9d9b33SDarren Tucker
495fa1b834cSDarren Tucker# net/route.h requires sys/socket.h and sys/types.h.
496fa1b834cSDarren Tucker# sys/sysctl.h also requires sys/param.h
497fa1b834cSDarren TuckerAC_CHECK_HEADERS([net/route.h sys/sysctl.h], [], [], [
498fa1b834cSDarren Tucker#ifdef HAVE_SYS_TYPES_H
499fa1b834cSDarren Tucker# include <sys/types.h>
500fa1b834cSDarren Tucker#endif
501fa1b834cSDarren Tucker#include <sys/param.h>
5023235473bSDamien Miller#include <sys/socket.h>
5033235473bSDamien Miller])
5043235473bSDamien Miller
5051cfab23bSTim Rice# lastlog.h requires sys/time.h to be included first on Solaris
506648f8765STim RiceAC_CHECK_HEADERS([lastlog.h], [], [], [
5071cfab23bSTim Rice#ifdef HAVE_SYS_TIME_H
5081cfab23bSTim Rice# include <sys/time.h>
5091cfab23bSTim Rice#endif
5101cfab23bSTim Rice])
5111cfab23bSTim Rice
5121cfab23bSTim Rice# sys/ptms.h requires sys/stream.h to be included first on Solaris
513648f8765STim RiceAC_CHECK_HEADERS([sys/ptms.h], [], [], [
5141cfab23bSTim Rice#ifdef HAVE_SYS_STREAM_H
5151cfab23bSTim Rice# include <sys/stream.h>
5161cfab23bSTim Rice#endif
5171cfab23bSTim Rice])
5181cfab23bSTim Rice
5191cfab23bSTim Rice# login_cap.h requires sys/types.h on NetBSD
520648f8765STim RiceAC_CHECK_HEADERS([login_cap.h], [], [], [
5211cfab23bSTim Rice#include <sys/types.h>
5221cfab23bSTim Rice])
5231cfab23bSTim Rice
524c4b22ca1SDarren Tucker# older BSDs need sys/param.h before sys/mount.h
525648f8765STim RiceAC_CHECK_HEADERS([sys/mount.h], [], [], [
526c4b22ca1SDarren Tucker#include <sys/param.h>
527c4b22ca1SDarren Tucker])
528c4b22ca1SDarren Tucker
529ef4901c3SDarren Tucker# Android requires sys/socket.h to be included before sys/un.h
530ef4901c3SDarren TuckerAC_CHECK_HEADERS([sys/un.h], [], [], [
5310b43ffe1SDarren Tucker#include <sys/types.h>
53216cac190SDarren Tucker#include <sys/socket.h>
533ef4901c3SDarren Tucker])
534ef4901c3SDarren Tucker
5351b06dc30SDamien Miller# Messages for features tested for in target-specific section
5361b06dc30SDamien MillerSIA_MSG="no"
5371b06dc30SDamien MillerSPC_MSG="no"
53897528353SDarren TuckerSP_MSG="no"
5394626cbafSDamien MillerSPP_MSG="no"
5404626cbafSDamien Miller
5414626cbafSDamien Miller# Support for Solaris/Illumos privileges (this test is used by both
5424626cbafSDamien Miller# the --with-solaris-privs option and --with-sandbox=solaris).
5434626cbafSDamien MillerSOLARIS_PRIVS="no"
5441b06dc30SDamien Miller
5458ad995fdSTim Rice# Check for some target-specific stuff
5468ad995fdSTim Ricecase "$host" in
5478ad995fdSTim Rice*-*-aix*)
5489216c37dSDarren Tucker	# Some versions of VAC won't allow macro redefinitions at
5499216c37dSDarren Tucker	# -qlanglevel=ansi, and autoconf 2.60 sometimes insists on using that
5509216c37dSDarren Tucker	# particularly with older versions of vac or xlc.
55110479cc2SDamien Miller	# It also throws errors about null macro arguments, but these are
5529216c37dSDarren Tucker	# not fatal.
553648f8765STim Rice	AC_MSG_CHECKING([if compiler allows macro redefinitions])
5549216c37dSDarren Tucker	AC_COMPILE_IFELSE(
555648f8765STim Rice	    [AC_LANG_PROGRAM([[
5569216c37dSDarren Tucker#define testmacro foo
557648f8765STim Rice#define testmacro bar]],
558648f8765STim Rice	    [[ exit(0); ]])],
559648f8765STim Rice	    [ AC_MSG_RESULT([yes]) ],
560648f8765STim Rice	    [ AC_MSG_RESULT([no])
5619216c37dSDarren Tucker	      CC="`echo $CC | sed 's/-qlanglvl\=ansi//g'`"
5629216c37dSDarren Tucker	      CFLAGS="`echo $CFLAGS | sed 's/-qlanglvl\=ansi//g'`"
5639216c37dSDarren Tucker	      CPPFLAGS="`echo $CPPFLAGS | sed 's/-qlanglvl\=ansi//g'`"
5649216c37dSDarren Tucker	    ]
5659216c37dSDarren Tucker	)
5669216c37dSDarren Tucker
567eab4bae0SDamien Miller	AC_MSG_CHECKING([how to specify blibpath for linker ($LD)])
568eab4bae0SDamien Miller	if (test -z "$blibpath"); then
569fcb6220dSTim Rice		blibpath="/usr/lib:/lib"
5708ad995fdSTim Rice	fi
571eab4bae0SDamien Miller	saved_LDFLAGS="$LDFLAGS"
572bdc12127SDarren Tucker	if test "$GCC" = "yes"; then
573bdc12127SDarren Tucker		flags="-Wl,-blibpath: -Wl,-rpath, -blibpath:"
574bdc12127SDarren Tucker	else
575bdc12127SDarren Tucker		flags="-blibpath: -Wl,-blibpath: -Wl,-rpath,"
576bdc12127SDarren Tucker	fi
577bdc12127SDarren Tucker	for tryflags in $flags ;do
578eab4bae0SDamien Miller		if (test -z "$blibflags"); then
579eab4bae0SDamien Miller			LDFLAGS="$saved_LDFLAGS $tryflags$blibpath"
580648f8765STim Rice			AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
581648f8765STim Rice			[blibflags=$tryflags], [])
582eab4bae0SDamien Miller		fi
583eab4bae0SDamien Miller	done
584eab4bae0SDamien Miller	if (test -z "$blibflags"); then
585648f8765STim Rice		AC_MSG_RESULT([not found])
586eab4bae0SDamien Miller		AC_MSG_ERROR([*** must be able to specify blibpath on AIX - check config.log])
587eab4bae0SDamien Miller	else
588648f8765STim Rice		AC_MSG_RESULT([$blibflags])
589eab4bae0SDamien Miller	fi
590eab4bae0SDamien Miller	LDFLAGS="$saved_LDFLAGS"
5915c6a91a3SDarren Tucker	dnl Check for authenticate.  Might be in libs.a on older AIXes
592648f8765STim Rice	AC_CHECK_FUNC([authenticate], [AC_DEFINE([WITH_AIXAUTHENTICATE], [1],
5937df8d39aSTim Rice		[Define if you want to enable AIX4's authenticate function])],
594648f8765STim Rice		[AC_CHECK_LIB([s], [authenticate],
595648f8765STim Rice			[ AC_DEFINE([WITH_AIXAUTHENTICATE])
596e958ed36STim Rice				LIBS="$LIBS -ls"
597e958ed36STim Rice			])
598e958ed36STim Rice		])
5993c774c52SDarren Tucker	dnl Check for various auth function declarations in headers.
60004cfbe04SDarren Tucker	AC_CHECK_DECLS([authenticate, loginrestrictions, loginsuccess,
601e66519d9SDarren Tucker	    passwdexpired, setauthdb], , , [#include <usersec.h>])
6025c6a91a3SDarren Tucker	dnl Check if loginfailed is declared and takes 4 arguments (AIX >= 5.2)
603648f8765STim Rice	AC_CHECK_DECLS([loginfailed],
604648f8765STim Rice	    [AC_MSG_CHECKING([if loginfailed takes 4 arguments])
605648f8765STim Rice	    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include <usersec.h> ]],
606648f8765STim Rice		[[ (void)loginfailed("user","host","tty",0); ]])],
607648f8765STim Rice		[AC_MSG_RESULT([yes])
608648f8765STim Rice		AC_DEFINE([AIX_LOGINFAILED_4ARG], [1],
6097df8d39aSTim Rice			[Define if your AIX loginfailed() function
610648f8765STim Rice			takes 4 arguments (AIX >= 5.2)])], [AC_MSG_RESULT([no])
611648f8765STim Rice	    ])],
6125c6a91a3SDarren Tucker	    [],
6135c6a91a3SDarren Tucker	    [#include <usersec.h>]
614a0c0b631SDarren Tucker	)
615648f8765STim Rice	AC_CHECK_FUNCS([getgrset setauthdb])
616648f8765STim Rice	AC_CHECK_DECL([F_CLOSEM],
617648f8765STim Rice	    AC_DEFINE([HAVE_FCNTL_CLOSEM], [1], [Use F_CLOSEM fcntl for closefrom]),
6183083bc2bSDarren Tucker	    [],
6193083bc2bSDarren Tucker	    [ #include <limits.h>
6203083bc2bSDarren Tucker	      #include <fcntl.h> ]
6213083bc2bSDarren Tucker	)
622691d5235SDarren Tucker	check_for_aix_broken_getaddrinfo=1
623648f8765STim Rice	AC_DEFINE([SETEUID_BREAKS_SETUID], [1],
6247df8d39aSTim Rice	    [Define if your platform breaks doing a seteuid before a setuid])
625648f8765STim Rice	AC_DEFINE([BROKEN_SETREUID], [1], [Define if your setreuid() is broken])
626648f8765STim Rice	AC_DEFINE([BROKEN_SETREGID], [1], [Define if your setregid() is broken])
6278ad995fdSTim Rice	dnl AIX handles lastlog as part of its login message
628648f8765STim Rice	AC_DEFINE([DISABLE_LASTLOG], [1], [Define if you don't want to use lastlog])
629648f8765STim Rice	AC_DEFINE([LOGIN_NEEDS_UTMPX], [1],
6307df8d39aSTim Rice		[Some systems need a utmpx entry for /bin/login to work])
631648f8765STim Rice	AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV],
6327df8d39aSTim Rice		[Define to a Set Process Title type if your system is
6337df8d39aSTim Rice		supported by bsd-setproctitle.c])
634648f8765STim Rice	AC_DEFINE([SSHPAM_CHAUTHTOK_NEEDS_RUID], [1],
63591d25a0cSDarren Tucker	    [AIX 5.2 and 5.3 (and presumably newer) require this])
636648f8765STim Rice	AC_DEFINE([PTY_ZEROREAD], [1], [read(1) can return 0 for a non-closed fd])
637aa97d13fSDarren Tucker	AC_DEFINE([PLATFORM_SYS_DIR_UID], 2, [System dirs owned by bin (uid 2)])
6382c71ca1dSDarren Tucker	AC_DEFINE([BROKEN_STRNDUP], 1, [strndup broken, see APAR IY61211])
6392c71ca1dSDarren Tucker	AC_DEFINE([BROKEN_STRNLEN], 1, [strnlen broken, see APAR IY62551])
6408ad995fdSTim Rice	;;
641898ac935SDarren Tucker*-*-android*)
642898ac935SDarren Tucker	AC_DEFINE([DISABLE_UTMP], [1], [Define if you don't want to use utmp])
643898ac935SDarren Tucker	AC_DEFINE([DISABLE_WTMP], [1], [Define if you don't want to use wtmp])
644898ac935SDarren Tucker	;;
6458ad995fdSTim Rice*-*-cygwin*)
646c8936acfSDamien Miller	check_for_libcrypt_later=1
647573e3878SDarren Tucker	LIBS="$LIBS /usr/lib/textreadmode.o"
648648f8765STim Rice	AC_DEFINE([HAVE_CYGWIN], [1], [Define if you are on Cygwin])
649648f8765STim Rice	AC_DEFINE([USE_PIPES], [1], [Use PIPES instead of a socketpair()])
6504626cbafSDamien Miller	AC_DEFINE([NO_UID_RESTORATION_TEST], [1],
6514626cbafSDamien Miller		[Define to disable UID restoration test])
652648f8765STim Rice	AC_DEFINE([DISABLE_SHADOW], [1],
6537df8d39aSTim Rice		[Define if you want to disable shadow passwords])
654648f8765STim Rice	AC_DEFINE([NO_X11_UNIX_SOCKETS], [1],
6557df8d39aSTim Rice		[Define if X11 doesn't support AF_UNIX sockets on that system])
656648f8765STim Rice	AC_DEFINE([DISABLE_FD_PASSING], [1],
6577df8d39aSTim Rice		[Define if your platform needs to skip post auth
6587df8d39aSTim Rice		file descriptor passing])
659648f8765STim Rice	AC_DEFINE([SSH_IOBUFSZ], [65535], [Windows is sensitive to read buffer size])
660648f8765STim Rice	AC_DEFINE([FILESYSTEM_NO_BACKSLASH], [1], [File names may not contain backslash characters])
661fdce3731SDarren Tucker	# Cygwin defines optargs, optargs as declspec(dllimport) for historical
662fdce3731SDarren Tucker	# reasons which cause compile warnings, so we disable those warnings.
663fdce3731SDarren Tucker	OSSH_CHECK_CFLAG_COMPILE([-Wno-attributes])
6648ad995fdSTim Rice	;;
6658ad995fdSTim Rice*-*-dgux*)
666648f8765STim Rice	AC_DEFINE([IP_TOS_IS_BROKEN], [1],
667a74000ebSTim Rice		[Define if your system choked on IP TOS setting])
668648f8765STim Rice	AC_DEFINE([SETEUID_BREAKS_SETUID])
669648f8765STim Rice	AC_DEFINE([BROKEN_SETREUID])
670648f8765STim Rice	AC_DEFINE([BROKEN_SETREGID])
6718ad995fdSTim Rice	;;
6728ad995fdSTim Rice*-*-darwin*)
673852472a5SDamien Miller	use_pie=auto
674648f8765STim Rice	AC_MSG_CHECKING([if we have working getaddrinfo])
675dc098405Spedro martelletto	AC_RUN_IFELSE([AC_LANG_SOURCE([[
676dc098405Spedro martelletto#include <mach-o/dyld.h>
677dc098405Spedro martelletto#include <stdlib.h>
678fc93d4bdSDamien Millermain() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
679fc93d4bdSDamien Miller		exit(0);
680fc93d4bdSDamien Miller	else
681fc93d4bdSDamien Miller		exit(1);
682648f8765STim Rice}
683648f8765STim Rice			]])],
684648f8765STim Rice	[AC_MSG_RESULT([working])],
685648f8765STim Rice	[AC_MSG_RESULT([buggy])
686648f8765STim Rice	AC_DEFINE([BROKEN_GETADDRINFO], [1],
687648f8765STim Rice		[getaddrinfo is broken (if present)])
688648f8765STim Rice	],
689648f8765STim Rice	[AC_MSG_RESULT([assume it is working])])
690648f8765STim Rice	AC_DEFINE([SETEUID_BREAKS_SETUID])
691648f8765STim Rice	AC_DEFINE([BROKEN_SETREUID])
692648f8765STim Rice	AC_DEFINE([BROKEN_SETREGID])
693648f8765STim Rice	AC_DEFINE([BROKEN_GLOB], [1], [OS X glob does not do what we expect])
694648f8765STim Rice	AC_DEFINE_UNQUOTED([BIND_8_COMPAT], [1],
6957df8d39aSTim Rice		[Define if your resolver libs need this for getrrsetbyname])
696648f8765STim Rice	AC_DEFINE([SSH_TUN_FREEBSD], [1], [Open tunnel devices the FreeBSD way])
697648f8765STim Rice	AC_DEFINE([SSH_TUN_COMPAT_AF], [1],
6983eb48344SDarren Tucker	    [Use tunnel device compatibility to OpenBSD])
699648f8765STim Rice	AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
7003eb48344SDarren Tucker	    [Prepend the address family to IP tunnel traffic])
701648f8765STim Rice	m4_pattern_allow([AU_IPv])
702648f8765STim Rice	AC_CHECK_DECL([AU_IPv4], [],
703648f8765STim Rice	    AC_DEFINE([AU_IPv4], [0], [System only supports IPv4 audit records])
704acada07bSDarren Tucker	    [#include <bsm/audit.h>]
705648f8765STim Rice	AC_DEFINE([LASTLOG_WRITE_PUTUTXLINE], [1],
70620e231f9SDamien Miller	    [Define if pututxline updates lastlog too])
707acada07bSDarren Tucker	)
708c09182f6SDamien Miller	AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV],
709c09182f6SDamien Miller		[Define to a Set Process Title type if your system is
710c09182f6SDamien Miller		supported by bsd-setproctitle.c])
711cd5e52eeSDamien Miller	AC_CHECK_FUNCS([sandbox_init])
712cd5e52eeSDamien Miller	AC_CHECK_HEADERS([sandbox.h])
71339f303b1SDamien Miller	AC_CHECK_LIB([sandbox], [sandbox_apply], [
71439f303b1SDamien Miller	    SSHDLIBS="$SSHDLIBS -lsandbox"
71539f303b1SDamien Miller	])
71628744182SDamien Miller	# proc_pidinfo()-based closefrom() replacement.
71728744182SDamien Miller	AC_CHECK_HEADERS([libproc.h])
71828744182SDamien Miller	AC_CHECK_FUNCS([proc_pidinfo])
7198ad995fdSTim Rice	;;
72057b2920aSDarren Tucker*-*-dragonfly*)
72157b2920aSDarren Tucker	SSHDLIBS="$SSHDLIBS -lcrypt"
722882abfd3SDarren Tucker	TEST_MALLOC_OPTIONS="AFGJPRX"
72357b2920aSDarren Tucker	;;
724a83d90fbSDarren Tucker*-*-haiku*)
725a83d90fbSDarren Tucker	LIBS="$LIBS -lbsd "
726bb4f003eSDarren Tucker	CFLAGS="$CFLAGS -D_BSD_SOURCE"
727648f8765STim Rice	AC_CHECK_LIB([network], [socket])
728648f8765STim Rice	AC_DEFINE([HAVE_U_INT64_T])
729bb4f003eSDarren Tucker	AC_DEFINE([DISABLE_UTMPX], [1], [no utmpx])
730a83d90fbSDarren Tucker	MANTYPE=man
731a83d90fbSDarren Tucker	;;
732fd33328aSDarren Tucker*-*-hpux*)
733fd33328aSDarren Tucker	# first we define all of the options common to all HP-UX releases
7340ea1d9d1SKevin Steves	CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
7350ea1d9d1SKevin Steves	IPADDR_IN_DISPLAY=yes
736648f8765STim Rice	AC_DEFINE([USE_PIPES])
737648f8765STim Rice	AC_DEFINE([LOGIN_NEEDS_UTMPX])
738648f8765STim Rice	AC_DEFINE([LOCKED_PASSWD_STRING], ["*"],
7397df8d39aSTim Rice		[String used in /etc/passwd to denote locked account])
740648f8765STim Rice	AC_DEFINE([SPT_TYPE], [SPT_PSTAT])
741aa97d13fSDarren Tucker	AC_DEFINE([PLATFORM_SYS_DIR_UID], 2, [System dirs owned by bin (uid 2)])
74290f42b07STim Rice	maildir="/var/mail"
743fd33328aSDarren Tucker	LIBS="$LIBS -lsec"
744648f8765STim Rice	AC_CHECK_LIB([xnet], [t_error], ,
745648f8765STim Rice	    [AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***])])
746fd33328aSDarren Tucker
747fd33328aSDarren Tucker	# next, we define all of the options specific to major releases
748fd33328aSDarren Tucker	case "$host" in
7498ad995fdSTim Rice	*-*-hpux10*)
7508ad995fdSTim Rice		if test -z "$GCC"; then
7518ad995fdSTim Rice			CFLAGS="$CFLAGS -Ae"
7528ad995fdSTim Rice		fi
7538ad995fdSTim Rice		;;
7548ad995fdSTim Rice	*-*-hpux11*)
755648f8765STim Rice		AC_DEFINE([PAM_SUN_CODEBASE], [1],
7567df8d39aSTim Rice			[Define if you are using Solaris-derived PAM which
7577df8d39aSTim Rice			passes pam_messages to the conversation function
7587df8d39aSTim Rice			with an extra level of indirection])
759648f8765STim Rice		AC_DEFINE([DISABLE_UTMP], [1],
7607df8d39aSTim Rice			[Define if you don't want to use utmp])
761648f8765STim Rice		AC_DEFINE([USE_BTMP], [1], [Use btmp to log bad logins])
7624398cf59SDarren Tucker		check_for_hpux_broken_getaddrinfo=1
763a56f191eSDarren Tucker		check_for_conflicting_getspnam=1
764fd33328aSDarren Tucker		;;
765fd33328aSDarren Tucker	esac
766fd33328aSDarren Tucker
767fd33328aSDarren Tucker	# lastly, we define options specific to minor releases
768fd33328aSDarren Tucker	case "$host" in
769fd33328aSDarren Tucker	*-*-hpux10.26)
770648f8765STim Rice		AC_DEFINE([HAVE_SECUREWARE], [1],
7717df8d39aSTim Rice			[Define if you have SecureWare-based
7727df8d39aSTim Rice			protected password database])
773fd33328aSDarren Tucker		disable_ptmx_check=yes
774fd33328aSDarren Tucker		LIBS="$LIBS -lsecpw"
775fd33328aSDarren Tucker		;;
776fd33328aSDarren Tucker	esac
7778ad995fdSTim Rice	;;
7788ad995fdSTim Rice*-*-irix5*)
7798ad995fdSTim Rice	PATH="$PATH:/usr/etc"
780648f8765STim Rice	AC_DEFINE([BROKEN_INET_NTOA], [1],
7817df8d39aSTim Rice		[Define if you system's inet_ntoa is busted
7827df8d39aSTim Rice		(e.g. Irix gcc issue)])
783648f8765STim Rice	AC_DEFINE([SETEUID_BREAKS_SETUID])
784648f8765STim Rice	AC_DEFINE([BROKEN_SETREUID])
785648f8765STim Rice	AC_DEFINE([BROKEN_SETREGID])
786648f8765STim Rice	AC_DEFINE([WITH_ABBREV_NO_TTY], [1],
7877df8d39aSTim Rice		[Define if you shouldn't strip 'tty' from your
7887df8d39aSTim Rice		ttyname in [uw]tmp])
789648f8765STim Rice	AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
7908ad995fdSTim Rice	;;
7918ad995fdSTim Rice*-*-irix6*)
7928ad995fdSTim Rice	PATH="$PATH:/usr/etc"
793648f8765STim Rice	AC_DEFINE([WITH_IRIX_ARRAY], [1],
7947df8d39aSTim Rice		[Define if you have/want arrays
79510479cc2SDamien Miller		(cluster-wide session management, not C arrays)])
796648f8765STim Rice	AC_DEFINE([WITH_IRIX_PROJECT], [1],
7977df8d39aSTim Rice		[Define if you want IRIX project management])
798648f8765STim Rice	AC_DEFINE([WITH_IRIX_AUDIT], [1],
7997df8d39aSTim Rice		[Define if you want IRIX audit trails])
800648f8765STim Rice	AC_CHECK_FUNC([jlimit_startjob], [AC_DEFINE([WITH_IRIX_JOBS], [1],
8017df8d39aSTim Rice		[Define if you want IRIX kernel jobs])])
802648f8765STim Rice	AC_DEFINE([BROKEN_INET_NTOA])
803648f8765STim Rice	AC_DEFINE([SETEUID_BREAKS_SETUID])
804648f8765STim Rice	AC_DEFINE([BROKEN_SETREUID])
805648f8765STim Rice	AC_DEFINE([BROKEN_SETREGID])
806648f8765STim Rice	AC_DEFINE([BROKEN_UPDWTMPX], [1], [updwtmpx is broken (if present)])
807648f8765STim Rice	AC_DEFINE([WITH_ABBREV_NO_TTY])
808648f8765STim Rice	AC_DEFINE([LOCKED_PASSWD_STRING], ["*LK*"])
8098ad995fdSTim Rice	;;
8109055172dSDamien Miller*-*-k*bsd*-gnu | *-*-kopensolaris*-gnu)
8119055172dSDamien Miller	check_for_libcrypt_later=1
812648f8765STim Rice	AC_DEFINE([PAM_TTY_KLUDGE])
813648f8765STim Rice	AC_DEFINE([LOCKED_PASSWD_PREFIX], ["!"])
814648f8765STim Rice	AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
815648f8765STim Rice	AC_DEFINE([_PATH_BTMP], ["/var/log/btmp"], [log for bad login attempts])
816648f8765STim Rice	AC_DEFINE([USE_BTMP], [1], [Use btmp to log bad logins])
8179055172dSDamien Miller	;;
8188ad995fdSTim Rice*-*-linux*)
8198ad995fdSTim Rice	no_dev_ptmx=1
820852472a5SDamien Miller	use_pie=auto
8218ad995fdSTim Rice	check_for_libcrypt_later=1
82270a3d55bSDarren Tucker	check_for_openpty_ctty_bug=1
823c61d5ec3SDarren Tucker	dnl Target SUSv3/POSIX.1-2001 plus BSD specifics.
824c61d5ec3SDarren Tucker	dnl _DEFAULT_SOURCE is the new name for _BSD_SOURCE
825c61d5ec3SDarren Tucker	CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=600 -D_BSD_SOURCE -D_DEFAULT_SOURCE"
826648f8765STim Rice	AC_DEFINE([PAM_TTY_KLUDGE], [1],
8277df8d39aSTim Rice		[Work around problematic Linux PAM modules handling of PAM_TTY])
828648f8765STim Rice	AC_DEFINE([LOCKED_PASSWD_PREFIX], ["!"],
8297df8d39aSTim Rice		[String used in /etc/passwd to denote locked account])
830648f8765STim Rice	AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
831648f8765STim Rice	AC_DEFINE([LINK_OPNOTSUPP_ERRNO], [EPERM],
8327df8d39aSTim Rice		[Define to whatever link() returns for "not supported"
8337df8d39aSTim Rice		if it doesn't return EOPNOTSUPP.])
834648f8765STim Rice	AC_DEFINE([_PATH_BTMP], ["/var/log/btmp"], [log for bad login attempts])
835648f8765STim Rice	AC_DEFINE([USE_BTMP])
836648f8765STim Rice	AC_DEFINE([LINUX_OOM_ADJUST], [1], [Adjust Linux out-of-memory killer])
8378ad995fdSTim Rice	inet6_default_4in6=yes
838c437cda3SDarren Tucker	case `uname -r` in
839c437cda3SDarren Tucker	1.*|2.0.*)
840648f8765STim Rice		AC_DEFINE([BROKEN_CMSG_TYPE], [1],
8417df8d39aSTim Rice			[Define if cmsg_type is not passed correctly])
8423c01654dSDarren Tucker		;;
8433c01654dSDarren Tucker	esac
84489e03baeSDamien Miller	# tun(4) forwarding compat code
845648f8765STim Rice	AC_CHECK_HEADERS([linux/if_tun.h])
846bd4e4108SDamien Miller	if test "x$ac_cv_header_linux_if_tun_h" = "xyes" ; then
847648f8765STim Rice		AC_DEFINE([SSH_TUN_LINUX], [1],
84889e03baeSDamien Miller		    [Open tunnel devices the Linux tun/tap way])
849648f8765STim Rice		AC_DEFINE([SSH_TUN_COMPAT_AF], [1],
85089e03baeSDamien Miller		    [Use tunnel device compatibility to OpenBSD])
851648f8765STim Rice		AC_DEFINE([SSH_TUN_PREPEND_AF], [1],
85289e03baeSDamien Miller		    [Prepend the address family to IP tunnel traffic])
85389e03baeSDamien Miller	fi
85481c9ccdbSDarren Tucker	AC_CHECK_HEADER([linux/if.h],
8556bd5b569SDamien Miller	    AC_DEFINE([SYS_RDOMAIN_LINUX], [1],
85624d2a33bSDarren Tucker		[Support routing domains using Linux VRF]), [], [
85724d2a33bSDarren Tucker#ifdef HAVE_SYS_TYPES_H
8588729498aSDamien Miller# include <sys/types.h>
85924d2a33bSDarren Tucker#endif
86024d2a33bSDarren Tucker	    ])
86160395f91SDarren Tucker	AC_CHECK_HEADERS([linux/seccomp.h linux/filter.h linux/audit.h], [],
86260395f91SDarren Tucker	    [], [#include <linux/types.h>])
86358008670SVicente Olivert Riera	# Obtain MIPS ABI
86458008670SVicente Olivert Riera	case "$host" in
86558008670SVicente Olivert Riera	mips*)
866fbd733abSDarren Tucker		AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
86758008670SVicente Olivert Riera#if _MIPS_SIM != _ABIO32
86858008670SVicente Olivert Riera#error
86958008670SVicente Olivert Riera#endif
870fbd733abSDarren Tucker			]])],[mips_abi="o32"],[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
87158008670SVicente Olivert Riera#if _MIPS_SIM != _ABIN32
87258008670SVicente Olivert Riera#error
87358008670SVicente Olivert Riera#endif
874fbd733abSDarren Tucker				]])],[mips_abi="n32"],[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
87558008670SVicente Olivert Riera#if _MIPS_SIM != _ABI64
87658008670SVicente Olivert Riera#error
87758008670SVicente Olivert Riera#endif
878fbd733abSDarren Tucker					]])],[mips_abi="n64"],[AC_MSG_ERROR([unknown MIPS ABI])
87958008670SVicente Olivert Riera				])
88058008670SVicente Olivert Riera			])
88158008670SVicente Olivert Riera		])
88258008670SVicente Olivert Riera		;;
88358008670SVicente Olivert Riera	esac
88491f40d85SDamien Miller	AC_MSG_CHECKING([for seccomp architecture])
88591f40d85SDamien Miller	seccomp_audit_arch=
886e0956e38SDamien Miller	case "$host" in
887e0956e38SDamien Miller	x86_64-*)
88891f40d85SDamien Miller		seccomp_audit_arch=AUDIT_ARCH_X86_64
889e0956e38SDamien Miller		;;
890e0956e38SDamien Miller	i*86-*)
89191f40d85SDamien Miller		seccomp_audit_arch=AUDIT_ARCH_I386
892e0956e38SDamien Miller		;;
89391f40d85SDamien Miller	arm*-*)
89491f40d85SDamien Miller		seccomp_audit_arch=AUDIT_ARCH_ARM
895e0956e38SDamien Miller		;;
89699f33d73SDamien Miller	aarch64*-*)
89799f33d73SDamien Miller		seccomp_audit_arch=AUDIT_ARCH_AARCH64
8985c15e22cSDamien Miller		;;
899b9c50614SDamien Miller	s390x-*)
900b9c50614SDamien Miller		seccomp_audit_arch=AUDIT_ARCH_S390X
901b9c50614SDamien Miller		;;
902b9c50614SDamien Miller	s390-*)
903b9c50614SDamien Miller		seccomp_audit_arch=AUDIT_ARCH_S390
904b9c50614SDamien Miller		;;
905b9c50614SDamien Miller	powerpc64-*)
906b9c50614SDamien Miller		seccomp_audit_arch=AUDIT_ARCH_PPC64
907b9c50614SDamien Miller		;;
908b9c50614SDamien Miller	powerpc64le-*)
909b9c50614SDamien Miller		seccomp_audit_arch=AUDIT_ARCH_PPC64LE
910b9c50614SDamien Miller		;;
911b9c50614SDamien Miller	mips-*)
912b9c50614SDamien Miller		seccomp_audit_arch=AUDIT_ARCH_MIPS
913b9c50614SDamien Miller		;;
914b9c50614SDamien Miller	mipsel-*)
915b9c50614SDamien Miller		seccomp_audit_arch=AUDIT_ARCH_MIPSEL
916b9c50614SDamien Miller		;;
917b9c50614SDamien Miller	mips64-*)
91845011511SVicente Olivert Riera		case "$mips_abi" in
91945011511SVicente Olivert Riera		"n32")
92045011511SVicente Olivert Riera			seccomp_audit_arch=AUDIT_ARCH_MIPS64N32
92145011511SVicente Olivert Riera			;;
92245011511SVicente Olivert Riera		"n64")
923b9c50614SDamien Miller			seccomp_audit_arch=AUDIT_ARCH_MIPS64
924b9c50614SDamien Miller			;;
92545011511SVicente Olivert Riera		esac
92645011511SVicente Olivert Riera		;;
927b9c50614SDamien Miller	mips64el-*)
928