home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / vile-src.zip / vile-8.1 / aclocal.m4 next >
M4 Source File  |  1998-08-30  |  42KB  |  1,452 lines

  1. dnl Local definitions for autoconf.
  2. dnl
  3. dnl $Header: /usr/build/vile/vile/RCS/aclocal.m4,v 1.60 1998/08/30 22:46:51 tom Exp $
  4. dnl
  5. dnl ---------------------------------------------------------------------------
  6. dnl ---------------------------------------------------------------------------
  7. dnl CF_PREREQ_COMPARE(MAJOR1, MINOR1, TERNARY1, MAJOR2, MINOR2, TERNARY2,
  8. dnl                   PRINTABLE2, not FOUND, FOUND)
  9. define(CF_PREREQ_COMPARE,
  10. [ifelse(builtin([eval], [$3 < $6]), 1,
  11. ifelse([$8], , ,[$8]),
  12. ifelse([$9], , ,[$9]))])dnl
  13. dnl ---------------------------------------------------------------------------
  14. dnl Conditionally generate script according to whether we're using the release
  15. dnl version of autoconf, or a patched version (using the ternary component as
  16. dnl the patch-version).
  17. define(CF_AC_PREREQ,
  18. [CF_PREREQ_COMPARE(
  19. AC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)),
  20. AC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])), [$1], [$2], [$3])])dnl
  21. dnl ---------------------------------------------------------------------------
  22. dnl Add an include-directory to $CPPFLAGS.  Don't add /usr/include, since it's
  23. dnl redundant.  We don't normally need to add -I/usr/local/include for gcc,
  24. dnl but old versions (and some misinstalled ones) need that.
  25. AC_DEFUN([CF_ADD_INCDIR],
  26. [
  27. for cf_add_incdir in $1
  28. do
  29.     while true
  30.     do
  31.         case $cf_add_incdir in
  32.         /usr/include) # (vi
  33.             ;;
  34.         *) # (vi
  35.             CPPFLAGS="$CPPFLAGS -I$cf_add_incdir"
  36.             ;;
  37.         esac
  38.         cf_top_incdir=`echo $cf_add_incdir | sed -e 's:/include/.*$:/include:'`
  39.         test "$cf_top_incdir" = "$cf_add_incdir" && break
  40.         cf_add_incdir="$cf_top_incdir"
  41.     done
  42. done
  43. ])dnl
  44. dnl ---------------------------------------------------------------------------
  45. dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES'
  46. dnl in the sharutils 4.2 distribution.
  47. AC_DEFUN([CF_ANSI_CC_CHECK],
  48. [
  49. AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C)
  50. AC_CACHE_VAL(cf_cv_ansi_cc,[
  51. cf_cv_ansi_cc=no
  52. cf_save_CFLAGS="$CFLAGS"
  53. # Don't try gcc -ansi; that turns off useful extensions and
  54. # breaks some systems' header files.
  55. # AIX            -qlanglvl=ansi
  56. # Ultrix and OSF/1    -std1
  57. # HP-UX            -Aa -D_HPUX_SOURCE
  58. # SVR4            -Xc
  59. # UnixWare 1.2        (cannot use -Xc, since ANSI/POSIX clashes)
  60. for cf_arg in "-DCC_HAS_PROTOS" \
  61.     "" \
  62.     -qlanglvl=ansi \
  63.     -std1 \
  64.     "-Aa -D_HPUX_SOURCE +e" \
  65.     "-Aa -D_HPUX_SOURCE" \
  66.     -Xc
  67. do
  68.     CFLAGS="$cf_save_CFLAGS $cf_arg"
  69.     AC_TRY_COMPILE(
  70. [
  71. #ifndef CC_HAS_PROTOS
  72. #if !defined(__STDC__) || __STDC__ != 1
  73. choke me
  74. #endif
  75. #endif
  76. ],[
  77.     int test (int i, double x);
  78.     struct s1 {int (*f) (int a);};
  79.     struct s2 {int (*f) (double a);};],
  80.     [cf_cv_ansi_cc="$cf_arg"; break])
  81. done
  82. CFLAGS="$cf_save_CFLAGS"
  83. ])
  84. AC_MSG_RESULT($cf_cv_ansi_cc)
  85.  
  86. if test "$cf_cv_ansi_cc" != "no"; then
  87. if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then
  88.     CFLAGS="$CFLAGS $cf_cv_ansi_cc"
  89. else
  90.     AC_DEFINE(CC_HAS_PROTOS)
  91. fi
  92. fi
  93. ])dnl
  94. dnl ---------------------------------------------------------------------------
  95. dnl For programs that must use an ANSI compiler, obtain compiler options that
  96. dnl will make it recognize prototypes.  We'll do preprocessor checks in other
  97. dnl macros, since tools such as unproto can fake prototypes, but only part of
  98. dnl the preprocessor.
  99. AC_DEFUN([CF_ANSI_CC_REQD],
  100. [AC_REQUIRE([CF_ANSI_CC_CHECK])
  101. if test "$cf_cv_ansi_cc" = "no"; then
  102.     AC_ERROR(
  103. [Your compiler does not appear to recognize prototypes.
  104. You have the following choices:
  105.     a. adjust your compiler options
  106.     b. get an up-to-date compiler
  107.     c. use a wrapper such as unproto])
  108. fi
  109. ])dnl
  110. dnl ---------------------------------------------------------------------------
  111. dnl Test if we should use ANSI-style prototype for qsort's compare-function
  112. AC_DEFUN([CF_ANSI_QSORT],
  113. [
  114. AC_MSG_CHECKING([for standard qsort])
  115. AC_CACHE_VAL(cf_cv_ansi_qsort,[
  116.     AC_TRY_COMPILE([
  117. #if HAVE_STDLIB_H
  118. #include <stdlib.h>
  119. #endif
  120.     int compare(const void *a, const void *b)
  121.     { return (*(int *)a - *(int *)b); } ],
  122.     [ extern long *vector;
  123.       qsort(vector, 1, 1, compare); ],
  124.     [cf_cv_ansi_qsort=yes],
  125.     [cf_cv_ansi_qsort=no])
  126. ])
  127. AC_MSG_RESULT($cf_cv_ansi_qsort)
  128. if test $cf_cv_ansi_qsort = yes; then
  129.     AC_DEFINE(ANSI_QSORT,1)
  130. else
  131.     AC_DEFINE(ANSI_QSORT,0)
  132. fi
  133. ])dnl
  134. dnl ---------------------------------------------------------------------------
  135. dnl Allow user to disable a normally-on option.
  136. AC_DEFUN([CF_ARG_DISABLE],
  137. [CF_ARG_OPTION($1,[$2 (default: on)],[$3],[$4],yes)])dnl
  138. dnl ---------------------------------------------------------------------------
  139. dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus
  140. dnl values.
  141. dnl
  142. dnl Parameters:
  143. dnl $1 = option name
  144. dnl $2 = help-string
  145. dnl $3 = action to perform if option is not default
  146. dnl $4 = action if perform if option is default
  147. dnl $5 = default option value (either 'yes' or 'no')
  148. AC_DEFUN([CF_ARG_OPTION],
  149. [AC_ARG_ENABLE($1,[$2],[test "$enableval" != ifelse($5,no,yes,no) && enableval=ifelse($5,no,no,yes)
  150.   if test "$enableval" != "$5" ; then
  151. ifelse($3,,[    :]dnl
  152. ,[    $3]) ifelse($4,,,[
  153.   else
  154.     $4])
  155.   fi],[enableval=$5 ifelse($4,,,[
  156.   $4
  157. ])dnl
  158.   ])])dnl
  159. dnl ---------------------------------------------------------------------------
  160. dnl Check if the C compiler supports initialization of unions.
  161. AC_DEFUN([CF_CC_INIT_UNIONS],[
  162. AC_CACHE_CHECK(if we can initialize unions,
  163. cf_cv_init_unions,[
  164.     AC_TRY_COMPILE([],
  165.     [static struct foo {int x; union {double a; int b; } bar; } c = {0,{1.0}}],
  166.     [cf_cv_init_unions=yes],
  167.     [cf_cv_init_unions=no])
  168.     ])
  169. test $cf_cv_init_unions = no && AC_DEFINE(CC_CANNOT_INIT_UNIONS)
  170. ])dnl
  171. dnl ---------------------------------------------------------------------------
  172. dnl Check if the C compiler supports offsetof expressions in switch cases.
  173. dnl Some losing compiler's can be found on pyramid's, aix, and Apple's AUX2.
  174. dnl (Lint on several platforms will complain, even when the compiler won't).
  175. AC_DEFUN([CF_CC_OFFSETOF_CASES],[
  176. AC_CACHE_CHECK(if switch cases work with structure offsets,
  177. cf_cv_case_offsetof,[
  178.     AC_TRY_COMPILE([],
  179.     [struct foo {int a,b;};
  180.      extern getpid();
  181.      switch(getpid()){case ((int) &(((struct foo *)0)->b)) : printf("foo"); } ],
  182.     [cf_cv_case_offsetof=yes],
  183.     [cf_cv_case_offsetof=no])
  184.     ])
  185. test $cf_cv_case_offsetof = no && AC_DEFINE(CC_CANNOT_OFFSET_CASES)
  186. ])dnl
  187. dnl ---------------------------------------------------------------------------
  188. dnl Check if we're accidentally using a cache from a different machine.
  189. dnl Derive the system name, as a check for reusing the autoconf cache.
  190. dnl
  191. dnl If we've packaged config.guess and config.sub, run that (since it does a
  192. dnl better job than uname).
  193. AC_DEFUN([CF_CHECK_CACHE],
  194. [
  195. if test -f $srcdir/config.guess ; then
  196.     AC_CANONICAL_HOST
  197.     system_name="$host_os"
  198. else
  199.     system_name="`(uname -s -r) 2>/dev/null`"
  200.     if test -z "$system_name" ; then
  201.         system_name="`(hostname) 2>/dev/null`"
  202.     fi
  203. fi
  204. test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name")
  205. AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"])
  206.  
  207. test -z "$system_name" && system_name="$cf_cv_system_name"
  208. test -n "$cf_cv_system_name" && AC_MSG_RESULT("Configuring for $cf_cv_system_name")
  209.  
  210. if test ".$system_name" != ".$cf_cv_system_name" ; then
  211.     AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name))
  212.     AC_ERROR("Please remove config.cache and try again.")
  213. fi
  214. ])dnl
  215. dnl ---------------------------------------------------------------------------
  216. dnl Check for data that is usually declared in <stdio.h> or <errno.h>
  217. dnl $1 = the name to check
  218. AC_DEFUN([CF_CHECK_ERRNO],
  219. [
  220. AC_MSG_CHECKING([declaration of $1])
  221. AC_CACHE_VAL(cf_cv_dcl_$1,[
  222.     AC_TRY_COMPILE([
  223. #if HAVE_STDLIB_H
  224. #include <stdlib.h>
  225. #endif
  226. #include <stdio.h>
  227. #include <sys/types.h>
  228. #include <errno.h> ],
  229.     [long x = (long) $1],
  230.     [eval 'cf_cv_dcl_'$1'=yes'],
  231.     [eval 'cf_cv_dcl_'$1'=no]')])
  232. eval 'cf_result=$cf_cv_dcl_'$1
  233. AC_MSG_RESULT($cf_result)
  234.  
  235. # It's possible (for near-UNIX clones) that the data doesn't exist
  236. AC_CACHE_VAL(cf_cv_have_$1,[
  237. if test $cf_result = no ; then
  238.     eval 'cf_result=DECL_'$1
  239.     CF_UPPER(cf_result,$cf_result)
  240.     AC_DEFINE_UNQUOTED($cf_result)
  241.     AC_MSG_CHECKING([existence of $1])
  242.         AC_TRY_LINK([
  243. #undef $1
  244. extern long $1;
  245. ],
  246.             [$1 = 2],
  247.             [eval 'cf_cv_have_'$1'=yes'],
  248.             [eval 'cf_cv_have_'$1'=no'])
  249.         eval 'cf_result=$cf_cv_have_'$1
  250.         AC_MSG_RESULT($cf_result)
  251. else
  252.     eval 'cf_cv_have_'$1'=yes'
  253. fi
  254. ])
  255. eval 'cf_result=HAVE_'$1
  256. CF_UPPER(cf_result,$cf_result)
  257. eval 'test $cf_cv_have_'$1' = yes && AC_DEFINE_UNQUOTED($cf_result)'
  258. ])dnl
  259. dnl ---------------------------------------------------------------------------
  260. dnl Check if we should include <curses.h> to pick up prototypes for termcap
  261. dnl functions.  On terminfo systems, these are normally declared in <curses.h>,
  262. dnl but may be in <term.h>.  We check for termcap.h as an alternate, but it
  263. dnl isn't standard (usually associated with GNU termcap).
  264. dnl
  265. dnl The 'tgoto()' function is declared in both terminfo and termcap.
  266. dnl
  267. dnl See CF_TYPE_OUTCHAR for more details.
  268. AC_DEFUN([CF_CURSES_TERMCAP],
  269. [
  270. AC_REQUIRE([CF_CURSES_TERM_H])
  271. AC_MSG_CHECKING(if we should include curses.h or termcap.h)
  272. AC_CACHE_VAL(cf_cv_need_curses_h,[
  273. cf_save_CFLAGS="$CFLAGS"
  274. cf_cv_need_curses_h=no
  275.  
  276. for cf_t_opts in "" "NEED_TERMCAP_H"
  277. do
  278. for cf_c_opts in "" "NEED_CURSES_H"
  279. do
  280.  
  281.     CFLAGS="$cf_save_CFLAGS $CHECK_DECL_FLAG"
  282.     test -n "$cf_c_opts" && CFLAGS="$CFLAGS -D$cf_c_opts"
  283.     test -n "$cf_t_opts" && CFLAGS="$CFLAGS -D$cf_t_opts"
  284.  
  285.     AC_TRY_LINK([/* $cf_c_opts $cf_t_opts */
  286. $CHECK_DECL_HDRS],
  287.     [char *x = (char *)tgoto("")],
  288.     [test "$cf_cv_need_curses_h" = no && {
  289.          cf_cv_need_curses_h=maybe
  290.          cf_ok_c_opts=$cf_c_opts
  291.          cf_ok_t_opts=$cf_t_opts
  292.     }],
  293.     [echo "Recompiling with corrected call (C:$cf_c_opts, T:$cf_t_opts)" >&AC_FD_CC
  294.     AC_TRY_LINK([
  295. $CHECK_DECL_HDRS],
  296.     [char *x = (char *)tgoto("",0,0)],
  297.     [cf_cv_need_curses_h=yes
  298.      cf_ok_c_opts=$cf_c_opts
  299.      cf_ok_t_opts=$cf_t_opts])])
  300.  
  301.     CFLAGS="$cf_save_CFLAGS"
  302.     test "$cf_cv_need_curses_h" = yes && break
  303. done
  304.     test "$cf_cv_need_curses_h" = yes && break
  305. done
  306.  
  307. if test "$cf_cv_need_curses_h" != no ; then
  308.     echo "Curses/termcap test = $cf_cv_need_curses_h (C:$cf_ok_c_opts, T:$cf_ok_t_opts)" >&AC_FD_CC
  309.     if test -n "$cf_ok_c_opts" ; then
  310.         if test -n "$cf_ok_t_opts" ; then
  311.             cf_cv_need_curses_h=both
  312.         else
  313.             cf_cv_need_curses_h=curses.h
  314.         fi
  315.     elif test -n "$cf_ok_t_opts" ; then
  316.         cf_cv_need_curses_h=termcap.h
  317.     elif test "$cf_cv_have_term_h" = yes ; then
  318.         cf_cv_need_curses_h=term.h
  319.     else
  320.         cf_cv_need_curses_h=no
  321.     fi
  322. fi
  323. ])
  324. AC_MSG_RESULT($cf_cv_need_curses_h)
  325.  
  326. case $cf_cv_need_curses_h in
  327. both) #(vi
  328.     AC_DEFINE_UNQUOTED(NEED_CURSES_H)
  329.     AC_DEFINE_UNQUOTED(NEED_TERMCAP_H)
  330.     ;;
  331. curses.h) #(vi
  332.     AC_DEFINE_UNQUOTED(NEED_CURSES_H)
  333.     ;;
  334. termcap.h) #(vi
  335.     AC_DEFINE_UNQUOTED(NEED_TERMCAP_H)
  336.     ;;
  337. esac
  338.  
  339. ])dnl
  340. dnl ---------------------------------------------------------------------------
  341. dnl SVr4 curses should have term.h as well (where it puts the definitions of
  342. dnl the low-level interface).  This may not be true in old/broken implementations,
  343. dnl as well as in misconfigured systems (e.g., gcc configured for Solaris 2.4
  344. dnl running with Solaris 2.5.1).
  345. AC_DEFUN([CF_CURSES_TERM_H],
  346. [
  347. AC_MSG_CHECKING([for term.h])
  348. AC_CACHE_VAL(cf_cv_have_term_h,[
  349.     AC_TRY_COMPILE([
  350. #include <curses.h>
  351. #include <term.h>],
  352.     [WINDOW *x],
  353.     [cf_cv_have_term_h=yes],
  354.     [cf_cv_have_term_h=no])
  355.     ])
  356. AC_MSG_RESULT($cf_cv_have_term_h)
  357. test $cf_cv_have_term_h = yes && AC_DEFINE(HAVE_TERM_H)
  358. ])dnl
  359. dnl ---------------------------------------------------------------------------
  360. dnl You can always use "make -n" to see the actual options, but it's hard to
  361. dnl pick out/analyze warning messages when the compile-line is long.
  362. dnl
  363. dnl Sets:
  364. dnl    ECHO_LD - symbol to prefix "cc -o" lines
  365. dnl    RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o)
  366. dnl    SHOW_CC - symbol to put before explicit "cc -c" lines
  367. dnl    ECHO_CC - symbol to put before any "cc" line
  368. dnl
  369. AC_DEFUN([CF_DISABLE_ECHO],[
  370. AC_MSG_CHECKING(if you want to see long compiling messages)
  371. CF_ARG_DISABLE(echo,
  372.     [  --disable-echo          test: display "compiling" commands],
  373.     [
  374.     ECHO_LD='@echo linking [$]@;'
  375.     RULE_CC='    @echo compiling [$]<'
  376.     SHOW_CC='    @echo compiling [$]@'
  377.     ECHO_CC='@'
  378. ],[
  379.     ECHO_LD=''
  380.     RULE_CC='# compiling'
  381.     SHOW_CC='# compiling'
  382.     ECHO_CC=''
  383. ])
  384. AC_MSG_RESULT($enableval)
  385. AC_SUBST(ECHO_LD)
  386. AC_SUBST(RULE_CC)
  387. AC_SUBST(SHOW_CC)
  388. AC_SUBST(ECHO_CC)
  389. ])dnl
  390. dnl ---------------------------------------------------------------------------
  391. dnl Check if 'errno' is declared in <errno.h>
  392. AC_DEFUN([CF_ERRNO],
  393. [
  394. CF_CHECK_ERRNO(errno)
  395. ])dnl
  396. dnl ---------------------------------------------------------------------------
  397. dnl Look for a non-standard library, given parameters for AC_TRY_LINK.  We
  398. dnl prefer a standard location, and use -L options only if we do not find the
  399. dnl library in the standard library location(s).
  400. dnl    $1 = library name
  401. dnl    $2 = includes
  402. dnl    $3 = code fragment to compile/link
  403. dnl    $4 = corresponding function-name
  404. dnl
  405. dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had
  406. dnl to use a -L option.
  407. AC_DEFUN([CF_FIND_LIBRARY],
  408. [
  409.     cf_cv_have_lib_$1=no
  410.     cf_libdir=""
  411.     AC_CHECK_FUNC($4,cf_cv_have_lib_$1=yes,[
  412.         cf_save_LIBS="$LIBS"
  413.         AC_MSG_CHECKING(for $4 in -l$1)
  414.         LIBS="-l$1 $LIBS"
  415.         AC_TRY_LINK([$2],[$3],
  416.             [AC_MSG_RESULT(yes)
  417.              cf_cv_have_lib_$1=yes
  418.             ],
  419.             [AC_MSG_RESULT(no)
  420.             CF_LIBRARY_PATH(cf_search,$1)
  421.             for cf_libdir in $cf_search
  422.             do
  423.                 AC_MSG_CHECKING(for -l$1 in $cf_libdir)
  424.                 LIBS="-L$cf_libdir -l$1 $cf_save_LIBS"
  425.                 AC_TRY_LINK([$2],[$3],
  426.                     [AC_MSG_RESULT(yes)
  427.                       cf_cv_have_lib_$1=yes
  428.                      break],
  429.                     [AC_MSG_RESULT(no)
  430.                      LIBS="$cf_save_LIBS"])
  431.             done
  432.             ])
  433.         ])
  434. if test $cf_cv_have_lib_$1 = no ; then
  435.     AC_ERROR(Cannot link $1 library)
  436. fi
  437. case $host_os in #(vi
  438. linux*) # Suse Linux does not follow /usr/lib convention
  439.     $1="[$]$1 /lib"
  440.     ;;
  441. esac
  442. ])dnl
  443. dnl ---------------------------------------------------------------------------
  444. dnl Test for the common variations of stdio structures that we can use to
  445. dnl test if a character is available for reading.
  446. AC_DEFUN([CF_FP_ISREADY],
  447. [
  448. AC_CACHE_CHECK(for file-pointer ready definition,
  449. cf_cv_fp_isready,[
  450. cf_cv_fp_isready=none
  451. while true
  452. do
  453.     read definition
  454.     test -z "$definition" && break
  455.     echo "test-compile $definition" 1>&AC_FD_CC
  456.  
  457.     AC_TRY_COMPILE([
  458. #include <stdio.h>
  459. #define isready_c(p) $definition
  460. ],[int x = isready_c(stdin)],
  461.     [echo "$definition" >conftest.env
  462.      break])
  463.  
  464. done <<'CF_EOF'
  465. ( (p)->_IO_read_ptr < (p)->_IO_read_end)
  466. ( (p)->__cnt > 0)
  467. ( (p)->__rptr < (p)->__rend)
  468. ( (p)->_cnt > 0)
  469. ( (p)->_gptr < (p)->_egptr)
  470. ( (p)->_r > 0)
  471. ( (p)->_rcount > 0)
  472. ( (p)->endr < (p)->endb)
  473. CF_EOF
  474.  
  475. test -f conftest.env && cf_cv_fp_isready=`cat conftest.env`
  476.  
  477. ])
  478.  
  479. test "$cf_cv_fp_isready" != none && AC_DEFINE_UNQUOTED(isready_c(p),$cf_cv_fp_isready)
  480.  
  481. ])dnl
  482. dnl ---------------------------------------------------------------------------
  483. dnl Test for availability of useful gcc __attribute__ directives to quiet
  484. dnl compiler warnings.  Though useful, not all are supported -- and contrary
  485. dnl to documentation, unrecognized directives cause older compilers to barf.
  486. AC_DEFUN([CF_GCC_ATTRIBUTES],
  487. [
  488. if test -n "$GCC"
  489. then
  490. cat > conftest.i <<EOF
  491. #ifndef GCC_PRINTF
  492. #define GCC_PRINTF 0
  493. #endif
  494. #ifndef GCC_SCANF
  495. #define GCC_SCANF 0
  496. #endif
  497. #ifndef GCC_NORETURN
  498. #define GCC_NORETURN /* nothing */
  499. #endif
  500. #ifndef GCC_UNUSED
  501. #define GCC_UNUSED /* nothing */
  502. #endif
  503. EOF
  504. if test -n "$GCC"
  505. then
  506.     AC_CHECKING([for gcc __attribute__ directives])
  507.     changequote(,)dnl
  508. cat > conftest.$ac_ext <<EOF
  509. #line __oline__ "configure"
  510. #include "confdefs.h"
  511. #include "conftest.h"
  512. #include "conftest.i"
  513. #if    GCC_PRINTF
  514. #define GCC_PRINTFLIKE(fmt,var) __attribute__((format(printf,fmt,var)))
  515. #else
  516. #define GCC_PRINTFLIKE(fmt,var) /*nothing*/
  517. #endif
  518. #if    GCC_SCANF
  519. #define GCC_SCANFLIKE(fmt,var)  __attribute__((format(scanf,fmt,var)))
  520. #else
  521. #define GCC_SCANFLIKE(fmt,var)  /*nothing*/
  522. #endif
  523. extern void wow(char *,...) GCC_SCANFLIKE(1,2);
  524. extern void oops(char *,...) GCC_PRINTFLIKE(1,2) GCC_NORETURN;
  525. extern void foo(void) GCC_NORETURN;
  526. int main(int argc GCC_UNUSED, char *argv[] GCC_UNUSED) { return 0; }
  527. EOF
  528.     changequote([,])dnl
  529.     for cf_attribute in scanf printf unused noreturn
  530.     do
  531.         CF_UPPER(CF_ATTRIBUTE,$cf_attribute)
  532.         cf_directive="__attribute__(($cf_attribute))"
  533.         echo "checking for gcc $cf_directive" 1>&AC_FD_CC
  534.         case $cf_attribute in
  535.         scanf|printf)
  536.         cat >conftest.h <<EOF
  537. #define GCC_$CF_ATTRIBUTE 1
  538. EOF
  539.             ;;
  540.         *)
  541.         cat >conftest.h <<EOF
  542. #define GCC_$CF_ATTRIBUTE $cf_directive
  543. EOF
  544.             ;;
  545.         esac
  546.         if AC_TRY_EVAL(ac_compile); then
  547.             test -n "$verbose" && AC_MSG_RESULT(... $cf_attribute)
  548.             cat conftest.h >>confdefs.h
  549. #        else
  550. #            sed -e 's/__attr.*/\/*nothing*\//' conftest.h >>confdefs.h
  551.         fi
  552.     done
  553. else
  554.     fgrep define conftest.i >>confdefs.h
  555. fi
  556. rm -rf conftest*
  557. fi
  558. ])dnl
  559. dnl ---------------------------------------------------------------------------
  560. dnl Check if the compiler supports useful warning options.  There's a few that
  561. dnl we don't use, simply because they're too noisy:
  562. dnl
  563. dnl    -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x)
  564. dnl    -Wredundant-decls (system headers make this too noisy)
  565. dnl    -Wtraditional (combines too many unrelated messages, only a few useful)
  566. dnl    -Wwrite-strings (too noisy, but should review occasionally)
  567. dnl    -pedantic
  568. dnl
  569. AC_DEFUN([CF_GCC_WARNINGS],
  570. [
  571. if test -n "$GCC"
  572. then
  573.     changequote(,)dnl
  574.     cat > conftest.$ac_ext <<EOF
  575. #line __oline__ "configure"
  576. int main(int argc, char *argv[]) { return argv[argc-1] == 0; }
  577. EOF
  578.     changequote([,])dnl
  579.     AC_CHECKING([for gcc warning options])
  580.     cf_save_CFLAGS="$CFLAGS"
  581.     EXTRA_CFLAGS="-W -Wall"
  582.     cf_warn_CONST=""
  583.     test "$with_ext_const" = yes && cf_warn_CONST="Wwrite-strings"
  584.     for cf_opt in \
  585.         Wbad-function-cast \
  586.         Wcast-align \
  587.         Wcast-qual \
  588.         Winline \
  589.         Wmissing-declarations \
  590.         Wmissing-prototypes \
  591.         Wnested-externs \
  592.         Wpointer-arith \
  593.         Wshadow \
  594.         Wstrict-prototypes $cf_warn_CONST
  595.     do
  596.         CFLAGS="$cf_save_CFLAGS $EXTRA_CFLAGS -$cf_opt"
  597.         if AC_TRY_EVAL(ac_compile); then
  598.             test -n "$verbose" && AC_MSG_RESULT(... -$cf_opt)
  599.             EXTRA_CFLAGS="$EXTRA_CFLAGS -$cf_opt"
  600.             test "$cf_opt" = Wcast-qual && EXTRA_CFLAGS="$EXTRA_CFLAGS -DXTSTRINGDEFINES"
  601.         fi
  602.     done
  603.     rm -f conftest*
  604.     CFLAGS="$cf_save_CFLAGS"
  605. fi
  606. AC_SUBST(EXTRA_CFLAGS)
  607. ])dnl
  608. dnl ---------------------------------------------------------------------------
  609. dnl Construct a search-list for a nonstandard header-file
  610. AC_DEFUN([CF_HEADER_PATH],
  611. [$1=""
  612. if test -d "$includedir"  ; then
  613. test "$includedir" != NONE       && $1="[$]$1 $includedir $includedir/$2"
  614. fi
  615. if test -d "$oldincludedir"  ; then
  616. test "$oldincludedir" != NONE    && $1="[$]$1 $oldincludedir $oldincludedir/$2"
  617. fi
  618. if test -d "$prefix"; then
  619. test "$prefix" != NONE           && $1="[$]$1 $prefix/include $prefix/include/$2"
  620. fi
  621. test "$prefix" != /usr/local     && $1="[$]$1 /usr/local/include /usr/local/include/$2"
  622. test "$prefix" != /usr           && $1="[$]$1 /usr/include /usr/include/$2"
  623. ])dnl
  624. dnl ---------------------------------------------------------------------------
  625. dnl Use imake to obtain compiler flags.  We could, in principle, write tests to
  626. dnl get these, but if imake is properly configured there is no point in doing
  627. dnl this.
  628. AC_DEFUN([CF_IMAKE_CFLAGS],
  629. [
  630. AC_PATH_PROGS(IMAKE,xmkmf imake)
  631. case $IMAKE in # (vi
  632. */imake)
  633.     cf_imake_opts="-DUseInstalled=YES" # (vi
  634.     ;;
  635. *)
  636.     cf_imake_opts=
  637.     ;;
  638. esac
  639.  
  640. # If it's installed properly, imake (or its wrapper, xmkmf) will point to the
  641. # config directory.
  642. if mkdir conftestdir; then
  643.     cd conftestdir
  644.     echo >./Imakefile
  645.     test -f ../Imakefile && cat ../Imakefile >>./Imakefile
  646.     cat >> ./Imakefile <<'CF_EOF'
  647. findstddefs:
  648.     @echo 'IMAKE_CFLAGS="${ALLDEFINES} ifelse($1,,,$1)"'
  649.     @echo 'IMAKE_LOADFLAGS="${EXTRA_LOAD_FLAGS} ifelse($2,,,$2)"'
  650. CF_EOF
  651.     if ( $IMAKE $cf_imake_opts 1>/dev/null 2>&AC_FD_CC && test -f Makefile)
  652.     then
  653.         CF_VERBOSE(Using $IMAKE)
  654.     else
  655.         # sometimes imake doesn't have the config path compiled in.  Find it.
  656.         cf_config=
  657.         for cf_libpath in $X_LIBS $LIBS ; do
  658.             case $cf_libpath in # (vi
  659.             -L*)
  660.                 cf_libpath=`echo .$cf_libpath | sed -e 's/^...//'`
  661.                 cf_libpath=$cf_libpath/X11/config
  662.                 if test -d $cf_libpath ; then
  663.                     cf_config=$cf_libpath
  664.                     break
  665.                 fi
  666.                 ;;
  667.             esac
  668.         done
  669.         if test -z "$cf_config" ; then
  670.             AC_WARN(Could not find imake config-directory)
  671.         else
  672.             cf_imake_opts="$cf_imake_opts -I$cf_config"
  673.             if ( $IMAKE -v $cf_imake_opts 2>&AC_FD_CC)
  674.             then
  675.                 CF_VERBOSE(Using $IMAKE $cf_config)
  676.             else
  677.                 AC_WARN(Cannot run $IMAKE)
  678.             fi
  679.         fi
  680.     fi
  681.  
  682.     # GNU make sometimes prints "make[1]: Entering...", which
  683.     # would confuse us.
  684.     eval `make findstddefs 2>/dev/null | grep -v make`
  685.  
  686.     cd ..
  687.     rm -rf conftestdir
  688.  
  689.     # We use $(ALLDEFINES) rather than $(STD_DEFINES) because the former
  690.     # declares XTFUNCPROTO there.  However, some vendors (e.g., SGI) have
  691.     # modified it to support site.cf, adding a kludge for the /usr/include
  692.     # directory.  Try to filter that out, otherwise gcc won't find its
  693.     # headers.
  694.     if test -n "$GCC" ; then
  695.         if test -n "$IMAKE_CFLAGS" ; then
  696.         cf_nostdinc=""
  697.         cf_std_incl=""
  698.         cf_cpp_opts=""
  699.         for cf_opt in $IMAKE_CFLAGS
  700.         do
  701.             case "$cf_opt" in
  702.             -nostdinc) #(vi
  703.             cf_nostdinc="$cf_opt"
  704.             ;;
  705.             -I/usr/include) #(vi
  706.             cf_std_incl="$cf_opt"
  707.             ;;
  708.             *) #(vi
  709.             cf_cpp_opts="$cf_cpp_opts $cf_opt"
  710.             ;;
  711.             esac
  712.         done
  713.         if test -z "$cf_nostdinc" ; then
  714.             IMAKE_CFLAGS="$cf_cpp_opts $cf_std_incl"
  715.         elif test -z "$cf_std_incl" ; then
  716.             IMAKE_CFLAGS="$cf_cpp_opts $cf_nostdinc"
  717.         else
  718.             CF_VERBOSE(suppressed \"$cf_nostdinc\" and \"$cf_std_incl\")
  719.             IMAKE_CFLAGS="$cf_cpp_opts"
  720.         fi
  721.         fi
  722.     fi
  723. fi
  724. AC_SUBST(IMAKE_CFLAGS)
  725. AC_SUBST(IMAKE_LOADFLAGS)
  726. ])dnl
  727. dnl ---------------------------------------------------------------------------
  728. dnl Note: must follow AC_FUNC_SETPGRP, but cannot use AC_REQUIRE, since that
  729. dnl messes up the messages...
  730. AC_DEFUN([CF_KILLPG],
  731. [
  732. AC_MSG_CHECKING([if killpg is needed])
  733. AC_CACHE_VAL(cf_cv_need_killpg,[
  734. AC_TRY_RUN([
  735. #include <sys/types.h>
  736. #include <signal.h>
  737. RETSIGTYPE
  738. handler(s)
  739.     int s;
  740. {
  741.     exit(0);
  742. }
  743.  
  744. main()
  745. {
  746. #ifdef SETPGRP_VOID
  747.     (void) setpgrp();
  748. #else
  749.     (void) setpgrp(0,0);
  750. #endif
  751.     (void) signal(SIGINT, handler);
  752.     (void) kill(-getpid(), SIGINT);
  753.     exit(1);
  754. }],
  755.     [cf_cv_need_killpg=no],
  756.     [cf_cv_need_killpg=yes],
  757.     [cf_cv_need_killpg=unknown]
  758. )])
  759. AC_MSG_RESULT($cf_cv_need_killpg)
  760. test $cf_cv_need_killpg = yes && AC_DEFINE(HAVE_KILLPG)
  761. ])dnl
  762. dnl ---------------------------------------------------------------------------
  763. dnl Construct a search-list for a nonstandard library-file
  764. AC_DEFUN([CF_LIBRARY_PATH],
  765. [$1=""
  766. if test -d "$libdir"  ; then
  767. test "$libdir" != NONE           && $1="[$]$1 $libdir $libdir/$2"
  768. fi
  769. if test -d "$exec_prefix"; then
  770. test "$exec_prefix" != NONE      && $1="[$]$1 $exec_prefix/lib $exec_prefix/lib/$2"
  771. fi
  772. if test -d "$prefix"; then
  773. test "$prefix" != NONE           && \
  774. test "$prefix" != "$exec_prefix" && $1="[$]$1 $prefix/lib $prefix/lib/$2"
  775. fi
  776. test "$prefix" != /usr/local     && $1="[$]$1 /usr/local/lib /usr/local/lib/$2"
  777. test "$prefix" != /usr           && $1="[$]$1 /usr/lib /usr/lib/$2"
  778. ])dnl
  779. dnl ---------------------------------------------------------------------------
  780. dnl
  781. AC_DEFUN([CF_MISSING_CHECK],
  782. [
  783. AC_MSG_CHECKING([for missing "$1" extern])
  784. AC_CACHE_VAL([cf_cv_func_$1],[
  785. cf_save_CFLAGS="$CFLAGS"
  786. CFLAGS="$CFLAGS $CHECK_DECL_FLAG"
  787. AC_TRY_LINK([
  788. $CHECK_DECL_HDRS
  789.  
  790. #undef $1
  791. struct zowie { int a; double b; struct zowie *c; char d; };
  792. extern struct zowie *$1();
  793. ],
  794. [
  795. #if HAVE_LIBXT        /* needed for SunOS 4.0.3 or 4.1 */
  796. XtToolkitInitialize();
  797. #endif
  798. ],
  799. [eval 'cf_cv_func_'$1'=yes'],
  800. [eval 'cf_cv_func_'$1'=no'])
  801. CFLAGS="$cf_save_CFLAGS"
  802. ])
  803. eval 'cf_result=$cf_cv_func_'$1
  804. AC_MSG_RESULT($cf_result)
  805. test $cf_result = yes && AC_DEFINE_UNQUOTED(MISSING_EXTERN_$2)
  806. ])dnl
  807. dnl ---------------------------------------------------------------------------
  808. dnl
  809. AC_DEFUN([CF_MISSING_EXTERN],
  810. [for ac_func in $1
  811. do
  812. CF_UPPER(ac_tr_func,$ac_func)
  813. CF_MISSING_CHECK(${ac_func}, ${ac_tr_func})dnl
  814. done
  815. ])dnl
  816. dnl ---------------------------------------------------------------------------
  817. dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting
  818. dnl the CPPFLAGS variable.
  819. dnl
  820. dnl The header files may be installed as either curses.h, or ncurses.h
  821. dnl (obsolete).  If not installed for overwrite, the curses.h file would be
  822. dnl in an ncurses subdirectory (e.g., /usr/include/ncurses), but someone may
  823. dnl have installed overwriting the vendor's curses.  Only very old versions
  824. dnl (pre-1.9.2d, the first autoconf'd version) of ncurses don't define
  825. dnl either __NCURSES_H or NCURSES_VERSION in the header.
  826. dnl
  827. dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header
  828. dnl is already in the include-path, don't even bother with this, since we cannot
  829. dnl easily determine which file it is.  In this case, it has to be <curses.h>.
  830. dnl
  831. AC_DEFUN([CF_NCURSES_CPPFLAGS],
  832. [
  833. AC_MSG_CHECKING(for ncurses header file)
  834. AC_CACHE_VAL(cf_cv_ncurses_header,[
  835.     AC_TRY_COMPILE([#include <curses.h>],[
  836. #ifdef NCURSES_VERSION
  837. printf("%s\n", NCURSES_VERSION);
  838. #else
  839. #ifdef __NCURSES_H
  840. printf("old\n");
  841. #else
  842. make an error
  843. #endif
  844. #endif
  845.     ],
  846.     [cf_cv_ncurses_header=predefined],[
  847.     CF_HEADER_PATH(cf_search,ncurses)
  848.     test -n "$verbose" && echo
  849.     for cf_incdir in $cf_search
  850.     do
  851.         for cf_header in \
  852.             curses.h \
  853.             ncurses.h
  854.         do
  855. changequote(,)dnl
  856.             if egrep "NCURSES_[VH]" $cf_incdir/$cf_header 1>&AC_FD_CC 2>&1; then
  857. changequote([,])dnl
  858.                 cf_cv_ncurses_header=$cf_incdir/$cf_header
  859.                 test -n "$verbose" && echo $ac_n "    ... found $ac_c" 1>&AC_FD_MSG
  860.                 break
  861.             fi
  862.             test -n "$verbose" && echo "    ... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG
  863.         done
  864.         test -n "$cf_cv_ncurses_header" && break
  865.     done
  866.     test -z "$cf_cv_ncurses_header" && AC_ERROR(not found)
  867.     ])])
  868. AC_MSG_RESULT($cf_cv_ncurses_header)
  869. AC_DEFINE(NCURSES)
  870.  
  871. changequote(,)dnl
  872. cf_incdir=`echo $cf_cv_ncurses_header | sed -e 's:/[^/]*$::'`
  873. changequote([,])dnl
  874.  
  875. case $cf_cv_ncurses_header in # (vi
  876. */ncurses.h)
  877.     AC_DEFINE(HAVE_NCURSES_H)
  878.     ;;
  879. esac
  880.  
  881. case $cf_cv_ncurses_header in # (vi
  882. predefined) # (vi
  883.     cf_cv_ncurses_header=curses.h
  884.     ;;
  885. *)
  886.     CF_ADD_INCDIR($cf_incdir)
  887.     ;;
  888. esac
  889. CF_NCURSES_VERSION
  890. ])dnl
  891. dnl ---------------------------------------------------------------------------
  892. dnl Look for the ncurses library.  This is a little complicated on Linux,
  893. dnl because it may be linked with the gpm (general purpose mouse) library.
  894. dnl Some distributions have gpm linked with (bsd) curses, which makes it
  895. dnl unusable with ncurses.  However, we don't want to link with gpm unless
  896. dnl ncurses has a dependency, since gpm is normally set up as a shared library,
  897. dnl and the linker will record a dependency.
  898. AC_DEFUN([CF_NCURSES_LIBS],
  899. [AC_REQUIRE([CF_NCURSES_CPPFLAGS])
  900.  
  901.     # This works, except for the special case where we find gpm, but
  902.     # ncurses is in a nonstandard location via $LIBS, and we really want
  903.     # to link gpm.
  904. cf_ncurses_LIBS=""
  905. cf_ncurses_SAVE="$LIBS"
  906. AC_CHECK_LIB(gpm,Gpm_Open,
  907.     [AC_CHECK_LIB(gpm,initscr,
  908.         [LIBS="$cf_ncurses_SAVE"],
  909.         [cf_ncurses_LIBS="-lgpm"])])
  910.  
  911. case $host_os in #(vi
  912. freebsd*)
  913.     # This is only necessary if you are linking against an obsolete
  914.     # version of ncurses (but it should do no harm, since it's static).
  915.     AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"])
  916.     ;;
  917. esac
  918.  
  919. LIBS="$cf_ncurses_LIBS $LIBS"
  920. CF_FIND_LIBRARY(ncurses,
  921.     [#include <${cf_cv_ncurses_header-curses.h}>],
  922.     [initscr()],
  923.     initscr)
  924.  
  925. if test -n "$cf_ncurses_LIBS" ; then
  926.     AC_MSG_CHECKING(if we can link ncurses without $cf_ncurses_LIBS)
  927.     cf_ncurses_SAVE="$LIBS"
  928.     for p in $cf_ncurses_LIBS ; do
  929.         q=`echo $LIBS | sed -e 's/'$p' //' -e 's/'$p'$//'`
  930.         if test "$q" != "$LIBS" ; then
  931.             LIBS="$q"
  932.         fi
  933.     done
  934.     AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>],
  935.         [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);],
  936.         [AC_MSG_RESULT(yes)],
  937.         [AC_MSG_RESULT(no)
  938.          LIBS="$cf_ncurses_SAVE"])
  939. fi
  940. ])dnl
  941. dnl ---------------------------------------------------------------------------
  942. dnl Check for the version of ncurses, to aid in reporting bugs, etc.
  943. AC_DEFUN([CF_NCURSES_VERSION],
  944. [AC_MSG_CHECKING(for ncurses version)
  945. AC_CACHE_VAL(cf_cv_ncurses_version,[
  946.     cf_cv_ncurses_version=no
  947.     cf_tempfile=out$$
  948.     AC_TRY_RUN([
  949. #include <${cf_cv_ncurses_header-curses.h}>
  950. int main()
  951. {
  952.     FILE *fp = fopen("$cf_tempfile", "w");
  953. #ifdef NCURSES_VERSION
  954. # ifdef NCURSES_VERSION_PATCH
  955.     fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH);
  956. # else
  957.     fprintf(fp, "%s\n", NCURSES_VERSION);
  958. # endif
  959. #else
  960. # ifdef __NCURSES_H
  961.     fprintf(fp, "old\n");
  962. # else
  963.     make an error
  964. # endif
  965. #endif
  966.     exit(0);
  967. }],[
  968.     cf_cv_ncurses_version=`cat $cf_tempfile`
  969.     rm -f $cf_tempfile],,[
  970.  
  971.     # This will not work if the preprocessor splits the line after the
  972.     # Autoconf token.  The 'unproto' program does that.
  973.     cat > conftest.$ac_ext <<EOF
  974. #include <${cf_cv_ncurses_header-curses.h}>
  975. #undef Autoconf
  976. #ifdef NCURSES_VERSION
  977. Autoconf NCURSES_VERSION
  978. #else
  979. #ifdef __NCURSES_H
  980. Autoconf "old"
  981. #endif
  982. ;
  983. #endif
  984. EOF
  985.     cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out"
  986.     AC_TRY_EVAL(cf_try)
  987.     if test -f conftest.out ; then
  988. changequote(,)dnl
  989.         cf_out=`cat conftest.out | sed -e 's@^Autoconf @@' -e 's@^[^"]*"@@' -e 's@".*@@'`
  990. changequote([,])dnl
  991.         test -n "$cf_out" && cf_cv_ncurses_version="$cf_out"
  992.         rm -f conftest.out
  993.     fi
  994. ])])
  995. AC_MSG_RESULT($cf_cv_ncurses_version)
  996. ])
  997. dnl ---------------------------------------------------------------------------
  998. dnl Within AC_OUTPUT, check if the given file differs from the target, and
  999. dnl update it if so.  Otherwise, remove the generated file.
  1000. dnl
  1001. dnl Parameters:
  1002. dnl $1 = input, which configure has done substitutions upon
  1003. dnl $2 = target file
  1004. dnl
  1005. AC_DEFUN([CF_OUTPUT_IF_CHANGED],[
  1006. if ( cmp -s $1 $2 2>/dev/null )
  1007. then
  1008.     echo "$2 is unchanged"
  1009.     rm -f $1
  1010. else
  1011.     echo "creating $2"
  1012.     rm -f $2
  1013.     mv $1 $2
  1014. fi
  1015. ])dnl
  1016. dnl ---------------------------------------------------------------------------
  1017. dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX.
  1018. AC_DEFUN([CF_PROG_EXT],
  1019. [
  1020. AC_REQUIRE([CF_CHECK_CACHE])
  1021. PROG_EXT=
  1022. case $cf_cv_system_name in
  1023. os2*)
  1024.     # We make sure -Zexe is not used -- it would interfere with @PROG_EXT@
  1025.     CFLAGS="$CFLAGS -Zmt -D__ST_MT_ERRNO__"
  1026.     LDFLAGS=`echo "$LDFLAGS -Zmt -Zcrtdll" | sed "s/-Zexe//g"`
  1027.     PROG_EXT=".exe"
  1028.     ;;
  1029. esac
  1030. AC_SUBST(PROG_EXT)
  1031. ])dnl
  1032. dnl ---------------------------------------------------------------------------
  1033. dnl Check for Perl, given the minimum version, to ensure that required features
  1034. dnl are present.
  1035. dnl $1 = the minimum version
  1036. changequote() 
  1037. define(U_TURN_BACK, ]) 
  1038. changequote([, ]) 
  1039.  
  1040. AC_DEFUN(CF_PROG_PERL,
  1041. [# find perl binary
  1042. AC_MSG_CHECKING([for ifelse([$1],,perl,[perl-$1])])
  1043. AC_CACHE_VAL(cf_cv_prog_PERL,
  1044. [ifelse([$1],,,[echo "configure:__oline__: ...version $1 required" >&AC_FD_CC
  1045.   ])# allow user to override
  1046.   if test -n "$PERL"; then
  1047.     cf_try="$PERL"
  1048.   else
  1049.     cf_try="perl perl5"
  1050.   fi
  1051.  
  1052.   for cf_prog in $cf_try; do
  1053.     echo "configure:__oline__: trying $cf_prog" >&AC_FD_CC
  1054.     if ($cf_prog -e 'printf "found version %g\n",$]U_TURN_BACK[dnl
  1055. ifelse([$1],,,[;exit($]U_TURN_BACK[<$1)])') 1>&AC_FD_CC 2>&1; then
  1056.       cf_cv_prog_PERL=$cf_prog
  1057.       break
  1058.     fi
  1059.   done])dnl
  1060. PERL="$cf_cv_prog_PERL"
  1061. if test -n "$PERL"; then
  1062.   AC_MSG_RESULT($PERL)
  1063. else
  1064.   AC_MSG_RESULT(no)
  1065. fi
  1066. AC_SUBST(PERL)dnl
  1067. ])dnl
  1068. dnl ---------------------------------------------------------------------------
  1069. dnl CF_RESTARTABLE_PIPEREAD is a modified version of AC_RESTARTABLE_SYSCALLS
  1070. dnl from acspecific.m4, which uses a read on a pipe (surprise!) rather than a
  1071. dnl wait() as the test code.  apparently there is a POSIX change, which OSF/1
  1072. dnl at least has adapted to, which says reads (or writes) on pipes for which no
  1073. dnl data has been transferred are interruptable _regardless_ of the SA_RESTART
  1074. dnl bit.  yuck.
  1075. AC_DEFUN([CF_RESTARTABLE_PIPEREAD],
  1076. [
  1077. AC_MSG_CHECKING(for restartable reads on pipes)
  1078. AC_CACHE_VAL(cf_cv_can_restart_read,[
  1079. AC_TRY_RUN(
  1080. [/* Exit 0 (true) if wait returns something other than -1,
  1081.    i.e. the pid of the child, which means that wait was restarted
  1082.    after getting the signal.  */
  1083. #include <sys/types.h>
  1084. #include <signal.h>
  1085. #ifdef SA_RESTART
  1086. sigwrapper(sig, disp)
  1087. int sig;
  1088. void (*disp)();
  1089. {
  1090.     struct sigaction act, oact;
  1091.  
  1092.     act.sa_handler = disp;
  1093.     sigemptyset(&act.sa_mask);
  1094.     act.sa_flags = SA_RESTART;
  1095.  
  1096.     (void)sigaction(sig, &act, &oact);
  1097.  
  1098. }
  1099. #else
  1100. # define sigwrapper signal
  1101. #endif
  1102. ucatch (isig) { }
  1103. main () {
  1104.   int i, status;
  1105.   int fd[2];
  1106.   char buff[2];
  1107.   pipe(fd);
  1108.   i = fork();
  1109.   if (i == 0) {
  1110.       sleep (2);
  1111.       kill (getppid (), SIGINT);
  1112.       sleep (2);
  1113.       write(fd[1],"done",4);
  1114.       close(fd[1]);
  1115.       exit (0);
  1116.   }
  1117.   sigwrapper (SIGINT, ucatch);
  1118.   status = read(fd[0], buff, sizeof(buff));
  1119.   wait (&i);
  1120.   exit (status == -1);
  1121. }
  1122. ],
  1123. [cf_cv_can_restart_read=yes],
  1124. [cf_cv_can_restart_read=no],
  1125. [cf_cv_can_restart_read=unknown])])
  1126. AC_MSG_RESULT($cf_cv_can_restart_read)
  1127. test $cf_cv_can_restart_read = yes && AC_DEFINE(HAVE_RESTARTABLE_PIPEREAD)
  1128. ])dnl
  1129. dnl ---------------------------------------------------------------------------
  1130. dnl Check for definitions & structures needed for window size-changing
  1131. dnl FIXME: check that this works with "snake" (HP-UX 10.x)
  1132. AC_DEFUN([CF_SIZECHANGE],
  1133. [
  1134. AC_MSG_CHECKING([declaration of size-change])
  1135. AC_CACHE_VAL(cf_cv_sizechange,[
  1136.     cf_cv_sizechange=unknown
  1137.     cf_save_CFLAGS="$CFLAGS"
  1138.  
  1139. for cf_opts in "" "NEED_PTEM_H"
  1140. do
  1141.  
  1142.     CFLAGS="$cf_save_CFLAGS"
  1143.     test -n "$cf_opts" && CFLAGS="$CFLAGS -D$cf_opts"
  1144.     AC_TRY_COMPILE([#include <sys/types.h>
  1145. #if HAVE_TERMIOS_H
  1146. #include <termios.h>
  1147. #else
  1148. #if HAVE_TERMIO_H
  1149. #include <termio.h>
  1150. #endif
  1151. #endif
  1152. #if NEED_PTEM_H
  1153. /* This is a workaround for SCO:  they neglected to define struct winsize in
  1154.  * termios.h -- it's only in termio.h and ptem.h
  1155.  */
  1156. #include        <sys/stream.h>
  1157. #include        <sys/ptem.h>
  1158. #endif
  1159. #if !defined(sun) || !defined(HAVE_TERMIOS_H)
  1160. #include <sys/ioctl.h>
  1161. #endif
  1162. ],[
  1163. #ifdef TIOCGSIZE
  1164.     struct ttysize win;    /* FIXME: what system is this? */
  1165.     int y = win.ts_lines;
  1166.     int x = win.ts_cols;
  1167. #else
  1168. #ifdef TIOCGWINSZ
  1169.     struct winsize win;
  1170.     int y = win.ws_row;
  1171.     int x = win.ws_col;
  1172. #else
  1173.     no TIOCGSIZE or TIOCGWINSZ
  1174. #endif /* TIOCGWINSZ */
  1175. #endif /* TIOCGSIZE */
  1176.     ],
  1177.     [cf_cv_sizechange=yes],
  1178.     [cf_cv_sizechange=no])
  1179.  
  1180.     CFLAGS="$cf_save_CFLAGS"
  1181.     if test "$cf_cv_sizechange" = yes ; then
  1182.         echo "size-change succeeded ($cf_opts)" >&AC_FD_CC
  1183.         test -n "$cf_opts" && AC_DEFINE_UNQUOTED($cf_opts)
  1184.         break
  1185.     fi
  1186. done
  1187.     ])
  1188. AC_MSG_RESULT($cf_cv_sizechange)
  1189. test $cf_cv_sizechange != no && AC_DEFINE(HAVE_SIZECHANGE)
  1190. ])dnl
  1191. dnl ---------------------------------------------------------------------------
  1192. dnl Check for declaration of sys_nerr and sys_errlist in one of stdio.h and
  1193. dnl errno.h.  Declaration of sys_errlist on BSD4.4 interferes with our
  1194. dnl declaration.  Reported by Keith Bostic.
  1195. AC_DEFUN([CF_SYS_ERRLIST],
  1196. [
  1197. for cf_name in sys_nerr sys_errlist
  1198. do
  1199.     CF_CHECK_ERRNO($cf_name)
  1200. done
  1201. ])dnl
  1202. dnl ---------------------------------------------------------------------------
  1203. dnl Look for termcap libraries, or the equivalent in terminfo.
  1204. AC_DEFUN([CF_TERMCAP_LIBS],
  1205. [
  1206. AC_CACHE_VAL(cf_cv_lib_termcap,[
  1207. cf_cv_lib_termcap=none
  1208. AC_TRY_LINK([],[char *x=(char*)tgoto("",0,0)],
  1209. [AC_TRY_LINK([],[int x=tigetstr("")],
  1210.     [cf_cv_termlib=terminfo],
  1211.     [cf_cv_termlib=termcap])
  1212.     CF_VERBOSE(using functions in predefined $cf_cv_termlib LIBS)
  1213. ],[
  1214. ifelse([$1],,,[
  1215. if test "$1" = ncurses; then
  1216.     CF_NCURSES_CPPFLAGS
  1217.     CF_NCURSES_LIBS
  1218.     cf_cv_termlib=terminfo
  1219. fi
  1220. ])
  1221. # HP-UX 9.x terminfo has setupterm, but no tigetstr.
  1222. if test "$termlib" = none; then
  1223.     AC_CHECK_LIB(termlib, tigetstr, [LIBS="$LIBS -ltermlib" cf_cv_lib_termcap=terminfo])
  1224. fi
  1225. if test "$cf_cv_lib_termcap" = none; then
  1226.     AC_CHECK_LIB(termlib, tgoto, [LIBS="$LIBS -ltermlib" cf_cv_lib_termcap=termcap])
  1227. fi
  1228. if test "$cf_cv_lib_termcap" = none; then
  1229.     # allow curses library for broken AIX system.
  1230.     AC_CHECK_LIB(curses, initscr, [LIBS="$LIBS -lcurses" cf_cv_lib_termcap=termcap])
  1231.     AC_CHECK_LIB(termcap, tgoto, [LIBS="$LIBS -ltermcap" cf_cv_lib_termcap=termcap])
  1232. fi
  1233. if test "$cf_cv_lib_termcap" = none; then
  1234.     AC_CHECK_LIB(termcap, tgoto, [LIBS="$LIBS -ltermcap" cf_cv_lib_termcap=termcap])
  1235. fi
  1236. if test "$cf_cv_lib_termcap" = none; then
  1237.     AC_CHECK_LIB(ncurses, tgoto, [LIBS="$LIBS -lncurses" cf_cv_lib_termcap=ncurses])
  1238. fi
  1239. ])
  1240. if test "$cf_cv_lib_termcap" = none; then
  1241.     AC_ERROR([Can't find -ltermlib, -lcurses, or -ltermcap])
  1242. fi
  1243. ])])dnl
  1244. dnl ---------------------------------------------------------------------------
  1245. dnl Check for return and param type of 3rd -- OutChar() -- param of tputs().
  1246. dnl
  1247. dnl For this check, and for CF_CURSES_TERMCAP, the $CHECK_DECL_HDRS variable
  1248. dnl must point to a header file containing this (or equivalent):
  1249. dnl
  1250. dnl    #ifdef NEED_CURSES_H
  1251. dnl    # if HAVE_NCURSES_H
  1252. dnl    #  include <ncurses.h>
  1253. dnl    # else
  1254. dnl    #  include <curses.h>
  1255. dnl    # endif
  1256. dnl    #endif
  1257. dnl    #if HAVE_TERM_H
  1258. dnl    # include <term.h>
  1259. dnl    #endif
  1260. dnl    #if NEED_TERMCAP_H
  1261. dnl    # include <termcap.h>
  1262. dnl    #endif
  1263. dnl
  1264. AC_DEFUN([CF_TYPE_OUTCHAR],
  1265. [
  1266. AC_REQUIRE([CF_CURSES_TERMCAP])
  1267.  
  1268. AC_MSG_CHECKING([declaration of tputs 3rd param])
  1269. AC_CACHE_VAL(cf_cv_type_outchar,[
  1270.  
  1271. cf_cv_type_outchar="int OutChar(int)"
  1272. cf_cv_found=no
  1273. cf_save_CFLAGS="$CFLAGS"
  1274. CFLAGS="$CFLAGS $CHECK_DECL_FLAG"
  1275.  
  1276. for P in int void; do
  1277. for Q in int void; do
  1278. for R in int char; do
  1279. for S in "" const; do
  1280.  
  1281.     AC_TRY_COMPILE([$CHECK_DECL_HDRS],
  1282.     [extern $Q OutChar($R);
  1283.     extern $P tputs ($S char *string, int nlines, $Q (*_f)($R));
  1284.     tputs("", 1, OutChar)],
  1285.     [cf_cv_type_outchar="$Q OutChar($R)"
  1286.      cf_cv_found=yes
  1287.      break])
  1288. done
  1289.     test $cf_cv_found = yes && break
  1290. done
  1291.     test $cf_cv_found = yes && break
  1292. done
  1293.     test $cf_cv_found = yes && break
  1294. done
  1295.     ])
  1296. AC_MSG_RESULT($cf_cv_type_outchar)
  1297. case $cf_cv_type_outchar in
  1298. int*)
  1299.     AC_DEFINE(OUTC_RETURN)
  1300.     ;;
  1301. esac
  1302. case $cf_cv_type_outchar in
  1303. *char*)
  1304.     AC_DEFINE(OUTC_ARGS,char c)
  1305.     ;;
  1306. esac
  1307.  
  1308. CFLAGS="$cf_save_CFLAGS"
  1309. ])dnl
  1310. dnl ---------------------------------------------------------------------------
  1311. dnl Make an uppercase version of a variable
  1312. dnl $1=uppercase($2)
  1313. AC_DEFUN([CF_UPPER],
  1314. [
  1315. changequote(,)dnl
  1316. $1=`echo $2 | tr '[a-z]' '[A-Z]'`
  1317. changequote([,])dnl
  1318. ])dnl
  1319. dnl ---------------------------------------------------------------------------
  1320. dnl Use AC_VERBOSE w/o the warnings
  1321. AC_DEFUN([CF_VERBOSE],
  1322. [test -n "$verbose" && echo "    $1" 1>&AC_FD_MSG
  1323. ])dnl
  1324. dnl ---------------------------------------------------------------------------
  1325. dnl Check for Xaw (Athena) libraries
  1326. dnl
  1327. AC_DEFUN([CF_X_ATHENA],
  1328. [AC_REQUIRE([CF_X_TOOLKIT])
  1329. cf_x_athena=${cf_x_athena-Xaw}
  1330.  
  1331. AC_ARG_WITH(Xaw3d,
  1332.     [  --with-Xaw3d            link with Xaw 3d library],
  1333.     [cf_x_athena=Xaw3d])
  1334.  
  1335. AC_ARG_WITH(neXtaw,
  1336.     [  --with-neXtaw           link with neXT Athena library],
  1337.     [cf_x_athena=neXtaw])
  1338.  
  1339. AC_CHECK_HEADERS(X11/$cf_x_athena/SimpleMenu.h)
  1340.  
  1341. AC_CHECK_LIB(Xmu, XmuClientWindow,,[
  1342. AC_CHECK_LIB(Xmu_s, XmuClientWindow)])
  1343.  
  1344. AC_CHECK_LIB(Xext,XextCreateExtension,
  1345.     [LIBS="-lXext $LIBS"])
  1346.  
  1347. AC_CHECK_LIB($cf_x_athena, XawSimpleMenuAddGlobalActions,
  1348.     [LIBS="-l$cf_x_athena $LIBS"],[
  1349. AC_CHECK_LIB(${cf_x_athena}_s, XawSimpleMenuAddGlobalActions,
  1350.     [LIBS="-l${cf_x_athena}_s $LIBS"],
  1351.     AC_ERROR(
  1352. [Unable to successfully link Athena library (-l$cf_x_athena) with test program]),
  1353.     [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])])
  1354. CF_UPPER(CF_X_ATHENA_LIBS,HAVE_LIB_$cf_x_athena)
  1355. AC_DEFINE_UNQUOTED($CF_X_ATHENA_LIBS)
  1356. ])dnl
  1357. dnl ---------------------------------------------------------------------------
  1358. dnl Check for Motif or Lesstif libraries (they should be indistinguishable)
  1359. AC_DEFUN([CF_X_MOTIF],
  1360. [AC_REQUIRE([CF_X_TOOLKIT])dnl
  1361. AC_CHECK_HEADERS(X11/IntrinsicI.h Xm/XmP.h)
  1362. AC_CHECK_LIB(gen,regcmp)
  1363. AC_CHECK_LIB(Xmu,XmuClientWindow)
  1364. AC_CHECK_LIB(Xp,XpStartDoc,,,[$LIBS $X_EXTRA_LIBS])
  1365. AC_CHECK_LIB(Xext,XextCreateExtension,
  1366.     [LIBS="-lXext $LIBS"])
  1367. AC_CHECK_LIB(Xpm, XpmCreatePixmapFromXpmImage,
  1368.     [LIBS="-lXpm $LIBS"],,
  1369.     [$LIBS $X_EXTRA_LIBS])
  1370. AC_CHECK_LIB(XIM,XmbTextListToTextProperty)dnl needed for Unixware's Xm
  1371. AC_CHECK_LIB(Xm, XmProcessTraversal, [LIBS="-lXm $LIBS"],
  1372.     AC_ERROR(
  1373. [Unable to successfully link Motif library (-lXm) with test program]),
  1374.     [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS]) dnl
  1375. ])dnl
  1376. dnl ---------------------------------------------------------------------------
  1377. AC_DEFUN([CF_X_OPENLOOK],
  1378. [AC_REQUIRE([CF_X_TOOLKIT])dnl
  1379. if test -n "$OPENWINHOME"; then
  1380.     X_LIBS="$X_LIBS -L${OPENWINHOME}/lib"
  1381.     X_CFLAGS="$X_CFLAGS -I${OPENWINHOME}/include"
  1382. fi
  1383. LDFLAGS="$LDFLAGS $X_LIBS"
  1384. AC_CHECK_LIB(Xmu,XmuClientWindow)
  1385. AC_CHECK_LIB(Xol, OlToolkitInitialize,
  1386.     [LIBS="-lXol -lm $LIBS"],
  1387.     AC_ERROR(
  1388. [Unable to successfully link OpenLook library (-lXol) with test program])) dnl
  1389. ])dnl
  1390. dnl ---------------------------------------------------------------------------
  1391. dnl Check for X Toolkit libraries
  1392. dnl
  1393. AC_DEFUN([CF_X_TOOLKIT],
  1394. [
  1395. AC_REQUIRE([CF_CHECK_CACHE])
  1396. # We need to check for -lsocket and -lnsl here in order to work around an
  1397. # autoconf bug.  autoconf-2.12 is not checking for these prior to checking for
  1398. # the X11R6 -lSM and -lICE libraries.  The resultant failures cascade...
  1399. #     (tested on Solaris 2.5 w/ X11R6)
  1400. SYSTEM_NAME=`echo "$cf_cv_system_name"|tr ' ' -`
  1401. cf_have_X_LIBS=no
  1402. case $SYSTEM_NAME in
  1403. changequote(,)dnl
  1404. irix[56]*) ;;
  1405. changequote([,])dnl
  1406. clix*)
  1407.     # FIXME: modify the library lookup in autoconf to
  1408.     # allow _s.a suffix ahead of .a
  1409.     AC_CHECK_LIB(c_s,open,
  1410.         [LIBS="-lc_s $LIBS"
  1411.     AC_CHECK_LIB(bsd,gethostname,
  1412.         [LIBS="-lbsd $LIBS"
  1413.     AC_CHECK_LIB(nsl_s,gethostname,
  1414.         [LIBS="-lnsl_s $LIBS"
  1415.     AC_CHECK_LIB(X11_s,XOpenDisplay,
  1416.         [LIBS="-lX11_s $LIBS"
  1417.     AC_CHECK_LIB(Xt_s,XtAppInitialize,
  1418.         [LIBS="-lXt_s $LIBS"
  1419.          cf_have_X_LIBS=Xt
  1420.         ]) ]) ]) ]) ])
  1421.     ;;
  1422. *)
  1423.     AC_CHECK_LIB(socket,socket)
  1424.     AC_CHECK_LIB(nsl,gethostname)
  1425.     ;;
  1426. esac
  1427.  
  1428. if test $cf_have_X_LIBS = no ; then
  1429.     AC_PATH_XTRA
  1430.     LDFLAGS="$LDFLAGS $X_LIBS"
  1431.     CFLAGS="$CFLAGS $X_CFLAGS"
  1432.     AC_CHECK_LIB(X11,XOpenDisplay,
  1433.         [LIBS="-lX11 $LIBS"],,
  1434.         [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])
  1435.     AC_CHECK_LIB(Xt, XtAppInitialize,
  1436.         [AC_DEFINE(HAVE_LIBXT)
  1437.          cf_have_X_LIBS=Xt
  1438.          LIBS="-lXt $X_PRE_LIBS $LIBS"],,
  1439.         [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])
  1440. else
  1441.     LDFLAGS="$LDFLAGS $X_LIBS"
  1442.     CFLAGS="$CFLAGS $X_CFLAGS"
  1443. fi
  1444.  
  1445. if test $cf_have_X_LIBS = no ; then
  1446.     AC_WARN(
  1447. [Unable to successfully link X Toolkit library (-lXt) with
  1448. test program.  You will have to check and add the proper libraries by hand
  1449. to makefile.])
  1450. fi
  1451. ])dnl
  1452.