1
# ===========================================================================
2
# http://www.gnu.org/software/autoconf-archive/ax_path_generic.html
3
# ===========================================================================
7
# AX_PATH_GENERIC(LIBRARY,[MINIMUM-VERSION,[SED-EXPR-EXTRACTOR]],[ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],[CONFIG-SCRIPTS],[CFLAGS-ARG],[LIBS-ARG])
11
# Runs the LIBRARY-config script and defines LIBRARY_CFLAGS and
12
# LIBRARY_LIBS unless the user had predefined them in the environment.
14
# The script must support `--cflags' and `--libs' args. If MINIMUM-VERSION
15
# is specified, the script must also support the `--version' arg. If the
16
# `--with-library-[exec-]prefix' arguments to ./configure are given, it
17
# must also support `--prefix' and `--exec-prefix'. Prefereable use
18
# CONFIG-SCRIPTS as config script, CFLAGS-ARG instead of `--cflags` and
19
# LIBS-ARG instead of `--libs`, if given.
21
# The SED-EXPR-EXTRACTOR parameter representes the expression used in sed
22
# to extract the version number. Use it if your 'foo-config --version'
23
# dumps something like 'Foo library v1.0.0 (alfa)' instead of '1.0.0'.
25
# The macro respects LIBRARY_CONFIG, LIBRARY_CFLAGS and LIBRARY_LIBS
26
# variables. If the first one is defined, it specifies the name of the
27
# config script to use. If the latter two are defined, the script is not
28
# ran at all and their values are used instead (if only one of them is
29
# defined, the empty value of the remaining one is still used).
33
# AX_PATH_GENERIC(Foo, 1.0.0)
35
# would run `foo-config --version' and check that it is at least 1.0.0, if
36
# successful the following variables would be defined and substituted:
38
# FOO_CFLAGS to `foo-config --cflags`
39
# FOO_LIBS to `foo-config --libs`
43
# AX_PATH_GENERIC([Bar],,,[
44
# AC_MSG_ERROR([Cannot find Bar library])
47
# would check for bar-config program, defining and substituting the
48
# following variables:
50
# BAR_CFLAGS to `bar-config --cflags`
51
# BAR_LIBS to `bar-config --libs`
55
# ./configure BAZ_LIBS=/usr/lib/libbaz.a
57
# would link with a static version of baz library even if `baz-config
58
# --libs` returns just "-lbaz" that would normally result in using the
61
# This macro is a rearranged version of AC_PATH_GENERIC from Angus Lees.
65
# Copyright (c) 2009 Francesco Salvestrini <salvestrini@users.sourceforge.net>
67
# Copying and distribution of this file, with or without modification, are
68
# permitted in any medium without royalty provided the copyright notice
69
# and this notice are preserved. This file is offered as-is, without any
74
AU_ALIAS([AC_PATH_GENERIC], [AX_PATH_GENERIC])
75
AC_DEFUN([AX_PATH_GENERIC],[
76
AC_REQUIRE([AC_PROG_SED])
78
dnl we're going to need uppercase and lowercase versions of the
80
pushdef([UP], translit([$1], [a-z], [A-Z]))dnl
81
pushdef([DOWN], translit([$1], [A-Z], [a-z]))dnl
83
AC_ARG_WITH(DOWN-prefix,[AS_HELP_STRING([--with-]DOWN[-prefix=PREFIX], [Prefix where $1 is installed (optional)])],
84
DOWN[]_config_prefix="$withval", DOWN[]_config_prefix="")
85
AC_ARG_WITH(DOWN-exec-prefix,[AS_HELP_STRING([--with-]DOWN[-exec-prefix=EPREFIX], [Exec prefix where $1 is installed (optional)])],
86
DOWN[]_config_exec_prefix="$withval", DOWN[]_config_exec_prefix="")
88
AC_ARG_VAR(UP[]_CONFIG, [config script used for $1])
89
AC_ARG_VAR(UP[]_CFLAGS, [CFLAGS used for $1])
90
AC_ARG_VAR(UP[]_LIBS, [LIBS used for $1])
92
AS_IF([test x$UP[]_CFLAGS != x -o x$UP[]_LIBS != x],[
93
dnl Don't run config script at all, use user-provided values instead.
99
AS_IF([test x$DOWN[]_config_exec_prefix != x],[
100
DOWN[]_config_args="$DOWN[]_config_args --exec-prefix=$DOWN[]_config_exec_prefix"
101
AS_IF([test x${UP[]_CONFIG+set} != xset],[
102
UP[]_CONFIG=$DOWN[]_config_exec_prefix/bin/DOWN-config
105
AS_IF([test x$DOWN[]_config_prefix != x],[
106
DOWN[]_config_args="$DOWN[]_config_args --prefix=$DOWN[]_config_prefix"
107
AS_IF([test x${UP[]_CONFIG+set} != xset],[
108
UP[]_CONFIG=$DOWN[]_config_prefix/bin/DOWN-config
112
AC_PATH_PROGS(UP[]_CONFIG,[$6 DOWN-config],[no])
113
AS_IF([test "$UP[]_CONFIG" == "no"],[
117
dnl Get the CFLAGS from LIBRARY-config script
118
AS_IF([test x"$7" == x],[
119
UP[]_CFLAGS="`$UP[]_CONFIG $DOWN[]_config_args --cflags`"
121
UP[]_CFLAGS="`$UP[]_CONFIG $DOWN[]_config_args $7`"
124
dnl Get the LIBS from LIBRARY-config script
125
AS_IF([test x"$8" == x],[
126
UP[]_LIBS="`$UP[]_CONFIG $DOWN[]_config_args --libs`"
128
UP[]_LIBS="`$UP[]_CONFIG $DOWN[]_config_args $8`"
131
AS_IF([test x"$2" != x],[
132
dnl Check for provided library version
133
AS_IF([test x"$3" != x],[
134
dnl Use provided sed expression
135
DOWN[]_version="`$UP[]_CONFIG $DOWN[]_config_args --version | $SED -e $3`"
137
DOWN[]_version="`$UP[]_CONFIG $DOWN[]_config_args --version | $SED -e 's/^\ *\(.*\)\ *$/\1/'`"
140
AC_MSG_CHECKING([for $1 ($DOWN[]_version) >= $2])
141
AX_COMPARE_VERSION($DOWN[]_version,[ge],[$2],[
144
AC_SUBST(UP[]_CFLAGS)
154
AC_SUBST(UP[]_CFLAGS)