dnl This file is stolen in its entirety from freeciv-1.8.1 dnl FC_CHECK_X_LIB(LIBRARY, FUNCTION [, ACTION-IF-FOUND [, dnl ACTION-IF-NOT-FOUND]]) dnl dnl This macro is intended to search for X11-related libraries. It takes the dnl following variables for input: dnl X_LIBS -- prefixed to all linker lines dnl X_EXTRA_LIBS -- suffixed to all linker lines dnl LIBS -- suffixed to all linker lines (after X_EXTRA_LIBS) dnl Thus, the trial linker line will be "$X_LIBS -l$1 $X_EXTRA_LIBS $LIBS". dnl dnl The following variables are output: dnl X_EXTRA_LIBS -- contains "-l$1 $X_EXTRA_LIBS" if the link succeeds dnl dnl Thus, the intended usage of this macro is something like this: dnl AC_PATH_XTRA dnl X_LIBS="$X_LIBS $X_PRE_LIBS" dnl dnl Is it just me or is AC_PATH_XTRA broken? dnl FC_CHECK_X_LIB(X11, XOpenDisplay, , AC_MSG_ERROR("Need X11")) dnl FC_CHECK_X_LIB(Xext, XShapeCombineMask) dnl [etc.] dnl LIBS="$X_LIBS $X_EXTRA_LIBS $LIBS" dnl AC_DEFUN(FC_CHECK_X_LIB, [AC_MSG_CHECKING([for $2 in X library -l$1]) dnl Use a cache variable name containing both the library and function name, dnl because the test really is for library $1 defining function $2, not dnl just for library $1. Separate tests with the same $1 and different $2s dnl may have different results. ac_lib_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'` AC_CACHE_VAL(ac_cv_lib_$ac_lib_var, [ac_save_LIBS="$LIBS" LIBS="$X_LIBS -l$1 $X_EXTRA_LIBS $LIBS" AC_TRY_LINK(dnl ifelse([$2], [main], , dnl Avoid conflicting decl of main. [/* Override any gcc2 internal prototype to avoid an error. */ ]ifelse(AC_LANG, CPLUSPLUS, [#ifdef __cplusplus extern "C" #endif ])dnl [/* We use char because int might match the return type of a gcc2 builtin and then its argument prototype would still apply. */ char $2(); ]), [$2()], eval "ac_cv_lib_$ac_lib_var=yes", eval "ac_cv_lib_$ac_lib_var=no") LIBS="$ac_save_LIBS" ])dnl if eval "test \"`echo '$ac_cv_lib_'$ac_lib_var`\" = yes"; then AC_MSG_RESULT(yes) ifelse([$3], , [changequote(, )dnl ac_tr_lib=HAVE_LIB`echo $1 | sed -e 's/[^a-zA-Z0-9_]/_/g' \ -e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/'` changequote([, ])dnl AC_DEFINE_UNQUOTED($ac_tr_lib) X_EXTRA_LIBS="-l$1 $X_EXTRA_LIBS" ], [$3]) else AC_MSG_RESULT(no) ifelse([$4], , , [$4 ])dnl fi ]) dnl FC_EXPAND_DIR(VARNAME, DIR) dnl expands occurrences of ${prefix} and ${exec_prefix} in the given DIR, dnl and assigns the resulting string to VARNAME dnl example: FC_EXPAND_DIR(LOCALEDIR, "$datadir/locale") dnl eg, then: AC_DEFINE_UNQUOTED(LOCALEDIR, "$LOCALEDIR") dnl by Alexandre Oliva dnl from http://www.cygnus.com/ml/automake/1998-Aug/0040.html AC_DEFUN(FC_EXPAND_DIR, [ $1=$2 $1=`( test "x$prefix" = xNONE && prefix="$ac_default_prefix" test "x$exec_prefix" = xNONE && exec_prefix="${prefix}" eval echo \""[$]$1"\" )` ]) dnl FC_XPM_PATHS dnl Allow user to specify extra include/lib paths for Xpm, with dnl --with-xpm=prefix --with-xpm-lib=dir --with-xpm-include=dir dnl The latter two override the prefix form. dnl Sets variables xpm_libdir and xpm_incdir dnl If user supplies a path, use that. dnl If user specifies "no", set that, meaning "no extra path" dnl If user specifies "yes" (default), then use /usr/local if it looks dnl likely, else set to "no". dnl Doesn't do any cache stuff. dnl AC_DEFUN(FC_XPM_PATHS, [AC_MSG_CHECKING(extra paths for Xpm) dnl General Xpm prefix: dnl "no" means no prefix is required, "yes" means try /usr/local AC_ARG_WITH(xpm-prefix, [ --with-xpm-prefix=DIR Xpm files are in DIR/lib and DIR/include, or use the following to set them separately:], xpm_prefix="$withval", xpm_prefix="yes" ) if test "$xpm_prefix" = "yes" || test "$xpm_prefix" = "no"; then xpm_libdir="$xpm_prefix" xpm_incdir="$xpm_prefix" else xpm_libdir="$xpm_prefix/lib" xpm_incdir="$xpm_prefix/include" fi dnl May override general Xpm prefix with explicit individual paths: AC_ARG_WITH(xpm-lib, [ --with-xpm-lib=DIR Xpm library is in DIR], xpm_libdir="$withval" ) AC_ARG_WITH(xpm-include, [ --with-xpm-include=DIR Xpm header file is in DIR (that is, DIR/X11/xpm.h)], xpm_incdir="$withval" ) dnl If xpm-lib path was not specified, try /usr/local/lib if that dnl looks likely; we don't actually try to link. fc_xpm_default=/usr/local if test "$xpm_libdir" = "yes"; then xpm_libdir="no" fc_xpm_default_lib="$fc_xpm_default/lib" for fc_extension in a so sl; do if test -r $fc_xpm_default_lib/libXpm.$fc_extension; then xpm_libdir=$fc_xpm_default_lib break fi done fi dnl Likewise for xpm-include with /usr/local/include; dnl we don't actually try to include. if test "$xpm_incdir" = "yes"; then xpm_incdir="no" fc_xpm_default_inc="no" if test -r $fc_xpm_default_inc/X11/xpm.h; then xpm_incdir=$fc_xpm_default_inc fi fi AC_MSG_RESULT([library $xpm_libdir, include $xpm_incdir]) ])