-
-dnl Check if the C compiler accepts a certain C flag, and if so adds it to
-dnl CFLAGS
-AC_DEFUN([GNOME_PKGCONFIG_CHECK_CFLAG], [
- AC_REQUIRE([GNOME_REQUIRE_PKGCONFIG])
-
- AC_MSG_CHECKING(if C compiler accepts $1)
- save_CFLAGS="$CFLAGS"
-
- dnl make sure we add it only once
- dnl this one doesn't seem to work: *[\ \ ]$1[\ \ ]*) ;;
- case " $CFLAGS " in
- *\ $1\ *) echo $ac_n "(already in CFLAGS) ... " ;;
- *\ $1\ *) echo $ac_n "(already in CFLAGS) ... " ;;
- *\ $1\ *) echo $ac_n "(already in CFLAGS) ... " ;;
- *\ $1\ *) echo $ac_n "(already in CFLAGS) ... " ;;
- *) CFLAGS="$CFLAGS $1" ;;
- esac
-
- AC_TRY_COMPILE([#include <stdio.h>], [printf("hello");],
- [ AC_MSG_RESULT(yes)],dnl
- [ CFLAGS="$save_CFLAGS" AC_MSG_RESULT(no) ])
-])
-
-dnl add $ACLOCAL_FLAGS (and optionally more dirs) to the aclocal
-dnl commandline, so make can work even if it needs to rerun aclocal
-AC_DEFUN([GNOME_PKGCONFIG_ACLOCALFLAGS],
-[
- AC_REQUIRE([GNOME_REQUIRE_PKGCONFIG])
-
- test -n "$ACLOCAL_FLAGS" && ACLOCAL="$ACLOCAL $ACLOCAL_FLAGS"
-
- for i in "$1"; do
- ACLOCAL="$ACLOCAL -I $i"
- done
-])
-
-AC_DEFUN([GNOME_PKGCONFIG_CHECK_OPTIONAL_MODULES],
-[
- AC_REQUIRE([GNOME_REQUIRE_PKGCONFIG])
-
- name=$1
- depvar=$3
-
- AC_MSG_CHECKING(for libraries)
- pkg_list=""
- for module in $2 ""; do
- if test -n "$module"; then
- if `echo $module |grep -q ":"`; then
- dnl has version requirement
- pkg_module_name=`echo $module |sed 's/\(.*\):.*/\1/'`
- test_version=`echo $module |sed 's/.*:\(.*\)/\1/'`
-
- msg=`$PKG_CONFIG $pkg_module_name 2>&1`
- if test -z "$msg"; then
- dnl module exists
- pkg_version=`$PKG_CONFIG --modversion $pkg_module_name`
- GNOME_PKGCONFIG_CHECK_VERSION($pkg_version, $test_version,
- dnl has the right version
- echo $ac_n "$pkg_module_name "
- pkg_list="$pkg_list $pkg_module_name"
- ,
- AC_MSG_RESULT([($pkg_module_name)])
- if test x$4 = xfail ; then
- AC_MSG_ERROR([An old version of $pkg_module_name (version $pkg_version) was found. You need at least version $test_version])
- else
- AC_MSG_WARN([An old version of $pkg_module_name (version $pkg_version) was found. You need at least version $test_version])
- fi
- )
- else
- dnl doesn't exist
- AC_MSG_RESULT([($pkg_module_name)])
- if test x$4 = xfail ; then
- AC_MSG_ERROR([$msg])
- else
- AC_MSG_WARN([$msg])
- fi
- fi
- else
- msg=`$PKG_CONFIG $module 2>&1`
- if test -z "$msg"; then
- echo $ac_n "$module "
- pkg_list="$pkg_list $module"
- else
- AC_MSG_RESULT([($module)])
- if test x$4 = xfail ; then
- AC_MSG_ERROR([$msg])
- else
- AC_MSG_WARN([$msg])
- fi
- fi
- fi
- fi
- done
- AC_MSG_RESULT([])
- if test -n "$pkg_list"; then
- eval $name'_CFLAGS'=\"`$PKG_CONFIG --cflags $pkg_list`\"
- eval $name'_LIBS'=\"`$PKG_CONFIG --libs $pkg_list`\"
- if test -n "$depvar"; then
- eval $depvar'_DEPENDS'=\"\$$depname'_DEPENDS' $pkg_list\"
- else
- eval $name'_DEPENDS'=\"$pkg_list\"
- fi
- if test -z "$4" ; then
- eval 'HAVE_'$name=yes
- fi
- eval 'have_'$name=yes
- else
- eval 'have_'$name=no
- fi
-])
-
-AC_DEFUN([GNOME_PKGCONFIG_CHECK_MODULES],
-[
- GNOME_PKGCONFIG_CHECK_OPTIONAL_MODULES($1,$2,$3,fail)
-])