1157184Sachednl Process this file with autoconf to produce a configure script. 2157184Sache 3157184SacheAC_INIT(rlfe.c) 4157184SacheAC_CONFIG_HEADER(config.h) 5157184SacheVERSION=0.4 6157184SacheAC_SUBST(VERSION) 7157184Sache 8157184Sachednl 9157184Sachednl Define some useful macros 10157184Sachednl 11157184SacheAC_DEFUN(AC_PROGRAM_SOURCE, 12157184Sache[AC_REQUIRE([AC_PROG_CPP])AC_PROVIDE([$0])cat > conftest.c <<EOF 13157184Sache#include "confdefs.h" 14157184Sache[$1] 15157184Sache_CUT_HERE_ 16157184Sache[$2] 17157184SacheEOF 18157184Sacheeval "$ac_cpp conftest.c 2>&5 | sed -e '1,/_CUT_HERE_/d' -e 's/ //g' > conftest.out" 19157184Sache. ./conftest.out 20157184Sacherm -f conftest* 21157184Sache])dnl 22157184Sachednl 23157184Sachedefine(AC_NOTE, 24157184Sache[echo "$1" 1>&AC_FD_MSG 25157184Sache])dnl 26157184Sache 27157184Sacheold_CFLAGS="$CFLAGS" 28157184SacheAC_PROG_CC 29157184SacheAC_PROG_CPP 30157184SacheAC_PROG_GCC_TRADITIONAL 31157184SacheAC_ISC_POSIX 32157184Sache 33157184SacheAC_TRY_RUN(main(){exit(0);},,[ 34157184Sacheif test $CC != cc ; then 35157184SacheAC_NOTE(Your $CC failed - restarting with CC=cc) 36157184SacheAC_NOTE() 37157184SacheCC=cc 38157184Sacheexport CC 39157184Sacheexec $0 $configure_args 40157184Sachefi 41157184Sache]) 42157184Sache 43157184SacheAC_TRY_RUN(main(){exit(0);},, 44157184Sacheexec 5>&2 45157184Sacheeval $ac_link 46157184SacheAC_NOTE(CC=$CC; CFLAGS=$CFLAGS; LIBS=$LIBS;) 47157184SacheAC_NOTE($ac_compile) 48157184SacheAC_MSG_ERROR(Can't run the compiler - sorry)) 49157184Sache 50157184SacheAC_TRY_RUN([ 51157184Sachemain() 52157184Sache{ 53157184Sache int __something_strange_(); 54157184Sache __something_strange_(0); 55157184Sache} 56157184Sache],AC_MSG_ERROR(Your compiler does not set the exit status - sorry)) 57157184Sache 58157184SacheAC_PROG_AWK 59157184Sache 60157184Sacheif test -f etc/toolcheck; then 61157184SacheAC_CHECKING(for buggy tools) 62157184Sachesh etc/toolcheck 1>&AC_FD_MSG 63157184Sachefi 64157184Sache 65157184Sachednl 66157184Sachednl **** special unix variants **** 67157184Sachednl 68157184Sache 69157184SacheAC_CHECKING(for System V) 70157184SacheAC_TRY_COMPILE( 71157184Sache[#include <sys/types.h> 72157184Sache#include <signal.h> 73157184Sache#include <fcntl.h>], [int x = SIGCHLD | FNDELAY;], , AC_DEFINE(SYSV)) 74157184Sache 75157184SacheAC_CHECKING(for Solaris 2.x) 76157184SacheAC_EGREP_CPP(yes, 77157184Sache[#if defined(SVR4) && defined(sun) 78157184Sache yes 79157184Sache#endif 80157184Sache], LIBS="$LIBS -lsocket -lnsl -lkstat") 81157184Sache 82157184Sachednl 83157184Sachednl **** select() **** 84157184Sachednl 85157184Sache 86157184SacheAC_CHECKING(select) 87157184SacheAC_TRY_LINK(,[select(0, 0, 0, 0, 0);],, 88157184SacheLIBS="$LIBS -lnet -lnsl" 89157184SacheAC_CHECKING(select with $LIBS) 90157184SacheAC_TRY_LINK(,[select(0, 0, 0, 0, 0);],, 91157184SacheAC_MSG_ERROR(!!! no select - no screen)) 92157184Sache) 93157184Sachednl 94157184Sachednl **** check the select implementation **** 95157184Sachednl 96157184Sache 97157184SacheAC_CHECKING(select return value) 98157184SacheAC_TRY_RUN([ 99157184Sache#include <sys/types.h> 100157184Sache#include <sys/stat.h> 101157184Sache#include <fcntl.h> 102157184Sache 103157184Sachechar *nam = "/tmp/conftest$$"; 104157184Sache 105157184Sache#ifdef NAMEDPIPE 106157184Sache 107157184Sache#ifndef O_NONBLOCK 108157184Sache#define O_NONBLOCK O_NDELAY 109157184Sache#endif 110157184Sache#ifndef S_IFIFO 111157184Sache#define S_IFIFO 0010000 112157184Sache#endif 113157184Sache 114157184Sache 115157184Sachemain() 116157184Sache{ 117157184Sache#ifdef FD_SET 118157184Sache fd_set f; 119157184Sache#else 120157184Sache int f; 121157184Sache#endif 122157184Sache 123157184Sache#ifdef __FreeBSD__ 124157184Sache/* From Andrew A. Chernov (ache@astral.msk.su): 125157184Sache * opening RDWR fifo fails in BSD 4.4, but select return values are 126157184Sache * right. 127157184Sache */ 128157184Sache exit(0); 129157184Sache#endif 130157184Sache (void)alarm(5); 131157184Sache#ifdef POSIX 132157184Sache if (mkfifo(nam, 0777)) 133157184Sache#else 134157184Sache if (mknod(nam, S_IFIFO|0777, 0)) 135157184Sache#endif 136157184Sache exit(1); 137157184Sache close(0); 138157184Sache if (open(nam, O_RDWR | O_NONBLOCK)) 139157184Sache exit(1); 140157184Sache if (write(0, "TEST", 4) == -1) 141157184Sache exit(1); 142157184Sache 143157184Sache#else 144157184Sache 145157184Sache#include <sys/types.h> 146157184Sache#include <sys/socket.h> 147157184Sache#include <sys/un.h> 148157184Sache 149157184Sachemain() 150157184Sache{ 151157184Sache int s1, s2, l; 152157184Sache struct sockaddr_un a; 153157184Sache#ifdef FD_SET 154157184Sache fd_set f; 155157184Sache#else 156157184Sache int f; 157157184Sache#endif 158157184Sache 159157184Sache (void)alarm(5); 160157184Sache if ((s1 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) 161157184Sache exit(1); 162157184Sache a.sun_family = AF_UNIX; 163157184Sache strcpy(a.sun_path, nam); 164157184Sache (void) unlink(nam); 165157184Sache if (bind(s1, (struct sockaddr *) &a, strlen(nam)+2) == -1) 166157184Sache exit(1); 167157184Sache if (listen(s1, 2)) 168157184Sache exit(1); 169157184Sache if (fork() == 0) 170157184Sache { 171157184Sache if ((s2 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) 172157184Sache kill(getppid(), 3); 173157184Sache (void)connect(s2, (struct sockaddr *)&a, strlen(nam) + 2); 174157184Sache if (write(s2, "HELLO", 5) == -1) 175157184Sache kill(getppid(), 3); 176157184Sache exit(0); 177157184Sache } 178157184Sache l = sizeof(a); 179157184Sache close(0); 180157184Sache if (accept(s1, (struct sockaddr *)&a, &l)) 181157184Sache exit(1); 182157184Sache#endif 183157184Sache 184157184Sache 185157184Sache#ifdef FD_SET 186157184Sache FD_SET(0, &f); 187157184Sache#else 188157184Sache f = 1; 189157184Sache#endif 190157184Sache if (select(1, &f, 0, 0, 0) == -1) 191157184Sache exit(1); 192157184Sache if (select(1, &f, &f, 0, 0) != 2) 193157184Sache exit(1); 194157184Sache exit(0); 195157184Sache} 196157184Sache],AC_NOTE(- select is ok), 197157184SacheAC_NOTE(- select can't count) AC_DEFINE(SELECT_BROKEN)) 198157184Sache 199157184Sachednl 200157184Sachednl **** termcap or terminfo **** 201157184Sachednl 202157184SacheAC_CHECKING(for tgetent) 203157184SacheAC_TRY_LINK(,tgetent((char *)0, (char *)0);,, 204157184Sacheolibs="$LIBS" 205157184SacheLIBS="-lcurses $olibs" 206157184SacheAC_CHECKING(libcurses) 207157184SacheAC_TRY_LINK(,[ 208157184Sache#ifdef __hpux 209157184Sache__sorry_hpux_libcurses_is_totally_broken_in_10_10(); 210157184Sache#else 211157184Sachetgetent((char *)0, (char *)0); 212157184Sache#endif 213157184Sache],, 214157184SacheLIBS="-ltermcap $olibs" 215157184SacheAC_CHECKING(libtermcap) 216157184SacheAC_TRY_LINK(,tgetent((char *)0, (char *)0);,, 217157184SacheLIBS="-ltermlib $olibs" 218157184SacheAC_CHECKING(libtermlib) 219157184SacheAC_TRY_LINK(,tgetent((char *)0, (char *)0);,, 220157184SacheLIBS="-lncurses $olibs" 221157184SacheAC_CHECKING(libncurses) 222157184SacheAC_TRY_LINK(,tgetent((char *)0, (char *)0);,, 223157184SacheAC_MSG_ERROR(!!! no tgetent - no screen)))))) 224157184Sache 225157184SacheAC_TRY_RUN([ 226157184Sachemain() 227157184Sache{ 228157184Sache exit(strcmp(tgoto("%p1%d", 0, 1), "1") ? 0 : 1); 229157184Sache}], AC_NOTE(- you use the termcap database), 230157184SacheAC_NOTE(- you use the terminfo database) AC_DEFINE(TERMINFO)) 231157184SacheAC_CHECKING(ospeed) 232157184SacheAC_TRY_LINK(extern short ospeed;,ospeed=5;,,AC_DEFINE(NEED_OSPEED)) 233157184Sache 234157184Sachednl 235157184Sachednl **** PTY specific things **** 236157184Sachednl 237157184SacheAC_CHECKING(for /dev/ptc) 238157184Sacheif test -r /dev/ptc; then 239157184SacheAC_DEFINE(HAVE_DEV_PTC) 240157184Sachefi 241157184Sache 242157184SacheAC_CHECKING(for SVR4 ptys) 243157184Sachesysvr4ptys= 244157184Sacheif test -c /dev/ptmx ; then 245157184SacheAC_TRY_LINK([],[ptsname(0);grantpt(0);unlockpt(0);],[AC_DEFINE(HAVE_SVR4_PTYS) 246157184Sachesysvr4ptys=1]) 247157184Sachefi 248157184Sache 249157184SacheAC_CHECK_FUNCS(getpt) 250157184Sache 251157184Sachednl check for openpty() 252157184Sacheif test -z "$sysvr4ptys"; then 253157184SacheAC_CHECK_FUNCS(openpty,, 254157184Sache[AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY)] [LIBS="$LIBS -lutil"])]) 255157184Sachefi 256157184Sache 257157184SacheAC_CHECKING(for ptyranges) 258157184Sacheif test -d /dev/ptym ; then 259157184Sachepdir='/dev/ptym' 260157184Sacheelse 261157184Sachepdir='/dev' 262157184Sachefi 263157184Sachednl SCO uses ptyp%d 264157184SacheAC_EGREP_CPP(yes, 265157184Sache[#ifdef M_UNIX 266157184Sache yes; 267157184Sache#endif 268157184Sache], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`) 269157184Sachednl if test -c /dev/ptyp19; then 270157184Sachednl ptys=`echo /dev/ptyp??` 271157184Sachednl else 272157184Sachednl ptys=`echo $pdir/pty??` 273157184Sachednl fi 274157184Sacheif test "$ptys" != "$pdir/pty??" ; then 275157184Sachep0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'` 276157184Sachep1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'` 277157184SacheAC_DEFINE_UNQUOTED(PTYRANGE0,"$p0") 278157184SacheAC_DEFINE_UNQUOTED(PTYRANGE1,"$p1") 279157184Sachefi 280157184Sache 281157184Sachednl **** pty mode/group handling **** 282157184Sachednl 283157184Sachednl support provided by Luke Mewburn <lm@rmit.edu.au>, 931222 284157184SacheAC_ARG_WITH(pty-mode, [ --with-pty-mode=mode default mode for ptys], [ ptymode="${withval}" ]) 285157184SacheAC_ARG_WITH(pty-group, [ --with-pty-group=group default group for ptys], [ ptygrp="${withval}" ]) 286157184Sachetest -n "$ptymode" || ptymode=0620 287157184Sacheif test -n "$ptygrp" ; then 288157184SacheAC_DEFINE_UNQUOTED(PTYMODE, $ptymode) 289157184SacheAC_DEFINE_UNQUOTED(PTYGROUP,$ptygrp) 290157184Sacheelse 291157184Sache 292157184SacheAC_CHECKING(default tty permissions/group) 293157184Sacherm -f conftest_grp 294157184SacheAC_TRY_RUN([ 295157184Sache#include <sys/types.h> 296157184Sache#include <sys/stat.h> 297157184Sache#include <stdio.h> 298157184Sachemain() 299157184Sache{ 300157184Sache struct stat sb; 301157184Sache char *x,*ttyname(); 302157184Sache int om, m; 303157184Sache FILE *fp; 304157184Sache 305157184Sache if (!(x = ttyname(0))) exit(1); 306157184Sache if (stat(x, &sb)) exit(1); 307157184Sache om = sb.st_mode; 308157184Sache if (om & 002) exit(0); 309157184Sache m = system("mesg y"); 310157184Sache if (m == -1 || m == 127) exit(1); 311157184Sache if (stat(x, &sb)) exit(1); 312157184Sache m = sb.st_mode; 313157184Sache if (chmod(x, om)) exit(1); 314157184Sache if (m & 002) exit(0); 315157184Sache if (sb.st_gid == getgid()) exit(1); 316157184Sache if (!(fp=fopen("conftest_grp", "w"))) 317157184Sache exit(1); 318157184Sache fprintf(fp, "%d\n", sb.st_gid); 319157184Sache fclose(fp); 320157184Sache exit(0); 321157184Sache} 322157184Sache],[ 323157184Sache if test -f conftest_grp; then 324157184Sache ptygrp=`cat conftest_grp` 325157184Sache AC_NOTE([- pty mode: $ptymode, group: $ptygrp]) 326157184Sache AC_DEFINE_UNQUOTED(PTYMODE, $ptymode) 327157184Sache AC_DEFINE_UNQUOTED(PTYGROUP,$ptygrp) 328157184Sache else 329157184Sache AC_NOTE(- ptys are world accessable) 330157184Sache fi 331157184Sache],[ 332157184Sache WRITEPATH='' 333157184Sache XTERMPATH='' 334157184Sache AC_PATH_PROG(WRITEPATH, write) 335157184Sache AC_PATH_PROG(XTERMPATH, xterm) 336157184Sache found= 337157184Sache if test -n "$WRITEPATH$XTERMPATH"; then 338157184Sache findfollow= 339157184Sache lsfollow= 340157184Sache found=`find $WRITEPATH $XTERMPATH -follow -print 2>/dev/null` 341157184Sache if test -n "$found"; then 342157184Sache findfollow=-follow 343157184Sache lsfollow=L 344157184Sache fi 345157184Sache if test -n "$XTERMPATH"; then 346157184Sache ptygrpn=`ls -l$lsfollow $XTERMPATH | sed -n -e 1p | $AWK '{print $4}'` 347157184Sache if test tty != "$ptygrpn"; then 348157184Sache XTERMPATH= 349157184Sache fi 350157184Sache fi 351157184Sache fi 352157184Sache if test -n "$WRITEPATH$XTERMPATH"; then 353157184Sache found=`find $WRITEPATH $XTERMPATH $findfollow -perm -2000 -print` 354157184Sache if test -n "$found"; then 355157184Sache ptygrp=`ls -ln$lsfollow $found | sed -n -e 1p | $AWK '{print $4}'` 356157184Sache AC_NOTE([- pty mode: $ptymode, group: $ptygrp]) 357157184Sache AC_DEFINE_UNQUOTED(PTYMODE, $ptymode) 358157184Sache AC_DEFINE_UNQUOTED(PTYGROUP,$ptygrp) 359157184Sache else 360157184Sache AC_NOTE(- ptys are world accessable) 361157184Sache fi 362157184Sache else 363157184Sache AC_NOTE(- can't determine - assume ptys are world accessable) 364157184Sache fi 365157184Sache ] 366157184Sache) 367157184Sacherm -f conftest_grp 368157184Sachefi 369157184Sache 370157184Sachednl 371157184Sachednl **** signal handling **** 372157184Sachednl 373157184Sacheif test -n "$posix" ; then 374157184Sache 375157184Sachednl POSIX has reliable signals with void return type. 376157184SacheAC_NOTE(assuming posix signal definition) 377157184SacheAC_DEFINE(SIGVOID) 378157184Sache 379157184Sacheelse 380157184Sache 381157184SacheAC_CHECKING(return type of signal handlers) 382157184SacheAC_TRY_COMPILE( 383157184Sache[#include <sys/types.h> 384157184Sache#include <signal.h> 385157184Sache#ifdef signal 386157184Sache#undef signal 387157184Sache#endif 388157184Sacheextern void (*signal ()) ();], [int i;], AC_DEFINE(SIGVOID)) 389157184SacheAC_CHECKING(sigset) 390157184SacheAC_TRY_LINK([ 391157184Sache#include <sys/types.h> 392157184Sache#include <signal.h> 393157184Sache],[ 394157184Sache#ifdef SIGVOID 395157184Sachesigset(0, (void (*)())0); 396157184Sache#else 397157184Sachesigset(0, (int (*)())0); 398157184Sache#endif 399157184Sache], AC_DEFINE(USESIGSET)) 400157184SacheAC_CHECKING(signal implementation) 401157184SacheAC_TRY_RUN([ 402157184Sache#include <sys/types.h> 403157184Sache#include <signal.h> 404157184Sache 405157184Sache#ifndef SIGCLD 406157184Sache#define SIGCLD SIGCHLD 407157184Sache#endif 408157184Sache#ifdef USESIGSET 409157184Sache#define signal sigset 410157184Sache#endif 411157184Sache 412157184Sacheint got; 413157184Sache 414157184Sache#ifdef SIGVOID 415157184Sachevoid 416157184Sache#endif 417157184Sachehand() 418157184Sache{ 419157184Sache got++; 420157184Sache} 421157184Sache 422157184Sachemain() 423157184Sache{ 424157184Sache /* on hpux we use sigvec to get bsd signals */ 425157184Sache#ifdef __hpux 426157184Sache (void)signal(SIGCLD, hand); 427157184Sache kill(getpid(), SIGCLD); 428157184Sache kill(getpid(), SIGCLD); 429157184Sache if (got < 2) 430157184Sache exit(1); 431157184Sache#endif 432157184Sache exit(0); 433157184Sache} 434157184Sache],,AC_DEFINE(SYSVSIGS)) 435157184Sache 436157184Sachefi 437157184Sache 438157184SacheAC_OUTPUT(Makefile) 439