1 dnl Process this file with autoconf to produce a configure script.
3 m4_include([../../../config/override.m4])
6 AC_CONFIG_HEADER(config.h)
11 dnl Define some useful macros
13 AC_DEFUN([AC_PROGRAM_SOURCE],
14 [AC_REQUIRE([AC_PROG_CPP])AC_PROVIDE([$0])cat > conftest.c <<EOF
20 eval "$ac_cpp conftest.c 2>&5 | sed -e '1,/_CUT_HERE_/d' -e 's/ //g' > conftest.out"
26 [echo "$1" 1>&AC_FD_MSG
32 AC_PROG_GCC_TRADITIONAL
35 AC_TRY_RUN(main(){exit(0);},,[
36 if test $CC != cc ; then
37 AC_NOTE(Your $CC failed - restarting with CC=cc)
41 exec $0 $configure_args
45 AC_TRY_RUN(main(){exit(0);},,
48 AC_NOTE(CC=$CC; CFLAGS=$CFLAGS; LIBS=$LIBS;)
50 AC_MSG_ERROR(Can't run the compiler - sorry))
55 int __something_strange_();
56 __something_strange_(0);
58 ],AC_MSG_ERROR(Your compiler does not set the exit status - sorry))
62 if test -f etc/toolcheck; then
63 AC_CHECKING(for buggy tools)
64 sh etc/toolcheck 1>&AC_FD_MSG
68 dnl **** special unix variants ****
71 AC_CHECKING(for System V)
73 [#include <sys/types.h>
75 #include <fcntl.h>], [int x = SIGCHLD | FNDELAY;], , AC_DEFINE(SYSV))
77 AC_CHECKING(for Solaris 2.x)
79 [#if defined(SVR4) && defined(sun)
82 ], LIBS="$LIBS -lsocket -lnsl -lkstat")
85 dnl **** select() ****
89 AC_TRY_LINK(,[select(0, 0, 0, 0, 0);],,
90 LIBS="$LIBS -lnet -lnsl"
91 AC_CHECKING(select with $LIBS)
92 AC_TRY_LINK(,[select(0, 0, 0, 0, 0);],,
93 AC_MSG_ERROR(!!! no select - no screen))
96 dnl **** check the select implementation ****
99 AC_CHECKING(select return value)
101 #include <sys/types.h>
102 #include <sys/stat.h>
105 char *nam = "/tmp/conftest$$";
110 #define O_NONBLOCK O_NDELAY
113 #define S_IFIFO 0010000
126 /* From Andrew A. Chernov (ache@astral.msk.su):
127 * opening RDWR fifo fails in BSD 4.4, but select return values are
134 if (mkfifo(nam, 0777))
136 if (mknod(nam, S_IFIFO|0777, 0))
140 if (open(nam, O_RDWR | O_NONBLOCK))
142 if (write(0, "TEST", 4) == -1)
147 #include <sys/types.h>
148 #include <sys/socket.h>
154 struct sockaddr_un a;
162 if ((s1 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
164 a.sun_family = AF_UNIX;
165 strcpy(a.sun_path, nam);
167 if (bind(s1, (struct sockaddr *) &a, strlen(nam)+2) == -1)
173 if ((s2 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
175 (void)connect(s2, (struct sockaddr *)&a, strlen(nam) + 2);
176 if (write(s2, "HELLO", 5) == -1)
182 if (accept(s1, (struct sockaddr *)&a, &l))
192 if (select(1, &f, 0, 0, 0) == -1)
194 if (select(1, &f, &f, 0, 0) != 2)
198 ],AC_NOTE(- select is ok),
199 AC_NOTE(- select can't count) AC_DEFINE(SELECT_BROKEN))
202 dnl **** termcap or terminfo ****
204 AC_CHECKING(for tgetent)
205 AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
207 LIBS="-lcurses $olibs"
208 AC_CHECKING(libcurses)
211 __sorry_hpux_libcurses_is_totally_broken_in_10_10();
213 tgetent((char *)0, (char *)0);
216 LIBS="-ltermcap $olibs"
217 AC_CHECKING(libtermcap)
218 AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
219 LIBS="-ltermlib $olibs"
220 AC_CHECKING(libtermlib)
221 AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
222 LIBS="-lncurses $olibs"
223 AC_CHECKING(libncurses)
224 AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
225 AC_MSG_ERROR(!!! no tgetent - no screen))))))
230 exit(strcmp(tgoto("%p1%d", 0, 1), "1") ? 0 : 1);
231 }], AC_NOTE(- you use the termcap database),
232 AC_NOTE(- you use the terminfo database) AC_DEFINE(TERMINFO))
234 AC_TRY_LINK(extern short ospeed;,ospeed=5;,,AC_DEFINE(NEED_OSPEED))
237 dnl **** PTY specific things ****
239 AC_CHECKING(for /dev/ptc)
240 if test -r /dev/ptc; then
241 AC_DEFINE(HAVE_DEV_PTC)
244 AC_CHECKING(for SVR4 ptys)
246 if test -c /dev/ptmx ; then
247 AC_TRY_LINK([],[ptsname(0);grantpt(0);unlockpt(0);],[AC_DEFINE(HAVE_SVR4_PTYS)
251 AC_CHECK_FUNCS(getpt)
253 dnl check for openpty()
254 if test -z "$sysvr4ptys"; then
255 AC_CHECK_FUNCS(openpty,,
256 [AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY)] [LIBS="$LIBS -lutil"])])
259 AC_CHECKING(for ptyranges)
260 if test -d /dev/ptym ; then
270 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
271 dnl if test -c /dev/ptyp19; then
272 dnl ptys=`echo /dev/ptyp??`
274 dnl ptys=`echo $pdir/pty??`
276 if test "$ptys" != "$pdir/pty??" ; then
277 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
278 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
279 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
280 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
283 dnl **** pty mode/group handling ****
285 dnl support provided by Luke Mewburn <lm@rmit.edu.au>, 931222
286 AC_ARG_WITH(pty-mode, [ --with-pty-mode=mode default mode for ptys], [ ptymode="${withval}" ])
287 AC_ARG_WITH(pty-group, [ --with-pty-group=group default group for ptys], [ ptygrp="${withval}" ])
288 test -n "$ptymode" || ptymode=0620
289 if test -n "$ptygrp" ; then
290 AC_DEFINE_UNQUOTED(PTYMODE, $ptymode)
291 AC_DEFINE_UNQUOTED(PTYGROUP,$ptygrp)
294 AC_CHECKING(default tty permissions/group)
297 #include <sys/types.h>
298 #include <sys/stat.h>
307 if (!(x = ttyname(0))) exit(1);
308 if (stat(x, &sb)) exit(1);
310 if (om & 002) exit(0);
311 m = system("mesg y");
312 if (m == -1 || m == 127) exit(1);
313 if (stat(x, &sb)) exit(1);
315 if (chmod(x, om)) exit(1);
316 if (m & 002) exit(0);
317 if (sb.st_gid == getgid()) exit(1);
318 if (!(fp=fopen("conftest_grp", "w")))
320 fprintf(fp, "%d\n", sb.st_gid);
325 if test -f conftest_grp; then
326 ptygrp=`cat conftest_grp`
327 AC_NOTE([- pty mode: $ptymode, group: $ptygrp])
328 AC_DEFINE_UNQUOTED(PTYMODE, $ptymode)
329 AC_DEFINE_UNQUOTED(PTYGROUP,$ptygrp)
331 AC_NOTE(- ptys are world accessable)
336 AC_PATH_PROG(WRITEPATH, write)
337 AC_PATH_PROG(XTERMPATH, xterm)
339 if test -n "$WRITEPATH$XTERMPATH"; then
342 found=`find $WRITEPATH $XTERMPATH -follow -print 2>/dev/null`
343 if test -n "$found"; then
347 if test -n "$XTERMPATH"; then
348 ptygrpn=`ls -l$lsfollow $XTERMPATH | sed -n -e 1p | $AWK '{print $4}'`
349 if test tty != "$ptygrpn"; then
354 if test -n "$WRITEPATH$XTERMPATH"; then
355 found=`find $WRITEPATH $XTERMPATH $findfollow -perm -2000 -print`
356 if test -n "$found"; then
357 ptygrp=`ls -ln$lsfollow $found | sed -n -e 1p | $AWK '{print $4}'`
358 AC_NOTE([- pty mode: $ptymode, group: $ptygrp])
359 AC_DEFINE_UNQUOTED(PTYMODE, $ptymode)
360 AC_DEFINE_UNQUOTED(PTYGROUP,$ptygrp)
362 AC_NOTE(- ptys are world accessable)
365 AC_NOTE(- can't determine - assume ptys are world accessable)
373 dnl **** signal handling ****
375 if test -n "$posix" ; then
377 dnl POSIX has reliable signals with void return type.
378 AC_NOTE(assuming posix signal definition)
383 AC_CHECKING(return type of signal handlers)
385 [#include <sys/types.h>
390 extern void (*signal ()) ();], [int i;], AC_DEFINE(SIGVOID))
393 #include <sys/types.h>
397 sigset(0, (void (*)())0);
399 sigset(0, (int (*)())0);
401 ], AC_DEFINE(USESIGSET))
402 AC_CHECKING(signal implementation)
404 #include <sys/types.h>
408 #define SIGCLD SIGCHLD
411 #define signal sigset
426 /* on hpux we use sigvec to get bsd signals */
428 (void)signal(SIGCLD, hand);
429 kill(getpid(), SIGCLD);
430 kill(getpid(), SIGCLD);
436 ],,AC_DEFINE(SYSVSIGS))