dnl # dnl # /usr/share/aclocal/libmpuio.m4 dnl # dnl # Configure paths for libmpuio dnl # Andrey V.Kosteltsev dnl ============================================================ dnl dnl Synopsis: dnl AC_CHECK_LIBMPUIO([MIN-VERSION [, # minimum libmpuio version, e.g. 1.0.3 dnl DEFAULT-WITH-LIBMPU [, # default value for --with-libmpuop option dnl ACTION-IF-FOUND [, # action to perform if libmpuio was found dnl ACTION-IF-NOT-FOUND # action to perform if libmpuio was not found dnl ]]]]) dnl Examples: dnl AC_CHECK_LIBMPUIO(1.0.3) dnl AC_CHECK_LIBMPUIO(1.0.3,,,CFLAGS="$CFLAGS -DHAVE_LIBMPUIO $LIBMPUIO_CFLAGS") dnl AC_CHECK_LIBMPUIO(1.0.3,yes,CFLAGS="$CFLAGS -DHAVE_LIBMPUIO") dnl dnl dnl If you have to change prefix returned by mpuio-config script or change dnl location of mpuio-config, you may set environment variable LIBMPUIO_CONFIG, dnl for example: dnl dnl # export LIBMPUIO_CONFIG="/usr/bin/mpuio-config" dnl dnl ============================================================ dnl dnl ============================================================ dnl auxilliary macros dnl ============================================================ AC_DEFUN([_AC_LIBMPUIO_ERROR], [dnl AC_MSG_RESULT([*FAILED*]) cat <>/ /' 1>&2 $1 EOT exit 1 ]) AC_DEFUN([_AC_LIBMPUIO_VERBOSE], [dnl if test "x$verbose" = "xyes"; then AC_MSG_RESULT([ $1]) fi ]) dnl ============================================================ dnl the user macro dnl ============================================================ AC_DEFUN([AC_CHECK_LIBMPUIO], [dnl dnl dnl ============================================================ dnl prerequisites dnl ============================================================ AC_REQUIRE([AC_PROG_CC])dnl AC_REQUIRE([AC_PROG_CPP])dnl dnl dnl ============================================================ dnl set LIBMPU_CONFIG variable dnl ============================================================ if test -z "$LIBMPUIO_CONFIG"; then LIBMPUIO_CONFIG='mpuio-config' fi dnl LIBMPUIO_CPPFLAGS='' LIBMPUIO_CFLAGS='' LIBMPUIO_LDFLAGS='' LIBMPUIO_LIBS='' AC_SUBST(LIBMPUIO_CPPFLAGS) AC_SUBST(LIBMPUIO_CFLAGS) AC_SUBST(LIBMPUIO_LDFLAGS) AC_SUBST(LIBMPUIO_LIBS) dnl dnl ============================================================ dnl command line options dnl ============================================================ AC_MSG_CHECKING(for libmpuio) _AC_LIBMPUIO_VERBOSE([]) AC_ARG_WITH(libmpuio,dnl [ --with-libmpuio[=ARG] Build with libmpuio Library (default=]ifelse([$2],,yes,$2)[)],dnl ,dnl with_libmpuio="ifelse([$2],,yes,$2)" )dnl _AC_LIBMPUIO_VERBOSE([+ Command Line Options:]) _AC_LIBMPUIO_VERBOSE([ o --with-libmpuio=$with_libmpu]) dnl dnl ============================================================ dnl configuration dnl ============================================================ if test "x$with_libmpuio" != "xno"; then libmpuio_version="" libmpuio_location="" libmpuio_type="" libmpuio_cppflags="" libmpuio_cflags="" libmpuio_ldflags="" libmpuio_libs="" if test "x$with_libmpuio" = "xyes"; then # via config script in $PATH changequote(, )dnl libmpuio_version=`($LIBMPUIO_CONFIG --version) 2>/dev/null |\ sed -e 's/^.*\([0-9]\.[0-9]*[ab.][0-9]*\).*$/\1/'` changequote([, ])dnl if test "x$libmpuio_version" != "x"; then libmpuio_location=`$LIBMPUIO_CONFIG --prefix` libmpuio_type='installed' libmpuio_cppflags=`$LIBMPUIO_CONFIG --cppflags` libmpuio_cflags=`$LIBMPUIO_CONFIG --cflags` libmpuio_ldflags=`$LIBMPUIO_CONFIG --ldflags` libmpuio_libs=`$LIBMPUIO_CONFIG --libs` fi fi dnl ======================================================== dnl Check whether the found version is sufficiently new dnl ======================================================== _req_version="ifelse([$1],,1.0.0,$1)" for _var in libmpuio_version _req_version; do eval "_val=\"\$${_var}\"" _major=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\1/'` _minor=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\2/'` _rtype=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\3/'` _micro=`echo $_val | sed 's/\([[0-9]]*\)\.\([[0-9]]*\)\([[ab.]]\)\([[0-9]]*\)/\4/'` case $_rtype in "a" ) _rtype=0 ;; "b" ) _rtype=1 ;; "." ) _rtype=2 ;; esac _hex=`echo dummy | awk '{ printf("%d%02d%1d%02d", major, minor, rtype, micro); }' \ "major=$_major" "minor=$_minor" "rtype=$_rtype" "micro=$_micro"` eval "${_var}_hex=\"\$_hex\"" done _AC_LIBMPUIO_VERBOSE([+ Determined Versions:]) _AC_LIBMPUIO_VERBOSE([ o existing: $libmpu_version -> 0x$libmpu_version_hex]) _AC_LIBMPUIO_VERBOSE([ o required: $_req_version -> 0x$_req_version_hex]) _ok=0 if test "x$libmpuio_version_hex" != "x"; then if test "x$_req_version_hex" != "x"; then if test $libmpuio_version_hex -ge $_req_version_hex; then _ok=1 fi fi fi if test "x$_ok" = "x0"; then _AC_LIBMPUIO_ERROR([dnl Found libmpuio version $libmpuio_version, but required at least version $_req_version. Upgrade libmpuio under $libmpuio_location to $_req_version or higher first, please.]) fi dnl ======================================================== dnl Perform libmpuio Sanity Compile Check dnl ======================================================== _ac_save_CPPFLAGS="$CPPFLAGS" _ac_save_CFLAGS="$CFLAGS" _ac_save_LDFLAGS="$LDFLAGS" _ac_save_LIBS="$LIBS" CPPFLAGS="$CPPFLAGS $libmpuio_cppflags" CFLAGS="$CFLAGS $libmpuio_cflags" LDFLAGS="$LDFLAGS $libmpuio_ldflags" LIBS="$LIBS $libmpu_libs" _AC_LIBMPUIO_VERBOSE([+ Test Build Environment:]) _AC_LIBMPUIO_VERBOSE([ o CPPFLAGS="$CPPFLAGS"]) _AC_LIBMPUIO_VERBOSE([ o CFLAGS="$CFLAGS"]) _AC_LIBMPUIO_VERBOSE([ o LDFLAGS="$LDFLAGS"]) _AC_LIBMPUIO_VERBOSE([ o LIBS="$LIBS"]) cross_compile=no _AC_LIBMPUIO_VERBOSE([+ Performing Sanity Checks:]) _AC_LIBMPUIO_VERBOSE([ o pre-processor test]) AC_PREPROC_IFELSE([AC_LANG_SOURCE([[ #include ]])], _ok=yes, _ok=no) if test "x$_ok" != "xyes"; then _AC_LIBMPUIO_ERROR([dnl Found libmpuio $libmpuio_version under $libmpuio_location, but was unable to perform a sanity pre-processor check. This means the libmpuio header libmpuio.h was not found. We used the following build environment: >> CPP="$CPP" >> CPPFLAGS="$CPPFLAGS" See config.log for possibly more details.]) fi _AC_LIBMPUIO_VERBOSE([ o link check]) AC_LINK_IFELSE([AC_LANG_SOURCE([[ #include int main() { __mpu_init(); __mpu_free_context(); return( 0 ); } ]])], _ok=yes, _ok=no) if test "x$_ok" != "xyes"; then _AC_LIBMPUIO_ERROR([dnl Found libmpuio $libmpuio_version under $libmpuio_location, but was unable to perform a sanity linker check. This means the libmpuio library libmpuio.a was not found. We used the following build environment: >> CC="$CC" >> CFLAGS="$CFLAGS" >> LDFLAGS="$LDFLAGS" >> LIBS="$LIBS" See config.log for possibly more details.]) fi CPPFLAGS="$_ac_save_CPPFLAGS" CFLAGS="$_ac_save_CFLAGS" LDFLAGS="$_ac_save_LDFLAGS" LIBS="$_ac_save_LIBS" LIBMPUIO_CPPFLAGS="$libmpuio_cppflags" LIBMPUIO_CFLAGS="$libmpuio_cflags" LIBMPUIO_LDFLAGS="$libmpuio_ldflags" LIBMPUIO_LIBS="$libmpuio_libs" AC_SUBST(LIBMPUIO_CPPFLAGS) AC_SUBST(LIBMPUIO_CFLAGS) AC_SUBST(LIBMPUIO_LDFLAGS) AC_SUBST(LIBMPUIO_LIBS) _AC_LIBMPUIO_VERBOSE([+ Final Results:]) _AC_LIBMPUIO_VERBOSE([ o LIBMPUIO_CPPFLAGS="$LIBMPUIO_CPPFLAGS"]) _AC_LIBMPUIO_VERBOSE([ o LIBMPUIO_CFLAGS="$LIBMPUIO_CFLAGS"]) _AC_LIBMPUIO_VERBOSE([ o LIBMPUIO_LDFLAGS="$LIBMPUIO_LDFLAGS"]) _AC_LIBMPUIO_VERBOSE([ o LIBMPUIO_LIBS="$LIBMPUIO_LIBS"]) fi if test "x$with_libmpuio" != "xno"; then AC_MSG_RESULT([version $libmpuio_version, $libmpuio_type under $libmpuio_location]) ifelse([$3], , :, [$3]) else AC_MSG_RESULT([no]) ifelse([$4], , :, [$4]) fi ])