diff options
Diffstat (limited to 'acinclude.m4')
-rw-r--r-- | acinclude.m4 | 233 |
1 files changed, 233 insertions, 0 deletions
diff --git a/acinclude.m4 b/acinclude.m4 new file mode 100644 index 0000000..a181dba --- /dev/null +++ b/acinclude.m4 | |||
@@ -0,0 +1,233 @@ | |||
1 | dnl @synopsis AC_PATH_GENERIC(LIBRARY [, MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) | ||
2 | dnl | ||
3 | dnl Runs a LIBRARY-config script and defines LIBRARY_CFLAGS and LIBRARY_LIBS | ||
4 | dnl | ||
5 | dnl The script must support `--cflags' and `--libs' args. | ||
6 | dnl If MINIMUM-VERSION is specified, the script must also support the | ||
7 | dnl `--version' arg. | ||
8 | dnl If the `--with-library-[exec-]prefix' arguments to ./configure are given, | ||
9 | dnl it must also support `--prefix' and `--exec-prefix'. | ||
10 | dnl (In other words, it must be like gtk-config.) | ||
11 | dnl | ||
12 | dnl For example: | ||
13 | dnl | ||
14 | dnl AC_PATH_GENERIC(Foo, 1.0.0) | ||
15 | dnl | ||
16 | dnl would run `foo-config --version' and check that it is at least 1.0.0 | ||
17 | dnl | ||
18 | dnl If so, the following would then be defined: | ||
19 | dnl | ||
20 | dnl FOO_CFLAGS to `foo-config --cflags` | ||
21 | dnl FOO_LIBS to `foo-config --libs` | ||
22 | dnl | ||
23 | dnl At present there is no support for additional "MODULES" (see AM_PATH_GTK) | ||
24 | dnl (shamelessly stolen from gtk.m4 and then hacked around a fair amount) | ||
25 | dnl | ||
26 | dnl @author Angus Lees <gusl@cse.unsw.edu.au> | ||
27 | dnl @version $Id: ac_path_generic.m4,v 1.1.1.1 2001/07/26 00:46:28 guidod Exp $ | ||
28 | |||
29 | AC_DEFUN([AC_PATH_GENERIC], | ||
30 | [dnl | ||
31 | dnl we're going to need uppercase, lowercase and user-friendly versions of the | ||
32 | dnl string `LIBRARY' | ||
33 | pushdef([UP], translit([$1], [a-z], [A-Z]))dnl | ||
34 | pushdef([DOWN], translit([$1], [A-Z], [a-z]))dnl | ||
35 | |||
36 | dnl | ||
37 | dnl Get the cflags and libraries from the LIBRARY-config script | ||
38 | dnl | ||
39 | AC_ARG_WITH(DOWN-prefix,[ --with-]DOWN[-prefix=PFX Prefix where $1 is installed (optional)], | ||
40 | DOWN[]_config_prefix="$withval", DOWN[]_config_prefix="") | ||
41 | AC_ARG_WITH(DOWN-exec-prefix,[ --with-]DOWN[-exec-prefix=PFX Exec prefix where $1 is installed (optional)], | ||
42 | DOWN[]_config_exec_prefix="$withval", DOWN[]_config_exec_prefix="") | ||
43 | |||
44 | if test x$DOWN[]_config_exec_prefix != x ; then | ||
45 | DOWN[]_config_args="$DOWN[]_config_args --exec-prefix=$DOWN[]_config_exec_prefix" | ||
46 | if test x${UP[]_CONFIG+set} != xset ; then | ||
47 | UP[]_CONFIG=$DOWN[]_config_exec_prefix/bin/DOWN-config | ||
48 | fi | ||
49 | fi | ||
50 | if test x$DOWN[]_config_prefix != x ; then | ||
51 | DOWN[]_config_args="$DOWN[]_config_args --prefix=$DOWN[]_config_prefix" | ||
52 | if test x${UP[]_CONFIG+set} != xset ; then | ||
53 | UP[]_CONFIG=$DOWN[]_config_prefix/bin/DOWN-config | ||
54 | fi | ||
55 | fi | ||
56 | |||
57 | AC_PATH_PROG(UP[]_CONFIG, DOWN-config, no) | ||
58 | ifelse([$2], , | ||
59 | AC_MSG_CHECKING(for $1), | ||
60 | AC_MSG_CHECKING(for $1 - version >= $2) | ||
61 | ) | ||
62 | no_[]DOWN="" | ||
63 | if test "$UP[]_CONFIG" = "no" ; then | ||
64 | no_[]DOWN=yes | ||
65 | else | ||
66 | UP[]_CFLAGS="`$UP[]_CONFIG $DOWN[]_config_args --cflags`" | ||
67 | UP[]_LIBS="`$UP[]_CONFIG $DOWN[]_config_args --libs`" | ||
68 | ifelse([$2], , ,[ | ||
69 | DOWN[]_config_major_version=`$UP[]_CONFIG $DOWN[]_config_args \ | ||
70 | --version | sed 's/[[^0-9]]*\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` | ||
71 | DOWN[]_config_minor_version=`$UP[]_CONFIG $DOWN[]_config_args \ | ||
72 | --version | sed 's/[[^0-9]]*\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` | ||
73 | DOWN[]_config_micro_version=`$UP[]_CONFIG $DOWN[]_config_args \ | ||
74 | --version | sed 's/[[^0-9]]*\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` | ||
75 | DOWN[]_wanted_major_version="regexp($2, [\<\([0-9]*\)], [\1])" | ||
76 | DOWN[]_wanted_minor_version="regexp($2, [\<\([0-9]*\)\.\([0-9]*\)], [\2])" | ||
77 | DOWN[]_wanted_micro_version="regexp($2, [\<\([0-9]*\).\([0-9]*\).\([0-9]*\)], [\3])" | ||
78 | |||
79 | # Compare wanted version to what config script returned. | ||
80 | # If I knew what library was being run, i'd probably also compile | ||
81 | # a test program at this point (which also extracted and tested | ||
82 | # the version in some library-specific way) | ||
83 | if test "$DOWN[]_config_major_version" -lt \ | ||
84 | "$DOWN[]_wanted_major_version" \ | ||
85 | -o \( "$DOWN[]_config_major_version" -eq \ | ||
86 | "$DOWN[]_wanted_major_version" \ | ||
87 | -a "$DOWN[]_config_minor_version" -lt \ | ||
88 | "$DOWN[]_wanted_minor_version" \) \ | ||
89 | -o \( "$DOWN[]_config_major_version" -eq \ | ||
90 | "$DOWN[]_wanted_major_version" \ | ||
91 | -a "$DOWN[]_config_minor_version" -eq \ | ||
92 | "$DOWN[]_wanted_minor_version" \ | ||
93 | -a "$DOWN[]_config_micro_version" -lt \ | ||
94 | "$DOWN[]_wanted_micro_version" \) ; then | ||
95 | # older version found | ||
96 | no_[]DOWN=yes | ||
97 | echo -n "*** An old version of $1 " | ||
98 | echo -n "($DOWN[]_config_major_version" | ||
99 | echo -n ".$DOWN[]_config_minor_version" | ||
100 | echo ".$DOWN[]_config_micro_version) was found." | ||
101 | echo -n "*** You need a version of $1 newer than " | ||
102 | echo -n "$DOWN[]_wanted_major_version" | ||
103 | echo -n ".$DOWN[]_wanted_minor_version" | ||
104 | echo ".$DOWN[]_wanted_micro_version." | ||
105 | echo "***" | ||
106 | echo "*** If you have already installed a sufficiently new version, this error" | ||
107 | echo "*** probably means that the wrong copy of the DOWN-config shell script is" | ||
108 | echo "*** being found. The easiest way to fix this is to remove the old version" | ||
109 | echo "*** of $1, but you can also set the UP[]_CONFIG environment to point to the" | ||
110 | echo "*** correct copy of DOWN-config. (In this case, you will have to" | ||
111 | echo "*** modify your LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf" | ||
112 | echo "*** so that the correct libraries are found at run-time)" | ||
113 | fi | ||
114 | ]) | ||
115 | fi | ||
116 | if test "x$no_[]DOWN" = x ; then | ||
117 | AC_MSG_RESULT(yes) | ||
118 | ifelse([$3], , :, [$3]) | ||
119 | else | ||
120 | AC_MSG_RESULT(no) | ||
121 | if test "$UP[]_CONFIG" = "no" ; then | ||
122 | echo "*** The DOWN-config script installed by $1 could not be found" | ||
123 | echo "*** If $1 was installed in PREFIX, make sure PREFIX/bin is in" | ||
124 | echo "*** your path, or set the UP[]_CONFIG environment variable to the" | ||
125 | echo "*** full path to DOWN-config." | ||
126 | fi | ||
127 | UP[]_CFLAGS="" | ||
128 | UP[]_LIBS="" | ||
129 | ifelse([$4], , :, [$4]) | ||
130 | fi | ||
131 | AC_SUBST(UP[]_CFLAGS) | ||
132 | AC_SUBST(UP[]_LIBS) | ||
133 | |||
134 | popdef([UP]) | ||
135 | popdef([DOWN]) | ||
136 | ]) | ||
137 | # xft.m4 | ||
138 | # Copyright (c) 2002 Henrik Kinnunen (fluxgen at linuxmail.org) | ||
139 | |||
140 | # Permission is hereby granted, free of charge, to any person obtaining a | ||
141 | # copy of this software and associated documentation files (the "Software"), | ||
142 | # to deal in the Software without restriction, including without limitation | ||
143 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
144 | # and/or sell copies of the Software, and to permit persons to whom the | ||
145 | # Software is furnished to do so, subject to the following conditions: | ||
146 | |||
147 | # The above copyright notice and this permission notice shall be included in | ||
148 | # all copies or substantial portions of the Software. | ||
149 | |||
150 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
151 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
152 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
153 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
154 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
155 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
156 | # DEALINGS IN THE SOFTWARE. | ||
157 | |||
158 | # AM_PATH_XFT1([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) | ||
159 | AC_DEFUN([AM_PATH_XFT1], | ||
160 | [ | ||
161 | AC_CHECK_LIB(Xft, XftFontOpen, | ||
162 | XFT_LIBS="-lXft" | ||
163 | [$1], | ||
164 | [$2] | ||
165 | ) | ||
166 | ]) | ||
167 | |||
168 | # AM_PATH_XFT2([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) | ||
169 | AC_DEFUN([AM_PATH_XFT2], | ||
170 | [ | ||
171 | if test x$pkg_exec_prefix != x ; then | ||
172 | xft_args="$xft_args --exec-prefix=$pkg_exec_prefix" | ||
173 | if test x${PKG_CONFIG+set} != xset ; then | ||
174 | PKG_CONFIG=$pkg_exec_prefix/bin/pkg-config | ||
175 | fi | ||
176 | fi | ||
177 | |||
178 | if test x$xft_prefix != x ; then | ||
179 | xft_args="$xft_args --prefix=$xft_prefix" | ||
180 | if test x${PKG_CONFIG+set} != xset ; then | ||
181 | PKG_CONFIG=$xft_prefix/bin/pkg-config | ||
182 | fi | ||
183 | fi | ||
184 | |||
185 | AC_PATH_PROG(PKG_CONFIG, pkg-config, no) | ||
186 | if test "x$PKG_CONFIG" = "xno" ; then | ||
187 | ifelse([$2], , :, [$2]) | ||
188 | else | ||
189 | XFT_CFLAGS=`$PKG_CONFIG $xftconf_args --cflags xft` | ||
190 | XFT_LIBS=`$PKG_CONFIG $xftconf_args --libs xft` | ||
191 | ifelse([$1], , :, [$1]) | ||
192 | fi | ||
193 | |||
194 | ]) | ||
195 | |||
196 | # AM_PATH_XFT(default-value, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) | ||
197 | # Test for Xft, and define XFT_CFLAGS and XFT_LIBS | ||
198 | AC_DEFUN([AM_PATH_XFT], | ||
199 | [ | ||
200 | AC_ARG_WITH(xft-prefix,[ --with-xft-prefix=path Prefix where Xft is installed (optional)], | ||
201 | xft_prefix="$withval", xft_prefix="") | ||
202 | AC_ARG_WITH(pkg-exec-prefix,[ --with-pkg-exec-prefix=path Exec prefix where pkg-config is installed (optional)], | ||
203 | pkg_exec_prefix="$withval", pkg_exec_prefix="") | ||
204 | AC_ARG_ENABLE(xft, [ --enable-xft Xft (antialias) support (default=$1)], | ||
205 | if test "x$enableval" = "xyes"; then | ||
206 | TRY_XFT=yes | ||
207 | else | ||
208 | TRY_XFT=no | ||
209 | fi | ||
210 | , | ||
211 | TRY_XFT=$1 | ||
212 | ) | ||
213 | |||
214 | if test "x$TRY_XFT" = "xyes"; then | ||
215 | AC_MSG_RESULT(yes) | ||
216 | AM_PATH_XFT2( | ||
217 | [$2], | ||
218 | # xft2 failed: try xft1 | ||
219 | AM_PATH_XFT1( | ||
220 | [$2], | ||
221 | [$3] | ||
222 | AC_MSG_RESULT([Cant find Xft libraries! Disabling Xft])) | ||
223 | ) | ||
224 | else | ||
225 | AC_MSG_RESULT(no) | ||
226 | [$3] | ||
227 | fi | ||
228 | |||
229 | CFLAGS="$CFLAGS $XFT_CFLAGS" | ||
230 | CXXFLAGS="$CXXFLAGS $XFT_CFLAGS" | ||
231 | LIBS="$LIBS $XFT_LIBS" | ||
232 | |||
233 | ]) | ||