1dnl --------------------------------------------------------------------------- 2dnl Macros for wxWidgets detection. Typically used in configure.in as: 3dnl 4dnl AC_ARG_ENABLE(...) 5dnl AC_ARG_WITH(...) 6dnl ... 7dnl AM_OPTIONS_WXCONFIG 8dnl ... 9dnl ... 10dnl AM_PATH_WXCONFIG(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 --------------------------------------------------------------------------- 28 29dnl --------------------------------------------------------------------------- 30dnl AM_OPTIONS_WXCONFIG 31dnl 32dnl adds support for --wx-prefix, --wx-exec-prefix, --with-wxdir and 33dnl --wx-config command line options 34dnl --------------------------------------------------------------------------- 35 36AC_DEFUN([AM_OPTIONS_WXCONFIG], 37[ 38 AC_ARG_WITH(wxdir, 39 [ --with-wxdir=PATH Use uninstalled version of wxWidgets in PATH], 40 [ wx_config_name="$withval/wx-config" 41 wx_config_args="--inplace"]) 42 AC_ARG_WITH(wx-config, 43 [ --with-wx-config=CONFIG wx-config script to use (optional)], 44 wx_config_name="$withval" ) 45 AC_ARG_WITH(wx-prefix, 46 [ --with-wx-prefix=PREFIX Prefix where wxWidgets is installed (optional)], 47 wx_config_prefix="$withval", wx_config_prefix="") 48 AC_ARG_WITH(wx-exec-prefix, 49 [ --with-wx-exec-prefix=PREFIX 50 Exec prefix where wxWidgets is installed (optional)], 51 wx_config_exec_prefix="$withval", wx_config_exec_prefix="") 52]) 53 54dnl Helper macro for checking if wx version is at least $1.$2.$3, set's 55dnl wx_ver_ok=yes if it is: 56AC_DEFUN([_WX_PRIVATE_CHECK_VERSION], 57[ 58 wx_ver_ok="" 59 if test "x$WX_VERSION" != x ; then 60 if test $wx_config_major_version -gt $1; then 61 wx_ver_ok=yes 62 else 63 if test $wx_config_major_version -eq $1; then 64 if test $wx_config_minor_version -gt $2; then 65 wx_ver_ok=yes 66 else 67 if test $wx_config_minor_version -eq $2; then 68 if test $wx_config_micro_version -ge $3; then 69 wx_ver_ok=yes 70 fi 71 fi 72 fi 73 fi 74 fi 75 fi 76]) 77 78dnl --------------------------------------------------------------------------- 79dnl AM_PATH_WXCONFIG(VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND 80dnl [, WX-LIBS [, ADDITIONAL-WX-CONFIG-FLAGS]]]]) 81dnl 82dnl Test for wxWidgets, and define WX_C*FLAGS, WX_LIBS and WX_LIBS_STATIC 83dnl (the latter is for static linking against wxWidgets). Set WX_CONFIG_NAME 84dnl environment variable to override the default name of the wx-config script 85dnl to use. Set WX_CONFIG_PATH to specify the full path to wx-config - in this 86dnl case the macro won't even waste time on tests for its existence. 87dnl 88dnl Optional WX-LIBS argument contains comma- or space-separated list of 89dnl wxWidgets libraries to link against (it may include contrib libraries). If 90dnl it is not specified then WX_LIBS and WX_LIBS_STATIC will contain flags to 91dnl link with all of the core wxWidgets libraries. 92dnl 93dnl Optional ADDITIONAL-WX-CONFIG-FLAGS argument is appended to wx-config 94dnl invocation command in present. It can be used to fine-tune lookup of 95dnl best wxWidgets build available. 96dnl 97dnl Example use: 98dnl AM_PATH_WXCONFIG([2.6.0], [wxWin=1], [wxWin=0], [html,core,net] 99dnl [--unicode --debug]) 100dnl --------------------------------------------------------------------------- 101 102dnl 103dnl Get the cflags and libraries from the wx-config script 104dnl 105AC_DEFUN([AM_PATH_WXCONFIG], 106[ 107 dnl do we have wx-config name: it can be wx-config or wxd-config or ... 108 if test x${WX_CONFIG_NAME+set} != xset ; then 109 WX_CONFIG_NAME=wx-config 110 fi 111 112 if test "x$wx_config_name" != x ; then 113 WX_CONFIG_NAME="$wx_config_name" 114 fi 115 116 dnl deal with optional prefixes 117 if test x$wx_config_exec_prefix != x ; then 118 wx_config_args="$wx_config_args --exec-prefix=$wx_config_exec_prefix" 119 WX_LOOKUP_PATH="$wx_config_exec_prefix/bin" 120 fi 121 if test x$wx_config_prefix != x ; then 122 wx_config_args="$wx_config_args --prefix=$wx_config_prefix" 123 WX_LOOKUP_PATH="$WX_LOOKUP_PATH:$wx_config_prefix/bin" 124 fi 125 if test "$cross_compiling" = "yes"; then 126 wx_config_args="$wx_config_args --host=$host_alias" 127 fi 128 129 dnl don't search the PATH if WX_CONFIG_NAME is absolute filename 130 if test -x "$WX_CONFIG_NAME" ; then 131 AC_MSG_CHECKING(for wx-config) 132 WX_CONFIG_PATH="$WX_CONFIG_NAME" 133 AC_MSG_RESULT($WX_CONFIG_PATH) 134 else 135 AC_PATH_PROG(WX_CONFIG_PATH, $WX_CONFIG_NAME, no, "$WX_LOOKUP_PATH:$PATH") 136 fi 137 138 if test "$WX_CONFIG_PATH" != "no" ; then 139 WX_VERSION="" 140 141 min_wx_version=ifelse([$1], ,2.2.1,$1) 142 if test -z "$5" ; then 143 AC_MSG_CHECKING([for wxWidgets version >= $min_wx_version]) 144 else 145 AC_MSG_CHECKING([for wxWidgets version >= $min_wx_version ($5)]) 146 fi 147 148 WX_CONFIG_WITH_ARGS="$WX_CONFIG_PATH $wx_config_args $5 $4" 149 150 WX_VERSION=`$WX_CONFIG_WITH_ARGS --version 2>/dev/null` 151 wx_config_major_version=`echo $WX_VERSION | \ 152 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` 153 wx_config_minor_version=`echo $WX_VERSION | \ 154 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` 155 wx_config_micro_version=`echo $WX_VERSION | \ 156 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` 157 158 wx_requested_major_version=`echo $min_wx_version | \ 159 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` 160 wx_requested_minor_version=`echo $min_wx_version | \ 161 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` 162 wx_requested_micro_version=`echo $min_wx_version | \ 163 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` 164 165 _WX_PRIVATE_CHECK_VERSION([$wx_requested_major_version], 166 [$wx_requested_minor_version], 167 [$wx_requested_micro_version]) 168 169 if test -n "$wx_ver_ok"; then 170 171 AC_MSG_RESULT(yes (version $WX_VERSION)) 172 WX_LIBS=`$WX_CONFIG_WITH_ARGS --libs` 173 174 dnl is this even still appropriate? --static is a real option now 175 dnl and WX_CONFIG_WITH_ARGS is likely to contain it if that is 176 dnl what the user actually wants, making this redundant at best. 177 dnl For now keep it in case anyone actually used it in the past. 178 AC_MSG_CHECKING([for wxWidgets static library]) 179 WX_LIBS_STATIC=`$WX_CONFIG_WITH_ARGS --static --libs 2>/dev/null` 180 if test "x$WX_LIBS_STATIC" = "x"; then 181 AC_MSG_RESULT(no) 182 else 183 AC_MSG_RESULT(yes) 184 fi 185 186 dnl starting with version 2.2.6 wx-config has --cppflags argument 187 wx_has_cppflags="" 188 if test $wx_config_major_version -gt 2; then 189 wx_has_cppflags=yes 190 else 191 if test $wx_config_major_version -eq 2; then 192 if test $wx_config_minor_version -gt 2; then 193 wx_has_cppflags=yes 194 else 195 if test $wx_config_minor_version -eq 2; then 196 if test $wx_config_micro_version -ge 6; then 197 wx_has_cppflags=yes 198 fi 199 fi 200 fi 201 fi 202 fi 203 204 if test "x$wx_has_cppflags" = x ; then 205 dnl no choice but to define all flags like CFLAGS 206 WX_CFLAGS=`$WX_CONFIG_WITH_ARGS --cflags` 207 WX_CPPFLAGS=$WX_CFLAGS 208 WX_CXXFLAGS=$WX_CFLAGS 209 210 WX_CFLAGS_ONLY=$WX_CFLAGS 211 WX_CXXFLAGS_ONLY=$WX_CFLAGS 212 else 213 dnl we have CPPFLAGS included in CFLAGS included in CXXFLAGS 214 WX_CPPFLAGS=`$WX_CONFIG_WITH_ARGS --cppflags` 215 WX_CXXFLAGS=`$WX_CONFIG_WITH_ARGS --cxxflags` 216 WX_CFLAGS=`$WX_CONFIG_WITH_ARGS --cflags` 217 218 WX_CFLAGS_ONLY=`echo $WX_CFLAGS | sed "s@^$WX_CPPFLAGS *@@"` 219 WX_CXXFLAGS_ONLY=`echo $WX_CXXFLAGS | sed "s@^$WX_CFLAGS *@@"` 220 fi 221 222 ifelse([$2], , :, [$2]) 223 224 else 225 226 if test "x$WX_VERSION" = x; then 227 dnl no wx-config at all 228 AC_MSG_RESULT(no) 229 else 230 AC_MSG_RESULT(no (version $WX_VERSION is not new enough)) 231 fi 232 233 WX_CFLAGS="" 234 WX_CPPFLAGS="" 235 WX_CXXFLAGS="" 236 WX_LIBS="" 237 WX_LIBS_STATIC="" 238 ifelse([$3], , :, [$3]) 239 240 fi 241 else 242 243 WX_CFLAGS="" 244 WX_CPPFLAGS="" 245 WX_CXXFLAGS="" 246 WX_LIBS="" 247 WX_LIBS_STATIC="" 248 ifelse([$3], , :, [$3]) 249 250 fi 251 252 # on solaris the wx CFLAGS and LIBS can be messed up because of the compiler 253 # used in the default installs. So we need to fix them. 254 case "${host}" in 255 sparc-sun-solaris*) 256 old_wx_cflags="${WX_CFLAGS}" 257 WX_CFLAGS= 258 for flag in $old_wx_cflags ; do 259 case "${flag}" in 260 -x*) 261 echo > /dev/null 262 ;; 263 -mt) 264 WX_CFLAGS="${WX_CFLAGS} ${PTHREAD_CFLAGS}" 265 ;; 266 *) 267 WX_CFLAGS="${WX_CFLAGS} ${flag}" 268 ;; 269 esac 270 done 271 old_wx_cppflags="${WX_CPPFLAGS}" 272 WX_CPPFLAGS= 273 for flag in $old_wx_cppflags ; do 274 case "${flag}" in 275 -x*) 276 echo > /dev/null 277 ;; 278 -mt) 279 WX_CPPFLAGS="${WX_CPPFLAGS} ${PTHREAD_CFLAGS}" 280 ;; 281 *) 282 WX_CPPFLAGS="${WX_CPPFLAGS} ${flag}" 283 ;; 284 esac 285 done 286 old_wx_cxxflags="${WX_CXXFLAGS}" 287 WX_CXXFLAGS= 288 for flag in $old_wx_cxxflags ; do 289 case "${flag}" in 290 -x*) 291 echo > /dev/null 292 ;; 293 -mt) 294 WX_CXXFLAGS="${WX_CXXFLAGS} ${PTHREAD_CFLAGS}" 295 ;; 296 *) 297 WX_CXXFLAGS="${WX_CXXFLAGS} ${flag}" 298 ;; 299 esac 300 done 301 old_wx_libs="${WX_LIBS}" 302 WX_LIBS= 303 for flag in $old_wx_libs ; do 304 case "${flag}" in 305 -x*) 306 echo > /dev/null 307 ;; 308 -mt) 309 WX_LIBS="${WX_LIBS} ${PTHREAD_LIBS}" 310 ;; 311 *) 312 WX_LIBS="${WX_LIBS} ${flag}" 313 ;; 314 esac 315 done 316 ;; 317 esac 318 319 320 AC_SUBST(WX_CPPFLAGS) 321 AC_SUBST(WX_CFLAGS) 322 AC_SUBST(WX_CXXFLAGS) 323 AC_SUBST(WX_CFLAGS_ONLY) 324 AC_SUBST(WX_CXXFLAGS_ONLY) 325 AC_SUBST(WX_LIBS) 326 AC_SUBST(WX_LIBS_STATIC) 327 AC_SUBST(WX_VERSION) 328]) 329 330dnl --------------------------------------------------------------------------- 331dnl Get information on the wxrc program for making C++, Python and xrs 332dnl resource files. 333dnl 334dnl AC_ARG_ENABLE(...) 335dnl AC_ARG_WITH(...) 336dnl ... 337dnl AM_OPTIONS_WXCONFIG 338dnl AM_OPTIONS_WXRC 339dnl ... 340dnl AM_PATH_WXCONFIG(2.6.0, wxWin=1) 341dnl if test "$wxWin" != 1; then 342dnl AC_MSG_ERROR([ 343dnl wxWidgets must be installed on your system 344dnl but wx-config script couldn't be found. 345dnl 346dnl Please check that wx-config is in path, the directory 347dnl where wxWidgets libraries are installed (returned by 348dnl 'wx-config --libs' command) is in LD_LIBRARY_PATH or 349dnl equivalent variable and wxWidgets version is 2.6.0 or above. 350dnl ]) 351dnl fi 352dnl 353dnl AM_PATH_WXRC([HAVE_WXRC=1], [HAVE_WXRC=0]) 354dnl if test "x$HAVE_WXRC" != x1; then 355dnl AC_MSG_ERROR([ 356dnl The wxrc program was not installed or not found. 357dnl 358dnl Please check the wxWidgets installation. 359dnl ]) 360dnl fi 361dnl 362dnl CPPFLAGS="$CPPFLAGS $WX_CPPFLAGS" 363dnl CXXFLAGS="$CXXFLAGS $WX_CXXFLAGS_ONLY" 364dnl CFLAGS="$CFLAGS $WX_CFLAGS_ONLY" 365dnl 366dnl LDFLAGS="$LDFLAGS $WX_LIBS" 367dnl --------------------------------------------------------------------------- 368 369 370 371dnl --------------------------------------------------------------------------- 372dnl AM_PATH_WXRC([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]) 373dnl 374dnl Test for wxWidgets' wxrc program for creating either C++, Python or XRS 375dnl resources. The variable WXRC will be set and substituted in the configure 376dnl script and Makefiles. 377dnl 378dnl Example use: 379dnl AM_PATH_WXRC([wxrc=1], [wxrc=0]) 380dnl --------------------------------------------------------------------------- 381 382dnl 383dnl wxrc program from the wx-config script 384dnl 385AC_DEFUN([AM_PATH_WXRC], 386[ 387 AC_ARG_VAR([WXRC], [Path to wxWidget's wxrc resource compiler]) 388 389 if test "x$WX_CONFIG_NAME" = x; then 390 AC_MSG_ERROR([The wxrc tests must run after wxWidgets test.]) 391 else 392 393 AC_MSG_CHECKING([for wxrc]) 394 395 if test "x$WXRC" = x ; then 396 dnl wx-config --utility is a new addition to wxWidgets: 397 _WX_PRIVATE_CHECK_VERSION(2,5,3) 398 if test -n "$wx_ver_ok"; then 399 WXRC=`$WX_CONFIG_WITH_ARGS --utility=wxrc` 400 fi 401 fi 402 403 if test "x$WXRC" = x ; then 404 AC_MSG_RESULT([not found]) 405 ifelse([$2], , :, [$2]) 406 else 407 AC_MSG_RESULT([$WXRC]) 408 ifelse([$1], , :, [$1]) 409 fi 410 411 AC_SUBST(WXRC) 412 fi 413]) 414