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