Blame confdb/aclocal_util.m4

Packit 0848f5
dnl Nesting safe macros for saving variables
Packit 0848f5
dnl Usage: PAC_PUSH_FLAG(CFLAGS)
Packit 0848f5
AC_DEFUN([PAC_PUSH_FLAG],[
Packit 0848f5
	if test -z "${pac_save_$1_nesting}" ; then
Packit 0848f5
	   pac_save_$1_nesting=0
Packit 0848f5
	fi
Packit 0848f5
	eval pac_save_$1_${pac_save_$1_nesting}='"$$1"'
Packit 0848f5
	pac_save_$1_nesting=`expr ${pac_save_$1_nesting} + 1`
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl Usage: PAC_POP_FLAG(CFLAGS)
Packit 0848f5
AC_DEFUN([PAC_POP_FLAG],[
Packit 0848f5
	pac_save_$1_nesting=`expr ${pac_save_$1_nesting} - 1`
Packit 0848f5
	eval $1="\$pac_save_$1_${pac_save_$1_nesting}"
Packit 0848f5
	eval pac_save_$1_${pac_save_$1_nesting}=""
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl Usage: PAC_PUSH_ALL_FLAGS
Packit 0848f5
AC_DEFUN([PAC_PUSH_ALL_FLAGS],[
Packit 0848f5
	PAC_PUSH_FLAG(CFLAGS)
Packit 0848f5
	PAC_PUSH_FLAG(CPPFLAGS)
Packit 0848f5
	PAC_PUSH_FLAG(CXXFLAGS)
Packit 0848f5
	PAC_PUSH_FLAG(FFLAGS)
Packit 0848f5
	PAC_PUSH_FLAG(FCFLAGS)
Packit 0848f5
	PAC_PUSH_FLAG(LDFLAGS)
Packit 0848f5
	PAC_PUSH_FLAG(LIBS)
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl Usage: PAC_POP_ALL_FLAGS
Packit 0848f5
AC_DEFUN([PAC_POP_ALL_FLAGS],[
Packit 0848f5
	PAC_POP_FLAG(CFLAGS)
Packit 0848f5
	PAC_POP_FLAG(CPPFLAGS)
Packit 0848f5
	PAC_POP_FLAG(CXXFLAGS)
Packit 0848f5
	PAC_POP_FLAG(FFLAGS)
Packit 0848f5
	PAC_POP_FLAG(FCFLAGS)
Packit 0848f5
	PAC_POP_FLAG(LDFLAGS)
Packit 0848f5
	PAC_POP_FLAG(LIBS)
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl PAC_PREFIX_FLAG - Save flag with a prefix
Packit 0848f5
dnl Usage: PAC_PREFIX_FLAG(PREFIX, FLAG)
Packit 0848f5
AC_DEFUN([PAC_PREFIX_FLAG],[
Packit 0848f5
	$1_$2=$$2
Packit 0848f5
	export $1_$2
Packit 0848f5
	AC_SUBST($1_$2)
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl PAC_PREFIX_ALL_FLAGS - Save flags with a prefix
Packit 0848f5
dnl Usage: PAC_PREFIX_ALL_FLAGS(PREFIX)
Packit 0848f5
AC_DEFUN([PAC_PREFIX_ALL_FLAGS],[
Packit 0848f5
	PAC_PREFIX_FLAG($1, CFLAGS)
Packit 0848f5
	PAC_PREFIX_FLAG($1, CPPFLAGS)
Packit 0848f5
	PAC_PREFIX_FLAG($1, CXXFLAGS)
Packit 0848f5
	PAC_PREFIX_FLAG($1, FFLAGS)
Packit 0848f5
	PAC_PREFIX_FLAG($1, FCFLAGS)
Packit 0848f5
	PAC_PREFIX_FLAG($1, LDFLAGS)
Packit 0848f5
	PAC_PREFIX_FLAG($1, LIBS)
Packit 0848f5
	PAC_PREFIX_FLAG($1, EXTRA_LIBS)
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl Usage: PAC_APPEND_FLAG([-02], [CFLAGS])
Packit 0848f5
dnl appends the given argument to the specified shell variable unless the
Packit 0848f5
dnl argument is already present in the variable
Packit 0848f5
AC_DEFUN([PAC_APPEND_FLAG],[
Packit 0848f5
	AC_REQUIRE([AC_PROG_FGREP])
Packit 0848f5
	AS_IF(
Packit 0848f5
		[echo "$$2" | $FGREP -e "\<$1\>" >/dev/null 2>&1],
Packit 0848f5
		[echo "$2(='$$2') contains '$1', not appending" >&AS_MESSAGE_LOG_FD],
Packit 0848f5
		[echo "$2(='$$2') does not contain '$1', appending" >&AS_MESSAGE_LOG_FD
Packit 0848f5
		$2="$$2 $1"]
Packit 0848f5
	)
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl Usage: PAC_PREPEND_FLAG([-lpthread], [LIBS])
Packit 0848f5
dnl Prepends the given argument to the specified shell variable unless the
Packit 0848f5
dnl argument is already present in the variable.
Packit 0848f5
dnl
Packit 0848f5
dnl This is typically used for LIBS and similar variables because libraries
Packit 0848f5
dnl should be added in reverse order.
Packit 0848f5
AC_DEFUN([PAC_PREPEND_FLAG],[
Packit 0848f5
        AC_REQUIRE([AC_PROG_FGREP])
Packit 0848f5
        AS_IF(
Packit 0848f5
                [echo "$$2" | $FGREP -e "\<$1\>" >/dev/null 2>&1],
Packit 0848f5
                [echo "$2(='$$2') contains '$1', not prepending" >&AS_MESSAGE_LOG_FD],
Packit 0848f5
                [echo "$2(='$$2') does not contain '$1', prepending" >&AS_MESSAGE_LOG_FD
Packit 0848f5
                $2="$1 $$2"]
Packit 0848f5
        )
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
Packit 0848f5
dnl PAC_MKDIRS(path)
Packit 0848f5
dnl Create any missing directories in the path
Packit 0848f5
AC_DEFUN([PAC_MKDIRS],[
Packit 0848f5
# Build any intermediate directories
Packit 0848f5
for dir in $1 ; do
Packit 0848f5
    PAC_PUSH_FLAG([IFS])
Packit 0848f5
    IFS="/"
Packit 0848f5
    tmp_curdir=""
Packit 0848f5
    for tmp_subdir in $dir ; do
Packit 0848f5
	tmp_curdir="${tmp_curdir}$tmp_subdir"
Packit 0848f5
	if test ! -d "$tmp_curdir" ; then mkdir "$tmp_curdir" ; fi
Packit 0848f5
        tmp_curdir="${tmp_curdir}/"
Packit 0848f5
    done
Packit 0848f5
    PAC_POP_FLAG([IFS])
Packit 0848f5
done
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
# Find something to use for mkdir -p.  Eventually, this will have a
Packit 0848f5
# script for backup. As of autoconf-2.63, AC_PROG_MKDIR_P was broken;
Packit 0848f5
# it was checking to see if it recognized the "version" of mkdir and
Packit 0848f5
# was deciding based on that. This should always be a feature test.
Packit 0848f5
AC_DEFUN([PAC_PROG_MKDIR_P],[
Packit 0848f5
AC_CACHE_CHECK([whether mkdir -p works],
Packit 0848f5
pac_cv_mkdir_p,[
Packit 0848f5
pac_cv_mkdir_p=no
Packit 0848f5
rm -rf .tmp
Packit 0848f5
if mkdir -p .tmp/.foo 1>/dev/null 2>&1 ; then
Packit 0848f5
    if test -d .tmp/.foo ; then
Packit 0848f5
        pac_cv_mkdir_p=yes
Packit 0848f5
    fi
Packit 0848f5
fi
Packit 0848f5
rm -rf .tmp
Packit 0848f5
])
Packit 0848f5
if test "$pac_cv_mkdir_p" = "yes" ; then
Packit 0848f5
   MKDIR_P="mkdir -p"
Packit 0848f5
   export MKDIR_P
Packit 0848f5
else
Packit 0848f5
   AC_MSG_WARN([mkdir -p does not work; the install step may fail])
Packit 0848f5
fi
Packit 0848f5
AC_SUBST(MKDIR_P)
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl Test for a clean VPATH directory.  Provide this command with the names
Packit 0848f5
dnl of all of the generated files that might cause problems 
Packit 0848f5
dnl (Makefiles won't cause problems because there's no VPATH usage for them)
Packit 0848f5
dnl
Packit 0848f5
dnl Synopsis
Packit 0848f5
dnl PAC_VPATH_CHECK([file-names],[directory-names])
Packit 0848f5
dnl  file-names should be files other than config.status and any header (e.g.,
Packit 0848f5
dnl fooconf.h) file that should be removed.  It is optional
Packit 0848f5
AC_DEFUN([PAC_VPATH_CHECK],[
Packit 0848f5
# This is needed for Mac OSX 10.5
Packit 0848f5
rm -rf conftest.dSYM
Packit 0848f5
rm -f conftest*
Packit 0848f5
date >conftest$$
Packit 0848f5
# If creating a file in the current directory does not show up in the srcdir
Packit 0848f5
# then we're doing a VPATH build (or something is very wrong)
Packit 0848f5
if test ! -s $srcdir/conftest$$ ; then
Packit 0848f5
    pac_dirtyfiles=""
Packit 0848f5
    pac_dirtydirs=""
Packit 0848f5
    pac_header=""
Packit 0848f5
    ifdef([AC_LIST_HEADER],[pac_header=AC_LIST_HEADER])
Packit 0848f5
    for file in config.status $pac_header $1 ; do
Packit 0848f5
        if test -f $srcdir/$file ; then 
Packit 0848f5
	    pac_dirtyfiles="$pac_dirtyfiles $file"
Packit 0848f5
	fi
Packit 0848f5
    done
Packit 0848f5
    ifelse($2,,,[
Packit 0848f5
 	for dir in $2 ; do 
Packit 0848f5
            if test -d $srcdir/$dir ; then
Packit 0848f5
                pac_dirtydirs="$pac_dirtydirs $dir"
Packit 0848f5
	    fi
Packit 0848f5
	done
Packit 0848f5
    ])
Packit 0848f5
Packit 0848f5
    if test -n "$pac_dirtyfiles" -o -n "$pac_dirtydirs" ; then
Packit 0848f5
	# Create a nice message about what to remove
Packit 0848f5
	rmmsg=""
Packit 0848f5
	if test -n "$pac_dirtyfiles" ; then
Packit 0848f5
	    rmmsg="files $pac_dirtyfiles"
Packit 0848f5
        fi
Packit 0848f5
 	if test -n "$pac_dirtydirs" ; then
Packit 0848f5
	    if test -n "$rmmsg" ; then
Packit 0848f5
	        rmmsg="$rmmsg and directories $pac_dirtydirs"
Packit 0848f5
            else
Packit 0848f5
                rmmsg="directories $pac_dirtydirs"
Packit 0848f5
            fi
Packit 0848f5
        fi
Packit 0848f5
        if test -f $srcdir/Makefile ; then
Packit 0848f5
            AC_MSG_ERROR([You cannot do a VPATH build if the source directory has been
Packit 0848f5
    configured.  Run "make distclean" in $srcdir first and make sure that the
Packit 0848f5
    $rmmsg have been removed.])
Packit 0848f5
        else
Packit 0848f5
            AC_MSG_ERROR([You cannot do a VPATH build if the source directory has been
Packit 0848f5
    configured.  Remove the $rmmsg in $srcdir.])
Packit 0848f5
        fi
Packit 0848f5
    fi
Packit 0848f5
fi
Packit 0848f5
# This is needed for Mac OSX 10.5
Packit 0848f5
rm -rf conftest.dSYM
Packit 0848f5
rm -f conftest*
Packit 0848f5
])
Packit 0848f5
Packit 0848f5
dnl PAC_CONF_HEX_TO_DEC(value,out_var)
Packit 0848f5
dnl
Packit 0848f5
dnl Converts the given hexadecimal integer constant to an integer constant and
Packit 0848f5
dnl stores the result in the shell variable given by 'out_var'.
Packit 0848f5
dnl
Packit 0848f5
dnl I think that printf like this will be sufficiently portable, but I don't
Packit 0848f5
dnl have any guarantee of it.  If not, we can fall back to AS_VAR_ARITH
Packit 0848f5
dnl and/or AC_COMPUTE_INT (the latter will probably be slow)
Packit 0848f5
AC_DEFUN([PAC_CONV_HEX_TO_DEC],[AS_VAR_SET([$2],[`printf "%d" $1`])])
Packit 0848f5
Packit 0848f5
dnl PAC_GET_EXENAME(exe_name, out_exe_name)
Packit 0848f5
dnl
Packit 0848f5
dnl Prepends and appends program prefix and suffix as supplied by --program_prefix
Packit 0848f5
dnl and --program-sufix
Packit 0848f5
AC_DEFUN([PAC_GET_EXENAME],[
Packit 0848f5
$2=$1
Packit 0848f5
if test "$program_prefix" != "NONE" ; then
Packit 0848f5
    $2="${program_prefix}$$2"
Packit 0848f5
fi
Packit 0848f5
if test "$program_suffix" != "NONE" ; then
Packit 0848f5
    $2="$$2$program_suffix"
Packit 0848f5
fi
Packit 0848f5
])