3 dnl File name: aclocal.m4
4 dnl Purpose: Macros for autoconf
5 dnl Author: Till Riedel
9 dnl Copyright: (c) 2002-2003 Universität Karlsruhe
10 dnl Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
14 dnl Set variable `LD' to the name of the linker program.
15 AC_DEFUN(LIBFIRM_PROG_LD,[
16 dnl AC_REQUIRE([AC_PROG_CC])
17 if test -z "$LD"; then
23 dnl Set variable `libfirm_cv_prog_ld_r' to yes if the linker accepts -r, else to no.
24 AC_DEFUN(LIBFIRM_PROG_LD_R,
25 [AC_CACHE_CHECK(whether $LD accepts -r, libfirm_cv_prog_ld_r,
26 [AC_REQUIRE([LIBFIRM_PROG_LD])
27 libfirm_cv_prog_ld_r=no
29 cat > conftest.$ac_ext <<EOF
30 int foo() { return 0; }
32 if eval $ac_compile && mv conftest.o conftest2.o; then
33 cat > conftest.$ac_ext <<EOF
35 int main() { return foo(); }
37 if eval $ac_compile; then
38 if $LD -r -o conftest conftest.o conftest2.o; then
39 libfirm_cv_prog_ld_r=yes
45 AC_SUBST(libfirm_cv_prog_ld_r)
48 # PKG_PROG_PKG_CONFIG([MIN-VERSION])
49 # ----------------------------------
50 AC_DEFUN([PKG_PROG_PKG_CONFIG],
51 [m4_pattern_forbid([^_?PKG_[A-Z_]+$])
52 m4_pattern_allow([^PKG_CONFIG(_PATH)?$])
53 AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility])dnl
54 if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
55 AC_PATH_TOOL([PKG_CONFIG], [pkg-config])
57 if test -n "$PKG_CONFIG"; then
58 _pkg_min_version=m4_default([$1], [0.9.0])
59 AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version])
60 if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
68 ])# PKG_PROG_PKG_CONFIG
70 # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
72 # Check to see whether a particular set of modules exists. Similar
73 # to PKG_CHECK_MODULES(), but does not set variables or print errors.
76 # Similar to PKG_CHECK_MODULES, make sure that the first instance of
77 # this or PKG_CHECK_MODULES is called, or make sure to call
78 # PKG_CHECK_EXISTS manually
79 # --------------------------------------------------------------
80 AC_DEFUN([PKG_CHECK_EXISTS],
81 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
82 if test -n "$PKG_CONFIG" && \
83 AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then
84 m4_ifval([$2], [$2], [:])
89 # _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES])
90 # ---------------------------------------------
91 m4_define([_PKG_CONFIG],
92 [if test -n "$PKG_CONFIG"; then
93 if test -n "$$1"; then
96 PKG_CHECK_EXISTS([$3],
97 [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
105 # _PKG_SHORT_ERRORS_SUPPORTED
106 # -----------------------------
107 AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED],
108 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])
109 if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
110 _pkg_short_errors_supported=yes
112 _pkg_short_errors_supported=no
114 ])# _PKG_SHORT_ERRORS_SUPPORTED
117 # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
118 # [ACTION-IF-NOT-FOUND])
121 # Note that if there is a possibility the first call to
122 # PKG_CHECK_MODULES might not happen, you should be sure to include an
123 # explicit call to PKG_PROG_PKG_CONFIG in your configure.ac
126 # --------------------------------------------------------------
127 AC_DEFUN([PKG_CHECK_MODULES],
128 [AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
129 AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
130 AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
133 AC_MSG_CHECKING([for $1])
135 _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
136 _PKG_CONFIG([$1][_LIBS], [libs], [$2])
138 m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
139 and $1[]_LIBS to avoid the need to call pkg-config.
140 See the pkg-config man page for more details.])
142 if test $pkg_failed = yes; then
143 _PKG_SHORT_ERRORS_SUPPORTED
144 if test $_pkg_short_errors_supported = yes; then
145 $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"`
147 $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
149 # Put the nasty error message in config.log where it belongs
150 echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
152 ifelse([$4], , [AC_MSG_ERROR(dnl
153 [Package requirements ($2) were not met:
157 Consider adjusting the PKG_CONFIG_PATH environment variable if you
158 installed software in a non-standard prefix.
164 elif test $pkg_failed = untried; then
165 ifelse([$4], , [AC_MSG_FAILURE(dnl
166 [The pkg-config script could not be found or is too old. Make sure it
167 is in your PATH or set the PKG_CONFIG environment variable to the full
172 To get pkg-config, see <http://www.freedesktop.org/software/pkgconfig>.])],
175 $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
176 $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
178 ifelse([$3], , :, [$3])
180 ])# PKG_CHECK_MODULES