home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / less3292.zip / configure.in < prev    next >
Text File  |  1996-09-03  |  6KB  |  200 lines

  1. dnl Process this file with autoconf to produce a configure script.
  2. AC_INIT(forwback.c)
  3. AC_CONFIG_HEADER(defines.h)
  4.  
  5. dnl Checks for programs.
  6. AC_PROG_CC
  7. AC_ISC_POSIX
  8. AC_PROG_GCC_TRADITIONAL
  9. AC_PROG_INSTALL
  10.  
  11. dnl Checks for libraries.
  12. AC_CHECK_LIB(ncurses, initscr, [have_ncurses=yes], [have_ncurses=no])
  13. AC_CHECK_LIB(curses, initscr, [have_curses=yes], [have_curses=no])
  14. AC_CHECK_LIB(termcap, tgetent, [have_termcap=yes], [have_termcap=no])
  15. AC_CHECK_LIB(termlib, tgetent, [have_termlib=yes], [have_termlib=no])
  16. dnl Regular expressions (regcmp) are in -lgen on Solaris 2,
  17. dnl and in -lintl on SCO Unix.
  18. AC_CHECK_LIB(gen, regcmp)
  19. AC_CHECK_LIB(intl, regcmp)
  20. AC_CHECK_LIB(PW, regcmp)
  21.  
  22. dnl Checks for terminal libraries
  23. dnl Solaris has curses & termcap, but they need libucb
  24. dnl which is broken, so we use termlib.
  25.  
  26. AC_MSG_CHECKING(for working terminal libraries)
  27. TERMLIBS=
  28. if test $have_ncurses = yes; then
  29.   TERMLIBS="$TERMLIBS -lncurses"
  30.   dnl Don't use -ltermcap with -lncurses (Linux doesn't like it).
  31. else
  32.   if test $have_curses = yes; then
  33.     TERMLIBS="$TERMLIBS -lcurses"
  34.   fi
  35.   if test $have_termcap = yes; then
  36.     TERMLIBS="$TERMLIBS -ltermcap"
  37.   fi
  38. fi
  39.  
  40. SAVE_LIBS=$LIBS
  41. LIBS="$LIBS $TERMLIBS"
  42. AC_TRY_LINK(, [tgetent(0); tgetflag(0); tgetnum(0); tgetstr(0);],
  43.   [termok=yes], [termok=no])
  44. if test $termok = yes; then
  45.   AC_MSG_RESULT(using $TERMLIBS)
  46. else
  47.   LIBS="$SAVE_LIBS"
  48.   if test $have_termlib = yes; then
  49.     LIBS="$LIBS -ltermlib"
  50.     AC_MSG_RESULT(using -ltermlib)
  51.   else
  52.     AC_MSG_RESULT(Cannot find terminal libraries - configure failed)
  53.     exit 1
  54.   fi
  55. fi
  56.  
  57. dnl Checks for header files.
  58. AC_HEADER_STDC
  59. AC_CHECK_HEADERS(ctype.h errno.h fcntl.h limits.h stdio.h string.h termcap.h termio.h termios.h time.h unistd.h values.h sys/ioctl.h sys/stream.h sys/ptem.h)
  60.  
  61. dnl Checks for identifiers.
  62. AC_TYPE_OFF_T
  63. AC_MSG_CHECKING(for void)
  64. AC_TRY_COMPILE(, [void *foo = 0;], 
  65.   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_VOID)], [AC_MSG_RESULT(no)])
  66. AC_MSG_CHECKING(for const)
  67. AC_TRY_COMPILE(, [const int foo = 0;], 
  68.   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CONST)], [AC_MSG_RESULT(no)])
  69. AC_MSG_CHECKING(for time_t)
  70. AC_TRY_COMPILE([#include <time.h>], [time_t t = 0;],
  71.   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_TIME_T)], [AC_MSG_RESULT(no)])
  72.  
  73. dnl Checks for functions and external variables.
  74. AC_TYPE_SIGNAL
  75. AC_CHECK_FUNCS(memcpy popen _setjmp sigsetmask stat strchr system)
  76.  
  77. dnl Some systems have termios.h but not the corresponding functions.
  78. AC_CHECK_FUNC(tcgetattr, AC_DEFINE(HAVE_TERMIOS_FUNCS))
  79.  
  80. AC_MSG_CHECKING(for fileno)
  81. AC_TRY_LINK([
  82. #if HAVE_STDIO_H
  83. #include <stdio.h>
  84. #endif], [static int x; x = fileno(stdin);],
  85.   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_FILENO)], [AC_MSG_RESULT(no)])
  86.  
  87. AC_MSG_CHECKING(for strerror)
  88. AC_TRY_LINK([
  89. #if HAVE_STDIO_H
  90. #include <stdio.h>
  91. #endif
  92. #if HAVE_STRING_H
  93. #include <string.h>
  94. #endif
  95. #if HAVE_ERRNO_H
  96. #include <errno.h>
  97. #endif], [static char *x; x = strerror(0);],
  98.   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_STRERROR)], [AC_MSG_RESULT(no)])
  99.  
  100. AC_MSG_CHECKING(for sys_errlist)
  101. AC_TRY_LINK(, [extern char *sys_errlist[]; static char **x; x = sys_errlist;], 
  102.   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_SYS_ERRLIST)], [AC_MSG_RESULT(no)])
  103.  
  104. have_errno=no
  105. AC_MSG_CHECKING(for errno)
  106. AC_TRY_LINK([
  107. #if HAVE_ERRNO_H
  108. #include <errno.h>
  109. #endif], [static int x; x = errno;], 
  110.   [AC_MSG_RESULT(yes - in errno.h); AC_DEFINE(HAVE_ERRNO) have_errno=yes])
  111. if test $have_errno = no; then
  112. AC_TRY_LINK([
  113. #if HAVE_ERRNO_H
  114. #include <errno.h>
  115. #endif], [extern int errno; static int x; x = errno;], 
  116.   [AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_ERRNO) AC_DEFINE(MUST_DEFINE_ERRNO)],
  117.   [AC_MSG_RESULT(no)])
  118. fi
  119.  
  120. AC_MSG_CHECKING(for locale)
  121. AC_TRY_LINK([#include <locale.h>
  122. #include <ctype.h>], [setlocale(LC_CTYPE,""); isprint(0); iscntrl(0);],
  123.   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_LOCALE)], [AC_MSG_RESULT(no)])
  124. AC_MSG_CHECKING(for ctype functions)
  125. AC_TRY_LINK([
  126. #if HAVE_CTYPE_H
  127. #include <ctype.h>
  128. #endif], [static int x; x = isupper(x); x = tolower(x); x = toupper(x);],
  129.   [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_UPPER_LOWER)], [AC_MSG_RESULT(no)])
  130.  
  131. dnl Checks for external variable ospeed in the termcap library.
  132. have_ospeed=no
  133. AC_MSG_CHECKING(termcap for ospeed)
  134. AC_TRY_LINK([
  135. #include <sys/types.h>
  136. #if HAVE_TERMIOS_H
  137. #include <termios.h>
  138. #endif
  139. #if HAVE_TERMCAP_H
  140. #include <termcap.h>
  141. #endif], [ospeed = 0;],
  142. [AC_MSG_RESULT(yes - in termcap.h); AC_DEFINE(HAVE_OSPEED) have_ospeed=yes])
  143. if test $have_ospeed = no; then
  144. AC_TRY_LINK(, [extern short ospeed; ospeed = 0;], 
  145.   [AC_MSG_RESULT(yes - must define); AC_DEFINE(HAVE_OSPEED) AC_DEFINE(MUST_DEFINE_OSPEED)],
  146.   [AC_MSG_RESULT(no)])
  147. fi
  148.  
  149. dnl Checks for regular expression functions.
  150. have_regex=no
  151. have_posix_regex=unknown
  152. AC_MSG_CHECKING(for regcomp)
  153. dnl Some versions of Solaris have a regcomp() function, but it doesn't work!
  154. dnl So we run a test program.  If we're cross-compiling, do it the old way.
  155. AC_TRY_RUN([
  156. #include <sys/types.h>
  157. #include <regex.h>
  158. main() { regex_t r; regmatch_t rm;
  159. if (regcomp(&r, "abc", 0)) exit(1);
  160. if (regexec(&r, "xabcy", 1, &rm, 0)) exit(1);
  161. exit(0); }],
  162.   have_posix_regex=yes, have_posix_regex=no, have_posix_regex=unknown)
  163. if test $have_posix_regex = yes; then
  164.   AC_MSG_RESULT(using POSIX regcomp)
  165.   AC_DEFINE(HAVE_POSIX_REGCOMP)
  166.   have_regex=yes
  167. elif test $have_posix_regex = unknown; then
  168.   AC_TRY_LINK([
  169. #include <sys/types.h>
  170. #include <regex.h>],
  171.   [regex_t *r; regfree(r);],
  172.   AC_MSG_RESULT(using POSIX regcomp)
  173.   AC_DEFINE(HAVE_POSIX_REGCOMP) have_regex=yes)
  174. else
  175.   AC_MSG_RESULT(no)
  176. fi
  177. if test $have_regex = no; then
  178. AC_CHECK_FUNC(regcmp, 
  179. AC_MSG_RESULT(using regcmp); AC_DEFINE(HAVE_REGCMP) have_regex=yes)
  180. fi
  181. if test $have_regex = no; then
  182. AC_TRY_LINK([
  183. #include "regexp.h"], [regcomp("");],
  184. AC_MSG_RESULT(using V8 regcomp); AC_DEFINE(HAVE_V8_REGCOMP) have_regex=yes)
  185. fi
  186. if test $have_regex = no && test -f ${srcdir}/regex.c; then
  187. AC_MSG_RESULT(using POSIX regcomp -- local source); AC_DEFINE(HAVE_POSIX_REGCOMP) REGEX_O='regex.$(O)' AC_SUBST(REGEX_O) have_regex=yes
  188. fi
  189. if test $have_regex = no && test -f ${srcdir}/regexp.c; then
  190. AC_MSG_RESULT(using V8 regcomp -- local source); AC_DEFINE(HAVE_V8_REGCOMP) REGEX_O='regexp.$(O)' AC_SUBST(REGEX_O) have_regex=yes
  191. fi
  192. if test $have_regex = no; then
  193. AC_MSG_RESULT(using re_comp); AC_CHECK_FUNC(re_comp, AC_DEFINE(HAVE_RE_COMP) have_regex=yes)
  194. fi
  195. if test $have_regex = no; then
  196. AC_MSG_RESULT(cannot find regular expression library); AC_DEFINE(NO_REGEX)
  197. fi
  198.  
  199. AC_OUTPUT(Makefile)
  200.