1 dnl ---------------------------------------------------------------------------
2 dnl AM_OPTIONS_GDLIBCONFIG
4 dnl adds support for --gdlib-prefix and --gdlib-config
5 dnl command line options
6 dnl ---------------------------------------------------------------------------
8 AC_DEFUN([AM_OPTIONS_GDLIBCONFIG],
13 [--with-gdlib-prefix=PREFIX],
14 [prefix where gdlib is installed (optional)])],
15 [gdlib_config_prefix="$withval"],
16 [gdlib_config_prefix=""])
20 [--with-gdlib-config=CONFIG],
21 [gdlib-config script to use (optional)])],
22 [gdlib_config_name="$withval"],
23 [gdlib_config_name=""])
26 dnl ---------------------------------------------------------------------------
27 dnl AM_PATH_GDLIBCONFIG([VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
29 dnl Test for gdlib, and define GDLIB*FLAGS, GDLIB_LIBS and GDLIB_CONFIG_NAME
30 dnl environment variable to override the default name of the gdlib-config script
31 dnl to use. Set GDLIB_CONFIG_PATH to specify the full path to gdlib-config -
32 dnl in this case the macro won't even waste time on tests for its existence.
33 dnl ---------------------------------------------------------------------------
34 AC_DEFUN([AM_PATH_GDLIBCONFIG],
35 [AC_REQUIRE([AM_OPTIONS_GDLIBCONFIG])dnl
36 m4_define([REQUIRED_VERSION], [ifelse([$1],, [2.0.0], [$1])])dnl
37 m4_define([REQUIRED_VERSION_MAJOR], [m4_bregexp(REQUIRED_VERSION, [\([0-9]+\)\.\([0-9]+\)\.\([0-9]+\)], [\1])])dnl
38 m4_define([REQUIRED_VERSION_MINOR], [m4_bregexp(REQUIRED_VERSION, [\([0-9]+\)\.\([0-9]+\)\.\([0-9]+\)], [\2])])dnl
39 m4_define([REQUIRED_VERSION_MICRO], [m4_bregexp(REQUIRED_VERSION, [\([0-9]+\)\.\([0-9]+\)\.\([0-9]+\)], [\3])])dnl
41 dnl do we have gdlib-config name: it can be gdlib-config or gd-config or ...
42 if test x${GDLIB_CONFIG_NAME+set} != xset ; then
43 GDLIB_CONFIG_NAME=gdlib-config
45 if test "x$gdlib_config_name" != x ; then
46 GDLIB_CONFIG_NAME="$gdlib_config_name"
49 dnl deal with optional prefix
50 if test x$gdlib_config_prefix != x ; then
51 GDLIB_LOOKUP_PATH="$gdlib_config_prefix/bin"
54 dnl don't search the PATH if GDLIB_CONFIG_NAME is absolute filename
55 if test -x "$GDLIB_CONFIG_NAME" ; then
56 AC_MSG_CHECKING(for gdlib-config)
57 GDLIB_CONFIG_PATH="$GDLIB_CONFIG_NAME"
58 AC_MSG_RESULT($GDLIB_CONFIG_PATH)
60 AC_PATH_PROG(GDLIB_CONFIG_PATH, $GDLIB_CONFIG_NAME, no, "$GDLIB_LOOKUP_PATH:$PATH")
63 if test "$GDLIB_CONFIG_PATH" != "no" ; then
66 AC_MSG_CHECKING([for gdlib version >= REQUIRED_VERSION])
68 GDLIB_CONFIG_WITH_ARGS="$GDLIB_CONFIG_PATH $gdlib_config_args"
70 GDLIB_VERSION=`$GDLIB_CONFIG_WITH_ARGS --version`
71 gdlib_config_major_version=`echo $GDLIB_VERSION | sed ['s/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\1/']`
72 gdlib_config_minor_version=`echo $GDLIB_VERSION | sed ['s/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\2/']`
73 gdlib_config_micro_version=`echo $GDLIB_VERSION | sed ['s/\([0-9]*\)\.\([0-9]*\)\.\([0-9]*\).*/\3/']`
76 if test $gdlib_config_major_version -gt REQUIRED_VERSION_MAJOR; then
79 if test $gdlib_config_major_version -eq REQUIRED_VERSION_MAJOR; then
80 if test $gdlib_config_minor_version -gt REQUIRED_VERSION_MINOR; then
83 if test $gdlib_config_minor_version -eq REQUIRED_VERSION_MINOR; then
84 if test $gdlib_config_micro_version -ge REQUIRED_VERSION_MICRO; then
92 if test x$gdlib_ver_ok = x ; then
93 if test x$GDLIB_VERSION = x; then
94 dnl no gdlib-config at all
97 AC_MSG_RESULT([no (version $GDLIB_VERSION is not new enough)])
102 AC_MSG_RESULT([yes (version $GDLIB_VERSION)])
103 AC_CHECK_HEADER([gd.h])
104 if test $ac_cv_header_gd_h = yes; then
105 GDLIB_CFLAGS="`$GDLIB_CONFIG_WITH_ARGS --cflags`"
106 GDLIB_LDFLAGS="`$GDLIB_CONFIG_WITH_ARGS --ldflags`"
107 GDLIB_LIBS="`$GDLIB_CONFIG_WITH_ARGS --libs`"
115 ifelse([$3],, :, [$3])
118 AC_SUBST(GDLIB_CFLAGS)dnl
119 AC_SUBST(GDLIB_LDFLAGS)dnl
120 AC_SUBST(GDLIB_LIBS)dnl
122 m4_undefine([REQUIRED_VERSION])dnl
123 m4_undefine([REQUIRED_VERSION_MAJOR])dnl
124 m4_undefine([REQUIRED_VERSION_MINOR])dnl
125 m4_undefine([REQUIRED_VERSION_MICRO])dnl