~ubuntu-dev/wxwidgets2.6/upstream-debian

« back to all changes in this revision

Viewing changes to acinclude.m4

  • Committer: Daniel T Chen
  • Date: 2006-06-26 10:15:11 UTC
  • Revision ID: crimsun@ubuntu.com-20060626101511-a4436cec4c6d9b35
ImportĀ DebianĀ 2.6.3.2.1

Show diffs side-by-side

added added

removed removed

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