dnl Local definitions for autoconf. dnl dnl $Header: /usr/build/vile/vile/RCS/aclocal.m4,v 1.60 1998/08/30 22:46:51 tom Exp $ dnl dnl --------------------------------------------------------------------------- dnl --------------------------------------------------------------------------- dnl CF_PREREQ_COMPARE(MAJOR1, MINOR1, TERNARY1, MAJOR2, MINOR2, TERNARY2, dnl PRINTABLE2, not FOUND, FOUND) define(CF_PREREQ_COMPARE, [ifelse(builtin([eval], [$3 < $6]), 1, ifelse([$8], , ,[$8]), ifelse([$9], , ,[$9]))])dnl dnl --------------------------------------------------------------------------- dnl Conditionally generate script according to whether we're using the release dnl version of autoconf, or a patched version (using the ternary component as dnl the patch-version). define(CF_AC_PREREQ, [CF_PREREQ_COMPARE( AC_PREREQ_CANON(AC_PREREQ_SPLIT(AC_ACVERSION)), AC_PREREQ_CANON(AC_PREREQ_SPLIT([$1])), [$1], [$2], [$3])])dnl dnl --------------------------------------------------------------------------- dnl Add an include-directory to $CPPFLAGS. Don't add /usr/include, since it's dnl redundant. We don't normally need to add -I/usr/local/include for gcc, dnl but old versions (and some misinstalled ones) need that. AC_DEFUN([CF_ADD_INCDIR], [ for cf_add_incdir in $1 do while true do case $cf_add_incdir in /usr/include) # (vi ;; *) # (vi CPPFLAGS="$CPPFLAGS -I$cf_add_incdir" ;; esac cf_top_incdir=`echo $cf_add_incdir | sed -e 's:/include/.*$:/include:'` test "$cf_top_incdir" = "$cf_add_incdir" && break cf_add_incdir="$cf_top_incdir" done done ])dnl dnl --------------------------------------------------------------------------- dnl This is adapted from the macros 'fp_PROG_CC_STDC' and 'fp_C_PROTOTYPES' dnl in the sharutils 4.2 distribution. AC_DEFUN([CF_ANSI_CC_CHECK], [ AC_MSG_CHECKING(for ${CC-cc} option to accept ANSI C) AC_CACHE_VAL(cf_cv_ansi_cc,[ cf_cv_ansi_cc=no cf_save_CFLAGS="$CFLAGS" # Don't try gcc -ansi; that turns off useful extensions and # breaks some systems' header files. # AIX -qlanglvl=ansi # Ultrix and OSF/1 -std1 # HP-UX -Aa -D_HPUX_SOURCE # SVR4 -Xc # UnixWare 1.2 (cannot use -Xc, since ANSI/POSIX clashes) for cf_arg in "-DCC_HAS_PROTOS" \ "" \ -qlanglvl=ansi \ -std1 \ "-Aa -D_HPUX_SOURCE +e" \ "-Aa -D_HPUX_SOURCE" \ -Xc do CFLAGS="$cf_save_CFLAGS $cf_arg" AC_TRY_COMPILE( [ #ifndef CC_HAS_PROTOS #if !defined(__STDC__) || __STDC__ != 1 choke me #endif #endif ],[ int test (int i, double x); struct s1 {int (*f) (int a);}; struct s2 {int (*f) (double a);};], [cf_cv_ansi_cc="$cf_arg"; break]) done CFLAGS="$cf_save_CFLAGS" ]) AC_MSG_RESULT($cf_cv_ansi_cc) if test "$cf_cv_ansi_cc" != "no"; then if test ".$cf_cv_ansi_cc" != ".-DCC_HAS_PROTOS"; then CFLAGS="$CFLAGS $cf_cv_ansi_cc" else AC_DEFINE(CC_HAS_PROTOS) fi fi ])dnl dnl --------------------------------------------------------------------------- dnl For programs that must use an ANSI compiler, obtain compiler options that dnl will make it recognize prototypes. We'll do preprocessor checks in other dnl macros, since tools such as unproto can fake prototypes, but only part of dnl the preprocessor. AC_DEFUN([CF_ANSI_CC_REQD], [AC_REQUIRE([CF_ANSI_CC_CHECK]) if test "$cf_cv_ansi_cc" = "no"; then AC_ERROR( [Your compiler does not appear to recognize prototypes. You have the following choices: a. adjust your compiler options b. get an up-to-date compiler c. use a wrapper such as unproto]) fi ])dnl dnl --------------------------------------------------------------------------- dnl Test if we should use ANSI-style prototype for qsort's compare-function AC_DEFUN([CF_ANSI_QSORT], [ AC_MSG_CHECKING([for standard qsort]) AC_CACHE_VAL(cf_cv_ansi_qsort,[ AC_TRY_COMPILE([ #if HAVE_STDLIB_H #include #endif int compare(const void *a, const void *b) { return (*(int *)a - *(int *)b); } ], [ extern long *vector; qsort(vector, 1, 1, compare); ], [cf_cv_ansi_qsort=yes], [cf_cv_ansi_qsort=no]) ]) AC_MSG_RESULT($cf_cv_ansi_qsort) if test $cf_cv_ansi_qsort = yes; then AC_DEFINE(ANSI_QSORT,1) else AC_DEFINE(ANSI_QSORT,0) fi ])dnl dnl --------------------------------------------------------------------------- dnl Allow user to disable a normally-on option. AC_DEFUN([CF_ARG_DISABLE], [CF_ARG_OPTION($1,[$2 (default: on)],[$3],[$4],yes)])dnl dnl --------------------------------------------------------------------------- dnl Restricted form of AC_ARG_ENABLE that ensures user doesn't give bogus dnl values. dnl dnl Parameters: dnl $1 = option name dnl $2 = help-string dnl $3 = action to perform if option is not default dnl $4 = action if perform if option is default dnl $5 = default option value (either 'yes' or 'no') AC_DEFUN([CF_ARG_OPTION], [AC_ARG_ENABLE($1,[$2],[test "$enableval" != ifelse($5,no,yes,no) && enableval=ifelse($5,no,no,yes) if test "$enableval" != "$5" ; then ifelse($3,,[ :]dnl ,[ $3]) ifelse($4,,,[ else $4]) fi],[enableval=$5 ifelse($4,,,[ $4 ])dnl ])])dnl dnl --------------------------------------------------------------------------- dnl Check if the C compiler supports initialization of unions. AC_DEFUN([CF_CC_INIT_UNIONS],[ AC_CACHE_CHECK(if we can initialize unions, cf_cv_init_unions,[ AC_TRY_COMPILE([], [static struct foo {int x; union {double a; int b; } bar; } c = {0,{1.0}}], [cf_cv_init_unions=yes], [cf_cv_init_unions=no]) ]) test $cf_cv_init_unions = no && AC_DEFINE(CC_CANNOT_INIT_UNIONS) ])dnl dnl --------------------------------------------------------------------------- dnl Check if the C compiler supports offsetof expressions in switch cases. dnl Some losing compiler's can be found on pyramid's, aix, and Apple's AUX2. dnl (Lint on several platforms will complain, even when the compiler won't). AC_DEFUN([CF_CC_OFFSETOF_CASES],[ AC_CACHE_CHECK(if switch cases work with structure offsets, cf_cv_case_offsetof,[ AC_TRY_COMPILE([], [struct foo {int a,b;}; extern getpid(); switch(getpid()){case ((int) &(((struct foo *)0)->b)) : printf("foo"); } ], [cf_cv_case_offsetof=yes], [cf_cv_case_offsetof=no]) ]) test $cf_cv_case_offsetof = no && AC_DEFINE(CC_CANNOT_OFFSET_CASES) ])dnl dnl --------------------------------------------------------------------------- dnl Check if we're accidentally using a cache from a different machine. dnl Derive the system name, as a check for reusing the autoconf cache. dnl dnl If we've packaged config.guess and config.sub, run that (since it does a dnl better job than uname). AC_DEFUN([CF_CHECK_CACHE], [ if test -f $srcdir/config.guess ; then AC_CANONICAL_HOST system_name="$host_os" else system_name="`(uname -s -r) 2>/dev/null`" if test -z "$system_name" ; then system_name="`(hostname) 2>/dev/null`" fi fi test -n "$system_name" && AC_DEFINE_UNQUOTED(SYSTEM_NAME,"$system_name") AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$system_name"]) test -z "$system_name" && system_name="$cf_cv_system_name" test -n "$cf_cv_system_name" && AC_MSG_RESULT("Configuring for $cf_cv_system_name") if test ".$system_name" != ".$cf_cv_system_name" ; then AC_MSG_RESULT(Cached system name ($system_name) does not agree with actual ($cf_cv_system_name)) AC_ERROR("Please remove config.cache and try again.") fi ])dnl dnl --------------------------------------------------------------------------- dnl Check for data that is usually declared in or dnl $1 = the name to check AC_DEFUN([CF_CHECK_ERRNO], [ AC_MSG_CHECKING([declaration of $1]) AC_CACHE_VAL(cf_cv_dcl_$1,[ AC_TRY_COMPILE([ #if HAVE_STDLIB_H #include #endif #include #include #include ], [long x = (long) $1], [eval 'cf_cv_dcl_'$1'=yes'], [eval 'cf_cv_dcl_'$1'=no]')]) eval 'cf_result=$cf_cv_dcl_'$1 AC_MSG_RESULT($cf_result) # It's possible (for near-UNIX clones) that the data doesn't exist AC_CACHE_VAL(cf_cv_have_$1,[ if test $cf_result = no ; then eval 'cf_result=DECL_'$1 CF_UPPER(cf_result,$cf_result) AC_DEFINE_UNQUOTED($cf_result) AC_MSG_CHECKING([existence of $1]) AC_TRY_LINK([ #undef $1 extern long $1; ], [$1 = 2], [eval 'cf_cv_have_'$1'=yes'], [eval 'cf_cv_have_'$1'=no']) eval 'cf_result=$cf_cv_have_'$1 AC_MSG_RESULT($cf_result) else eval 'cf_cv_have_'$1'=yes' fi ]) eval 'cf_result=HAVE_'$1 CF_UPPER(cf_result,$cf_result) eval 'test $cf_cv_have_'$1' = yes && AC_DEFINE_UNQUOTED($cf_result)' ])dnl dnl --------------------------------------------------------------------------- dnl Check if we should include to pick up prototypes for termcap dnl functions. On terminfo systems, these are normally declared in , dnl but may be in . We check for termcap.h as an alternate, but it dnl isn't standard (usually associated with GNU termcap). dnl dnl The 'tgoto()' function is declared in both terminfo and termcap. dnl dnl See CF_TYPE_OUTCHAR for more details. AC_DEFUN([CF_CURSES_TERMCAP], [ AC_REQUIRE([CF_CURSES_TERM_H]) AC_MSG_CHECKING(if we should include curses.h or termcap.h) AC_CACHE_VAL(cf_cv_need_curses_h,[ cf_save_CFLAGS="$CFLAGS" cf_cv_need_curses_h=no for cf_t_opts in "" "NEED_TERMCAP_H" do for cf_c_opts in "" "NEED_CURSES_H" do CFLAGS="$cf_save_CFLAGS $CHECK_DECL_FLAG" test -n "$cf_c_opts" && CFLAGS="$CFLAGS -D$cf_c_opts" test -n "$cf_t_opts" && CFLAGS="$CFLAGS -D$cf_t_opts" AC_TRY_LINK([/* $cf_c_opts $cf_t_opts */ $CHECK_DECL_HDRS], [char *x = (char *)tgoto("")], [test "$cf_cv_need_curses_h" = no && { cf_cv_need_curses_h=maybe cf_ok_c_opts=$cf_c_opts cf_ok_t_opts=$cf_t_opts }], [echo "Recompiling with corrected call (C:$cf_c_opts, T:$cf_t_opts)" >&AC_FD_CC AC_TRY_LINK([ $CHECK_DECL_HDRS], [char *x = (char *)tgoto("",0,0)], [cf_cv_need_curses_h=yes cf_ok_c_opts=$cf_c_opts cf_ok_t_opts=$cf_t_opts])]) CFLAGS="$cf_save_CFLAGS" test "$cf_cv_need_curses_h" = yes && break done test "$cf_cv_need_curses_h" = yes && break done if test "$cf_cv_need_curses_h" != no ; then echo "Curses/termcap test = $cf_cv_need_curses_h (C:$cf_ok_c_opts, T:$cf_ok_t_opts)" >&AC_FD_CC if test -n "$cf_ok_c_opts" ; then if test -n "$cf_ok_t_opts" ; then cf_cv_need_curses_h=both else cf_cv_need_curses_h=curses.h fi elif test -n "$cf_ok_t_opts" ; then cf_cv_need_curses_h=termcap.h elif test "$cf_cv_have_term_h" = yes ; then cf_cv_need_curses_h=term.h else cf_cv_need_curses_h=no fi fi ]) AC_MSG_RESULT($cf_cv_need_curses_h) case $cf_cv_need_curses_h in both) #(vi AC_DEFINE_UNQUOTED(NEED_CURSES_H) AC_DEFINE_UNQUOTED(NEED_TERMCAP_H) ;; curses.h) #(vi AC_DEFINE_UNQUOTED(NEED_CURSES_H) ;; termcap.h) #(vi AC_DEFINE_UNQUOTED(NEED_TERMCAP_H) ;; esac ])dnl dnl --------------------------------------------------------------------------- dnl SVr4 curses should have term.h as well (where it puts the definitions of dnl the low-level interface). This may not be true in old/broken implementations, dnl as well as in misconfigured systems (e.g., gcc configured for Solaris 2.4 dnl running with Solaris 2.5.1). AC_DEFUN([CF_CURSES_TERM_H], [ AC_MSG_CHECKING([for term.h]) AC_CACHE_VAL(cf_cv_have_term_h,[ AC_TRY_COMPILE([ #include #include ], [WINDOW *x], [cf_cv_have_term_h=yes], [cf_cv_have_term_h=no]) ]) AC_MSG_RESULT($cf_cv_have_term_h) test $cf_cv_have_term_h = yes && AC_DEFINE(HAVE_TERM_H) ])dnl dnl --------------------------------------------------------------------------- dnl You can always use "make -n" to see the actual options, but it's hard to dnl pick out/analyze warning messages when the compile-line is long. dnl dnl Sets: dnl ECHO_LD - symbol to prefix "cc -o" lines dnl RULE_CC - symbol to put before implicit "cc -c" lines (e.g., .c.o) dnl SHOW_CC - symbol to put before explicit "cc -c" lines dnl ECHO_CC - symbol to put before any "cc" line dnl AC_DEFUN([CF_DISABLE_ECHO],[ AC_MSG_CHECKING(if you want to see long compiling messages) CF_ARG_DISABLE(echo, [ --disable-echo test: display "compiling" commands], [ ECHO_LD='@echo linking [$]@;' RULE_CC=' @echo compiling [$]<' SHOW_CC=' @echo compiling [$]@' ECHO_CC='@' ],[ ECHO_LD='' RULE_CC='# compiling' SHOW_CC='# compiling' ECHO_CC='' ]) AC_MSG_RESULT($enableval) AC_SUBST(ECHO_LD) AC_SUBST(RULE_CC) AC_SUBST(SHOW_CC) AC_SUBST(ECHO_CC) ])dnl dnl --------------------------------------------------------------------------- dnl Check if 'errno' is declared in AC_DEFUN([CF_ERRNO], [ CF_CHECK_ERRNO(errno) ])dnl dnl --------------------------------------------------------------------------- dnl Look for a non-standard library, given parameters for AC_TRY_LINK. We dnl prefer a standard location, and use -L options only if we do not find the dnl library in the standard library location(s). dnl $1 = library name dnl $2 = includes dnl $3 = code fragment to compile/link dnl $4 = corresponding function-name dnl dnl Sets the variable "$cf_libdir" as a side-effect, so we can see if we had dnl to use a -L option. AC_DEFUN([CF_FIND_LIBRARY], [ cf_cv_have_lib_$1=no cf_libdir="" AC_CHECK_FUNC($4,cf_cv_have_lib_$1=yes,[ cf_save_LIBS="$LIBS" AC_MSG_CHECKING(for $4 in -l$1) LIBS="-l$1 $LIBS" AC_TRY_LINK([$2],[$3], [AC_MSG_RESULT(yes) cf_cv_have_lib_$1=yes ], [AC_MSG_RESULT(no) CF_LIBRARY_PATH(cf_search,$1) for cf_libdir in $cf_search do AC_MSG_CHECKING(for -l$1 in $cf_libdir) LIBS="-L$cf_libdir -l$1 $cf_save_LIBS" AC_TRY_LINK([$2],[$3], [AC_MSG_RESULT(yes) cf_cv_have_lib_$1=yes break], [AC_MSG_RESULT(no) LIBS="$cf_save_LIBS"]) done ]) ]) if test $cf_cv_have_lib_$1 = no ; then AC_ERROR(Cannot link $1 library) fi case $host_os in #(vi linux*) # Suse Linux does not follow /usr/lib convention $1="[$]$1 /lib" ;; esac ])dnl dnl --------------------------------------------------------------------------- dnl Test for the common variations of stdio structures that we can use to dnl test if a character is available for reading. AC_DEFUN([CF_FP_ISREADY], [ AC_CACHE_CHECK(for file-pointer ready definition, cf_cv_fp_isready,[ cf_cv_fp_isready=none while true do read definition test -z "$definition" && break echo "test-compile $definition" 1>&AC_FD_CC AC_TRY_COMPILE([ #include #define isready_c(p) $definition ],[int x = isready_c(stdin)], [echo "$definition" >conftest.env break]) done <<'CF_EOF' ( (p)->_IO_read_ptr < (p)->_IO_read_end) ( (p)->__cnt > 0) ( (p)->__rptr < (p)->__rend) ( (p)->_cnt > 0) ( (p)->_gptr < (p)->_egptr) ( (p)->_r > 0) ( (p)->_rcount > 0) ( (p)->endr < (p)->endb) CF_EOF test -f conftest.env && cf_cv_fp_isready=`cat conftest.env` ]) test "$cf_cv_fp_isready" != none && AC_DEFINE_UNQUOTED(isready_c(p),$cf_cv_fp_isready) ])dnl dnl --------------------------------------------------------------------------- dnl Test for availability of useful gcc __attribute__ directives to quiet dnl compiler warnings. Though useful, not all are supported -- and contrary dnl to documentation, unrecognized directives cause older compilers to barf. AC_DEFUN([CF_GCC_ATTRIBUTES], [ if test -n "$GCC" then cat > conftest.i < conftest.$ac_ext <&AC_FD_CC case $cf_attribute in scanf|printf) cat >conftest.h <conftest.h <>confdefs.h # else # sed -e 's/__attr.*/\/*nothing*\//' conftest.h >>confdefs.h fi done else fgrep define conftest.i >>confdefs.h fi rm -rf conftest* fi ])dnl dnl --------------------------------------------------------------------------- dnl Check if the compiler supports useful warning options. There's a few that dnl we don't use, simply because they're too noisy: dnl dnl -Wconversion (useful in older versions of gcc, but not in gcc 2.7.x) dnl -Wredundant-decls (system headers make this too noisy) dnl -Wtraditional (combines too many unrelated messages, only a few useful) dnl -Wwrite-strings (too noisy, but should review occasionally) dnl -pedantic dnl AC_DEFUN([CF_GCC_WARNINGS], [ if test -n "$GCC" then changequote(,)dnl cat > conftest.$ac_ext <./Imakefile test -f ../Imakefile && cat ../Imakefile >>./Imakefile cat >> ./Imakefile <<'CF_EOF' findstddefs: @echo 'IMAKE_CFLAGS="${ALLDEFINES} ifelse($1,,,$1)"' @echo 'IMAKE_LOADFLAGS="${EXTRA_LOAD_FLAGS} ifelse($2,,,$2)"' CF_EOF if ( $IMAKE $cf_imake_opts 1>/dev/null 2>&AC_FD_CC && test -f Makefile) then CF_VERBOSE(Using $IMAKE) else # sometimes imake doesn't have the config path compiled in. Find it. cf_config= for cf_libpath in $X_LIBS $LIBS ; do case $cf_libpath in # (vi -L*) cf_libpath=`echo .$cf_libpath | sed -e 's/^...//'` cf_libpath=$cf_libpath/X11/config if test -d $cf_libpath ; then cf_config=$cf_libpath break fi ;; esac done if test -z "$cf_config" ; then AC_WARN(Could not find imake config-directory) else cf_imake_opts="$cf_imake_opts -I$cf_config" if ( $IMAKE -v $cf_imake_opts 2>&AC_FD_CC) then CF_VERBOSE(Using $IMAKE $cf_config) else AC_WARN(Cannot run $IMAKE) fi fi fi # GNU make sometimes prints "make[1]: Entering...", which # would confuse us. eval `make findstddefs 2>/dev/null | grep -v make` cd .. rm -rf conftestdir # We use $(ALLDEFINES) rather than $(STD_DEFINES) because the former # declares XTFUNCPROTO there. However, some vendors (e.g., SGI) have # modified it to support site.cf, adding a kludge for the /usr/include # directory. Try to filter that out, otherwise gcc won't find its # headers. if test -n "$GCC" ; then if test -n "$IMAKE_CFLAGS" ; then cf_nostdinc="" cf_std_incl="" cf_cpp_opts="" for cf_opt in $IMAKE_CFLAGS do case "$cf_opt" in -nostdinc) #(vi cf_nostdinc="$cf_opt" ;; -I/usr/include) #(vi cf_std_incl="$cf_opt" ;; *) #(vi cf_cpp_opts="$cf_cpp_opts $cf_opt" ;; esac done if test -z "$cf_nostdinc" ; then IMAKE_CFLAGS="$cf_cpp_opts $cf_std_incl" elif test -z "$cf_std_incl" ; then IMAKE_CFLAGS="$cf_cpp_opts $cf_nostdinc" else CF_VERBOSE(suppressed \"$cf_nostdinc\" and \"$cf_std_incl\") IMAKE_CFLAGS="$cf_cpp_opts" fi fi fi fi AC_SUBST(IMAKE_CFLAGS) AC_SUBST(IMAKE_LOADFLAGS) ])dnl dnl --------------------------------------------------------------------------- dnl Note: must follow AC_FUNC_SETPGRP, but cannot use AC_REQUIRE, since that dnl messes up the messages... AC_DEFUN([CF_KILLPG], [ AC_MSG_CHECKING([if killpg is needed]) AC_CACHE_VAL(cf_cv_need_killpg,[ AC_TRY_RUN([ #include #include RETSIGTYPE handler(s) int s; { exit(0); } main() { #ifdef SETPGRP_VOID (void) setpgrp(); #else (void) setpgrp(0,0); #endif (void) signal(SIGINT, handler); (void) kill(-getpid(), SIGINT); exit(1); }], [cf_cv_need_killpg=no], [cf_cv_need_killpg=yes], [cf_cv_need_killpg=unknown] )]) AC_MSG_RESULT($cf_cv_need_killpg) test $cf_cv_need_killpg = yes && AC_DEFINE(HAVE_KILLPG) ])dnl dnl --------------------------------------------------------------------------- dnl Construct a search-list for a nonstandard library-file AC_DEFUN([CF_LIBRARY_PATH], [$1="" if test -d "$libdir" ; then test "$libdir" != NONE && $1="[$]$1 $libdir $libdir/$2" fi if test -d "$exec_prefix"; then test "$exec_prefix" != NONE && $1="[$]$1 $exec_prefix/lib $exec_prefix/lib/$2" fi if test -d "$prefix"; then test "$prefix" != NONE && \ test "$prefix" != "$exec_prefix" && $1="[$]$1 $prefix/lib $prefix/lib/$2" fi test "$prefix" != /usr/local && $1="[$]$1 /usr/local/lib /usr/local/lib/$2" test "$prefix" != /usr && $1="[$]$1 /usr/lib /usr/lib/$2" ])dnl dnl --------------------------------------------------------------------------- dnl AC_DEFUN([CF_MISSING_CHECK], [ AC_MSG_CHECKING([for missing "$1" extern]) AC_CACHE_VAL([cf_cv_func_$1],[ cf_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $CHECK_DECL_FLAG" AC_TRY_LINK([ $CHECK_DECL_HDRS #undef $1 struct zowie { int a; double b; struct zowie *c; char d; }; extern struct zowie *$1(); ], [ #if HAVE_LIBXT /* needed for SunOS 4.0.3 or 4.1 */ XtToolkitInitialize(); #endif ], [eval 'cf_cv_func_'$1'=yes'], [eval 'cf_cv_func_'$1'=no']) CFLAGS="$cf_save_CFLAGS" ]) eval 'cf_result=$cf_cv_func_'$1 AC_MSG_RESULT($cf_result) test $cf_result = yes && AC_DEFINE_UNQUOTED(MISSING_EXTERN_$2) ])dnl dnl --------------------------------------------------------------------------- dnl AC_DEFUN([CF_MISSING_EXTERN], [for ac_func in $1 do CF_UPPER(ac_tr_func,$ac_func) CF_MISSING_CHECK(${ac_func}, ${ac_tr_func})dnl done ])dnl dnl --------------------------------------------------------------------------- dnl Look for the SVr4 curses clone 'ncurses' in the standard places, adjusting dnl the CPPFLAGS variable. dnl dnl The header files may be installed as either curses.h, or ncurses.h dnl (obsolete). If not installed for overwrite, the curses.h file would be dnl in an ncurses subdirectory (e.g., /usr/include/ncurses), but someone may dnl have installed overwriting the vendor's curses. Only very old versions dnl (pre-1.9.2d, the first autoconf'd version) of ncurses don't define dnl either __NCURSES_H or NCURSES_VERSION in the header. dnl dnl If the installer has set $CFLAGS or $CPPFLAGS so that the ncurses header dnl is already in the include-path, don't even bother with this, since we cannot dnl easily determine which file it is. In this case, it has to be . dnl AC_DEFUN([CF_NCURSES_CPPFLAGS], [ AC_MSG_CHECKING(for ncurses header file) AC_CACHE_VAL(cf_cv_ncurses_header,[ AC_TRY_COMPILE([#include ],[ #ifdef NCURSES_VERSION printf("%s\n", NCURSES_VERSION); #else #ifdef __NCURSES_H printf("old\n"); #else make an error #endif #endif ], [cf_cv_ncurses_header=predefined],[ CF_HEADER_PATH(cf_search,ncurses) test -n "$verbose" && echo for cf_incdir in $cf_search do for cf_header in \ curses.h \ ncurses.h do changequote(,)dnl if egrep "NCURSES_[VH]" $cf_incdir/$cf_header 1>&AC_FD_CC 2>&1; then changequote([,])dnl cf_cv_ncurses_header=$cf_incdir/$cf_header test -n "$verbose" && echo $ac_n " ... found $ac_c" 1>&AC_FD_MSG break fi test -n "$verbose" && echo " ... tested $cf_incdir/$cf_header" 1>&AC_FD_MSG done test -n "$cf_cv_ncurses_header" && break done test -z "$cf_cv_ncurses_header" && AC_ERROR(not found) ])]) AC_MSG_RESULT($cf_cv_ncurses_header) AC_DEFINE(NCURSES) changequote(,)dnl cf_incdir=`echo $cf_cv_ncurses_header | sed -e 's:/[^/]*$::'` changequote([,])dnl case $cf_cv_ncurses_header in # (vi */ncurses.h) AC_DEFINE(HAVE_NCURSES_H) ;; esac case $cf_cv_ncurses_header in # (vi predefined) # (vi cf_cv_ncurses_header=curses.h ;; *) CF_ADD_INCDIR($cf_incdir) ;; esac CF_NCURSES_VERSION ])dnl dnl --------------------------------------------------------------------------- dnl Look for the ncurses library. This is a little complicated on Linux, dnl because it may be linked with the gpm (general purpose mouse) library. dnl Some distributions have gpm linked with (bsd) curses, which makes it dnl unusable with ncurses. However, we don't want to link with gpm unless dnl ncurses has a dependency, since gpm is normally set up as a shared library, dnl and the linker will record a dependency. AC_DEFUN([CF_NCURSES_LIBS], [AC_REQUIRE([CF_NCURSES_CPPFLAGS]) # This works, except for the special case where we find gpm, but # ncurses is in a nonstandard location via $LIBS, and we really want # to link gpm. cf_ncurses_LIBS="" cf_ncurses_SAVE="$LIBS" AC_CHECK_LIB(gpm,Gpm_Open, [AC_CHECK_LIB(gpm,initscr, [LIBS="$cf_ncurses_SAVE"], [cf_ncurses_LIBS="-lgpm"])]) case $host_os in #(vi freebsd*) # This is only necessary if you are linking against an obsolete # version of ncurses (but it should do no harm, since it's static). AC_CHECK_LIB(mytinfo,tgoto,[cf_ncurses_LIBS="-lmytinfo $cf_ncurses_LIBS"]) ;; esac LIBS="$cf_ncurses_LIBS $LIBS" CF_FIND_LIBRARY(ncurses, [#include <${cf_cv_ncurses_header-curses.h}>], [initscr()], initscr) if test -n "$cf_ncurses_LIBS" ; then AC_MSG_CHECKING(if we can link ncurses without $cf_ncurses_LIBS) cf_ncurses_SAVE="$LIBS" for p in $cf_ncurses_LIBS ; do q=`echo $LIBS | sed -e 's/'$p' //' -e 's/'$p'$//'` if test "$q" != "$LIBS" ; then LIBS="$q" fi done AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>], [initscr(); mousemask(0,0); tgoto((char *)0, 0, 0);], [AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no) LIBS="$cf_ncurses_SAVE"]) fi ])dnl dnl --------------------------------------------------------------------------- dnl Check for the version of ncurses, to aid in reporting bugs, etc. AC_DEFUN([CF_NCURSES_VERSION], [AC_MSG_CHECKING(for ncurses version) AC_CACHE_VAL(cf_cv_ncurses_version,[ cf_cv_ncurses_version=no cf_tempfile=out$$ AC_TRY_RUN([ #include <${cf_cv_ncurses_header-curses.h}> int main() { FILE *fp = fopen("$cf_tempfile", "w"); #ifdef NCURSES_VERSION # ifdef NCURSES_VERSION_PATCH fprintf(fp, "%s.%d\n", NCURSES_VERSION, NCURSES_VERSION_PATCH); # else fprintf(fp, "%s\n", NCURSES_VERSION); # endif #else # ifdef __NCURSES_H fprintf(fp, "old\n"); # else make an error # endif #endif exit(0); }],[ cf_cv_ncurses_version=`cat $cf_tempfile` rm -f $cf_tempfile],,[ # This will not work if the preprocessor splits the line after the # Autoconf token. The 'unproto' program does that. cat > conftest.$ac_ext < #undef Autoconf #ifdef NCURSES_VERSION Autoconf NCURSES_VERSION #else #ifdef __NCURSES_H Autoconf "old" #endif ; #endif EOF cf_try="$ac_cpp conftest.$ac_ext 2>&AC_FD_CC | grep '^Autoconf ' >conftest.out" AC_TRY_EVAL(cf_try) if test -f conftest.out ; then changequote(,)dnl cf_out=`cat conftest.out | sed -e 's@^Autoconf @@' -e 's@^[^"]*"@@' -e 's@".*@@'` changequote([,])dnl test -n "$cf_out" && cf_cv_ncurses_version="$cf_out" rm -f conftest.out fi ])]) AC_MSG_RESULT($cf_cv_ncurses_version) ]) dnl --------------------------------------------------------------------------- dnl Within AC_OUTPUT, check if the given file differs from the target, and dnl update it if so. Otherwise, remove the generated file. dnl dnl Parameters: dnl $1 = input, which configure has done substitutions upon dnl $2 = target file dnl AC_DEFUN([CF_OUTPUT_IF_CHANGED],[ if ( cmp -s $1 $2 2>/dev/null ) then echo "$2 is unchanged" rm -f $1 else echo "creating $2" rm -f $2 mv $1 $2 fi ])dnl dnl --------------------------------------------------------------------------- dnl Compute $PROG_EXT, used for non-Unix ports, such as OS/2 EMX. AC_DEFUN([CF_PROG_EXT], [ AC_REQUIRE([CF_CHECK_CACHE]) PROG_EXT= case $cf_cv_system_name in os2*) # We make sure -Zexe is not used -- it would interfere with @PROG_EXT@ CFLAGS="$CFLAGS -Zmt -D__ST_MT_ERRNO__" LDFLAGS=`echo "$LDFLAGS -Zmt -Zcrtdll" | sed "s/-Zexe//g"` PROG_EXT=".exe" ;; esac AC_SUBST(PROG_EXT) ])dnl dnl --------------------------------------------------------------------------- dnl Check for Perl, given the minimum version, to ensure that required features dnl are present. dnl $1 = the minimum version changequote() define(U_TURN_BACK, ]) changequote([, ]) AC_DEFUN(CF_PROG_PERL, [# find perl binary AC_MSG_CHECKING([for ifelse([$1],,perl,[perl-$1])]) AC_CACHE_VAL(cf_cv_prog_PERL, [ifelse([$1],,,[echo "configure:__oline__: ...version $1 required" >&AC_FD_CC ])# allow user to override if test -n "$PERL"; then cf_try="$PERL" else cf_try="perl perl5" fi for cf_prog in $cf_try; do echo "configure:__oline__: trying $cf_prog" >&AC_FD_CC if ($cf_prog -e 'printf "found version %g\n",$]U_TURN_BACK[dnl ifelse([$1],,,[;exit($]U_TURN_BACK[<$1)])') 1>&AC_FD_CC 2>&1; then cf_cv_prog_PERL=$cf_prog break fi done])dnl PERL="$cf_cv_prog_PERL" if test -n "$PERL"; then AC_MSG_RESULT($PERL) else AC_MSG_RESULT(no) fi AC_SUBST(PERL)dnl ])dnl dnl --------------------------------------------------------------------------- dnl CF_RESTARTABLE_PIPEREAD is a modified version of AC_RESTARTABLE_SYSCALLS dnl from acspecific.m4, which uses a read on a pipe (surprise!) rather than a dnl wait() as the test code. apparently there is a POSIX change, which OSF/1 dnl at least has adapted to, which says reads (or writes) on pipes for which no dnl data has been transferred are interruptable _regardless_ of the SA_RESTART dnl bit. yuck. AC_DEFUN([CF_RESTARTABLE_PIPEREAD], [ AC_MSG_CHECKING(for restartable reads on pipes) AC_CACHE_VAL(cf_cv_can_restart_read,[ AC_TRY_RUN( [/* Exit 0 (true) if wait returns something other than -1, i.e. the pid of the child, which means that wait was restarted after getting the signal. */ #include #include #ifdef SA_RESTART sigwrapper(sig, disp) int sig; void (*disp)(); { struct sigaction act, oact; act.sa_handler = disp; sigemptyset(&act.sa_mask); act.sa_flags = SA_RESTART; (void)sigaction(sig, &act, &oact); } #else # define sigwrapper signal #endif ucatch (isig) { } main () { int i, status; int fd[2]; char buff[2]; pipe(fd); i = fork(); if (i == 0) { sleep (2); kill (getppid (), SIGINT); sleep (2); write(fd[1],"done",4); close(fd[1]); exit (0); } sigwrapper (SIGINT, ucatch); status = read(fd[0], buff, sizeof(buff)); wait (&i); exit (status == -1); } ], [cf_cv_can_restart_read=yes], [cf_cv_can_restart_read=no], [cf_cv_can_restart_read=unknown])]) AC_MSG_RESULT($cf_cv_can_restart_read) test $cf_cv_can_restart_read = yes && AC_DEFINE(HAVE_RESTARTABLE_PIPEREAD) ])dnl dnl --------------------------------------------------------------------------- dnl Check for definitions & structures needed for window size-changing dnl FIXME: check that this works with "snake" (HP-UX 10.x) AC_DEFUN([CF_SIZECHANGE], [ AC_MSG_CHECKING([declaration of size-change]) AC_CACHE_VAL(cf_cv_sizechange,[ cf_cv_sizechange=unknown cf_save_CFLAGS="$CFLAGS" for cf_opts in "" "NEED_PTEM_H" do CFLAGS="$cf_save_CFLAGS" test -n "$cf_opts" && CFLAGS="$CFLAGS -D$cf_opts" AC_TRY_COMPILE([#include #if HAVE_TERMIOS_H #include #else #if HAVE_TERMIO_H #include #endif #endif #if NEED_PTEM_H /* This is a workaround for SCO: they neglected to define struct winsize in * termios.h -- it's only in termio.h and ptem.h */ #include #include #endif #if !defined(sun) || !defined(HAVE_TERMIOS_H) #include #endif ],[ #ifdef TIOCGSIZE struct ttysize win; /* FIXME: what system is this? */ int y = win.ts_lines; int x = win.ts_cols; #else #ifdef TIOCGWINSZ struct winsize win; int y = win.ws_row; int x = win.ws_col; #else no TIOCGSIZE or TIOCGWINSZ #endif /* TIOCGWINSZ */ #endif /* TIOCGSIZE */ ], [cf_cv_sizechange=yes], [cf_cv_sizechange=no]) CFLAGS="$cf_save_CFLAGS" if test "$cf_cv_sizechange" = yes ; then echo "size-change succeeded ($cf_opts)" >&AC_FD_CC test -n "$cf_opts" && AC_DEFINE_UNQUOTED($cf_opts) break fi done ]) AC_MSG_RESULT($cf_cv_sizechange) test $cf_cv_sizechange != no && AC_DEFINE(HAVE_SIZECHANGE) ])dnl dnl --------------------------------------------------------------------------- dnl Check for declaration of sys_nerr and sys_errlist in one of stdio.h and dnl errno.h. Declaration of sys_errlist on BSD4.4 interferes with our dnl declaration. Reported by Keith Bostic. AC_DEFUN([CF_SYS_ERRLIST], [ for cf_name in sys_nerr sys_errlist do CF_CHECK_ERRNO($cf_name) done ])dnl dnl --------------------------------------------------------------------------- dnl Look for termcap libraries, or the equivalent in terminfo. AC_DEFUN([CF_TERMCAP_LIBS], [ AC_CACHE_VAL(cf_cv_lib_termcap,[ cf_cv_lib_termcap=none AC_TRY_LINK([],[char *x=(char*)tgoto("",0,0)], [AC_TRY_LINK([],[int x=tigetstr("")], [cf_cv_termlib=terminfo], [cf_cv_termlib=termcap]) CF_VERBOSE(using functions in predefined $cf_cv_termlib LIBS) ],[ ifelse([$1],,,[ if test "$1" = ncurses; then CF_NCURSES_CPPFLAGS CF_NCURSES_LIBS cf_cv_termlib=terminfo fi ]) # HP-UX 9.x terminfo has setupterm, but no tigetstr. if test "$termlib" = none; then AC_CHECK_LIB(termlib, tigetstr, [LIBS="$LIBS -ltermlib" cf_cv_lib_termcap=terminfo]) fi if test "$cf_cv_lib_termcap" = none; then AC_CHECK_LIB(termlib, tgoto, [LIBS="$LIBS -ltermlib" cf_cv_lib_termcap=termcap]) fi if test "$cf_cv_lib_termcap" = none; then # allow curses library for broken AIX system. AC_CHECK_LIB(curses, initscr, [LIBS="$LIBS -lcurses" cf_cv_lib_termcap=termcap]) AC_CHECK_LIB(termcap, tgoto, [LIBS="$LIBS -ltermcap" cf_cv_lib_termcap=termcap]) fi if test "$cf_cv_lib_termcap" = none; then AC_CHECK_LIB(termcap, tgoto, [LIBS="$LIBS -ltermcap" cf_cv_lib_termcap=termcap]) fi if test "$cf_cv_lib_termcap" = none; then AC_CHECK_LIB(ncurses, tgoto, [LIBS="$LIBS -lncurses" cf_cv_lib_termcap=ncurses]) fi ]) if test "$cf_cv_lib_termcap" = none; then AC_ERROR([Can't find -ltermlib, -lcurses, or -ltermcap]) fi ])])dnl dnl --------------------------------------------------------------------------- dnl Check for return and param type of 3rd -- OutChar() -- param of tputs(). dnl dnl For this check, and for CF_CURSES_TERMCAP, the $CHECK_DECL_HDRS variable dnl must point to a header file containing this (or equivalent): dnl dnl #ifdef NEED_CURSES_H dnl # if HAVE_NCURSES_H dnl # include dnl # else dnl # include dnl # endif dnl #endif dnl #if HAVE_TERM_H dnl # include dnl #endif dnl #if NEED_TERMCAP_H dnl # include dnl #endif dnl AC_DEFUN([CF_TYPE_OUTCHAR], [ AC_REQUIRE([CF_CURSES_TERMCAP]) AC_MSG_CHECKING([declaration of tputs 3rd param]) AC_CACHE_VAL(cf_cv_type_outchar,[ cf_cv_type_outchar="int OutChar(int)" cf_cv_found=no cf_save_CFLAGS="$CFLAGS" CFLAGS="$CFLAGS $CHECK_DECL_FLAG" for P in int void; do for Q in int void; do for R in int char; do for S in "" const; do AC_TRY_COMPILE([$CHECK_DECL_HDRS], [extern $Q OutChar($R); extern $P tputs ($S char *string, int nlines, $Q (*_f)($R)); tputs("", 1, OutChar)], [cf_cv_type_outchar="$Q OutChar($R)" cf_cv_found=yes break]) done test $cf_cv_found = yes && break done test $cf_cv_found = yes && break done test $cf_cv_found = yes && break done ]) AC_MSG_RESULT($cf_cv_type_outchar) case $cf_cv_type_outchar in int*) AC_DEFINE(OUTC_RETURN) ;; esac case $cf_cv_type_outchar in *char*) AC_DEFINE(OUTC_ARGS,char c) ;; esac CFLAGS="$cf_save_CFLAGS" ])dnl dnl --------------------------------------------------------------------------- dnl Make an uppercase version of a variable dnl $1=uppercase($2) AC_DEFUN([CF_UPPER], [ changequote(,)dnl $1=`echo $2 | tr '[a-z]' '[A-Z]'` changequote([,])dnl ])dnl dnl --------------------------------------------------------------------------- dnl Use AC_VERBOSE w/o the warnings AC_DEFUN([CF_VERBOSE], [test -n "$verbose" && echo " $1" 1>&AC_FD_MSG ])dnl dnl --------------------------------------------------------------------------- dnl Check for Xaw (Athena) libraries dnl AC_DEFUN([CF_X_ATHENA], [AC_REQUIRE([CF_X_TOOLKIT]) cf_x_athena=${cf_x_athena-Xaw} AC_ARG_WITH(Xaw3d, [ --with-Xaw3d link with Xaw 3d library], [cf_x_athena=Xaw3d]) AC_ARG_WITH(neXtaw, [ --with-neXtaw link with neXT Athena library], [cf_x_athena=neXtaw]) AC_CHECK_HEADERS(X11/$cf_x_athena/SimpleMenu.h) AC_CHECK_LIB(Xmu, XmuClientWindow,,[ AC_CHECK_LIB(Xmu_s, XmuClientWindow)]) AC_CHECK_LIB(Xext,XextCreateExtension, [LIBS="-lXext $LIBS"]) AC_CHECK_LIB($cf_x_athena, XawSimpleMenuAddGlobalActions, [LIBS="-l$cf_x_athena $LIBS"],[ AC_CHECK_LIB(${cf_x_athena}_s, XawSimpleMenuAddGlobalActions, [LIBS="-l${cf_x_athena}_s $LIBS"], AC_ERROR( [Unable to successfully link Athena library (-l$cf_x_athena) with test program]), [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS])]) CF_UPPER(CF_X_ATHENA_LIBS,HAVE_LIB_$cf_x_athena) AC_DEFINE_UNQUOTED($CF_X_ATHENA_LIBS) ])dnl dnl --------------------------------------------------------------------------- dnl Check for Motif or Lesstif libraries (they should be indistinguishable) AC_DEFUN([CF_X_MOTIF], [AC_REQUIRE([CF_X_TOOLKIT])dnl AC_CHECK_HEADERS(X11/IntrinsicI.h Xm/XmP.h) AC_CHECK_LIB(gen,regcmp) AC_CHECK_LIB(Xmu,XmuClientWindow) AC_CHECK_LIB(Xp,XpStartDoc,,,[$LIBS $X_EXTRA_LIBS]) AC_CHECK_LIB(Xext,XextCreateExtension, [LIBS="-lXext $LIBS"]) AC_CHECK_LIB(Xpm, XpmCreatePixmapFromXpmImage, [LIBS="-lXpm $LIBS"],, [$LIBS $X_EXTRA_LIBS]) AC_CHECK_LIB(XIM,XmbTextListToTextProperty)dnl needed for Unixware's Xm AC_CHECK_LIB(Xm, XmProcessTraversal, [LIBS="-lXm $LIBS"], AC_ERROR( [Unable to successfully link Motif library (-lXm) with test program]), [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS]) dnl ])dnl dnl --------------------------------------------------------------------------- AC_DEFUN([CF_X_OPENLOOK], [AC_REQUIRE([CF_X_TOOLKIT])dnl if test -n "$OPENWINHOME"; then X_LIBS="$X_LIBS -L${OPENWINHOME}/lib" X_CFLAGS="$X_CFLAGS -I${OPENWINHOME}/include" fi LDFLAGS="$LDFLAGS $X_LIBS" AC_CHECK_LIB(Xmu,XmuClientWindow) AC_CHECK_LIB(Xol, OlToolkitInitialize, [LIBS="-lXol -lm $LIBS"], AC_ERROR( [Unable to successfully link OpenLook library (-lXol) with test program])) dnl ])dnl dnl --------------------------------------------------------------------------- dnl Check for X Toolkit libraries dnl AC_DEFUN([CF_X_TOOLKIT], [ AC_REQUIRE([CF_CHECK_CACHE]) # We need to check for -lsocket and -lnsl here in order to work around an # autoconf bug. autoconf-2.12 is not checking for these prior to checking for # the X11R6 -lSM and -lICE libraries. The resultant failures cascade... # (tested on Solaris 2.5 w/ X11R6) SYSTEM_NAME=`echo "$cf_cv_system_name"|tr ' ' -` cf_have_X_LIBS=no case $SYSTEM_NAME in changequote(,)dnl irix[56]*) ;; changequote([,])dnl clix*) # FIXME: modify the library lookup in autoconf to # allow _s.a suffix ahead of .a AC_CHECK_LIB(c_s,open, [LIBS="-lc_s $LIBS" AC_CHECK_LIB(bsd,gethostname, [LIBS="-lbsd $LIBS" AC_CHECK_LIB(nsl_s,gethostname, [LIBS="-lnsl_s $LIBS" AC_CHECK_LIB(X11_s,XOpenDisplay, [LIBS="-lX11_s $LIBS" AC_CHECK_LIB(Xt_s,XtAppInitialize, [LIBS="-lXt_s $LIBS" cf_have_X_LIBS=Xt ]) ]) ]) ]) ]) ;; *) AC_CHECK_LIB(socket,socket) AC_CHECK_LIB(nsl,gethostname) ;; esac if test $cf_have_X_LIBS = no ; then AC_PATH_XTRA LDFLAGS="$LDFLAGS $X_LIBS" CFLAGS="$CFLAGS $X_CFLAGS" AC_CHECK_LIB(X11,XOpenDisplay, [LIBS="-lX11 $LIBS"],, [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS]) AC_CHECK_LIB(Xt, XtAppInitialize, [AC_DEFINE(HAVE_LIBXT) cf_have_X_LIBS=Xt LIBS="-lXt $X_PRE_LIBS $LIBS"],, [$X_PRE_LIBS $LIBS $X_EXTRA_LIBS]) else LDFLAGS="$LDFLAGS $X_LIBS" CFLAGS="$CFLAGS $X_CFLAGS" fi if test $cf_have_X_LIBS = no ; then AC_WARN( [Unable to successfully link X Toolkit library (-lXt) with test program. You will have to check and add the proper libraries by hand to makefile.]) fi ])dnl