1dnl Process this file with autoconf to produce a configure script. 2 3AC_INIT(rlfe.c) 4AC_CONFIG_HEADER(config.h) 5VERSION=0.4 6AC_SUBST(VERSION) 7 8dnl 9dnl Define some useful macros 10dnl 11AC_DEFUN([AC_PROGRAM_SOURCE], 12[AC_REQUIRE([AC_PROG_CPP])AC_PROVIDE([$0])cat > conftest.c <<EOF 13#include "confdefs.h" 14[$1] 15_CUT_HERE_ 16[$2] 17EOF 18eval "$ac_cpp conftest.c 2>&5 | sed -e '1,/_CUT_HERE_/d' -e 's/ //g' > conftest.out" 19. ./conftest.out 20rm -f conftest* 21])dnl 22dnl 23define(AC_NOTE, 24[echo "$1" 1>&AC_FD_MSG 25])dnl 26 27old_CFLAGS="$CFLAGS" 28AC_PROG_CC 29AC_PROG_CPP 30AC_PROG_GCC_TRADITIONAL 31AC_ISC_POSIX 32 33AC_TRY_RUN(main(){exit(0);},,[ 34if test $CC != cc ; then 35AC_NOTE(Your $CC failed - restarting with CC=cc) 36AC_NOTE() 37CC=cc 38export CC 39exec $0 $configure_args 40fi 41]) 42 43AC_TRY_RUN(main(){exit(0);},, 44exec 5>&2 45eval $ac_link 46AC_NOTE(CC=$CC; CFLAGS=$CFLAGS; LIBS=$LIBS;) 47AC_NOTE($ac_compile) 48AC_MSG_ERROR(Can't run the compiler - sorry)) 49 50AC_TRY_RUN([ 51main() 52{ 53 int __something_strange_(); 54 __something_strange_(0); 55} 56],AC_MSG_ERROR(Your compiler does not set the exit status - sorry)) 57 58AC_PROG_AWK 59 60if test -f etc/toolcheck; then 61AC_CHECKING(for buggy tools) 62sh etc/toolcheck 1>&AC_FD_MSG 63fi 64 65dnl 66dnl **** special unix variants **** 67dnl 68 69AC_CHECKING(for System V) 70AC_TRY_COMPILE( 71[#include <sys/types.h> 72#include <signal.h> 73#include <fcntl.h>], [int x = SIGCHLD | FNDELAY;], , AC_DEFINE(SYSV)) 74 75AC_CHECKING(for Solaris 2.x) 76AC_EGREP_CPP(yes, 77[#if defined(SVR4) && defined(sun) 78 yes 79#endif 80], LIBS="$LIBS -lsocket -lnsl -lkstat") 81 82dnl 83dnl **** select() **** 84dnl 85 86AC_CHECKING(select) 87AC_TRY_LINK(,[select(0, 0, 0, 0, 0);],, 88LIBS="$LIBS -lnet -lnsl" 89AC_CHECKING(select with $LIBS) 90AC_TRY_LINK(,[select(0, 0, 0, 0, 0);],, 91AC_MSG_ERROR(!!! no select - no screen)) 92) 93dnl 94dnl **** check the select implementation **** 95dnl 96 97AC_CHECKING(select return value) 98AC_TRY_RUN([ 99#include <sys/types.h> 100#include <sys/stat.h> 101#include <fcntl.h> 102 103char *nam = "/tmp/conftest$$"; 104 105#ifdef NAMEDPIPE 106 107#ifndef O_NONBLOCK 108#define O_NONBLOCK O_NDELAY 109#endif 110#ifndef S_IFIFO 111#define S_IFIFO 0010000 112#endif 113 114 115main() 116{ 117#ifdef FD_SET 118 fd_set f; 119#else 120 int f; 121#endif 122 123#ifdef __FreeBSD__ 124/* From Andrew A. Chernov (ache@astral.msk.su): 125 * opening RDWR fifo fails in BSD 4.4, but select return values are 126 * right. 127 */ 128 exit(0); 129#endif 130 (void)alarm(5); 131#ifdef POSIX 132 if (mkfifo(nam, 0777)) 133#else 134 if (mknod(nam, S_IFIFO|0777, 0)) 135#endif 136 exit(1); 137 close(0); 138 if (open(nam, O_RDWR | O_NONBLOCK)) 139 exit(1); 140 if (write(0, "TEST", 4) == -1) 141 exit(1); 142 143#else 144 145#include <sys/types.h> 146#include <sys/socket.h> 147#include <sys/un.h> 148 149main() 150{ 151 int s1, s2, l; 152 struct sockaddr_un a; 153#ifdef FD_SET 154 fd_set f; 155#else 156 int f; 157#endif 158 159 (void)alarm(5); 160 if ((s1 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) 161 exit(1); 162 a.sun_family = AF_UNIX; 163 strcpy(a.sun_path, nam); 164 (void) unlink(nam); 165 if (bind(s1, (struct sockaddr *) &a, strlen(nam)+2) == -1) 166 exit(1); 167 if (listen(s1, 2)) 168 exit(1); 169 if (fork() == 0) 170 { 171 if ((s2 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1) 172 kill(getppid(), 3); 173 (void)connect(s2, (struct sockaddr *)&a, strlen(nam) + 2); 174 if (write(s2, "HELLO", 5) == -1) 175 kill(getppid(), 3); 176 exit(0); 177 } 178 l = sizeof(a); 179 close(0); 180 if (accept(s1, (struct sockaddr *)&a, &l)) 181 exit(1); 182#endif 183 184 185#ifdef FD_SET 186 FD_SET(0, &f); 187#else 188 f = 1; 189#endif 190 if (select(1, &f, 0, 0, 0) == -1) 191 exit(1); 192 if (select(1, &f, &f, 0, 0) != 2) 193 exit(1); 194 exit(0); 195} 196],AC_NOTE(- select is ok), 197AC_NOTE(- select can't count) AC_DEFINE(SELECT_BROKEN)) 198 199dnl 200dnl **** termcap or terminfo **** 201dnl 202AC_CHECKING(for tgetent) 203AC_TRY_LINK(,tgetent((char *)0, (char *)0);,, 204olibs="$LIBS" 205LIBS="-lcurses $olibs" 206AC_CHECKING(libcurses) 207AC_TRY_LINK(,[ 208#ifdef __hpux 209__sorry_hpux_libcurses_is_totally_broken_in_10_10(); 210#else 211tgetent((char *)0, (char *)0); 212#endif 213],, 214LIBS="-ltermcap $olibs" 215AC_CHECKING(libtermcap) 216AC_TRY_LINK(,tgetent((char *)0, (char *)0);,, 217LIBS="-ltermlib $olibs" 218AC_CHECKING(libtermlib) 219AC_TRY_LINK(,tgetent((char *)0, (char *)0);,, 220LIBS="-lncurses $olibs" 221AC_CHECKING(libncurses) 222AC_TRY_LINK(,tgetent((char *)0, (char *)0);,, 223AC_MSG_ERROR(!!! no tgetent - no screen)))))) 224 225AC_TRY_RUN([ 226extern char *tgoto(); 227main() 228{ 229 exit(strcmp(tgoto("%p1%d", 0, 1), "1") ? 0 : 1); 230}], AC_NOTE(- you use the termcap database), 231AC_NOTE(- you use the terminfo database) AC_DEFINE(TERMINFO)) 232AC_CHECKING(ospeed) 233AC_TRY_LINK(extern short ospeed;,ospeed=5;,,AC_DEFINE(NEED_OSPEED)) 234 235dnl 236dnl **** PTY specific things **** 237dnl 238AC_CHECKING(for /dev/ptc) 239if test -r /dev/ptc; then 240AC_DEFINE(HAVE_DEV_PTC) 241fi 242 243AC_CHECKING(for SVR4 ptys) 244sysvr4ptys= 245if test -c /dev/ptmx ; then 246AC_TRY_LINK([],[ptsname(0);grantpt(0);unlockpt(0);],[AC_DEFINE(HAVE_SVR4_PTYS) 247sysvr4ptys=1]) 248fi 249 250AC_CHECK_FUNCS(getpt) 251 252dnl check for openpty() 253if test -z "$sysvr4ptys"; then 254AC_CHECK_FUNCS(openpty,, 255[AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY)] [LIBS="$LIBS -lutil"])]) 256fi 257 258AC_CHECKING(for ptyranges) 259if test -d /dev/ptym ; then 260pdir='/dev/ptym' 261else 262pdir='/dev' 263fi 264dnl SCO uses ptyp%d 265AC_EGREP_CPP(yes, 266[#ifdef M_UNIX 267 yes; 268#endif 269], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`) 270dnl if test -c /dev/ptyp19; then 271dnl ptys=`echo /dev/ptyp??` 272dnl else 273dnl ptys=`echo $pdir/pty??` 274dnl fi 275if test "$ptys" != "$pdir/pty??" ; then 276p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'` 277p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'` 278AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0") 279AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1") 280fi 281 282dnl **** pty mode/group handling **** 283dnl 284dnl support provided by Luke Mewburn <lm@rmit.edu.au>, 931222 285AC_ARG_WITH(pty-mode, [ --with-pty-mode=mode default mode for ptys], [ ptymode="${withval}" ]) 286AC_ARG_WITH(pty-group, [ --with-pty-group=group default group for ptys], [ ptygrp="${withval}" ]) 287test -n "$ptymode" || ptymode=0620 288if test -n "$ptygrp" ; then 289AC_DEFINE_UNQUOTED(PTYMODE, $ptymode) 290AC_DEFINE_UNQUOTED(PTYGROUP,$ptygrp) 291else 292 293AC_CHECKING(default tty permissions/group) 294rm -f conftest_grp 295AC_TRY_RUN([ 296#include <sys/types.h> 297#include <sys/stat.h> 298#include <stdio.h> 299main() 300{ 301 struct stat sb; 302 char *x,*ttyname(); 303 int om, m; 304 FILE *fp; 305 306 if (!(x = ttyname(0))) exit(1); 307 if (stat(x, &sb)) exit(1); 308 om = sb.st_mode; 309 if (om & 002) exit(0); 310 m = system("mesg y"); 311 if (m == -1 || m == 127) exit(1); 312 if (stat(x, &sb)) exit(1); 313 m = sb.st_mode; 314 if (chmod(x, om)) exit(1); 315 if (m & 002) exit(0); 316 if (sb.st_gid == getgid()) exit(1); 317 if (!(fp=fopen("conftest_grp", "w"))) 318 exit(1); 319 fprintf(fp, "%d\n", sb.st_gid); 320 fclose(fp); 321 exit(0); 322} 323],[ 324 if test -f conftest_grp; then 325 ptygrp=`cat conftest_grp` 326 AC_NOTE([- pty mode: $ptymode, group: $ptygrp]) 327 AC_DEFINE_UNQUOTED(PTYMODE, $ptymode) 328 AC_DEFINE_UNQUOTED(PTYGROUP,$ptygrp) 329 else 330 AC_NOTE(- ptys are world accessable) 331 fi 332],[ 333 WRITEPATH='' 334 XTERMPATH='' 335 AC_PATH_PROG(WRITEPATH, write) 336 AC_PATH_PROG(XTERMPATH, xterm) 337 found= 338 if test -n "$WRITEPATH$XTERMPATH"; then 339 findfollow= 340 lsfollow= 341 found=`find $WRITEPATH $XTERMPATH -follow -print 2>/dev/null` 342 if test -n "$found"; then 343 findfollow=-follow 344 lsfollow=L 345 fi 346 if test -n "$XTERMPATH"; then 347 ptygrpn=`ls -l$lsfollow $XTERMPATH | sed -n -e 1p | $AWK '{print $4}'` 348 if test tty != "$ptygrpn"; then 349 XTERMPATH= 350 fi 351 fi 352 fi 353 if test -n "$WRITEPATH$XTERMPATH"; then 354 found=`find $WRITEPATH $XTERMPATH $findfollow -perm -2000 -print` 355 if test -n "$found"; then 356 ptygrp=`ls -ln$lsfollow $found | sed -n -e 1p | $AWK '{print $4}'` 357 AC_NOTE([- pty mode: $ptymode, group: $ptygrp]) 358 AC_DEFINE_UNQUOTED(PTYMODE, $ptymode) 359 AC_DEFINE_UNQUOTED(PTYGROUP,$ptygrp) 360 else 361 AC_NOTE(- ptys are world accessable) 362 fi 363 else 364 AC_NOTE(- can't determine - assume ptys are world accessable) 365 fi 366 ] 367) 368rm -f conftest_grp 369fi 370 371dnl 372dnl **** signal handling **** 373dnl 374if test -n "$posix" ; then 375 376dnl POSIX has reliable signals with void return type. 377AC_NOTE(assuming posix signal definition) 378AC_DEFINE(SIGVOID) 379 380else 381 382AC_CHECKING(return type of signal handlers) 383AC_TRY_COMPILE( 384[#include <sys/types.h> 385#include <signal.h> 386#ifdef signal 387#undef signal 388#endif 389extern void (*signal ()) ();], [int i;], AC_DEFINE(SIGVOID)) 390AC_CHECKING(sigset) 391AC_TRY_LINK([ 392#include <sys/types.h> 393#include <signal.h> 394],[ 395#ifdef SIGVOID 396sigset(0, (void (*)())0); 397#else 398sigset(0, (int (*)())0); 399#endif 400], AC_DEFINE(USESIGSET)) 401AC_CHECKING(signal implementation) 402AC_TRY_RUN([ 403#include <sys/types.h> 404#include <signal.h> 405 406#ifndef SIGCLD 407#define SIGCLD SIGCHLD 408#endif 409#ifdef USESIGSET 410#define signal sigset 411#endif 412 413int got; 414 415#ifdef SIGVOID 416void 417#endif 418hand() 419{ 420 got++; 421} 422 423main() 424{ 425 /* on hpux we use sigvec to get bsd signals */ 426#ifdef __hpux 427 (void)signal(SIGCLD, hand); 428 kill(getpid(), SIGCLD); 429 kill(getpid(), SIGCLD); 430 if (got < 2) 431 exit(1); 432#endif 433 exit(0); 434} 435],,AC_DEFINE(SYSVSIGS)) 436 437fi 438 439AC_CHECK_HEADERS(sys/stropts.h sys/wait.h sgtty.h sys/select.h) 440AC_CHECK_HEADERS(term.h) 441 442AC_OUTPUT(Makefile) 443