]> git.saurik.com Git - wxWidgets.git/blob - wxwin.m4
fix for focus handling in generic wxListCtrl
[wxWidgets.git] / wxwin.m4
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.2, 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.2 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 and --wx-config
33 dnl command line options
34 dnl ---------------------------------------------------------------------------
35
36 AC_DEFUN(AM_OPTIONS_WXCONFIG,
37 [
38 AC_ARG_WITH(wx-prefix, [ --with-wx-prefix=PREFIX Prefix where wxWindows is installed (optional)],
39 wx_config_prefix="$withval", wx_config_prefix="")
40 AC_ARG_WITH(wx-exec-prefix,[ --with-wx-exec-prefix=PREFIX Exec prefix where wxWindows is installed (optional)],
41 wx_config_exec_prefix="$withval", wx_config_exec_prefix="")
42 AC_ARG_WITH(wx-config,[ --with-wx-config=CONFIG wx-config script to use (optional)],
43 wx_config_name="$withval", wx_config_name="")
44 ])
45
46 dnl ---------------------------------------------------------------------------
47 dnl AM_PATH_WXCONFIG(VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
48 dnl
49 dnl Test for wxWindows, and define WX_C*FLAGS, WX_LIBS and WX_LIBS_STATIC
50 dnl (the latter is for static linking against wxWindows). Set WX_CONFIG_NAME
51 dnl environment variable to override the default name of the wx-config script
52 dnl to use. Set WX_CONFIG_PATH to specify the full path to wx-config - in this
53 dnl case the macro won't even waste time on tests for its existence.
54 dnl ---------------------------------------------------------------------------
55
56 dnl
57 dnl Get the cflags and libraries from the wx-config script
58 dnl
59 AC_DEFUN(AM_PATH_WXCONFIG,
60 [
61 dnl do we have wx-config name: it can be wx-config or wxd-config or ...
62 if test x${WX_CONFIG_NAME+set} != xset ; then
63 WX_CONFIG_NAME=wx-config
64 fi
65 if test "x$wx_config_name" != x ; then
66 WX_CONFIG_NAME="$wx_config_name"
67 fi
68
69 dnl deal with optional prefixes
70 if test x$wx_config_exec_prefix != x ; then
71 wx_config_args="$wx_config_args --exec-prefix=$wx_config_exec_prefix"
72 WX_LOOKUP_PATH="$wx_config_exec_prefix/bin"
73 fi
74 if test x$wx_config_prefix != x ; then
75 wx_config_args="$wx_config_args --prefix=$wx_config_prefix"
76 WX_LOOKUP_PATH="$WX_LOOKUP_PATH:$wx_config_prefix/bin"
77 fi
78
79 dnl don't search the PATH if WX_CONFIG_NAME is absolute filename
80 if test -x "$WX_CONFIG_NAME" ; then
81 AC_MSG_CHECKING(for wx-config)
82 WX_CONFIG_PATH="$WX_CONFIG_NAME"
83 AC_MSG_RESULT($WX_CONFIG_PATH)
84 else
85 AC_PATH_PROG(WX_CONFIG_PATH, $WX_CONFIG_NAME, no, "$WX_LOOKUP_PATH:$PATH")
86 fi
87
88 if test "$WX_CONFIG_PATH" != "no" ; then
89 WX_VERSION=""
90 no_wx=""
91
92 min_wx_version=ifelse([$1], ,2.2.1,$1)
93 AC_MSG_CHECKING(for wxWindows version >= $min_wx_version)
94
95 WX_CONFIG_WITH_ARGS="$WX_CONFIG_PATH $wx_config_args"
96
97 WX_VERSION=`$WX_CONFIG_WITH_ARGS --version`
98 wx_config_major_version=`echo $WX_VERSION | \
99 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
100 wx_config_minor_version=`echo $WX_VERSION | \
101 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
102 wx_config_micro_version=`echo $WX_VERSION | \
103 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
104
105 wx_requested_major_version=`echo $min_wx_version | \
106 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
107 wx_requested_minor_version=`echo $min_wx_version | \
108 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
109 wx_requested_micro_version=`echo $min_wx_version | \
110 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
111
112 wx_ver_ok=""
113 if test $wx_config_major_version -gt $wx_requested_major_version; then
114 wx_ver_ok=yes
115 else
116 if test $wx_config_major_version -eq $wx_requested_major_version; then
117 if test $wx_config_minor_version -gt $wx_requested_minor_version; then
118 wx_ver_ok=yes
119 else
120 if test $wx_config_minor_version -eq $wx_requested_minor_version; then
121 if test $wx_config_micro_version -ge $wx_requested_micro_version; then
122 wx_ver_ok=yes
123 fi
124 fi
125 fi
126 fi
127 fi
128
129 if test "x$wx_ver_ok" = x ; then
130 no_wx=yes
131 else
132 WX_LIBS=`$WX_CONFIG_WITH_ARGS --libs`
133 WX_LIBS_STATIC=`$WX_CONFIG_WITH_ARGS --static --libs`
134
135 dnl starting with version 2.2.6 wx-config has --cppflags argument
136 wx_has_cppflags=""
137 if test $wx_config_major_version -gt 2; then
138 wx_has_cppflags=yes
139 else
140 if test $wx_config_major_version -eq 2; then
141 if test $wx_config_minor_version -gt 2; then
142 wx_has_cppflags=yes
143 else
144 if test $wx_config_minor_version -eq 2; then
145 if test $wx_config_micro_version -ge 6; then
146 wx_has_cppflags=yes
147 fi
148 fi
149 fi
150 fi
151 fi
152
153 if test "x$wx_has_cppflags" = x ; then
154 dnl no choice but to define all flags like CFLAGS
155 WX_CFLAGS=`$WX_CONFIG_WITH_ARGS --cflags`
156 WX_CPPFLAGS=$WX_CFLAGS
157 WX_CXXFLAGS=$WX_CFLAGS
158
159 WX_CFLAGS_ONLY=$WX_CFLAGS
160 WX_CXXFLAGS_ONLY=$WX_CFLAGS
161 else
162 dnl we have CPPFLAGS included in CFLAGS included in CXXFLAGS
163 WX_CPPFLAGS=`$WX_CONFIG_WITH_ARGS --cppflags`
164 WX_CXXFLAGS=`$WX_CONFIG_WITH_ARGS --cxxflags`
165 WX_CFLAGS=`$WX_CONFIG_WITH_ARGS --cflags`
166
167 WX_CFLAGS_ONLY=`echo $WX_CFLAGS | sed "s@^$WX_CPPFLAGS *@@"`
168 WX_CXXFLAGS_ONLY=`echo $WX_CXXFLAGS | sed "s@^$WX_CFLAGS *@@"`
169 fi
170 fi
171
172 if test "x$no_wx" = x ; then
173 AC_MSG_RESULT(yes (version $WX_VERSION))
174 ifelse([$2], , :, [$2])
175 else
176 if test "x$WX_VERSION" = x; then
177 dnl no wx-config at all
178 AC_MSG_RESULT(no)
179 else
180 AC_MSG_RESULT(no (version $WX_VERSION is not new enough))
181 fi
182
183 WX_CFLAGS=""
184 WX_CPPFLAGS=""
185 WX_CXXFLAGS=""
186 WX_LIBS=""
187 WX_LIBS_STATIC=""
188 ifelse([$3], , :, [$3])
189 fi
190 fi
191
192 AC_SUBST(WX_CPPFLAGS)
193 AC_SUBST(WX_CFLAGS)
194 AC_SUBST(WX_CXXFLAGS)
195 AC_SUBST(WX_CFLAGS_ONLY)
196 AC_SUBST(WX_CXXFLAGS_ONLY)
197 AC_SUBST(WX_LIBS)
198 AC_SUBST(WX_LIBS_STATIC)
199 AC_SUBST(WX_VERSION)
200 ])