1# $Id: configure.ac,v 1.519 2013/03/22 01:49:15 dtucker Exp $
2#
3# Copyright (c) 2016 Gilles Chehade <gilles@poolp.org>
4# Copyright (c) 1999-2004 Damien Miller
5#
6# Permission to use, copy, modify, and distribute this software for any
7# purpose with or without fee is hereby granted, provided that the above
8# copyright notice and this permission notice appear in all copies.
9#
10# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17
18
19#
20# WE NEED TO CLEANUP CONFIGURE.AC AND MAKE IT FOLLOW THE
21# STANDARD LAYOUT ...
22#
23# 3.1.3 Standard configure.ac Layout
24#
25# https://www.gnu.org/software/autoconf/manual/autoconf-2.69/html_node/Autoconf-Input-Layout.html
26#
27
28
29#
30# AUTOCONF REQUIREMENTS
31#
32AC_PREREQ(2.69)
33
34
35#
36# AC_INIT
37#
38AC_INIT([OpenSMTPD],
39	[portable],
40	[bugs@opensmtpd.org],
41	[opensmtpd],
42	[https://www.OpenSMTPD.org])
43
44AM_INIT_AUTOMAKE([subdir-objects no-dependencies])
45LT_INIT
46
47# here we should test for variables set by libtool detection
48if test "x$with_pic" != "xno"; then
49	CFLAGS="$CFLAGS ${pic_flag}"
50fi
51
52
53#
54# PACKAGE INFORMATION
55#
56AC_LANG([C])
57AC_CONFIG_MACRO_DIR([m4])
58AC_CONFIG_HEADER([config.h])
59AC_PROG_CC
60AC_CANONICAL_HOST
61AC_C_BIGENDIAN
62
63
64#
65# CHECKS FOR PROGRAMS
66#
67AC_PROG_CPP
68AC_PROG_INSTALL
69AC_PROG_LIBTOOL
70AC_PATH_PROG([AR], [ar])
71AC_PATH_PROG([CAT], [cat])
72AC_PATH_PROG([CHMOD], [chmod])
73AC_PATH_PROG([CHOWN], [chown])
74AC_PATH_PROG([ZCAT], [zcat])
75AC_PATH_PROG([SED], [sed])
76AC_PATH_PROG([TEST_MINUS_S_SH], [bash])
77AC_PATH_PROG([TEST_MINUS_S_SH], [ksh])
78AC_PATH_PROG([TEST_MINUS_S_SH], [sh])
79AC_PATH_PROG([SH], [sh])
80AC_PATH_PROG([GROFF], [groff])
81AC_PATH_PROG([NROFF], [nroff])
82AC_PATH_PROG([MANDOC], [mandoc])
83AC_PROG_YACC
84
85AC_SUBST([ZCAT])
86
87
88if test -z "$AR"; then
89	AC_MSG_ERROR([*** 'ar' missing, please install or fix your \$PATH ***])
90fi
91
92if test -z "$LD"; then
93	LD=$CC
94fi
95AC_SUBST([LD])
96
97dnl select manpage formatter
98if test -n "$MANDOC"; then
99	MANFMT="$MANDOC"
100elif test -n "$NROFF"; then
101	MANFMT="$NROFF -mandoc"
102elif test -n "$GROFF"; then
103	MANFMT="$GROFF -mandoc -Tascii"
104else
105	AC_MSG_WARN([no manpage formatted found])
106	MANFMT="false"
107fi
108AC_SUBST([MANFMT])
109
110
111#
112# CHECKS FOR LIBRARIES
113#
114
115
116
117#
118# CHECKS FOR HEADERS
119#
120AC_CHECK_HEADERS([ \
121	arpa/nameser_compat.h \
122	crypt.h \
123	dirent.h \
124	err.h \
125	fcntl.h \
126	getopt.h \
127	grp.h \
128	libgen.h \
129	limits.h \
130	maillock.h \
131	mach/mach_time.h \
132	ndir.h \
133	netdb.h \
134	pam/pam_appl.h \
135	paths.h \
136	security/pam_appl.h \
137	shadow.h \
138	sys/cdefs.h \
139	sys/dir.h \
140	sys/file.h \
141	sys/mount.h \
142	sys/ndir.h \
143	sys/pstat.h \
144	sys/statfs.h \
145	sys/time.h \
146	sys/un.h \
147	time.h \
148	ucred.h \
149	util.h \
150	vis.h
151])
152
153AM_CONDITIONAL([NEED_ERR_H], [test x$HAVE_ERR_H = x1])
154AM_CONDITIONAL([SUPPORT_PATHS_H], [test x$HAVE_PATHS_H = x1])
155
156# NetBSD requires sys/types.h before login_cap.h
157AC_CHECK_HEADERS([login_cap.h], [], [], [
158#include <sys/types.h>
159])
160
161# older BSDs need sys/param.h before sys/mount.h
162AC_CHECK_HEADERS([sys/mount.h], [], [], [
163#include <sys/param.h>
164])
165
166AC_CHECK_HEADERS([bsd/libutil.h libutil.h])
167
168AC_CHECK_HEADER([fts.h],
169	[],
170	[AC_MSG_ERROR([*** fts.h missing - please install libfts ***])],
171	[
172#include <sys/types.h>
173#include <sys/stat.h>
174])
175
176need_libasr=no
177AC_CHECK_HEADER([asr.h],
178	[],
179	[need_libasr=yes],
180	[
181#include <sys/types.h>
182#include <sys/socket.h>
183#include <netdb.h>
184])
185AM_CONDITIONAL([NEED_LIBASR], [test x"$need_libasr" = x"yes"])
186
187#
188# CHECKS FOR TYPES
189#
190AC_CHECK_TYPES([long long, unsigned long long, long double, u_int, u_char])
191AC_CHECK_SIZEOF([short int], [2])
192AC_CHECK_SIZEOF([int], [4])
193AC_CHECK_SIZEOF([long int], [4])
194AC_CHECK_SIZEOF([long long int], [8])
195
196AC_TYPE_INT8_T
197AC_TYPE_INT16_T
198AC_TYPE_INT32_T
199AC_TYPE_INT64_T
200AC_TYPE_UINT8_T
201AC_TYPE_UINT16_T
202AC_TYPE_UINT32_T
203AC_TYPE_UINT64_T
204AC_TYPE_INTPTR_T
205AC_TYPE_INTMAX_T
206AC_TYPE_UINTPTR_T
207AC_TYPE_UINTMAX_T
208AC_TYPE_SIZE_T
209AC_TYPE_SSIZE_T
210AC_TYPE_OFF_T
211AC_TYPE_MODE_T
212AC_TYPE_PID_T
213AC_TYPE_UID_T
214
215TYPE_SOCKLEN_T
216
217AC_CHECK_TYPES([sig_atomic_t], [], [], [
218#include <signal.h>
219])
220AC_CHECK_TYPES([fsblkcnt_t, fsfilcnt_t], [], [], [
221#include <sys/types.h>
222#ifdef HAVE_SYS_BITYPES_H
223#include <sys/bitypes.h>
224#endif
225#ifdef HAVE_SYS_STATFS_H
226#include <sys/statfs.h>
227#endif
228#ifdef HAVE_SYS_STATVFS_H
229#include <sys/statvfs.h>
230#endif
231])
232
233AC_CHECK_TYPES([in_addr_t, in_port_t], [], [], [
234#include <sys/types.h>
235#include <netinet/in.h>
236])
237
238AC_CHECK_TYPES([sa_family_t], [], [], [
239#include <sys/types.h>
240#include <sys/socket.h>
241#include <netinet/in.h>
242])
243
244AC_CHECK_TYPES([struct timespec])
245AC_CHECK_TYPES([struct ifgroupreq])
246AC_CHECK_TYPES([struct sockaddr_storage], [], [], [
247#include <sys/types.h>
248#include <sys/socket.h>
249])
250AC_CHECK_TYPES([struct sockaddr_in6], [], [], [
251#include <sys/types.h>
252#include <netinet/in.h>
253])
254AC_CHECK_TYPES([struct in6_addr], [], [], [
255#include <sys/types.h>
256#include <netinet/in.h>
257])
258AC_CHECK_TYPES([struct addrinfo], [], [], [
259#include <sys/types.h>
260#include <sys/socket.h>
261#include <netdb.h>
262])
263AC_CHECK_TYPES([struct timeval], [], [], [
264#include <sys/time.h>
265])
266
267AC_CHECK_DECL([LLONG_MAX], [have_llong_max=1], , [#include <limits.h>])
268
269
270#
271# CHECKS FOR STRUCTURES
272#
273AC_CHECK_MEMBERS([struct sockaddr_in6.sin6_scope_id], [], [], [
274#ifdef HAVE_SYS_TYPES_H
275#include <sys/types.h>
276#endif
277#include <netinet/in.h>
278])
279
280AC_CHECK_MEMBERS([struct passwd.pw_gecos, struct passwd.pw_class,
281struct passwd.pw_change, struct passwd.pw_expire],
282[], [], [
283#include <sys/types.h>
284#include <pwd.h>
285])
286
287AC_CHECK_MEMBERS([struct stat.st_flags], , ,
288	[ #include <sys/types.h>
289	  #include <sys/stat.h> ]
290)
291
292AC_CHECK_MEMBERS([struct stat.st_mtim], , ,
293	[ #include <sys/types.h>
294	  #include <sys/stat.h> ]
295)
296
297AC_CHECK_MEMBERS([struct stat.st_mtimespec], , ,
298	[ #include <sys/types.h>
299	  #include <sys/stat.h> ]
300)
301
302AC_CHECK_MEMBERS([struct sockaddr.sa_len], , ,
303	[ #include <netdb.h>
304	  #include <netinet/in.h>
305	  #include <sys/socket.h> ]
306)
307
308AC_CHECK_MEMBERS([struct sockaddr_storage.ss_len], , ,
309	[ #include <netdb.h>
310	  #include <netinet/in.h>
311	  #include <sys/socket.h> ]
312)
313
314AC_CHECK_MEMBERS([struct sockaddr_in.sin_len], , ,
315	[ #include <netdb.h>
316	  #include <netinet/in.h>
317	  #include <sys/socket.h> ]
318)
319
320AC_CHECK_MEMBERS([struct sockaddr_in6.sin6_len], , ,
321	[ #include <netdb.h>
322	  #include <netinet/in.h>
323	  #include <sys/socket.h> ]
324)
325
326AC_CHECK_MEMBERS([struct statfs.f_favail], , ,
327	[ #include <sys/vfs.h>
328	  #include <sys/statfs.h> ]
329)
330
331AC_CHECK_MEMBERS([struct sockaddr_storage.ss_family], [], [], [
332#include <sys/types.h>
333#include <sys/socket.h>
334])
335
336AC_CHECK_MEMBERS([struct sockaddr_storage.__ss_family], [], [], [
337#include <sys/types.h>
338#include <sys/socket.h>
339])
340
341AC_CHECK_MEMBERS([struct tm.tm_gmtoff, struct tm.tm_zone], [],
342	[
343		AC_CHECK_DECLS([timezone, altzone, tzname],
344			[],
345			[ AC_MSG_ERROR([cannot find timezone])],
346			[ #include <time.h> ]
347		)
348	],
349	[ #include <time.h> ]
350)
351
352AC_CHECK_MEMBERS([struct DIR.d_type], [], [], [
353#include <sys/types.h>
354#include <dirent.h>
355])
356
357#
358# CHECKS FOR DECLARATIONS
359#
360AC_CHECK_DECLS([O_NONBLOCK], [], [], [
361#include <sys/types.h>
362#ifdef HAVE_SYS_STAT_H
363# include <sys/stat.h>
364#endif
365#ifdef HAVE_FCNTL_H
366# include <fcntl.h>
367#endif
368])
369
370AC_CHECK_DECLS([AF_LOCAL, PF_LOCAL], [], [], [
371#include <sys/socket.h>
372])
373
374AC_CHECK_DECLS([IPPORT_HILASTAUTO], [], [], [
375#include <netinet/in.h>
376])
377
378AC_CHECK_DECLS([WAIT_MYPGRP], [], [], [
379#include <sys/wait.h>
380])
381
382AC_CHECK_DECLS([writev], [], [], [
383#include <sys/types.h>
384#include <sys/uio.h>
385#include <unistd.h>
386])
387
388AC_CHECK_DECLS([LOG_PERROR], [], [], [
389#include <syslog.h>
390])
391
392
393#
394# CHECKS FOR COMPILER CHARACTERISTICS
395#
396AC_C_INLINE
397
398
399AC_ARG_WITH([libs],
400	[  --with-libs			Specify additional libraries to link with],
401	[
402		if test -n "$withval" -a "$withval" != "no" -a "${withval}" != "yes"; then
403			LIBS="$LIBS $withval"
404		fi
405	]
406)
407#
408# CHECKS FOR LIBRARY FUNCTIONS
409#
410AC_SEARCH_LIBS([basename],
411	[gen],
412	[
413		AC_DEFINE([HAVE_BASENAME], [1],
414			[Define if you have the basename() function.])
415	])
416
417AC_SEARCH_LIBS([closefrom],
418	[gen],
419	[
420		AC_DEFINE([HAVE_CLOSEFROM], [1],
421			[Define if you have the closefrom() function.])
422        AC_COMPILE_IFELSE(
423            [
424                AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[int res = closefrom(0);]])
425            ],
426            AC_DEFINE(HAVE_CLOSEFROM_INT, 1, [closefrom return int])
427        )
428	])
429
430AC_SEARCH_LIBS([fmt_scaled],
431	[util bsd],
432	[
433		AC_DEFINE([HAVE_FMT_SCALED], [1],
434			[Define if you have the fmt_scaled() function.])
435	])
436
437AC_SEARCH_LIBS([dirname],
438	[gen],
439	[
440		AC_DEFINE([HAVE_DIRNAME], [1],
441			[Define if you have the dirname() function.])
442	])
443
444AC_SEARCH_LIBS([inet_net_pton],
445	[resolv bsd],
446	[
447		AC_DEFINE([HAVE_INET_NET_PTON], [1],
448			[Define if you have the inet_net_pton() function.])
449	])
450
451AC_SEARCH_LIBS([clock_gettime],
452	[rt],
453	[
454		AC_DEFINE([HAVE_CLOCK_GETTIME], [1],
455			[Define if you have the clock_gettime() function.])
456	])
457
458AC_SEARCH_LIBS([fts_open],
459	[fts],
460	[
461		AC_DEFINE([HAVE_FTS_OPEN], [1],
462			[Define if you have the fts_open() function.])
463	])
464
465AC_SEARCH_LIBS([daemon],
466	[bsd],
467	[
468		AC_DEFINE([HAVE_DAEMON], [1],
469			[Define if you have the daemon() function.])
470	])
471
472AC_SEARCH_LIBS([fparseln],
473	[util],
474	[
475		AC_DEFINE([HAVE_FPARSELN], [1],
476			[Define if you have the fparseln() function.])
477	])
478
479AC_SEARCH_LIBS([res_hnok],
480	[resolv],
481	[
482		AC_DEFINE([HAVE_RES_HNOK], [1],
483			[Define if you have the res_hnok() function.])
484	])
485
486AC_SEARCH_LIBS([res_randomid],
487	[resolv],
488	[
489		AC_DEFINE([HAVE_RES_RANDOMID], [1],
490			[Define if you have the res_randomid() function.])
491	])
492
493AC_SEARCH_LIBS([res_9_b64_ntop],
494	[resolv],
495	[
496		AC_DEFINE([HAVE_RES_9_B64_NTOP], [1],
497			[Define if you have the res_9_b64_ntop() function.])
498	])
499
500AC_SEARCH_LIBS([__b64_pton],
501	[resolv],
502	[
503		AC_DEFINE([HAVE___B64_PTON], [1],
504			[Define if you have the __b64_pton() function.])
505	])
506
507AC_SEARCH_LIBS([b64_pton],
508	[resolv],
509	[
510		AC_DEFINE([HAVE_B64_PTON], [1],
511			[Define if you have the b64_pton() function.])
512	])
513
514AC_SEARCH_LIBS([__b64_ntop],
515	[resolv],
516	[
517		AC_DEFINE([HAVE___B64_NTOP], [1],
518			[Define if you have the b64_ntop() function.])
519	])
520
521AC_SEARCH_LIBS([b64_ntop],
522	[resolv],
523	[
524		AC_DEFINE([HAVE_B64_NTOP], [1],
525			[Define if you have the b64_ntop() function.])
526	])
527
528AC_SEARCH_LIBS([setsockopt],
529	[socket],
530	[
531		AC_DEFINE([HAVE_SETSOCKOPT], [1],
532			[Define if you have the setsockopt() function.])
533	])
534
535AC_SEARCH_LIBS([crypt],
536	[crypt],
537	[
538		AC_DEFINE([HAVE_CRYPT], [1],
539			[Define if you have the crypt() function.])
540	])
541
542AC_SEARCH_LIBS([imsg_init],
543	[util],
544	[
545		AC_DEFINE([HAVE_IMSG], [1],
546			[Define if you have the imsg framework.])
547	])
548
549AC_SEARCH_LIBS([event_asr_run],
550	[event],
551	[
552		AC_DEFINE([HAVE_EVENT_ASR_RUN], [1],
553			[Define if you have the event_asr_run() function.])
554	])
555
556AC_CHECK_FUNCS([ \
557	asprintf \
558	arc4random \
559	bcopy \
560	calloc_conceal \
561	chflags \
562	crypt_checkpass \
563	dirfd \
564	err \
565	errc \
566	errx \
567	explicit_bzero \
568	fchflags \
569	fgetln \
570	flock \
571	freeaddrinfo \
572	freezero \
573	getaddrinfo \
574	getdtablesize \
575	getdtablecount \
576	getline \
577	getnameinfo \
578	gettimeofday \
579	getopt \
580	getpeereid \
581	getpeerucred \
582	getspnam \
583	inet_aton \
584	inet_ntoa \
585	inet_ntop \
586	malloc_conceal \
587	memmove \
588	nanosleep \
589	nsleep \
590	pipe2 \
591	pidfile \
592	pledge \
593	reallocarray \
594	recallocarray \
595	res_hnok \
596	res_randomid \
597	setenv \
598	seteuid \
599	setegid \
600	setproctitle \
601	setregid \
602	setreuid \
603	setresuid \
604	setresgid \
605	setsid \
606	signal \
607	sigaction \
608	snprintf \
609	socketpair \
610	strdup \
611	strerror \
612	strlcat \
613	strlcpy \
614	strmode \
615	strndup \
616	strnlen \
617	strnvis \
618	strtonum \
619	sysconf \
620	tcgetpgrp \
621	time \
622	usleep \
623	vasprintf \
624	vsnprintf \
625	waitpid \
626	warn \
627	warnx \
628])
629
630AC_CHECK_DECL([strsep],
631	[AC_CHECK_FUNCS([strsep])],
632	[],
633	[
634#ifdef HAVE_STRING_H
635# include <string.h>
636#endif
637	])
638
639
640# These functions might be found in libressl
641AC_CHECK_DECLS([strlcat, strlcpy],
642	[],
643	[],
644	[])
645
646#
647# CHECKS FOR SYSTEM SERVICES
648#
649AC_MSG_CHECKING([for /proc/pid/fd directory])
650if test -d "/proc/$$/fd"; then
651	AC_DEFINE([HAVE_PROC_PID], [1], [Define if you have /proc/$pid/fd])
652	AC_MSG_RESULT([yes])
653else
654	AC_MSG_RESULT([no])
655fi
656
657
658#
659# AC_CONFIG_FILES
660#
661
662#
663# AC_OUTPUT
664#
665
666
667###
668### EVERYTHING BELOW MUST BE CLEANED AND MOVED ABOVE
669###
670
671#l150 (without _FORTIFY_SOURCE=2)
672if test "$GCC" = "yes" -o "$GCC" = "egcs"; then
673	OSSH_CHECK_CFLAG_COMPILE([-Qunused-arguments])
674	OSSH_CHECK_CFLAG_COMPILE([-Wunknown-warning-option])
675	OSSH_CHECK_CFLAG_COMPILE([-Wall])
676	OSSH_CHECK_CFLAG_COMPILE([-Wpointer-arith])
677	OSSH_CHECK_CFLAG_COMPILE([-Wuninitialized])
678	OSSH_CHECK_CFLAG_COMPILE([-Wsign-compare])
679	OSSH_CHECK_CFLAG_COMPILE([-Wformat-security])
680	OSSH_CHECK_CFLAG_COMPILE([-Wsizeof-pointer-memaccess])
681	OSSH_CHECK_CFLAG_COMPILE([-Wpointer-sign], [-Wno-pointer-sign])
682	OSSH_CHECK_CFLAG_COMPILE([-Wunused-result], [-Wno-unused-result])
683	OSSH_CHECK_CFLAG_COMPILE([-fno-strict-aliasing])
684#	OSSH_CHECK_CFLAG_COMPILE([-D_FORTIFY_SOURCE=2])
685    if test "x$use_toolchain_hardening" = "x1"; then
686	OSSH_CHECK_LDFLAG_LINK([-Wl,-z,relro])
687	OSSH_CHECK_LDFLAG_LINK([-Wl,-z,now])
688	OSSH_CHECK_LDFLAG_LINK([-Wl,-z,noexecstack])
689	# NB. -ftrapv expects certain support functions to be present in
690	# the compiler library (libgcc or similar) to detect integer operations
691	# that can overflow. We must check that the result of enabling it
692	# actually links. The test program compiled/linked includes a number
693	# of integer operations that should exercise this.
694	OSSH_CHECK_CFLAG_LINK([-ftrapv])
695    fi
696	AC_MSG_CHECKING([gcc version])
697	GCC_VER=`$CC -v 2>&1 | $AWK '/gcc version /{print $3}'`
698	case $GCC_VER in
699		1.*) no_attrib_nonnull=1 ;;
700		2.8* | 2.9*)
701		     no_attrib_nonnull=1
702		     ;;
703		2.*) no_attrib_nonnull=1 ;;
704		*) ;;
705	esac
706	AC_MSG_RESULT([$GCC_VER])
707
708	AC_MSG_CHECKING([if $CC accepts -fno-builtin-memset])
709	saved_CFLAGS="$CFLAGS"
710	CFLAGS="$CFLAGS -fno-builtin-memset"
711	AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <string.h> ]],
712			[[ char b[10]; memset(b, 0, sizeof(b)); ]])],
713		[ AC_MSG_RESULT([yes]) ],
714		[ AC_MSG_RESULT([no])
715		  CFLAGS="$saved_CFLAGS" ]
716	)
717
718	# -fstack-protector-all doesn't always work for some GCC versions
719	# and/or platforms, so we test if we can.  If it's not supported
720	# on a given platform gcc will emit a warning so we use -Werror.
721	if test "x$use_stack_protector" = "x1"; then
722	    for t in -fstack-protector-strong -fstack-protector-all \
723		    -fstack-protector; do
724		AC_MSG_CHECKING([if $CC supports $t])
725		saved_CFLAGS="$CFLAGS"
726		saved_LDFLAGS="$LDFLAGS"
727		CFLAGS="$CFLAGS $t -Werror"
728		LDFLAGS="$LDFLAGS $t -Werror"
729		AC_LINK_IFELSE(
730			[AC_LANG_PROGRAM([[ #include <stdio.h> ]],
731			[[
732	char x[256];
733	snprintf(x, sizeof(x), "XXX");
734			 ]])],
735		    [ AC_MSG_RESULT([yes])
736		      CFLAGS="$saved_CFLAGS $t"
737		      LDFLAGS="$saved_LDFLAGS $t"
738		      AC_MSG_CHECKING([if $t works])
739		      AC_RUN_IFELSE(
740			[AC_LANG_PROGRAM([[ #include <stdio.h> ]],
741			[[
742	char x[256];
743	snprintf(x, sizeof(x), "XXX");
744			]])],
745			[ AC_MSG_RESULT([yes])
746			  break ],
747			[ AC_MSG_RESULT([no]) ],
748			[ AC_MSG_WARN([cross compiling: cannot test])
749			  break ]
750		      )
751		    ],
752		    [ AC_MSG_RESULT([no]) ]
753		)
754		CFLAGS="$saved_CFLAGS"
755		LDFLAGS="$saved_LDFLAGS"
756	    done
757	fi
758
759	if test -z "$have_llong_max"; then
760		# retry LLONG_MAX with -std=gnu99, needed on some Linuxes
761		unset ac_cv_have_decl_LLONG_MAX
762		saved_CFLAGS="$CFLAGS"
763		CFLAGS="$CFLAGS -std=gnu99"
764		AC_CHECK_DECL([LLONG_MAX],
765		    [have_llong_max=1],
766		    [CFLAGS="$saved_CFLAGS"],
767		    [#include <limits.h>]
768		)
769	fi
770fi
771
772AC_MSG_CHECKING([if compiler allows __attribute__ on return types])
773AC_COMPILE_IFELSE(
774    [AC_LANG_PROGRAM([[
775#include <stdlib.h>
776__attribute__((__unused__)) static void foo(void){return;}]],
777    [[ exit(0); ]])],
778    [ AC_MSG_RESULT([yes]) ],
779    [ AC_MSG_RESULT([no])
780      AC_DEFINE(NO_ATTRIBUTE_ON_RETURN_TYPE, 1,
781	 [compiler does not accept __attribute__ on return types]) ]
782)
783
784if test "x$no_attrib_nonnull" != "x1"; then
785	AC_DEFINE([HAVE_ATTRIBUTE__NONNULL__], [1], [Have attribute nonnull])
786fi
787
788AC_ARG_WITH([rpath],
789	[  --without-rpath		Disable auto-added -R linker paths],
790	[
791		if test "x$withval" = "xno"; then
792			need_dash_r=""
793		fi
794		if test "x$withval" = "xyes"; then
795			need_dash_r=1
796		fi
797	]
798)
799
800
801AC_ARG_WITH([cflags],
802	[  --with-cflags			Specify additional flags to pass to compiler],
803	[
804		if test -n "$withval" -a "$withval" != "no" -a "${withval}" != "yes"; then
805			CFLAGS="$CFLAGS $withval"
806		fi
807	]
808)
809AC_ARG_WITH([cppflags],
810	[  --with-cppflags		Specify additional flags to pass to preprocessor] ,
811	[
812		if test -n "$withval" -a "$withval" != "no" -a "${withval}" != "yes"; then
813			CPPFLAGS="$CPPFLAGS $withval"
814		fi
815	]
816)
817AC_ARG_WITH([ldflags],
818	[  --with-ldflags		Specify additional flags to pass to linker],
819	[
820		if test -n "$withval" -a "$withval" != "xno" -a "${withval}" != "yes"; then
821			LDFLAGS="$LDFLAGS $withval"
822		fi
823	]
824)
825AC_ARG_WITH([Werror],
826	[  --with-Werror			Build main code with -Werror],
827	[
828		if test -n "$withval" -a "$withval" != "no"; then
829			werror_flags="-Werror"
830			if test "${withval}" != "yes"; then
831				werror_flags="$withval"
832			fi
833		fi
834	]
835)
836
837
838
839AC_ARG_WITH([pie],
840    [  --with-pie			Build Position Independent Executables if possible], [
841	if test "x$withval" = "xno"; then
842		use_pie=no
843	fi
844	if test "x$withval" = "xyes"; then
845		use_pie=yes
846	fi
847    ]
848)
849if test -z "$use_pie"; then
850	use_pie=no
851fi
852if test "x$use_toolchain_hardening" != "x1" -a "x$use_pie" = "xauto"; then
853	# Turn off automatic PIE when toolchain hardening is off.
854	use_pie=no
855fi
856if test "x$use_pie" = "xauto"; then
857	# Automatic PIE requires gcc >= 4.x
858	AC_MSG_CHECKING([for gcc >= 4.x])
859	AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
860#if !defined(__GNUC__) || __GNUC__ < 4
861#error gcc is too old
862#endif
863]])],
864	[ AC_MSG_RESULT([yes]) ],
865	[ AC_MSG_RESULT([no])
866	  use_pie=no ]
867)
868fi
869if test "x$use_pie" != "xno"; then
870	SAVED_CFLAGS="$CFLAGS"
871	SAVED_LDFLAGS="$LDFLAGS"
872	OSSH_CHECK_CFLAG_COMPILE([-fPIE])
873	OSSH_CHECK_LDFLAG_LINK([-pie])
874	# We use both -fPIE and -pie or neither.
875	AC_MSG_CHECKING([whether both -fPIE and -pie are supported])
876	if echo "x $CFLAGS"  | grep ' -fPIE' >/dev/null 2>&1 && \
877	   echo "x $LDFLAGS" | grep ' -pie'  >/dev/null 2>&1 ; then
878		AC_MSG_RESULT([yes])
879	else
880		AC_MSG_RESULT([no])
881		CFLAGS="$SAVED_CFLAGS"
882		LDFLAGS="$SAVED_LDFLAGS"
883	fi
884fi
885
886
887
888
889
890
891#l432 (customized)
892# Check for some target-specific stuff
893
894case "$host" in
895*-*-darwin*)
896	use_pie=auto
897	AC_MSG_CHECKING([if we have working getaddrinfo])
898	AC_RUN_IFELSE([AC_LANG_SOURCE([[
899#include <stdlib.h>
900#include <mach-o/dyld.h>
901main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
902		exit(0);
903	else
904		exit(1);
905}
906			]])],
907	[AC_MSG_RESULT([working])],
908	[AC_MSG_RESULT([buggy])
909	AC_DEFINE([BROKEN_GETADDRINFO], [1],
910		[getaddrinfo is broken (if present)])
911	],
912	[AC_MSG_RESULT([assume it is working])])
913	AC_DEFINE([SETEUID_BREAKS_SETUID], [1], [define if seteuid breaks setuid])
914	AC_DEFINE([BROKEN_SETREUID], [1], [define if setreuid is broken])
915	AC_DEFINE([BROKEN_SETREGID], [1], [define if setregid is broken])
916	AC_DEFINE([BROKEN_GLOB], [1], [OS X glob does not do what we expect])
917	AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV],
918		[Define to a Set Process Title type if your system is
919		supported by bsd-setproctitle.c])
920	AC_DEFINE([BROKEN_STRNVIS], [1],
921	    [OSX strnvis argument order is swapped compared to OpenBSD])
922	BROKEN_STRNVIS=1
923	;;
924*-*-dragonfly*)
925	;;
926*-*-linux* | *-gnu* | *-k*bsd*-gnu* )
927	use_pie=auto
928	CFLAGS="$CFLAGS -D_BSD_SOURCE -D_DEFAULT_SOURCE"
929	AC_DEFINE([SPT_TYPE], [SPT_REUSEARGV])
930	;;
931*-*-netbsd*)
932	if test "x$withval" != "xno"; then
933		need_dash_r=1
934	fi
935	AC_DEFINE([BROKEN_STRNVIS], [1],
936	    [NetBSD strnvis argument order is swapped compared to OpenBSD])
937	BROKEN_STRNVIS=1
938	;;
939*-*-freebsd*)
940	AC_DEFINE([BROKEN_GLOB], [1], [FreeBSD glob does not do what we need])
941	AC_DEFINE([BROKEN_STRNVIS], [1],
942	    [FreeBSD strnvis argument order is swapped compared to OpenBSD])
943	BROKEN_STRNVIS=1
944	;;
945*-*-openbsd*)
946	use_pie=auto
947	AC_DEFINE([HAVE_ATTRIBUTE__SENTINEL__], [1], [OpenBSD's gcc has sentinel])
948	AC_DEFINE([HAVE_ATTRIBUTE__BOUNDED__], [1], [OpenBSD's gcc has bounded])
949
950	AC_DEFINE([BROKEN_STRNVIS], [0],
951	    [FreeBSD strnvis argument order is swapped compared to OpenBSD])
952	BROKEN_STRNVIS=0
953	YACC='yacc'
954	ASR_LIB=
955	AC_DEFINE([NOOP_ASR_FREEADDRINFO], [0], [OpenBSD doesn't need ASR_FREEADDRINFO])
956	;;
957*-sun-solaris*)
958	AC_DEFINE([HAVE_M_DATA], [1], [M_DATA is defined in sys/stream.h included by netinet/in.h])
959	;;
960esac
961AC_SUBST([ASR_LIB])
962
963
964AC_MSG_CHECKING([compiler and flags for sanity])
965AC_RUN_IFELSE([AC_LANG_PROGRAM([[
966#include <stdio.h>
967#include <stdlib.h> ]], [[ exit(0); ]])],
968	[	AC_MSG_RESULT([yes]) ],
969	[
970		AC_MSG_RESULT([no])
971		AC_MSG_ERROR([*** compiler cannot create working executables, check config.log ***])
972	],
973	[	AC_MSG_WARN([cross compiling: not checking compiler sanity]) ]
974)
975
976
977
978#l1747
979
980
981
982
983# Check for missing getpeereid (or equiv) support
984NO_PEERCHECK=""
985if test "x$ac_cv_func_getpeereid" != "xyes" -a "x$ac_cv_func_getpeerucred" != "xyes"; then
986	AC_MSG_CHECKING([whether system supports SO_PEERCRED getsockopt])
987	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
988#include <sys/types.h>
989#include <sys/socket.h>]], [[int i = SO_PEERCRED;]])],
990		[ AC_MSG_RESULT([yes])
991		  AC_DEFINE([HAVE_SO_PEERCRED], [1], [Have PEERCRED socket option])
992		], [AC_MSG_RESULT([no])
993		NO_PEERCHECK=1
994        ])
995fi
996
997#l4176 (customized s/ssh.1/smtpd/smtpd.8/)
998# Options from here on. Some of these are preset by platform above
999AC_ARG_WITH([mantype],
1000	[  --with-mantype=man|cat|doc	Set man page type],
1001	[
1002		case "$withval" in
1003		man|cat|doc)
1004			MANTYPE=$withval
1005			;;
1006		*)
1007			AC_MSG_ERROR([invalid man type: $withval])
1008			;;
1009		esac
1010	]
1011)
1012if test -z "$MANTYPE"; then
1013	TestPath="/usr/bin${PATH_SEPARATOR}/usr/ucb"
1014	AC_PATH_PROGS([NROFF], [nroff awf], [/bin/false], [$TestPath])
1015	if ${NROFF} -mdoc ${srcdir}/usr.sbin/smtpd/smtpd.8 >/dev/null 2>&1; then
1016		MANTYPE=doc
1017	elif ${NROFF} -man ${srcdir}/usr.sbin/smtpd/smtpd.8 >/dev/null 2>&1; then
1018		MANTYPE=man
1019	else
1020		MANTYPE=cat
1021	fi
1022fi
1023AC_SUBST([MANTYPE])
1024if test "$MANTYPE" = "doc"; then
1025	mansubdir=man;
1026else
1027	mansubdir=$MANTYPE;
1028fi
1029AC_SUBST([mansubdir])
1030#l4207
1031
1032
1033#l4432 (customized s/pid/sock/)
1034# Whether to enable BSD auth support
1035BSD_AUTH_MSG=no
1036AC_ARG_WITH([auth-bsdauth],
1037	[  --with-auth-bsdauth		Enable bsd_auth(3) authentication support],
1038	[
1039		if test "x$withval" != "xno"; then
1040			AC_DEFINE([BSD_AUTH], [1],
1041				[Define if you have BSD auth support])
1042			BSD_AUTH_MSG=yes
1043		fi
1044	]
1045)
1046
1047
1048#l2757
1049# Check for PAM libs
1050PAM_MSG="no"
1051USE_PAM_SERVICE=smtpd
1052AC_ARG_WITH([auth-pam],
1053	[  --with-auth-pam=SERVICE	Enable PAM authentication support (default=smtpd)],
1054	[
1055		if test "x$withval" != "xno"; then
1056			if test -n "$withval" -a "x${withval}" != "xyes"; then
1057				USE_PAM_SERVICE=$withval
1058			fi
1059
1060			if test "x$ac_cv_header_security_pam_appl_h" != "xyes" -a \
1061			   test "x$ac_cv_header_pam_pam_appl_h" != "xyes"; then
1062				AC_MSG_ERROR([PAM headers not found])
1063			fi
1064
1065			saved_LIBS="$LIBS"
1066			AC_CHECK_LIB([dl], [dlopen], , )
1067			AC_CHECK_LIB([pam], [pam_set_item], , [AC_MSG_ERROR([*** libpam missing])])
1068			AC_CHECK_FUNCS([pam_getenvlist])
1069			AC_CHECK_FUNCS([pam_putenv])
1070			LIBS="$saved_LIBS"
1071
1072			PAM_MSG="yes"
1073
1074			SMTPDLIBS="$SMTPDLIBS -lpam"
1075			AC_DEFINE([USE_PAM], [1],
1076				[Define if you want to enable PAM support])
1077
1078			if test "x$ac_cv_lib_dl_dlopen" = "xyes"; then
1079				case "$LIBS" in
1080				*-ldl*)
1081					# libdl already in LIBS
1082					;;
1083				*)
1084					SMTPDLIBS="$SMTPDLIBS -ldl"
1085					;;
1086				esac
1087			fi
1088		fi
1089	]
1090)
1091AC_DEFINE_UNQUOTED([USE_PAM_SERVICE], ["$USE_PAM_SERVICE"], [pam service])
1092AC_SUBST([USE_PAM_SERVICE])
1093
1094
1095# Check for older PAM
1096if test "x$PAM_MSG" = "xyes"; then
1097	# Check PAM strerror arguments (old PAM)
1098	AC_MSG_CHECKING([whether pam_strerror takes only one argument])
1099	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1100#include <stdlib.h>
1101#if defined(HAVE_SECURITY_PAM_APPL_H)
1102#include <security/pam_appl.h>
1103#elif defined (HAVE_PAM_PAM_APPL_H)
1104#include <pam/pam_appl.h>
1105#endif
1106		]], [[
1107(void)pam_strerror((pam_handle_t *)NULL, -1);
1108		]])], [AC_MSG_RESULT([no])], [
1109			AC_DEFINE([HAVE_OLD_PAM], [1],
1110				[Define if you have an old version of PAM
1111				which takes only one argument to pam_strerror])
1112			AC_MSG_RESULT([yes])
1113			PAM_MSG="yes (old library)"
1114
1115	])
1116fi
1117#l2816
1118
1119
1120##gilles
1121
1122SMTPD_USER=_smtpd
1123AC_ARG_WITH([user-smtpd],
1124	[  --with-user-smtpd=user	Specify non-privileged user for smtpd (default=_smtpd)],
1125	[
1126		if test -n "$withval" -a "$withval" != "no" -a "${withval}" != "yes"; then
1127			SMTPD_USER=$withval
1128		fi
1129	]
1130)
1131AC_DEFINE_UNQUOTED([SMTPD_USER], ["$SMTPD_USER"],
1132	[non-privileged user for privilege separation])
1133AC_SUBST([SMTPD_USER])
1134
1135SMTPD_QUEUE_USER=_smtpq
1136AC_ARG_WITH([user-queue],
1137	[  --with-user-queue=user	Specify non-privileged user for queue process (default=_smtpq)],
1138	[
1139		if test -n "$withval" -a "$withval" != "no" -a "${withval}" != "yes"; then
1140			SMTPD_QUEUE_USER=$withval
1141		fi
1142	]
1143)
1144AC_DEFINE_UNQUOTED([SMTPD_QUEUE_USER], ["$SMTPD_QUEUE_USER"],
1145	[non-privileged user for queue process])
1146AC_SUBST([SMTPD_QUEUE_USER])
1147
1148SMTPD_QUEUE_GROUP=_smtpq
1149AC_ARG_WITH([group-queue],
1150	[  --with-group-queue=group	Specify non-privileged group for offline queue (default=_smtpq)],
1151	[
1152		if test -n "$withval"  -a "$withval" != "no" -a "${withval}" != "yes"; then
1153			SMTPD_QUEUE_GROUP=$withval
1154		fi
1155	]
1156)
1157AC_DEFINE_UNQUOTED([SMTPD_QUEUE_GROUP], ["$SMTPD_QUEUE_GROUP"],
1158	[non-privileged group for queue process])
1159AC_SUBST([SMTPD_QUEUE_GROUP])
1160
1161# Where to place spooler
1162spooldir=/var/spool/smtpd
1163AC_ARG_WITH([path-queue],
1164	[  --with-path-queue=PATH	Specify path to queue directory (default=/var/spool/smtpd)],
1165	[
1166		if test -n "$withval" -a "$withval" != "no" -a "${withval}" != "yes"; then
1167			spooldir=$withval
1168			if test ! -d $spooldir; then
1169			AC_MSG_WARN([** no $spooldir directory on this system **])
1170			fi
1171		fi
1172	]
1173)
1174
1175AC_DEFINE_UNQUOTED([PATH_SPOOL], ["$spooldir"],
1176	[Specify location of spooler])
1177AC_SUBST([spooldir])
1178
1179
1180PRIVSEP_PATH=/var/empty
1181AC_ARG_WITH([path-empty],
1182	[  --with-path-empty=PATH	Specify path to empty directory (default=/var/empty)],
1183	[
1184		if test -n "$withval" -a "$withval" != "no" -a "${withval}" != "yes"; then
1185			PRIVSEP_PATH=$withval
1186		fi
1187	]
1188)
1189AC_SUBST([PRIVSEP_PATH])
1190#l4022
1191
1192#l4066
1193dnl # --with-maildir=/path/to/mail gets top priority.
1194dnl # if maildir is set in the platform case statement above we use that.
1195dnl # Otherwise we run a program to get the dir from system headers.
1196dnl # We first look for _PATH_MAILDIR then MAILDIR then _PATH_MAIL
1197dnl # If we find _PATH_MAILDIR we do nothing because that is what
1198dnl # session.c expects anyway. Otherwise we set to the value found
1199dnl # stripping any trailing slash. If for some strage reason our program
1200dnl # does not find what it needs, we default to /var/spool/mail.
1201# Check for mail directory
1202AC_ARG_WITH([path-mbox],
1203    [  --with-path-mbox=PATH		Specify path to mbox directory (default=/var/spool/mail)],
1204    [
1205	if test -n "$withval" -a "$withval" != "no" -a "${withval}" != "yes"; then
1206		AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$withval"],
1207            [Set this to your mail directory if you do not have _PATH_MAILDIR])
1208	    fi
1209     ],[
1210	if test -n "$maildir"; then
1211	    AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$maildir"])
1212	else
1213	    AC_MSG_CHECKING([system mail directory])
1214	    AC_RUN_IFELSE(
1215		[AC_LANG_PROGRAM([[
1216#include <stdio.h>
1217#include <string.h>
1218#include <stdlib.h>
1219#ifdef HAVE_PATHS_H
1220#include <paths.h>
1221#endif
1222#ifdef HAVE_MAILLOCK_H
1223#include <maillock.h>
1224#endif
1225#define DATA "conftest.maildir"
1226	]], [[
1227	FILE *fd;
1228	int rc;
1229
1230	fd = fopen(DATA,"w");
1231	if(fd == NULL)
1232		exit(1);
1233
1234#if defined (_PATH_MAILDIR)
1235	if ((rc = fprintf(fd ,"_PATH_MAILDIR:%s\n", _PATH_MAILDIR)) <0)
1236		exit(1);
1237#elif defined (MAILDIR)
1238	if ((rc = fprintf(fd ,"MAILDIR:%s\n", MAILDIR)) <0)
1239		exit(1);
1240#elif defined (_PATH_MAIL)
1241	if ((rc = fprintf(fd ,"_PATH_MAIL:%s\n", _PATH_MAIL)) <0)
1242		exit(1);
1243#else
1244	exit (2);
1245#endif
1246
1247	exit(0);
1248		]])],
1249		[
1250	 	    maildir_what=`awk -F: '{print $1}' conftest.maildir`
1251		    maildir=`awk -F: '{print $2}' conftest.maildir \
1252			| sed 's|/$||'`
1253		    AC_MSG_RESULT([$maildir from $maildir_what])
1254		    if test "x$maildir_what" != "x_PATH_MAILDIR"; then
1255			AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["$maildir"])
1256		    fi
1257		],
1258		[
1259		    if test "X$ac_status" = "X2"; then
1260# our test program didn't find it. Default to /var/spool/mail
1261			AC_MSG_RESULT([/var/spool/mail])
1262			AC_DEFINE_UNQUOTED([MAIL_DIRECTORY], ["/var/spool/mail"])
1263		     else
1264			AC_MSG_RESULT([*** not found ***])
1265		     fi
1266		],
1267		[
1268			AC_MSG_WARN([cross compiling: use --with-maildir=/path/to/mail])
1269		]
1270	    )
1271	fi
1272    ]
1273) # maildir
1274#l4146
1275
1276# Where to place smtpd.sock
1277sockdir=/var/run
1278# make sure the directory exists
1279if test ! -d $sockdir; then
1280	sockdir=`eval echo ${sysconfdir}`
1281	case $sockdir in
1282		NONE/*) sockdir=`echo $sockdir | sed "s~NONE~$ac_default_prefix~"` ;;
1283	esac
1284fi
1285
1286AC_ARG_WITH([path-socket],
1287	[  --with-path-socket=PATH	Specify path to smtpd.sock directory (default=/var/run)],
1288	[
1289		if test -n "$withval" -a "$withval" != "no" -a "${withval}" != "yes"; then
1290			sockdir=$withval
1291			if test ! -d $sockdir; then
1292			AC_MSG_WARN([** no $sockdir directory on this system **])
1293			fi
1294		fi
1295	]
1296)
1297
1298AC_DEFINE_UNQUOTED([SMTPD_SOCKDIR], ["$sockdir"],
1299	[Specify location of smtpd.sock])
1300AC_SUBST([sockdir])
1301#l4470
1302
1303# Where to place smtpd.pid
1304piddir=/var/run
1305AC_MSG_CHECKING([system pid directory])
1306AC_RUN_IFELSE(
1307	[
1308	    AC_LANG_PROGRAM([[
1309#include <stdio.h>
1310#include <stdlib.h>
1311#ifdef HAVE_PATHS_H
1312#include <paths.h>
1313#endif
1314#define DATA "conftest.piddir"
1315		]],
1316		[[
1317#ifdef _PATH_VARRUN
1318FILE *fd;
1319int rc;
1320
1321if ((fd = fopen(DATA,"w")) == NULL) { exit(1); }
1322if ((rc = fprintf(fd ,"%s\n", _PATH_VARRUN)) < 0) { exit(2); }
1323exit(0);
1324#else
1325exit(-1);
1326#endif
1327		]])
1328	],		[
1329		piddir=`cat conftest.piddir`
1330		AC_MSG_RESULT([$piddir from paths.h])
1331	],
1332	[
1333		AC_MSG_RESULT([$piddir from default value])
1334	],
1335	[
1336		AC_MSG_RESULT([$piddir from default value])
1337	]
1338)
1339
1340AC_ARG_WITH([path-pidfile],
1341	[  --with-path-pidfile=PATH	Specify path to smtpd.pid directory (default=/var/run)],
1342	[
1343		if test -n "$withval" -a "$withval" != "no" -a "${withval}" != "yes"; then
1344			piddir=$withval
1345		fi
1346	]
1347)
1348
1349AC_DEFINE_UNQUOTED([SMTPD_PIDDIR], ["$piddir"], [Specify location of smtpd.pid])
1350AC_SUBST([piddir])
1351
1352CA_FILE=/etc/ssl/cert.pem
1353AC_ARG_WITH([path-CAfile],
1354	[  --with-path-CAfile=FILE	Specify path to CA certificate (default=/etc/ssl/cert.pem)],
1355	[
1356		if test -n "$withval" -a "$withval" != "no" -a "${withval}" != "yes"; then
1357			CA_FILE=$withval
1358		fi
1359	]
1360)
1361AC_SUBST([CA_FILE])
1362
1363
1364
1365
1366
1367
1368# compute LLONG_MIN and LLONG_MAX if we don't know them.
1369if test -z "$have_llong_max"; then
1370	AC_MSG_CHECKING([for max value of long long])
1371	AC_RUN_IFELSE(
1372		[AC_LANG_PROGRAM([[
1373#include <stdio.h>
1374#include <stdlib.h>
1375/* Why is this so damn hard? */
1376#ifdef __GNUC__
1377# undef __GNUC__
1378#endif
1379#define __USE_ISOC99
1380#include <limits.h>
1381#define DATA "conftest.llminmax"
1382#define my_abs(a) ((a) < 0 ? ((a) * -1) : (a))
1383
1384/*
1385 * printf in libc on some platforms (eg old Tru64) does not understand %lld so
1386 * we do this the hard way.
1387 */
1388static int
1389fprint_ll(FILE *f, long long n)
1390{
1391	unsigned int i;
1392	int l[sizeof(long long) * 8];
1393
1394	if (n < 0)
1395		if (fprintf(f, "-") < 0)
1396			return -1;
1397	for (i = 0; n != 0; i++) {
1398		l[i] = my_abs(n % 10);
1399		n /= 10;
1400	}
1401	do {
1402		if (fprintf(f, "%d", l[--i]) < 0)
1403			return -1;
1404	} while (i != 0);
1405	if (fprintf(f, " ") < 0)
1406		return -1;
1407	return 0;
1408}
1409		]], [[
1410	FILE *f;
1411	long long i, llmin, llmax = 0;
1412
1413	if((f = fopen(DATA,"w")) == NULL)
1414		exit(1);
1415
1416#if defined(LLONG_MIN) && defined(LLONG_MAX)
1417	fprintf(stderr, "Using system header for LLONG_MIN and LLONG_MAX\n");
1418	llmin = LLONG_MIN;
1419	llmax = LLONG_MAX;
1420#else
1421	fprintf(stderr, "Calculating  LLONG_MIN and LLONG_MAX\n");
1422	/* This will work on one's complement and two's complement */
1423	for (i = 1; i > llmax; i <<= 1, i++)
1424		llmax = i;
1425	llmin = llmax + 1LL;	/* wrap */
1426#endif
1427
1428	/* Sanity check */
1429	if (llmin + 1 < llmin || llmin - 1 < llmin || llmax + 1 > llmax
1430	    || llmax - 1 > llmax || llmin == llmax || llmin == 0
1431	    || llmax == 0 || llmax < LONG_MAX || llmin > LONG_MIN) {
1432		fprintf(f, "unknown unknown\n");
1433		exit(2);
1434	}
1435
1436	if (fprint_ll(f, llmin) < 0)
1437		exit(3);
1438	if (fprint_ll(f, llmax) < 0)
1439		exit(4);
1440	if (fclose(f) < 0)
1441		exit(5);
1442	exit(0);
1443		]])],
1444		[
1445			llong_min=`$AWK '{print $1}' conftest.llminmax`
1446			llong_max=`$AWK '{print $2}' conftest.llminmax`
1447
1448			AC_MSG_RESULT([$llong_max])
1449			AC_DEFINE_UNQUOTED([LLONG_MAX], [${llong_max}LL],
1450			    [max value of long long calculated by configure])
1451			AC_MSG_CHECKING([for min value of long long])
1452			AC_MSG_RESULT([$llong_min])
1453			AC_DEFINE_UNQUOTED([LLONG_MIN], [${llong_min}LL],
1454			    [min value of long long calculated by configure])
1455		],
1456		[
1457			AC_MSG_RESULT([not found])
1458		],
1459		[
1460			AC_MSG_WARN([cross compiling: not checking])
1461		]
1462	)
1463fi
1464
1465
1466
1467
1468
1469#l3561
1470
1471
1472dnl make sure we're using the real structure members and not defines
1473AC_CACHE_CHECK([for msg_accrights field in struct msghdr],
1474		ac_cv_have_accrights_in_msghdr, [
1475	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1476#include <sys/types.h>
1477#include <sys/socket.h>
1478#include <sys/uio.h>
1479#include <stdlib.h>
1480		]], [[
1481#ifdef msg_accrights
1482#error "msg_accrights is a macro"
1483exit(1);
1484#endif
1485struct msghdr m;
1486m.msg_accrights = 0;
1487exit(0);
1488		]])],
1489		[ ac_cv_have_accrights_in_msghdr="yes" ],
1490		[ ac_cv_have_accrights_in_msghdr="no" ]
1491	)
1492])
1493if test "x$ac_cv_have_accrights_in_msghdr" = "xyes"; then
1494	AC_DEFINE([HAVE_ACCRIGHTS_IN_MSGHDR], [1],
1495		[Define if your system uses access rights style
1496		file descriptor passing])
1497fi
1498
1499
1500AC_CACHE_CHECK([for msg_control field in struct msghdr],
1501		ac_cv_have_control_in_msghdr, [
1502	AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1503#include <sys/types.h>
1504#include <sys/socket.h>
1505#include <sys/uio.h>
1506#include <stdlib.h>
1507		]], [[
1508#ifdef msg_control
1509#error "msg_control is a macro"
1510exit(1);
1511#endif
1512struct msghdr m;
1513m.msg_control = 0;
1514exit(0);
1515		]])],
1516		[ ac_cv_have_control_in_msghdr="yes" ],
1517		[ ac_cv_have_control_in_msghdr="no" ]
1518	)
1519])
1520if test "x$ac_cv_have_control_in_msghdr" = "xyes"; then
1521	AC_DEFINE([HAVE_CONTROL_IN_MSGHDR], [1],
1522		[Define if your system uses ancillary data style
1523		file descriptor passing])
1524fi
1525
1526AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [
1527	AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]],
1528		[[ extern char *__progname; printf("%s", __progname); ]])],
1529	[ ac_cv_libc_defines___progname="yes" ],
1530	[ ac_cv_libc_defines___progname="no"
1531	])
1532])
1533if test "x$ac_cv_libc_defines___progname" = "xyes"; then
1534	AC_DEFINE([HAVE___PROGNAME], [1], [Define if libc defines __progname])
1535fi
1536
1537AC_CACHE_CHECK([whether $CC implements __FUNCTION__], ac_cv_cc_implements___FUNCTION__, [
1538	AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]],
1539		[[ printf("%s", __FUNCTION__); ]])],
1540	[ ac_cv_cc_implements___FUNCTION__="yes" ],
1541	[ ac_cv_cc_implements___FUNCTION__="no"
1542	])
1543])
1544if test "x$ac_cv_cc_implements___FUNCTION__" = "xyes"; then
1545	AC_DEFINE([HAVE___FUNCTION__], [1],
1546		[Define if compiler implements __FUNCTION__])
1547fi
1548
1549AC_CACHE_CHECK([whether $CC implements __func__], ac_cv_cc_implements___func__, [
1550	AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <stdio.h> ]],
1551		[[ printf("%s", __func__); ]])],
1552	[ ac_cv_cc_implements___func__="yes" ],
1553	[ ac_cv_cc_implements___func__="no"
1554	])
1555])
1556if test "x$ac_cv_cc_implements___func__" = "xyes"; then
1557	AC_DEFINE([HAVE___func__], [1], [Define if compiler implements __func__])
1558fi
1559
1560AC_CACHE_CHECK([whether va_copy exists], ac_cv_have_va_copy, [
1561	AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1562#include <stdarg.h>
1563va_list x,y;
1564		]], [[ va_copy(x,y); ]])],
1565	[ ac_cv_have_va_copy="yes" ],
1566	[ ac_cv_have_va_copy="no"
1567	])
1568])
1569if test "x$ac_cv_have_va_copy" = "xyes"; then
1570	AC_DEFINE([HAVE_VA_COPY], [1], [Define if va_copy exists])
1571fi
1572
1573AC_CACHE_CHECK([whether __va_copy exists], ac_cv_have___va_copy, [
1574	AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1575#include <stdarg.h>
1576va_list x,y;
1577		]], [[ __va_copy(x,y); ]])],
1578	[ ac_cv_have___va_copy="yes" ], [ ac_cv_have___va_copy="no"
1579	])
1580])
1581if test "x$ac_cv_have___va_copy" = "xyes"; then
1582	AC_DEFINE([HAVE___VA_COPY], [1], [Define if __va_copy exists])
1583fi
1584
1585AC_CACHE_CHECK([whether getopt has optreset support],
1586		ac_cv_have_getopt_optreset, [
1587	AC_LINK_IFELSE([AC_LANG_PROGRAM([[ #include <getopt.h> ]],
1588		[[ extern int optreset; optreset = 0; ]])],
1589	[ ac_cv_have_getopt_optreset="yes" ],
1590	[ ac_cv_have_getopt_optreset="no"
1591	])
1592])
1593if test "x$ac_cv_have_getopt_optreset" = "xyes"; then
1594	AC_DEFINE([HAVE_GETOPT_OPTRESET], [1],
1595		[Define if your getopt(3) defines and uses optreset])
1596fi
1597#l3765
1598
1599
1600
1601
1602#l4045
1603STRIP_OPT=-s
1604AC_ARG_ENABLE([strip],
1605	[  --disable-strip	Disable calling strip(1) on install],
1606	[
1607		if test "x$enableval" = "xno"; then
1608			STRIP_OPT=
1609		fi
1610	]
1611)
1612AC_SUBST([STRIP_OPT])
1613#l4054
1614
1615
1616
1617case "$host" in
1618*-*-openbsd*)
1619        pkglibexecdir="$libexecdir/smtpd"
1620        ;;
1621*)
1622        pkglibexecdir="$libexecdir/opensmtpd"
1623        ;;
1624esac
1625AC_SUBST([pkglibexecdir])
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635#l4742
1636dnl Adding -Werror to CFLAGS early prevents configure tests from running.
1637dnl Add now.
1638CFLAGS="$CFLAGS $werror_flags"
1639
1640AC_SUBST([TEST_MALLOC_OPTIONS], [$TEST_MALLOC_OPTIONS])
1641
1642
1643AC_EXEEXT
1644#l4757
1645
1646
1647# Search for fts
1648AC_ARG_WITH([libfts],
1649	[  --with-libfts=PATH		Specify path to libfts installation (default: none, part of libc)],
1650	[ if test "x$withval" = "xno"; then
1651		AC_MSG_ERROR([*** fts is required ***])
1652	  elif test "x$withval" != "xyes"; then
1653		if test -d "$withval/lib"; then
1654			if test -n "${need_dash_r}"; then
1655				LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
1656			else
1657				LDFLAGS="-L${withval}/lib ${LDFLAGS}"
1658			fi
1659		else
1660			if test -n "${need_dash_r}"; then
1661				LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
1662			else
1663				LDFLAGS="-L${withval} ${LDFLAGS}"
1664			fi
1665		fi
1666		if test -d "$withval/include"; then
1667			CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
1668		else
1669			CPPFLAGS="-I${withval} ${CPPFLAGS}"
1670		fi
1671	LIBS="-lfts $LIBS"
1672	fi
1673	]
1674)
1675
1676
1677
1678##chl (based on OpenSSL checks, see above)
1679# Search for libevent
1680saved_CPPFLAGS="$CPPFLAGS"
1681saved_LDFLAGS="$LDFLAGS"
1682AC_ARG_WITH([libevent],
1683	[  --with-libevent=PATH          Specify path to libevent installation ],
1684	[
1685		if test "x$withval" != "xno"; then
1686			case "$withval" in
1687				# Relative paths
1688				./*|../*)	withval="`pwd`/$withval"
1689			esac
1690			if test -d "$withval/lib"; then
1691				if test -n "${need_dash_r}"; then
1692					LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
1693				else
1694					LDFLAGS="-L${withval}/lib ${LDFLAGS}"
1695				fi
1696			elif test -d "$withval/lib64"; then
1697				if test -n "${need_dash_r}"; then
1698					LDFLAGS="-L${withval}/lib64 -R${withval}/lib64 ${LDFLAGS}"
1699				else
1700					LDFLAGS="-L${withval}/lib64 ${LDFLAGS}"
1701				fi
1702			else
1703				if test -n "${need_dash_r}"; then
1704					LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
1705				else
1706					LDFLAGS="-L${withval} ${LDFLAGS}"
1707				fi
1708			fi
1709			if test -d "$withval/include"; then
1710				CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
1711			else
1712				CPPFLAGS="-I${withval} ${CPPFLAGS}"
1713			fi
1714			need_libevent_autodetect=no
1715		fi
1716	]
1717)
1718
1719if test "x${need_libevent_autodetect}" != "xno"; then
1720   for path in /usr/local /usr; do
1721       if test -f "${path}/include/event.h"; then
1722       	  CPPFLAGS="-I${path}/include ${CPPFLAGS}"
1723	  LDFLAGS="-L${path}/lib ${LDFLAGS}"
1724       fi
1725   done
1726fi
1727
1728AC_CHECK_HEADER([event.h], ,[AC_MSG_ERROR([*** event.h missing - please install libevent ***])],
1729[#include <sys/types.h>])
1730LIBS="-levent $LIBS"
1731AC_MSG_CHECKING([if programs using libevent functions will link])
1732AC_LINK_IFELSE(
1733	[AC_LANG_PROGRAM([[
1734	#include <event.h>
1735	]], [[
1736	event_base_new();
1737	]])],
1738	[
1739		AC_MSG_RESULT([yes])
1740	],
1741	[
1742		AC_MSG_RESULT([no])
1743	]
1744)
1745
1746
1747#l2174 (customized, bu adding -lssl to LIBS)
1748# Search for OpenSSL
1749saved_CPPFLAGS="$CPPFLAGS"
1750saved_LDFLAGS="$LDFLAGS"
1751AC_ARG_WITH([libssl],
1752	[  --with-libssl=PATH		Specify path to libssl installation ],
1753	[
1754		if test "x$withval" != "xno"; then
1755			case "$withval" in
1756				# Relative paths
1757				./*|../*)	withval="`pwd`/$withval"
1758			esac
1759			if test -d "$withval/lib"; then
1760				if test -n "${need_dash_r}"; then
1761					LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
1762				else
1763					LDFLAGS="-L${withval}/lib ${LDFLAGS}"
1764				fi
1765			elif test -d "$withval/lib64"; then
1766				if test -n "${need_dash_r}"; then
1767					LDFLAGS="-L${withval}/lib64 -R${withval}/lib64 ${LDFLAGS}"
1768				else
1769					LDFLAGS="-L${withval}/lib64 ${LDFLAGS}"
1770				fi
1771			else
1772				if test -n "${need_dash_r}"; then
1773					LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
1774				else
1775					LDFLAGS="-L${withval} ${LDFLAGS}"
1776				fi
1777			fi
1778			if test -d "$withval/include"; then
1779				CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
1780			else
1781				CPPFLAGS="-I${withval} ${CPPFLAGS}"
1782			fi
1783		fi
1784	]
1785)
1786## XXX chl -lssl manually added
1787LIBS="-lcrypto -lssl $LIBS"
1788AC_TRY_LINK_FUNC([RAND_add], [AC_DEFINE([HAVE_OPENSSL], [1],
1789	[Define if your ssl headers are included
1790	with #include <openssl/header.h>])],
1791	[
1792		dnl Check default openssl install dir
1793		if test -n "${need_dash_r}"; then
1794			LDFLAGS="-L/usr/local/ssl/lib -R/usr/local/ssl/lib ${saved_LDFLAGS}"
1795		else
1796			LDFLAGS="-L/usr/local/ssl/lib ${saved_LDFLAGS}"
1797		fi
1798		CPPFLAGS="-I/usr/local/ssl/include ${saved_CPPFLAGS}"
1799		AC_CHECK_HEADER([openssl/opensslv.h], ,
1800		    [AC_MSG_ERROR([*** LibreSSL headers missing - please install first or check config.log ***])])
1801		AC_TRY_LINK_FUNC([RAND_add], [AC_DEFINE([HAVE_OPENSSL])],
1802			[
1803				AC_MSG_ERROR([*** Can't find recent LibreSSL libcrypto (see config.log for details) ***])
1804			]
1805		)
1806	]
1807)
1808
1809
1810LIBS="-lcrypto -lssl $LIBS"
1811AC_MSG_CHECKING([whether SSL_CTX_use_certificate_chain_mem is available])
1812AC_TRY_LINK_FUNC([SSL_CTX_use_certificate_chain_mem],
1813	[
1814		AC_DEFINE([HAVE_SSL_CTX_USE_CERTIFICATE_CHAIN_MEM], [1],
1815			[Define if SSL_CTX_use_certificate_chain_mem exists in libssl])
1816		AC_MSG_RESULT([yes])
1817	],
1818	[ AC_MSG_RESULT([no])]
1819)
1820
1821LIBS="-lcrypto -lssl $LIBS"
1822AC_MSG_CHECKING([whether ECDSA is available])
1823AC_TRY_LINK_FUNC([ENGINE_get_ECDSA],
1824	[
1825		AC_DEFINE([SUPPORT_ECDSA], [1],
1826			[Define if ECDSA is supported])
1827		AC_MSG_RESULT([yes])
1828	],
1829	[ AC_MSG_RESULT([no])]
1830)
1831
1832# Sanity check OpenSSL headers
1833AC_MSG_CHECKING([whether LibreSSL's headers match the library])
1834AC_RUN_IFELSE(
1835	[AC_LANG_PROGRAM([[
1836#include <stdlib.h>
1837#include <string.h>
1838#include <openssl/opensslv.h>
1839#include <openssl/crypto.h>
1840	]], [[
1841	exit(SSLeay() == OPENSSL_VERSION_NUMBER ? 0 : 1);
1842	]])],
1843	[
1844		AC_MSG_RESULT([yes])
1845	],
1846	[
1847		AC_MSG_RESULT([no])
1848		AC_MSG_ERROR([Your LibreSSL headers do not match your library.])
1849	],
1850	[
1851		AC_MSG_WARN([cross compiling: not checking])
1852	]
1853)
1854
1855AC_MSG_CHECKING([if programs using LibreSSL functions will link])
1856AC_LINK_IFELSE(
1857	[AC_LANG_PROGRAM([[ #include <openssl/evp.h> ]],
1858	[[ SSLeay_add_all_algorithms(); ]])],
1859	[
1860		AC_MSG_RESULT([yes])
1861	],
1862	[
1863		AC_MSG_RESULT([no])
1864		saved_LIBS="$LIBS"
1865		LIBS="$LIBS -ldl"
1866		AC_MSG_CHECKING([if programs using LibreSSL need -ldl])
1867		AC_LINK_IFELSE(
1868			[AC_LANG_PROGRAM([[ #include <openssl/evp.h> ]],
1869			[[ SSLeay_add_all_algorithms(); ]])],
1870			[
1871				AC_MSG_RESULT([yes])
1872			],
1873			[
1874				AC_MSG_RESULT([no])
1875				LIBS="$saved_LIBS"
1876			]
1877		)
1878	]
1879)
1880
1881AC_CHECK_DECL([LIBRESSL_VERSION_NUMBER], , , [#include <openssl/ssl.h>])
1882
1883#l2371
1884
1885
1886dnl zlib is required
1887AC_ARG_WITH([libz],
1888	[  --with-libz=PATH		Specify path to libz installation],
1889	[ if test "x$withval" = "xno"; then
1890		AC_MSG_ERROR([*** zlib is required ***])
1891	  elif test "x$withval" != "xyes"; then
1892		if test -d "$withval/lib"; then
1893			if test -n "${need_dash_r}"; then
1894				LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
1895			else
1896				LDFLAGS="-L${withval}/lib ${LDFLAGS}"
1897			fi
1898		else
1899			if test -n "${need_dash_r}"; then
1900				LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
1901			else
1902				LDFLAGS="-L${withval} ${LDFLAGS}"
1903			fi
1904		fi
1905		if test -d "$withval/include"; then
1906			CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
1907		else
1908			CPPFLAGS="-I${withval} ${CPPFLAGS}"
1909		fi
1910	fi ]
1911)
1912
1913AC_CHECK_HEADER([zlib.h], ,[AC_MSG_ERROR([*** zlib.h missing - please install first or check config.log ***])])
1914AC_CHECK_LIB([z], [deflate], ,
1915	[
1916		saved_CPPFLAGS="$CPPFLAGS"
1917		saved_LDFLAGS="$LDFLAGS"
1918		save_LIBS="$LIBS"
1919		dnl Check default zlib install dir
1920		if test -n "${need_dash_r}"; then
1921			LDFLAGS="-L/usr/local/lib -R/usr/local/lib ${saved_LDFLAGS}"
1922		else
1923			LDFLAGS="-L/usr/local/lib ${saved_LDFLAGS}"
1924		fi
1925		CPPFLAGS="-I/usr/local/include ${saved_CPPFLAGS}"
1926		LIBS="$LIBS -lz"
1927		AC_TRY_LINK_FUNC([deflate], [AC_DEFINE([HAVE_LIBZ])],
1928			[
1929				AC_MSG_ERROR([*** zlib missing - please install first or check config.log ***])
1930			]
1931		)
1932	]
1933)
1934
1935
1936
1937
1938
1939AC_ARG_WITH([table-db],
1940	[  --with-table-db		Enable building of table-db backend (default=no)],
1941	[
1942		if test "x$withval" = "xyes"; then
1943			use_db_api=1
1944		else
1945			use_db_api=0
1946		fi
1947	]
1948)
1949
1950if test "x$use_db_api" = "x1"; then
1951# Search for libdb
1952AC_CHECK_HEADER(db_185.h, [AC_DEFINE([HAVE_DB_185_H], [], [if you have the <db_185.h> header file]) ] , [
1953AC_CHECK_HEADER(db.h,     [AC_DEFINE([HAVE_DB_H],     [], [if you have the <db.h> header file])     ] , [
1954AC_CHECK_HEADER(db1/db.h, [AC_DEFINE([HAVE_DB1_DB_H], [], [if you have the <db1/db.h> header file]) ] , [
1955				AC_MSG_ERROR([*** Can't find Berkeley DB headers (see config.log for details) ***])
1956])])])
1957fi
1958
1959save_LIBS="$LIBS"
1960
1961if test "x$use_db_api" = "x1"; then
1962DB_LIB=
1963
1964for libdb in db db1 c; do
1965    AC_CHECK_LIB($libdb, dbopen,       [ DB_LIB="$libdb"; break; ],
1966    AC_CHECK_LIB($libdb, __db185_open, [ DB_LIB="$libdb"; break; ]))
1967done
1968
1969if test -z "$DB_LIB"; then
1970    AC_MSG_ERROR([Berkeley DB not found or not built with --enable-185])
1971fi
1972
1973DB_LIB="-l$DB_LIB"
1974AC_SUBST([DB_LIB])
1975fi
1976
1977LIBS="$save_LIBS"
1978
1979
1980AM_CONDITIONAL([HAVE_DB_API], [test "x$use_db_api" = "x1"])
1981AM_COND_IF([HAVE_DB_API], [AC_DEFINE([HAVE_DB_API], [1], [Define to 1 if HAVE_DB_API])])
1982
1983
1984
1985if test "$need_libasr" = "no" -a "x$ac_cv_search_event_asr_run" = "xno"; then
1986	LIBS="$LIBS -lasr"
1987fi
1988
1989
1990LIBS="$LIBS ${SMTPDLIBS}"
1991##end of chl
1992
1993
1994##
1995#AM_CONDITIONAL([NEED_BASENAME], [test "x$ac_cv_have_basename" != "xyes"])
1996AM_CONDITIONAL([NEED_BASE64], [test "x$ac_cv_search_b64_ntop" = "xno" -a "x$ac_cv_search___b64_ntop" = "xno" ])
1997AM_CONDITIONAL([NEED_BASENAME], [test "x$ac_cv_search_basename" = "xno"])
1998AM_CONDITIONAL([NEED_CLOCK_GETTIME], [test "x$ac_cv_search_clock_gettime" = "xno"])
1999AM_CONDITIONAL([NEED_CLOSEFROM], [test "x$ac_cv_search_closefrom" = "xno"])
2000AM_CONDITIONAL([NEED_DAEMON], [test "x$ac_cv_search_daemon" = "xno"])
2001AM_CONDITIONAL([NEED_DIRNAME], [test "x$ac_cv_search_dirname" = "xno"])
2002AM_CONDITIONAL([NEED_EVENT_ASR_RUN], [test "x$ac_cv_search_event_asr_run" = "xno"])
2003AM_CONDITIONAL([NEED_FMT_SCALED], [test "x$ac_cv_search_fmt_scaled" = "xno"])
2004AM_CONDITIONAL([NEED_FPARSELN], [test "x$ac_cv_search_fparseln" = "xno"])
2005AM_CONDITIONAL([NEED_IMSG], [test "x$ac_cv_search_imsg_init" = "xno"])
2006AM_CONDITIONAL([NEED_INET_NET_PTON], [test "x$ac_cv_search_inet_net_pton" = "xno"])
2007
2008AM_CONDITIONAL([NEED_ERR], [test "x$ac_cv_func_err" != "xyes"])
2009AM_CONDITIONAL([NEED_ERRC], [test "x$ac_cv_func_errc" != "xyes"])
2010AM_CONDITIONAL([NEED_CRYPT_CHECKPASS], [test "x$ac_cv_func_crypt_checkpass" != "xyes"])
2011AM_CONDITIONAL([NEED_EXPLICIT_BZERO], [test "x$ac_cv_func_explicit_bzero" != "xyes"])
2012AM_CONDITIONAL([NEED_FGETLN], [test "x$ac_cv_func_fgetln" != "xyes"])
2013AM_CONDITIONAL([NEED_FREEZERO], [test "x$ac_cv_func_freezero" != "xyes"])
2014AM_CONDITIONAL([NEED_GETOPT], [test "x$ac_cv_func_getopt" != "xyes"])
2015AM_CONDITIONAL([NEED_GETPEEREID], [test "x$ac_cv_func_getpeereid" != "xyes"])
2016AM_CONDITIONAL([NEED_NANOSLEEP], [test "x$ac_cv_func_nanosleep" != "xyes"])
2017AM_CONDITIONAL([NEED_PIDFILE], [test "x$ac_cv_func_pidfile" != "xyes"])
2018AM_CONDITIONAL([NEED_PIPE2], [test "x$ac_cv_func_pipe2" != "xyes"])
2019AM_CONDITIONAL([NEED_REALLOCARRAY], [test "x$ac_cv_func_reallocarray" != "xyes"])
2020AM_CONDITIONAL([NEED_RECALLOCARRAY], [test "x$ac_cv_func_recallocarray" != "xyes"])
2021AM_CONDITIONAL([NEED_SETPROCTITLE], [test "x$ac_cv_func_setproctitle" != "xyes"])
2022AM_CONDITIONAL([NEED_SETEGID], [test "x$ac_cv_func_setegid" != "xyes"])
2023AM_CONDITIONAL([NEED_SETEUID], [test "x$ac_cv_func_seteuid" != "xyes"])
2024AM_CONDITIONAL([NEED_SETRESGID], [test "x$ac_cv_func_setresgid" != "xyes"])
2025AM_CONDITIONAL([NEED_SETRESUID], [test "x$ac_cv_func_setresuid" != "xyes"])
2026AM_CONDITIONAL([NEED_SIGNAL], [test "x$ac_cv_func_signal" != "xyes"])
2027AM_CONDITIONAL([NEED_STRERROR], [test "x$ac_cv_func_strerror" != "xyes"])
2028AM_CONDITIONAL([NEED_STRLCAT], [test "x$ac_cv_func_strlcat" != "xyes"])
2029AM_CONDITIONAL([NEED_STRLCPY], [test "x$ac_cv_func_strlcpy" != "xyes"])
2030AM_CONDITIONAL([NEED_STRMODE], [test "x$ac_cv_func_strmode" != "xyes"])
2031AM_CONDITIONAL([NEED_STRSEP], [test "x$ac_cv_func_strsep" != "xyes"])
2032AM_CONDITIONAL([NEED_STRTONUM], [test "x$ac_cv_func_strtonum" != "xyes"])
2033AM_CONDITIONAL([NEED_STRNDUP], [test "x$ac_cv_func_strndup" != "xyes"])
2034AM_CONDITIONAL([NEED_STRNLEN], [test "x$ac_cv_func_strnlen" != "xyes"])
2035AM_CONDITIONAL([NEED_WAITPID], [test "x$ac_cv_func_waitpid" != "xyes"])
2036AM_CONDITIONAL([NEED_VIS], [test "x$ac_cv_func_strnvis" != "xyes" -o "x$BROKEN_STRNVIS" = "x1"])
2037AM_CONDITIONAL([NEED_USLEEP], [test "x$ac_cv_func_usleep" != "xyes"])
2038
2039AM_CONDITIONAL([NEED_RES_HNOK], [test "x$ac_cv_search_res_hnok" = "xno" -a x"$ac_cv_func_res_hnok" != "xyes" -a x"$need_libasr" = x"yes"])
2040AM_CONDITIONAL([NEED_RES_RANDOMID], [test "x$ac_cv_search_res_randomid" = "xno" -a x"$ac_cv_func_res_randomid" != "xyes" -a x"$need_libasr" = x"yes"])
2041
2042AM_CONDITIONAL([NEED_ARC4RANDOM], [test "x$ac_cv_func_arc4random" != "xyes" -a "x$ac_cv_have_decl_LIBRESSL_VERSION_NUMBER" != "xyes"])
2043AM_CONDITIONAL([NEED_SSL_CTX_USE_CERTIFICATE_CHAIN_MEM], [test "x$ac_cv_have_decl_LIBRESSL_VERSION_NUMBER" != "xyes"])
2044
2045AM_CONDITIONAL([NEED_PROGNAME], [test "x$ac_cv_libc_defines___progname" != "xyes"])
2046##
2047
2048
2049AM_COND_IF([NEED_PROGNAME], [AC_DEFINE([NEED_PROGNAME], [1], [Define to 1 if NEED_PROGNAME])])
2050AM_COND_IF([NEED_SETPROCTITLE], [AC_DEFINE([NEED_SETPROCTITLE], [1], [Define to 1 if NEED_SETPROCTITLE])])
2051
2052
2053AC_CONFIG_FILES([Makefile
2054		openbsd-compat/Makefile
2055		mk/Makefile
2056		mk/mail/Makefile
2057		mk/mail/mail.lmtp/Makefile
2058		mk/mail/mail.maildir/Makefile
2059		mk/mail/mail.mboxfile/Makefile
2060		mk/mail/mail.mda/Makefile
2061		mk/smtpd/Makefile
2062		mk/smtpctl/Makefile
2063		mk/smtp/Makefile
2064		contrib/Makefile
2065		contrib/libexec/Makefile
2066		contrib/libexec/mail.local/Makefile
2067		contrib/libexec/lockspool/Makefile
2068		contrib/libexec/encrypt/Makefile
2069		])
2070
2071#l4761
2072AC_OUTPUT
2073