dnl macros used for DIALOG configure script dnl -- T.Dickey dnl $Id: aclocal.m4,v 1.8 2000/06/29 10:30:06 tom Exp $ dnl --------------------------------------------------------------------------- dnl --------------------------------------------------------------------------- dnl AC_DEFUN(AM_GNU_GETTEXT, [AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_PROG_RANLIB])dnl AC_REQUIRE([AC_ISC_POSIX])dnl AC_REQUIRE([AC_HEADER_STDC])dnl AC_REQUIRE([AC_C_CONST])dnl AC_REQUIRE([AC_C_INLINE])dnl AC_REQUIRE([AC_TYPE_OFF_T])dnl AC_REQUIRE([AC_TYPE_SIZE_T])dnl AC_REQUIRE([AC_FUNC_ALLOCA])dnl AC_REQUIRE([AC_FUNC_MMAP])dnl AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \ unistd.h sys/param.h]) AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \ strdup __argz_count __argz_stringify __argz_next]) if test "${ac_cv_func_stpcpy+set}" != "set"; then AC_CHECK_FUNCS(stpcpy) fi if test "${ac_cv_func_stpcpy}" = "yes"; then AC_DEFINE(HAVE_STPCPY) fi AM_LC_MESSAGES AM_WITH_NLS if test "x$CATOBJEXT" != "x"; then if test "x$ALL_LINGUAS" = "x"; then LINGUAS= else AC_MSG_CHECKING(for catalogs to be installed) NEW_LINGUAS= for lang in ${LINGUAS=$ALL_LINGUAS}; do case "$ALL_LINGUAS" in *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;; esac done LINGUAS=$NEW_LINGUAS AC_MSG_RESULT($LINGUAS) fi dnl Construct list of names of catalog files to be constructed. if test -n "$LINGUAS"; then for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done fi fi dnl The reference to in the installed file dnl must be resolved because we cannot expect the users of this dnl to define HAVE_LOCALE_H. if test $ac_cv_header_locale_h = yes; then INCLUDE_LOCALE_H="#include " else INCLUDE_LOCALE_H="\ /* The system does not provide the header . Take care of it yourself. */" fi AC_SUBST(INCLUDE_LOCALE_H) dnl Determine which catalog format we have (if any is needed) dnl For now we know about two different formats: dnl Linux libc-5 and the normal X/Open format if test "$USE_NLS" = "yes"; then test -d intl || mkdir intl if test "$CATOBJEXT" = ".cat"; then AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen) dnl Transform the SED scripts while copying because some dumb SEDs dnl cannot handle comments. sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed fi dnl po2tbl.sed is always needed. if test -f $srcdir/intl/po2tbl.sed.in ; then rm -f intl/po2tbl.sed sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \ $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed fi fi dnl In the intl/Makefile.in we have a special dependency which only dnl makes sense for gettext. We comment this out for non-gettext dnl packages. if test "$PACKAGE" = "gettext"; then GT_NO="#NO#" GT_YES= else GT_NO= GT_YES="#YES#" fi AC_SUBST(GT_NO) AC_SUBST(GT_YES) dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly dnl find the mkinstalldirs script in another subdir but ($top_srcdir). dnl Try to locate it. dnl changed mkinstalldirs to mkdirs.sh for Lynx /je spath 1998-Aug-21 MKINSTALLDIRS= if test -n "$ac_aux_dir"; then MKINSTALLDIRS="$ac_aux_dir/mkdirs.sh" fi if test -z "$MKINSTALLDIRS"; then MKINSTALLDIRS="\$(top_srcdir)/mkdirs.sh" fi AC_SUBST(MKINSTALLDIRS) dnl *** For now the libtool support in intl/Makefile is not for real. l= AC_SUBST(l) dnl Generate list of files to be processed by xgettext which will dnl be included in po/Makefile. if test "x$srcdir" != "x."; then if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then posrcprefix="$srcdir/" else posrcprefix="../$srcdir/" fi else posrcprefix="../" fi if test -f $srcdir/po/POTFILES.in ; then if test "$USE_NLS" = "yes"; then test -d po || mkdir po rm -f po/POTFILES sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \ < $srcdir/po/POTFILES.in > po/POTFILES fi fi ])dnl dnl --------------------------------------------------------------------------- dnl dnl Check whether LC_MESSAGES is available in . dnl Ulrich Drepper , 1995. dnl dnl This file can be copied and used freely without restrictions. It can dnl be used in projects which are not available under the GNU Public License dnl but which still want to provide support for the GNU gettext functionality. dnl Please note that the actual code is *not* freely available. dnl dnl serial 1 dnl AC_DEFUN(AM_LC_MESSAGES, [if test $ac_cv_header_locale_h = yes; then AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES, [AC_TRY_LINK([#include ], [return LC_MESSAGES], am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)]) if test $am_cv_val_LC_MESSAGES = yes; then AC_DEFINE(HAVE_LC_MESSAGES) fi fi]) dnl --------------------------------------------------------------------------- dnl Search path for a program which passes the given test. dnl Ulrich Drepper , 1996. dnl dnl This file can be copied and used freely without restrictions. It can dnl be used in projects which are not available under the GNU Public License dnl but which still want to provide support for the GNU gettext functionality. dnl Please note that the actual code is *not* freely available. dnl dnl serial 1 dnl dnl dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR, dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) AC_DEFUN(AM_PATH_PROG_WITH_TEST, [# Extract the first word of "$2", so it can be a program name with args. set dummy $2; ac_word=[$]2 AC_MSG_CHECKING([for $ac_word]) AC_CACHE_VAL(ac_cv_path_$1, [case "[$]$1" in /*) ac_cv_path_$1="[$]$1" # Let the user override the test with a path. ;; *) IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" for ac_dir in ifelse([$5], , $PATH, [$5]); do test -z "$ac_dir" && ac_dir=. if test -f $ac_dir/$ac_word; then if [$3]; then ac_cv_path_$1="$ac_dir/$ac_word" break fi fi done IFS="$ac_save_ifs" dnl If no 4th arg is given, leave the cache variable unset, dnl so AC_PATH_PROGS will keep looking. ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" ])dnl ;; esac])dnl $1="$ac_cv_path_$1" if test -n "[$]$1"; then AC_MSG_RESULT([$]$1) else AC_MSG_RESULT(no) fi AC_SUBST($1)dnl ]) dnl --------------------------------------------------------------------------- dnl Macro to add for using GNU gettext. dnl Ulrich Drepper , 1995. dnl dnl This file can be copied and used freely without restrictions. It can dnl be used in projects which are not available under the GNU Public License dnl but which still want to provide support for the GNU gettext functionality. dnl Please note that the actual code is *not* freely available. dnl dnl serial 5 dnl AC_DEFUN(AM_WITH_NLS, [AC_MSG_CHECKING([whether NLS is requested]) dnl Default is enabled NLS AC_ARG_ENABLE(nls, [ --enable-nls use Native Language Support], USE_NLS=$enableval, USE_NLS=no) AC_MSG_RESULT($USE_NLS) AC_SUBST(USE_NLS) USE_INCLUDED_LIBINTL=no dnl If we use NLS figure out what method if test "$USE_NLS" = "yes"; then AC_DEFINE(ENABLE_NLS) AC_MSG_CHECKING([whether included gettext is requested]) AC_ARG_WITH(included-gettext, [ --with-included-gettext use the GNU gettext library included here], nls_cv_force_use_gnu_gettext=$withval, nls_cv_force_use_gnu_gettext=no) AC_MSG_RESULT($nls_cv_force_use_gnu_gettext) nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" if test "$nls_cv_force_use_gnu_gettext" != "yes"; then dnl User does not insist on using GNU NLS library. Figure out what dnl to use. If gettext or catgets are available (in this order) we dnl use this. Else we have to fall back to GNU NLS library. dnl catgets is only used if permitted by option --with-catgets. nls_cv_header_intl= nls_cv_header_libgt= CATOBJEXT=NONE AC_CHECK_HEADER(libintl.h, [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc, [AC_TRY_LINK([#include ], [return (int) gettext ("")], gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)]) if test "$gt_cv_func_gettext_libc" != "yes"; then AC_CHECK_LIB(intl, bindtextdomain, [ gt_save_LIBS="$LIBS" LIBS="$gt_save_LIBS -lintl" AC_CACHE_CHECK([for gettext in libintl], gt_cv_func_gettext_libintl, [AC_TRY_LINK([], [return (int) gettext ("")], gt_cv_func_gettext_libintl=yes, gt_cv_func_gettext_libintl=no)]) LIBS="$gt_save_LIBS"]) fi if test "$gt_cv_func_gettext_libintl" = yes; then LIBS="$LIBS -lintl" fi if test "$gt_cv_func_gettext_libc" = "yes" \ || test "$gt_cv_func_gettext_libintl" = "yes"; then AC_DEFINE(HAVE_GETTEXT) AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl if test "$MSGFMT" != "no"; then AC_CHECK_FUNCS(dcgettext) AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT) AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :) AC_TRY_LINK(, [extern int _nl_msg_cat_cntr; return _nl_msg_cat_cntr], [CATOBJEXT=.gmo DATADIRNAME=share], [CATOBJEXT=.mo DATADIRNAME=lib]) INSTOBJEXT=.mo fi fi ]) if test "$CATOBJEXT" = "NONE"; then AC_MSG_CHECKING([whether catgets can be used]) AC_ARG_WITH(catgets, [ --with-catgets use catgets functions if available], nls_cv_use_catgets=$withval, nls_cv_use_catgets=no) AC_MSG_RESULT($nls_cv_use_catgets) if test "$nls_cv_use_catgets" = "yes"; then dnl No gettext in C library. Try catgets next. AC_CHECK_LIB(i, main) AC_CHECK_FUNC(catgets, [AC_DEFINE(HAVE_CATGETS) INTLOBJS="\$(CATOBJS)" AC_PATH_PROG(GENCAT, gencat, no)dnl if test "$GENCAT" != "no"; then AC_PATH_PROG(GMSGFMT, gmsgfmt, no) if test "$GMSGFMT" = "no"; then AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt, [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no) fi AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :) USE_INCLUDED_LIBINTL=yes CATOBJEXT=.cat INSTOBJEXT=.cat DATADIRNAME=lib INTLDEPS='$(top_builddir)/intl/libintl.a' INTLLIBS=$INTLDEPS LIBS=`echo $LIBS | sed -e 's/-lintl//'` nls_cv_header_intl=intl/libintl.h nls_cv_header_libgt=intl/libgettext.h fi]) fi fi if test "$CATOBJEXT" = "NONE"; then dnl Neither gettext nor catgets in included in the C library. dnl Fall back on GNU gettext library. nls_cv_use_gnu_gettext=yes fi fi if test "$nls_cv_use_gnu_gettext" = "yes"; then dnl Mark actions used to generate GNU NLS library. INTLOBJS="\$(GETTOBJS)" AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt) AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT) AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :) AC_SUBST(MSGFMT) USE_INCLUDED_LIBINTL=yes CATOBJEXT=.gmo INSTOBJEXT=.mo DATADIRNAME=share INTLDEPS='$(top_builddir)/intl/libintl.a' INTLLIBS=$INTLDEPS LIBS=`echo $LIBS | sed -e 's/-lintl//'` nls_cv_header_intl=intl/libintl.h nls_cv_header_libgt=intl/libgettext.h fi dnl Test whether we really found GNU xgettext. if test "$XGETTEXT" != ":"; then dnl If it is no GNU xgettext we define it as : so that the dnl makefiles still can work. if $XGETTEXT --omit-header /dev/null 2> /dev/null; then : ; else AC_MSG_RESULT( [found xgettext program is not GNU xgettext; ignore it]) XGETTEXT=":" fi fi # We need to process the po/ directory. POSUB=po else DATADIRNAME=share nls_cv_header_intl=intl/libintl.h nls_cv_header_libgt=intl/libgettext.h fi # If this is used in GNU gettext we have to set USE_NLS to `yes' # because some of the sources are only built for this goal. if test "$PACKAGE" = gettext; then USE_NLS=yes USE_INCLUDED_LIBINTL=yes fi # If we really do not use included intl, suppress the command that # would attempt to symlink the two copies of its header. if test "$USE_INCLUDED_LIBINTL" != yes; then nls_cv_header_libgt= nls_cv_header_intl= fi AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl) AC_OUTPUT_COMMANDS([ #(vi case "\$CONFIG_FILES" in *po/makefile.in*) #(vi sed -e "/POTFILES =/r po/POTFILES" po/makefile.in > po/makefile ;; *po/Makefile.in*) sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile esac]) dnl These rules are solely for the distribution goal. While doing this dnl we only have to keep exactly one list of the available catalogs dnl in configure.in. for lang in $ALL_LINGUAS; do GMOFILES="$GMOFILES $lang.gmo" POFILES="$POFILES $lang.po" done dnl Make all variables we use known to autoconf. AC_SUBST(USE_INCLUDED_LIBINTL) AC_SUBST(CATALOGS) AC_SUBST(CATOBJEXT) AC_SUBST(DATADIRNAME) AC_SUBST(GMOFILES) AC_SUBST(INSTOBJEXT) AC_SUBST(INTLDEPS) AC_SUBST(INTLLIBS) AC_SUBST(INTLOBJS) AC_SUBST(POFILES) AC_SUBST(POSUB) ]) 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 Allow user to disable a normally-on option. AC_DEFUN([CF_ARG_DISABLE], [CF_ARG_OPTION($1,[$2],[$3],[$4],yes)])dnl dnl --------------------------------------------------------------------------- dnl Allow user to enable a normally-off option. AC_DEFUN([CF_ARG_ENABLE], [CF_ARG_OPTION($1,[$2],[$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 Top-level macro for configuring an application with a bundled copy of dnl the intl and po directories for gettext. dnl dnl $1 specifies either Makefile or makefile, defaulting to the former. AC_DEFUN([CF_BUNDLED_INTL],[ cf_makefile=ifelse($1,,Makefile,$1) dnl Set of available languages (based on source distribution). Note that dnl setting $LINGUAS overrides $ALL_LINGUAS. Some environments set $LINGUAS dnl rather than $LC_ALL test -z "$ALL_LINGUAS" && ALL_LINGUAS=`test -d $srcdir/po && cd $srcdir/po && echo *.po|sed -e 's/\.po//g' -e 's/*//'` AM_GNU_GETTEXT INTLDIR_MAKE= MSG_DIR_MAKE= SUB_MAKEFILE= CF_OUR_MESSAGES if test "$USE_INCLUDED_LIBINTL" = yes ; then if test "$nls_cv_force_use_gnu_gettext" = yes ; then SUB_MAKEFILE="intl/$cf_makefile" else INTLDIR_MAKE="#" fi if test $use_our_messages = no ; then MSG_DIR_MAKE="#" SUB_MAKEFILE= fi if test "$use_our_messages" = yes ; then SUB_MAKEFILE="$SUB_MAKEFILE po/$cf_makefile.in:po/$cf_makefile.inn" else MSG_DIR_MAKE="#" fi elif test "$USE_NLS" = yes ; then AC_CHECK_HEADERS(libintl.h) INTLDIR_MAKE="#" SUB_MAKEFILE="po/$cf_makefile.in:po/$cf_makefile.inn" else INTLDIR_MAKE="#" MSG_DIR_MAKE="#" fi dnl We might want to use a preinstalled message library rather than the one dnl which is bundled with this program. if test -z "$MSG_DIR_MAKE" ; then if test $use_our_messages = no ; then MSG_DIR_MAKE="#" SUB_MAKEFILE= fi fi if test -z "$INTLDIR_MAKE" ; then CPPFLAGS="$CPPFLAGS -I../intl" fi AC_SUBST(INTLDIR_MAKE) AC_SUBST(MSG_DIR_MAKE) dnl FIXME: the underlying AM_GNU_GETTEXT macro either needs some fixes or a dnl little documentation. It doesn't define anything so that we can ifdef our dnl own code, except ENABLE_NLS, which is too vague to be of any use. if test "$USE_INCLUDED_LIBINTL" = yes ; then if test "$nls_cv_force_use_gnu_gettext" = yes ; then AC_DEFINE(HAVE_GETTEXT) elif test "$nls_cv_use_gnu_gettext" = yes ; then AC_DEFINE(HAVE_GETTEXT) fi if test -n "$nls_cv_header_intl" ; then AC_DEFINE(HAVE_LIBINTL_H) fi fi ])dnl 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"]) ;; hpux10.*|hpux11.*) AC_CHECK_LIB(cur_colr,initscr,[ LIBS="-lcur_colr $LIBS" CFLAGS="-I/usr/include/curses_colr $CFLAGS" ac_cv_func_initscr=yes ],[ 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_cv_func_initscr=yes ])]) ;; linux*) # Suse Linux does not follow /usr/lib convention LIBS="$LIBS -L/lib" ;; esac if test ".$With5lib" != ".no" ; then if test -d /usr/5lib ; then # SunOS 3.x or 4.x CPPFLAGS="$CPPFLAGS -I/usr/5include" LIBS="$LIBS -L/usr/5lib" fi fi if test ".$ac_cv_func_initscr" != .yes ; then cf_save_LIBS="$LIBS" cf_term_lib="" cf_curs_lib="" # Check for library containing tgoto. Do this before curses library # because it may be needed to link the test-case for initscr. AC_CHECK_FUNC(tgoto,[cf_term_lib=predefined],[ for cf_term_lib in termcap termlib unknown do AC_CHECK_LIB($cf_term_lib,tgoto,[break]) done ]) # Check for library containing initscr test "$cf_term_lib" != predefined && test "$cf_term_lib" != unknown && LIBS="-l$cf_term_lib $cf_save_LIBS" for cf_curs_lib in cursesX curses ncurses xcurses jcurses unknown do AC_CHECK_LIB($cf_curs_lib,initscr,[break]) done test $cf_curs_lib = unknown && AC_ERROR(no curses library found) LIBS="-l$cf_curs_lib $cf_save_LIBS" if test "$cf_term_lib" = unknown ; then AC_MSG_CHECKING(if we can link with $cf_curs_lib library) AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>], [initscr()], [cf_result=yes], [cf_result=no]) AC_MSG_RESULT($cf_result) test $cf_result = no && AC_ERROR(Cannot link curses library) elif test "$cf_term_lib" != predefined ; then AC_MSG_CHECKING(if we need both $cf_curs_lib and $cf_term_lib libraries) AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>], [initscr(); tgoto((char *)0, 0, 0);], [cf_result=no], [ LIBS="-l$cf_curs_lib -l$cf_term_lib $cf_save_LIBS" AC_TRY_LINK([#include <${cf_cv_ncurses_header-curses.h}>], [initscr()], [cf_result=yes], [cf_result=error]) ]) AC_MSG_RESULT($cf_result) fi fi ])]) 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 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 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 = library class, usually the same as library name dnl $3 = includes dnl $4 = code fragment to compile/link dnl $5 = corresponding function-name dnl $6 = flag, nonnull if failure causes an error-exit 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], [ eval 'cf_cv_have_lib_'$1'=no' cf_libdir="" AC_CHECK_FUNC($5, eval 'cf_cv_have_lib_'$1'=yes',[ cf_save_LIBS="$LIBS" AC_MSG_CHECKING(for $5 in -l$1) LIBS="-l$1 $LIBS" AC_TRY_LINK([$3],[$4], [AC_MSG_RESULT(yes) eval 'cf_cv_have_lib_'$1'=yes' ], [AC_MSG_RESULT(no) CF_LIBRARY_PATH(cf_search,$2) 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([$3],[$4], [AC_MSG_RESULT(yes) eval 'cf_cv_have_lib_'$1'=yes' break], [AC_MSG_RESULT(no) LIBS="$cf_save_LIBS"]) done ]) ]) eval 'cf_found_library=[$]cf_cv_have_lib_'$1 ifelse($6,,[ if test $cf_found_library = no ; then AC_ERROR(Cannot link $1 library) fi ]) ])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 <cf_makeflags.tmp </dev/null` case "$cf_result" in .*k) cf_result=`${MAKE-make} -k -f cf_makeflags.tmp CC=cc 2>/dev/null` case "$cf_result" in .*CC=*) cf_cv_makeflags= ;; *) cf_cv_makeflags=$cf_option ;; esac break ;; *) echo no match "$cf_result" ;; esac done rm -f cf_makeflags.tmp]) AC_MSG_RESULT($cf_cv_makeflags) AC_SUBST(cf_cv_makeflags) ])dnl dnl --------------------------------------------------------------------------- dnl Checks for libraries. At least one UNIX system, Apple Macintosh dnl Rhapsody 5.5, does not have -lm. We cannot use the simpler dnl AC_CHECK_LIB(m,sin), because that fails for C++. AC_DEFUN([CF_MATH_LIB], [ AC_CACHE_CHECK(if -lm needed for math functions, cf_cv_need_libm,[ AC_TRY_LINK([ #include #include ], [double x = rand(); printf("result = %g\n", ]ifelse($2,,sin(x),$2)[)], [cf_cv_need_libm=no], [cf_cv_need_libm=yes])]) if test "$cf_cv_need_libm" = yes then ifelse($1,,[ LIBS="$LIBS -lm" ],[$1=-lm]) fi ]) 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,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 Check if we use the messages included with this program AC_DEFUN([CF_OUR_MESSAGES], [ use_our_messages=no if test "$USE_NLS" = yes ; then if test -d $srcdir/po ; then AC_MSG_CHECKING(if we should use included message-library) AC_ARG_ENABLE(included-msgs, [ --enable-included-msgs use included messages, for i18n support], [use_our_messages=$enableval], [use_our_messages=yes]) fi AC_MSG_RESULT($use_our_messages) fi test $use_our_messages = yes && USE_OUR_MESSAGES= AC_SUBST(USE_OUR_MESSAGES) ])dnl dnl --------------------------------------------------------------------------- dnl Shorthand macro for substituting things that the user may override dnl with an environment variable. dnl dnl $1 = long/descriptive name dnl $2 = environment variable dnl $3 = default value AC_DEFUN([CF_SUBST], [AC_CACHE_VAL(cf_cv_subst_$2,[ AC_MSG_CHECKING(for $1 (symbol $2)) test -z "[$]$2" && $2=$3 AC_MSG_RESULT([$]$2) AC_SUBST($2) cf_cv_subst_$2=[$]$2]) $2=${cf_cv_subst_$2} ])dnl dnl --------------------------------------------------------------------------- dnl Derive the system-type (our main clue to the method of building shared dnl libraries). AC_DEFUN([CF_SYSTYPE], [ AC_MSG_CHECKING(for system type) AC_CACHE_VAL(cf_cv_systype,[ AC_ARG_WITH(system-type, [ --with-system-type=XXX test: override derived host system-type], [cf_cv_systype=$withval], [ changequote(,)dnl cf_cv_systype="`(uname -s || hostname || echo unknown) 2>/dev/null |sed -e s'/[:\/.-]/_/'g | sed 1q`" changequote([,])dnl if test -z "$cf_cv_systype"; then cf_cv_systype=unknown;fi ])]) AC_MSG_RESULT($cf_cv_systype) ])dnl dnl --------------------------------------------------------------------------- dnl Derive the system name, as a check for reusing the autoconf cache AC_DEFUN([CF_SYS_NAME], [ SYS_NAME=`(uname -s -r || uname -a || hostname) 2>/dev/null | sed 1q` test -z "$SYS_NAME" && SYS_NAME=unknown AC_DEFINE_UNQUOTED(SYS_NAME,"$SYS_NAME") AC_CACHE_VAL(cf_cv_system_name,[cf_cv_system_name="$SYS_NAME"]) if test ".$SYS_NAME" != ".$cf_cv_system_name" ; then AC_MSG_RESULT("Cached system name does not agree with actual") AC_ERROR("Please remove config.cache and try again.") fi]) 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 Make an uppercase version of a given name AC_DEFUN([CF_UPPERCASE], [ changequote(,)dnl $2=`echo $1 |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 Test if we should define X/Open source for curses, needed on Digital Unix dnl 4.x, to see the extended functions, but breaks on IRIX 6.x. AC_DEFUN([CF_XOPEN_CURSES], [ AC_CACHE_CHECK(if we must define _XOPEN_SOURCE_EXTENDED,cf_cv_need_xopen_extension,[ AC_TRY_LINK([ #include #include <${cf_cv_ncurses_header-curses.h}>],[ long x = winnstr(stdscr, "", 0)], [cf_cv_need_xopen_extension=no], [AC_TRY_LINK([ #define _XOPEN_SOURCE_EXTENDED #include #include <${cf_cv_ncurses_header-curses.h}>],[ long x = winnstr(stdscr, "", 0)], [cf_cv_need_xopen_extension=yes], [cf_cv_need_xopen_extension=no])])]) test $cf_cv_need_xopen_extension = yes && CFLAGS="$CFLAGS -D_XOPEN_SOURCE_EXTENDED" ])dnl