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