don't emit vfp copies
[libfirm] / aclocal.m4
1 dnl
2 dnl Project:     libFIRM
3 dnl File name:   aclocal.m4
4 dnl Purpose:     Macros for autoconf
5 dnl Author:      Till Riedel
6 dnl Modified by:
7 dnl Created:
8 dnl CVS-ID:      $Id$
9 dnl Copyright:   (c) 2002-2003 Universität Karlsruhe
10 dnl Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
11 dnl
12
13
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
18   AC_CHECK_TOOL(LD, ld)
19 fi
20 ])
21
22
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
28 if test "$LD"; then
29   cat > conftest.$ac_ext <<EOF
30 int foo() { return 0; }
31 EOF
32   if eval $ac_compile && mv conftest.o conftest2.o; then
33     cat > conftest.$ac_ext <<EOF
34 extern int foo();
35 int main() { return foo(); }
36 EOF
37     if eval $ac_compile; then
38       if $LD -r -o conftest conftest.o conftest2.o; then
39         libfirm_cv_prog_ld_r=yes
40       fi
41     fi
42   fi
43 fi
44 rm -f conftest*])
45 AC_SUBST(libfirm_cv_prog_ld_r)
46 ])
47
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])
56 fi
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
61                 AC_MSG_RESULT([yes])
62         else
63                 AC_MSG_RESULT([no])
64                 PKG_CONFIG=""
65         fi
66
67 fi[]dnl
68 ])# PKG_PROG_PKG_CONFIG
69
70 # PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
71 #
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.
74 #
75 #
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], [:])
85 m4_ifvaln([$3], [else
86   $3])dnl
87 fi])
88
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
94         pkg_cv_[]$1="$$1"
95     else
96         PKG_CHECK_EXISTS([$3],
97                          [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null`],
98                          [pkg_failed=yes])
99     fi
100 else
101         pkg_failed=untried
102 fi[]dnl
103 ])# _PKG_CONFIG
104
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
111 else
112         _pkg_short_errors_supported=no
113 fi[]dnl
114 ])# _PKG_SHORT_ERRORS_SUPPORTED
115
116
117 # PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
118 # [ACTION-IF-NOT-FOUND])
119 #
120 #
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
124 #
125 #
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
131
132 pkg_failed=no
133 AC_MSG_CHECKING([for $1])
134
135 _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
136 _PKG_CONFIG([$1][_LIBS], [libs], [$2])
137
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.])
141
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"`
146         else
147                 $1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
148         fi
149         # Put the nasty error message in config.log where it belongs
150         echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
151
152         ifelse([$4], , [AC_MSG_ERROR(dnl
153 [Package requirements ($2) were not met:
154
155 $$1_PKG_ERRORS
156
157 Consider adjusting the PKG_CONFIG_PATH environment variable if you
158 installed software in a non-standard prefix.
159
160 _PKG_TEXT
161 ])],
162                 [AC_MSG_RESULT([no])
163                 $4])
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
168 path to pkg-config.
169
170 _PKG_TEXT
171
172 To get pkg-config, see <http://www.freedesktop.org/software/pkgconfig>.])],
173                 [$4])
174 else
175         $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
176         $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
177         AC_MSG_RESULT([yes])
178         ifelse([$3], , :, [$3])
179 fi[]dnl
180 ])# PKG_CHECK_MODULES
181
182 dnl end of aclocal.m