]> git.saurik.com Git - wxWidgets.git/blob - wxwin.m4
Also redirect wxEVT_KEY_UP and wxEVT_CHAR from the embedded wxTextCtrl
[wxWidgets.git] / wxwin.m4
1 dnl ---------------------------------------------------------------------------
2 dnl Author: wxWidgets development team,
3 dnl Francesco Montorsi,
4 dnl Bob McCown (Mac-testing)
5 dnl Creation date: 24/11/2001
6 dnl RCS-ID: $Id$
7 dnl ---------------------------------------------------------------------------
8
9 dnl ===========================================================================
10 dnl Table of Contents of this macro file:
11 dnl -------------------------------------
12 dnl
13 dnl SECTION A: wxWidgets main macros
14 dnl - WX_CONFIG_OPTIONS
15 dnl - WX_CONFIG_CHECK
16 dnl - WXRC_CHECK
17 dnl - WX_STANDARD_OPTIONS
18 dnl - WX_CONVERT_STANDARD_OPTIONS_TO_WXCONFIG_FLAGS
19 dnl - WX_DETECT_STANDARD_OPTION_VALUES
20 dnl
21 dnl SECTION B: wxWidgets-related utilities
22 dnl - WX_LIKE_LIBNAME
23 dnl - WX_ARG_ENABLE_YESNOAUTO
24 dnl - WX_ARG_WITH_YESNOAUTO
25 dnl
26 dnl SECTION C: messages to the user
27 dnl - WX_STANDARD_OPTIONS_SUMMARY_MSG
28 dnl - WX_STANDARD_OPTIONS_SUMMARY_MSG_BEGIN
29 dnl - WX_STANDARD_OPTIONS_SUMMARY_MSG_END
30 dnl - WX_BOOLOPT_SUMMARY
31 dnl
32 dnl The special "WX_DEBUG_CONFIGURE" variable can be set to 1 to enable extra
33 dnl debug output on stdout from these macros.
34 dnl ===========================================================================
35
36
37 dnl ---------------------------------------------------------------------------
38 dnl Macros for wxWidgets detection. Typically used in configure.in as:
39 dnl
40 dnl AC_ARG_ENABLE(...)
41 dnl AC_ARG_WITH(...)
42 dnl ...
43 dnl WX_CONFIG_OPTIONS
44 dnl ...
45 dnl ...
46 dnl WX_CONFIG_CHECK([2.6.0], [wxWin=1])
47 dnl if test "$wxWin" != 1; then
48 dnl AC_MSG_ERROR([
49 dnl wxWidgets must be installed on your system
50 dnl but wx-config script couldn't be found.
51 dnl
52 dnl Please check that wx-config is in path, the directory
53 dnl where wxWidgets libraries are installed (returned by
54 dnl 'wx-config --libs' command) is in LD_LIBRARY_PATH or
55 dnl equivalent variable and wxWidgets version is 2.3.4 or above.
56 dnl ])
57 dnl fi
58 dnl CPPFLAGS="$CPPFLAGS $WX_CPPFLAGS"
59 dnl CXXFLAGS="$CXXFLAGS $WX_CXXFLAGS_ONLY"
60 dnl CFLAGS="$CFLAGS $WX_CFLAGS_ONLY"
61 dnl
62 dnl LIBS="$LIBS $WX_LIBS"
63 dnl
64 dnl If you want to support standard --enable-debug/unicode/shared options, you
65 dnl may do the following:
66 dnl
67 dnl ...
68 dnl AC_CANONICAL_SYSTEM
69 dnl
70 dnl # define configure options
71 dnl WX_CONFIG_OPTIONS
72 dnl WX_STANDARD_OPTIONS([debug,unicode,shared,toolkit,wxshared])
73 dnl
74 dnl # basic configure checks
75 dnl ...
76 dnl
77 dnl # we want to always have DEBUG==WX_DEBUG and UNICODE==WX_UNICODE
78 dnl WX_DEBUG=$DEBUG
79 dnl WX_UNICODE=$UNICODE
80 dnl
81 dnl WX_CONVERT_STANDARD_OPTIONS_TO_WXCONFIG_FLAGS
82 dnl WX_CONFIG_CHECK([2.8.0], [wxWin=1],,[html,core,net,base],[$WXCONFIG_FLAGS])
83 dnl WX_DETECT_STANDARD_OPTION_VALUES
84 dnl
85 dnl # write the output files
86 dnl AC_CONFIG_FILES([Makefile ...])
87 dnl AC_OUTPUT
88 dnl
89 dnl # optional: just to show a message to the user
90 dnl WX_STANDARD_OPTIONS_SUMMARY_MSG
91 dnl
92 dnl ---------------------------------------------------------------------------
93
94
95 dnl ---------------------------------------------------------------------------
96 dnl WX_CONFIG_OPTIONS
97 dnl
98 dnl adds support for --wx-prefix, --wx-exec-prefix, --with-wxdir and
99 dnl --wx-config command line options
100 dnl ---------------------------------------------------------------------------
101
102 AC_DEFUN([WX_CONFIG_OPTIONS],
103 [
104 AC_ARG_WITH(wxdir,
105 [ --with-wxdir=PATH Use uninstalled version of wxWidgets in PATH],
106 [ wx_config_name="$withval/wx-config"
107 wx_config_args="--inplace"])
108 AC_ARG_WITH(wx-config,
109 [ --with-wx-config=CONFIG wx-config script to use (optional)],
110 wx_config_name="$withval" )
111 AC_ARG_WITH(wx-prefix,
112 [ --with-wx-prefix=PREFIX Prefix where wxWidgets is installed (optional)],
113 wx_config_prefix="$withval", wx_config_prefix="")
114 AC_ARG_WITH(wx-exec-prefix,
115 [ --with-wx-exec-prefix=PREFIX
116 Exec prefix where wxWidgets is installed (optional)],
117 wx_config_exec_prefix="$withval", wx_config_exec_prefix="")
118 ])
119
120 dnl Helper macro for checking if wx version is at least $1.$2.$3, set's
121 dnl wx_ver_ok=yes if it is:
122 AC_DEFUN([_WX_PRIVATE_CHECK_VERSION],
123 [
124 wx_ver_ok=""
125 if test "x$WX_VERSION" != x ; then
126 if test $wx_config_major_version -gt $1; then
127 wx_ver_ok=yes
128 else
129 if test $wx_config_major_version -eq $1; then
130 if test $wx_config_minor_version -gt $2; then
131 wx_ver_ok=yes
132 else
133 if test $wx_config_minor_version -eq $2; then
134 if test $wx_config_micro_version -ge $3; then
135 wx_ver_ok=yes
136 fi
137 fi
138 fi
139 fi
140 fi
141 fi
142 ])
143
144 dnl ---------------------------------------------------------------------------
145 dnl WX_CONFIG_CHECK(VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
146 dnl [, WX-LIBS [, ADDITIONAL-WX-CONFIG-FLAGS]]]])
147 dnl
148 dnl Test for wxWidgets, and define WX_C*FLAGS, WX_LIBS and WX_LIBS_STATIC
149 dnl (the latter is for static linking against wxWidgets). Set WX_CONFIG_NAME
150 dnl environment variable to override the default name of the wx-config script
151 dnl to use. Set WX_CONFIG_PATH to specify the full path to wx-config - in this
152 dnl case the macro won't even waste time on tests for its existence.
153 dnl
154 dnl Optional WX-LIBS argument contains comma- or space-separated list of
155 dnl wxWidgets libraries to link against. If it is not specified then WX_LIBS
156 dnl and WX_LIBS_STATIC will contain flags to link with all of the core
157 dnl wxWidgets libraries.
158 dnl
159 dnl Optional ADDITIONAL-WX-CONFIG-FLAGS argument is appended to wx-config
160 dnl invocation command in present. It can be used to fine-tune lookup of
161 dnl best wxWidgets build available.
162 dnl
163 dnl Example use:
164 dnl WX_CONFIG_CHECK([2.6.0], [wxWin=1], [wxWin=0], [html,core,net]
165 dnl [--unicode --debug])
166 dnl ---------------------------------------------------------------------------
167
168 dnl
169 dnl Get the cflags and libraries from the wx-config script
170 dnl
171 AC_DEFUN([WX_CONFIG_CHECK],
172 [
173 dnl do we have wx-config name: it can be wx-config or wxd-config or ...
174 if test x${WX_CONFIG_NAME+set} != xset ; then
175 WX_CONFIG_NAME=wx-config
176 fi
177
178 if test "x$wx_config_name" != x ; then
179 WX_CONFIG_NAME="$wx_config_name"
180 fi
181
182 dnl deal with optional prefixes
183 if test x$wx_config_exec_prefix != x ; then
184 wx_config_args="$wx_config_args --exec-prefix=$wx_config_exec_prefix"
185 WX_LOOKUP_PATH="$wx_config_exec_prefix/bin"
186 fi
187 if test x$wx_config_prefix != x ; then
188 wx_config_args="$wx_config_args --prefix=$wx_config_prefix"
189 WX_LOOKUP_PATH="$WX_LOOKUP_PATH:$wx_config_prefix/bin"
190 fi
191 if test "$cross_compiling" = "yes"; then
192 wx_config_args="$wx_config_args --host=$host_alias"
193 fi
194
195 dnl don't search the PATH if WX_CONFIG_NAME is absolute filename
196 if test -x "$WX_CONFIG_NAME" ; then
197 AC_MSG_CHECKING(for wx-config)
198 WX_CONFIG_PATH="$WX_CONFIG_NAME"
199 AC_MSG_RESULT($WX_CONFIG_PATH)
200 else
201 AC_PATH_PROG(WX_CONFIG_PATH, $WX_CONFIG_NAME, no, "$WX_LOOKUP_PATH:$PATH")
202 fi
203
204 if test "$WX_CONFIG_PATH" != "no" ; then
205 WX_VERSION=""
206
207 min_wx_version=ifelse([$1], ,2.2.1,$1)
208 if test -z "$5" ; then
209 AC_MSG_CHECKING([for wxWidgets version >= $min_wx_version])
210 else
211 AC_MSG_CHECKING([for wxWidgets version >= $min_wx_version ($5)])
212 fi
213
214 dnl don't add the libraries ($4) to this variable as this would result in
215 dnl an error when it's used with --version below
216 WX_CONFIG_WITH_ARGS="$WX_CONFIG_PATH $wx_config_args $5"
217
218 WX_VERSION=`$WX_CONFIG_WITH_ARGS --version 2>/dev/null`
219 wx_config_major_version=`echo $WX_VERSION | \
220 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
221 wx_config_minor_version=`echo $WX_VERSION | \
222 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
223 wx_config_micro_version=`echo $WX_VERSION | \
224 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
225
226 wx_requested_major_version=`echo $min_wx_version | \
227 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
228 wx_requested_minor_version=`echo $min_wx_version | \
229 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
230 wx_requested_micro_version=`echo $min_wx_version | \
231 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
232
233 _WX_PRIVATE_CHECK_VERSION([$wx_requested_major_version],
234 [$wx_requested_minor_version],
235 [$wx_requested_micro_version])
236
237 if test -n "$wx_ver_ok"; then
238 AC_MSG_RESULT(yes (version $WX_VERSION))
239 WX_LIBS=`$WX_CONFIG_WITH_ARGS --libs $4`
240
241 dnl is this even still appropriate? --static is a real option now
242 dnl and WX_CONFIG_WITH_ARGS is likely to contain it if that is
243 dnl what the user actually wants, making this redundant at best.
244 dnl For now keep it in case anyone actually used it in the past.
245 AC_MSG_CHECKING([for wxWidgets static library])
246 WX_LIBS_STATIC=`$WX_CONFIG_WITH_ARGS --static --libs $4 2>/dev/null`
247 if test "x$WX_LIBS_STATIC" = "x"; then
248 AC_MSG_RESULT(no)
249 else
250 AC_MSG_RESULT(yes)
251 fi
252
253 dnl starting with version 2.2.6 wx-config has --cppflags argument
254 wx_has_cppflags=""
255 if test $wx_config_major_version -gt 2; then
256 wx_has_cppflags=yes
257 else
258 if test $wx_config_major_version -eq 2; then
259 if test $wx_config_minor_version -gt 2; then
260 wx_has_cppflags=yes
261 else
262 if test $wx_config_minor_version -eq 2; then
263 if test $wx_config_micro_version -ge 6; then
264 wx_has_cppflags=yes
265 fi
266 fi
267 fi
268 fi
269 fi
270
271 dnl starting with version 2.7.0 wx-config has --rescomp option
272 wx_has_rescomp=""
273 if test $wx_config_major_version -gt 2; then
274 wx_has_rescomp=yes
275 else
276 if test $wx_config_major_version -eq 2; then
277 if test $wx_config_minor_version -ge 7; then
278 wx_has_rescomp=yes
279 fi
280 fi
281 fi
282 if test "x$wx_has_rescomp" = x ; then
283 dnl cannot give any useful info for resource compiler
284 WX_RESCOMP=
285 else
286 WX_RESCOMP=`$WX_CONFIG_WITH_ARGS --rescomp`
287 fi
288
289 if test "x$wx_has_cppflags" = x ; then
290 dnl no choice but to define all flags like CFLAGS
291 WX_CFLAGS=`$WX_CONFIG_WITH_ARGS --cflags $4`
292 WX_CPPFLAGS=$WX_CFLAGS
293 WX_CXXFLAGS=$WX_CFLAGS
294
295 WX_CFLAGS_ONLY=$WX_CFLAGS
296 WX_CXXFLAGS_ONLY=$WX_CFLAGS
297 else
298 dnl we have CPPFLAGS included in CFLAGS included in CXXFLAGS
299 WX_CPPFLAGS=`$WX_CONFIG_WITH_ARGS --cppflags $4`
300 WX_CXXFLAGS=`$WX_CONFIG_WITH_ARGS --cxxflags $4`
301 WX_CFLAGS=`$WX_CONFIG_WITH_ARGS --cflags $4`
302
303 WX_CFLAGS_ONLY=`echo $WX_CFLAGS | sed "s@^$WX_CPPFLAGS *@@"`
304 WX_CXXFLAGS_ONLY=`echo $WX_CXXFLAGS | sed "s@^$WX_CFLAGS *@@"`
305 fi
306
307 ifelse([$2], , :, [$2])
308
309 else
310
311 if test "x$WX_VERSION" = x; then
312 dnl no wx-config at all
313 AC_MSG_RESULT(no)
314 else
315 AC_MSG_RESULT(no (version $WX_VERSION is not new enough))
316 fi
317
318 WX_CFLAGS=""
319 WX_CPPFLAGS=""
320 WX_CXXFLAGS=""
321 WX_LIBS=""
322 WX_LIBS_STATIC=""
323 WX_RESCOMP=""
324
325 if test ! -z "$5"; then
326
327 wx_error_message="
328 The configuration you asked for $PACKAGE_NAME requires a wxWidgets
329 build with the following settings:
330 $5
331 but such build is not available.
332
333 To see the wxWidgets builds available on this system, please use
334 'wx-config --list' command. To use the default build, returned by
335 'wx-config --selected-config', use the options with their 'auto'
336 default values."
337
338 fi
339
340 wx_error_message="
341 The requested wxWidgets build couldn't be found.
342 $wx_error_message
343
344 If you still get this error, then check that 'wx-config' is
345 in path, the directory where wxWidgets libraries are installed
346 (returned by 'wx-config --libs' command) is in LD_LIBRARY_PATH
347 or equivalent variable and wxWidgets version is $1 or above."
348
349 ifelse([$3], , AC_MSG_ERROR([$wx_error_message]), [$3])
350
351 fi
352 else
353
354 WX_CFLAGS=""
355 WX_CPPFLAGS=""
356 WX_CXXFLAGS=""
357 WX_LIBS=""
358 WX_LIBS_STATIC=""
359 WX_RESCOMP=""
360
361 ifelse([$3], , :, [$3])
362
363 fi
364
365 AC_SUBST(WX_CPPFLAGS)
366 AC_SUBST(WX_CFLAGS)
367 AC_SUBST(WX_CXXFLAGS)
368 AC_SUBST(WX_CFLAGS_ONLY)
369 AC_SUBST(WX_CXXFLAGS_ONLY)
370 AC_SUBST(WX_LIBS)
371 AC_SUBST(WX_LIBS_STATIC)
372 AC_SUBST(WX_VERSION)
373 AC_SUBST(WX_RESCOMP)
374
375 dnl need to export also WX_VERSION_MINOR and WX_VERSION_MAJOR symbols
376 dnl to support wxpresets bakefiles (we export also WX_VERSION_MICRO for completeness):
377 WX_VERSION_MAJOR="$wx_config_major_version"
378 WX_VERSION_MINOR="$wx_config_minor_version"
379 WX_VERSION_MICRO="$wx_config_micro_version"
380 AC_SUBST(WX_VERSION_MAJOR)
381 AC_SUBST(WX_VERSION_MINOR)
382 AC_SUBST(WX_VERSION_MICRO)
383 ])
384
385 dnl ---------------------------------------------------------------------------
386 dnl Get information on the wxrc program for making C++, Python and xrs
387 dnl resource files.
388 dnl
389 dnl AC_ARG_ENABLE(...)
390 dnl AC_ARG_WITH(...)
391 dnl ...
392 dnl WX_CONFIG_OPTIONS
393 dnl ...
394 dnl WX_CONFIG_CHECK(2.6.0, wxWin=1)
395 dnl if test "$wxWin" != 1; then
396 dnl AC_MSG_ERROR([
397 dnl wxWidgets must be installed on your system
398 dnl but wx-config script couldn't be found.
399 dnl
400 dnl Please check that wx-config is in path, the directory
401 dnl where wxWidgets libraries are installed (returned by
402 dnl 'wx-config --libs' command) is in LD_LIBRARY_PATH or
403 dnl equivalent variable and wxWidgets version is 2.6.0 or above.
404 dnl ])
405 dnl fi
406 dnl
407 dnl WXRC_CHECK([HAVE_WXRC=1], [HAVE_WXRC=0])
408 dnl if test "x$HAVE_WXRC" != x1; then
409 dnl AC_MSG_ERROR([
410 dnl The wxrc program was not installed or not found.
411 dnl
412 dnl Please check the wxWidgets installation.
413 dnl ])
414 dnl fi
415 dnl
416 dnl CPPFLAGS="$CPPFLAGS $WX_CPPFLAGS"
417 dnl CXXFLAGS="$CXXFLAGS $WX_CXXFLAGS_ONLY"
418 dnl CFLAGS="$CFLAGS $WX_CFLAGS_ONLY"
419 dnl
420 dnl LDFLAGS="$LDFLAGS $WX_LIBS"
421 dnl ---------------------------------------------------------------------------
422
423 dnl ---------------------------------------------------------------------------
424 dnl WXRC_CHECK([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
425 dnl
426 dnl Test for wxWidgets' wxrc program for creating either C++, Python or XRS
427 dnl resources. The variable WXRC will be set and substituted in the configure
428 dnl script and Makefiles.
429 dnl
430 dnl Example use:
431 dnl WXRC_CHECK([wxrc=1], [wxrc=0])
432 dnl ---------------------------------------------------------------------------
433
434 dnl
435 dnl wxrc program from the wx-config script
436 dnl
437 AC_DEFUN([WXRC_CHECK],
438 [
439 AC_ARG_VAR([WXRC], [Path to wxWidget's wxrc resource compiler])
440
441 if test "x$WX_CONFIG_NAME" = x; then
442 AC_MSG_ERROR([The wxrc tests must run after wxWidgets test.])
443 else
444
445 AC_MSG_CHECKING([for wxrc])
446
447 if test "x$WXRC" = x ; then
448 dnl wx-config --utility is a new addition to wxWidgets:
449 _WX_PRIVATE_CHECK_VERSION(2,5,3)
450 if test -n "$wx_ver_ok"; then
451 WXRC=`$WX_CONFIG_WITH_ARGS --utility=wxrc`
452 fi
453 fi
454
455 if test "x$WXRC" = x ; then
456 AC_MSG_RESULT([not found])
457 ifelse([$2], , :, [$2])
458 else
459 AC_MSG_RESULT([$WXRC])
460 ifelse([$1], , :, [$1])
461 fi
462
463 AC_SUBST(WXRC)
464 fi
465 ])
466
467 dnl ---------------------------------------------------------------------------
468 dnl WX_LIKE_LIBNAME([output-var] [prefix], [name])
469 dnl
470 dnl Sets the "output-var" variable to the name of a library named with same
471 dnl wxWidgets rule.
472 dnl E.g. for output-var=='lib', name=='test', prefix='mine', sets
473 dnl the $lib variable to:
474 dnl 'mine_gtk2ud_test-2.8'
475 dnl if WX_PORT=gtk2, WX_UNICODE=1, WX_DEBUG=1 and WX_RELEASE=28
476 dnl ---------------------------------------------------------------------------
477 AC_DEFUN([WX_LIKE_LIBNAME],
478 [
479 wx_temp="$2""_""$WX_PORT"
480
481 dnl add the [u][d] string
482 if test "$WX_UNICODE" = "1"; then
483 wx_temp="$wx_temp""u"
484 fi
485 if test "$WX_DEBUG" = "1"; then
486 wx_temp="$wx_temp""d"
487 fi
488
489 dnl complete the name of the lib
490 wx_temp="$wx_temp""_""$3""-$WX_VERSION_MAJOR.$WX_VERSION_MINOR"
491
492 dnl save it in the user's variable
493 $1=$wx_temp
494 ])
495
496 dnl ---------------------------------------------------------------------------
497 dnl WX_ARG_ENABLE_YESNOAUTO/WX_ARG_WITH_YESNOAUTO
498 dnl
499 dnl Two little custom macros which define the ENABLE/WITH configure arguments.
500 dnl Macro arguments:
501 dnl $1 = the name of the --enable / --with feature
502 dnl $2 = the name of the variable associated
503 dnl $3 = the description of that feature
504 dnl $4 = the default value for that feature
505 dnl $5 = additional action to do in case option is given with "yes" value
506 dnl ---------------------------------------------------------------------------
507 AC_DEFUN([WX_ARG_ENABLE_YESNOAUTO],
508 [AC_ARG_ENABLE($1,
509 AC_HELP_STRING([--enable-$1], [$3 (default is $4)]),
510 [], [enableval="$4"])
511
512 dnl Show a message to the user about this option
513 AC_MSG_CHECKING([for the --enable-$1 option])
514 if test "$enableval" = "yes" ; then
515 AC_MSG_RESULT([yes])
516 $2=1
517 $5
518 elif test "$enableval" = "no" ; then
519 AC_MSG_RESULT([no])
520 $2=0
521 elif test "$enableval" = "auto" ; then
522 AC_MSG_RESULT([will be automatically detected])
523 $2="auto"
524 else
525 AC_MSG_ERROR([
526 Unrecognized option value (allowed values: yes, no, auto)
527 ])
528 fi
529 ])
530
531 AC_DEFUN([WX_ARG_WITH_YESNOAUTO],
532 [AC_ARG_WITH($1,
533 AC_HELP_STRING([--with-$1], [$3 (default is $4)]),
534 [], [withval="$4"])
535
536 dnl Show a message to the user about this option
537 AC_MSG_CHECKING([for the --with-$1 option])
538 if test "$withval" = "yes" ; then
539 AC_MSG_RESULT([yes])
540 $2=1
541 $5
542 dnl NB: by default we don't allow --with-$1=no option
543 dnl since it does not make much sense !
544 elif test "$6" = "1" -a "$withval" = "no" ; then
545 AC_MSG_RESULT([no])
546 $2=0
547 elif test "$withval" = "auto" ; then
548 AC_MSG_RESULT([will be automatically detected])
549 $2="auto"
550 else
551 AC_MSG_ERROR([
552 Unrecognized option value (allowed values: yes, auto)
553 ])
554 fi
555 ])
556
557
558 dnl ---------------------------------------------------------------------------
559 dnl WX_STANDARD_OPTIONS([options-to-add])
560 dnl
561 dnl Adds to the configure script one or more of the following options:
562 dnl --enable-[debug|unicode|shared|wxshared|wxdebug]
563 dnl --with-[gtk|msw|motif|x11|mac|mgl|dfb]
564 dnl --with-wxversion
565 dnl Then checks for their presence and eventually set the DEBUG, UNICODE, SHARED,
566 dnl PORT, WX_SHARED, WX_DEBUG, variables to one of the "yes", "no", "auto" values.
567 dnl
568 dnl Note that e.g. UNICODE != WX_UNICODE; the first is the value of the
569 dnl --enable-unicode option (in boolean format) while the second indicates
570 dnl if wxWidgets was built in Unicode mode (and still is in boolean format).
571 dnl ---------------------------------------------------------------------------
572 AC_DEFUN([WX_STANDARD_OPTIONS],
573 [
574
575 dnl the following lines will expand to WX_ARG_ENABLE_YESNOAUTO calls if and only if
576 dnl the $1 argument contains respectively the debug,unicode or shared options.
577
578 dnl be careful here not to set debug flag if only "wxdebug" was specified
579 ifelse(regexp([$1], [\bdebug]), [-1],,
580 [WX_ARG_ENABLE_YESNOAUTO([debug], [DEBUG], [Build in debug mode], [auto])])
581
582 ifelse(index([$1], [unicode]), [-1],,
583 [WX_ARG_ENABLE_YESNOAUTO([unicode], [UNICODE], [Build in Unicode mode], [auto])])
584
585 ifelse(regexp([$1], [\bshared]), [-1],,
586 [WX_ARG_ENABLE_YESNOAUTO([shared], [SHARED], [Build as shared library], [auto])])
587
588 dnl WX_ARG_WITH_YESNOAUTO cannot be used for --with-toolkit since it's an option
589 dnl which must be able to accept the auto|gtk1|gtk2|msw|... values
590 ifelse(index([$1], [toolkit]), [-1],,
591 [
592 AC_ARG_WITH([toolkit],
593 AC_HELP_STRING([--with-toolkit],
594 [Build against a specific wxWidgets toolkit (default is auto)]),
595 [], [withval="auto"])
596
597 dnl Show a message to the user about this option
598 AC_MSG_CHECKING([for the --with-toolkit option])
599 if test "$withval" = "auto" ; then
600 AC_MSG_RESULT([will be automatically detected])
601 TOOLKIT="auto"
602 else
603 TOOLKIT="$withval"
604
605 dnl PORT must be one of the allowed values
606 if test "$TOOLKIT" != "gtk1" -a "$TOOLKIT" != "gtk2" -a \
607 "$TOOLKIT" != "msw" -a "$TOOLKIT" != "motif" -a \
608 "$TOOLKIT" != "x11" -a "$TOOLKIT" != "mac" -a \
609 "$TOOLKIT" != "mgl" -a "$TOOLKIT" != "dfb" ; then
610 AC_MSG_ERROR([
611 Unrecognized option value (allowed values: auto, gtk1, gtk2, msw, motif, x11, mac, mgl, dfb)
612 ])
613 fi
614
615 AC_MSG_RESULT([$TOOLKIT])
616 fi
617 ])
618
619 dnl ****** IMPORTANT *******
620 dnl Unlike for the UNICODE setting, you can build your program in
621 dnl shared mode against a static build of wxWidgets. Thus we have the
622 dnl following option which allows these mixtures. E.g.
623 dnl
624 dnl ./configure --disable-shared --with-wxshared
625 dnl
626 dnl will build your library in static mode against the first available
627 dnl shared build of wxWidgets.
628 dnl
629 dnl Note that's not possible to do the viceversa:
630 dnl
631 dnl ./configure --enable-shared --without-wxshared
632 dnl
633 dnl Doing so you would try to build your library in shared mode against a static
634 dnl build of wxWidgets. This is not possible (you would mix PIC and non PIC code) !
635 dnl A check for this combination of options is in WX_DETECT_STANDARD_OPTION_VALUES
636 dnl (where we know what 'auto' should be expanded to).
637 dnl
638 dnl If you try to build something in ANSI mode against a UNICODE build
639 dnl of wxWidgets or in RELEASE mode against a DEBUG build of wxWidgets,
640 dnl then at best you'll get ton of linking errors !
641 dnl ************************
642
643 ifelse(index([$1], [wxshared]), [-1],,
644 [
645 WX_ARG_WITH_YESNOAUTO(
646 [wxshared], [WX_SHARED],
647 [Force building against a shared build of wxWidgets, even if --disable-shared is given],
648 [auto], [], [1])
649 ])
650
651 dnl Just like for SHARED and WX_SHARED it may happen that some adventurous
652 dnl peoples will want to mix a wxWidgets release build with a debug build of
653 dnl his app/lib. So, we have both DEBUG and WX_DEBUG variables.
654 ifelse(index([$1], [wxdebug]), [-1],,
655 [
656 WX_ARG_WITH_YESNOAUTO(
657 [wxdebug], [WX_DEBUG],
658 [Force building against a debug build of wxWidgets, even if --disable-debug is given],
659 [auto], [], [1])
660 ])
661
662 dnl WX_ARG_WITH_YESNOAUTO cannot be used for --with-wxversion since it's an option
663 dnl which accepts the "auto|2.6|2.7|2.8|2.9|3.0" etc etc values
664 ifelse(index([$1], [wxversion]), [-1],,
665 [
666 AC_ARG_WITH([wxversion],
667 AC_HELP_STRING([--with-wxversion],
668 [Build against a specific version of wxWidgets (default is auto)]),
669 [], [withval="auto"])
670
671 dnl Show a message to the user about this option
672 AC_MSG_CHECKING([for the --with-wxversion option])
673 if test "$withval" = "auto" ; then
674 AC_MSG_RESULT([will be automatically detected])
675 WX_RELEASE="auto"
676 else
677
678 wx_requested_major_version=`echo $withval | \
679 sed 's/\([[0-9]]*\).\([[0-9]]*\).*/\1/'`
680 wx_requested_minor_version=`echo $withval | \
681 sed 's/\([[0-9]]*\).\([[0-9]]*\).*/\2/'`
682
683 dnl both vars above must be exactly 1 digit
684 if test "${#wx_requested_major_version}" != "1" -o \
685 "${#wx_requested_minor_version}" != "1" ; then
686 AC_MSG_ERROR([
687 Unrecognized option value (allowed values: auto, 2.6, 2.7, 2.8, 2.9, 3.0)
688 ])
689 fi
690
691 WX_RELEASE="$wx_requested_major_version"".""$wx_requested_minor_version"
692 AC_MSG_RESULT([$WX_RELEASE])
693 fi
694 ])
695
696 if test "$WX_DEBUG_CONFIGURE" = "1"; then
697 echo "[[dbg]] DEBUG: $DEBUG, WX_DEBUG: $WX_DEBUG"
698 echo "[[dbg]] UNICODE: $UNICODE, WX_UNICODE: $WX_UNICODE"
699 echo "[[dbg]] SHARED: $SHARED, WX_SHARED: $WX_SHARED"
700 echo "[[dbg]] TOOLKIT: $TOOLKIT, WX_TOOLKIT: $WX_TOOLKIT"
701 echo "[[dbg]] VERSION: $VERSION, WX_RELEASE: $WX_RELEASE"
702 fi
703 ])
704
705
706 dnl ---------------------------------------------------------------------------
707 dnl WX_CONVERT_STANDARD_OPTIONS_TO_WXCONFIG_FLAGS
708 dnl
709 dnl Sets the WXCONFIG_FLAGS string using the SHARED,DEBUG,UNICODE variable values
710 dnl which are different from "auto".
711 dnl Thus this macro needs to be called only once all options have been set.
712 dnl ---------------------------------------------------------------------------
713 AC_DEFUN([WX_CONVERT_STANDARD_OPTIONS_TO_WXCONFIG_FLAGS],
714 [
715 if test "$WX_SHARED" = "1" ; then
716 WXCONFIG_FLAGS="--static=no "
717 elif test "$WX_SHARED" = "0" ; then
718 WXCONFIG_FLAGS="--static=yes "
719 fi
720
721 if test "$WX_DEBUG" = "1" ; then
722 WXCONFIG_FLAGS="$WXCONFIG_FLAGS""--debug=yes "
723 elif test "$WX_DEBUG" = "0" ; then
724 WXCONFIG_FLAGS="$WXCONFIG_FLAGS""--debug=no "
725 fi
726
727 dnl The user should have set WX_UNICODE=UNICODE
728 if test "$WX_UNICODE" = "1" ; then
729 WXCONFIG_FLAGS="$WXCONFIG_FLAGS""--unicode=yes "
730 elif test "$WX_UNICODE" = "0" ; then
731 WXCONFIG_FLAGS="$WXCONFIG_FLAGS""--unicode=no "
732 fi
733
734 if test "$TOOLKIT" != "auto" ; then
735 WXCONFIG_FLAGS="$WXCONFIG_FLAGS""--toolkit=$TOOLKIT "
736 fi
737
738 if test "$WX_RELEASE" != "auto" ; then
739 WXCONFIG_FLAGS="$WXCONFIG_FLAGS""--version=$WX_RELEASE "
740 fi
741
742 dnl strip out the last space of the string
743 WXCONFIG_FLAGS=${WXCONFIG_FLAGS% }
744
745 if test "$WX_DEBUG_CONFIGURE" = "1"; then
746 echo "[[dbg]] WXCONFIG_FLAGS: $WXCONFIG_FLAGS"
747 fi
748 ])
749
750
751 dnl ---------------------------------------------------------------------------
752 dnl _WX_SELECTEDCONFIG_CHECKFOR([RESULTVAR], [STRING], [MSG]
753 dnl [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
754 dnl
755 dnl Outputs the given MSG. Then searches the given STRING in the wxWidgets
756 dnl additional CPP flags and put the result of the search in WX_$RESULTVAR
757 dnl also adding the "yes" or "no" message result to MSG.
758 dnl ---------------------------------------------------------------------------
759 AC_DEFUN([_WX_SELECTEDCONFIG_CHECKFOR],
760 [
761 if test "$$1" = "auto" ; then
762
763 dnl The user does not have particular preferences for this option;
764 dnl so we will detect the wxWidgets relative build setting and use it
765 AC_MSG_CHECKING([$3])
766
767 dnl set WX_$1 variable to 1 if the $WX_SELECTEDCONFIG contains the $2
768 dnl string or to 0 otherwise.
769 dnl NOTE: 'expr match STRING REGEXP' cannot be used since on Mac it
770 dnl doesn't work; we use 'expr STRING : REGEXP' instead
771 WX_$1=$(expr "$WX_SELECTEDCONFIG" : ".*$2.*")
772
773 if test "$WX_$1" != "0"; then
774 WX_$1=1
775 AC_MSG_RESULT([yes])
776 ifelse([$4], , :, [$4])
777 else
778 WX_$1=0
779 AC_MSG_RESULT([no])
780 ifelse([$5], , :, [$5])
781 fi
782 else
783
784 dnl Use the setting given by the user
785 WX_$1=$$1
786 fi
787 ])
788
789 dnl ---------------------------------------------------------------------------
790 dnl WX_DETECT_STANDARD_OPTION_VALUES
791 dnl
792 dnl Detects the values of the following variables:
793 dnl 1) WX_RELEASE
794 dnl 2) WX_UNICODE
795 dnl 3) WX_DEBUG
796 dnl 4) WX_SHARED (and also WX_STATIC)
797 dnl 5) WX_PORT
798 dnl from the previously selected wxWidgets build; this macro in fact must be
799 dnl called *after* calling the WX_CONFIG_CHECK macro.
800 dnl
801 dnl Note that the WX_VERSION_MAJOR, WX_VERSION_MINOR symbols are already set
802 dnl by WX_CONFIG_CHECK macro
803 dnl ---------------------------------------------------------------------------
804 AC_DEFUN([WX_DETECT_STANDARD_OPTION_VALUES],
805 [
806 dnl IMPORTANT: WX_VERSION contains all three major.minor.micro digits,
807 dnl while WX_RELEASE only the major.minor ones.
808 WX_RELEASE="$WX_VERSION_MAJOR""$WX_VERSION_MINOR"
809 if test $WX_RELEASE -lt 26 ; then
810
811 AC_MSG_ERROR([
812 Cannot detect the wxWidgets configuration for the selected wxWidgets build
813 since its version is $WX_VERSION < 2.6.0; please install a newer
814 version of wxWidgets.
815 ])
816 fi
817
818 dnl The wx-config we are using understands the "--selected_config"
819 dnl option which returns an easy-parseable string !
820 WX_SELECTEDCONFIG=$($WX_CONFIG_WITH_ARGS --selected_config)
821
822 if test "$WX_DEBUG_CONFIGURE" = "1"; then
823 echo "[[dbg]] Using wx-config --selected-config"
824 echo "[[dbg]] WX_SELECTEDCONFIG: $WX_SELECTEDCONFIG"
825 fi
826
827
828 dnl we could test directly for WX_SHARED with a line like:
829 dnl _WX_SELECTEDCONFIG_CHECKFOR([SHARED], [shared],
830 dnl [if wxWidgets was built in SHARED mode])
831 dnl but wx-config --selected-config DOES NOT outputs the 'shared'
832 dnl word when wx was built in shared mode; it rather outputs the
833 dnl 'static' word when built in static mode.
834 if test $WX_SHARED = "1"; then
835 STATIC=0
836 elif test $WX_SHARED = "0"; then
837 STATIC=1
838 elif test $WX_SHARED = "auto"; then
839 STATIC="auto"
840 fi
841
842 dnl Now set the WX_UNICODE, WX_DEBUG, WX_STATIC variables
843 _WX_SELECTEDCONFIG_CHECKFOR([UNICODE], [unicode],
844 [if wxWidgets was built with UNICODE enabled])
845 _WX_SELECTEDCONFIG_CHECKFOR([DEBUG], [debug],
846 [if wxWidgets was built in DEBUG mode])
847 _WX_SELECTEDCONFIG_CHECKFOR([STATIC], [static],
848 [if wxWidgets was built in STATIC mode])
849
850 dnl init WX_SHARED from WX_STATIC
851 if test "$WX_STATIC" != "0"; then
852 WX_SHARED=0
853 else
854 WX_SHARED=1
855 fi
856
857 AC_SUBST(WX_UNICODE)
858 AC_SUBST(WX_DEBUG)
859 AC_SUBST(WX_SHARED)
860
861 dnl detect the WX_PORT to use
862 if test "$TOOLKIT" = "auto" ; then
863
864 dnl The user does not have particular preferences for this option;
865 dnl so we will detect the wxWidgets relative build setting and use it
866 AC_MSG_CHECKING([which wxWidgets toolkit was selected])
867
868 WX_GTKPORT1=$(expr "$WX_SELECTEDCONFIG" : ".*gtk1.*")
869 WX_GTKPORT2=$(expr "$WX_SELECTEDCONFIG" : ".*gtk2.*")
870 WX_MSWPORT=$(expr "$WX_SELECTEDCONFIG" : ".*msw.*")
871 WX_MOTIFPORT=$(expr "$WX_SELECTEDCONFIG" : ".*motif.*")
872 WX_MACPORT=$(expr "$WX_SELECTEDCONFIG" : ".*mac.*")
873 WX_X11PORT=$(expr "$WX_SELECTEDCONFIG" : ".*x11.*")
874 WX_MGLPORT=$(expr "$WX_SELECTEDCONFIG" : ".*mgl.*")
875 WX_DFBPORT=$(expr "$WX_SELECTEDCONFIG" : ".*dfb.*")
876
877 WX_PORT="unknown"
878 if test "$WX_GTKPORT1" != "0"; then WX_PORT="gtk1"; fi
879 if test "$WX_GTKPORT2" != "0"; then WX_PORT="gtk2"; fi
880 if test "$WX_MSWPORT" != "0"; then WX_PORT="msw"; fi
881 if test "$WX_MOTIFPORT" != "0"; then WX_PORT="motif"; fi
882 if test "$WX_MACPORT" != "0"; then WX_PORT="mac"; fi
883 if test "$WX_X11PORT" != "0"; then WX_PORT="x11"; fi
884 if test "$WX_MGLPORT" != "0"; then WX_PORT="mgl"; fi
885 if test "$WX_DFBPORT" != "0"; then WX_PORT="dfb"; fi
886
887 dnl check at least one of the WX_*PORT has been set !
888
889 if test "$WX_PORT" = "unknown" ; then
890 AC_MSG_ERROR([
891 Cannot detect the currently installed wxWidgets port !
892 Please check your 'wx-config --cxxflags'...
893 ])
894 fi
895
896 AC_MSG_RESULT([$WX_PORT])
897 else
898
899 dnl Use the setting given by the user
900 if test -z "$TOOLKIT" ; then
901 WX_PORT=$TOOLKIT
902 else
903 dnl try with PORT
904 WX_PORT=$PORT
905 fi
906 fi
907
908 AC_SUBST(WX_PORT)
909
910 if test "$WX_DEBUG_CONFIGURE" = "1"; then
911 echo "[[dbg]] Values of all WX_* options after final detection:"
912 echo "[[dbg]] WX_DEBUG: $WX_DEBUG"
913 echo "[[dbg]] WX_UNICODE: $WX_UNICODE"
914 echo "[[dbg]] WX_SHARED: $WX_SHARED"
915 echo "[[dbg]] WX_RELEASE: $WX_RELEASE"
916 echo "[[dbg]] WX_PORT: $WX_PORT"
917 fi
918
919 dnl Avoid problem described in the WX_STANDARD_OPTIONS which happens when
920 dnl the user gives the options:
921 dnl ./configure --enable-shared --without-wxshared
922 dnl or just do
923 dnl ./configure --enable-shared
924 dnl but there is only a static build of wxWidgets available.
925 if test "$WX_SHARED" = "0" -a "$SHARED" = "1"; then
926 AC_MSG_ERROR([
927 Cannot build shared library against a static build of wxWidgets !
928 This error happens because the wxWidgets build which was selected
929 has been detected as static while you asked to build $PACKAGE_NAME
930 as shared library and this is not possible.
931 Use the '--disable-shared' option to build $PACKAGE_NAME
932 as static library or '--with-wxshared' to use wxWidgets as shared library.
933 ])
934 fi
935
936 dnl now we can finally update the DEBUG,UNICODE,SHARED options
937 dnl to their final values if they were set to 'auto'
938 if test "$DEBUG" = "auto"; then
939 DEBUG=$WX_DEBUG
940 fi
941 if test "$UNICODE" = "auto"; then
942 UNICODE=$WX_UNICODE
943 fi
944 if test "$SHARED" = "auto"; then
945 SHARED=$WX_SHARED
946 fi
947 if test "$TOOLKIT" = "auto"; then
948 TOOLKIT=$WX_PORT
949 fi
950
951 dnl in case the user needs a BUILD=debug/release var...
952 if test "$DEBUG" = "1"; then
953 BUILD="debug"
954 elif test "$DEBUG" = "0" -o "$DEBUG" = ""; then
955 BUILD="release"
956 fi
957
958 dnl respect the DEBUG variable adding the optimize/debug flags
959 dnl NOTE: the CXXFLAGS are merged together with the CPPFLAGS so we
960 dnl don't need to set them, too
961 if test "$DEBUG" = "1"; then
962 CXXFLAGS="$CXXFLAGS -g -O0"
963 CFLAGS="$CFLAGS -g -O0"
964 else
965 CXXFLAGS="$CXXFLAGS -O2"
966 CFLAGS="$CFLAGS -O2"
967 fi
968 ])
969
970 dnl ---------------------------------------------------------------------------
971 dnl WX_BOOLOPT_SUMMARY([name of the boolean variable to show summary for],
972 dnl [what to print when var is 1],
973 dnl [what to print when var is 0])
974 dnl
975 dnl Prints $2 when variable $1 == 1 and prints $3 when variable $1 == 0.
976 dnl This macro mainly exists just to make configure.ac scripts more readable.
977 dnl
978 dnl NOTE: you need to use the [" my message"] syntax for 2nd and 3rd arguments
979 dnl if you want that m4 avoid to throw away the spaces prefixed to the
980 dnl argument value.
981 dnl ---------------------------------------------------------------------------
982 AC_DEFUN([WX_BOOLOPT_SUMMARY],
983 [
984 if test "x$$1" = "x1" ; then
985 echo $2
986 elif test "x$$1" = "x0" ; then
987 echo $3
988 else
989 echo "$1 is $$1"
990 fi
991 ])
992
993 dnl ---------------------------------------------------------------------------
994 dnl WX_STANDARD_OPTIONS_SUMMARY_MSG
995 dnl
996 dnl Shows a summary message to the user about the WX_* variable contents.
997 dnl This macro is used typically at the end of the configure script.
998 dnl ---------------------------------------------------------------------------
999 AC_DEFUN([WX_STANDARD_OPTIONS_SUMMARY_MSG],
1000 [
1001 echo
1002 echo " The wxWidgets build which will be used by $PACKAGE_NAME $PACKAGE_VERSION"
1003 echo " has the following settings:"
1004 WX_BOOLOPT_SUMMARY([WX_DEBUG], [" - DEBUG build"], [" - RELEASE build"])
1005 WX_BOOLOPT_SUMMARY([WX_UNICODE], [" - UNICODE mode"], [" - ANSI mode"])
1006 WX_BOOLOPT_SUMMARY([WX_SHARED], [" - SHARED mode"], [" - STATIC mode"])
1007 echo " - VERSION: $WX_VERSION"
1008 echo " - PORT: $WX_PORT"
1009 ])
1010
1011
1012 dnl ---------------------------------------------------------------------------
1013 dnl WX_STANDARD_OPTIONS_SUMMARY_MSG_BEGIN, WX_STANDARD_OPTIONS_SUMMARY_MSG_END
1014 dnl
1015 dnl Like WX_STANDARD_OPTIONS_SUMMARY_MSG macro but these two macros also gives info
1016 dnl about the configuration of the package which used the wxpresets.
1017 dnl
1018 dnl Typical usage:
1019 dnl WX_STANDARD_OPTIONS_SUMMARY_MSG_BEGIN
1020 dnl echo " - Package setting 1: $SETTING1"
1021 dnl echo " - Package setting 2: $SETTING1"
1022 dnl ...
1023 dnl WX_STANDARD_OPTIONS_SUMMARY_MSG_END
1024 dnl
1025 dnl ---------------------------------------------------------------------------
1026 AC_DEFUN([WX_STANDARD_OPTIONS_SUMMARY_MSG_BEGIN],
1027 [
1028 echo
1029 echo " ----------------------------------------------------------------"
1030 echo " Configuration for $PACKAGE_NAME $PACKAGE_VERSION successfully completed."
1031 echo " Summary of main configuration settings for $PACKAGE_NAME:"
1032 WX_BOOLOPT_SUMMARY([DEBUG], [" - DEBUG build"], [" - RELEASE build"])
1033 WX_BOOLOPT_SUMMARY([UNICODE], [" - UNICODE mode"], [" - ANSI mode"])
1034 WX_BOOLOPT_SUMMARY([SHARED], [" - SHARED mode"], [" - STATIC mode"])
1035 ])
1036
1037 AC_DEFUN([WX_STANDARD_OPTIONS_SUMMARY_MSG_END],
1038 [
1039 WX_STANDARD_OPTIONS_SUMMARY_MSG
1040 echo
1041 echo " Now, just run make."
1042 echo " ----------------------------------------------------------------"
1043 echo
1044 ])
1045
1046
1047 dnl ---------------------------------------------------------------------------
1048 dnl Deprecated macro wrappers
1049 dnl ---------------------------------------------------------------------------
1050
1051 AC_DEFUN([AM_OPTIONS_WXCONFIG], [WX_CONFIG_OPTIONS])
1052 AC_DEFUN([AM_PATH_WXCONFIG], [
1053 WX_CONFIG_CHECK([$1],[$2],[$3],[$4],[$5])
1054 ])
1055
1056