"Fossies" - the Fresh Open Source Software Archive

Member "tmux-3.2a/configure.ac" (10 Jun 2021, 17239 Bytes) of package /linux/misc/tmux-3.2a.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "configure.ac": 3.2_vs_3.2a.

    1 # configure.ac
    2 
    3 AC_INIT([tmux], 3.2a)
    4 AC_PREREQ([2.60])
    5 
    6 AC_CONFIG_AUX_DIR(etc)
    7 AC_CONFIG_LIBOBJ_DIR(compat)
    8 AM_INIT_AUTOMAKE([foreign subdir-objects])
    9 
   10 AC_CANONICAL_HOST
   11 
   12 # When CFLAGS isn't set at this stage and gcc is detected by the macro below,
   13 # autoconf will automatically use CFLAGS="-O2 -g". Prevent that by using an
   14 # empty default.
   15 : ${CFLAGS=""}
   16 
   17 # Save user CPPFLAGS, CFLAGS and LDFLAGS. We need to change them because
   18 # AC_CHECK_HEADER doesn't give us any other way to update the include
   19 # paths. But for Makefile.am we want to use AM_CPPFLAGS and friends.
   20 SAVED_CFLAGS="$CFLAGS"
   21 SAVED_CPPFLAGS="$CPPFLAGS"
   22 SAVED_LDFLAGS="$LDFLAGS"
   23 
   24 # Is this oss-fuzz build?
   25 AC_ARG_ENABLE(
   26 	fuzzing,
   27 	AC_HELP_STRING(--enable-fuzzing, build fuzzers)
   28 )
   29 AC_ARG_VAR(
   30 	FUZZING_LIBS,
   31 	AC_HELP_STRING(libraries to link fuzzing targets with)
   32 )
   33 
   34 # Set up convenient fuzzing defaults before initializing compiler.
   35 if test "x$enable_fuzzing" = xyes; then
   36 	AC_DEFINE(NEED_FUZZING)
   37 	test "x$CC" = x && CC=clang
   38 	test "x$FUZZING_LIBS" = x && \
   39 		FUZZING_LIBS="-fsanitize=fuzzer"
   40 	test "x$SAVED_CFLAGS" = x && \
   41 		AM_CFLAGS="-g -fsanitize=fuzzer-no-link,address"
   42 fi
   43 
   44 # Set up the compiler in two different ways and say yes we may want to install.
   45 AC_PROG_CC
   46 AM_PROG_CC_C_O
   47 AC_PROG_CC_C99
   48 AC_PROG_CPP
   49 AC_PROG_EGREP
   50 AC_PROG_INSTALL
   51 AC_PROG_YACC
   52 PKG_PROG_PKG_CONFIG
   53 AC_USE_SYSTEM_EXTENSIONS
   54 
   55 # Default tmux.conf goes in /etc not ${prefix}/etc.
   56 test "$sysconfdir" = '${prefix}/etc' && sysconfdir=/etc
   57 
   58 # Is this --enable-debug?
   59 case "x$VERSION" in xnext*) enable_debug=yes;; esac
   60 AC_ARG_ENABLE(
   61 	debug,
   62 	AC_HELP_STRING(--enable-debug, enable debug build flags),
   63 )
   64 AM_CONDITIONAL(IS_DEBUG, test "x$enable_debug" = xyes)
   65 
   66 # Is this a static build?
   67 AC_ARG_ENABLE(
   68 	static,
   69 	AC_HELP_STRING(--enable-static, create a static build)
   70 )
   71 if test "x$enable_static" = xyes; then
   72 	test "x$PKG_CONFIG" != x && PKG_CONFIG="$PKG_CONFIG --static"
   73 	AM_LDFLAGS="-static $AM_LDFLAGS"
   74 	LDFLAGS="$AM_LDFLAGS $SAVED_LDFLAGS"
   75 fi
   76 
   77 # Do we need fuzzers?
   78 AM_CONDITIONAL(NEED_FUZZING, test "x$enable_fuzzing" = xyes)
   79 
   80 # Is this gcc?
   81 AM_CONDITIONAL(IS_GCC, test "x$GCC" = xyes -a "x$enable_fuzzing" != xyes)
   82 
   83 # Is this Sun CC?
   84 AC_EGREP_CPP(
   85 	yes,
   86 	[
   87 		#ifdef __SUNPRO_C
   88 		yes
   89 		#endif
   90 	],
   91 	found_suncc=yes,
   92 	found_suncc=no
   93 )
   94 AM_CONDITIONAL(IS_SUNCC, test "x$found_suncc" = xyes)
   95 
   96 # Check for various headers. Alternatives included from compat.h.
   97 AC_CHECK_HEADERS([ \
   98 	bitstring.h \
   99 	dirent.h \
  100 	fcntl.h \
  101 	inttypes.h \
  102 	libproc.h \
  103 	libutil.h \
  104 	ndir.h \
  105 	paths.h \
  106 	pty.h \
  107 	stdint.h \
  108 	sys/dir.h \
  109 	sys/ndir.h \
  110 	sys/tree.h \
  111 	util.h \
  112 ])
  113 
  114 # Look for sys_signame.
  115 AC_SEARCH_LIBS(sys_signame, , AC_DEFINE(HAVE_SYS_SIGNAME))
  116 
  117 # Look for fmod.
  118 AC_CHECK_LIB(m, fmod)
  119 
  120 # Look for library needed for flock.
  121 AC_SEARCH_LIBS(flock, bsd)
  122 
  123 # Check for functions that are replaced or omitted.
  124 AC_CHECK_FUNCS([ \
  125 	dirfd \
  126 	flock \
  127 	prctl \
  128 	proc_pidinfo \
  129 	sysconf
  130 ])
  131 
  132 # Check for functions with a compatibility implementation.
  133 AC_REPLACE_FUNCS([ \
  134 	asprintf \
  135 	cfmakeraw \
  136 	clock_gettime \
  137 	closefrom \
  138 	explicit_bzero \
  139 	fgetln \
  140 	freezero \
  141 	getdtablecount \
  142 	getdtablesize \
  143 	getline \
  144 	getprogname \
  145 	memmem \
  146 	setenv \
  147 	setproctitle \
  148 	strcasestr \
  149 	strlcat \
  150 	strlcpy \
  151 	strndup \
  152 	strsep \
  153 ])
  154 AC_FUNC_STRNLEN
  155 
  156 # Check if strtonum works.
  157 AC_MSG_CHECKING([for working strtonum])
  158 AC_RUN_IFELSE([AC_LANG_PROGRAM(
  159          [#include <stdlib.h>],
  160          [return (strtonum("0", 0, 1, NULL) == 0 ? 0 : 1);]
  161 	 )],
  162 	 [AC_DEFINE(HAVE_STRTONUM) AC_MSG_RESULT(yes)],
  163 	 [AC_LIBOBJ(strtonum) AC_MSG_RESULT(no)]
  164 )
  165 
  166 # Clang sanitizers wrap reallocarray even if it isn't available on the target
  167 # system. When compiled it always returns NULL and crashes the program. To
  168 # detect this we need a more complicated test.
  169 AC_MSG_CHECKING([for working reallocarray])
  170 AC_RUN_IFELSE([AC_LANG_PROGRAM(
  171 		[#include <stdlib.h>],
  172 		[return (reallocarray(NULL, 1, 1) == NULL);]
  173 	)],
  174 	AC_MSG_RESULT(yes),
  175 	[AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])],
  176 	[AC_LIBOBJ(reallocarray) AC_MSG_RESULT([no])]
  177 )
  178 AC_MSG_CHECKING([for working recallocarray])
  179 AC_RUN_IFELSE([AC_LANG_PROGRAM(
  180 		[#include <stdlib.h>],
  181 		[return (recallocarray(NULL, 1, 1, 1) == NULL);]
  182 	)],
  183 	AC_MSG_RESULT(yes),
  184 	[AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])],
  185 	[AC_LIBOBJ(recallocarray) AC_MSG_RESULT([no])]
  186 )
  187 
  188 # Look for clock_gettime. Must come before event_init.
  189 AC_SEARCH_LIBS(clock_gettime, rt)
  190 
  191 # Always use our getopt because 1) glibc's doesn't enforce argument order 2)
  192 # musl does not set optarg to NULL for flags without arguments (although it is
  193 # not required to, but it is helpful) 3) there are probably other weird
  194 # implementations.
  195 AC_LIBOBJ(getopt)
  196 
  197 # Look for libevent. Try libevent_core or libevent with pkg-config first then
  198 # look for the library.
  199 PKG_CHECK_MODULES(
  200 	LIBEVENT_CORE,
  201 	[libevent_core >= 2],
  202 	[
  203 		AM_CPPFLAGS="$LIBEVENT_CORE_CFLAGS $AM_CPPFLAGS"
  204 		CPPFLAGS="$AM_CPPFLAGS $SAVED_CPPFLAGS"
  205 		LIBS="$LIBEVENT_CORE_LIBS $LIBS"
  206 		found_libevent=yes
  207 	],
  208 	found_libevent=no
  209 )
  210 if test x$found_libevent = xno; then
  211 	PKG_CHECK_MODULES(
  212 		LIBEVENT,
  213 		[libevent >= 2],
  214 		[
  215 			AM_CPPFLAGS="$LIBEVENT_CFLAGS $AM_CPPFLAGS"
  216 			CPPFLAGS="$AM_CPPFLAGS $SAVED_CPPFLAGS"
  217 			LIBS="$LIBEVENT_LIBS $LIBS"
  218 			found_libevent=yes
  219 		],
  220 		found_libevent=no
  221 	)
  222 fi
  223 if test x$found_libevent = xno; then
  224 	AC_SEARCH_LIBS(
  225 		event_init,
  226 		[event_core event event-1.4],
  227 		found_libevent=yes,
  228 		found_libevent=no
  229 	)
  230 fi
  231 AC_CHECK_HEADER(
  232 	event2/event.h,
  233 	AC_DEFINE(HAVE_EVENT2_EVENT_H),
  234 	[
  235 		AC_CHECK_HEADER(
  236 			event.h,
  237 			AC_DEFINE(HAVE_EVENT_H),
  238 			found_libevent=no
  239 		)
  240 	]
  241 )
  242 if test "x$found_libevent" = xno; then
  243 	AC_MSG_ERROR("libevent not found")
  244 fi
  245 
  246 # Look for ncurses or curses. Try pkg-config first then directly for the
  247 # library.
  248 PKG_CHECK_MODULES(
  249 	LIBTINFO,
  250 	tinfo,
  251 	[
  252 		AM_CPPFLAGS="$LIBTINFO_CFLAGS $AM_CPPFLAGS"
  253 		CPPFLAGS="$LIBTINFO_CFLAGS $SAVED_CPPFLAGS"
  254 		LIBS="$LIBTINFO_LIBS $LIBS"
  255 		found_ncurses=yes
  256 	],
  257 	found_ncurses=no
  258 )
  259 if test "x$found_ncurses" = xno; then
  260 	PKG_CHECK_MODULES(
  261 		LIBNCURSES,
  262 		ncurses,
  263 		[
  264 			AM_CPPFLAGS="$LIBNCURSES_CFLAGS $AM_CPPFLAGS"
  265 			CPPFLAGS="$LIBNCURSES_CFLAGS $SAVED_CPPFLAGS"
  266 			LIBS="$LIBNCURSES_LIBS $LIBS"
  267 			found_ncurses=yes
  268 		],
  269 		found_ncurses=no
  270 	)
  271 fi
  272 if test "x$found_ncurses" = xno; then
  273 	PKG_CHECK_MODULES(
  274 		LIBNCURSESW,
  275 		ncursesw,
  276 		[
  277 			AM_CPPFLAGS="$LIBNCURSESW_CFLAGS $AM_CPPFLAGS"
  278 			CPPFLAGS="$LIBNCURSESW_CFLAGS $SAVED_CPPFLAGS"
  279 			LIBS="$LIBNCURSESW_LIBS $LIBS"
  280 			found_ncurses=yes
  281 		],
  282 		found_ncurses=no
  283 	)
  284 fi
  285 if test "x$found_ncurses" = xno; then
  286 	AC_SEARCH_LIBS(
  287 		setupterm,
  288 		[tinfo ncurses ncursesw],
  289 		found_ncurses=yes,
  290 		found_ncurses=no
  291 	)
  292 	if test "x$found_ncurses" = xyes; then
  293 		AC_CHECK_HEADER(
  294 			ncurses.h,
  295 			LIBS="$LIBS -lncurses",
  296 			found_ncurses=no
  297 		)
  298 	fi
  299 fi
  300 if test "x$found_ncurses" = xyes; then
  301 	AC_DEFINE(HAVE_NCURSES_H)
  302 else
  303 	AC_CHECK_LIB(
  304 		curses,
  305 		setupterm,
  306 		found_curses=yes,
  307 		found_curses=no
  308 	)
  309 	AC_CHECK_HEADER(
  310 		curses.h,
  311 		,
  312 		found_curses=no
  313 	)
  314 	if test "x$found_curses" = xyes; then
  315 		LIBS="$LIBS -lcurses"
  316 		AC_DEFINE(HAVE_CURSES_H)
  317 	else
  318 		AC_MSG_ERROR("curses not found")
  319 	fi
  320 fi
  321 
  322 # Look for utempter.
  323 AC_ARG_ENABLE(
  324 	utempter,
  325 	AC_HELP_STRING(--enable-utempter, use utempter if it is installed)
  326 )
  327 if test "x$enable_utempter" = xyes; then
  328 	AC_CHECK_HEADER(utempter.h, enable_utempter=yes, enable_utempter=no)
  329 	if test "x$enable_utempter" = xyes; then
  330 		AC_SEARCH_LIBS(
  331 			utempter_add_record,
  332 			utempter,
  333 			enable_utempter=yes,
  334 			enable_utempter=no
  335 		)
  336 	fi
  337 	if test "x$enable_utempter" = xyes; then
  338 		AC_DEFINE(HAVE_UTEMPTER)
  339 	else
  340 		AC_MSG_ERROR("utempter not found")
  341 	fi
  342 fi
  343 
  344 # Look for utf8proc.
  345 AC_ARG_ENABLE(
  346 	utf8proc,
  347 	AC_HELP_STRING(--enable-utf8proc, use utf8proc if it is installed)
  348 )
  349 if test "x$enable_utf8proc" = xyes; then
  350 	AC_CHECK_HEADER(utf8proc.h, enable_utf8proc=yes, enable_utf8proc=no)
  351 	if test "x$enable_utf8proc" = xyes; then
  352 		AC_SEARCH_LIBS(
  353 			utf8proc_charwidth,
  354 			utf8proc,
  355 			enable_utf8proc=yes,
  356 			enable_utf8proc=no
  357 		)
  358 	fi
  359 	if test "x$enable_utf8proc" = xyes; then
  360 		AC_DEFINE(HAVE_UTF8PROC)
  361 	else
  362 		AC_MSG_ERROR("utf8proc not found")
  363 	fi
  364 fi
  365 AM_CONDITIONAL(HAVE_UTF8PROC, [test "x$enable_utf8proc" = xyes])
  366 
  367 # Check for b64_ntop. If we have b64_ntop, we assume b64_pton as well.
  368 AC_MSG_CHECKING(for b64_ntop)
  369 AC_TRY_LINK(
  370 	[
  371 		#include <sys/types.h>
  372 		#include <netinet/in.h>
  373 		#include <resolv.h>
  374 	],
  375 	[b64_ntop(NULL, 0, NULL, 0);],
  376 	found_b64_ntop=yes,
  377 	found_b64_ntop=no
  378 )
  379 AC_MSG_RESULT($found_b64_ntop)
  380 OLD_LIBS="$LIBS"
  381 if test "x$found_b64_ntop" = xno; then
  382 	AC_MSG_CHECKING(for b64_ntop with -lresolv)
  383 	LIBS="$OLD_LIBS -lresolv"
  384 	AC_TRY_LINK(
  385 		[
  386 			#include <sys/types.h>
  387 			#include <netinet/in.h>
  388 			#include <resolv.h>
  389 		],
  390 		[b64_ntop(NULL, 0, NULL, 0);],
  391 		found_b64_ntop=yes,
  392 		found_b64_ntop=no
  393 	)
  394 	AC_MSG_RESULT($found_b64_ntop)
  395 fi
  396 if test "x$found_b64_ntop" = xno; then
  397 	AC_MSG_CHECKING(for b64_ntop with -lnetwork)
  398 	LIBS="$OLD_LIBS -lnetwork"
  399 	AC_TRY_LINK(
  400 		[
  401 			#include <sys/types.h>
  402 			#include <netinet/in.h>
  403 			#include <resolv.h>
  404 		],
  405 		[b64_ntop(NULL, 0, NULL, 0);],
  406 		found_b64_ntop=yes,
  407 		found_b64_ntop=no
  408 	)
  409 	AC_MSG_RESULT($found_b64_ntop)
  410 fi
  411 if test "x$found_b64_ntop" = xyes; then
  412 	AC_DEFINE(HAVE_B64_NTOP)
  413 else
  414 	LIBS="$OLD_LIBS"
  415 	AC_LIBOBJ(base64)
  416 fi
  417 
  418 # Look for networking libraries.
  419 AC_SEARCH_LIBS(inet_ntoa, nsl)
  420 AC_SEARCH_LIBS(socket, socket)
  421 AC_CHECK_LIB(xnet, socket)
  422 
  423 # Check if using glibc and have malloc_trim(3). The glibc free(3) is pretty bad
  424 # about returning memory to the kernel unless the application tells it when to
  425 # with malloc_trim(3).
  426 AC_MSG_CHECKING(if free doesn't work very well)
  427 AC_LINK_IFELSE([AC_LANG_SOURCE(
  428 	[
  429 		#include <stdlib.h>
  430 		#ifdef __GLIBC__
  431 		#include <malloc.h>
  432 		int main(void) {
  433 			malloc_trim (0);
  434 			exit(0);
  435 		}
  436 		#else
  437 		no
  438 		#endif
  439 	])],
  440 	found_malloc_trim=yes,
  441 	found_malloc_trim=no
  442 )
  443 AC_MSG_RESULT($found_malloc_trim)
  444 if test "x$found_malloc_trim" = xyes; then
  445 	AC_DEFINE(HAVE_MALLOC_TRIM)
  446 fi
  447 
  448 # Check for CMSG_DATA. On some platforms like HP-UX this requires UNIX 95
  449 # (_XOPEN_SOURCE and _XOPEN_SOURCE_EXTENDED) (see xopen_networking(7)). On
  450 # others, UNIX 03 (_XOPEN_SOURCE 600, see standards(7) on Solaris).
  451 XOPEN_DEFINES=
  452 AC_MSG_CHECKING(for CMSG_DATA)
  453 AC_EGREP_CPP(
  454 	yes,
  455 	[
  456 		#include <sys/socket.h>
  457 		#ifdef CMSG_DATA
  458 		yes
  459 		#endif
  460 	],
  461 	found_cmsg_data=yes,
  462 	found_cmsg_data=no
  463 )
  464 AC_MSG_RESULT($found_cmsg_data)
  465 if test "x$found_cmsg_data" = xno; then
  466 	AC_MSG_CHECKING(if CMSG_DATA needs _XOPEN_SOURCE_EXTENDED)
  467 	AC_EGREP_CPP(
  468 		yes,
  469 		[
  470 			#define _XOPEN_SOURCE 1
  471 			#define _XOPEN_SOURCE_EXTENDED 1
  472 			#include <sys/socket.h>
  473 			#ifdef CMSG_DATA
  474 			yes
  475 			#endif
  476 		],
  477 		found_cmsg_data=yes,
  478 		found_cmsg_data=no
  479 	)
  480 	AC_MSG_RESULT($found_cmsg_data)
  481 	if test "x$found_cmsg_data" = xyes; then
  482 		XOPEN_DEFINES="-D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED"
  483 	fi
  484 fi
  485 if test "x$found_cmsg_data" = xno; then
  486 	AC_MSG_CHECKING(if CMSG_DATA needs _XOPEN_SOURCE 600)
  487 	AC_EGREP_CPP(
  488 		yes,
  489 		[
  490 			#define _XOPEN_SOURCE 600
  491 			#include <sys/socket.h>
  492 			#ifdef CMSG_DATA
  493 			yes
  494 			#endif
  495 		],
  496 		found_cmsg_data=yes,
  497 		found_cmsg_data=no
  498 	)
  499 	AC_MSG_RESULT($found_cmsg_data)
  500 	if test "x$found_cmsg_data" = xyes; then
  501 		XOPEN_DEFINES="-D_XOPEN_SOURCE=600"
  502 	else
  503 		AC_MSG_ERROR("CMSG_DATA not found")
  504 	fi
  505 fi
  506 AC_SUBST(XOPEN_DEFINES)
  507 
  508 # Look for err and friends in err.h.
  509 AC_CHECK_FUNC(err, found_err_h=yes, found_err_h=no)
  510 AC_CHECK_FUNC(errx, , found_err_h=no)
  511 AC_CHECK_FUNC(warn, , found_err_h=no)
  512 AC_CHECK_FUNC(warnx, , found_err_h=no)
  513 if test "x$found_err_h" = xyes; then
  514 	AC_CHECK_HEADER(err.h, , found_err_h=no)
  515 else
  516 	AC_LIBOBJ(err)
  517 fi
  518 
  519 # Look for imsg_init in libutil.
  520 AC_SEARCH_LIBS(imsg_init, util, found_imsg_init=yes, found_imsg_init=no)
  521 if test "x$found_imsg_init" = xyes; then
  522 	AC_DEFINE(HAVE_IMSG)
  523 else
  524 	AC_LIBOBJ(imsg)
  525 	AC_LIBOBJ(imsg-buffer)
  526 fi
  527 
  528 # Look for daemon, compat/daemon.c used if missing. Solaris 10 has it in
  529 # libresolv, but no declaration anywhere, so check for declaration as well as
  530 # function.
  531 AC_CHECK_FUNC(daemon, found_daemon=yes, found_daemon=no)
  532 AC_CHECK_DECL(
  533 	daemon,
  534 	,
  535 	found_daemon=no,
  536 	[
  537 		#include <stdlib.h>
  538 		#include <unistd.h>
  539 	]
  540 )
  541 if test "x$found_daemon" = xyes; then
  542 	AC_DEFINE(HAVE_DAEMON)
  543 else
  544 	AC_LIBOBJ(daemon)
  545 fi
  546 
  547 # Look for stravis, compat/{vis,unvis}.c used if missing.
  548 AC_CHECK_FUNC(stravis, found_stravis=yes, found_stravis=no)
  549 if test "x$found_stravis" = xyes; then
  550 	AC_MSG_CHECKING(if strnvis is broken)
  551 	AC_EGREP_HEADER([strnvis\(char \*, const char \*, size_t, int\)],
  552 			vis.h,
  553 			AC_MSG_RESULT(no),
  554 			[found_stravis=no])
  555 	if test "x$found_stravis" = xno; then
  556 		AC_MSG_RESULT(yes)
  557 	fi
  558 fi
  559 if test "x$found_stravis" = xyes; then
  560 	AC_CHECK_DECL(
  561 		VIS_DQ,
  562 		,
  563 		found_stravis=no,
  564 		[
  565 			#include <stdlib.h>
  566 			#include <vis.h>
  567 		]
  568 )
  569 fi
  570 if test "x$found_stravis" = xyes; then
  571 	AC_DEFINE(HAVE_VIS)
  572 else
  573 	AC_LIBOBJ(vis)
  574 	AC_LIBOBJ(unvis)
  575 fi
  576 
  577 # Look for fdforkpty and forkpty in libutil.
  578 AC_SEARCH_LIBS(fdforkpty, util, found_fdforkpty=yes, found_fdforkpty=no)
  579 if test "x$found_fdforkpty" = xyes; then
  580 	AC_DEFINE(HAVE_FDFORKPTY)
  581 else
  582 	AC_LIBOBJ(fdforkpty)
  583 fi
  584 AC_SEARCH_LIBS(forkpty, util, found_forkpty=yes, found_forkpty=no)
  585 if test "x$found_forkpty" = xyes; then
  586 	AC_DEFINE(HAVE_FORKPTY)
  587 fi
  588 AM_CONDITIONAL(NEED_FORKPTY, test "x$found_forkpty" = xno)
  589 
  590 # Look for kinfo_getfile in libutil.
  591 AC_SEARCH_LIBS(kinfo_getfile, [util util-freebsd])
  592 
  593 # Look for a suitable queue.h.
  594 AC_CHECK_DECL(
  595 	TAILQ_CONCAT,
  596 	found_queue_h=yes,
  597 	found_queue_h=no,
  598 	[#include <sys/queue.h>]
  599 )
  600 AC_CHECK_DECL(
  601 	TAILQ_PREV,
  602 	found_queue_h=yes,
  603 	found_queue_h=no,
  604 	[#include <sys/queue.h>]
  605 )
  606 AC_CHECK_DECL(
  607 	TAILQ_REPLACE,
  608 	,
  609 	found_queue_h=no,
  610 	[#include <sys/queue.h>]
  611 )
  612 if test "x$found_queue_h" = xyes; then
  613 	AC_DEFINE(HAVE_QUEUE_H)
  614 fi
  615 
  616 # Look for __progname.
  617 AC_MSG_CHECKING(for __progname)
  618 AC_LINK_IFELSE([AC_LANG_SOURCE(
  619 	[
  620 		#include <stdio.h>
  621 		#include <stdlib.h>
  622 		extern char *__progname;
  623 		int main(void) {
  624 			const char *cp = __progname;
  625 			printf("%s\n", cp);
  626 			exit(0);
  627 		}
  628 	])],
  629 	[AC_DEFINE(HAVE___PROGNAME) AC_MSG_RESULT(yes)],
  630 	AC_MSG_RESULT(no)
  631 )
  632 
  633 # Look for program_invocation_short_name.
  634 AC_MSG_CHECKING(for program_invocation_short_name)
  635 AC_LINK_IFELSE([AC_LANG_SOURCE(
  636 	[
  637 		#include <errno.h>
  638 		#include <stdio.h>
  639 		#include <stdlib.h>
  640 		int main(void) {
  641 			const char *cp = program_invocation_short_name;
  642 			printf("%s\n", cp);
  643 			exit(0);
  644 		}
  645 	])],
  646 	[AC_DEFINE(HAVE_PROGRAM_INVOCATION_SHORT_NAME) AC_MSG_RESULT(yes)],
  647 	AC_MSG_RESULT(no)
  648 )
  649 
  650 # Look for prctl(PR_SET_NAME).
  651 AC_CHECK_DECL(
  652 	PR_SET_NAME,
  653 	AC_DEFINE(HAVE_PR_SET_NAME),
  654 	,
  655 	[#include <sys/prctl.h>]
  656 )
  657 
  658 # Look for fcntl(F_CLOSEM).
  659 AC_CHECK_DECL(
  660 	F_CLOSEM,
  661 	AC_DEFINE(HAVE_FCNTL_CLOSEM),
  662 	,
  663 	[#include <fcntl.h>]
  664 )
  665 
  666 # Look for /proc/$$.
  667 AC_MSG_CHECKING(for /proc/\$\$)
  668 if test -d /proc/$$; then
  669 	AC_DEFINE(HAVE_PROC_PID)
  670 	AC_MSG_RESULT(yes)
  671 else
  672 	AC_MSG_RESULT(no)
  673 fi
  674 
  675 # Man page defaults to mdoc.
  676 MANFORMAT=mdoc
  677 AC_SUBST(MANFORMAT)
  678 
  679 # Figure out the platform.
  680 AC_MSG_CHECKING(platform)
  681 case "$host_os" in
  682 	*aix*)
  683 		AC_MSG_RESULT(aix)
  684 		PLATFORM=aix
  685 		;;
  686 	*darwin*)
  687 		AC_MSG_RESULT(darwin)
  688 		PLATFORM=darwin
  689 		#
  690 		# OS X uses __dead2 instead of __dead, like FreeBSD. But it
  691 		# defines __dead away so it needs to be removed before we can
  692 		# replace it.
  693 		#
  694 		AC_DEFINE(BROKEN___DEAD)
  695 		#
  696 		# OS X CMSG_FIRSTHDR is broken, so redefine it with a working
  697 		# one. daemon works but has some stupid side effects, so use
  698 		# our internal version which has a workaround.
  699 		#
  700 		AC_DEFINE(BROKEN_CMSG_FIRSTHDR)
  701 		AC_LIBOBJ(daemon)
  702 		AC_LIBOBJ(daemon-darwin)
  703 		;;
  704 	*dragonfly*)
  705 		AC_MSG_RESULT(dragonfly)
  706 		PLATFORM=dragonfly
  707 		;;
  708 	*linux*)
  709 		AC_MSG_RESULT(linux)
  710 		PLATFORM=linux
  711 		;;
  712 	*freebsd*)
  713 		AC_MSG_RESULT(freebsd)
  714 		PLATFORM=freebsd
  715 		;;
  716 	*netbsd*)
  717 		AC_MSG_RESULT(netbsd)
  718 		PLATFORM=netbsd
  719 		;;
  720 	*openbsd*)
  721 		AC_MSG_RESULT(openbsd)
  722 		PLATFORM=openbsd
  723 		;;
  724 	*sunos*)
  725 		AC_MSG_RESULT(sunos)
  726 		PLATFORM=sunos
  727 		;;
  728 	*solaris*)
  729 		AC_MSG_RESULT(sunos)
  730 		PLATFORM=sunos
  731 		case `/usr/bin/nroff --version 2>&1` in
  732 			*GNU*)
  733 				# Solaris 11.4 and later use GNU groff.
  734 				MANFORMAT=mdoc
  735 				;;
  736 			*)
  737 				# Solaris 2.0 to 11.3 use AT&T nroff.
  738 				MANFORMAT=man
  739 				;;
  740 		esac
  741 		;;
  742 	*hpux*)
  743 		AC_MSG_RESULT(hpux)
  744 		PLATFORM=hpux
  745 		;;
  746 	*cygwin*|*msys*)
  747 		AC_MSG_RESULT(cygwin)
  748 		PLATFORM=cygwin
  749 		;;
  750 	*haiku*)
  751 		AC_MSG_RESULT(haiku)
  752 		PLATFORM=haiku
  753 		;;
  754 	*)
  755 		AC_MSG_RESULT(unknown)
  756 		PLATFORM=unknown
  757 		;;
  758 esac
  759 AC_SUBST(PLATFORM)
  760 AM_CONDITIONAL(IS_AIX, test "x$PLATFORM" = xaix)
  761 AM_CONDITIONAL(IS_DARWIN, test "x$PLATFORM" = xdarwin)
  762 AM_CONDITIONAL(IS_DRAGONFLY, test "x$PLATFORM" = xdragonfly)
  763 AM_CONDITIONAL(IS_LINUX, test "x$PLATFORM" = xlinux)
  764 AM_CONDITIONAL(IS_FREEBSD, test "x$PLATFORM" = xfreebsd)
  765 AM_CONDITIONAL(IS_NETBSD, test "x$PLATFORM" = xnetbsd)
  766 AM_CONDITIONAL(IS_OPENBSD, test "x$PLATFORM" = xopenbsd)
  767 AM_CONDITIONAL(IS_SUNOS, test "x$PLATFORM" = xsunos)
  768 AM_CONDITIONAL(IS_HPUX, test "x$PLATFORM" = xhpux)
  769 AM_CONDITIONAL(IS_HAIKU, test "x$PLATFORM" = xhaiku)
  770 AM_CONDITIONAL(IS_UNKNOWN, test "x$PLATFORM" = xunknown)
  771 
  772 # Save our CFLAGS/CPPFLAGS/LDFLAGS for the Makefile and restore the old user
  773 # variables.
  774 AC_SUBST(AM_CPPFLAGS)
  775 CPPFLAGS="$SAVED_CPPFLAGS"
  776 AC_SUBST(AM_CFLAGS)
  777 CFLAGS="$SAVED_CFLAGS"
  778 AC_SUBST(AM_LDFLAGS)
  779 LDFLAGS="$SAVED_LDFLAGS"
  780 
  781 # autoconf should create a Makefile.
  782 AC_OUTPUT(Makefile)