]> git.saurik.com Git - wxWidgets.git/blame - wxwin.m4
reSWIGed
[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
36AC_DEFUN(AM_OPTIONS_WXCONFIG,
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
VS
55dnl AM_PATH_WXCONFIG(VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
56dnl [, WX-LIBS]]])
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
VS
63dnl
64dnl Optional WX-LIBS argument contains comma-separated list of wxWindows
65dnl libraries to link against (it may include contrib libraries). If it is not
66dnl specified then WX_LIBS and WX_LIBS_STATIC will contain flags to link
67dnl with all of the core wxWindows libraries.
68dnl
69dnl Example use:
70dnl AM_PATH_WXCONFIG([2.6.0], [wxWin=1], [wxWin=0], [html,core,net])
debc175a
VS
71dnl ---------------------------------------------------------------------------
72
73dnl
74dnl Get the cflags and libraries from the wx-config script
75dnl
76AC_DEFUN(AM_PATH_WXCONFIG,
77[
78 dnl do we have wx-config name: it can be wx-config or wxd-config or ...
79 if test x${WX_CONFIG_NAME+set} != xset ; then
80 WX_CONFIG_NAME=wx-config
81 fi
5ff72dc4 82
debc175a
VS
83 if test "x$wx_config_name" != x ; then
84 WX_CONFIG_NAME="$wx_config_name"
85 fi
86
87 dnl deal with optional prefixes
88 if test x$wx_config_exec_prefix != x ; then
89 wx_config_args="$wx_config_args --exec-prefix=$wx_config_exec_prefix"
8e1aefe0 90 WX_LOOKUP_PATH="$wx_config_exec_prefix/bin"
debc175a
VS
91 fi
92 if test x$wx_config_prefix != x ; then
93 wx_config_args="$wx_config_args --prefix=$wx_config_prefix"
8e1aefe0 94 WX_LOOKUP_PATH="$WX_LOOKUP_PATH:$wx_config_prefix/bin"
debc175a
VS
95 fi
96
8e1aefe0
VS
97 dnl don't search the PATH if WX_CONFIG_NAME is absolute filename
98 if test -x "$WX_CONFIG_NAME" ; then
99 AC_MSG_CHECKING(for wx-config)
100 WX_CONFIG_PATH="$WX_CONFIG_NAME"
101 AC_MSG_RESULT($WX_CONFIG_PATH)
102 else
103 AC_PATH_PROG(WX_CONFIG_PATH, $WX_CONFIG_NAME, no, "$WX_LOOKUP_PATH:$PATH")
debc175a
VS
104 fi
105
106 if test "$WX_CONFIG_PATH" != "no" ; then
107 WX_VERSION=""
108 no_wx=""
109
110 min_wx_version=ifelse([$1], ,2.2.1,$1)
111 AC_MSG_CHECKING(for wxWindows version >= $min_wx_version)
112
113 WX_CONFIG_WITH_ARGS="$WX_CONFIG_PATH $wx_config_args"
114
115 WX_VERSION=`$WX_CONFIG_WITH_ARGS --version`
116 wx_config_major_version=`echo $WX_VERSION | \
117 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
118 wx_config_minor_version=`echo $WX_VERSION | \
119 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
120 wx_config_micro_version=`echo $WX_VERSION | \
121 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
122
123 wx_requested_major_version=`echo $min_wx_version | \
124 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
125 wx_requested_minor_version=`echo $min_wx_version | \
126 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
127 wx_requested_micro_version=`echo $min_wx_version | \
128 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
129
130 wx_ver_ok=""
131 if test $wx_config_major_version -gt $wx_requested_major_version; then
132 wx_ver_ok=yes
133 else
134 if test $wx_config_major_version -eq $wx_requested_major_version; then
135 if test $wx_config_minor_version -gt $wx_requested_minor_version; then
136 wx_ver_ok=yes
137 else
138 if test $wx_config_minor_version -eq $wx_requested_minor_version; then
139 if test $wx_config_micro_version -ge $wx_requested_micro_version; then
140 wx_ver_ok=yes
141 fi
142 fi
143 fi
144 fi
145 fi
146
147 if test "x$wx_ver_ok" = x ; then
148 no_wx=yes
149 else
c5be79d9
VS
150 if test "x$4" = "x" ; then
151 wx_libs_arg="--libs"
152 else
153 wx_libs_arg="--libs=$4"
154 fi
155 WX_LIBS=`$WX_CONFIG_WITH_ARGS $wx_libs_arg`
156 WX_LIBS_STATIC=`$WX_CONFIG_WITH_ARGS --static $wx_libs_arg`
debc175a
VS
157
158 dnl starting with version 2.2.6 wx-config has --cppflags argument
159 wx_has_cppflags=""
160 if test $wx_config_major_version -gt 2; then
161 wx_has_cppflags=yes
162 else
163 if test $wx_config_major_version -eq 2; then
164 if test $wx_config_minor_version -gt 2; then
165 wx_has_cppflags=yes
166 else
167 if test $wx_config_minor_version -eq 2; then
168 if test $wx_config_micro_version -ge 6; then
169 wx_has_cppflags=yes
170 fi
171 fi
172 fi
173 fi
174 fi
175
176 if test "x$wx_has_cppflags" = x ; then
177 dnl no choice but to define all flags like CFLAGS
178 WX_CFLAGS=`$WX_CONFIG_WITH_ARGS --cflags`
179 WX_CPPFLAGS=$WX_CFLAGS
180 WX_CXXFLAGS=$WX_CFLAGS
181
182 WX_CFLAGS_ONLY=$WX_CFLAGS
183 WX_CXXFLAGS_ONLY=$WX_CFLAGS
184 else
185 dnl we have CPPFLAGS included in CFLAGS included in CXXFLAGS
186 WX_CPPFLAGS=`$WX_CONFIG_WITH_ARGS --cppflags`
187 WX_CXXFLAGS=`$WX_CONFIG_WITH_ARGS --cxxflags`
188 WX_CFLAGS=`$WX_CONFIG_WITH_ARGS --cflags`
189
190 WX_CFLAGS_ONLY=`echo $WX_CFLAGS | sed "s@^$WX_CPPFLAGS *@@"`
191 WX_CXXFLAGS_ONLY=`echo $WX_CXXFLAGS | sed "s@^$WX_CFLAGS *@@"`
192 fi
193 fi
194
195 if test "x$no_wx" = x ; then
196 AC_MSG_RESULT(yes (version $WX_VERSION))
197 ifelse([$2], , :, [$2])
198 else
199 if test "x$WX_VERSION" = x; then
5ff72dc4
VZ
200 dnl no wx-config at all
201 AC_MSG_RESULT(no)
debc175a 202 else
5ff72dc4 203 AC_MSG_RESULT(no (version $WX_VERSION is not new enough))
debc175a
VS
204 fi
205
206 WX_CFLAGS=""
207 WX_CPPFLAGS=""
208 WX_CXXFLAGS=""
209 WX_LIBS=""
210 WX_LIBS_STATIC=""
211 ifelse([$3], , :, [$3])
212 fi
213 fi
214
215 AC_SUBST(WX_CPPFLAGS)
216 AC_SUBST(WX_CFLAGS)
217 AC_SUBST(WX_CXXFLAGS)
218 AC_SUBST(WX_CFLAGS_ONLY)
219 AC_SUBST(WX_CXXFLAGS_ONLY)
220 AC_SUBST(WX_LIBS)
221 AC_SUBST(WX_LIBS_STATIC)
222 AC_SUBST(WX_VERSION)
223])