dnl Macros for auto-configure script. dnl by T.E.Dickey dnl and Jim Spath dnl dnl Created: 1997/1/28 dnl Updated: 1997/8/28 dnl dnl --------------------------------------------------------------------------- dnl --------------------------------------------------------------------------- dnl Add an include-directory to $CPPFLAGS. Don't add /usr/include, since it's dnl redundant. Also, don't add /usr/local/include if we're using gcc. AC_DEFUN([CF_ADD_INCDIR], [ for cf_add_incdir in $1 do while true do case $cf_add_incdir in /usr/include) # (vi ;; /usr/local/include) # (vi test -z "$GCC" && CPPFLAGS="$CPPFLAGS -I$cf_add_incdir" ;; *) # (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" -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 Check for existence of alternate-character-set support in curses, so we dnl can decide to use it for box characters. dnl AC_DEFUN([CF_ALT_CHAR_SET], [ AC_MSG_CHECKING([if curses supports alternate-character set]) AC_CACHE_VAL(cf_cv_alt_char_set,[ AC_TRY_LINK([ #include <$cf_cv_ncurses_header> ],[chtype x = acs_map['l']; acs_map['m'] = 0], [cf_cv_alt_char_set=yes], [cf_cv_alt_char_set=no])]) AC_MSG_RESULT($cf_cv_alt_char_set) test $cf_cv_alt_char_set = yes && AC_DEFINE(ALT_CHAR_SET) ])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 Allow user to enable a normally-off option. AC_DEFUN([CF_ARG_ENABLE], [CF_ARG_OPTION($1,[$2 (default: off)],[$3],[$4],no)])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 curses.h defines TRUE/FALSE (it does under SVr4). AC_DEFUN([CF_BOOL_DEFS], [ AC_MSG_CHECKING(if TRUE/FALSE are defined) AC_CACHE_VAL(cf_cv_bool_defs,[ AC_TRY_COMPILE([ #include <$cf_cv_ncurses_header> #include ],[int x = TRUE, y = FALSE], [cf_cv_bool_defs=yes], [cf_cv_bool_defs=no])]) AC_MSG_RESULT($cf_cv_bool_defs) if test "$cf_cv_bool_defs" = no ; then AC_DEFINE(TRUE,(1)) AC_DEFINE(FALSE,(0)) fi ])dnl dnl --------------------------------------------------------------------------- dnl Check if curses supports color. (Note that while SVr3 curses supports dnl color, it does this differently from SVr4 curses; more work would be needed dnl to accommodate SVr3). dnl AC_DEFUN([CF_COLOR_CURSES], [ AC_MSG_CHECKING(if curses supports color attributes) AC_CACHE_VAL(cf_cv_color_curses,[ AC_TRY_LINK([ #include <$cf_cv_ncurses_header> ], [chtype x = COLOR_BLUE; has_colors(); start_color(); #ifndef NCURSES_BROKEN wbkgd(curscr, getbkgd(stdscr)); /* X/Open XPG4 aka SVr4 Curses */ #endif ], [cf_cv_color_curses=yes], [cf_cv_color_curses=no]) ]) AC_MSG_RESULT($cf_cv_color_curses) if test $cf_cv_color_curses = yes ; then AC_DEFINE(COLOR_CURSES) test ".$cf_cv_ncurses_broken" != .yes && AC_DEFINE(HAVE_GETBKGD) fi ]) dnl --------------------------------------------------------------------------- dnl Look for the curses libraries. Older curses implementations may require dnl termcap/termlib to be linked as well. AC_DEFUN([CF_CURSES_LIBS],[ AC_CHECK_FUNC(initscr,,[ case $host_os in #(vi freebsd*) #(vi AC_CHECK_LIB(mytinfo,tgoto,[LIBS="-lmytinfo $LIBS"]) ;; *hp-hpux10.*) AC_CHECK_LIB(Hcurses,initscr,[ # HP's header uses __HP_CURSES, but user claims _HP_CURSES. LIBS="-lHcurses $LIBS" CFLAGS="-D__HP_CURSES -D_HP_CURSES $CFLAGS" ],[ AC_CHECK_LIB(cur_color,initscr,[ LIBS="-lcur_color $LIBS" CFLAGS="-I/usr/include/curses_colr $CFLAGS" ])]) ;; esac if test -d /usr/5lib ; then # SunOS 3.x or 4.x CPPFLAGS="$CPPFLAGS -I/usr/5include" LIBS="$LIBS -L/usr/5lib" # FIXME: check if we need/use -R option # elif test -d /usr/ccs/lib ; then # # Solaris 5.x # LIBS="$LIBS -L/usr/ccs/lib -R/usr/ccs/lib" fi cf_save_LIBS="$LIBS" AC_CHECK_FUNC(tgoto,[ AC_CHECK_LIB(curses,initscr,,[ AC_ERROR(cannot link curses)]) ],[ AC_CHECK_LIB(termcap, tgoto,[ LIBS="-ltermcap $cf_save_LIBS" AC_CHECK_LIB(curses,initscr,,[ AC_CHECK_LIB(cursesX,initscr,,[ AC_CHECK_LIB(jcurses,initscr,,[ AC_ERROR(cannot link curses)])])]) ],[ AC_CHECK_LIB(curses,initscr,,[ AC_ERROR(cannot link curses)])]) ]) ])]) dnl --------------------------------------------------------------------------- dnl Solaris 2.x curses provides a "performance" tradeoff according to whether dnl CURS_PERFORMANCE is defined. If defined, the implementation defines macros dnl that access the WINDOW structure. Otherwise, function calls are used. AC_DEFUN([CF_CURS_PERFORMANCE], [ AC_MSG_CHECKING([for curses performance tradeoff]) AC_CACHE_VAL(cf_cv_curs_performance,[ cf_cv_curs_performance=no AC_TRY_COMPILE([ #include <$cf_cv_ncurses_header>],[ #if defined(wbkgdset) && defined(clearok) && defined(getbkgd) int x = ERR; #else int x = ; /* force an error */ #endif ],[ AC_TRY_COMPILE([ #define CURS_PERFORMANCE #include <$cf_cv_ncurses_header>],[ #if defined(wbkgdset) && defined(clearok) && defined(getbkgd) int x = ; /* force an error */ #else int x = ERR; #endif ],[cf_cv_curs_performance=yes])])]) AC_MSG_RESULT($cf_cv_curs_performance) test $cf_cv_curs_performance = yes && AC_DEFINE(CURS_PERFORMANCE) ])dnl dnl --------------------------------------------------------------------------- dnl Check for a program in the given list $3, defining the corresponding dnl program variable $2. dnl AC_DEFUN([CF_DEFINE_PROG],[ AC_MSG_CHECKING(for $1) AC_CACHE_VAL(cf_cv_$2,[ cf_cv_$2=unknown for cv_path in $3 do if test -f $cv_path ; then cf_cv_$2=$cv_path break fi done ]) AC_MSG_RESULT($cf_cv_$2) AC_DEFINE_UNQUOTED($2,"$cf_cv_$2") ]) 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], [ AC_MSG_CHECKING([for errno external decl]) AC_CACHE_VAL(cf_cv_extern_errno,[ AC_TRY_COMPILE([ #include ], [int x = errno], [cf_cv_extern_errno=yes], [cf_cv_extern_errno=no])]) AC_MSG_RESULT($cf_cv_extern_errno) test $cf_cv_extern_errno = no && AC_DEFINE(DECL_ERRNO) ])dnl dnl --------------------------------------------------------------------------- AC_DEFUN([CF_FANCY_CURSES], [ AC_MSG_CHECKING(if curses supports fancy attributes) AC_CACHE_VAL(cf_cv_fancy_curses,[ AC_TRY_LINK([ #include <$cf_cv_ncurses_header> ], [attrset(A_UNDERLINE|A_BOLD|A_REVERSE); wattrset(stdscr, A_BLINK|A_DIM); attroff(A_BOLD); keypad(stdscr,TRUE); ], [cf_cv_fancy_curses=yes], [cf_cv_fancy_curses=no]) ]) AC_MSG_RESULT($cf_cv_fancy_curses) test $cf_cv_fancy_curses = yes && AC_DEFINE(FANCY_CURSES) ]) 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 ])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], [EXTRA_CFLAGS="" if test -n "$GCC" then changequote(,)dnl cat > conftest.$ac_ext < AC_DEFUN([CF_LOCALE], [ AC_MSG_CHECKING(for setlocale()) AC_CACHE_VAL(cf_cv_locale,[ AC_TRY_LINK([#include ], [setlocale(LC_ALL, "")], [cf_cv_locale=yes], [cf_cv_locale=no]) ]) AC_MSG_RESULT($cf_cv_locale) test $cf_cv_locale = yes && AC_DEFINE(LOCALE) ]) dnl --------------------------------------------------------------------------- dnl Check for the use of 'include' in 'make' (BSDI is a special case) dnl The symbol $ac_make is set in AC_MAKE_SET, as a side-effect. AC_DEFUN([CF_MAKE_INCLUDE], [ AC_MSG_CHECKING(for style of include in makefiles) make_include_left="" make_include_right="" make_include_quote="unknown" cf_inc=head$$ cf_dir=subd$$ echo 'RESULT=OK' >$cf_inc mkdir $cf_dir for cf_include in "include" ".include" "!include" do for cf_quote in '' '"' do cat >$cf_dir/makefile <&AC_FD_CC | grep cf_make_include=OK` if test -n "$cf_make_include"; then make_include_left="$cf_include" make_include_quote="$cf_quote" break else echo Tried 1>&AC_FD_CC cat $cf_dir/makefile 1>&AC_FD_CC fi done test -n "$cf_make_include" && break done rm -rf $cf_inc $cf_dir if test -z "$make_include_left" ; then AC_ERROR(Your $ac_make program does not support includes) fi if test ".$make_include_quote" != .unknown ; then make_include_left="$make_include_left $make_include_quote" make_include_right="$make_include_quote" fi AC_MSG_RESULT(${make_include_left}file${make_include_right}) AC_SUBST(make_include_left) AC_SUBST(make_include_right) ])dnl dnl --------------------------------------------------------------------------- dnl Check for pre-1.9.9g ncurses (among other problems, the most obvious is dnl that color combinations don't work). AC_DEFUN([CF_NCURSES_BROKEN], [ AC_MSG_CHECKING(for obsolete/broken version of ncurses) if test "$cf_cv_ncurses_version" != no ; then AC_CACHE_VAL(cf_cv_ncurses_broken,[ AC_TRY_COMPILE([ #include <$cf_cv_ncurses_header>],[ #if defined(NCURSES_VERSION) && defined(wgetbkgd) make an error #else int x = 1 #endif ], [cf_cv_ncurses_broken=no], [cf_cv_ncurses_broken=yes]) ]) AC_MSG_RESULT($cf_cv_ncurses_broken=yes) if test "$cf_cv_ncurses_broken" = yes ; then AC_MSG_WARN(hmm... you should get an up-to-date version of ncurses) AC_DEFINE(NCURSES_BROKEN) fi fi ])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("maybe 1.8.7\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 if egrep "NCURSES" $cf_incdir/$cf_header 1>&5 2>&1; then cf_cv_ncurses_header=$cf_incdir/$cf_header test -n "$verbose" && echo $ac_n " ... found $ac_c" 1>&6 break fi test -n "$verbose" && echo " ... tested $cf_incdir/$cf_header" 1>&6 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 ])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]) cf_ncurses_LIBS="" AC_CHECK_LIB(gpm,Gpm_Open,[AC_CHECK_LIB(gpm,initscr,,[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>], [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>], [initscr(); 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 cat > conftest.$ac_ext < #ifdef NCURSES_VERSION Autoconf NCURSES_VERSION #else #ifdef __NCURSES_H Autoconf "old" #endif #endif EOF cf_try="$ac_cpp conftest.$ac_ext 2>&5 | 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@^[^\"]*\"@@' -e 's@\".*@@'` changequote([,])dnl test -n "$cf_out" && cf_cv_ncurses_version="$cf_out" fi ]) AC_MSG_RESULT($cf_cv_ncurses_version) ]) dnl --------------------------------------------------------------------------- dnl After checking for functions in the default $LIBS, make a further check dnl for the functions that are netlib-related (these aren't always in the dnl libc, etc., and have to be handled specially because there are conflicting dnl and broken implementations. dnl Common library requirements (in order): dnl -lresolv -lsocket -lnsl dnl -lnsl -lsocket dnl -lsocket dnl -lbsd AC_DEFUN([CF_NETLIBS],[ cf_test_netlibs=no AC_MSG_CHECKING(for network libraries) AC_CACHE_VAL(cf_cv_netlibs,[ AC_MSG_RESULT(working...) cf_cv_netlibs="" cf_test_netlibs=yes AC_CHECK_FUNCS(gethostname,,[ CF_RECHECK_FUNC(gethostname,nsl,cf_cv_netlibs,[ CF_RECHECK_FUNC(gethostname,socket,cf_cv_netlibs)])]) # # FIXME: sequent needs this library (i.e., -lsocket -linet -lnsl), but # I don't know the entrypoints - 97/7/22 TD AC_HAVE_LIBRARY(inet,cf_cv_netlibs="-linet $cf_cv_netlibs") # if test "$ac_cv_func_lsocket" != no ; then AC_CHECK_FUNCS(socket,,[ CF_RECHECK_FUNC(socket,socket,cf_cv_netlibs,[ CF_RECHECK_FUNC(socket,bsd,cf_cv_netlibs)])]) fi # AC_CHECK_FUNCS(gethostbyname,,[ CF_RECHECK_FUNC(gethostbyname,nsl,cf_cv_netlibs)]) # AC_CHECK_FUNCS(strcasecmp,,[ CF_RECHECK_FUNC(strcasecmp,resolv,cf_cv_netlibs)]) ]) LIBS="$LIBS $cf_cv_netlibs" test $cf_test_netlibs = no && echo "$cf_cv_netlibs" >&AC_FD_MSG ])dnl dnl --------------------------------------------------------------------------- dnl Check for the symbol NGROUPS AC_DEFUN([CF_NGROUPS], [ AC_MSG_CHECKING(if NGROUPS is defined) AC_CACHE_VAL(cf_cv_ngroups,[ AC_TRY_COMPILE([ #if HAVE_SYS_PARAM_H #include #endif #if HAVE_LIMITS_H #include #endif ],[int x = NGROUPS], [cf_cv_ngroups=yes], [AC_TRY_COMPILE([ #if HAVE_SYS_PARAM_H #include #endif #if HAVE_LIMITS_H #include #endif ],[int x = NGROUPS_MAX], [cf_cv_ngroups=NGROUPS_MAX], [cf_cv_ngroups=no]) ]) AC_MSG_RESULT($cf_cv_ngroups) if test "$cf_cv_ngroups" = no ; then AC_DEFINE(NGROUPS,16) elif test "$cf_cv_ngroups" = NGROUPS_MAX ; then AC_DEFINE(NGROUPS,NGROUPS_MAX) fi ]) ])dnl dnl --------------------------------------------------------------------------- dnl Check for a given program, defining corresponding symbol. dnl $1 = environment variable, which is suffixed by "_PATH" in the #define. dnl $2 = program name to find. dnl dnl If there is more than one token in the result, #define the remaining tokens dnl to $1_ARGS. We need this for 'install' in particular. dnl dnl FIXME: we should allow this to be overridden by environment variables dnl AC_DEFUN([CF_PATH_PROG],[ test -z "[$]$1" && $1=$2 if test "$with_full_paths" = yes ; then AC_PATH_PROG($1,$2,[$]$1) else AC_MSG_CHECKING(for $2) AC_MSG_RESULT([$]$1) fi cf_path_prog="" cf_path_args="" IFS="${IFS= }"; cf_save_ifs="$IFS"; IFS="${IFS}:" for cf_temp in $ac_cv_path_$1 do if test -z "$cf_path_prog" ; then cf_path_prog="$cf_temp" elif test -z "$cf_path_args" ; then cf_path_args="$cf_temp" else cf_path_args="$cf_path_args $cf_temp" fi done IFS="$cf_save_ifs" AC_DEFINE_UNQUOTED($1_PATH,"$cf_path_prog") test -n "$cf_path_args" && AC_DEFINE_UNQUOTED($1_ARGS,"$cf_path_args") ])dnl dnl --------------------------------------------------------------------------- dnl Re-check on a function to see if we can pick it up by adding a library. dnl $1 = function to check dnl $2 = library to check in dnl $3 = environment to update (e.g., $LIBS) dnl $4 = what to do if this fails dnl dnl This uses 'unset' if the shell happens to support it, but leaves the dnl configuration variable set to 'unknown' if not. This is a little better dnl than the normal autoconf test, which gives misleading results if a test dnl for the function is made (e.g., with AC_CHECK_FUNC) after this macro is dnl used (autoconf does not distinguish between a null token and one that is dnl set to 'no'). AC_DEFUN([CF_RECHECK_FUNC],[ AC_CHECK_LIB($2,$1,[ CF_UPPER(cf_tr_func,$1) AC_DEFINE_UNQUOTED(HAVE_$cf_tr_func) ac_cv_func_$1=yes $3="-l$2 [$]$3"],[ ac_cv_func_$1=unknown unset ac_cv_func_$1 2>/dev/null $4], [[$]$3]) ])dnl dnl --------------------------------------------------------------------------- dnl Check for broken definition of 'remove()'. This is (in particular) broken dnl on the older version of SCO (I'd cite version if I knew where to look) by dnl having #define remove to __unlink, which appears in no library. dnl dnl Fortuitously, we can combine this with a more general test: do we have dnl 'unlink()' but no 'remove()'. Note, however, that we cannot simply #define dnl remove to unlink, but have to make a fallback function. dnl AC_DEFUN([CF_REMOVE_BROKEN], [ AC_MSG_CHECKING(for broken/missing definition of remove) AC_CACHE_VAL(cf_cv_baddef_remove,[ AC_TRY_LINK( [#include ], [remove("dummy")], [cf_cv_baddef_remove=no], [AC_TRY_LINK( [#include int __unlink(name) { return unlink(name); } ], [remove("dummy")], [cf_cv_baddef_remove=yes], [cf_cv_baddef_remove=unknown]) ]) ]) AC_MSG_RESULT($cf_cv_baddef_remove) test "$cf_cv_baddef_remove" = yes && AC_DEFINE(NEED_REMOVE) ])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 #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_MSG 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 Look for the slang header files in the standard places, adjusting the dnl CPPFLAGS variable. dnl AC_DEFUN([CF_SLANG_CPPFLAGS], [ AC_MSG_CHECKING(for slang header file) AC_CACHE_VAL(cf_cv_slang_header,[ AC_TRY_COMPILE([#include ], [printf("%s\n", SLANG_VERSION)], [cf_cv_slang_header=predefined],[ CF_HEADER_PATH(cf_search,slang) for cf_incdir in $cf_search do for cf_header in \ slang.h do if egrep "SLANG_VERSION" $cf_incdir/$cf_header 1>&5 2>&1; then cf_cv_slang_header=$cf_incdir/$cf_header break fi done test -n "$cf_cv_slang_header" && break done test -z "$cf_cv_slang_header" && AC_ERROR(not found) ])]) AC_MSG_RESULT($cf_cv_slang_header) AC_DEFINE(USE_SLANG) changequote(,)dnl cf_incdir=`echo $cf_cv_slang_header | sed -e 's:/[^/]*$::'` changequote([,])dnl case $cf_cv_slang_header in # (vi predefined) # (vi ;; *) CF_ADD_INCDIR($cf_incdir) ;; esac ])dnl dnl --------------------------------------------------------------------------- dnl Look for the slang library. AC_DEFUN([CF_SLANG_LIBS], [ AC_CHECK_FUNC(acos,,[CF_RECHECK_FUNC(acos,m,LIBS)]) CF_FIND_LIBRARY(slang, [#include ], [SLtt_get_screen_size()], SLtt_get_screen_size) ])dnl dnl --------------------------------------------------------------------------- dnl Remove "-g" option from the compiler options AC_DEFUN([CF_STRIP_G_OPT], [$1=`echo ${$1} | sed -e 's/-g //' -e 's/-g$//'`])dnl dnl --------------------------------------------------------------------------- dnl Remove "-O" option from the compiler options AC_DEFUN([CF_STRIP_O_OPT],[ changequote(,)dnl $1=`echo ${$1} | sed -e 's/-O[1-9]\? //' -e 's/-O[1-9]\?$//'` changequote([,])dnl ])dnl dnl --------------------------------------------------------------------------- dnl Check for declaration of sys_errlist in one of stdio.h and errno.h. dnl Declaration of sys_errlist on BSD4.4 interferes with our declaration. dnl Reported by Keith Bostic. AC_DEFUN([CF_SYS_ERRLIST], [ AC_MSG_CHECKING([declaration of sys_errlist]) AC_CACHE_VAL(cf_cv_dcl_sys_errlist,[ AC_TRY_COMPILE([ #include #include #include ], [char *c = (char *) *sys_errlist], [cf_cv_dcl_sys_errlist=yes], [cf_cv_dcl_sys_errlist=no])]) AC_MSG_RESULT($cf_cv_dcl_sys_errlist) # It's possible (for near-UNIX clones) that sys_errlist doesn't exist if test $cf_cv_dcl_sys_errlist = no ; then AC_DEFINE(DECL_SYS_ERRLIST) AC_MSG_CHECKING([existence of sys_errlist]) AC_CACHE_VAL(cf_cv_have_sys_errlist,[ AC_TRY_LINK([#include ], [char *c = (char *) *sys_errlist], [cf_cv_have_sys_errlist=yes], [cf_cv_have_sys_errlist=no])]) AC_MSG_RESULT($cf_cv_have_sys_errlist) fi ])dnl dnl --------------------------------------------------------------------------- AC_DEFUN([CF_SYSTEM_MAIL_FLAGS], [ AC_MSG_CHECKING([system mail flags]) AC_CACHE_VAL(cf_cv_system_mail_flags,[ case $cf_cv_SYSTEM_MAIL in */mmdf/*) [cf_cv_system_mail_flags="-mlruxto,cc\\\\*"] ;; *) [cf_cv_system_mail_flags="-t -oi"] esac ]) AC_MSG_RESULT($cf_cv_system_mail_flags) AC_DEFINE_UNQUOTED(SYSTEM_MAIL_FLAGS, "$cf_cv_system_mail_flags") ])dnl dnl --------------------------------------------------------------------------- dnl Look for termcap libraries, needed by some versions of slang. AC_DEFUN([CF_TERMCAP_LIBS], [ AC_CACHE_VAL(cf_cv_lib_termcap,[ cf_cv_lib_termcap=none # 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 if including both termio.h and termios.h die like on DG.UX AC_DEFUN([CF_TERMIO_AND_TERMIOS], [ AC_MSG_CHECKING([termio.h and termios.h]) AC_CACHE_VAL(cf_cv_termio_and_termios,[ AC_TRY_COMPILE([ #if HAVE_TERMIO_H #include #endif #if HAVE_TERMIOS_H #include #endif ], [putchar (0x0a)], [cf_cv_termio_and_termios=yes], [cf_cv_termio_and_termios=no])]) AC_MSG_RESULT($cf_cv_termio_and_termios) test $cf_cv_termio_and_termios = no && AC_DEFINE(TERMIO_AND_TERMIOS) ])dnl dnl --------------------------------------------------------------------------- AC_DEFUN([CF_TTYTYPE], [ AC_MSG_CHECKING(if ttytype is declared in curses library) AC_CACHE_VAL(cf_cv_have_ttytype,[ AC_TRY_LINK([#include <$cf_cv_ncurses_header>], [char *x = &ttytype[1]; *x = 1], [cf_cv_have_ttytype=yes], [cf_cv_have_ttytype=no]) ]) AC_MSG_RESULT($cf_cv_have_ttytype) test $cf_cv_have_ttytype = yes && AC_DEFINE(HAVE_TTYTYPE) ]) 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 --------------------------------------------------------------------------- AC_DEFUN([CF_UNION_WAIT], [ AC_MSG_CHECKING([for union wait]) AC_CACHE_VAL(cf_cv_type_unionwait,[ AC_TRY_COMPILE([ #include #if HAVE_SYS_WAIT_H #include #endif #if HAVE_WAITSTATUS_H #include #endif ], [union wait x], [cf_cv_type_unionwait=yes], [cf_cv_type_unionwait=no])]) AC_MSG_RESULT($cf_cv_type_unionwait) test $cf_cv_type_unionwait = yes && AC_DEFINE(HAVE_TYPE_UNIONWAIT) ])dnl dnl --------------------------------------------------------------------------- AC_DEFUN([CF_UTMP], [ AC_MSG_CHECKING(if struct utmp is declared) AC_CACHE_VAL(cf_cv_have_utmp,[ AC_TRY_COMPILE([ #include #include ], [struct utmp x; char *y = &x.ut_host[0]], [cf_cv_have_utmp=yes], [AC_TRY_COMPILE([#include ], [struct utmpx x; char *y = &x.ut_host[0]], [cf_cv_have_utmp=utmpx], [cf_cv_have_utmp=no]) ]) ]) AC_MSG_RESULT($cf_cv_have_utmp) test $cf_cv_have_utmp != no && AC_DEFINE(HAVE_UTMP) test $cf_cv_have_utmp = utmpx && AC_DEFINE(UTMPX_FOR_UTMP) ]) dnl --------------------------------------------------------------------------- dnl Wrapper for AC_ARG_WITH to ensure that user supplies a pathname, not just dnl defaulting to yes/no. dnl dnl $1 = option name dnl $2 = help-text dnl $3 = environment variable to set dnl $4 = default value, shown in the help-message, must be a constant dnl $5 = default value, if it's an expression & cannot be in the help-message dnl AC_DEFUN([CF_WITH_PATH], [AC_ARG_WITH($1,[$2 ](default: ifelse($4,,empty,$4)),, ifelse($4,,[withval="${$3}"],[withval="${$3-ifelse($5,,$4,$5)}"]))dnl case ".$withval" in #(vi ./*) #(vi ;; .\${*) #(vi eval withval="$withval" case ".$withval" in #(vi .NONE/*) withval=`echo $withval | sed -e s@NONE@$ac_default_prefix@` ;; esac ;; #(vi *) AC_ERROR(expected a pathname for $1) ;; esac eval $3="$withval" AC_SUBST($3)dnl ])dnl