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