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