]> git.saurik.com Git - wxWidgets.git/blame - wxwin.m4
data stream test for extended
[wxWidgets.git] / wxwin.m4
CommitLineData
debc175a
VS
1dnl ---------------------------------------------------------------------------
2dnl Macros for wxWindows detection. Typically used in configure.in as:
3dnl
5ff72dc4
VZ
4dnl AC_ARG_ENABLE(...)
5dnl AC_ARG_WITH(...)
6dnl ...
7dnl AM_OPTIONS_WXCONFIG
8dnl ...
9dnl ...
10dnl AM_PATH_WXCONFIG(2.3.4, wxWin=1)
debc175a
VS
11dnl if test "$wxWin" != 1; then
12dnl AC_MSG_ERROR([
5ff72dc4
VZ
13dnl wxWindows must be installed on your system
14dnl but wx-config script couldn't be found.
15dnl
16dnl Please check that wx-config is in path, the directory
17dnl where wxWindows libraries are installed (returned by
18dnl 'wx-config --libs' command) is in LD_LIBRARY_PATH or
19dnl equivalent variable and wxWindows version is 2.3.4 or above.
debc175a
VS
20dnl ])
21dnl fi
22dnl CPPFLAGS="$CPPFLAGS $WX_CPPFLAGS"
23dnl CXXFLAGS="$CXXFLAGS $WX_CXXFLAGS_ONLY"
24dnl CFLAGS="$CFLAGS $WX_CFLAGS_ONLY"
5ff72dc4 25dnl
debc175a
VS
26dnl LDFLAGS="$LDFLAGS $WX_LIBS"
27dnl ---------------------------------------------------------------------------
28
29dnl ---------------------------------------------------------------------------
30dnl AM_OPTIONS_WXCONFIG
31dnl
5ff72dc4
VZ
32dnl adds support for --wx-prefix, --wx-exec-prefix, --with-wxdir and
33dnl --wx-config command line options
debc175a
VS
34dnl ---------------------------------------------------------------------------
35
79f8a0d8 36AC_DEFUN([AM_OPTIONS_WXCONFIG],
debc175a 37[
5ff72dc4
VZ
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="")
debc175a
VS
52])
53
54dnl ---------------------------------------------------------------------------
c5be79d9 55dnl AM_PATH_WXCONFIG(VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
8708fa76 56dnl [, WX-LIBS [, ADDITIONAL-WX-CONFIG-FLAGS]]]])
debc175a
VS
57dnl
58dnl Test for wxWindows, and define WX_C*FLAGS, WX_LIBS and WX_LIBS_STATIC
59dnl (the latter is for static linking against wxWindows). Set WX_CONFIG_NAME
60dnl environment variable to override the default name of the wx-config script
61dnl to use. Set WX_CONFIG_PATH to specify the full path to wx-config - in this
62dnl case the macro won't even waste time on tests for its existence.
c5be79d9 63dnl
8708fa76
VS
64dnl Optional WX-LIBS argument contains comma- or space-separated list of
65dnl wxWindows libraries to link against (it may include contrib libraries). If
66dnl it is not specified then WX_LIBS and WX_LIBS_STATIC will contain flags to
67dnl link with all of the core wxWindows libraries.
68dnl
69dnl Optional ADDITIONAL-WX-CONFIG-FLAGS argument is appended to wx-config
70dnl invocation command in present. It can be used to fine-tune lookup of
71dnl best wxWidgets build available.
c5be79d9
VS
72dnl
73dnl Example use:
8708fa76
VS
74dnl AM_PATH_WXCONFIG([2.6.0], [wxWin=1], [wxWin=0], [html,core,net]
75dnl [--unicode --debug])
debc175a
VS
76dnl ---------------------------------------------------------------------------
77
78dnl
79dnl Get the cflags and libraries from the wx-config script
80dnl
79f8a0d8 81AC_DEFUN([AM_PATH_WXCONFIG],
debc175a
VS
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
5ff72dc4 87
debc175a
VS
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"
8e1aefe0 95 WX_LOOKUP_PATH="$wx_config_exec_prefix/bin"
debc175a
VS
96 fi
97 if test x$wx_config_prefix != x ; then
98 wx_config_args="$wx_config_args --prefix=$wx_config_prefix"
8e1aefe0 99 WX_LOOKUP_PATH="$WX_LOOKUP_PATH:$wx_config_prefix/bin"
debc175a 100 fi
48112931
VS
101 if test "$cross_compiling" = "yes"; then
102 wx_config_args="$wx_config_args --host=$host_alias"
103 fi
debc175a 104
8e1aefe0
VS
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")
debc175a
VS
112 fi
113
114 if test "$WX_CONFIG_PATH" != "no" ; then
115 WX_VERSION=""
debc175a
VS
116
117 min_wx_version=ifelse([$1], ,2.2.1,$1)
8708fa76
VS
118 if test -z "$5" ; then
119 AC_MSG_CHECKING([for wxWindows version >= $min_wx_version])
120 else
121 AC_MSG_CHECKING([for wxWindows version >= $min_wx_version ($5)])
122 fi
debc175a 123
8708fa76 124 WX_CONFIG_WITH_ARGS="$WX_CONFIG_PATH $wx_config_args $5 $4"
debc175a 125
8708fa76 126 WX_VERSION=`$WX_CONFIG_WITH_ARGS --version 2>/dev/null`
debc175a
VS
127 wx_config_major_version=`echo $WX_VERSION | \
128 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
129 wx_config_minor_version=`echo $WX_VERSION | \
130 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
131 wx_config_micro_version=`echo $WX_VERSION | \
132 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
133
134 wx_requested_major_version=`echo $min_wx_version | \
135 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
136 wx_requested_minor_version=`echo $min_wx_version | \
137 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
138 wx_requested_micro_version=`echo $min_wx_version | \
139 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
140
141 wx_ver_ok=""
8708fa76
VS
142 if test "x$WX_VERSION" != x ; then
143 if test $wx_config_major_version -gt $wx_requested_major_version; then
144 wx_ver_ok=yes
145 else
146 if test $wx_config_major_version -eq $wx_requested_major_version; then
147 if test $wx_config_minor_version -gt $wx_requested_minor_version; then
148 wx_ver_ok=yes
149 else
150 if test $wx_config_minor_version -eq $wx_requested_minor_version; then
151 if test $wx_config_micro_version -ge $wx_requested_micro_version; then
152 wx_ver_ok=yes
153 fi
154 fi
155 fi
156 fi
debc175a
VS
157 fi
158 fi
159
3f45f8bf
RL
160 if test -n "$wx_ver_ok"; then
161
162 AC_MSG_RESULT(yes (version $WX_VERSION))
8708fa76 163 WX_LIBS=`$WX_CONFIG_WITH_ARGS --libs`
3f45f8bf
RL
164
165 dnl is this even still appropriate? --static is a real option now
166 dnl and WX_CONFIG_WITH_ARGS is likely to contain it if that is
167 dnl what the user actually wants, making this redundant at best.
168 dnl For now keep it in case anyone actually used it in the past.
169 AC_MSG_CHECKING([for wxWindows static library])
a1d47842
VZ
170 WX_LIBS_STATIC=`$WX_CONFIG_WITH_ARGS --static --libs 2>/dev/null`
171 if test "x$WX_LIBS_STATIC" = "x"; then
172 AC_MSG_RESULT(no)
173 else
3f45f8bf
RL
174 AC_MSG_RESULT(yes)
175 fi
debc175a
VS
176
177 dnl starting with version 2.2.6 wx-config has --cppflags argument
178 wx_has_cppflags=""
179 if test $wx_config_major_version -gt 2; then
180 wx_has_cppflags=yes
181 else
182 if test $wx_config_major_version -eq 2; then
183 if test $wx_config_minor_version -gt 2; then
184 wx_has_cppflags=yes
185 else
186 if test $wx_config_minor_version -eq 2; then
187 if test $wx_config_micro_version -ge 6; then
188 wx_has_cppflags=yes
189 fi
190 fi
191 fi
192 fi
193 fi
194
195 if test "x$wx_has_cppflags" = x ; then
196 dnl no choice but to define all flags like CFLAGS
197 WX_CFLAGS=`$WX_CONFIG_WITH_ARGS --cflags`
198 WX_CPPFLAGS=$WX_CFLAGS
199 WX_CXXFLAGS=$WX_CFLAGS
200
201 WX_CFLAGS_ONLY=$WX_CFLAGS
202 WX_CXXFLAGS_ONLY=$WX_CFLAGS
203 else
204 dnl we have CPPFLAGS included in CFLAGS included in CXXFLAGS
205 WX_CPPFLAGS=`$WX_CONFIG_WITH_ARGS --cppflags`
206 WX_CXXFLAGS=`$WX_CONFIG_WITH_ARGS --cxxflags`
207 WX_CFLAGS=`$WX_CONFIG_WITH_ARGS --cflags`
208
209 WX_CFLAGS_ONLY=`echo $WX_CFLAGS | sed "s@^$WX_CPPFLAGS *@@"`
210 WX_CXXFLAGS_ONLY=`echo $WX_CXXFLAGS | sed "s@^$WX_CFLAGS *@@"`
211 fi
debc175a 212
3f45f8bf
RL
213 ifelse([$2], , :, [$2])
214
debc175a 215 else
3f45f8bf 216
debc175a 217 if test "x$WX_VERSION" = x; then
5ff72dc4
VZ
218 dnl no wx-config at all
219 AC_MSG_RESULT(no)
debc175a 220 else
5ff72dc4 221 AC_MSG_RESULT(no (version $WX_VERSION is not new enough))
debc175a
VS
222 fi
223
224 WX_CFLAGS=""
225 WX_CPPFLAGS=""
226 WX_CXXFLAGS=""
227 WX_LIBS=""
228 WX_LIBS_STATIC=""
229 ifelse([$3], , :, [$3])
3f45f8bf 230
debc175a
VS
231 fi
232 fi
233
234 AC_SUBST(WX_CPPFLAGS)
235 AC_SUBST(WX_CFLAGS)
236 AC_SUBST(WX_CXXFLAGS)
237 AC_SUBST(WX_CFLAGS_ONLY)
238 AC_SUBST(WX_CXXFLAGS_ONLY)
239 AC_SUBST(WX_LIBS)
240 AC_SUBST(WX_LIBS_STATIC)
241 AC_SUBST(WX_VERSION)
242])