]> git.saurik.com Git - wxWidgets.git/blame_incremental - acinclude.m4
Fixed missing key down events (probably introduced
[wxWidgets.git] / acinclude.m4
... / ...
CommitLineData
1dnl ---------------------------------------------------------------------------
2dnl
3dnl Macros for configure.in for wxWindows by Robert Roebling, Phil Blecker,
4dnl Vadim Zeitlin and Ron Lee
5dnl
6dnl This script is under the wxWindows licence.
7dnl
8dnl Version: $Id$
9dnl ---------------------------------------------------------------------------
10
11dnl ===========================================================================
12dnl macros to find the a file in the list of include/lib paths
13dnl ===========================================================================
14
15dnl ---------------------------------------------------------------------------
16dnl call WX_PATH_FIND_INCLUDES(search path, header name), sets ac_find_includes
17dnl to the full name of the file that was found or leaves it empty if not found
18dnl ---------------------------------------------------------------------------
19AC_DEFUN([WX_PATH_FIND_INCLUDES],
20[
21ac_find_includes=
22for ac_dir in $1 /usr/include;
23 do
24 if test -f "$ac_dir/$2"; then
25 ac_find_includes=$ac_dir
26 break
27 fi
28 done
29])
30
31dnl ---------------------------------------------------------------------------
32dnl call WX_PATH_FIND_LIBRARIES(search path, header name), sets ac_find_libraries
33dnl to the full name of the file that was found or leaves it empty if not found
34dnl ---------------------------------------------------------------------------
35AC_DEFUN([WX_PATH_FIND_LIBRARIES],
36[
37ac_find_libraries=
38for ac_dir in $1 /usr/lib;
39 do
40 for ac_extension in a so sl dylib; do
41 if test -f "$ac_dir/lib$2.$ac_extension"; then
42 ac_find_libraries=$ac_dir
43 break 2
44 fi
45 done
46 done
47])
48
49dnl ---------------------------------------------------------------------------
50dnl Path to include, already defined
51dnl ---------------------------------------------------------------------------
52AC_DEFUN([WX_INCLUDE_PATH_EXIST],
53[
54 dnl never add -I/usr/include to the CPPFLAGS
55 if test "x$1" = "x/usr/include"; then
56 ac_path_to_include=""
57 else
58 echo "$2" | grep "\-I$1" > /dev/null
59 result=$?
60 if test $result = 0; then
61 ac_path_to_include=""
62 else
63 ac_path_to_include=" -I$1"
64 fi
65 fi
66])
67
68dnl ---------------------------------------------------------------------------
69dnl Path to link, already defined
70dnl ---------------------------------------------------------------------------
71AC_DEFUN([WX_LINK_PATH_EXIST],
72[
73 echo "$2" | grep "\-L$1" > /dev/null
74 result=$?
75 if test $result = 0; then
76 ac_path_to_link=""
77 else
78 ac_path_to_link=" -L$1"
79 fi
80])
81
82dnl ===========================================================================
83dnl C++ features test
84dnl ===========================================================================
85
86dnl ---------------------------------------------------------------------------
87dnl WX_CPP_NEW_HEADERS checks whether the compiler has "new" <iostream> header
88dnl or only the old <iostream.h> one - it may be generally assumed that if
89dnl <iostream> exists, the other "new" headers (without .h) exist too.
90dnl
91dnl call WX_CPP_NEW_HEADERS(actiof-if-true, action-if-false)
92dnl ---------------------------------------------------------------------------
93
94AC_DEFUN([WX_CPP_NEW_HEADERS],
95[
96 AC_LANG_SAVE
97 AC_LANG_CPLUSPLUS
98
99 AC_CHECK_HEADERS(iostream)
100
101 if test "$ac_cv_header_iostream" = "yes" ; then
102 ifelse([$1], , :, [$1])
103 else
104 ifelse([$2], , :, [$2])
105 fi
106
107 AC_LANG_RESTORE
108])
109
110dnl ---------------------------------------------------------------------------
111dnl WX_CPP_BOOL checks whether the C++ compiler has a built in bool type
112dnl
113dnl call WX_CPP_BOOL - will define HAVE_BOOL if the compiler supports bool
114dnl ---------------------------------------------------------------------------
115
116AC_DEFUN([WX_CPP_BOOL],
117[
118 AC_CACHE_CHECK([if C++ compiler supports bool], wx_cv_cpp_bool,
119 [
120 AC_LANG_SAVE
121 AC_LANG_CPLUSPLUS
122
123 AC_TRY_COMPILE(
124 [
125 ],
126 [
127 bool b = true;
128
129 return 0;
130 ],
131 [
132 wx_cv_cpp_bool=yes
133 ],
134 [
135 wx_cv_cpp_bool=no
136 ]
137 )
138
139 AC_LANG_RESTORE
140 ])
141
142 if test "$wx_cv_cpp_bool" = "yes"; then
143 AC_DEFINE(HAVE_BOOL)
144 fi
145])
146
147dnl ---------------------------------------------------------------------------
148dnl WX_CPP_EXPLICIT checks whether the C++ compiler support the explicit
149dnl keyword and defines HAVE_EXPLICIT if this is the case
150dnl ---------------------------------------------------------------------------
151
152AC_DEFUN([WX_CPP_EXPLICIT],
153[
154 AC_CACHE_CHECK([if C++ compiler supports the explicit keyword],
155 wx_cv_explicit,
156 [
157 AC_LANG_SAVE
158 AC_LANG_CPLUSPLUS
159
160 dnl do the test in 2 steps: first check that the compiler knows about the
161 dnl explicit keyword at all and then verify that it really honours it
162 AC_TRY_COMPILE(
163 [
164 class Foo { public: explicit Foo(int) {} };
165 ],
166 [
167 return 0;
168 ],
169 [
170 AC_TRY_COMPILE(
171 [
172 class Foo { public: explicit Foo(int) {} };
173 static void TakeFoo(const Foo& foo) { }
174 ],
175 [
176 TakeFoo(17);
177 return 0;
178 ],
179 wx_cv_explicit=no,
180 wx_cv_explicit=yes
181 )
182 ],
183 wx_cv_explicit=no
184 )
185
186 AC_LANG_RESTORE
187 ])
188
189 if test "$wx_cv_explicit" = "yes"; then
190 AC_DEFINE(HAVE_EXPLICIT)
191 fi
192])
193
194dnl ---------------------------------------------------------------------------
195dnl a slightly better AC_C_BIGENDIAN macro which allows cross-compiling
196dnl ---------------------------------------------------------------------------
197
198AC_DEFUN([WX_C_BIGENDIAN],
199[AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian,
200[ac_cv_c_bigendian=unknown
201# See if sys/param.h defines the BYTE_ORDER macro.
202AC_TRY_COMPILE([#include <sys/types.h>
203#include <sys/param.h>], [
204#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
205 bogus endian macros
206#endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
207AC_TRY_COMPILE([#include <sys/types.h>
208#include <sys/param.h>], [
209#if BYTE_ORDER != BIG_ENDIAN
210 not big endian
211#endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
212if test $ac_cv_c_bigendian = unknown; then
213AC_TRY_RUN([main () {
214 /* Are we little or big endian? From Harbison&Steele. */
215 union
216 {
217 long l;
218 char c[sizeof (long)];
219 } u;
220 u.l = 1;
221 exit (u.c[sizeof (long) - 1] == 1);
222}], [ac_cv_c_bigendian=no], [ac_cv_c_bigendian=yes], [ac_cv_c_bigendian=unknown])
223fi])
224if test $ac_cv_c_bigendian = unknown; then
225 AC_MSG_WARN([Assuming little-endian target machine - this may be overriden by adding the line "ac_cv_c_bigendian=${ac_cv_c_bigendian='yes'}" to config.cache file])
226fi
227if test $ac_cv_c_bigendian = yes; then
228 AC_DEFINE(WORDS_BIGENDIAN)
229fi
230])
231
232dnl ---------------------------------------------------------------------------
233dnl override AC_ARG_ENABLE/WITH to cache the results in .cache file
234dnl ---------------------------------------------------------------------------
235
236AC_DEFUN([WX_ARG_CACHE_INIT],
237 [
238 wx_arg_cache_file="configarg.cache"
239 echo "loading argument cache $wx_arg_cache_file"
240 rm -f ${wx_arg_cache_file}.tmp
241 touch ${wx_arg_cache_file}.tmp
242 touch ${wx_arg_cache_file}
243 ])
244
245AC_DEFUN([WX_ARG_CACHE_FLUSH],
246 [
247 echo "saving argument cache $wx_arg_cache_file"
248 mv ${wx_arg_cache_file}.tmp ${wx_arg_cache_file}
249 ])
250
251dnl this macro checks for a three-valued command line --with argument:
252dnl possible arguments are 'yes', 'no', 'sys', or 'builtin'
253dnl usage: WX_ARG_SYS_WITH(option, helpmessage, variable-name)
254AC_DEFUN([WX_ARG_SYS_WITH],
255 [
256 AC_MSG_CHECKING([for --with-$1])
257 no_cache=0
258 AC_ARG_WITH($1, [$2],
259 [
260 if test "$withval" = yes; then
261 ac_cv_use_$1='$3=yes'
262 elif test "$withval" = no; then
263 ac_cv_use_$1='$3=no'
264 elif test "$withval" = sys; then
265 ac_cv_use_$1='$3=sys'
266 elif test "$withval" = builtin; then
267 ac_cv_use_$1='$3=builtin'
268 else
269 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
270 fi
271 ],
272 [
273 LINE=`grep "$3" ${wx_arg_cache_file}`
274 if test "x$LINE" != x ; then
275 eval "DEFAULT_$LINE"
276 else
277 no_cache=1
278 fi
279
280 ac_cv_use_$1='$3='$DEFAULT_$3
281 ])
282
283 eval "$ac_cv_use_$1"
284 if test "$no_cache" != 1; then
285 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
286 fi
287
288 if test "$$3" = yes; then
289 AC_MSG_RESULT(yes)
290 elif test "$$3" = no; then
291 AC_MSG_RESULT(no)
292 elif test "$$3" = sys; then
293 AC_MSG_RESULT([system version])
294 elif test "$$3" = builtin; then
295 AC_MSG_RESULT([builtin version])
296 else
297 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
298 fi
299 ])
300
301dnl this macro checks for a command line argument and caches the result
302dnl usage: WX_ARG_WITH(option, helpmessage, variable-name)
303AC_DEFUN([WX_ARG_WITH],
304 [
305 AC_MSG_CHECKING([for --with-$1])
306 no_cache=0
307 AC_ARG_WITH($1, [$2],
308 [
309 if test "$withval" = yes; then
310 ac_cv_use_$1='$3=yes'
311 else
312 ac_cv_use_$1='$3=no'
313 fi
314 ],
315 [
316 LINE=`grep "$3" ${wx_arg_cache_file}`
317 if test "x$LINE" != x ; then
318 eval "DEFAULT_$LINE"
319 else
320 no_cache=1
321 fi
322
323 ac_cv_use_$1='$3='$DEFAULT_$3
324 ])
325
326 eval "$ac_cv_use_$1"
327 if test "$no_cache" != 1; then
328 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
329 fi
330
331 if test "$$3" = yes; then
332 AC_MSG_RESULT(yes)
333 else
334 AC_MSG_RESULT(no)
335 fi
336 ])
337
338dnl like WX_ARG_WITH but uses AC_ARG_ENABLE instead of AC_ARG_WITH
339dnl usage: WX_ARG_ENABLE(option, helpmessage, variable-name, enablestring)
340dnl
341dnl enablestring is a hack and allows to show "checking for --disable-foo"
342dnl message when running configure instead of the default "checking for
343dnl --enable-foo" one whih is useful for the options enabled by default
344AC_DEFUN([WX_ARG_ENABLE],
345 [
346 enablestring=$4
347 AC_MSG_CHECKING([for --${enablestring:-enable}-$1])
348 no_cache=0
349 AC_ARG_ENABLE($1, [$2],
350 [
351 if test "$enableval" = yes; then
352 ac_cv_use_$1='$3=yes'
353 else
354 ac_cv_use_$1='$3=no'
355 fi
356 ],
357 [
358 LINE=`grep "$3" ${wx_arg_cache_file}`
359 if test "x$LINE" != x ; then
360 eval "DEFAULT_$LINE"
361 else
362 no_cache=1
363 fi
364
365 ac_cv_use_$1='$3='$DEFAULT_$3
366 ])
367
368 eval "$ac_cv_use_$1"
369 if test "$no_cache" != 1; then
370 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
371 fi
372
373 if test "$$3" = yes; then
374 AC_MSG_RESULT(yes)
375 else
376 AC_MSG_RESULT(no)
377 fi
378 ])
379
380
381dnl ===========================================================================
382dnl Linker features test
383dnl ===========================================================================
384
385dnl ---------------------------------------------------------------------------
386dnl WX_VERSIONED_SYMBOLS checks whether the linker can create versioned
387dnl symbols. If it can, sets LDFLAGS_VERSIONING to $CXX flags needed to use
388dnl version script file named versionfile
389dnl
390dnl call WX_VERSIONED_SYMBOLS(versionfile)
391dnl ---------------------------------------------------------------------------
392AC_DEFUN([WX_VERSIONED_SYMBOLS],
393[
394 found_versioning=no
395
396 dnl FIXME - doesn't work, Solaris linker doesn't accept wildcards
397 dnl in the script.
398 dnl dnl Check for known non-gcc cases:
399 dnl case "${host}" in
400 dnl *-*-solaris2* )
401 dnl if test "x$GCC" != "xyes" ; then
402 dnl LDFLAGS_VERSIONING="-M $1"
403 dnl found_versioning=yes
404 dnl fi
405 dnl ;;
406 dnl esac
407
408 dnl Generic check for GCC or GCC-like behaviour (Intel C++, GCC):
409 if test $found_versioning = no ; then
410 AC_CACHE_CHECK([if the linker accepts --version-script], wx_cv_version_script,
411 [
412 echo "VER_1 { *; };" >conftest.sym
413 echo "int main() { return 0; }" >conftest.cpp
414
415 if AC_TRY_COMMAND([
416 $CXX -o conftest.output $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.cpp
417 -Wl,--version-script,conftest.sym >/dev/null 2>conftest.stderr]) ; then
418 if test -s conftest.stderr ; then
419 wx_cv_version_script=no
420 else
421 wx_cv_version_script=yes
422 fi
423 else
424 wx_cv_version_script=no
425 fi
426 rm -f conftest.output conftest.stderr conftest.sym conftest.cpp
427 ])
428 if test $wx_cv_version_script = yes ; then
429 LDFLAGS_VERSIONING="-Wl,--version-script,$1"
430 fi
431 fi
432])
433
434
435dnl ===========================================================================
436dnl "3rd party" macros included here because they are not widely available
437dnl ===========================================================================
438
439dnl ---------------------------------------------------------------------------
440dnl test for availability of iconv()
441dnl ---------------------------------------------------------------------------
442
443dnl From Bruno Haible.
444
445AC_DEFUN([AM_ICONV],
446[
447 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
448 dnl those with the standalone portable GNU libiconv installed).
449
450 AC_ARG_WITH([libiconv-prefix],
451[ --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib], [
452 for dir in `echo "$withval" | tr : ' '`; do
453 if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
454 if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
455 done
456 ])
457
458 AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
459 am_cv_func_iconv="no, consider installing GNU libiconv"
460 am_cv_lib_iconv=no
461 AC_TRY_LINK([#include <stdlib.h>
462#include <iconv.h>],
463 [iconv_t cd = iconv_open("","");
464 iconv(cd,NULL,NULL,NULL,NULL);
465 iconv_close(cd);],
466 am_cv_func_iconv=yes)
467 if test "$am_cv_func_iconv" != yes; then
468 am_save_LIBS="$LIBS"
469 LIBS="$LIBS -liconv"
470 AC_TRY_LINK([#include <stdlib.h>
471#include <iconv.h>],
472 [iconv_t cd = iconv_open("","");
473 iconv(cd,NULL,NULL,NULL,NULL);
474 iconv_close(cd);],
475 am_cv_lib_iconv=yes
476 am_cv_func_iconv=yes)
477 LIBS="$am_save_LIBS"
478 fi
479 ])
480 if test "$am_cv_func_iconv" = yes; then
481 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
482 AC_CACHE_CHECK([if iconv needs const], wx_cv_func_iconv_const,
483 AC_TRY_COMPILE([
484#include <stdlib.h>
485#include <iconv.h>
486extern
487#ifdef __cplusplus
488"C"
489#endif
490#if defined(__STDC__) || defined(__cplusplus)
491size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
492#else
493size_t iconv();
494#endif
495 ],
496 [],
497 wx_cv_func_iconv_const="no",
498 wx_cv_func_iconv_const="yes"
499 )
500 )
501
502 iconv_const=
503 if test "x$wx_cv_func_iconv_const" = "xyes"; then
504 iconv_const="const"
505 fi
506
507 AC_DEFINE_UNQUOTED(ICONV_CONST, $iconv_const,
508 [Define as const if the declaration of iconv() needs const.])
509 fi
510 LIBICONV=
511 if test "$am_cv_lib_iconv" = yes; then
512 LIBICONV="-liconv"
513 fi
514 AC_SUBST(LIBICONV)
515])
516
517dnl ---------------------------------------------------------------------------
518dnl AC_SYS_LARGEFILE (partly based on the code from autoconf 2.5x)
519dnl ---------------------------------------------------------------------------
520
521dnl WX_SYS_LARGEFILE_TEST
522dnl
523dnl NB: original autoconf test was checking if compiler supported 6 bit off_t
524dnl arithmetic properly but this failed miserably with gcc under Linux
525dnl whereas the system still supports 64 bit files, so now simply check
526dnl that off_t is big enough
527define(WX_SYS_LARGEFILE_TEST,
528[typedef struct {
529 unsigned int field: sizeof(off_t) == 8;
530} wxlf;
531])
532
533
534dnl WX_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR)
535define(WX_SYS_LARGEFILE_MACRO_VALUE,
536[
537 AC_CACHE_CHECK([for $1 value needed for large files], [$3],
538 [
539 AC_TRY_COMPILE([#define $1 $2
540 #include <sys/types.h>],
541 WX_SYS_LARGEFILE_TEST,
542 [$3=$2],
543 [$3=no])
544 ]
545 )
546
547 if test "$$3" != no; then
548 wx_largefile=yes
549 AC_DEFINE_UNQUOTED([$1], [$$3])
550 fi
551])
552
553
554dnl AC_SYS_LARGEFILE
555dnl ----------------
556dnl By default, many hosts won't let programs access large files;
557dnl one must use special compiler options to get large-file access to work.
558dnl For more details about this brain damage please see:
559dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
560AC_DEFUN([AC_SYS_LARGEFILE],
561[AC_ARG_ENABLE(largefile,
562 [ --disable-largefile omit support for large files])
563if test "$enable_largefile" != no; then
564 dnl _FILE_OFFSET_BITS==64 is needed for Linux, Solaris, ...
565 dnl _LARGE_FILES -- for AIX
566 wx_largefile=no
567 WX_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64, ac_cv_sys_file_offset_bits)
568 if test "x$wx_largefile" != "xyes"; then
569 WX_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, ac_cv_sys_large_files)
570 fi
571
572 AC_MSG_CHECKING(if large file support is available)
573 if test "x$wx_largefile" = "xyes"; then
574 AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
575 fi
576 AC_MSG_RESULT($wx_largefile)
577fi
578])
579
580
581dnl Available from the GNU Autoconf Macro Archive at:
582dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_const_cast.html
583dnl
584AC_DEFUN([AC_CXX_CONST_CAST],
585[AC_CACHE_CHECK(whether the compiler supports const_cast<>,
586ac_cv_cxx_const_cast,
587[AC_LANG_SAVE
588 AC_LANG_CPLUSPLUS
589 AC_TRY_COMPILE(,[int x = 0;const int& y = x;int& z = const_cast<int&>(y);return z;],
590 ac_cv_cxx_const_cast=yes, ac_cv_cxx_const_cast=no)
591 AC_LANG_RESTORE
592])
593if test "$ac_cv_cxx_const_cast" = yes; then
594 AC_DEFINE(HAVE_CONST_CAST,,[define if the compiler supports const_cast<>])
595fi
596])
597
598dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_reinterpret_cast.html
599AC_DEFUN([AC_CXX_REINTERPRET_CAST],
600[AC_CACHE_CHECK(whether the compiler supports reinterpret_cast<>,
601ac_cv_cxx_reinterpret_cast,
602[AC_LANG_SAVE
603 AC_LANG_CPLUSPLUS
604 AC_TRY_COMPILE([#include <typeinfo>
605class Base { public : Base () {} virtual void f () = 0;};
606class Derived : public Base { public : Derived () {} virtual void f () {} };
607class Unrelated { public : Unrelated () {} };
608int g (Unrelated&) { return 0; }],[
609Derived d;Base& b=d;Unrelated& e=reinterpret_cast<Unrelated&>(b);return g(e);],
610 ac_cv_cxx_reinterpret_cast=yes, ac_cv_cxx_reinterpret_cast=no)
611 AC_LANG_RESTORE
612])
613if test "$ac_cv_cxx_reinterpret_cast" = yes; then
614 AC_DEFINE(HAVE_REINTERPRET_CAST,,
615 [define if the compiler supports reinterpret_cast<>])
616fi
617])
618
619dnl and http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_static_cast.html
620AC_DEFUN([AC_CXX_STATIC_CAST],
621[AC_CACHE_CHECK(whether the compiler supports static_cast<>,
622ac_cv_cxx_static_cast,
623[AC_LANG_SAVE
624 AC_LANG_CPLUSPLUS
625 AC_TRY_COMPILE([#include <typeinfo>
626class Base { public : Base () {} virtual void f () = 0; };
627class Derived : public Base { public : Derived () {} virtual void f () {} };
628int g (Derived&) { return 0; }],[
629Derived d; Base& b = d; Derived& s = static_cast<Derived&> (b); return g (s);],
630 ac_cv_cxx_static_cast=yes, ac_cv_cxx_static_cast=no)
631 AC_LANG_RESTORE
632])
633if test "$ac_cv_cxx_static_cast" = yes; then
634 AC_DEFINE(HAVE_STATIC_CAST,, [define if the compiler supports static_cast<>])
635fi
636])