| 1 |
dnl this macro has been copied from /usr/share/aclocal/pkg.m4 |
| 2 |
dnl modified to check only for zziplib. You are advised to use |
| 3 |
dnl pgkconfig macro directly instead. It is only installed to |
| 4 |
dnl the convenience of software makers who do not want to have |
| 5 |
dnl yet another package dependency when building zziplib-based |
| 6 |
dnl projects. In general, you can include in your configure.ac |
| 7 |
dnl some line like |
| 8 |
dnl PKG_CHECK_ZZIPLIB([ZZIP],[0.10.75]) |
| 9 |
dnl in order to get the two autoconf/automake subst variables |
| 10 |
dnl named ZZIP_CFLAGS and ZZIP_LIBS respectively. |
| 11 |
|
| 12 |
dnl PKG_CHECK_ZZIPLIB(ZZIP, minversion, action-if, action-not) |
| 13 |
dnl defines ZZIP_LIBS, ZZIP_CFLAGS, see pkg-config man page |
| 14 |
dnl also defines ZZIP_PKG_ERRORS on error |
| 15 |
AC_DEFUN([PKG_CHECK_ZZIPLIB], [# checking for zziplib cflags/libs $2 |
| 16 |
succeeded=no |
| 17 |
|
| 18 |
if test -z "$PKG_CONFIG"; then |
| 19 |
AC_PATH_PROG([PKG_CONFIG],[pkg-config],[no]) |
| 20 |
fi |
| 21 |
|
| 22 |
if test "$PKG_CONFIG" = "no" ; then |
| 23 |
dnl we stick in an extra section that takes advantage of `zzip-config` |
| 24 |
dnl script that might be there and carry cflags/libs info as well. |
| 25 |
AC_PATH_PROG([ZZIP_CONFIG], [zzip-config], [no]) |
| 26 |
if test "$ZZIP_CONFIG" = "no" ; then |
| 27 |
echo "*** Neither config spec could be found - there was no archaic" |
| 28 |
echo "*** zzip-config script around and no pkg-config script in the" |
| 29 |
echo "*** PATH. Make sure that either one is in your path, or set" |
| 30 |
echo "*** set the PKG_CONFIG environment variable to the full" |
| 31 |
echo "*** path to pkg-config. See http://zziplib.sf.net - or see" |
| 32 |
echo "*** http://www.freedesktop.org/software/pkgconfig for more." |
| 33 |
else |
| 34 |
AC_MSG_CHECKING($1_LIBS) |
| 35 |
$1_LIBS=`$ZZIP_CONFIG --libs 2>/dev/null` |
| 36 |
AC_MSG_RESULT($[]$1_LIBS) |
| 37 |
|
| 38 |
if test ".$[]$1_LIBS" != "." ; then |
| 39 |
AC_MSG_CHECKING($1_CFLAGS) |
| 40 |
$1_CFLAGS=`$ZZIP_CONFIG --cflags 2>/dev/null` |
| 41 |
AC_MSG_RESULT($[]$1_CFLAGS) |
| 42 |
succeeded="yes" |
| 43 |
else |
| 44 |
AC_MSG_CHECKING($1_CFLAGS) |
| 45 |
$1_CFLAGS=`$ZZIP_CONFIG --cflags 2>&1` |
| 46 |
AC_MSG_RESULT([(detecting errors...)]) |
| 47 |
AC_MSG_WARN([... there is a problem with zzip-config]) |
| 48 |
AC_MSG_WARN([... $[]$1_CFLAGS]) |
| 49 |
AC_MSG_WARN([... inference of library requirements from prefix]) |
| 50 |
succeeded=`echo $ZZIP_CONFIG | sed -e 's,/[^/]*,,'` # dirname |
| 51 |
$1_CFLAGS="" |
| 52 |
$1_LIBS="" |
| 53 |
if test "/$succeeded" != "//usr" ; then |
| 54 |
test -d "$succeeded/include" && $1_CFLAGS="-I$succeeded/include " |
| 55 |
test -d "$succeeded/lib" && $1_LIBS="-L$succeeded/lib " |
| 56 |
fi |
| 57 |
$1_LIBS="$[]$1_LIBS -lzzip -lz" |
| 58 |
succeeded="yes" |
| 59 |
AC_MSG_CHECKING($1_CFLAGS... guessed) |
| 60 |
AC_MSG_RESULT($[]$1_CFLAGS) |
| 61 |
AC_MSG_CHECKING($1_LIBS... guessed) |
| 62 |
AC_MSG_RESULT($[]$1_LIBS) |
| 63 |
fi |
| 64 |
fi |
| 65 |
else |
| 66 |
PKG_CONFIG_MIN_VERSION=0.9.0 |
| 67 |
if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then |
| 68 |
AC_MSG_CHECKING(for zziplib[]ifelse([$2],,,[ >= $2])) |
| 69 |
|
| 70 |
if $PKG_CONFIG --exists "zziplib[]ifelse([$2],,,[ >= $2])" ; then |
| 71 |
AC_MSG_RESULT(yes) |
| 72 |
succeeded=yes |
| 73 |
|
| 74 |
AC_MSG_CHECKING($1_CFLAGS) |
| 75 |
$1_CFLAGS=`$PKG_CONFIG --cflags "zziplib[]ifelse([$2],,,[ >= $2])"` |
| 76 |
AC_MSG_RESULT($$1_CFLAGS) |
| 77 |
|
| 78 |
AC_MSG_CHECKING($1_LIBS) |
| 79 |
$1_LIBS=`$PKG_CONFIG --libs "zziplib[]ifelse([$2],,,[ >= $2])"` |
| 80 |
AC_MSG_RESULT($$1_LIBS) |
| 81 |
else |
| 82 |
$1_CFLAGS="" |
| 83 |
$1_LIBS="" |
| 84 |
## If we have a custom action on failure, don't print errors, but |
| 85 |
## do set a variable so people can do so. |
| 86 |
$1_PKG_ERRORS=`$PKG_CONFIG dnl |
| 87 |
--errors-to-stdout --print-errors "zziplib[]ifelse([$2],,,[ >= $2])"` |
| 88 |
ifelse([$4], ,echo $$1_PKG_ERRORS,) |
| 89 |
fi |
| 90 |
|
| 91 |
AC_SUBST($1_CFLAGS) |
| 92 |
AC_SUBST($1_LIBS) |
| 93 |
else |
| 94 |
echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer." |
| 95 |
echo "*** See http://www.freedesktop.org/software/pkgconfig" |
| 96 |
fi |
| 97 |
fi |
| 98 |
|
| 99 |
if test $succeeded = yes; then |
| 100 |
ifelse([$3], , :, [$3]) |
| 101 |
else |
| 102 |
succeeded="zziplib[]ifelse([$2],,,[ >= $2])" |
| 103 |
ifelse([$4], ,[AC_MSG_ERROR([Library requirements ($succeeded) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.])], [$4]) |
| 104 |
fi |
| 105 |
]) |