configure.ac revision 1.1.1.2
1# configure.ac 2 3AC_INIT(tmux, 2.6) 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# Set up the compiler in two different ways and say yes we may want to install. 25AC_PROG_CC 26AM_PROG_CC_C_O 27AC_PROG_CC_C99 28AC_PROG_CPP 29AC_PROG_EGREP 30AC_PROG_INSTALL 31PKG_PROG_PKG_CONFIG 32AC_USE_SYSTEM_EXTENSIONS 33 34# Default tmux.conf goes in /etc not ${prefix}/etc. 35test "$sysconfdir" = '${prefix}/etc' && sysconfdir=/etc 36 37# Is this --enable-debug? 38test "x$VERSION" = xmaster && enable_debug=yes 39AC_ARG_ENABLE( 40 debug, 41 AC_HELP_STRING(--enable-debug, enable debug build flags), 42) 43AM_CONDITIONAL(IS_DEBUG, test "x$enable_debug" = xyes) 44 45# Is this a static build? 46AC_ARG_ENABLE( 47 static, 48 AC_HELP_STRING(--enable-static, create a static build) 49) 50if test "x$enable_static" = xyes; then 51 test "x$PKG_CONFIG" != x && PKG_CONFIG="$PKG_CONFIG --static" 52 AM_LDFLAGS="-static $AM_LDFLAGS" 53 LDFLAGS="$AM_LDFLAGS $SAVED_LDFLAGS" 54fi 55 56# Is this gcc? 57AM_CONDITIONAL(IS_GCC, test "x$GCC" = xyes) 58 59# Is this Sun CC? 60AC_EGREP_CPP( 61 yes, 62 [ 63 #ifdef __SUNPRO_C 64 yes 65 #endif 66 ], 67 found_suncc=yes, 68 found_suncc=no 69) 70AM_CONDITIONAL(IS_SUNCC, test "x$found_suncc" = xyes) 71 72# Check for various headers. Alternatives included from compat.h. 73AC_CHECK_HEADERS([ \ 74 bitstring.h \ 75 dirent.h \ 76 fcntl.h \ 77 inttypes.h \ 78 libutil.h \ 79 ndir.h \ 80 paths.h \ 81 pty.h \ 82 stdint.h \ 83 sys/dir.h \ 84 sys/ndir.h \ 85 sys/tree.h \ 86 util.h \ 87]) 88 89# Look for library needed for flock. 90AC_SEARCH_LIBS(flock, bsd) 91 92# Check for functions that are replaced or omitted. 93AC_CHECK_FUNCS([ \ 94 dirfd \ 95 flock \ 96 prctl \ 97 sysconf \ 98]) 99 100# Check for functions with a compatibility implementation. 101AC_REPLACE_FUNCS([ \ 102 asprintf \ 103 cfmakeraw \ 104 closefrom \ 105 explicit_bzero \ 106 fgetln \ 107 freezero \ 108 getdtablecount \ 109 getprogname \ 110 memmem \ 111 recallocarray \ 112 reallocarray \ 113 setenv \ 114 setproctitle \ 115 strcasestr \ 116 strlcat \ 117 strlcpy \ 118 strndup \ 119 strsep \ 120 strtonum \ 121]) 122AC_FUNC_STRNLEN 123 124# Look for clock_gettime. Must come before event_init. 125AC_SEARCH_LIBS(clock_gettime, rt) 126 127# Look for libevent. 128PKG_CHECK_MODULES( 129 LIBEVENT, 130 libevent, 131 [ 132 AM_CFLAGS="$LIBEVENT_CFLAGS $AM_CFLAGS" 133 CFLAGS="$AM_CFLAGS $SAVED_CFLAGS" 134 LIBS="$LIBEVENT_LIBS $LIBS" 135 found_libevent=yes 136 ], 137 [ 138 AC_SEARCH_LIBS( 139 event_init, 140 [event event-1.4 event2], 141 found_libevent=yes, 142 found_libevent=no 143 ) 144 ] 145) 146AC_CHECK_HEADER( 147 event.h, 148 , 149 found_libevent=no 150) 151if test "x$found_libevent" = xno; then 152 AC_MSG_ERROR("libevent not found") 153fi 154 155# Look for ncurses. 156PKG_CHECK_MODULES( 157 LIBTINFO, 158 tinfo, 159 found_ncurses=yes, 160 found_ncurses=no 161) 162if test "x$found_ncurses" = xno; then 163 PKG_CHECK_MODULES( 164 LIBNCURSES, 165 ncurses, 166 found_ncurses=yes, 167 found_ncurses=no 168 ) 169fi 170if test "x$found_ncurses" = xno; then 171 PKG_CHECK_MODULES( 172 LIBNCURSES, 173 ncursesw, 174 found_ncurses=yes, 175 found_ncurses=no 176 ) 177fi 178if test "x$found_ncurses" = xyes; then 179 AM_CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $AM_CFLAGS" 180 CFLAGS="$LIBNCURSES_CFLAGS $LIBTINFO_CFLAGS $CFLAGS" 181 LIBS="$LIBNCURSES_LIBS $LIBTINFO_LIBS $LIBS" 182else 183 # pkg-config didn't work, try ncurses. 184 AC_CHECK_LIB( 185 tinfo, 186 setupterm, 187 found_ncurses=yes, 188 found_ncurses=no 189 ) 190 if test "x$found_ncurses" = xno; then 191 AC_CHECK_LIB( 192 ncurses, 193 setupterm, 194 found_ncurses=yes, 195 found_ncurses=no 196 ) 197 fi 198 if test "x$found_ncurses" = xyes; then 199 AC_CHECK_HEADER( 200 ncurses.h, 201 LIBS="$LIBS -lncurses", 202 found_ncurses=no) 203 fi 204fi 205if test "x$found_ncurses" = xyes; then 206 AC_DEFINE(HAVE_NCURSES_H) 207else 208 # No ncurses, try curses. 209 AC_CHECK_LIB( 210 curses, 211 setupterm, 212 found_curses=yes, 213 found_curses=no 214 ) 215 AC_CHECK_HEADER( 216 curses.h, 217 , 218 found_curses=no) 219 if test "x$found_curses" = xyes; then 220 LIBS="$LIBS -lcurses" 221 AC_DEFINE(HAVE_CURSES_H) 222 else 223 AC_MSG_ERROR("curses not found") 224 fi 225fi 226 227# Look for utempter. 228AC_ARG_ENABLE( 229 utempter, 230 AC_HELP_STRING(--enable-utempter, use utempter if it is installed) 231) 232if test "x$enable_utempter" = xyes; then 233 AC_CHECK_HEADER(utempter.h, enable_utempter=yes, enable_utempter=no) 234 if test "x$enable_utempter" = xyes; then 235 AC_SEARCH_LIBS( 236 utempter_add_record, 237 utempter, 238 enable_utempter=yes, 239 enable_utempter=no 240 ) 241 fi 242 if test "x$enable_utempter" = xyes; then 243 AC_DEFINE(HAVE_UTEMPTER) 244 else 245 AC_MSG_ERROR("utempter not found") 246 fi 247fi 248 249# Look for utf8proc. 250AC_ARG_ENABLE( 251 utf8proc, 252 AC_HELP_STRING(--enable-utf8proc, use utf8proc if it is installed) 253) 254if test "x$enable_utf8proc" = xyes; then 255 AC_CHECK_HEADER(utf8proc.h, enable_utf8proc=yes, enable_utf8proc=no) 256 if test "x$enable_utf8proc" = xyes; then 257 AC_SEARCH_LIBS( 258 utf8proc_charwidth, 259 utf8proc, 260 enable_utf8proc=yes, 261 enable_utf8proc=no 262 ) 263 fi 264 if test "x$enable_utf8proc" = xyes; then 265 AC_DEFINE(HAVE_UTF8PROC) 266 else 267 AC_MSG_ERROR("utf8proc not found") 268 fi 269fi 270AM_CONDITIONAL(HAVE_UTF8PROC, [test "x$enable_utf8proc" = xyes]) 271 272# Check for b64_ntop. If we have b64_ntop, we assume b64_pton as well. 273AC_MSG_CHECKING(for b64_ntop) 274AC_TRY_LINK( 275 [ 276 #include <sys/types.h> 277 #include <netinet/in.h> 278 #include <resolv.h> 279 ], 280 [b64_ntop(NULL, 0, NULL, 0);], 281 found_b64_ntop=yes, 282 found_b64_ntop=no 283) 284if test "x$found_b64_ntop" = xno; then 285 AC_MSG_RESULT(no) 286 287 AC_MSG_CHECKING(for b64_ntop with -lresolv) 288 LIBS="$LIBS -lresolv" 289 AC_TRY_LINK( 290 [ 291 #include <sys/types.h> 292 #include <netinet/in.h> 293 #include <resolv.h> 294 ], 295 [b64_ntop(NULL, 0, NULL, 0);], 296 found_b64_ntop=yes, 297 found_b64_ntop=no 298 ) 299 if test "x$found_b64_ntop" = xno; then 300 AC_MSG_RESULT(no) 301 fi 302fi 303if test "x$found_b64_ntop" = xyes; then 304 AC_DEFINE(HAVE_B64_NTOP) 305 AC_MSG_RESULT(yes) 306else 307 AC_LIBOBJ(base64) 308fi 309 310# Look for networking libraries. 311AC_SEARCH_LIBS(inet_ntoa, nsl) 312AC_SEARCH_LIBS(socket, socket) 313AC_CHECK_LIB(xnet, socket) 314 315# Check for CMSG_DATA. Some platforms require _XOPEN_SOURCE_EXTENDED (for 316# example see xopen_networking(7) on HP-UX). 317XOPEN_DEFINES= 318AC_MSG_CHECKING(for CMSG_DATA) 319AC_EGREP_CPP( 320 yes, 321 [ 322 #include <sys/socket.h> 323 #ifdef CMSG_DATA 324 yes 325 #endif 326 ], 327 found_cmsg_data=yes, 328 found_cmsg_data=no 329) 330AC_MSG_RESULT($found_cmsg_data) 331if test "x$found_cmsg_data" = xno; then 332 AC_MSG_CHECKING(if CMSG_DATA needs _XOPEN_SOURCE_EXTENDED) 333 AC_EGREP_CPP( 334 yes, 335 [ 336 #define _XOPEN_SOURCE 1 337 #define _XOPEN_SOURCE_EXTENDED 1 338 #include <sys/socket.h> 339 #ifdef CMSG_DATA 340 yes 341 #endif 342 ], 343 found_cmsg_data=yes, 344 found_cmsg_data=no 345 ) 346 AC_MSG_RESULT($found_cmsg_data) 347 if test "x$found_cmsg_data" = xyes; then 348 XOPEN_DEFINES="-D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED" 349 else 350 AC_MSG_ERROR("CMSG_DATA not found") 351 fi 352fi 353AC_SUBST(XOPEN_DEFINES) 354 355# Look for err and friends in err.h. 356AC_CHECK_FUNC(err, found_err_h=yes, found_err_h=no) 357AC_CHECK_FUNC(errx, , found_err_h=no) 358AC_CHECK_FUNC(warn, , found_err_h=no) 359AC_CHECK_FUNC(warnx, , found_err_h=no) 360if test "x$found_err_h" = xyes; then 361 AC_CHECK_HEADER(err.h, , found_err_h=no) 362else 363 AC_LIBOBJ(err) 364fi 365 366# Look for imsg_init in libutil. 367AC_SEARCH_LIBS(imsg_init, util, found_imsg_init=yes, found_imsg_init=no) 368if test "x$found_imsg_init" = xyes; then 369 AC_DEFINE(HAVE_IMSG) 370else 371 AC_LIBOBJ(imsg) 372 AC_LIBOBJ(imsg-buffer) 373fi 374 375# Look for daemon, compat/daemon.c used if missing. Solaris 10 has it in 376# libresolv, but no declaration anywhere, so check for declaration as well as 377# function. 378AC_CHECK_FUNC(daemon, found_daemon=yes, found_daemon=no) 379AC_CHECK_DECL( 380 daemon, 381 , 382 found_daemon=no, 383 [ 384 #include <stdlib.h> 385 #include <unistd.h> 386 ] 387) 388if test "x$found_daemon" = xyes; then 389 AC_DEFINE(HAVE_DAEMON) 390else 391 AC_LIBOBJ(daemon) 392fi 393 394# Look for stravis, compat/{vis,unvis}.c used if missing. 395AC_CHECK_FUNC(stravis, found_stravis=yes, found_stravis=no) 396if test "x$found_stravis" = xyes; then 397 AC_MSG_CHECKING(if strnvis is broken) 398 AC_EGREP_HEADER([strnvis\(char \*, const char \*, size_t, int\)], 399 vis.h, 400 AC_MSG_RESULT(no), 401 [found_stravis=no]) 402 if test "x$found_stravis" = xno; then 403 AC_MSG_RESULT(yes) 404 fi 405fi 406if test "x$found_stravis" = xyes; then 407 AC_CHECK_DECL( 408 VIS_DQ, 409 , 410 found_stravis=no, 411 [ 412 #include <stdlib.h> 413 #include <vis.h> 414 ] 415) 416fi 417if test "x$found_stravis" = xyes; then 418 AC_DEFINE(HAVE_VIS) 419else 420 AC_LIBOBJ(vis) 421 AC_LIBOBJ(unvis) 422fi 423 424# Look for getopt. glibc's getopt does not enforce argument order and the ways 425# of making it do so are stupid, so just use our own instead. 426AC_CHECK_FUNC(getopt, found_getopt=yes, found_getopt=no) 427if test "x$found_getopt" != xno; then 428 AC_MSG_CHECKING(if getopt is suitable) 429 AC_EGREP_CPP( 430 yes, 431 [ 432 #include <features.h> 433 #ifdef __GLIBC__ 434 yes 435 #endif 436 ], 437 [ 438 found_getopt=no 439 AC_MSG_RESULT(no) 440 ], 441 AC_MSG_RESULT(yes)) 442fi 443if test "x$found_getopt" != xno; then 444 AC_CHECK_DECLS( 445 [optarg, optind, optreset], 446 , 447 found_getopt=no, 448 [ 449 #include <unistd.h> 450 ]) 451fi 452if test "x$found_getopt" != xno; then 453 AC_DEFINE(HAVE_GETOPT) 454else 455 AC_LIBOBJ(getopt) 456fi 457 458# Look for fparseln in libutil. 459AC_SEARCH_LIBS(fparseln, util, found_fparseln=yes, found_fparseln=no) 460if test "x$found_fparseln" = xyes; then 461 AC_DEFINE(HAVE_FPARSELN) 462else 463 AC_LIBOBJ(fparseln) 464fi 465 466# Look for fdforkpty and forkpty in libutil. 467AC_SEARCH_LIBS(fdforkpty, util, found_fdforkpty=yes, found_fdforkpty=no) 468if test "x$found_fdforkpty" = xyes; then 469 AC_DEFINE(HAVE_FDFORKPTY) 470else 471 AC_LIBOBJ(fdforkpty) 472fi 473AC_SEARCH_LIBS(forkpty, util, found_forkpty=yes, found_forkpty=no) 474if test "x$found_forkpty" = xyes; then 475 AC_DEFINE(HAVE_FORKPTY) 476fi 477AM_CONDITIONAL(NEED_FORKPTY, test "x$found_forkpty" = xno) 478 479# Look for a suitable queue.h. 480AC_CHECK_DECL( 481 TAILQ_CONCAT, 482 found_queue_h=yes, 483 found_queue_h=no, 484 [#include <sys/queue.h>] 485) 486AC_CHECK_DECL( 487 TAILQ_PREV, 488 found_queue_h=yes, 489 found_queue_h=no, 490 [#include <sys/queue.h>] 491) 492AC_CHECK_DECL( 493 TAILQ_REPLACE, 494 , 495 found_queue_h=no, 496 [#include <sys/queue.h>] 497) 498if test "x$found_queue_h" = xyes; then 499 AC_DEFINE(HAVE_QUEUE_H) 500fi 501 502# Look for __progname. 503AC_MSG_CHECKING(for __progname) 504AC_LINK_IFELSE([AC_LANG_SOURCE( 505 [ 506 #include <stdio.h> 507 #include <stdlib.h> 508 extern char *__progname; 509 int main(void) { 510 const char *cp = __progname; 511 printf("%s\n", cp); 512 exit(0); 513 } 514 ])], 515 [AC_DEFINE(HAVE___PROGNAME) AC_MSG_RESULT(yes)], 516 AC_MSG_RESULT(no) 517) 518 519# Look for program_invocation_short_name. 520AC_MSG_CHECKING(for program_invocation_short_name) 521AC_LINK_IFELSE([AC_LANG_SOURCE( 522 [ 523 #include <errno.h> 524 #include <stdio.h> 525 #include <stdlib.h> 526 int main(void) { 527 const char *cp = program_invocation_short_name; 528 printf("%s\n", cp); 529 exit(0); 530 } 531 ])], 532 [AC_DEFINE(HAVE_PROGRAM_INVOCATION_SHORT_NAME) AC_MSG_RESULT(yes)], 533 AC_MSG_RESULT(no) 534) 535 536# Look for prctl(PR_SET_NAME). 537AC_CHECK_DECL( 538 PR_SET_NAME, 539 AC_DEFINE(HAVE_PR_SET_NAME), 540 , 541 [#include <sys/prctl.h>] 542) 543 544# Look for fcntl(F_CLOSEM). 545AC_CHECK_DECL( 546 F_CLOSEM, 547 AC_DEFINE(HAVE_FCNTL_CLOSEM), 548 , 549 [#include <fcntl.h>] 550) 551 552# Look for /proc/$$. 553AC_MSG_CHECKING(for /proc/\$\$) 554if test -d /proc/$$; then 555 AC_DEFINE(HAVE_PROC_PID) 556 AC_MSG_RESULT(yes) 557else 558 AC_MSG_RESULT(no) 559fi 560 561# Man page defaults to mdoc. 562MANFORMAT=mdoc 563AC_SUBST(MANFORMAT) 564 565# Figure out the platform. 566AC_MSG_CHECKING(platform) 567case "$host_os" in 568 *aix*) 569 AC_MSG_RESULT(aix) 570 PLATFORM=aix 571 ;; 572 *darwin*) 573 AC_MSG_RESULT(darwin) 574 PLATFORM=darwin 575 # 576 # OS X CMSG_FIRSTHDR is broken, so redefine it with a working 577 # one. daemon works but has some stupid side effects, so use 578 # our internal version which has a workaround. 579 # 580 AC_DEFINE(BROKEN_CMSG_FIRSTHDR) 581 AC_LIBOBJ(daemon) 582 AC_LIBOBJ(daemon-darwin) 583 ;; 584 *dragonfly*) 585 AC_MSG_RESULT(dragonfly) 586 PLATFORM=dragonfly 587 ;; 588 *linux*) 589 AC_MSG_RESULT(linux) 590 PLATFORM=linux 591 ;; 592 *freebsd*) 593 AC_MSG_RESULT(freebsd) 594 PLATFORM=freebsd 595 ;; 596 *netbsd*) 597 AC_MSG_RESULT(netbsd) 598 PLATFORM=netbsd 599 ;; 600 *openbsd*) 601 AC_MSG_RESULT(openbsd) 602 PLATFORM=openbsd 603 ;; 604 *sunos*) 605 AC_MSG_RESULT(sunos) 606 PLATFORM=sunos 607 ;; 608 *solaris*) 609 AC_MSG_RESULT(sunos) 610 PLATFORM=sunos 611 MANFORMAT=man 612 ;; 613 *hpux*) 614 AC_MSG_RESULT(hpux) 615 PLATFORM=hpux 616 ;; 617 *cygwin*) 618 AC_MSG_RESULT(cygwin) 619 PLATFORM=cygwin 620 ;; 621 *) 622 AC_MSG_RESULT(unknown) 623 PLATFORM=unknown 624 ;; 625esac 626AC_SUBST(PLATFORM) 627AM_CONDITIONAL(IS_AIX, test "x$PLATFORM" = xaix) 628AM_CONDITIONAL(IS_DARWIN, test "x$PLATFORM" = xdarwin) 629AM_CONDITIONAL(IS_DRAGONFLY, test "x$PLATFORM" = xdragonfly) 630AM_CONDITIONAL(IS_LINUX, test "x$PLATFORM" = xlinux) 631AM_CONDITIONAL(IS_FREEBSD, test "x$PLATFORM" = xfreebsd) 632AM_CONDITIONAL(IS_NETBSD, test "x$PLATFORM" = xnetbsd) 633AM_CONDITIONAL(IS_OPENBSD, test "x$PLATFORM" = xopenbsd) 634AM_CONDITIONAL(IS_SUNOS, test "x$PLATFORM" = xsunos) 635AM_CONDITIONAL(IS_HPUX, test "x$PLATFORM" = xhpux) 636AM_CONDITIONAL(IS_UNKNOWN, test "x$PLATFORM" = xunknown) 637 638# Save our CFLAGS/CPPFLAGS/LDFLAGS for the Makefile and restore the old user 639# variables. 640AC_SUBST(AM_CPPFLAGS) 641CPPFLAGS="$SAVED_CPPFLAGS" 642AC_SUBST(AM_CFLAGS) 643CFLAGS="$SAVED_CFLAGS" 644AC_SUBST(AM_LDFLAGS) 645LDFLAGS="$SAVED_LDFLAGS" 646 647# autoconf should create a Makefile. 648AC_OUTPUT(Makefile) 649