1 dnl Process this file with autoconf to produce a configure script.
4 AC_CONFIG_HEADER(config.h)
9 dnl Define some useful macros
11 AC_DEFUN(AC_PROGRAM_SOURCE,
12 [AC_REQUIRE([AC_PROG_CPP])AC_PROVIDE([$0])cat > conftest.c <<EOF
18 eval "$ac_cpp conftest.c 2>&5 | sed -e '1,/_CUT_HERE_/d' -e 's/ //g' > conftest.out"
24 [echo "$1" 1>&AC_FD_MSG
30 AC_PROG_GCC_TRADITIONAL
33 AC_TRY_RUN(main(){exit(0);},,[
34 if test $CC != cc ; then
35 AC_NOTE(Your $CC failed - restarting with CC=cc)
39 exec $0 $configure_args
43 AC_TRY_RUN(main(){exit(0);},,
46 AC_NOTE(CC=$CC; CFLAGS=$CFLAGS; LIBS=$LIBS;)
48 AC_MSG_ERROR(Can't run the compiler - sorry))
53 int __something_strange_();
54 __something_strange_(0);
56 ],AC_MSG_ERROR(Your compiler does not set the exit status - sorry))
60 if test -f etc/toolcheck; then
61 AC_CHECKING(for buggy tools)
62 sh etc/toolcheck 1>&AC_FD_MSG
66 dnl **** special unix variants ****
69 AC_CHECKING(for System V)
71 [#include <sys/types.h>
73 #include <fcntl.h>], [int x = SIGCHLD | FNDELAY;], , AC_DEFINE(SYSV))
75 AC_CHECKING(for Solaris 2.x)
77 [#if defined(SVR4) && defined(sun)
80 ], LIBS="$LIBS -lsocket -lnsl -lkstat")
83 dnl **** select() ****
87 AC_TRY_LINK(,[select(0, 0, 0, 0, 0);],,
88 LIBS="$LIBS -lnet -lnsl"
89 AC_CHECKING(select with $LIBS)
90 AC_TRY_LINK(,[select(0, 0, 0, 0, 0);],,
91 AC_MSG_ERROR(!!! no select - no screen))
94 dnl **** check the select implementation ****
97 AC_CHECKING(select return value)
99 #include <sys/types.h>
100 #include <sys/stat.h>
103 char *nam = "/tmp/conftest$$";
108 #define O_NONBLOCK O_NDELAY
111 #define S_IFIFO 0010000
124 /* From Andrew A. Chernov (ache@astral.msk.su):
125 * opening RDWR fifo fails in BSD 4.4, but select return values are
132 if (mkfifo(nam, 0777))
134 if (mknod(nam, S_IFIFO|0777, 0))
138 if (open(nam, O_RDWR | O_NONBLOCK))
140 if (write(0, "TEST", 4) == -1)
145 #include <sys/types.h>
146 #include <sys/socket.h>
152 struct sockaddr_un a;
160 if ((s1 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
162 a.sun_family = AF_UNIX;
163 strcpy(a.sun_path, nam);
165 if (bind(s1, (struct sockaddr *) &a, strlen(nam)+2) == -1)
171 if ((s2 = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
173 (void)connect(s2, (struct sockaddr *)&a, strlen(nam) + 2);
174 if (write(s2, "HELLO", 5) == -1)
180 if (accept(s1, (struct sockaddr *)&a, &l))
190 if (select(1, &f, 0, 0, 0) == -1)
192 if (select(1, &f, &f, 0, 0) != 2)
196 ],AC_NOTE(- select is ok),
197 AC_NOTE(- select can't count) AC_DEFINE(SELECT_BROKEN))
200 dnl **** termcap or terminfo ****
202 AC_CHECKING(for tgetent)
203 AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
205 LIBS="-lcurses $olibs"
206 AC_CHECKING(libcurses)
209 __sorry_hpux_libcurses_is_totally_broken_in_10_10();
211 tgetent((char *)0, (char *)0);
214 LIBS="-ltermcap $olibs"
215 AC_CHECKING(libtermcap)
216 AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
217 LIBS="-ltermlib $olibs"
218 AC_CHECKING(libtermlib)
219 AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
220 LIBS="-lncurses $olibs"
221 AC_CHECKING(libncurses)
222 AC_TRY_LINK(,tgetent((char *)0, (char *)0);,,
223 AC_MSG_ERROR(!!! no tgetent - no screen))))))
228 exit(strcmp(tgoto("%p1%d", 0, 1), "1") ? 0 : 1);
229 }], AC_NOTE(- you use the termcap database),
230 AC_NOTE(- you use the terminfo database) AC_DEFINE(TERMINFO))
232 AC_TRY_LINK(extern short ospeed;,ospeed=5;,,AC_DEFINE(NEED_OSPEED))
235 dnl **** PTY specific things ****
237 AC_CHECKING(for /dev/ptc)
238 if test -r /dev/ptc; then
239 AC_DEFINE(HAVE_DEV_PTC)
242 AC_CHECKING(for SVR4 ptys)
244 if test -c /dev/ptmx ; then
245 AC_TRY_LINK([],[ptsname(0);grantpt(0);unlockpt(0);],[AC_DEFINE(HAVE_SVR4_PTYS)
249 AC_CHECK_FUNCS(getpt)
251 dnl check for openpty()
252 if test -z "$sysvr4ptys"; then
253 AC_CHECK_FUNCS(openpty,,
254 [AC_CHECK_LIB(util,openpty, [AC_DEFINE(HAVE_OPENPTY)] [LIBS="$LIBS -lutil"])])
257 AC_CHECKING(for ptyranges)
258 if test -d /dev/ptym ; then
268 ], ptys=`echo /dev/ptyp??`, ptys=`echo $pdir/pty??`)
269 dnl if test -c /dev/ptyp19; then
270 dnl ptys=`echo /dev/ptyp??`
272 dnl ptys=`echo $pdir/pty??`
274 if test "$ptys" != "$pdir/pty??" ; then
275 p0=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\).$/\1/g' | sort -u | tr -d '\012'`
276 p1=`echo $ptys | tr ' ' '\012' | sed -e 's/^.*\(.\)$/\1/g' | sort -u | tr -d '\012'`
277 AC_DEFINE_UNQUOTED(PTYRANGE0,"$p0")
278 AC_DEFINE_UNQUOTED(PTYRANGE1,"$p1")
281 dnl **** pty mode/group handling ****
283 dnl support provided by Luke Mewburn <lm@rmit.edu.au>, 931222
284 AC_ARG_WITH(pty-mode, [ --with-pty-mode=mode default mode for ptys], [ ptymode="${withval}" ])
285 AC_ARG_WITH(pty-group, [ --with-pty-group=group default group for ptys], [ ptygrp="${withval}" ])
286 test -n "$ptymode" || ptymode=0620
287 if test -n "$ptygrp" ; then
288 AC_DEFINE_UNQUOTED(PTYMODE, $ptymode)
289 AC_DEFINE_UNQUOTED(PTYGROUP,$ptygrp)
292 AC_CHECKING(default tty permissions/group)
295 #include <sys/types.h>
296 #include <sys/stat.h>
305 if (!(x = ttyname(0))) exit(1);
306 if (stat(x, &sb)) exit(1);
308 if (om & 002) exit(0);
309 m = system("mesg y");
310 if (m == -1 || m == 127) exit(1);
311 if (stat(x, &sb)) exit(1);
313 if (chmod(x, om)) exit(1);
314 if (m & 002) exit(0);
315 if (sb.st_gid == getgid()) exit(1);
316 if (!(fp=fopen("conftest_grp", "w")))
318 fprintf(fp, "%d\n", sb.st_gid);
323 if test -f conftest_grp; then
324 ptygrp=`cat conftest_grp`
325 AC_NOTE([- pty mode: $ptymode, group: $ptygrp])
326 AC_DEFINE_UNQUOTED(PTYMODE, $ptymode)
327 AC_DEFINE_UNQUOTED(PTYGROUP,$ptygrp)
329 AC_NOTE(- ptys are world accessable)
334 AC_PATH_PROG(WRITEPATH, write)
335 AC_PATH_PROG(XTERMPATH, xterm)
337 if test -n "$WRITEPATH$XTERMPATH"; then
340 found=`find $WRITEPATH $XTERMPATH -follow -print 2>/dev/null`
341 if test -n "$found"; then
345 if test -n "$XTERMPATH"; then
346 ptygrpn=`ls -l$lsfollow $XTERMPATH | sed -n -e 1p | $AWK '{print $4}'`
347 if test tty != "$ptygrpn"; then
352 if test -n "$WRITEPATH$XTERMPATH"; then
353 found=`find $WRITEPATH $XTERMPATH $findfollow -perm -2000 -print`
354 if test -n "$found"; then
355 ptygrp=`ls -ln$lsfollow $found | sed -n -e 1p | $AWK '{print $4}'`
356 AC_NOTE([- pty mode: $ptymode, group: $ptygrp])
357 AC_DEFINE_UNQUOTED(PTYMODE, $ptymode)
358 AC_DEFINE_UNQUOTED(PTYGROUP,$ptygrp)
360 AC_NOTE(- ptys are world accessable)
363 AC_NOTE(- can't determine - assume ptys are world accessable)
371 dnl **** signal handling ****
373 if test -n "$posix" ; then
375 dnl POSIX has reliable signals with void return type.
376 AC_NOTE(assuming posix signal definition)
381 AC_CHECKING(return type of signal handlers)
383 [#include <sys/types.h>
388 extern void (*signal ()) ();], [int i;], AC_DEFINE(SIGVOID))
391 #include <sys/types.h>
395 sigset(0, (void (*)())0);
397 sigset(0, (int (*)())0);
399 ], AC_DEFINE(USESIGSET))
400 AC_CHECKING(signal implementation)
402 #include <sys/types.h>
406 #define SIGCLD SIGCHLD
409 #define signal sigset
424 /* on hpux we use sigvec to get bsd signals */
426 (void)signal(SIGCLD, hand);
427 kill(getpid(), SIGCLD);
428 kill(getpid(), SIGCLD);
434 ],,AC_DEFINE(SYSVSIGS))