1dnl Process this file with autoconf to produce a configure script. 2dnl 3dnl $Id: configure.in,v 1.18 1994/09/06 16:59:54 mlschroe Exp $ FAU 4dnl 5dnl Many thanks to David MacKenzie for writing autoconf and 6dnl providing a sample configure.in file for screen. 7dnl 8AC_REVISION($Revision: 1.18 $)dnl 9AC_INIT(screen.c) 10AC_CONFIG_HEADER(config.h) 11 12dnl 13dnl Define some useful macros 14dnl 15AC_DEFUN(AC_PROGRAM_SOURCE, 16[AC_REQUIRE([AC_PROG_CPP])AC_PROVIDE([$0])cat > conftest.c <<EOF 17#include "confdefs.h" 18[$1] 19_CUT_HERE_ 20[$2] 21EOF 22eval "$ac_cpp conftest.c 2>&5 | sed -e '1,/_CUT_HERE_/d' -e 's/ //g' > conftest.out" 23. ./conftest.out 24rm -f conftest* 25])dnl 26dnl 27define(AC_NOTE, 28[echo "$1" 1>&AC_FD_MSG 29])dnl 30 31dnl 32dnl Extract version from patchlevel.h 33dnl 34rev=`sed < ${srcdir}/patchlevel.h -n -e '/#define REV/s/#define REV *//p'` 35vers=`sed < ${srcdir}/patchlevel.h -n -e '/#define VERS/s/#define VERS *//p'` 36pat=`sed < ${srcdir}/patchlevel.h -n -e '/#define PATCHLEVEL/s/#define PATCHLEVEL *//p'` 37VERSION="$rev.$vers.$pat" 38AC_NOTE(this is screen version $VERSION) 39AC_SUBST(VERSION) 40AC_PREFIX_PROGRAM(screen) 41AC_PREFIX_PROGRAM(gzip) 42 43old_CFLAGS="$CFLAGS" 44AC_PROG_CC 45AC_PROG_CPP 46AC_PROG_GCC_TRADITIONAL 47AC_ISC_POSIX 48 49AC_TRY_RUN(main(){exit(0);},,[ 50if test $CC != cc ; then 51AC_NOTE(Your $CC failed - restarting with CC=cc) 52AC_NOTE() 53CC=cc 54export CC 55exec $0 $configure_args 56fi 57]) 58 59AC_TRY_RUN(main(){exit(0);},, 60exec 5>&2 61eval $ac_link 62AC_NOTE(CC=$CC; CFLAGS=$CFLAGS; LIBS=$LIBS;) 63AC_NOTE($ac_compile) 64AC_MSG_ERROR(Can't run the compiler - sorry)) 65 66AC_TRY_RUN([ 67main() 68{ 69 int __something_strange_(); 70 __something_strange_(0); 71} 72],AC_MSG_ERROR(Your compiler does not set the exit status - sorry)) 73 74AC_PROG_AWK 75 76AC_PROG_INSTALL 77 78if test -f etc/toolcheck; then 79AC_CHECKING(for buggy tools) 80sh etc/toolcheck 1>&AC_FD_MSG 81fi 82 83 84 85dnl SOCKDIR 86AC_MSG_CHECKING(if a system-wide socket dir should be used) 87AC_ARG_ENABLE(socket-dir, 88 [ --disable-socket-dir disable system wide socket-dir and use ~/.screen instead], 89 [ 90 AC_MSG_RESULT(no. ~/.screen will be used instead.) 91 ], 92 [ 93 AC_MSG_RESULT(yes) 94 AC_MSG_CHECKING(for the socket dir) 95 SOCKDIR="(eff_uid ? \"/tmp/uscreens\" : \"/tmp/screens\")" 96 AC_ARG_WITH(socket-dir, [ --with-socket-dir=path where to put the per-user sockets], [ SOCKDIR="\"${withval}\"" ]) 97 AC_MSG_RESULT(${SOCKDIR}) 98 AC_DEFINE_UNQUOTED(SOCKDIR, $SOCKDIR) 99 ] 100) 101 102 103dnl 104dnl **** special unix variants **** 105dnl 106if test -n "$ISC"; then 107 AC_DEFINE(ISC) LIBS="$LIBS -linet" 108fi 109 110dnl AC_CHECKING(for OSF1) 111dnl if test -f /bin/uname ; then 112dnl if test `/bin/uname` = OSF1 || test -f /osf_boot; then 113dnl AC_DEFINE(OSF1) # this disables MIPS again.... 114dnl fi 115dnl fi 116 117if test -f /sysV68 ; then 118AC_DEFINE(sysV68) 119fi 120 121AC_CHECKING(for MIPS) 122if test -f /lib/libmld.a || test -f /usr/lib/libmld.a || test -f /usr/lib/cmplrs/cc/libmld.a; then 123oldlibs="$LIBS" 124test -f /bin/mx || LIBS="$LIBS -lmld" # for nlist. But not on alpha. 125dnl djm@eng.umd.edu: "... for one thing, it doubles the size of the executable" 126AC_CHECKING(mld library) 127AC_TRY_LINK(,,,LIBS="$oldlibs") 128dnl 129dnl 130if test -r /dev/ptc; then 131AC_DEFINE(MIPS) 132AC_CHECKING(wait3) 133AC_TRY_LINK(,[wait3();], , 134AC_CHECKING(wait2) 135AC_TRY_LINK(,[wait2();], 136dnl John Rouillard (rouilj@sni-usa.com): 137dnl need -I/usr/include/bsd in RISCOS otherwise sockets are broken, no 138dnl job control etc. 139dnl Detect RISCOS if wait2 is present, but not wait3. 140AC_DEFINE(USE_WAIT2) LIBS="$LIBS -lbsd" ; CC="$CC -I/usr/include/bsd" 141)) 142fi 143fi 144 145 146AC_CHECKING(for Ultrix) 147AC_EGREP_CPP(yes, 148[#if defined(ultrix) || defined(__ultrix) 149 yes; 150#endif 151], ULTRIX=1) 152 153if test -f /usr/lib/libpyr.a ; then 154oldlibs="$LIBS" 155LIBS="$LIBS -lpyr" 156AC_CHECKING(Pyramid OSX) 157AC_TRY_LINK(,[open_controlling_pty("")], AC_DEFINE(OSX), LIBS="$oldlibs") 158fi 159 160dnl ghazi@caip.rutgers.edu (Kaveh R. Ghazi): 161dnl BBN butterfly is not POSIX, but a MACH BSD system. 162dnl Do not define POSIX and TERMIO. 163AC_CHECKING(for butterfly) 164AC_EGREP_CPP(yes, 165[#if defined(butterfly) 166 yes; 167#endif 168], butterfly=1) 169 170if test -z "$butterfly"; then 171if test -n "$ULTRIX"; then 172 test -z "$GCC" && CC="$CC -YBSD" 173fi 174AC_CHECKING(for POSIX.1) 175AC_EGREP_CPP(yes, 176[#include <sys/types.h> 177#include <unistd.h> 178main () { 179#ifdef _POSIX_VERSION 180 yes; 181#endif 182], AC_NOTE(- you have a POSIX system) AC_DEFINE(POSIX) posix=1) 183fi 184 185AC_CHECKING(for System V) 186AC_TRY_COMPILE( 187[#include <sys/types.h> 188#include <signal.h> 189#include <fcntl.h>], [int x = SIGCHLD | FNDELAY;], , AC_DEFINE(SYSV)) 190 191AC_CHECKING(for sequent/ptx) 192AC_EGREP_CPP(yes, 193[#ifdef _SEQUENT_ 194 yes; 195#endif 196], LIBS="$LIBS -lsocket -linet";seqptx=1) 197 198oldlibs="$LIBS" 199LIBS="$LIBS -lelf" 200AC_CHECKING(SVR4) 201AC_TRY_LINK([#include <utmpx.h> 202],, 203[AC_CHECK_HEADER(dwarf.h, AC_DEFINE(SVR4) AC_DEFINE(BUGGYGETLOGIN), 204[AC_CHECK_HEADER(elf.h, AC_DEFINE(SVR4) AC_DEFINE(BUGGYGETLOGIN))])] 205,LIBS="$oldlibs") 206 207AC_CHECKING(for Solaris 2.x) 208AC_EGREP_CPP(yes, 209[#if defined(SVR4) && defined(sun) 210 yes 211#endif 212], LIBS="$LIBS -lsocket -lnsl -lkstat") 213 214dnl 215dnl **** typedefs **** 216dnl 217dnl (currently not used) 218dnl 219dnl AC_CHECKING(for pid_t) 220dnl AC_EGREP_CPP(pid_t,[#include <sys/types.h> 221dnl ],AC_DEFINE(PID_T_DEFINED)) 222dnl 223dnl AC_CHECKING(for sig_t) 224dnl AC_EGREP_CPP(sig_t,[#include <sys/types.h> 225dnl #include <signal.h> 226dnl ],AC_DEFINE(SIG_T_DEFINED)) 227dnl 228dnl AC_CHECKING(for uid_t) 229dnl AC_EGREP_CPP(uid_t,[#include <sys/types.h> 230dnl ],AC_DEFINE(UID_T_DEFINED)) 231dnl 232 233dnl 234dnl **** Job control **** 235dnl 236 237AC_CHECKING(BSD job jontrol) 238AC_TRY_LINK( 239[#include <sys/types.h> 240#include <sys/ioctl.h> 241], [ 242#ifdef POSIX 243tcsetpgrp(0, 0); 244#else 245int x = TIOCSPGRP; 246#ifdef SYSV 247setpgrp(); 248#else 249int y = TIOCNOTTY; 250#endif 251#endif 252], AC_NOTE(- you have jobcontrol) AC_DEFINE(BSDJOBS), AC_NOTE(- you don't have jobcontrol)) 253 254dnl 255dnl **** setreuid(), seteuid() **** 256dnl 257AC_CHECKING(setreuid) 258AC_TRY_LINK(,[ 259#ifdef __hpux 260setresuid(0, 0, 0); 261#else 262setreuid(0, 0); 263#endif 264], AC_DEFINE(HAVE_SETREUID)) 265dnl 266dnl seteuid() check: 267dnl linux seteuid was broken before V1.1.11 268dnl NeXT, AUX, ISC, and ultrix are still broken (no saved uid support) 269dnl Solaris seteuid doesn't change the saved uid, bad for 270dnl multiuser screen sessions 271AC_CHECKING(seteuid) 272AC_TRY_LINK(,[ 273#if defined(linux) || defined(NeXT) || defined(_AUX_SOURCE) || defined(AUX) || defined(ultrix) || (defined(sun) && defined(SVR4)) || defined(ISC) || defined(sony_news) 274seteuid_is_broken(0); 275#else 276seteuid(0); 277#endif 278], AC_DEFINE(HAVE_SETEUID)) 279 280dnl 281dnl **** select() **** 282dnl 283 284AC_CHECKING(select) 285AC_TRY_LINK(,[select(0, 0, 0, 0, 0);],, 286LIBS="$LIBS -lnet -lnsl" 287AC_CHECKING(select with $LIBS) 288AC_TRY_LINK(,[select(0, 0, 0, 0, 0);],, 289AC_MSG_ERROR(!!! no select - no screen)) 290) 291dnl 292dnl **** FIFO tests **** 293dnl 294 295AC_CHECKING(fifos) 296AC_TRY_RUN([ 297#include <sys/types.h> 298#include <sys/stat.h> 299#include <fcntl.h> 300 301#ifndef O_NONBLOCK 302#define O_NONBLOCK O_NDELAY 303#endif 304#ifndef S_IFIFO 305#define S_IFIFO 0010000 306#endif 307 308char *fin = "/tmp/conftest$$"; 309 310main() 311{ 312 struct stat stb; 313#ifdef FD_SET 314 fd_set f; 315#else 316 int f; 317#endif 318 319 (void)alarm(5); 320#ifdef POSIX 321 if (mkfifo(fin, 0777)) 322#else 323 if (mknod(fin, S_IFIFO|0777, 0)) 324#endif 325 exit(1); 326 if (stat(fin, &stb) || (stb.st_mode & S_IFIFO) != S_IFIFO) 327 exit(1); 328 close(0); 329#ifdef __386BSD__ 330 /* 331 * The next test fails under 386BSD, but screen works using fifos. 332 * Fifos in O_RDWR mode are only used for the BROKEN_PIPE case and for 333 * the select() configuration test. 334 */ 335 exit(0); 336#endif 337 if (open(fin, O_RDONLY | O_NONBLOCK)) 338 exit(1); 339 if (fork() == 0) 340 { 341 close(0); 342 if (open(fin, O_WRONLY | O_NONBLOCK)) 343 exit(1); 344 close(0); 345 if (open(fin, O_WRONLY | O_NONBLOCK)) 346 exit(1); 347 if (write(0, "TEST", 4) == -1) 348 exit(1); 349 exit(0); 350 } 351#ifdef FD_SET 352 FD_SET(0, &f); 353#else 354 f = 1; 355#endif 356 if (select(1, &f, 0, 0, 0) == -1) 357 exit(1); 358 exit(0); 359} 360], AC_NOTE(- your fifos are usable) fifo=1, 361AC_NOTE(- your fifos are not usable)) 362rm -f /tmp/conftest* 363 364if test -n "$fifo"; then 365AC_CHECKING(for broken fifo implementation) 366AC_TRY_RUN([ 367#include <sys/types.h> 368#include <fcntl.h> 369#include <sys/time.h> 370#include <sys/stat.h> 371 372#ifndef O_NONBLOCK 373#define O_NONBLOCK O_NDELAY 374#endif 375#ifndef S_IFIFO 376#define S_IFIFO 0010000 377#endif 378 379char *fin = "/tmp/conftest$$"; 380 381main() 382{ 383 struct timeval tv; 384#ifdef FD_SET 385 fd_set f; 386#else 387 int f; 388#endif 389 390#ifdef POSIX 391 if (mkfifo(fin, 0600)) 392#else 393 if (mknod(fin, S_IFIFO|0600, 0)) 394#endif 395 exit(1); 396 close(0); 397 if (open(fin, O_RDONLY|O_NONBLOCK)) 398 exit(1); 399#ifdef FD_SET 400 FD_SET(0, &f); 401#else 402 f = 1; 403#endif 404 tv.tv_sec = 1; 405 tv.tv_usec = 0; 406 if (select(1, &f, 0, 0, &tv)) 407 exit(1); 408 exit(0); 409} 410], AC_NOTE(- your implementation is ok), 411AC_NOTE(- you have a broken implementation) AC_DEFINE(BROKEN_PIPE) fifobr=1) 412rm -f /tmp/conftest* 413fi 414 415dnl 416dnl **** SOCKET tests **** 417dnl 418dnl may need LIBS="$LIBS -lsocket" here 419dnl 420 421AC_CHECKING(sockets) 422AC_TRY_RUN([ 423#include <sys/types.h> 424#include <sys/socket.h> 425#include <sys/un.h> 426#include <fcntl.h> 427 428char *son = "/tmp/conftest$$"; 429 430main() 431{ 432 int s1, s2, l; 433 struct sockaddr_un a; 434#ifdef FD_SET 435 fd_set f; 436#else 437 int f; 438#endif 439 440 (void)alarm(5); 441 if ((s1 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) 442 exit(1); 443 a.sun_family = AF_UNIX; 444 strcpy(a.sun_path, son); 445 (void) unlink(son); 446 if (bind(s1, (struct sockaddr *) &a, strlen(son)+2) == -1) 447 exit(1); 448 if (listen(s1, 2)) 449 exit(1); 450 if (fork() == 0) 451 { 452 if ((s2 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) 453 kill(getppid(), 3); 454 (void)connect(s2, (struct sockaddr *)&a, strlen(son) + 2); 455 if (write(s2, "HELLO", 5) == -1) 456 kill(getppid(), 3); 457 exit(0); 458 } 459 l = sizeof(a); 460 close(0); 461 if (accept(s1, &a, &l)) 462 exit(1); 463#ifdef FD_SET 464 FD_SET(0, &f); 465#else 466 f = 1; 467#endif 468 if (select(1, &f, 0, 0, 0) == -1) 469 exit(1); 470 exit(0); 471} 472], AC_NOTE(- your sockets are usable) sock=1, 473AC_NOTE(- your sockets are not usable)) 474rm -f /tmp/conftest* 475 476if test -n "$sock"; then 477AC_CHECKING(socket implementation) 478AC_TRY_RUN([ 479#include <sys/types.h> 480#include <sys/stat.h> 481#include <sys/socket.h> 482#include <sys/un.h> 483 484char *son = "/tmp/conftest$$"; 485 486main() 487{ 488 int s; 489 struct stat stb; 490 struct sockaddr_un a; 491 if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) 492 exit(0); 493 a.sun_family = AF_UNIX; 494 strcpy(a.sun_path, son); 495 (void) unlink(son); 496 if (bind(s, (struct sockaddr *) &a, strlen(son)+2) == -1) 497 exit(0); 498 if (stat(son, &stb)) 499 exit(1); 500 close(s); 501 exit(0); 502} 503],AC_NOTE(- you are normal), 504AC_NOTE(- unix domain sockets are not kept in the filesystem) 505AC_DEFINE(SOCK_NOT_IN_FS) socknofs=1) 506rm -f /tmp/conftest* 507fi 508 509 510dnl 511dnl **** choose sockets or fifos **** 512dnl 513if test -n "$fifo"; then 514 if test -n "$sock"; then 515 if test -n "$nore"; then 516 AC_NOTE(- hmmm... better take the fifos) 517 AC_DEFINE(NAMEDPIPE) 518 elif test -n "$fifobr"; then 519 AC_NOTE(- as your fifos are broken lets use the sockets.) 520 else 521 AC_NOTE(- both sockets and fifos usable. let's take fifos.) 522 AC_DEFINE(NAMEDPIPE) 523 fi 524 else 525 AC_NOTE(- using named pipes, of course) 526 AC_DEFINE(NAMEDPIPE) 527 fi 528elif test -n "$sock"; then 529 AC_NOTE(- using unix-domain sockets, of course) 530else 531 AC_MSG_ERROR(you have neither usable sockets nor usable pipes -> no screen) 532fi 533 534dnl 535dnl **** check the select implementation **** 536dnl 537 538AC_CHECKING(select return value) 539AC_TRY_RUN([ 540#include <sys/types.h> 541#include <sys/stat.h> 542#include <fcntl.h> 543 544char *nam = "/tmp/conftest$$"; 545 546#ifdef NAMEDPIPE 547 548#ifndef O_NONBLOCK 549#define O_NONBLOCK O_NDELAY 550#endif 551#ifndef S_IFIFO 552#define S_IFIFO 0010000 553#endif 554 555 556main() 557{ 558#ifdef FD_SET 559 fd_set f; 560#else 561 int f; 562#endif 563 564#ifdef __FreeBSD__ 565/* From Andrew A. Chernov (ache@astral.msk.su): 566 * opening RDWR fifo fails in BSD 4.4, but select return values are 567 * right. 568 */ 569 exit(0); 570#endif 571 (void)alarm(5); 572#ifdef POSIX 573 if (mkfifo(nam, 0777)) 574#else 575 if (mknod(nam, S_IFIFO|0777, 0)) 576#endif 577 exit(1); 578 close(0); 579 if (open(nam, O_RDWR | O_NONBLOCK)) 580 exit(1); 581 if (write(0, "TEST", 4) == -1) 582 exit(1); 583 584#else 585 586#include <sys/types.h> 587#include <sys/socket.h> 588#include <sys/un.h> 589 590main() 591{ 592 int s1, s2, l; 593 struct sockaddr_un a; 594#ifdef FD_SET 595 fd_set f; 596#else 597 int f; 598#endif 599 600 (void)alarm(5); 601 if ((s1 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) 602 exit(1); 603 a.sun_family = AF_UNIX; 604 strcpy(a.sun_path, nam); 605 (void) unlink(nam); 606 if (bind(s1, (struct sockaddr *) &a, strlen(nam)+2) == -1) 607 exit(1); 608 if (listen(s1, 2)) 609 exit(1); 610 if (fork() == 0) 611 { 612 if ((s2 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) 613 kill(getppid(), 3); 614 (void)connect(s2, (struct sockaddr *)&a, strlen(nam) + 2); 615 if (write(s2, "HELLO", 5) == -1) 616 kill(getppid(), 3); 617 exit(0); 618 } 619 l = sizeof(a); 620 close(0); 621 if (accept(s1, (struct sockaddr *)&a, &l)) 622 exit(1); 623#endif 624 625 626#ifdef FD_SET 627 FD_SET(0, &f); 628#else 629 f = 1; 630#endif 631 if (select(1, &f, 0, 0, 0) == -1) 632 exit(1); 633 if (select(1, &f, &f, 0, 0) != 2) 634 exit(1); 635 exit(0); 636} 637],AC_NOTE(- select is ok), 638AC_NOTE(- select can't count) AC_DEFINE(SELECT_BROKEN)) 639 640dnl 641dnl **** termcap or terminfo **** 642dnl 643AC_CHECKING(for tgetent) 644AC_TRY_LINK(,tgetent((char *)0, (char *)0);,, 645olibs="$LIBS" 646LIBS="-lcurses $olibs" 647AC_CHECKING(libcurses) 648AC_TRY_LINK(,[ 649#ifdef __hpux 650__sorry_hpux_libcurses_is_totally_broken_in_10_10(); 651#else 652tgetent((char *)0, (char *)0); 653#endif 654],, 655LIBS="-ltermcap $olibs" 656AC_CHECKING(libtermcap) 657AC_TRY_LINK(,tgetent((char *)0, (char *)0);,, 658LIBS="-ltermlib $olibs" 659AC_CHECKING(libtermlib) 660AC_TRY_LINK(,tgetent((char *)0, (char *)0);,, 661LIBS="-lncurses $olibs" 662AC_CHECKING(libncurses) 663AC_TRY_LINK(,tgetent((char *)0, (char *)0);,, 664AC_MSG_ERROR(!!! no tgetent - no screen)))))) 665 666AC_TRY_RUN([ 667main() 668{ 669 exit(strcmp(tgoto("%p1%d", 0, 1), "1") ? 0 : 1); 670}], AC_NOTE(- you use the termcap database), 671AC_NOTE(- you use the terminfo database) AC_DEFINE(TERMINFO)) 672AC_CHECKING(ospeed) 673AC_TRY_LINK(extern short ospeed;,ospeed=5;,,AC_DEFINE(NEED_OSPEED)) 674 675dnl 676dnl **** PTY specific things **** 677dnl 678AC_CHECKING(for /dev/ptc) 679if test -r /dev/ptc; then 680AC_DEFINE(HAVE_DEV_PTC) 681fi 682 683AC_CHECKING(for SVR4 ptys) 684sysvr4ptys= 685if test -c /dev/ptmx ; then 686AC_TRY_LINK([],[ptsname(0);grantpt(0);unlockpt(0);],[AC_DEFINE(HAVE_SVR4_PTYS) 687sysvr4ptys=1]) 688fi 689 690AC_CHECK_FUNCS(getpt) 691 692dnl check for openpty() 693if test -z "$sysvr4ptys"; then 694AC_CHECK_FUNCS(openpty,, 695[AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY)] [LIBS="$LIBS -lutil"])]) 696fi 697 698AC_CHECKING(for ptyranges) 699if test -d /dev/ptym ; then 700pdir='/dev/ptym' 701else 702pdir='/dev' 703fi 704dnl SCO uses ptyp%d 705AC_EGREP_CPP(yes, 706[#ifdef M_UNIX 707 yes; 708#endif 709], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`) 710dnl if test -c /dev/ptyp19; then 711dnl ptys=`echo /dev/ptyp??` 712dnl else 713dnl ptys=`echo $pdir/pty??` 714dnl fi 715if test "$ptys" != "$pdir/pty??" ; then 716p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'` 717p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'` 718AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0") 719AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1") 720fi 721 722dnl **** pty mode/group handling **** 723dnl 724dnl support provided by Luke Mewburn <lm@rmit.edu.au>, 931222 725AC_ARG_WITH(pty-mode, [ --with-pty-mode=mode default mode for ptys], [ ptymode="${withval}" ]) 726AC_ARG_WITH(pty-group, [ --with-pty-group=group default group for ptys], [ ptygrp="${withval}" ]) 727test -n "$ptymode" || ptymode=0620 728if test -n "$ptygrp" ; then 729AC_DEFINE_UNQUOTED(PTYMODE, $ptymode) 730AC_DEFINE_UNQUOTED(PTYGROUP,$ptygrp) 731else 732 733AC_CHECKING(default tty permissions/group) 734rm -f conftest_grp 735AC_TRY_RUN([ 736#include <sys/types.h> 737#include <sys/stat.h> 738#include <stdio.h> 739main() 740{ 741 struct stat sb; 742 char *x,*ttyname(); 743 int om, m; 744 FILE *fp; 745 746 if (!(x = ttyname(0))) exit(1); 747 if (stat(x, &sb)) exit(1); 748 om = sb.st_mode; 749 if (om & 002) exit(0); 750 m = system("mesg y"); 751 if (m == -1 || m == 127) exit(1); 752 if (stat(x, &sb)) exit(1); 753 m = sb.st_mode; 754 if (chmod(x, om)) exit(1); 755 if (m & 002) exit(0); 756 if (sb.st_gid == getgid()) exit(1); 757 if (!(fp=fopen("conftest_grp", "w"))) 758 exit(1); 759 fprintf(fp, "%d\n", sb.st_gid); 760 fclose(fp); 761 exit(0); 762} 763],[ 764 if test -f conftest_grp; then 765 ptygrp=`cat conftest_grp` 766 AC_NOTE([- pty mode: $ptymode, group: $ptygrp]) 767 AC_DEFINE_UNQUOTED(PTYMODE, $ptymode) 768 AC_DEFINE_UNQUOTED(PTYGROUP,$ptygrp) 769 else 770 AC_NOTE(- ptys are world accessable) 771 fi 772],[ 773 WRITEPATH='' 774 XTERMPATH='' 775 AC_PATH_PROG(WRITEPATH, write) 776 AC_PATH_PROG(XTERMPATH, xterm) 777 found= 778 if test -n "$WRITEPATH$XTERMPATH"; then 779 findfollow= 780 lsfollow= 781 found=`find $WRITEPATH $XTERMPATH -follow -print 2>/dev/null` 782 if test -n "$found"; then 783 findfollow=-follow 784 lsfollow=L 785 fi 786 if test -n "$XTERMPATH"; then 787 ptygrpn=`ls -l$lsfollow $XTERMPATH | sed -n -e 1p | $AWK '{print $4}'` 788 if test tty != "$ptygrpn"; then 789 XTERMPATH= 790 fi 791 fi 792 fi 793 if test -n "$WRITEPATH$XTERMPATH"; then 794 found=`find $WRITEPATH $XTERMPATH $findfollow -perm -2000 -print` 795 if test -n "$found"; then 796 ptygrp=`ls -ln$lsfollow $found | sed -n -e 1p | $AWK '{print $4}'` 797 AC_NOTE([- pty mode: $ptymode, group: $ptygrp]) 798 AC_DEFINE_UNQUOTED(PTYMODE, $ptymode) 799 AC_DEFINE_UNQUOTED(PTYGROUP,$ptygrp) 800 else 801 AC_NOTE(- ptys are world accessable) 802 fi 803 else 804 AC_NOTE(- can't determine - assume ptys are world accessable) 805 fi 806 ] 807) 808rm -f conftest_grp 809fi 810 811dnl 812dnl **** utmp handling **** 813dnl 814AC_CHECKING(getutent) 815AC_TRY_LINK([ 816#include <time.h> /* to get time_t on SCO */ 817#include <sys/types.h> 818#if defined(SVR4) && !defined(DGUX) 819#include <utmpx.h> 820#define utmp utmpx 821#else 822#include <utmp.h> 823#endif 824#ifdef __hpux 825#define pututline _pututline 826#endif 827], 828[int x = DEAD_PROCESS; pututline((struct utmp *)0); getutent();], AC_DEFINE(GETUTENT), 829olibs="$LIBS" 830LIBS="$LIBS -lgen" 831AC_CHECKING(getutent with -lgen) 832AC_TRY_LINK([ 833#include <time.h> 834#include <sys/types.h> 835#if defined(SVR4) && !defined(DGUX) 836#include <utmpx.h> 837#define utmp utmpx 838#else 839#include <utmp.h> 840#endif 841#ifdef __hpux 842#define pututline _pututline 843#endif 844], 845[int x = DEAD_PROCESS; pututline((struct utmp *)0); getutent();], AC_DEFINE(GETUTENT), LIBS="$olibs") 846) 847AC_CHECKING(ut_host) 848AC_TRY_COMPILE([ 849#include <time.h> 850#include <sys/types.h> 851#if defined(SVR4) && !defined(DGUX) 852#include <utmpx.h> 853#define utmp utmpx 854#else 855#include <utmp.h> 856#endif 857],[struct utmp u; u.ut_host[0] = 0;], AC_DEFINE(UTHOST)) 858AC_CHECK_HEADER(utempter.h, have_utempter=yes, have_utempter=no) 859if test "$have_utempter" = yes; then 860 AC_DEFINE(HAVE_UTEMPTER) 861 LIBS="$LIBS -lutempter" 862fi 863 864dnl 865dnl **** loadav **** 866dnl 867AC_CHECKING(for libutil(s)) 868test -f /usr/lib/libutils.a && LIBS="$LIBS -lutils" 869test -f /usr/lib/libutil.a && LIBS="$LIBS -lutil" 870 871AC_CHECKING(getloadavg) 872AC_TRY_LINK(,[getloadavg((double *)0, 0);], 873AC_DEFINE(LOADAV_GETLOADAVG) load=1, 874if test -f /usr/lib/libkvm.a ; then 875olibs="$LIBS" 876LIBS="$LIBS -lkvm" 877AC_CHECKING(getloadavg with -lkvm) 878AC_TRY_LINK(,[getloadavg((double *)0, 0);], 879AC_DEFINE(LOADAV_GETLOADAVG) load=1, LIBS="$olibs") 880fi 881) 882 883if test -z "$load" ; then 884AC_EGREP_CPP(yes, 885[#if defined(NeXT) || defined(apollo) || defined(linux) 886 yes; 887#endif 888], load=1) 889fi 890if test -z "$load" ; then 891AC_CHECKING(for kernelfile) 892for core in /unix /vmunix /dynix /hp-ux /xelos /dev/ksyms /kernel/unix /kernel/genunix /unicos /mach /netbsd /386bsd /dgux /bsd /stand/vmunix; do 893 if test -f $core || test -c $core; then 894 break 895 fi 896done 897if test ! -f $core && test ! -c $core ; then 898 AC_NOTE(- no kernelfile found) 899else 900 AC_NOTE(- using kernelfile '$core') 901 if test -r $core ; then 902 AC_DEFINE_UNQUOTED(LOADAV_UNIX,"$core") 903 AC_CHECK_HEADER(nlist.h, 904 [AC_DEFINE(NLIST_STRUCT) 905 AC_CHECKING(n_un in struct nlist) 906 AC_TRY_COMPILE([#include <nlist.h>], 907 [struct nlist n; n.n_un.n_name = 0;], 908 AC_DEFINE(NLIST_NAME_UNION))]) 909 910 AC_CHECKING(for nlist declaration) 911 AC_EGREP_CPP([nlist(( | )( | )*.*\(|\()],[ 912#ifdef NLIST_STRUCT 913# include <nlist.h> 914#else 915# include <a.out.h> 916#endif 917],AC_DEFINE(NLIST_DECLARED)) 918 919 AC_CHECKING(for avenrun symbol) 920 nlist64= 921 for av in avenrun _avenrun _Loadavg avenrun _avenrun _Loadavg; do 922 AC_TRY_RUN([ 923#include <sys/types.h> 924#ifdef NLIST_STRUCT 925#include <nlist.h> 926#else 927#include <a.out.h> 928#endif 929 930$nlist64 931 932struct nlist nl[2]; 933 934main() 935{ 936#if !defined(_AUX_SOURCE) && !defined(AUX) 937# ifdef NLIST_NAME_UNION 938 nl[0].n_un.n_name = "$av"; 939# else 940 nl[0].n_name = "$av"; 941# endif 942#else 943 strncpy(nl[0].n_name, "$av", sizeof(nl[0].n_name)); 944#endif 945 nlist(LOADAV_UNIX, nl); 946 if (nl[0].n_value == 0) 947 exit(1); 948 exit(0); 949} 950 ],avensym=$av;break) 951 if test "$av" = _Loadavg; then 952 nlist64='#define nlist nlist64' 953 fi 954 done 955 if test -z "$avensym" ; then 956 AC_NOTE(- no avenrun symbol found) 957 else 958 AC_NOTE(- using avenrun symbol '$avensym') 959 AC_DEFINE_UNQUOTED(LOADAV_AVENRUN,"$avensym") 960 if test -n "$nlist64"; then 961 AC_NOTE(- used nlist64 to find it) 962 AC_DEFINE(LOADAV_USE_NLIST64) 963 fi 964 load=1 965 fi 966 else 967 AC_NOTE( Can't configure the load average display feature) 968 AC_NOTE( because $core is not readable by you.) 969 AC_NOTE( To configure the load average display feature,) 970 AC_NOTE( re-run configure as root if possible.) 971 AC_NOTE( If you are not the system administrator then disregard) 972 AC_NOTE( this warning. You can still use screen without) 973 AC_NOTE( the load average display feature.) 974 fi 975fi 976fi 977 978AC_PROGRAM_SOURCE([ 979#include <sys/types.h> 980#include <sys/param.h> 981],[ 982#if !defined(LOADAV_GETLOADAVG) && ((defined(hp300) && !defined(__hpux)) || defined(sun) || (defined(ultrix) && defined(mips)) || defined(_SEQUENT_) || defined(sgi) || (defined(SVR4) && !defined(__hpux)) || defined(sony_news) || (!defined(__osf__) && defined(__alpha)) || defined(_IBMR2) || defined(_AUX_SOURCE) || defined(AUX) || defined(m88k)) 983loadtype=long 984# if defined(apollo) || defined(_IBMR2) || defined(_AUX_SOURCE) || defined(AUX) 985loadscale=65536 986# else 987# if defined(FSCALE) && !defined(__osf__) 988# undef FSCALE 989loadscale=FSCALE 990# else 991# ifdef sgi 992loadtype=int 993loadscale=1024 994# else 995# if defined(MIPS) || defined(SVR4) || defined(m88k) 996loadscale=256 997# else /* not MIPS */ 998loadscale=1000 /* our default value */ 999# endif /* MIPS */ 1000# endif /* sgi */ 1001# endif /* not FSCALE */ 1002# endif /* not apollo */ 1003#else 1004loadtype=double 1005loadscale=1 1006#endif 1007#ifdef alliant 1008loadnum=4 1009#else 1010loadnum=3 1011#endif 1012]) 1013 1014if test -n "$load" ; then AC_DEFINE(LOADAV) fi 1015if test -n "$loadtype" ; then AC_DEFINE_UNQUOTED(LOADAV_TYPE,$loadtype) fi 1016if test -n "$loadnum" ; then AC_DEFINE_UNQUOTED(LOADAV_NUM,$loadnum) fi 1017if test -n "$loadscale" ; then AC_DEFINE_UNQUOTED(LOADAV_SCALE,$loadscale) fi 1018 1019dnl 1020dnl **** signal handling **** 1021dnl 1022if test -n "$posix" ; then 1023 1024dnl POSIX has reliable signals with void return type. 1025AC_NOTE(assuming posix signal definition) 1026AC_DEFINE(SIGVOID) 1027 1028else 1029 1030AC_CHECKING(return type of signal handlers) 1031AC_TRY_COMPILE( 1032[#include <sys/types.h> 1033#include <signal.h> 1034#ifdef signal 1035#undef signal 1036#endif 1037extern void (*signal ()) ();], [int i;], AC_DEFINE(SIGVOID)) 1038AC_CHECKING(sigset) 1039AC_TRY_LINK([ 1040#include <sys/types.h> 1041#include <signal.h> 1042],[ 1043#ifdef SIGVOID 1044sigset(0, (void (*)())0); 1045#else 1046sigset(0, (int (*)())0); 1047#endif 1048], AC_DEFINE(USESIGSET)) 1049AC_CHECKING(signal implementation) 1050AC_TRY_RUN([ 1051#include <sys/types.h> 1052#include <signal.h> 1053 1054#ifndef SIGCLD 1055#define SIGCLD SIGCHLD 1056#endif 1057#ifdef USESIGSET 1058#define signal sigset 1059#endif 1060 1061int got; 1062 1063#ifdef SIGVOID 1064void 1065#endif 1066hand() 1067{ 1068 got++; 1069} 1070 1071main() 1072{ 1073 /* on hpux we use sigvec to get bsd signals */ 1074#ifdef __hpux 1075 (void)signal(SIGCLD, hand); 1076 kill(getpid(), SIGCLD); 1077 kill(getpid(), SIGCLD); 1078 if (got < 2) 1079 exit(1); 1080#endif 1081 exit(0); 1082} 1083],,AC_DEFINE(SYSVSIGS)) 1084 1085fi 1086 1087dnl 1088dnl **** libraries **** 1089dnl 1090 1091AC_CHECKING(for crypt and sec libraries) 1092test -f /lib/libcrypt_d.a || test -f /usr/lib/libcrypt_d.a && LIBS="$LIBS -lcrypt_d" 1093oldlibs="$LIBS" 1094LIBS="$LIBS -lcrypt" 1095AC_CHECKING(crypt) 1096AC_TRY_LINK(,,,LIBS="$oldlibs") 1097test -f /lib/libsec.a || test -f /usr/lib/libsec.a && LIBS="$LIBS -lsec" 1098test -f /lib/libshadow.a || test -f /usr/lib/libshadow.a && LIBS="$LIBS -lshadow" 1099oldlibs="$LIBS" 1100LIBS="$LIBS -lsun" 1101AC_CHECKING(IRIX sun library) 1102AC_TRY_LINK(,,,LIBS="$oldlibs") 1103 1104AC_CHECKING(syslog) 1105AC_TRY_LINK(,[closelog();], , [oldlibs="$LIBS" 1106LIBS="$LIBS -lbsd" 1107AC_CHECKING(syslog in libbsd.a) 1108AC_TRY_LINK(, [closelog();], AC_NOTE(- found.), [LIBS="$oldlibs" 1109AC_NOTE(- bad news: syslog missing.) AC_DEFINE(NOSYSLOG)])]) 1110 1111AC_EGREP_CPP(yes, 1112[#ifdef M_UNIX 1113 yes; 1114#endif 1115], LIBS="$LIBS -lsocket -lcrypt_i") 1116 1117dnl 1118dnl **** misc things **** 1119dnl 1120AC_CHECKING(wait union) 1121AC_TRY_COMPILE([#include <sys/types.h> 1122#include <sys/wait.h> 1123],[ 1124 union wait x; 1125 int y; 1126#ifdef WEXITSTATUS 1127 y = WEXITSTATUS(x); 1128#endif 1129],AC_DEFINE(BSDWAIT)) 1130 1131if test -z "$butterfly"; then 1132AC_CHECKING(for termio or termios) 1133AC_TRY_CPP([#include <termio.h>], AC_DEFINE(TERMIO), 1134if test -n "$posix"; then 1135AC_TRY_CPP([#include <termios.h>], AC_DEFINE(TERMIO)) 1136fi 1137) 1138fi 1139 1140dnl AC_CHECK_HEADER(shadow.h, AC_DEFINE(SHADOWPW)) 1141AC_CHECKING(getspnam) 1142AC_TRY_LINK([#include <shadow.h>], [getspnam("x");],AC_DEFINE(SHADOWPW)) 1143 1144AC_CHECKING(getttyent) 1145AC_TRY_LINK(,[getttyent();], AC_DEFINE(GETTTYENT)) 1146 1147AC_CHECKING(fdwalk) 1148AC_TRY_LINK([#include <stdlib.h>], [fdwalk(NULL, NULL);],AC_DEFINE(HAVE_FDWALK)) 1149 1150AC_CHECKING(whether memcpy/memmove/bcopy handles overlapping arguments) 1151AC_TRY_RUN([ 1152main() { 1153 char buf[10]; 1154 strcpy(buf, "abcdefghi"); 1155 bcopy(buf, buf + 2, 3); 1156 if (strncmp(buf, "ababcf", 6)) 1157 exit(1); 1158 strcpy(buf, "abcdefghi"); 1159 bcopy(buf + 2, buf, 3); 1160 if (strncmp(buf, "cdedef", 6)) 1161 exit(1); 1162 exit(0); /* libc version works properly. */ 1163}], AC_DEFINE(USEBCOPY)) 1164 1165AC_TRY_RUN([ 1166#define bcopy(s,d,l) memmove(d,s,l) 1167main() { 1168 char buf[10]; 1169 strcpy(buf, "abcdefghi"); 1170 bcopy(buf, buf + 2, 3); 1171 if (strncmp(buf, "ababcf", 6)) 1172 exit(1); 1173 strcpy(buf, "abcdefghi"); 1174 bcopy(buf + 2, buf, 3); 1175 if (strncmp(buf, "cdedef", 6)) 1176 exit(1); 1177 exit(0); /* libc version works properly. */ 1178}], AC_DEFINE(USEMEMMOVE)) 1179 1180 1181AC_TRY_RUN([ 1182#define bcopy(s,d,l) memcpy(d,s,l) 1183main() { 1184 char buf[10]; 1185 strcpy(buf, "abcdefghi"); 1186 bcopy(buf, buf + 2, 3); 1187 if (strncmp(buf, "ababcf", 6)) 1188 exit(1); 1189 strcpy(buf, "abcdefghi"); 1190 bcopy(buf + 2, buf, 3); 1191 if (strncmp(buf, "cdedef", 6)) 1192 exit(1); 1193 exit(0); /* libc version works properly. */ 1194}], AC_DEFINE(USEMEMCPY)) 1195 1196AC_MSG_CHECKING(long file names) 1197(echo 1 > /tmp/conftest9012345) 2>/dev/null 1198(echo 2 > /tmp/conftest9012346) 2>/dev/null 1199val=`cat /tmp/conftest9012345 2>/dev/null` 1200if test -f /tmp/conftest9012345 && test "$val" = 1; then 1201AC_MSG_RESULT(yes) 1202else 1203AC_MSG_RESULT(no) 1204AC_DEFINE(NAME_MAX, 14) 1205fi 1206rm -f /tmp/conftest* 1207 1208AC_MSG_CHECKING(for vsprintf) 1209AC_TRY_LINK(,[vsprintf(0,0,0);], AC_MSG_RESULT(yes);AC_DEFINE(USEVARARGS), AC_MSG_RESULT(no)) 1210 1211AC_HEADER_DIRENT 1212 1213AC_MSG_CHECKING(for setenv) 1214AC_TRY_LINK(,[setenv((char *)0,(char *)0);unsetenv((char *)0);], AC_MSG_RESULT(yes);AC_DEFINE(USESETENV), 1215AC_MSG_RESULT(no) 1216AC_MSG_CHECKING(for putenv) 1217AC_TRY_LINK(,[putenv((char *)0);unsetenv((char *)0);], AC_MSG_RESULT(yes) , AC_MSG_RESULT(no);AC_DEFINE(NEEDPUTENV) 1218)) 1219AC_MSG_CHECKING([for nl_langinfo(CODESET)]) 1220AC_TRY_LINK([ 1221#include <langinfo.h> 1222],[nl_langinfo(CODESET);], AC_MSG_RESULT(yes);AC_DEFINE(HAVE_NL_LANGINFO), AC_MSG_RESULT(no)) 1223 1224AC_SEARCH_LIBS(gethostname, nsl) 1225 1226AC_CHECK_FUNCS(rename fchmod fchown strerror lstat _exit utimes vsnprintf getcwd setlocale strftime) 1227 1228AC_ARG_ENABLE(pam, [ --enable-pam enable PAM support]) 1229if test "$enable_pam" = "yes"; then 1230 AC_MSG_CHECKING(for PAM support) 1231 oldlibs="$LIBS" 1232 LIBS="$LIBS -lpam" 1233 AC_TRY_LINK([#include <security/pam_appl.h>], [ 1234 pam_start(0, 0, 0, 0); 1235 pam_authenticate(0, 0); 1236 pam_end(0,0); 1237 ], AC_MSG_RESULT(yes);AC_DEFINE(USE_PAM), 1238 AC_MSG_RESULT(no);LIBS="$oldlibs") 1239fi 1240 1241AC_ARG_ENABLE(use_locale, [ --enable-locale use localized month/day names]) 1242if test "$enable_use_locale" = "yes"; then 1243 AC_DEFINE(USE_LOCALE) 1244fi 1245AC_ARG_ENABLE(telnet, [ --enable-telnet enable builtin telnet]) 1246if test "$enable_telnet" = "yes"; then 1247 AC_DEFINE(BUILTIN_TELNET) 1248fi 1249AC_ARG_ENABLE(colors256, [ --enable-colors256 enable support for 256 colors]) 1250if test "$enable_colors256" = "yes"; then 1251 AC_DEFINE(COLORS256) 1252fi 1253AC_ARG_ENABLE(rxvt_osc, [ --enable-rxvt_osc enable support for rxvt OSC codes]) 1254if test "$enable_rxvt_osc" = "yes"; then 1255 AC_DEFINE(RXVT_OSC) 1256fi 1257 1258dnl 1259dnl **** the end **** 1260dnl 1261if test -z "$old_CFLAGS"; then 1262 if test "x$CFLAGS" = "x-g"; then 1263 CFLAGS="-O" 1264 fi 1265fi 1266dnl Ptx bug workaround -- insert -lc after -ltermcap 1267test -n "$seqptx" && LIBS="-ltermcap -lc -lsocket -linet -lnsl -lsec -lseq" 1268 1269AC_TRY_RUN(main(){exit(0);},,AC_MSG_ERROR(Can't run the compiler - internal error. Sorry.)) 1270 1271ETCSCREENRC="\"/usr/local/etc/screenrc\"" 1272if test -n "$prefix"; then 1273ETCSCREENRC="\"$prefix/etc/screenrc\"" 1274fi 1275AC_MSG_CHECKING(for the global screenrc file) 1276AC_ARG_WITH(sys-screenrc, [ --with-sys-screenrc=path where to put the global screenrc file], [ ETCSCREENRC="\"${withval}\"" ]) 1277AC_DEFINE_UNQUOTED(ETCSCREENRC,$ETCSCREENRC) 1278AC_MSG_RESULT($ETCSCREENRC) 1279 1280SCREENENCODINGS="\"/usr/local/lib/screen/utf8encodings\"" 1281if test -n "$datadir"; then 1282eval SCREENENCODINGS="$datadir/screen/utf8encodings" 1283SCREENENCODINGS="\"$SCREENENCODINGS\"" 1284fi 1285AC_MSG_CHECKING(for the utf8-encodings location) 1286AC_DEFINE_UNQUOTED(SCREENENCODINGS,$SCREENENCODINGS) 1287AC_MSG_RESULT($SCREENENCODINGS) 1288 1289AC_OUTPUT(Makefile doc/Makefile, [[ 1290# a hook for preserving undef directive in config.h 1291mv config.h conftest 1292sed -e 's@^\(.*\)defin.\( .*\) .*/\*\(.*KEEP_UNDEF_HERE\)@\1undef\2 /\*\3@' < conftest > config.h 1293rm -f conftest 1294]]) 1295 1296echo "" 1297if test -z "$AWK"; then 1298echo "!!! Since you have no awk you must copy the files 'comm.h.dist'" 1299echo "!!! and 'term.h.dist' to 'comm.h' and 'term.h'." 1300echo "!!! Do _not_ change the user configuration section in config.h!" 1301echo "Please check the pathnames in the Makefile." 1302else 1303echo "Now please check the pathnames in the Makefile and in the user" 1304echo "configuration section in config.h." 1305fi 1306echo "Then type 'make' to make screen. Good luck." 1307echo "" 1308