configure.in 8.8 KB

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