+dnl Use 'pkgconfig' to check for a package
+dnl $1 is the --with component name
+dnl $2 is the pkg-config component name, if provided; otherwise use $1 for this
+dnl on success, resulting INCLUDES, INCLUDEDIR, LA, and LIBDIRPATH variables
+dnl will be set; on failure, will exit with an error.
+AC_DEFUN([GRC_WITH_PKG_CONFIG_CHECK], [
+ if test [x]$2 = x; then
+ pc_comp_name="$1"
+ else
+ pc_comp_name="$2"
+ fi
+ _GRC_WITH_PKG_CONFIG_CHECK($1,${pc_comp_name},m4_bpatsubst($1,-,_))
+])
+dnl $2 is the pkg-config component name
+dnl $3 is the '_'d component name
+AC_DEFUN([_GRC_WITH_PKG_CONFIG_CHECK],[
+ dnl save PKG_CONFIG_PATH, restore at the end
+ s_PKG_CONFIG_PATH=$PKG_CONFIG_PATH
+
+ dnl create the PKG_CONFIG_PATH, via this component arg, if provided;
+ dnl else use the environment PKG_CONFIG_PATH
+ l_PKG_CONFIG_PATH=$[with_]$3[_val]
+ if test "x$l_PKG_CONFIG_PATH" != "x"; then
+ export PKG_CONFIG_PATH=$l_PKG_CONFIG_PATH
+
+ dnl verify that the file exists; if not, no point in continuing
+ if ! test -r ${l_PKG_CONFIG_PATH}/$2[.pc]; then
+ AC_MSG_ERROR([Component $1: PKGCONFIG cannot find info for $2, with provided PKG_CONFIG_PATH = @<:@ $l_PKG_CONFIG_PATH @:>@ .])
+ fi
+ fi
+
+ dnl do the check; error out if not found
+ PKG_CHECK_EXISTS($2, [passed=with; check1=yes], [
+ check1=no
+ dnl pkg-config returned an error; this might be that the .pc
+ dnl file was not valid, or the Requires: were not met.
+ dnl If the arg was provided and the input PKG_CONFIG_PATH , then try
+ dnl again appending the whole PKG_CONFIG_PATH.
+ if test "x$l_PKG_CONFIG_PATH" != "x"; then
+ if test "x$s_PKG_CONFIG_PATH" != "x"; then
+ export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:${s_PKG_CONFIG_PATH}
+ PKG_CHECK_EXISTS($2, passed=with, passed=no)
+ fi
+ fi
+ if test $passed != with; then
+ AC_MSG_ERROR([Component $1: PKGCONFIG cannot find info for $2, with PKG_CONFIG_PATH = @<:@ $PKG_CONFIG_PATH @:>@ .])
+ fi
+ dnl pkg-config Requires are now met; save the new PKG_CONFIG_PATH
+ s_PKG_CONFIG_PATH=$PKG_CONFIG_PATH
+ ])
+
+ dnl if PKG_CHECK_EXISTS returned, then this component's .pc file was
+ dnl found in the provided 'arg' PKG_CONFIG_PATH;
+ dnl retrieve various parameters
+ $3[_INCLUDES]=`$PKG_CONFIG --cflags-only-I $2`
+ $3[_LA]=`$PKG_CONFIG --libs $2`
+ $3[_INCLUDEDIR]=`$PKG_CONFIG --variable=includedir $2`
+
+ if test x$check1 = xyes; then
+ dnl prepend the args PKG_CONFIG_PATH to the saved one, if the
+ dnl saved version was not empty
+ if test "x$s_PKG_CONFIG_PATH" != "x"; then
+ export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:${s_PKG_CONFIG_PATH}
+ fi
+ fi
+])
+
+dnl Check the $prefix versus the --with libdirpath for this component
+dnl $1 is the prefix
+dnl $2 is the --with component name
+dnl $3 is the --with component library path
+AC_DEFUN([GRC_PREFIX_LDFLAGS],[
+ $2[_LIBDIRPATH]=$3
+ dnl create LDFLAGS for this --with, if different from the provided $prefix
+ if test [x]$1[/lib] != [x]$3; then
+ $2[_LDFLAG]=[-L]$3
+ else
+ $2[_LDFLAG]=
+ fi
+])
+
+dnl Check to make sure this dependency is fulfilled for this component
+dnl $1 is the component's name
+dnl $2 is the component dependency name
+dnl On input and exit, $passed will be:
+dnl with : if --with passed muster
+dnl yes : if --enable passed muster
+dnl no : otherwise
+dnl If trying --with, will error-out if any dependency was not --with'd
+AC_DEFUN([GRC_CHECK_DEPENDENCY],[
+dnl f0=[enable_]m4_bpatsubst($1,-,_)
+dnl f1=[$enable_]m4_bpatsubst($1,-,_)
+dnl echo
+dnl echo "$1 : Checking Dependency $2"
+dnl echo "$1 : enable_all_components is '$enable_all_components'"
+dnl echo "$1 : $f0 is '$f1'"
+dnl echo "$1 : passed is '$passed'"
+dnl echo
+ if test $passed != no; then
+ if test $passed = yes; then
+ dnl make sure this dependency was not skipped
+ if test [x$]m4_bpatsubst($2,-,_)[_skipped] = xyes; then
+ AC_MSG_RESULT([Component $1 requires $2, which is not being built or specified via pre-installed files.])
+ passed=no
+ fi
+ else
+ dnl make sure this dependency was --with'd only; not --enable'd
+ if test [x$]m4_bpatsubst($2,-,_)[_with] = xno; then
+ AC_MSG_ERROR([Component $1 requires $2 to be included as --with-$1@<:@=arg@:>@])
+ fi
+ fi
+ fi
+])
+
+dnl Check to make sure GUILE is available
+dnl $1 is the component name
+AC_DEFUN([GRC_CHECK_GUILE],[
+ if test x"$GUILE" = x; then
+ AC_MSG_RESULT([Component $1 requires guile, which was not found.])
+ passed=no
+ fi
+])
+
+dnl Add the specified "with" list; clear the provided variable
+dnl $1 is the component name
+dnl $2 is the path list name suffix
+dnl $3 is the separator (for paths, ":"; for includes " ")