# ESO_FIND_FILE(file, directories, variable) #------------------------------------------ # Search for file in directories. Set variable to the first location # where file was found, if file is not found at all variable is set to NO. AC_DEFUN(ESO_FIND_FILE, [ $3=NO for i in $2; do for j in $1; do echo "configure: __oline__: $i/$j" >&AC_FD_CC if test -r "$i/$j"; then echo "taking that" >&AC_FD_CC $3=$i break 2 fi done done ]) # ESO_PROG_CC_FLAG(FLAG, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) #----------------------------------------------------------------- AC_DEFUN(ESO_PROG_CC_FLAG, [ AC_REQUIRE([AC_PROG_CC]) flag=`echo $1 | sed 'y%.=/+-%___p_%'` AC_CACHE_CHECK([whether $CC supports -$1], [eso_cv_prog_cc_$flag], [ eval "eso_cv_prog_cc_$flag=no" AC_LANG_PUSH(C) echo 'int main() { return 0; }' >conftest.$ac_ext try_compile="`$CC -$1 -c conftest.$ac_ext 2>&1`" if test -z "$try_compile"; then try_link="`$CC -$1 -o conftest$ac_exeext \ conftest.$ac_ext 2>&1`" if test -z "$try_link"; then eval "eso_cv_prog_cc_$flag=yes" fi fi rm -f conftest* AC_LANG_POP(C) ]) if eval "test \"`echo '$eso_cv_prog_cc_'$flag`\" = yes"; then : $2 else : $3 fi ]) # ESO_ENABLE_DEBUG(debug=no) #--------------------------- AC_DEFUN(ESO_ENABLE_DEBUG, [ AC_REQUIRE([AC_PROG_CC]) AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [creates debugging code [[default=$1]]]), eso_enable_debug=$enableval, eso_enable_debug=$1) AC_CACHE_CHECK([whether debugging code should be created], eso_cv_enable_debug, eso_cv_enable_debug=$eso_enable_debug) if test "$eso_cv_enable_debug" = "yes"; then eso_clean_CFLAGS="`echo $CFLAGS | sed -e 's/-O[[0-9]]//g' \ -e 's/-O//g'`" if test $ac_cv_prog_cc_g = yes; then eso_clean_CFLAGS="`echo $eso_clean_CFLAGS | sed -e 's/-g//g'`" CFLAGS="-g" else CFLAGS="" fi ESO_PROG_CC_FLAG([Wall], [CFLAGS="$CFLAGS -Wall"]) ESO_PROG_CC_FLAG([W], [CFLAGS="$CFLAGS -W"]) CFLAGS="$CFLAGS $eso_clean_CFLAGS" else CFLAGS="`echo $CFLAGS | sed -e 's/-g//g'`" fi ]) # ESO_ENABLE_STRICT(strict=no) #----------------------------- AC_DEFUN(ESO_ENABLE_STRICT, [ AC_REQUIRE([AC_PROG_CC]) AC_ARG_ENABLE(strict, AC_HELP_STRING([--enable-strict], [compiles with strict compiler options (may not work! [[default=$1]]]), eso_enable_strict=$enableval, eso_enable_strict=$1) AC_CACHE_CHECK([whether strict compiler options should be used], eso_cv_enable_strict, eso_cv_enable_strict=$eso_enable_strict) if test x"$eso_cv_enable_strict" = xyes; then ESO_PROG_CC_FLAG([ansi], [CFLAGS="$CFLAGS -ansi"]) ESO_PROG_CC_FLAG([pedantic], [CFLAGS="$CFLAGS -pedantic"]) fi ]) # ESO_CHECK_DOCTOOLS #------------------- AC_DEFUN(ESO_CHECK_DOCTOOLS, [ AC_ARG_VAR([DOXYGEN], [doxygen command]) AC_PATH_PROG([DOXYGEN], [doxygen]) AC_ARG_VAR([LATEX], [latex command]) AC_PATH_PROG([LATEX], [latex]) if test -z "${DOXYGEN}"; then DOXYGEN=":" fi if test -z "${LATEX}"; then LATEX=":" fi ]) # Check for ar #------------- # Checks if ar is in the path AC_DEFUN(ESO_PROG_AR, [ AC_CHECK_PROG(AR, ar, ar, NONE) if test x"$AR" = xNONE; then AC_MSG_ERROR([Cannot find \'ar\']) fi ]) # Check for functions #-------------------- AC_DEFUN(ESO_CHECK_FUNC, [ AC_LANG_PUSH(C) eso_save_CFLAGS="$CFLAGS" if test x"$GCC" = xyes; then CFLAGS="$CFLAGS -pedantic-errors" fi AC_CHECK_DECL($1, [], [], [$2]) AC_CHECK_FUNC($1) CFLAGS="$eso_save_CFLAGS" AC_LANG_POP(C) if test x"$ac_cv_have_decl_$1" = xyes && test x"$ac_cv_func_$1" = xyes; then AC_DEFINE($3) fi ]) # ESO_FUNC_GETOPT #---------------- # Checks for GNU getopt_long declaration and function. AC_DEFUN(ESO_FUNC_GETOPT, [ AH_TEMPLATE([HAVE_GETOPT_LONG], [Define if you have the GNU `getopt_long' function]) ESO_CHECK_FUNC(getopt_long, [#include ], HAVE_GETOPT_LONG) if test $ac_cv_func_getopt_long = no || test $ac_cv_have_decl_getopt_long = no; then if test -n "$LIBTOOL"; then GETOPT="getopt.lo getopt1.lo" else GETOPT="getopt.$ac_objext getopt1.$ac_objext" fi fi AC_SUBST(GETOPT) ]) # ESO_FUNC_STRDUP #---------------- AC_DEFUN(ESO_FUNC_STRDUP, [ AH_TEMPLATE([HAVE_STRDUP], [Define if you have the `strdup' function]) ESO_CHECK_FUNC(strdup, [#include ], HAVE_STRDUP) if test $ac_cv_func_strdup = no || test $ac_cv_have_decl_strdup = no; then if test -n "$LIBTOOL"; then STRDUP=strdup.lo else STRDUP=strdup.$ac_objext fi fi AC_SUBST(STRDUP) ]) # QFITS_CHECK_CHAR_BIT #--------------------- AC_DEFUN(QFITS_CHECK_CHAR_BIT, [ qfits_have_char_bit=no qfits_have_char_8_bits=no AC_MSG_CHECKING([for bits per char]) AC_CACHE_VAL(qfits_cv_have_char_8_bits, [ AC_LANG_PUSH(C) qfits_cppflags_save="$CPPFLAGS" qfits_cflags_save="$CFLAGS" qfits_ld_flags_save="$LDFLAGS" qfits_libs_save="$LIBS" if test "$GCC" = "yes"; then CFLAGS="$CFLAGS -pedantic-errors" CPPFLAGS="$CPPFLAGS $CFLAGS" fi AC_TRY_COMPILE([#include ], [int i = CHAR_BIT;], qfits_have_char_bit=yes, qfits_have_char_bit=no) if test "x$qfits_have_char_bit" = "xyes"; then AC_TRY_RUN( [ #include int main() { if (CHAR_BIT != 8) return 1; return 0; } ], qfits_have_char_8_bits=yes, qfits_have_char_8_bits=no) else AC_TRY_RUN( [ #include int main() { char c = 1; int i = 0; while (c) { c <<= 1; i++; } if (i != 8) return 1; return 0; } ], qfits_have_char_8_bits=yes, qfits_have_char_8_bits=no) fi CPPFLAGS="$qfits_cppflags_save" CFLAGS="$qfits_cflags_save" LDFLAGS="$qfits_ldflags_save" LIBS="$qfits_libs_save" AC_LANG_POP qfits_cv_have_char_8_bits="qfits_have_char_bit=$qfits_have_char_bit \ qfits_have_char_8_bits=$qfits_have_char_8_bits" ]) eval "$qfits_cv_have_char_8_bits" if test "$qfits_have_char_8_bits" = "no"; then AC_MSG_ERROR([C type char is not 8 bits wide!]) else if test "$qfits_have_char_bit" = "no"; then AC_DEFINE(CHAR_BIT, 8, [Width of type 'char']) else AC_DEFINE(HAVE_CHAR_BIT, 1, [Define if CHAR_BIT is defined in limits.h and equals 8]) fi AC_MSG_RESULT([8]) fi ]) # FSMOSAIC_ADD_HEADER_TEMPLATES #---------------------------- # Add templates to config.h.in AC_DEFUN(FSMOSAIC_ADD_HEADER_TEMPLATES, [ # The following macros must start at column 1 to get out a # working config.h.in AH_BOTTOM( [ /* Define strdup prototype if not defined in string.h */ #ifndef HAVE_STRDUP char *strdup(const char *); #endif ]) AH_BOTTOM( [ /* * Define the maximum number of characters a filename including the * path may have, excluding the string terminator. */ #ifndef PATHNAME_MAX #define PATHNAME_MAX 4095 #endif ]) ])