dnl Process this file with autoconf to produce a configure script. dnl dnl $Id: configure.in,v 1.1.1.1 1993/08/15 18:32:58 nate Exp $ FAU dnl dnl Many thanks to David MacKenzie for writing autoconf and dnl providing a sample configure.in file for screen. dnl AC_INIT(screen.c) AC_CONFIG_HEADER(config.h) dnl dnl Define some useful macros dnl define(AC_PROGRAM_SOURCE, [AC_REQUIRE([AC_PROG_CPP])AC_PROVIDE([$0])cat > conftest.c </dev/null | sed -e '1,/_CUT_HERE_/d' > conftest.out" . ./conftest.out rm -f conftest* ])dnl rev=`sed < ${srcdir}/patchlevel.h -n -e '/#define REV/s/#define REV *//p'` vers=`sed < ${srcdir}/patchlevel.h -n -e '/#define VERS/s/#define VERS *//p'` pat=`sed < ${srcdir}/patchlevel.h -n -e '/#define PATCHLEVEL/s/#define PATCHLEVEL *//p'` VERSION="$rev.$vers.$pat" echo "this is screen version $VERSION" AC_SUBST(VERSION) AC_PROG_CC AC_PROG_CPP AC_GCC_TRADITIONAL AC_ISC_POSIX AC_TEST_PROGRAM(main(){exit(0);},,echo "Can't run the compiler - sorry";exit) AC_PROG_AWK AC_PROG_INSTALL dnl dnl **** special unix variants **** dnl if test -n "$ISC"; then AC_DEFINE(ISC) LIBS="$LIBS -linet" fi echo checking for OSF1 if test -f /bin/uname ; then if test `/bin/uname` = OSF1 || test -f /osf_boot; then AC_DEFINE(OSF1) # this disables MIPS again.... fi fi echo checking for MIPS if test -f /lib/libmld.a || test -f /usr/lib/libmld.a || test -f /usr/lib/cmplrs/cc/libmld.a; then LIBS="$LIBS -lmld" # for nlist. if test -c /dev/ptc; then AC_DEFINE(MIPS) AC_COMPILE_CHECK(wait3, , [wait3();], , AC_COMPILE_CHECK(wait2, , [wait2();], dnl John Rouillard (rouilj@sni-usa.com): dnl need -I/usr/include/bsd in RISCOS otherwise sockets are broken, no dnl job control etc. dnl Detect RISCOS if wait2 is present, but not wait3. AC_DEFINE(USE_WAIT2) LIBS="$LIBS -lbsd" ; CC="$CC -I/usr/include/bsd" )) fi fi echo checking for Ultrix AC_PROGRAM_EGREP(yes, [#if defined(ultrix) || defined(__ultrix) yes #endif ], ULTRIX=1) dnl ghazi@caip.rutgers.edu (Kaveh R. Ghazi): dnl BBN butterfly is not POSIX, but a MACH BSD system. dnl Do not define POSIX and TERMIO. echo checking for butterfly AC_PROGRAM_EGREP(yes, [#if defined(butterfly) yes #endif ], butterfly=1) if test -z "$butterfly"; then if test -n "$ULTRIX"; then test -z "$GCC" && CC="$CC -YBSD" fi echo checking for POSIX.1 AC_PROGRAM_EGREP(yes, [#include #include main () { #ifdef _POSIX_VERSION yes #endif ], echo "- you have a POSIX system";AC_DEFINE(POSIX)) fi AC_COMPILE_CHECK([System V], [#include #include #include ], [int x = SIGCHLD | FNDELAY;], , AC_DEFINE(SYSV)) echo checking for sequent/ptx AC_PROGRAM_EGREP(yes, [#ifdef _SEQUENT_ yes #endif ], LIBS="$LIBS -lsocket -linet";seqptx=1) oldlibs="$LIBS" LIBS="$LIBS -lelf" AC_COMPILE_CHECK(SVR4,,, AC_HEADER_CHECK(dwarf.h, AC_DEFINE(SVR4) AC_DEFINE(BUGGYGETLOGIN) LIBS="$LIBS -lelf", AC_HEADER_CHECK(elf.h, AC_DEFINE(SVR4) AC_DEFINE(BUGGYGETLOGIN) LIBS="$LIBS -lelf")) ,LIBS="$oldlibs") dnl dnl **** typedefs **** dnl echo checking for pid_t AC_PROGRAM_EGREP(pid_t,[#include ],AC_DEFINE(PID_T_DEFINED)) echo checking for sig_t AC_PROGRAM_EGREP(sig_t,[#include #include ],AC_DEFINE(SIG_T_DEFINED)) echo checking for uid_t AC_PROGRAM_EGREP(uid_t,[#include ],AC_DEFINE(UID_T_DEFINED)) dnl dnl **** Job control **** dnl AC_COMPILE_CHECK([BSD job control], [#include #include ], [ #ifdef POSIX tcsetpgrp(0, 0); #else int x = TIOCSPGRP; #ifdef SYSV setpgrp(); #else int y = TIOCNOTTY; #endif #endif ], echo "- you have jobcontrol" AC_DEFINE(BSDJOBS), echo "- you don't have jobcontrol") dnl dnl **** setreuid() **** dnl AC_COMPILE_CHECK(setreuid, , [ #ifdef hpux setresuid(0, 0, 0); #else setreuid(0, 0); #endif ], , AC_DEFINE(NOREUID)) dnl **** select() **** dnl AC_COMPILE_CHECK(select,,[select(0, 0, 0, 0, 0);],, LIBS="$LIBS -lnet -lnsl" AC_COMPILE_CHECK(select with $LIBS,,[select(0, 0, 0, 0, 0);],, echo '!!! no select - no screen';exit) ) dnl dnl **** FIFO tests **** dnl echo checking fifos AC_TEST_PROGRAM([ #include #include #include #ifndef O_NDELAY #define O_NDELAY O_NONBLOCK #endif #ifndef S_IFIFO #define S_IFIFO 0010000 #endif char *fin = "/tmp/conftest$$"; main() { struct stat stb; int f; (void)alarm(5); if (mknod(fin, S_IFIFO|0777, 0)) exit(1); if (stat(fin, &stb) || (stb.st_mode & S_IFIFO) != S_IFIFO) exit(1); close(0); if (open(fin, O_RDWR | O_NDELAY)) exit(1); if (write(0, "TEST", 4) == -1) exit(1); f = 1; if (select(1, &f, 0, 0, 0) == -1) exit(1); exit(0); } ], echo "- your fifos are usable"; fifo=1, echo "- your fifos are not usable") rm -f /tmp/conftest* if test -n "$fifo"; then echo "checking for broken fifo implementation" AC_TEST_PROGRAM([ #include #include #include #include #ifndef O_NDELAY #define O_NDELAY O_NONBLOCK #endif #ifndef S_IFIFO #define S_IFIFO 0010000 #endif char *fin = "/tmp/conftest$$"; main() { struct timeval tv; int r, x; if (mknod(fin, S_IFIFO|0600, 0)) exit(1); close(0); if (open(fin, O_RDONLY|O_NDELAY)) exit(1); r = 1; tv.tv_sec = 1; tv.tv_usec = 0; if (select(1, &r, 0, 0, &tv)) exit(1); exit(0); } ], echo "- your implementation is ok", echo "- you have a broken implementation" AC_DEFINE(BROKEN_PIPE) fifobr=1) rm -f /tmp/conftest* fi dnl dnl **** SOCKET tests **** dnl dnl may need LIBS="$LIBS -lsocket" here dnl echo checking sockets AC_TEST_PROGRAM([ #include #include #include #include #ifndef O_NDELAY #define O_NDELAY O_NONBLOCK #endif #ifndef FNDELAY #define FNDELAY O_NDELAY #endif char *son = "/tmp/conftest$$"; main() { int s1, s2, s3, l; struct sockaddr_un a; (void)alarm(5); if ((s1 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) exit(1); a.sun_family = AF_UNIX; strcpy(a.sun_path, son); (void) unlink(son); if (bind(s1, (struct sockaddr *) &a, strlen(son)+2) == -1) exit(1); if (listen(s1, 2)) exit(1); if (fork() == 0) { if ((s2 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) kill(getppid(), 3); (void)connect(s2, (struct sockaddr *)&a, strlen(son) + 2); if (write(s2, "HELLO", 5) == -1) kill(getppid(), 3); exit(0); } l = sizeof(a); close(0); if (accept(s1, &a, &l)) exit(1); l = 1; if (select(1, &l, 0, 0, 0) == -1) exit(1); exit(0); } ], echo "- your sockets are usable"; sock=1, echo "- your sockets are not usable") rm -f /tmp/conftest* if test -n "$sock"; then echo "checking socket implementation" AC_TEST_PROGRAM([ #include #include #include #include char *son = "/tmp/conftest$$"; main() { int s; struct stat stb; struct sockaddr_un a; if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) exit(0); a.sun_family = AF_UNIX; strcpy(a.sun_path, son); (void) unlink(son); if (bind(s, (struct sockaddr *) &a, strlen(son)+2) == -1) exit(0); if (stat(son, &stb)) exit(1); close(s); exit(0); } ],echo "- you are normal", echo "- unix domain sockets are not kept in the filesystem" AC_DEFINE(SOCK_NOT_IN_FS) socknofs=1) rm -f /tmp/conftest* fi dnl dnl **** choose sockets or fifos **** dnl if test -n "$fifo"; then if test -n "$sock"; then if test -n "$nore"; then echo "- hmmm... better take the fifos" AC_DEFINE(NAMEDPIPE) elif test -n "$fifobr"; then echo "- as your fifos are broken lets use the sockets." else echo "- both sockets and fifos usable. let's take fifos." AC_DEFINE(NAMEDPIPE) fi else echo "- using named pipes, of course" AC_DEFINE(NAMEDPIPE) fi elif test -n "$sock"; then echo "- using unix-domain sockets, of course" else echo "!!! you have neither usable sockets nor usable pipes -> no screen" exit fi dnl dnl **** check the select implementation **** dnl echo "checking select return value" AC_TEST_PROGRAM([ #include #include #include char *nam = "/tmp/conftest$$"; #ifdef NAMEDPIPE #ifndef O_NDELAY #define O_NDELAY O_NONBLOCK #endif #ifndef S_IFIFO #define S_IFIFO 0010000 #endif main() { int l; (void)alarm(5); if (mknod(nam, S_IFIFO|0777, 0)) exit(1); close(0); if (open(nam, O_RDWR | O_NDELAY)) exit(1); if (write(0, "TEST", 4) == -1) exit(1); #else #include #include #include main() { int s1, s2, s3, l; struct sockaddr_un a; (void)alarm(5); if ((s1 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) exit(1); a.sun_family = AF_UNIX; strcpy(a.sun_path, nam); (void) unlink(nam); if (bind(s1, (struct sockaddr *) &a, strlen(nam)+2) == -1) exit(1); if (listen(s1, 2)) exit(1); if (fork() == 0) { if ((s2 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) kill(getppid(), 3); (void)connect(s2, (struct sockaddr *)&a, strlen(nam) + 2); if (write(s2, "HELLO", 5) == -1) kill(getppid(), 3); exit(0); } l = sizeof(a); close(0); if (accept(s1, (struct sockaddr *)&a, &l)) exit(1); #endif l = 1; if (select(1, &l, 0, 0, 0) == -1) exit(1); if (select(1, &l, &l, 0, 0) != 2) exit(1); exit(0); } ],echo "- select is ok",echo "- it is not usable" AC_DEFINE(SELECT_BROKEN)) dnl dnl **** termcap or terminfo **** dnl echo searching for tgetent olibs="$LIBS" LIBS="-ltermcap $LIBS" AC_COMPILE_CHECK(libtermcap,,tgetent((char *)0, (char *)0);,, LIBS="-lcurses $olibs" AC_COMPILE_CHECK(libcurses,,tgetent((char *)0, (char *)0);,, echo "!!! no tgetent - no screen";exit) ) TERMCAP="xx|scrdumm:xx:" TERM=scrdumm export TERMCAP export TERM AC_TEST_PROGRAM([ main() { char buf[1024]; if (tgetent(buf, "scrdumm") != 1) exit(1); exit(0); }], echo "- you use the termcap database", echo "- you use the terminfo database" AC_DEFINE(TERMINFO)) AC_COMPILE_CHECK(ospeed,extern short ospeed;,ospeed=5;,,AC_DEFINE(NEED_OSPEED)) dnl dnl **** PTY ranges **** dnl echo checking for ptyranges if test -d /dev/ptym ; then pdir='/dev/ptym' else pdir='/dev' fi ptys=`echo $pdir/pty??` if test "$ptys" != "$pdir/pty??" ; then p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | tr ' ' '\012' | sort -u | sed -n -e H -e g -e 's/\n//g' -e '$p'` p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | tr ' ' '\012' | sort -u | sed -n -e H -e g -e 's/\n//g' -e '$p'` AC_DEFINE_UNQUOTED(PTYRANGE0,\"$p0\") AC_DEFINE_UNQUOTED(PTYRANGE1,\"$p1\") fi dnl dnl **** utmp handling **** dnl dnl linux has a void pututline, grrr, gcc will error when evaluating it. AC_COMPILE_CHECK(getutent, [#include /* to get time_t on SCO */ #include #ifdef SVR4 #include #else #include #endif #ifdef hpux #define pututline _pututline #endif ], [int x = DEAD_PROCESS; struct utmp *y = pututline((struct utmp *)0); getutent();], AC_DEFINE(GETUTENT)) AC_COMPILE_CHECK(ut_host, [#include #include #ifdef SVR4 #include #else #include #endif ],[struct utmp u; u.ut_host[0] = 0;], AC_DEFINE(UTHOST)) dnl dnl **** loadav **** dnl echo "checking for libutil(s)" test -f /usr/lib/libutils.a && LIBS="$LIBS -lutils" test -f /usr/lib/libutil.a && LIBS="$LIBS -lutil" AC_COMPILE_CHECK(getloadavg, , [getloadavg((double *)0, 0);], AC_DEFINE(LOADAV_GETLOADAVG) load=1) if test -z "$load" ; then AC_PROGRAM_EGREP(yes, [#if defined(NeXT) || defined(apollo) || defined(linux) yes #endif ], load=1) fi if test -z "$load" ; then echo "searching for kernelfile" for core in /unix /vmunix /dynix /hp-ux /xelos /386bsd /kernel/unix ; do if test -f $core ; then break fi done if test ! -f $core ; then echo "- no kernelfile found" else echo "- using kernelfile '$core'" AC_DEFINE_UNQUOTED(LOADAV_UNIX,\"$core\") AC_HEADER_CHECK(nlist.h, [AC_DEFINE(NLIST_STRUCT) AC_COMPILE_CHECK(n_un in struct nlist, [#include ], [struct nlist n; n.n_un.n_name = 0;], AC_DEFINE(NLIST_NAME_UNION))]) echo checking for nlist declaration AC_PROGRAM_EGREP([nlist( | |\()],[ #ifdef NLIST_STRUCT # include #else # include #endif ],AC_DEFINE(NLIST_DECLARED)) echo searching for avenrun symbol for av in avenrun _avenrun _Loadavg ; do AC_TEST_PROGRAM([ #include #ifdef NLIST_STRUCT #include #else #include #endif struct nlist nl[2]; main() { #ifdef NLIST_NAME_UNION nl[0].n_un.n_name = "$av"; #else nl[0].n_name = "$av"; #endif nlist(LOADAV_UNIX, nl); if (nl[0].n_value == 0) exit(1); exit(0); } ],avensym=$av;break) done if test -z "$avensym" ; then echo "- no avenrun symbol found" else echo "- using avenrun symbol '$avensym'" AC_DEFINE_UNQUOTED(LOADAV_AVENRUN,\"$avensym\") load=1 fi fi fi AC_PROGRAM_SOURCE([ #include #include ],[ #if ((defined(hp300) && !defined(hpux)) || defined(sun) || (defined(ultrix) && defined(mips)) || defined(_SEQUENT_) || defined(sgi) || defined(SVR4) || defined(sony_news) || defined(__alpha)) loadtype=long # ifdef apollo loadscale=65536 # else # ifdef FSCALE # undef FSCALE loadscale=FSCALE # else # ifdef sgi loadscale=1024 # else # if defined(MIPS) || defined(SVR4) loadscale=256 # else /* not MIPS */ loadscale=1000 /* our default value */ # endif /* MIPS */ # endif /* sgi */ # endif /* not FSCALE */ # endif /* not apollo */ #else loadtype=double loadscale=1 #endif #ifdef alliant loadnum=4 #else loadnum=3 #endif ]) if test -n "$load" ; then AC_DEFINE(LOADAV) fi if test -n "$loadtype" ; then AC_DEFINE_UNQUOTED(LOADAV_TYPE,$loadtype) fi if test -n "$loadnum" ; then AC_DEFINE_UNQUOTED(LOADAV_NUM,$loadnum) fi if test -n "$loadscale" ; then AC_DEFINE_UNQUOTED(LOADAV_SCALE,$loadscale) fi dnl dnl **** signal handling **** dnl AC_HEADER_EGREP([(void|sighandler_t).*signal], signal.h, AC_DEFINE(SIGVOID)) AC_COMPILE_CHECK(sigset, [ #include #include ], [ #ifdef SIGVOID sigset(0, (void (*)())0); #else sigset(0, (int (*)())0); #endif ], AC_DEFINE(USESIGSET)) echo checking signal implementation AC_TEST_PROGRAM([ #include #include #ifndef SIGCHLD #define SIGCHLD SIGCLD #endif #ifdef USESIGSET #define signal sigset #endif int got; #ifdef SIGVOID void #endif hand() { got++; } main() { (void)signal(SIGCHLD, hand); kill(getpid(), SIGCHLD); kill(getpid(), SIGCHLD); if (got < 2) exit(1); exit(0); } ],,AC_DEFINE(SYSVSIGS)) dnl dnl **** libraries **** dnl echo checking for crypt and sec libraries test -f /lib/libcrypt_d.a || test -f /usr/lib/libcrypt_d.a && LIBS="$LIBS -lcrypt_d" test -f /lib/libcrypt.a || test -f /usr/lib/libcrypt.a && LIBS="$LIBS -lcrypt" test -f /lib/libsec.a || test -f /usr/lib/libsec.a && LIBS="$LIBS -lsec" oldlibs="$LIBS" LIBS="$LIBS -lsun" AC_COMPILE_CHECK(IRIX sun library,,,,LIBS="$oldlibs") dnl dnl **** misc things **** dnl AC_COMPILE_CHECK(wait union,[#include #include ],[ union wait x; int y; #ifdef WEXITSTATUS y = WEXITSTATUS(x); #endif ],AC_DEFINE(BSDWAIT)) if test -z "$butterfly"; then echo checking for termio or termios AC_TEST_CPP([#include ], AC_DEFINE(TERMIO), AC_TEST_CPP([#include ], AC_DEFINE(TERMIO))) fi dnl AC_HEADER_CHECK(shadow.h, AC_DEFINE(SHADOWPW)) AC_COMPILE_CHECK(getspnam, [#include ], [getspnam("x");], AC_DEFINE(SHADOWPW)) AC_COMPILE_CHECK(getttyent, , [getttyent();], AC_DEFINE(GETTTYENT)) echo checking whether memcpy/memmove/bcopy handles overlapping arguments AC_TEST_PROGRAM([ main() { char buf[10]; strcpy(buf, "abcdefghi"); bcopy(buf, buf + 2, 3); if (strncmp(buf, "ababcf", 6)) exit(1); strcpy(buf, "abcdefghi"); bcopy(buf + 2, buf, 3); if (strncmp(buf, "cdedef", 6)) exit(1); exit(0); /* libc version works properly. */ }], AC_DEFINE(USEBCOPY)) AC_TEST_PROGRAM([ #define bcopy(s,d,l) memmove(d,s,l) main() { char buf[10]; strcpy(buf, "abcdefghi"); bcopy(buf, buf + 2, 3); if (strncmp(buf, "ababcf", 6)) exit(1); strcpy(buf, "abcdefghi"); bcopy(buf + 2, buf, 3); if (strncmp(buf, "cdedef", 6)) exit(1); exit(0); /* libc version works properly. */ }], AC_DEFINE(USEMEMMOVE)) AC_TEST_PROGRAM([ #define bcopy(s,d,l) memcpy(d,s,l) main() { char buf[10]; strcpy(buf, "abcdefghi"); bcopy(buf, buf + 2, 3); if (strncmp(buf, "ababcf", 6)) exit(1); strcpy(buf, "abcdefghi"); bcopy(buf + 2, buf, 3); if (strncmp(buf, "cdedef", 6)) exit(1); exit(0); /* libc version works properly. */ }], AC_DEFINE(USEMEMCPY)) echo checking for long file names (echo 1 > /tmp/conftest9012345) 2>/dev/null (echo 2 > /tmp/conftest9012346) 2>/dev/null val=`cat /tmp/conftest9012345 2>/dev/null` if test -f /tmp/conftest9012345 && test "$val" = 1; then : else AC_DEFINE(NAME_MAX, 14) fi rm -f /tmp/conftest* AC_COMPILE_CHECK(vsprintf, [#include #include ], [vsprintf();], AC_DEFINE(USEVARARGS)) AC_DIR_HEADER AC_XENIX_DIR AC_COMPILE_CHECK(setenv, , [setenv((char *)0,(char *)0);unsetenv((char *)0);], AC_DEFINE(USESETENV), AC_COMPILE_CHECK(putenv, , [putenv((char *)0);unsetenv((char *)0);], , AC_DEFINE(NEEDPUTENV) )) dnl dnl **** the end **** dnl dnl Ptx bug workaround -- insert -lc after -ltermcap test -n "$seqptx" && LIBS="-ltermcap -lc -lsocket -linet -lsec -lseq" AC_TEST_PROGRAM(main(){exit(0);},,echo "Can't run the compiler - internal error. Sorry.";exit) if test -n "$prefix"; then AC_DEFINE_UNQUOTED(ETCSCREENRC,\"$prefix/etc/screenrc\") fi AC_OUTPUT(Makefile doc/Makefile) # a hook for preserving undef directive in config.h if test -z "$no_create" ; then mv config.h conftest sed -e 's@^\(.*\)defin.\( .*\) .*/\*\(.*KEEP_UNDEF_HERE\)@\1undef\2 /\*\3@' < conftest > config.h rm -f conftest fi cat >> config.status << EOF mv config.h conftest sed -e 's@^\(.*\)defin.\( .*\) .*/\*\(.*KEEP_UNDEF_HERE\)@\1undef\2 /\*\3@' < conftest > config.h rm -f conftest EOF echo "" if test -z "$AWK"; then echo "!!! Since you have no awk you must copy the files 'comm.h.dist'" echo "!!! and 'term.h.dist' to 'comm.h' and 'term.h'." echo "!!! Do _not_ change the user configuration section in config.h!" echo "Please check the pathnames in the Makefile." else echo "Now please check the pathnames in the Makefile and the user" echo "configuration section in config.h." fi echo "Then type 'make' to make screen. Good luck." echo ""