]>
Commit | Line | Data |
---|---|---|
1 | dnl --------------------------------------------------------------------------- | |
2 | dnl Macros for wxWindows detection. Typically used in configure.in as: | |
3 | dnl | |
4 | dnl AC_ARG_ENABLE(...) | |
5 | dnl AC_ARG_WITH(...) | |
6 | dnl ... | |
7 | dnl AM_OPTIONS_WXCONFIG | |
8 | dnl ... | |
9 | dnl ... | |
10 | dnl AM_PATH_WXCONFIG(2.3.4, wxWin=1) | |
11 | dnl if test "$wxWin" != 1; then | |
12 | dnl AC_MSG_ERROR([ | |
13 | dnl wxWindows must be installed on your system | |
14 | dnl but wx-config script couldn't be found. | |
15 | dnl | |
16 | dnl Please check that wx-config is in path, the directory | |
17 | dnl where wxWindows libraries are installed (returned by | |
18 | dnl 'wx-config --libs' command) is in LD_LIBRARY_PATH or | |
19 | dnl equivalent variable and wxWindows version is 2.3.4 or above. | |
20 | dnl ]) | |
21 | dnl fi | |
22 | dnl CPPFLAGS="$CPPFLAGS $WX_CPPFLAGS" | |
23 | dnl CXXFLAGS="$CXXFLAGS $WX_CXXFLAGS_ONLY" | |
24 | dnl CFLAGS="$CFLAGS $WX_CFLAGS_ONLY" | |
25 | dnl | |
26 | dnl LDFLAGS="$LDFLAGS $WX_LIBS" | |
27 | dnl --------------------------------------------------------------------------- | |
28 | ||
29 | dnl --------------------------------------------------------------------------- | |
30 | dnl AM_OPTIONS_WXCONFIG | |
31 | dnl | |
32 | dnl adds support for --wx-prefix, --wx-exec-prefix, --with-wxdir and | |
33 | dnl --wx-config command line options | |
34 | dnl --------------------------------------------------------------------------- | |
35 | ||
36 | AC_DEFUN([AM_OPTIONS_WXCONFIG], | |
37 | [ | |
38 | AC_ARG_WITH(wxdir, | |
39 | [ --with-wxdir=PATH Use uninstalled version of wxWindows in PATH], | |
40 | [ wx_config_name="$withval/wx-config" | |
41 | wx_config_args="--inplace"]) | |
42 | AC_ARG_WITH(wx-config, | |
43 | [ --with-wx-config=CONFIG wx-config script to use (optional)], | |
44 | wx_config_name="$withval" ) | |
45 | AC_ARG_WITH(wx-prefix, | |
46 | [ --with-wx-prefix=PREFIX Prefix where wxWindows is installed (optional)], | |
47 | wx_config_prefix="$withval", wx_config_prefix="") | |
48 | AC_ARG_WITH(wx-exec-prefix, | |
49 | [ --with-wx-exec-prefix=PREFIX | |
50 | Exec prefix where wxWindows is installed (optional)], | |
51 | wx_config_exec_prefix="$withval", wx_config_exec_prefix="") | |
52 | ]) | |
53 | ||
54 | dnl --------------------------------------------------------------------------- | |
55 | dnl AM_PATH_WXCONFIG(VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND | |
56 | dnl [, WX-LIBS [, ADDITIONAL-WX-CONFIG-FLAGS]]]]) | |
57 | dnl | |
58 | dnl Test for wxWindows, and define WX_C*FLAGS, WX_LIBS and WX_LIBS_STATIC | |
59 | dnl (the latter is for static linking against wxWindows). Set WX_CONFIG_NAME | |
60 | dnl environment variable to override the default name of the wx-config script | |
61 | dnl to use. Set WX_CONFIG_PATH to specify the full path to wx-config - in this | |
62 | dnl case the macro won't even waste time on tests for its existence. | |
63 | dnl | |
64 | dnl Optional WX-LIBS argument contains comma- or space-separated list of | |
65 | dnl wxWindows libraries to link against (it may include contrib libraries). If | |
66 | dnl it is not specified then WX_LIBS and WX_LIBS_STATIC will contain flags to | |
67 | dnl link with all of the core wxWindows libraries. | |
68 | dnl | |
69 | dnl Optional ADDITIONAL-WX-CONFIG-FLAGS argument is appended to wx-config | |
70 | dnl invocation command in present. It can be used to fine-tune lookup of | |
71 | dnl best wxWidgets build available. | |
72 | dnl | |
73 | dnl Example use: | |
74 | dnl AM_PATH_WXCONFIG([2.6.0], [wxWin=1], [wxWin=0], [html,core,net] | |
75 | dnl [--unicode --debug]) | |
76 | dnl --------------------------------------------------------------------------- | |
77 | ||
78 | dnl | |
79 | dnl Get the cflags and libraries from the wx-config script | |
80 | dnl | |
81 | AC_DEFUN([AM_PATH_WXCONFIG], | |
82 | [ | |
83 | dnl do we have wx-config name: it can be wx-config or wxd-config or ... | |
84 | if test x${WX_CONFIG_NAME+set} != xset ; then | |
85 | WX_CONFIG_NAME=wx-config | |
86 | fi | |
87 | ||
88 | if test "x$wx_config_name" != x ; then | |
89 | WX_CONFIG_NAME="$wx_config_name" | |
90 | fi | |
91 | ||
92 | dnl deal with optional prefixes | |
93 | if test x$wx_config_exec_prefix != x ; then | |
94 | wx_config_args="$wx_config_args --exec-prefix=$wx_config_exec_prefix" | |
95 | WX_LOOKUP_PATH="$wx_config_exec_prefix/bin" | |
96 | fi | |
97 | if test x$wx_config_prefix != x ; then | |
98 | wx_config_args="$wx_config_args --prefix=$wx_config_prefix" | |
99 | WX_LOOKUP_PATH="$WX_LOOKUP_PATH:$wx_config_prefix/bin" | |
100 | fi | |
101 | if test "$cross_compiling" = "yes"; then | |
102 | wx_config_args="$wx_config_args --host=$host_alias" | |
103 | fi | |
104 | ||
105 | dnl don't search the PATH if WX_CONFIG_NAME is absolute filename | |
106 | if test -x "$WX_CONFIG_NAME" ; then | |
107 | AC_MSG_CHECKING(for wx-config) | |
108 | WX_CONFIG_PATH="$WX_CONFIG_NAME" | |
109 | AC_MSG_RESULT($WX_CONFIG_PATH) | |
110 | else | |
111 | AC_PATH_PROG(WX_CONFIG_PATH, $WX_CONFIG_NAME, no, "$WX_LOOKUP_PATH:$PATH") | |
112 | fi | |
113 | ||
114 | if test "$WX_CONFIG_PATH" != "no" ; then | |
115 | WX_VERSION="" | |
116 | no_wx="" | |
117 | ||
118 | min_wx_version=ifelse([$1], ,2.2.1,$1) | |
119 | if test -z "$5" ; then | |
120 | AC_MSG_CHECKING([for wxWindows version >= $min_wx_version]) | |
121 | else | |
122 | AC_MSG_CHECKING([for wxWindows version >= $min_wx_version ($5)]) | |
123 | fi | |
124 | ||
125 | WX_CONFIG_WITH_ARGS="$WX_CONFIG_PATH $wx_config_args $5 $4" | |
126 | ||
127 | WX_VERSION=`$WX_CONFIG_WITH_ARGS --version 2>/dev/null` | |
128 | wx_config_major_version=`echo $WX_VERSION | \ | |
129 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` | |
130 | wx_config_minor_version=`echo $WX_VERSION | \ | |
131 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` | |
132 | wx_config_micro_version=`echo $WX_VERSION | \ | |
133 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` | |
134 | ||
135 | wx_requested_major_version=`echo $min_wx_version | \ | |
136 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` | |
137 | wx_requested_minor_version=`echo $min_wx_version | \ | |
138 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` | |
139 | wx_requested_micro_version=`echo $min_wx_version | \ | |
140 | sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` | |
141 | ||
142 | wx_ver_ok="" | |
143 | if test "x$WX_VERSION" != x ; then | |
144 | if test $wx_config_major_version -gt $wx_requested_major_version; then | |
145 | wx_ver_ok=yes | |
146 | else | |
147 | if test $wx_config_major_version -eq $wx_requested_major_version; then | |
148 | if test $wx_config_minor_version -gt $wx_requested_minor_version; then | |
149 | wx_ver_ok=yes | |
150 | else | |
151 | if test $wx_config_minor_version -eq $wx_requested_minor_version; then | |
152 | if test $wx_config_micro_version -ge $wx_requested_micro_version; then | |
153 | wx_ver_ok=yes | |
154 | fi | |
155 | fi | |
156 | fi | |
157 | fi | |
158 | fi | |
159 | fi | |
160 | ||
161 | if test "x$wx_ver_ok" = x ; then | |
162 | no_wx=yes | |
163 | else | |
164 | WX_LIBS=`$WX_CONFIG_WITH_ARGS --libs` | |
165 | WX_LIBS_STATIC=`$WX_CONFIG_WITH_ARGS --static --libs` | |
166 | ||
167 | dnl starting with version 2.2.6 wx-config has --cppflags argument | |
168 | wx_has_cppflags="" | |
169 | if test $wx_config_major_version -gt 2; then | |
170 | wx_has_cppflags=yes | |
171 | else | |
172 | if test $wx_config_major_version -eq 2; then | |
173 | if test $wx_config_minor_version -gt 2; then | |
174 | wx_has_cppflags=yes | |
175 | else | |
176 | if test $wx_config_minor_version -eq 2; then | |
177 | if test $wx_config_micro_version -ge 6; then | |
178 | wx_has_cppflags=yes | |
179 | fi | |
180 | fi | |
181 | fi | |
182 | fi | |
183 | fi | |
184 | ||
185 | if test "x$wx_has_cppflags" = x ; then | |
186 | dnl no choice but to define all flags like CFLAGS | |
187 | WX_CFLAGS=`$WX_CONFIG_WITH_ARGS --cflags` | |
188 | WX_CPPFLAGS=$WX_CFLAGS | |
189 | WX_CXXFLAGS=$WX_CFLAGS | |
190 | ||
191 | WX_CFLAGS_ONLY=$WX_CFLAGS | |
192 | WX_CXXFLAGS_ONLY=$WX_CFLAGS | |
193 | else | |
194 | dnl we have CPPFLAGS included in CFLAGS included in CXXFLAGS | |
195 | WX_CPPFLAGS=`$WX_CONFIG_WITH_ARGS --cppflags` | |
196 | WX_CXXFLAGS=`$WX_CONFIG_WITH_ARGS --cxxflags` | |
197 | WX_CFLAGS=`$WX_CONFIG_WITH_ARGS --cflags` | |
198 | ||
199 | WX_CFLAGS_ONLY=`echo $WX_CFLAGS | sed "s@^$WX_CPPFLAGS *@@"` | |
200 | WX_CXXFLAGS_ONLY=`echo $WX_CXXFLAGS | sed "s@^$WX_CFLAGS *@@"` | |
201 | fi | |
202 | fi | |
203 | ||
204 | if test "x$no_wx" = x ; then | |
205 | AC_MSG_RESULT(yes (version $WX_VERSION)) | |
206 | ifelse([$2], , :, [$2]) | |
207 | else | |
208 | if test "x$WX_VERSION" = x; then | |
209 | dnl no wx-config at all | |
210 | AC_MSG_RESULT(no) | |
211 | else | |
212 | AC_MSG_RESULT(no (version $WX_VERSION is not new enough)) | |
213 | fi | |
214 | ||
215 | WX_CFLAGS="" | |
216 | WX_CPPFLAGS="" | |
217 | WX_CXXFLAGS="" | |
218 | WX_LIBS="" | |
219 | WX_LIBS_STATIC="" | |
220 | ifelse([$3], , :, [$3]) | |
221 | fi | |
222 | fi | |
223 | ||
224 | AC_SUBST(WX_CPPFLAGS) | |
225 | AC_SUBST(WX_CFLAGS) | |
226 | AC_SUBST(WX_CXXFLAGS) | |
227 | AC_SUBST(WX_CFLAGS_ONLY) | |
228 | AC_SUBST(WX_CXXFLAGS_ONLY) | |
229 | AC_SUBST(WX_LIBS) | |
230 | AC_SUBST(WX_LIBS_STATIC) | |
231 | AC_SUBST(WX_VERSION) | |
232 | ]) |