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: wxwin.m4 9815 2009-09-20 01:09:03Z gonosztopi $
7 dnl ---------------------------------------------------------------------------
9 dnl ===========================================================================
10 dnl Table of Contents of this macro file:
11 dnl -------------------------------------
13 dnl SECTION A: wxWidgets main macros
14 dnl - WX_CONFIG_OPTIONS
17 dnl - WX_STANDARD_OPTIONS
18 dnl - WX_CONVERT_STANDARD_OPTIONS_TO_WXCONFIG_FLAGS
19 dnl - WX_DETECT_STANDARD_OPTION_VALUES
21 dnl SECTION B: wxWidgets-related utilities
23 dnl - WX_ARG_ENABLE_YESNOAUTO
24 dnl - WX_ARG_WITH_YESNOAUTO
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
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 ===========================================================================
37 dnl ---------------------------------------------------------------------------
38 dnl Macros for wxWidgets detection. Typically used in configure.in as:
40 dnl AC_ARG_ENABLE(...)
46 dnl WX_CONFIG_CHECK([2.6.0], [wxWin=1])
47 dnl if test "$wxWin" != 1; then
49 dnl wxWidgets must be installed on your system
50 dnl but wx-config script couldn't be found.
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.
58 dnl CPPFLAGS="$CPPFLAGS $WX_CPPFLAGS"
59 dnl CXXFLAGS="$CXXFLAGS $WX_CXXFLAGS_ONLY"
60 dnl CFLAGS="$CFLAGS $WX_CFLAGS_ONLY"
62 dnl LIBS="$LIBS $WX_LIBS"
64 dnl If you want to support standard --enable-debug/unicode/shared options, you
65 dnl may do the following:
68 dnl AC_CANONICAL_SYSTEM
70 dnl # define configure options
72 dnl WX_STANDARD_OPTIONS([debug,unicode,shared,toolkit,wxshared])
74 dnl # basic configure checks
77 dnl # we want to always have DEBUG==WX_DEBUG and UNICODE==WX_UNICODE
79 dnl WX_UNICODE=$UNICODE
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
85 dnl # write the output files
86 dnl AC_CONFIG_FILES([Makefile ...])
89 dnl # optional: just to show a message to the user
90 dnl WX_STANDARD_OPTIONS_SUMMARY_MSG
92 dnl ---------------------------------------------------------------------------
95 dnl ---------------------------------------------------------------------------
98 dnl adds support for --wx-prefix, --wx-exec-prefix, --with-wxdir and
99 dnl --wx-config command line options
100 dnl ---------------------------------------------------------------------------
102 AC_DEFUN([WX_CONFIG_OPTIONS],
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="")
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],
125 if test "x$WX_VERSION_FULL" != x ; then
126 if test $wx_config_major_version -gt $1; then
129 if test $wx_config_major_version -eq $1; then
130 if test $wx_config_minor_version -gt $2; then
133 if test $wx_config_minor_version -eq $2; then
134 if test $wx_config_micro_version -ge $3; then
144 dnl ---------------------------------------------------------------------------
145 dnl WX_CONFIG_CHECK(VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
146 dnl [, WX-LIBS [, ADDITIONAL-WX-CONFIG-FLAGS]]]])
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.
154 dnl Optional WX-LIBS argument contains comma- or space-separated list of
155 dnl wxWidgets libraries to link against (it may include contrib libraries). If
156 dnl it is not specified then WX_LIBS and WX_LIBS_STATIC will contain flags to
157 dnl link with all of the core wxWidgets libraries.
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.
164 dnl WX_CONFIG_CHECK([2.6.0], [wxWin=1], [wxWin=0], [html,core,net]
165 dnl [--unicode --debug])
166 dnl ---------------------------------------------------------------------------
169 dnl Get the cflags and libraries from the wx-config script
171 AC_DEFUN([WX_CONFIG_CHECK],
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
178 if test "x$wx_config_name" != x ; then
179 WX_CONFIG_NAME="$wx_config_name"
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"
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"
191 if test "$cross_compiling" = "yes"; then
192 wx_config_args="$wx_config_args --host=$host_alias"
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)
201 AC_PATH_PROG(WX_CONFIG_PATH, $WX_CONFIG_NAME, no, "$WX_LOOKUP_PATH:$PATH")
204 if test "$WX_CONFIG_PATH" != "no" ; then
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])
211 AC_MSG_CHECKING([for wxWidgets version >= $min_wx_version ($5)])
214 WX_CONFIG_WITH_ARGS="$WX_CONFIG_PATH $wx_config_args $5 $4"
216 WX_VERSION_FULL=`$WX_CONFIG_WITH_ARGS --version 2>/dev/null`
217 wx_config_major_version=`echo $WX_VERSION_FULL | \
218 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
219 wx_config_minor_version=`echo $WX_VERSION_FULL | \
220 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
221 wx_config_micro_version=`echo $WX_VERSION_FULL | \
222 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
224 wx_requested_major_version=`echo $min_wx_version | \
225 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
226 wx_requested_minor_version=`echo $min_wx_version | \
227 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
228 wx_requested_micro_version=`echo $min_wx_version | \
229 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
231 _WX_PRIVATE_CHECK_VERSION([$wx_requested_major_version],
232 [$wx_requested_minor_version],
233 [$wx_requested_micro_version])
235 if test -n "$wx_ver_ok"; then
237 AC_MSG_RESULT(yes (version $WX_VERSION_FULL))
238 WX_LIBS=`$WX_CONFIG_WITH_ARGS --libs`
240 dnl is this even still appropriate? --static is a real option now
241 dnl and WX_CONFIG_WITH_ARGS is likely to contain it if that is
242 dnl what the user actually wants, making this redundant at best.
243 dnl For now keep it in case anyone actually used it in the past.
244 AC_MSG_CHECKING([for wxWidgets static library])
245 WX_LIBS_STATIC=`$WX_CONFIG_WITH_ARGS --static --libs 2>/dev/null`
246 if test "x$WX_LIBS_STATIC" = "x"; then
252 dnl starting with version 2.2.6 wx-config has --cppflags argument
254 if test $wx_config_major_version -gt 2; then
257 if test $wx_config_major_version -eq 2; then
258 if test $wx_config_minor_version -gt 2; then
261 if test $wx_config_minor_version -eq 2; then
262 if test $wx_config_micro_version -ge 6; then
270 dnl starting with version 2.7.0 wx-config has --rescomp option
272 if test $wx_config_major_version -gt 2; then
275 if test $wx_config_major_version -eq 2; then
276 if test $wx_config_minor_version -ge 7; then
281 if test "x$wx_has_rescomp" = x ; then
282 dnl cannot give any useful info for resource compiler
285 WX_RESCOMP=`$WX_CONFIG_WITH_ARGS --rescomp`
288 if test "x$wx_has_cppflags" = x ; then
289 dnl no choice but to define all flags like CFLAGS
290 WX_CFLAGS=`$WX_CONFIG_WITH_ARGS --cflags`
291 WX_CPPFLAGS=$WX_CFLAGS
292 WX_CXXFLAGS=$WX_CFLAGS
294 WX_CFLAGS_ONLY=$WX_CFLAGS
295 WX_CXXFLAGS_ONLY=$WX_CFLAGS
297 dnl we have CPPFLAGS included in CFLAGS included in CXXFLAGS
298 WX_CPPFLAGS=`$WX_CONFIG_WITH_ARGS --cppflags`
299 WX_CXXFLAGS=`$WX_CONFIG_WITH_ARGS --cxxflags`
300 WX_CFLAGS=`$WX_CONFIG_WITH_ARGS --cflags`
302 WX_CFLAGS_ONLY=`echo $WX_CFLAGS | sed "s@^$WX_CPPFLAGS *@@"`
303 WX_CXXFLAGS_ONLY=`echo $WX_CXXFLAGS | sed "s@^$WX_CFLAGS *@@"`
306 ifelse([$2], , :, [$2])
310 if test "x$WX_VERSION_FULL" = x; then
311 dnl no wx-config at all
314 AC_MSG_RESULT(no (version $WX_VERSION_FULL is not new enough))
324 if test ! -z "$5"; then
327 The configuration you asked for $PACKAGE_NAME requires a wxWidgets
328 build with the following settings:
330 but such build is not available.
332 To see the wxWidgets builds available on this system, please use
333 'wx-config --list' command. To use the default build, returned by
334 'wx-config --selected-config', use the options with their 'auto'
340 The requested wxWidgets build couldn't be found.
343 If you still get this error, then check that 'wx-config' is
344 in path, the directory where wxWidgets libraries are installed
345 (returned by 'wx-config --libs' command) is in LD_LIBRARY_PATH
346 or equivalent variable and wxWidgets version is $1 or above."
348 ifelse([$3], , AC_MSG_ERROR([$wx_error_message]), [$3])
360 ifelse([$3], , :, [$3])
364 AC_SUBST(WX_CPPFLAGS)
366 AC_SUBST(WX_CXXFLAGS)
367 AC_SUBST(WX_CFLAGS_ONLY)
368 AC_SUBST(WX_CXXFLAGS_ONLY)
370 AC_SUBST(WX_LIBS_STATIC)
371 AC_SUBST(WX_VERSION_FULL)
374 dnl need to export also WX_VERSION_MINOR and WX_VERSION_MAJOR symbols
375 dnl to support wxpresets bakefiles
376 WX_VERSION_MAJOR="$wx_config_major_version"
377 WX_VERSION_MINOR="$wx_config_minor_version"
378 AC_SUBST(WX_VERSION_MAJOR)
379 AC_SUBST(WX_VERSION_MINOR)
382 dnl ---------------------------------------------------------------------------
383 dnl Get information on the wxrc program for making C++, Python and xrs
386 dnl AC_ARG_ENABLE(...)
389 dnl WX_CONFIG_OPTIONS
391 dnl WX_CONFIG_CHECK(2.6.0, wxWin=1)
392 dnl if test "$wxWin" != 1; then
394 dnl wxWidgets must be installed on your system
395 dnl but wx-config script couldn't be found.
397 dnl Please check that wx-config is in path, the directory
398 dnl where wxWidgets libraries are installed (returned by
399 dnl 'wx-config --libs' command) is in LD_LIBRARY_PATH or
400 dnl equivalent variable and wxWidgets version is 2.6.0 or above.
404 dnl WXRC_CHECK([HAVE_WXRC=1], [HAVE_WXRC=0])
405 dnl if test "x$HAVE_WXRC" != x1; then
407 dnl The wxrc program was not installed or not found.
409 dnl Please check the wxWidgets installation.
413 dnl CPPFLAGS="$CPPFLAGS $WX_CPPFLAGS"
414 dnl CXXFLAGS="$CXXFLAGS $WX_CXXFLAGS_ONLY"
415 dnl CFLAGS="$CFLAGS $WX_CFLAGS_ONLY"
417 dnl LDFLAGS="$LDFLAGS $WX_LIBS"
418 dnl ---------------------------------------------------------------------------
420 dnl ---------------------------------------------------------------------------
421 dnl WXRC_CHECK([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
423 dnl Test for wxWidgets' wxrc program for creating either C++, Python or XRS
424 dnl resources. The variable WXRC will be set and substituted in the configure
425 dnl script and Makefiles.
428 dnl WXRC_CHECK([wxrc=1], [wxrc=0])
429 dnl ---------------------------------------------------------------------------
432 dnl wxrc program from the wx-config script
434 AC_DEFUN([WXRC_CHECK],
436 AC_ARG_VAR([WXRC], [Path to wxWidget's wxrc resource compiler])
438 if test "x$WX_CONFIG_NAME" = x; then
439 AC_MSG_ERROR([The wxrc tests must run after wxWidgets test.])
442 AC_MSG_CHECKING([for wxrc])
444 if test "x$WXRC" = x ; then
445 dnl wx-config --utility is a new addition to wxWidgets:
446 _WX_PRIVATE_CHECK_VERSION(2,5,3)
447 if test -n "$wx_ver_ok"; then
448 WXRC=`$WX_CONFIG_WITH_ARGS --utility=wxrc`
452 if test "x$WXRC" = x ; then
453 AC_MSG_RESULT([not found])
454 ifelse([$2], , :, [$2])
456 AC_MSG_RESULT([$WXRC])
457 ifelse([$1], , :, [$1])
464 dnl ---------------------------------------------------------------------------
465 dnl WX_LIKE_LIBNAME([output-var] [prefix], [name])
467 dnl Sets the "output-var" variable to the name of a library named with same
469 dnl E.g. for output-var=='lib', name=='test', prefix='mine', sets
470 dnl the $lib variable to:
471 dnl 'mine_gtk2ud_test-2.8'
472 dnl if WX_PORT=gtk2, WX_UNICODE=1, WX_DEBUG=1 and WX_VERSION=28
473 dnl ---------------------------------------------------------------------------
474 AC_DEFUN([WX_LIKE_LIBNAME],
476 wx_temp="$2""_""$WX_PORT"
478 dnl add the [u][d] string
479 if test "$WX_UNICODE" = "1"; then
480 wx_temp="$wx_temp""u"
482 if test "$WX_DEBUG" = "1"; then
483 wx_temp="$wx_temp""d"
486 dnl complete the name of the lib
487 wx_temp="$wx_temp""_""$3""-$WX_VERSION_MAJOR.$WX_VERSION_MINOR"
489 dnl save it in the user's variable
493 dnl ---------------------------------------------------------------------------
494 dnl WX_ARG_ENABLE_YESNOAUTO/WX_ARG_WITH_YESNOAUTO
496 dnl Two little custom macros which define the ENABLE/WITH configure arguments.
498 dnl $1 = the name of the --enable / --with feature
499 dnl $2 = the name of the variable associated
500 dnl $3 = the description of that feature
501 dnl $4 = the default value for that feature
502 dnl $5 = additional action to do in case option is given with "yes" value
503 dnl ---------------------------------------------------------------------------
504 AC_DEFUN([WX_ARG_ENABLE_YESNOAUTO],
506 AC_HELP_STRING([--enable-$1], [$3 (default is $4)]),
507 [], [enableval="$4"])
509 dnl Show a message to the user about this option
510 AC_MSG_CHECKING([for the --enable-$1 option])
511 if test "$enableval" = "yes" ; then
515 elif test "$enableval" = "no" ; then
518 elif test "$enableval" = "auto" ; then
519 AC_MSG_RESULT([will be automatically detected])
523 Unrecognized option value (allowed values: yes, no, auto)
528 AC_DEFUN([WX_ARG_WITH_YESNOAUTO],
530 AC_HELP_STRING([--with-$1], [$3 (default is $4)]),
533 dnl Show a message to the user about this option
534 AC_MSG_CHECKING([for the --with-$1 option])
535 if test "$withval" = "yes" ; then
539 dnl NB: by default we don't allow --with-$1=no option
540 dnl since it does not make much sense !
541 elif test "$6" = "1" -a "$withval" = "no" ; then
544 elif test "$withval" = "auto" ; then
545 AC_MSG_RESULT([will be automatically detected])
549 Unrecognized option value (allowed values: yes, auto)
555 dnl ---------------------------------------------------------------------------
556 dnl WX_STANDARD_OPTIONS([options-to-add])
558 dnl Adds to the configure script one or more of the following options:
559 dnl --enable-[debug|unicode|shared|wxshared|wxdebug]
560 dnl --with-[gtk|msw|motif|x11|mac|mgl|dfb]
561 dnl Then checks for their presence and eventually set the DEBUG, UNICODE, SHARED,
562 dnl PORT, WX_SHARED, WX_DEBUG, variables to one of the "yes", "no", "auto" values.
564 dnl Note that e.g. UNICODE != WX_UNICODE; the first is the value of the
565 dnl --enable-unicode option (in boolean format) while the second indicates
566 dnl if wxWidgets was built in Unicode mode (and still is in boolean format).
567 dnl ---------------------------------------------------------------------------
568 AC_DEFUN([WX_STANDARD_OPTIONS],
571 dnl the following lines will expand to WX_ARG_ENABLE_YESNOAUTO calls if and only if
572 dnl the $1 argument contains respectively the debug,unicode or shared options.
574 ifelse(regexp([$1], [\bdebug]), [-1],,
575 [WX_ARG_ENABLE_YESNOAUTO([debug], [DEBUG], [Build in debug mode], [auto])])
577 ifelse(index([$1], [unicode]), [-1],,
578 [WX_ARG_ENABLE_YESNOAUTO([unicode], [UNICODE], [Build in Unicode mode], [auto])])
580 ifelse(regexp([$1], [\bshared]), [-1],,
581 [WX_ARG_ENABLE_YESNOAUTO([shared], [SHARED], [Build as shared library], [auto])])
583 dnl WX_ARG_WITH_YESNOAUTO cannot be used for --with-toolkit since it's an option
584 dnl which must be able to accept the auto|gtk1|gtk2|msw|... values
585 ifelse(index([$1], [toolkit]), [-1],,
587 AC_ARG_WITH([toolkit],
588 AC_HELP_STRING([--with-toolkit],
589 [Build against a specific wxWidgets toolkit (default is auto)]),
590 [], [withval="auto"])
592 dnl Show a message to the user about this option
593 AC_MSG_CHECKING([for the --with-toolkit option])
594 if test "$withval" = "auto" ; then
595 AC_MSG_RESULT([will be automatically detected])
600 dnl PORT must be one of the allowed values
601 if test "$TOOLKIT" != "gtk1" -a "$TOOLKIT" != "gtk2" -a \
602 "$TOOLKIT" != "msw" -a "$TOOLKIT" != "motif" -a \
603 "$TOOLKIT" != "x11" -a "$TOOLKIT" != "mac" -a \
604 "$TOOLKIT" != "mgl" -a "$TOOLKIT" != "dfb" -a \
605 "$TOOLKIT" != "base" -a "$TOOLKIT" != "cocoa" -a \
606 "$TOOLKIT" != "osx_cocoa"; then
608 Unrecognized option value (allowed values: auto, gtk1, gtk2, msw, motif, x11, mac, mgl, dfb, base, cocoa, osx_cocoa)
612 AC_MSG_RESULT([$TOOLKIT])
616 dnl ****** IMPORTANT *******
617 dnl Unlike for the UNICODE setting, you can build your program in
618 dnl shared mode against a static build of wxWidgets. Thus we have the
619 dnl following option which allows these mixtures. E.g.
621 dnl ./configure --disable-shared --with-wxshared
623 dnl will build your library in static mode against the first available
624 dnl shared build of wxWidgets.
626 dnl Note that's not possible to do the viceversa:
628 dnl ./configure --enable-shared --without-wxshared
630 dnl Doing so you would try to build your library in shared mode against a static
631 dnl build of wxWidgets. This is not possible (you would mix PIC and non PIC code) !
632 dnl A check for this combination of options is in WX_DETECT_STANDARD_OPTION_VALUES
633 dnl (where we know what 'auto' should be expanded to).
635 dnl If you try to build something in ANSI mode against a UNICODE build
636 dnl of wxWidgets or in RELEASE mode against a DEBUG build of wxWidgets,
637 dnl then at best you'll get ton of linking errors !
638 dnl ************************
640 ifelse(index([$1], [wxshared]), [-1],,
642 WX_ARG_WITH_YESNOAUTO(
643 [wxshared], [WX_SHARED],
644 [Force building against a shared build of wxWidgets, even if --disable-shared is given],
648 dnl Just like for SHARED and WX_SHARED it may happen that some adventurous
649 dnl peoples will want to mix a wxWidgets release build with a debug build of
650 dnl his app/lib. So, we have both DEBUG and WX_DEBUG variables.
651 ifelse(index([$1], [wxdebug]), [-1],,
653 WX_ARG_WITH_YESNOAUTO(
654 [wxdebug], [WX_DEBUG],
655 [Force building against a debug build of wxWidgets, even if --disable-debug is given],
659 dnl WX_ARG_WITH_YESNOAUTO cannot be used for --with-wxversion since it's an option
660 dnl which must be able to accept the auto|26|27|28... values
661 ifelse(index([$1], [wxversion]), [-1],,
663 AC_ARG_WITH([wxversion],
664 AC_HELP_STRING([--with-wxversion],
665 [Build against a specific version of wxWidgets (default is auto)]),
666 [], [withval="auto"])
668 dnl Show a message to the user about this option
669 AC_MSG_CHECKING([for the --with-wxversion option])
670 if test "$withval" = "auto" ; then
671 AC_MSG_RESULT([will be automatically detected])
675 wx_requested_major_version=`echo $withval | \
676 sed 's/\([[0-9]]*\).\([[0-9]]*\).*/\1/'`
677 wx_requested_minor_version=`echo $withval | \
678 sed 's/\([[0-9]]*\).\([[0-9]]*\).*/\2/'`
680 dnl both vars above must be exactly 1 digit
681 if test "${#wx_requested_major_version}" != "1" -o \
682 "${#wx_requested_minor_version}" != "1" ; then
684 Unrecognized option value (allowed values: auto, 2.6, 2.7, 2.8, 2.9)
688 WX_VERSION="$wx_requested_major_version"".""$wx_requested_minor_version"
689 AC_MSG_RESULT([$WX_VERSION])
693 if test "$WX_DEBUG_CONFIGURE" = "1"; then
694 echo "[[dbg]] DEBUG: $DEBUG, WX_DEBUG: $WX_DEBUG"
695 echo "[[dbg]] UNICODE: $UNICODE, WX_UNICODE: $WX_UNICODE"
696 echo "[[dbg]] SHARED: $SHARED, WX_SHARED: $WX_SHARED"
697 echo "[[dbg]] TOOLKIT: $TOOLKIT, WX_TOOLKIT: $WX_TOOLKIT"
698 echo "[[dbg]] VERSION: $VERSION, WX_VERSION: $WX_VERSION"
703 dnl ---------------------------------------------------------------------------
704 dnl WX_CONVERT_STANDARD_OPTIONS_TO_WXCONFIG_FLAGS
706 dnl Sets the WXCONFIG_FLAGS string using the SHARED,DEBUG,UNICODE variable values
707 dnl which are different from "auto".
708 dnl Thus this macro needs to be called only once all options have been set.
709 dnl ---------------------------------------------------------------------------
710 AC_DEFUN([WX_CONVERT_STANDARD_OPTIONS_TO_WXCONFIG_FLAGS],
712 if test "$WX_SHARED" = "1" ; then
713 WXCONFIG_FLAGS="--static=no "
714 elif test "$WX_SHARED" = "0" ; then
715 WXCONFIG_FLAGS="--static=yes "
718 if test "$WX_DEBUG" = "1" ; then
719 WXCONFIG_FLAGS="$WXCONFIG_FLAGS""--debug=yes "
720 elif test "$WX_DEBUG" = "0" ; then
721 WXCONFIG_FLAGS="$WXCONFIG_FLAGS""--debug=no "
724 dnl The user should have set WX_UNICODE=UNICODE
725 if test "$WX_UNICODE" = "1" ; then
726 WXCONFIG_FLAGS="$WXCONFIG_FLAGS""--unicode=yes "
727 elif test "$WX_UNICODE" = "0" ; then
728 WXCONFIG_FLAGS="$WXCONFIG_FLAGS""--unicode=no "
731 if test "$TOOLKIT" != "auto" ; then
732 WXCONFIG_FLAGS="$WXCONFIG_FLAGS""--toolkit=$TOOLKIT "
735 if test "$WX_VERSION" != "auto" ; then
736 WXCONFIG_FLAGS="$WXCONFIG_FLAGS""--version=$WX_VERSION "
739 dnl strip out the last space of the string
740 WXCONFIG_FLAGS=${WXCONFIG_FLAGS% }
742 if test "$WX_DEBUG_CONFIGURE" = "1"; then
743 echo "[[dbg]] WXCONFIG_FLAGS: $WXCONFIG_FLAGS"
748 dnl ---------------------------------------------------------------------------
749 dnl _WX_SELECTEDCONFIG_CHECKFOR([RESULTVAR], [STRING], [MSG]
750 dnl [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
752 dnl Outputs the given MSG. Then searches the given STRING in the wxWidgets
753 dnl additional CPP flags and put the result of the search in WX_$RESULTVAR
754 dnl also adding the "yes" or "no" message result to MSG.
755 dnl ---------------------------------------------------------------------------
756 AC_DEFUN([_WX_SELECTEDCONFIG_CHECKFOR],
758 if test "$$1" = "auto" ; then
760 dnl The user does not have particular preferences for this option;
761 dnl so we will detect the wxWidgets relative build setting and use it
762 AC_MSG_CHECKING([$3])
764 dnl set WX_$1 variable to 1 if the $WX_SELECTEDCONFIG contains the $2
765 dnl string or to 0 otherwise.
766 dnl NOTE: 'expr match STRING REGEXP' cannot be used since on Mac it
767 dnl doesn't work; we use 'expr STRING : REGEXP' instead
768 WX_$1=$(expr "$WX_SELECTEDCONFIG" : ".*$2.*")
770 if test "$WX_$1" != "0"; then
773 ifelse([$4], , :, [$4])
777 ifelse([$5], , :, [$5])
781 dnl Use the setting given by the user
786 dnl ---------------------------------------------------------------------------
787 dnl WX_DETECT_STANDARD_OPTION_VALUES
789 dnl Detects the values of the following variables:
793 dnl 4) WX_SHARED (and also WX_STATIC)
795 dnl from the previously selected wxWidgets build; this macro in fact must be
796 dnl called *after* calling the WX_CONFIG_CHECK macro.
798 dnl Note that the WX_VERSION_MAJOR, WX_VERSION_MINOR symbols are already set
799 dnl by WX_CONFIG_CHECK macro
800 dnl ---------------------------------------------------------------------------
801 AC_DEFUN([WX_DETECT_STANDARD_OPTION_VALUES],
803 WX_VERSION="$WX_VERSION_MAJOR""$WX_VERSION_MINOR"
804 if test $WX_VERSION -lt 26 ; then
807 Cannot detect the wxWidgets configuration for the selected wxWidgets build
808 since its version is $WX_VERSION_FULL < 2.6.0; please install a newer
809 version of wxWidgets.
813 dnl The wx-config we are using understands the "--selected_config"
814 dnl option which returns an easy-parseable string !
815 WX_SELECTEDCONFIG=$($WX_CONFIG_WITH_ARGS --selected_config)
817 if test "$WX_DEBUG_CONFIGURE" = "1"; then
818 echo "[[dbg]] Using wx-config --selected-config"
819 echo "[[dbg]] WX_SELECTEDCONFIG: $WX_SELECTEDCONFIG"
823 dnl we could test directly for WX_SHARED with a line like:
824 dnl _WX_SELECTEDCONFIG_CHECKFOR([SHARED], [shared],
825 dnl [if wxWidgets was built in SHARED mode])
826 dnl but wx-config --selected-config DOES NOT outputs the 'shared'
827 dnl word when wx was built in shared mode; it rather outputs the
828 dnl 'static' word when built in static mode.
829 if test $WX_SHARED = "1"; then
831 elif test $WX_SHARED = "0"; then
833 elif test $WX_SHARED = "auto"; then
837 dnl Now set the WX_UNICODE, WX_DEBUG, WX_STATIC variables
838 _WX_SELECTEDCONFIG_CHECKFOR([UNICODE], [unicode],
839 [if wxWidgets was built with UNICODE enabled])
840 _WX_SELECTEDCONFIG_CHECKFOR([DEBUG], [debug],
841 [if wxWidgets was built in DEBUG mode])
842 _WX_SELECTEDCONFIG_CHECKFOR([STATIC], [static],
843 [if wxWidgets was built in STATIC mode])
845 dnl init WX_SHARED from WX_STATIC
846 if test "$WX_STATIC" != "0"; then
856 dnl detect the WX_PORT to use
857 if test "$TOOLKIT" = "auto" ; then
859 dnl The user does not have particular preferences for this option;
860 dnl so we will detect the wxWidgets relative build setting and use it
861 AC_MSG_CHECKING([which wxWidgets toolkit was selected])
863 WX_GTKPORT1=$(expr "$WX_SELECTEDCONFIG" : ".*gtk1.*")
864 WX_GTKPORT2=$(expr "$WX_SELECTEDCONFIG" : ".*gtk2.*")
865 WX_MSWPORT=$(expr "$WX_SELECTEDCONFIG" : ".*msw.*")
866 WX_MOTIFPORT=$(expr "$WX_SELECTEDCONFIG" : ".*motif.*")
867 WX_MACPORT=$(expr "$WX_SELECTEDCONFIG" : ".*mac.*")
868 WX_X11PORT=$(expr "$WX_SELECTEDCONFIG" : ".*x11.*")
869 WX_MGLPORT=$(expr "$WX_SELECTEDCONFIG" : ".*mgl.*")
870 WX_DFBPORT=$(expr "$WX_SELECTEDCONFIG" : ".*dfb.*")
871 WX_BASEPORT=$(expr "$WX_SELECTEDCONFIG" : ".*base.*")
872 WX_COCOAPORT=$(expr "$WX_SELECTEDCONFIG" : ".*cocoa.*")
873 WX_OSXCOCOAPORT=$(expr "$WX_SELECTEDCONFIG" : ".*osx_cocoa.*")
876 if test "$WX_GTKPORT1" != "0"; then WX_PORT="gtk1"; fi
877 if test "$WX_GTKPORT2" != "0"; then WX_PORT="gtk2"; fi
878 if test "$WX_MSWPORT" != "0"; then WX_PORT="msw"; fi
879 if test "$WX_MOTIFPORT" != "0"; then WX_PORT="motif"; fi
880 if test "$WX_MACPORT" != "0"; then WX_PORT="mac"; fi
881 if test "$WX_X11PORT" != "0"; then WX_PORT="x11"; fi
882 if test "$WX_MGLPORT" != "0"; then WX_PORT="mgl"; fi
883 if test "$WX_DFBPORT" != "0"; then WX_PORT="dfb"; fi
884 if test "$WX_BASEPORT" != "0"; then WX_PORT="base"; fi
885 if test "$WX_COCOAPORT" != "0"; then WX_PORT="cocoa"; fi
886 if test "$WX_OSXCOCOAPORT" != "0"; then WX_PORT="osx_cocoa"; fi
888 dnl check at least one of the WX_*PORT has been set !
890 if test "$WX_PORT" = "unknown" ; then
892 Cannot detect the currently installed wxWidgets port !
893 Please check your 'wx-config --cxxflags'...
897 AC_MSG_RESULT([$WX_PORT])
900 dnl Use the setting given by the user
901 if test -n "$TOOLKIT" ; then
911 if test "$WX_DEBUG_CONFIGURE" = "1"; then
912 echo "[[dbg]] Values of all WX_* options after final detection:"
913 echo "[[dbg]] WX_DEBUG: $WX_DEBUG"
914 echo "[[dbg]] WX_UNICODE: $WX_UNICODE"
915 echo "[[dbg]] WX_SHARED: $WX_SHARED"
916 echo "[[dbg]] WX_VERSION: $WX_VERSION"
917 echo "[[dbg]] WX_PORT: $WX_PORT"
920 dnl Avoid problem described in the WX_STANDARD_OPTIONS which happens when
921 dnl the user gives the options:
922 dnl ./configure --enable-shared --without-wxshared
924 dnl ./configure --enable-shared
925 dnl but there is only a static build of wxWidgets available.
926 if test "$WX_SHARED" = "0" -a "$SHARED" = "1"; then
928 Cannot build shared library against a static build of wxWidgets !
929 This error happens because the wxWidgets build which was selected
930 has been detected as static while you asked to build $PACKAGE_NAME
931 as shared library and this is not possible.
932 Use the '--disable-shared' option to build $PACKAGE_NAME
933 as static library or '--with-wxshared' to use wxWidgets as shared library.
937 dnl now we can finally update the DEBUG,UNICODE,SHARED options
938 dnl to their final values if they were set to 'auto'
939 if test "$DEBUG" = "auto"; then
942 dnl in case user wants a BUILD=debug/release var...
943 if test "$DEBUG" = "1"; then
945 elif test "$DEBUG" = ""; then
949 if test "$UNICODE" = "auto"; then
952 if test "$SHARED" = "auto"; then
955 if test "$TOOLKIT" = "auto"; then
959 dnl dnl respect the DEBUG variable adding the optimize/debug flags
960 dnl dnl NOTE: the CXXFLAGS are merged together with the CPPFLAGS so we
961 dnl dnl don't need to set them, too
962 dnl if test "$DEBUG" = "1"; then
963 dnl CXXFLAGS="$CXXFLAGS -g -O0"
964 dnl CFLAGS="$CFLAGS -g -O0"
966 dnl CXXFLAGS="$CXXFLAGS -O2"
967 dnl CFLAGS="$CFLAGS -O2"
971 dnl ---------------------------------------------------------------------------
972 dnl WX_BOOLOPT_SUMMARY([name of the boolean variable to show summary for],
973 dnl [what to print when var is 1],
974 dnl [what to print when var is 0])
976 dnl Prints $2 when variable $1 == 1 and prints $3 when variable $1 == 0.
977 dnl This macro mainly exists just to make configure.ac scripts more readable.
979 dnl NOTE: you need to use the [" my message"] syntax for 2nd and 3rd arguments
980 dnl if you want that m4 avoid to throw away the spaces prefixed to the
982 dnl ---------------------------------------------------------------------------
983 AC_DEFUN([WX_BOOLOPT_SUMMARY],
985 if test "x$$1" = "x1" ; then
987 elif test "x$$1" = "x0" ; then
994 dnl ---------------------------------------------------------------------------
995 dnl WX_STANDARD_OPTIONS_SUMMARY_MSG
997 dnl Shows a summary message to the user about the WX_* variable contents.
998 dnl This macro is used typically at the end of the configure script.
999 dnl ---------------------------------------------------------------------------
1000 AC_DEFUN([WX_STANDARD_OPTIONS_SUMMARY_MSG],
1003 echo " The wxWidgets build which will be used by $PACKAGE_NAME $PACKAGE_VERSION"
1004 echo " has the following settings:"
1005 WX_BOOLOPT_SUMMARY([WX_DEBUG], [" - DEBUG build"], [" - RELEASE build"])
1006 WX_BOOLOPT_SUMMARY([WX_UNICODE], [" - UNICODE mode"], [" - ANSI mode"])
1007 WX_BOOLOPT_SUMMARY([WX_SHARED], [" - SHARED mode"], [" - STATIC mode"])
1008 echo " - VERSION: $WX_VERSION_FULL"
1009 echo " - PORT: $WX_PORT"
1013 dnl ---------------------------------------------------------------------------
1014 dnl WX_STANDARD_OPTIONS_SUMMARY_MSG_BEGIN, WX_STANDARD_OPTIONS_SUMMARY_MSG_END
1016 dnl Like WX_STANDARD_OPTIONS_SUMMARY_MSG macro but these two macros also gives info
1017 dnl about the configuration of the package which used the wxpresets.
1020 dnl WX_STANDARD_OPTIONS_SUMMARY_MSG_BEGIN
1021 dnl echo " - Package setting 1: $SETTING1"
1022 dnl echo " - Package setting 2: $SETTING1"
1024 dnl WX_STANDARD_OPTIONS_SUMMARY_MSG_END
1026 dnl ---------------------------------------------------------------------------
1027 AC_DEFUN([WX_STANDARD_OPTIONS_SUMMARY_MSG_BEGIN],
1030 echo " ----------------------------------------------------------------"
1031 echo " Configuration for $PACKAGE_NAME $PACKAGE_VERSION successfully completed."
1032 echo " Summary of main configuration settings for $PACKAGE_NAME:"
1033 WX_BOOLOPT_SUMMARY([DEBUG], [" - DEBUG build"], [" - RELEASE build"])
1034 WX_BOOLOPT_SUMMARY([UNICODE], [" - UNICODE mode"], [" - ANSI mode"])
1035 WX_BOOLOPT_SUMMARY([SHARED], [" - SHARED mode"], [" - STATIC mode"])
1038 AC_DEFUN([WX_STANDARD_OPTIONS_SUMMARY_MSG_END],
1040 WX_STANDARD_OPTIONS_SUMMARY_MSG
1042 echo " Now, just run make."
1043 echo " ----------------------------------------------------------------"
1048 dnl ---------------------------------------------------------------------------
1049 dnl Deprecated macro wrappers
1050 dnl ---------------------------------------------------------------------------
1052 AC_DEFUN([AM_OPTIONS_WXCONFIG], [WX_CONFIG_OPTIONS])
1053 AC_DEFUN([AM_PATH_WXCONFIG], [
1054 WX_CONFIG_CHECK([$1],[$2],[$3],[$4],[$5])