Update to include recent acinclude.m4 changes.
[wxWidgets.git] / aclocal.m4
1 # aclocal.m4 generated automatically by aclocal 1.6.3 -*- Autoconf -*-
2
3 # Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002
4 # Free Software Foundation, Inc.
5 # This file is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 dnl ---------------------------------------------------------------------------
15 dnl
16 dnl Macros for configure.in for wxWindows by Robert Roebling, Phil Blecker,
17 dnl Vadim Zeitlin and Ron Lee
18 dnl
19 dnl This script is under the wxWindows licence.
20 dnl
21 dnl Version: $Id$
22 dnl ---------------------------------------------------------------------------
23
24 dnl ===========================================================================
25 dnl macros to detect specialty compiler options
26 dnl ===========================================================================
27
28 dnl Figure out if we need to pass -ext o to compiler (MetroWerks)
29 AC_DEFUN([AC_WX_METROWERKS_EXTO],
30 [AC_CACHE_CHECK([if the _AC_LANG compiler requires -ext o], wx_cv_[]_AC_LANG_ABBREV[]_exto,
31 dnl First create an empty conf test
32 [AC_LANG_CONFTEST([AC_LANG_PROGRAM()])
33 dnl Now remove .o and .c.o or .cc.o
34 rm -f conftest.$ac_objext conftest.$ac_ext.o
35 dnl Now compile the test
36 AS_IF([AC_TRY_EVAL(ac_compile)],
37 dnl If the test succeeded look for conftest.c.o or conftest.cc.o
38 [for ac_file in `(ls conftest.* 2>/dev/null)`; do
39     case $ac_file in
40         conftest.$ac_ext.o)
41             wx_cv_[]_AC_LANG_ABBREV[]_exto="-ext o"
42             ;;
43         *)
44             ;;
45     esac
46 done],
47 [AC_MSG_FAILURE([cannot figure out if compiler needs -ext o: cannot compile])
48 ]) dnl AS_IF
49
50 rm -f conftest.$ac_ext.o conftest.$ac_objext conftest.$ac_ext
51 ]) dnl AC_CACHE_CHECK
52
53 if test "x$wx_cv_[]_AC_LANG_ABBREV[]_exto" '!=' "x"; then
54     if test "[]_AC_LANG_ABBREV[]" = "c"; then
55         CFLAGS="$wx_cv_[]_AC_LANG_ABBREV[]_exto $CFLAGS"
56     fi
57     if test "[]_AC_LANG_ABBREV[]" = "cxx"; then
58         CXXFLAGS="$wx_cv_[]_AC_LANG_ABBREV[]_exto $CXXFLAGS"
59     fi
60 fi
61 ]) dnl AC_DEFUN
62
63
64 dnl Based on autoconf _AC_LANG_COMPILER_GNU
65 AC_DEFUN([_AC_WX_LANG_COMPILER_XLC],
66 [AC_CACHE_CHECK([whether we are using the IBM xlC _AC_LANG compiler],
67     [wx_cv_[]_AC_LANG_ABBREV[]_compiler_xlc],
68     [AC_TRY_COMPILE([],[#ifndef __xlC__
69        choke me
70 #endif
71 ],
72         [wx_compiler_xlc=yes],
73         [wx_compiler_xlc=no])
74     wx_cv_[]_AC_LANG_ABBREV[]_compiler_xlc=$wx_compiler_xlc
75     ])
76 ])
77
78 dnl Loosely based on autoconf AC_PROG_CC
79 AC_DEFUN([AC_WX_PROG_XLCC],
80 [AC_LANG_PUSH(C)
81 _AC_WX_LANG_COMPILER_XLC
82 XLCC=`test $wx_compiler_xlc = yes && echo yes`
83 AC_LANG_POP(C)
84 ])
85
86 dnl Loosely based on autoconf AC_PROG_CXX
87 AC_DEFUN([AC_WX_PROG_XLCXX],
88 [AC_LANG_PUSH(C++)
89 _AC_WX_LANG_COMPILER_XLC
90 XLCXX=`test $wx_compiler_xlc = yes && echo yes`
91 AC_LANG_POP(C++)
92 ])
93
94
95 dnl ===========================================================================
96 dnl macros to find the a file in the list of include/lib paths
97 dnl ===========================================================================
98
99 dnl ---------------------------------------------------------------------------
100 dnl call WX_PATH_FIND_INCLUDES(search path, header name), sets ac_find_includes
101 dnl to the full name of the file that was found or leaves it empty if not found
102 dnl ---------------------------------------------------------------------------
103 AC_DEFUN([WX_PATH_FIND_INCLUDES],
104 [
105 ac_find_includes=
106 for ac_dir in $1 /usr/include;
107   do
108     if test -f "$ac_dir/$2"; then
109       ac_find_includes=$ac_dir
110       break
111     fi
112   done
113 ])
114
115 dnl ---------------------------------------------------------------------------
116 dnl call WX_PATH_FIND_LIBRARIES(search path, header name), sets ac_find_libraries
117 dnl to the full name of the file that was found or leaves it empty if not found
118 dnl ---------------------------------------------------------------------------
119 AC_DEFUN([WX_PATH_FIND_LIBRARIES],
120 [
121 ac_find_libraries=
122 for ac_dir in $1 /usr/lib;
123   do
124     for ac_extension in a so sl dylib; do
125       if test -f "$ac_dir/lib$2.$ac_extension"; then
126         ac_find_libraries=$ac_dir
127         break 2
128       fi
129     done
130   done
131 ])
132
133 dnl ---------------------------------------------------------------------------
134 dnl Path to include, already defined
135 dnl ---------------------------------------------------------------------------
136 AC_DEFUN([WX_INCLUDE_PATH_EXIST],
137 [
138   dnl never add -I/usr/include to the CPPFLAGS
139   if test "x$1" = "x/usr/include"; then
140     ac_path_to_include=""
141   else
142     echo "$2" | grep "\-I$1" > /dev/null
143     result=$?
144     if test $result = 0; then
145       ac_path_to_include=""
146     else
147       ac_path_to_include=" -I$1"
148     fi
149   fi
150 ])
151
152 dnl ---------------------------------------------------------------------------
153 dnl Path to link, already defined
154 dnl ---------------------------------------------------------------------------
155 AC_DEFUN([WX_LINK_PATH_EXIST],
156 [
157   echo "$2" | grep "\-L$1" > /dev/null
158   result=$?
159   if test $result = 0; then
160     ac_path_to_link=""
161   else
162     ac_path_to_link=" -L$1"
163   fi
164 ])
165
166 dnl ===========================================================================
167 dnl C++ features test
168 dnl ===========================================================================
169
170 dnl ---------------------------------------------------------------------------
171 dnl WX_CPP_NEW_HEADERS checks whether the compiler has "new" <iostream> header
172 dnl or only the old <iostream.h> one - it may be generally assumed that if
173 dnl <iostream> exists, the other "new" headers (without .h) exist too.
174 dnl
175 dnl call WX_CPP_NEW_HEADERS(actiof-if-true, action-if-false)
176 dnl ---------------------------------------------------------------------------
177
178 AC_DEFUN([WX_CPP_NEW_HEADERS],
179 [
180     AC_LANG_SAVE
181     AC_LANG_CPLUSPLUS
182
183     AC_CHECK_HEADERS(iostream)
184
185     if test "$ac_cv_header_iostream" = "yes" ; then
186       ifelse([$1], , :, [$1])
187     else
188       ifelse([$2], , :, [$2])
189     fi
190
191     AC_LANG_RESTORE
192 ])
193
194 dnl ---------------------------------------------------------------------------
195 dnl WX_CPP_BOOL checks whether the C++ compiler has a built in bool type
196 dnl
197 dnl call WX_CPP_BOOL - will define HAVE_BOOL if the compiler supports bool
198 dnl ---------------------------------------------------------------------------
199
200 AC_DEFUN([WX_CPP_BOOL],
201 [
202   AC_CACHE_CHECK([if C++ compiler supports bool], wx_cv_cpp_bool,
203   [
204     AC_LANG_SAVE
205     AC_LANG_CPLUSPLUS
206
207     AC_TRY_COMPILE(
208       [
209       ],
210       [
211         bool b = true;
212
213         return 0;
214       ],
215       [
216         wx_cv_cpp_bool=yes
217       ],
218       [
219         wx_cv_cpp_bool=no
220       ]
221     )
222
223     AC_LANG_RESTORE
224   ])
225
226   if test "$wx_cv_cpp_bool" = "yes"; then
227     AC_DEFINE(HAVE_BOOL)
228   fi
229 ])
230
231 dnl ---------------------------------------------------------------------------
232 dnl WX_CPP_EXPLICIT checks whether the C++ compiler support the explicit
233 dnl keyword and defines HAVE_EXPLICIT if this is the case
234 dnl ---------------------------------------------------------------------------
235
236 AC_DEFUN([WX_CPP_EXPLICIT],
237 [
238   AC_CACHE_CHECK([if C++ compiler supports the explicit keyword],
239                  wx_cv_explicit,
240   [
241     AC_LANG_SAVE
242     AC_LANG_CPLUSPLUS
243
244     dnl do the test in 2 steps: first check that the compiler knows about the
245     dnl explicit keyword at all and then verify that it really honours it
246     AC_TRY_COMPILE(
247       [
248         class Foo { public: explicit Foo(int) {} };
249       ],
250       [
251         return 0;
252       ],
253       [
254         AC_TRY_COMPILE(
255             [
256                 class Foo { public: explicit Foo(int) {} };
257                 static void TakeFoo(const Foo& foo) { }
258             ],
259             [
260                 TakeFoo(17);
261                 return 0;
262             ],
263             wx_cv_explicit=no,
264             wx_cv_explicit=yes
265         )
266       ],
267       wx_cv_explicit=no
268     )
269
270     AC_LANG_RESTORE
271   ])
272
273   if test "$wx_cv_explicit" = "yes"; then
274     AC_DEFINE(HAVE_EXPLICIT)
275   fi
276 ])
277
278 dnl ---------------------------------------------------------------------------
279 dnl a slightly better AC_C_BIGENDIAN macro which allows cross-compiling
280 dnl ---------------------------------------------------------------------------
281
282 AC_DEFUN([WX_C_BIGENDIAN],
283 [AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian,
284 [ac_cv_c_bigendian=unknown
285 # See if sys/param.h defines the BYTE_ORDER macro.
286 AC_TRY_COMPILE([#include <sys/types.h>
287 #include <sys/param.h>], [
288 #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
289  bogus endian macros
290 #endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
291 AC_TRY_COMPILE([#include <sys/types.h>
292 #include <sys/param.h>], [
293 #if BYTE_ORDER != BIG_ENDIAN
294  not big endian
295 #endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
296 if test $ac_cv_c_bigendian = unknown; then
297 AC_TRY_RUN([main () {
298   /* Are we little or big endian?  From Harbison&Steele.  */
299   union
300   {
301     long l;
302     char c[sizeof (long)];
303   } u;
304   u.l = 1;
305   exit (u.c[sizeof (long) - 1] == 1);
306 }], [ac_cv_c_bigendian=no], [ac_cv_c_bigendian=yes], [ac_cv_c_bigendian=unknown])
307 fi])
308 if test $ac_cv_c_bigendian = unknown; then
309   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])
310 fi
311 if test $ac_cv_c_bigendian = yes; then
312   AC_DEFINE(WORDS_BIGENDIAN)
313 fi
314 ])
315
316 dnl ---------------------------------------------------------------------------
317 dnl override AC_ARG_ENABLE/WITH to cache the results in .cache file
318 dnl ---------------------------------------------------------------------------
319
320 AC_DEFUN([WX_ARG_CACHE_INIT],
321         [
322           wx_arg_cache_file="configarg.cache"
323           echo "loading argument cache $wx_arg_cache_file"
324           rm -f ${wx_arg_cache_file}.tmp
325           touch ${wx_arg_cache_file}.tmp
326           touch ${wx_arg_cache_file}
327         ])
328
329 AC_DEFUN([WX_ARG_CACHE_FLUSH],
330         [
331           echo "saving argument cache $wx_arg_cache_file"
332           mv ${wx_arg_cache_file}.tmp ${wx_arg_cache_file}
333         ])
334
335 dnl this macro checks for a three-valued command line --with argument:
336 dnl   possible arguments are 'yes', 'no', 'sys', or 'builtin'
337 dnl usage: WX_ARG_SYS_WITH(option, helpmessage, variable-name)
338 AC_DEFUN([WX_ARG_SYS_WITH],
339         [
340           AC_MSG_CHECKING([for --with-$1])
341           no_cache=0
342           AC_ARG_WITH($1, [$2],
343                       [
344                         if test "$withval" = yes; then
345                           ac_cv_use_$1='$3=yes'
346                         elif test "$withval" = no; then
347                           ac_cv_use_$1='$3=no'
348                         elif test "$withval" = sys; then
349                           ac_cv_use_$1='$3=sys'
350                         elif test "$withval" = builtin; then
351                           ac_cv_use_$1='$3=builtin'
352                         else
353                           AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
354                         fi
355                       ],
356                       [
357                         LINE=`grep "$3" ${wx_arg_cache_file}`
358                         if test "x$LINE" != x ; then
359                           eval "DEFAULT_$LINE"
360                         else
361                           no_cache=1
362                         fi
363
364                         ac_cv_use_$1='$3='$DEFAULT_$3
365                       ])
366
367           eval "$ac_cv_use_$1"
368           if test "$no_cache" != 1; then
369             echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
370           fi
371
372           if test "$$3" = yes; then
373             AC_MSG_RESULT(yes)
374           elif test "$$3" = no; then
375             AC_MSG_RESULT(no)
376           elif test "$$3" = sys; then
377             AC_MSG_RESULT([system version])
378           elif test "$$3" = builtin; then
379             AC_MSG_RESULT([builtin version])
380           else
381             AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
382           fi
383         ])
384
385 dnl this macro checks for a command line argument and caches the result
386 dnl usage: WX_ARG_WITH(option, helpmessage, variable-name)
387 AC_DEFUN([WX_ARG_WITH],
388         [
389           AC_MSG_CHECKING([for --with-$1])
390           no_cache=0
391           AC_ARG_WITH($1, [$2],
392                       [
393                         if test "$withval" = yes; then
394                           ac_cv_use_$1='$3=yes'
395                         else
396                           ac_cv_use_$1='$3=no'
397                         fi
398                       ],
399                       [
400                         LINE=`grep "$3" ${wx_arg_cache_file}`
401                         if test "x$LINE" != x ; then
402                           eval "DEFAULT_$LINE"
403                         else
404                           no_cache=1
405                         fi
406
407                         ac_cv_use_$1='$3='$DEFAULT_$3
408                       ])
409
410           eval "$ac_cv_use_$1"
411           if test "$no_cache" != 1; then
412             echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
413           fi
414
415           if test "$$3" = yes; then
416             AC_MSG_RESULT(yes)
417           else
418             AC_MSG_RESULT(no)
419           fi
420         ])
421
422 dnl like WX_ARG_WITH but uses AC_ARG_ENABLE instead of AC_ARG_WITH
423 dnl usage: WX_ARG_ENABLE(option, helpmessage, variable-name, enablestring)
424 dnl
425 dnl enablestring is a hack and allows to show "checking for --disable-foo"
426 dnl message when running configure instead of the default "checking for
427 dnl --enable-foo" one whih is useful for the options enabled by default
428 AC_DEFUN([WX_ARG_ENABLE],
429         [
430           enablestring=$4
431           AC_MSG_CHECKING([for --${enablestring:-enable}-$1])
432           no_cache=0
433           AC_ARG_ENABLE($1, [$2],
434                         [
435                           if test "$enableval" = yes; then
436                             ac_cv_use_$1='$3=yes'
437                           else
438                             ac_cv_use_$1='$3=no'
439                           fi
440                         ],
441                         [
442                           LINE=`grep "$3" ${wx_arg_cache_file}`
443                           if test "x$LINE" != x ; then
444                             eval "DEFAULT_$LINE"
445                           else
446                             no_cache=1
447                           fi
448
449                           ac_cv_use_$1='$3='$DEFAULT_$3
450                         ])
451
452           eval "$ac_cv_use_$1"
453           if test "$no_cache" != 1; then
454             echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
455           fi
456
457           if test "$$3" = yes; then
458             AC_MSG_RESULT(yes)
459           else
460             AC_MSG_RESULT(no)
461           fi
462         ])
463
464
465 dnl ===========================================================================
466 dnl Linker features test
467 dnl ===========================================================================
468
469 dnl ---------------------------------------------------------------------------
470 dnl WX_VERSIONED_SYMBOLS checks whether the linker can create versioned
471 dnl symbols. If it can, sets LDFLAGS_VERSIONING to $CXX flags needed to use
472 dnl version script file named versionfile
473 dnl
474 dnl call WX_VERSIONED_SYMBOLS(versionfile)
475 dnl ---------------------------------------------------------------------------
476 AC_DEFUN([WX_VERSIONED_SYMBOLS],
477 [
478   found_versioning=no
479
480   dnl FIXME - doesn't work, Solaris linker doesn't accept wildcards
481   dnl         in the script.
482   dnl dnl Check for known non-gcc cases:
483   dnl case "${host}" in
484   dnl   *-*-solaris2* )
485   dnl     if test "x$GCC" != "xyes" ; then
486   dnl         LDFLAGS_VERSIONING="-M $1"
487   dnl         found_versioning=yes
488   dnl     fi
489   dnl   ;;
490   dnl esac
491   
492   dnl Generic check for GCC or GCC-like behaviour (Intel C++, GCC):
493   if test $found_versioning = no ; then
494       AC_CACHE_CHECK([if the linker accepts --version-script], wx_cv_version_script,
495       [
496         echo "VER_1 { *; };" >conftest.sym
497         echo "int main() { return 0; }" >conftest.cpp
498   
499         if AC_TRY_COMMAND([
500                 $CXX -o conftest.output $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.cpp
501                 -Wl,--version-script,conftest.sym >/dev/null 2>conftest.stderr]) ; then
502           if test -s conftest.stderr ; then
503               wx_cv_version_script=no
504           else
505               wx_cv_version_script=yes
506           fi
507         else
508           wx_cv_version_script=no
509         fi
510         rm -f conftest.output conftest.stderr conftest.sym conftest.cpp
511       ])
512       if test $wx_cv_version_script = yes ; then
513         LDFLAGS_VERSIONING="-Wl,--version-script,$1"
514       fi
515   fi
516 ])
517
518
519 dnl ===========================================================================
520 dnl "3rd party" macros included here because they are not widely available
521 dnl ===========================================================================
522
523 dnl ---------------------------------------------------------------------------
524 dnl test for availability of iconv()
525 dnl ---------------------------------------------------------------------------
526
527 dnl From Bruno Haible.
528
529 AC_DEFUN([AM_ICONV],
530 [
531   dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
532   dnl those with the standalone portable GNU libiconv installed).
533
534   AC_ARG_WITH([libiconv-prefix],
535 [  --with-libiconv-prefix=DIR  search for libiconv in DIR/include and DIR/lib], [
536     for dir in `echo "$withval" | tr : ' '`; do
537       if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
538       if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
539     done
540    ])
541
542   AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
543     am_cv_func_iconv="no, consider installing GNU libiconv"
544     am_cv_lib_iconv=no
545     AC_TRY_LINK([#include <stdlib.h>
546 #include <iconv.h>],
547       [iconv_t cd = iconv_open("","");
548        iconv(cd,NULL,NULL,NULL,NULL);
549        iconv_close(cd);],
550       am_cv_func_iconv=yes)
551     if test "$am_cv_func_iconv" != yes; then
552       am_save_LIBS="$LIBS"
553       LIBS="$LIBS -liconv"
554       AC_TRY_LINK([#include <stdlib.h>
555 #include <iconv.h>],
556         [iconv_t cd = iconv_open("","");
557          iconv(cd,NULL,NULL,NULL,NULL);
558          iconv_close(cd);],
559         am_cv_lib_iconv=yes
560         am_cv_func_iconv=yes)
561       LIBS="$am_save_LIBS"
562     fi
563   ])
564   if test "$am_cv_func_iconv" = yes; then
565     AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
566     AC_CACHE_CHECK([if iconv needs const], wx_cv_func_iconv_const,
567       AC_TRY_COMPILE([
568 #include <stdlib.h>
569 #include <iconv.h>
570 extern
571 #ifdef __cplusplus
572 "C"
573 #endif
574 #if defined(__STDC__) || defined(__cplusplus)
575 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
576 #else
577 size_t iconv();
578 #endif
579         ],
580         [],
581         wx_cv_func_iconv_const="no",
582         wx_cv_func_iconv_const="yes"
583       )
584     )
585
586     iconv_const=
587     if test "x$wx_cv_func_iconv_const" = "xyes"; then
588         iconv_const="const"
589     fi
590
591     AC_DEFINE_UNQUOTED(ICONV_CONST, $iconv_const,
592       [Define as const if the declaration of iconv() needs const.])
593   fi
594   LIBICONV=
595   if test "$am_cv_lib_iconv" = yes; then
596     LIBICONV="-liconv"
597   fi
598   AC_SUBST(LIBICONV)
599 ])
600
601 dnl ---------------------------------------------------------------------------
602 dnl AC_SYS_LARGEFILE (partly based on the code from autoconf 2.5x)
603 dnl ---------------------------------------------------------------------------
604
605 dnl WX_SYS_LARGEFILE_TEST
606 dnl
607 dnl NB: original autoconf test was checking if compiler supported 6 bit off_t
608 dnl     arithmetic properly but this failed miserably with gcc under Linux
609 dnl     whereas the system still supports 64 bit files, so now simply check
610 dnl     that off_t is big enough
611 define(WX_SYS_LARGEFILE_TEST,
612 [typedef struct {
613     unsigned int field: sizeof(off_t) == 8;
614 } wxlf;
615 ])
616
617
618 dnl WX_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR)
619 define(WX_SYS_LARGEFILE_MACRO_VALUE,
620 [
621     AC_CACHE_CHECK([for $1 value needed for large files], [$3],
622         [
623           AC_TRY_COMPILE([#define $1 $2
624                           #include <sys/types.h>],
625                          WX_SYS_LARGEFILE_TEST,
626                          [$3=$2],
627                          [$3=no])
628         ]
629     )
630
631     if test "$$3" != no; then
632         wx_largefile=yes
633         AC_DEFINE_UNQUOTED([$1], [$$3])
634     fi
635 ])
636
637
638 dnl AC_SYS_LARGEFILE
639 dnl ----------------
640 dnl By default, many hosts won't let programs access large files;
641 dnl one must use special compiler options to get large-file access to work.
642 dnl For more details about this brain damage please see:
643 dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
644 AC_DEFUN([AC_SYS_LARGEFILE],
645 [AC_ARG_ENABLE(largefile,
646                [  --disable-largefile     omit support for large files])
647 if test "$enable_largefile" != no; then
648     dnl _FILE_OFFSET_BITS==64 is needed for Linux, Solaris, ...
649     dnl _LARGE_FILES -- for AIX
650     wx_largefile=no
651     WX_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64, ac_cv_sys_file_offset_bits)
652     if test "x$wx_largefile" != "xyes"; then
653         WX_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, ac_cv_sys_large_files)
654     fi
655
656     AC_MSG_CHECKING(if large file support is available)
657     if test "x$wx_largefile" = "xyes"; then
658         AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
659     fi
660     AC_MSG_RESULT($wx_largefile)
661 fi
662 ])
663
664
665 dnl Available from the GNU Autoconf Macro Archive at:
666 dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_const_cast.html
667 dnl
668 AC_DEFUN([AC_CXX_CONST_CAST],
669 [AC_CACHE_CHECK(whether the compiler supports const_cast<>,
670 ac_cv_cxx_const_cast,
671 [AC_LANG_SAVE
672  AC_LANG_CPLUSPLUS
673  AC_TRY_COMPILE(,[int x = 0;const int& y = x;int& z = const_cast<int&>(y);return z;],
674  ac_cv_cxx_const_cast=yes, ac_cv_cxx_const_cast=no)
675  AC_LANG_RESTORE
676 ])
677 if test "$ac_cv_cxx_const_cast" = yes; then
678   AC_DEFINE(HAVE_CONST_CAST,,[define if the compiler supports const_cast<>])
679 fi
680 ])
681
682 dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_reinterpret_cast.html
683 AC_DEFUN([AC_CXX_REINTERPRET_CAST],
684 [AC_CACHE_CHECK(whether the compiler supports reinterpret_cast<>,
685 ac_cv_cxx_reinterpret_cast,
686 [AC_LANG_SAVE
687  AC_LANG_CPLUSPLUS
688  AC_TRY_COMPILE([#include <typeinfo>
689 class Base { public : Base () {} virtual void f () = 0;};
690 class Derived : public Base { public : Derived () {} virtual void f () {} };
691 class Unrelated { public : Unrelated () {} };
692 int g (Unrelated&) { return 0; }],[
693 Derived d;Base& b=d;Unrelated& e=reinterpret_cast<Unrelated&>(b);return g(e);],
694  ac_cv_cxx_reinterpret_cast=yes, ac_cv_cxx_reinterpret_cast=no)
695  AC_LANG_RESTORE
696 ])
697 if test "$ac_cv_cxx_reinterpret_cast" = yes; then
698   AC_DEFINE(HAVE_REINTERPRET_CAST,,
699             [define if the compiler supports reinterpret_cast<>])
700 fi
701 ])
702
703 dnl and http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_static_cast.html
704 AC_DEFUN([AC_CXX_STATIC_CAST],
705 [AC_CACHE_CHECK(whether the compiler supports static_cast<>,
706 ac_cv_cxx_static_cast,
707 [AC_LANG_SAVE
708  AC_LANG_CPLUSPLUS
709  AC_TRY_COMPILE([#include <typeinfo>
710 class Base { public : Base () {} virtual void f () = 0; };
711 class Derived : public Base { public : Derived () {} virtual void f () {} };
712 int g (Derived&) { return 0; }],[
713 Derived d; Base& b = d; Derived& s = static_cast<Derived&> (b); return g (s);],
714  ac_cv_cxx_static_cast=yes, ac_cv_cxx_static_cast=no)
715  AC_LANG_RESTORE
716 ])
717 if test "$ac_cv_cxx_static_cast" = yes; then
718   AC_DEFINE(HAVE_STATIC_CAST,, [define if the compiler supports static_cast<>])
719 fi
720 ])
721
722 dnl http://autoconf-archive.cryp.to/ac_cxx_dynamic_cast.html
723 AC_DEFUN([AC_CXX_DYNAMIC_CAST],
724 [AC_CACHE_CHECK(whether the compiler supports dynamic_cast<>,
725 ac_cv_cxx_dynamic_cast,
726 [AC_LANG_SAVE
727  AC_LANG_CPLUSPLUS
728  AC_TRY_COMPILE([#include <typeinfo>
729 class Base { public : Base () {} virtual void f () = 0;};
730 class Derived : public Base { public : Derived () {} virtual void f () {} };],[
731 Derived d; Base& b=d; return dynamic_cast<Derived*>(&b) ? 0 : 1;],
732  ac_cv_cxx_dynamic_cast=yes, ac_cv_cxx_dynamic_cast=no)
733  AC_LANG_RESTORE
734 ])
735 if test "$ac_cv_cxx_dynamic_cast" = yes; then
736   AC_DEFINE(HAVE_DYNAMIC_CAST,,[define if the compiler supports dynamic_cast<>])
737 fi
738 ])
739
740
741 dnl ---------------------------------------------------------------------------
742 dnl Support macros for makefiles generated by BAKEFILE.
743 dnl ---------------------------------------------------------------------------
744
745 dnl Lots of compiler & linker detection code contained here was taken from
746 dnl wxWindows configure.in script (see http://www.wxwindows.org)
747
748 dnl Based on autoconf _AC_LANG_COMPILER_GNU
749 AC_DEFUN([_AC_BAKEFILE_LANG_COMPILER_MWERKS],
750 [AC_CACHE_CHECK([whether we are using the Metrowerks _AC_LANG compiler],
751     [bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_mwerks],
752     [AC_TRY_COMPILE([],[#ifndef __MWERKS__
753        choke me
754 #endif
755 ],
756         [bakefile_compiler_mwerks=yes],
757         [bakefile_compiler_mwerks=no])
758     bakefile_cv_[]_AC_LANG_ABBREV[]_compiler_mwerks=$bakefile_compiler_mwerks
759     ])
760 ])
761
762 dnl Loosely based on autoconf AC_PROG_CC
763 dnl TODO: Maybe this should wrap the call to AC_PROG_CC and be used instead.
764 AC_DEFUN([AC_BAKEFILE_PROG_MWCC],
765 [AC_LANG_PUSH(C)
766 _AC_BAKEFILE_LANG_COMPILER_MWERKS
767 MWCC=`test $bakefile_compiler_mwerks = yes && echo yes`
768 AC_LANG_POP(C)
769 ])
770
771 dnl Loosely based on autoconf AC_PROG_CXX
772 dnl TODO: Maybe this should wrap the call to AC_PROG_CXX and be used instead.
773 AC_DEFUN([AC_BAKEFILE_PROG_MWCXX],
774 [AC_LANG_PUSH(C++)
775 _AC_BAKEFILE_LANG_COMPILER_MWERKS
776 MWCXX=`test $bakefile_compiler_mwerks = yes && echo yes`
777 AC_LANG_POP(C++)
778 ])
779
780 dnl ---------------------------------------------------------------------------
781 dnl AC_BAKEFILE_GNUMAKE
782 dnl
783 dnl Detects GNU make
784 dnl ---------------------------------------------------------------------------
785
786 AC_DEFUN([AC_BAKEFILE_GNUMAKE],
787 [
788     dnl does make support "-include" (only GNU make does AFAIK)?
789     AC_CACHE_CHECK([if make is GNU make], bakefile_cv_prog_makeisgnu,
790     [
791         if ( ${SHELL-sh} -c "${MAKE-make} --version" 2> /dev/null |
792                 egrep -s GNU > /dev/null); then
793             bakefile_cv_prog_makeisgnu="yes"
794         else
795             bakefile_cv_prog_makeisgnu="no"
796         fi
797     ])
798
799     if test "x$bakefile_cv_prog_makeisgnu" = "xyes"; then
800         IF_GNU_MAKE=""
801     else
802         IF_GNU_MAKE="#"
803     fi
804     AC_SUBST(IF_GNU_MAKE)
805 ])
806
807 dnl ---------------------------------------------------------------------------
808 dnl AC_BAKEFILE_PLATFORM
809 dnl
810 dnl Detects platform and sets PLATFORM_XXX variables accordingly
811 dnl ---------------------------------------------------------------------------
812
813 AC_DEFUN([AC_BAKEFILE_PLATFORM],
814 [
815     PLATFORM_UNIX=0
816     PLATFORM_WIN32=0
817     PLATFORM_MSDOS=0
818     PLATFORM_MAC=0
819     PLATFORM_MACOS=0
820     PLATFORM_MACOSX=0
821     PLATFORM_OS2=0
822     PLATFORM_BEOS=0
823
824     if test "x$BAKEFILE_FORCE_PLATFORM" = "x"; then 
825         case "${BAKEFILE_HOST}" in
826             *-*-cygwin* | *-*-mingw32* )
827                 PLATFORM_WIN32=1
828             ;;
829             *-pc-msdosdjgpp )
830                 PLATFORM_MSDOS=1
831             ;;
832             *-pc-os2_emx | *-pc-os2-emx )
833                 PLATFORM_OS2=1
834             ;;
835             powerpc-*-darwin* )
836                 PLATFORM_MAC=1
837                 PLATFORM_MACOSX=1
838             ;; 
839             *-*-beos* )
840                 PLATFORM_BEOS=1
841             ;;
842             powerpc-apple-macos* )
843                 PLATFORM_MAC=1
844                 PLATFORM_MACOS=1
845             ;;
846             * )
847                 PLATFORM_UNIX=1
848             ;;
849         esac
850     else
851         case "$BAKEFILE_FORCE_PLATFORM" in
852             win32 )
853                 PLATFORM_WIN32=1
854             ;;
855             msdos )
856                 PLATFORM_MSDOS=1
857             ;;
858             os2 )
859                 PLATFORM_OS2=1
860             ;;
861             darwin )
862                 PLATFORM_MAC=1
863                 PLATFORM_MACOSX=1
864             ;;
865             unix )
866                 PLATFORM_UNIX=1
867             ;;
868             beos )
869                 PLATFORM_BEOS=1
870             ;;
871             * )
872                 AC_MSG_ERROR([Unknown platform: $BAKEFILE_FORCE_PLATFORM])
873             ;;
874         esac
875     fi
876
877     AC_SUBST(PLATFORM_UNIX)
878     AC_SUBST(PLATFORM_WIN32)
879     AC_SUBST(PLATFORM_MSDOS)
880     AC_SUBST(PLATFORM_MAC)
881     AC_SUBST(PLATFORM_MACOS)
882     AC_SUBST(PLATFORM_MACOSX)
883     AC_SUBST(PLATFORM_OS2)
884     AC_SUBST(PLATFORM_BEOS)
885 ])
886
887
888 dnl ---------------------------------------------------------------------------
889 dnl AC_BAKEFILE_PLATFORM_SPECIFICS
890 dnl
891 dnl Sets misc platform-specific settings
892 dnl ---------------------------------------------------------------------------
893
894 AC_DEFUN([AC_BAKEFILE_PLATFORM_SPECIFICS],
895 [
896     AC_ARG_ENABLE([omf], AS_HELP_STRING([--enable-omf],
897                                         [use OMF object format (OS/2)]),
898                   [bk_os2_use_omf="$enableval"])
899     
900     case "${BAKEFILE_HOST}" in
901       *-*-darwin* )
902         dnl For Unix to MacOS X porting instructions, see:
903         dnl http://fink.sourceforge.net/doc/porting/porting.html
904         CFLAGS="$CFLAGS -fno-common"
905         CXXFLAGS="$CXXFLAGS -fno-common"
906         ;;
907
908       *-pc-os2_emx | *-pc-os2-emx )
909         if test "x$bk_os2_use_omf" = "xyes" ; then
910             AR=emxomfar
911             RANLIB=:
912             LDFLAGS="-Zomf $LDFLAGS"
913             CFLAGS="-Zomf $CFLAGS"
914             CXXFLAGS="-Zomf $CXXFLAGS"
915             OS2_LIBEXT="lib"
916         else
917             OS2_LIBEXT="a"
918         fi
919         ;;
920       
921       i*86-*-beos* )
922         LDFLAGS="-L/boot/develop/lib/x86 $LDFLAGS"
923         ;;
924     esac
925 ])
926
927 dnl ---------------------------------------------------------------------------
928 dnl AC_BAKEFILE_SUFFIXES
929 dnl
930 dnl Detects shared various suffixes for shared libraries, libraries, programs,
931 dnl plugins etc.
932 dnl ---------------------------------------------------------------------------
933
934 AC_DEFUN([AC_BAKEFILE_SUFFIXES],
935 [
936     SO_SUFFIX="so"
937     SO_SUFFIX_MODULE="so"
938     EXEEXT=""
939     LIBPREFIX="lib"
940     LIBEXT=".a"
941     DLLPREFIX="lib"
942     DLLPREFIX_MODULE=""
943     DLLIMP_SUFFIX=""
944     
945     case "${BAKEFILE_HOST}" in
946         *-hp-hpux* )
947             SO_SUFFIX="sl"
948             SO_SUFFIX_MODULE="sl"
949         ;;
950         *-*-aix* )
951             dnl quoting from
952             dnl http://www-1.ibm.com/servers/esdd/articles/gnu.html:
953             dnl     Both archive libraries and shared libraries on AIX have an
954             dnl     .a extension. This will explain why you can't link with an
955             dnl     .so and why it works with the name changed to .a.
956             SO_SUFFIX="a"
957             SO_SUFFIX_MODULE="a"
958         ;;
959         *-*-cygwin* | *-*-mingw32* )
960             SO_SUFFIX="dll"
961             SO_SUFFIX_MODULE="dll"
962             DLLIMP_SUFFIX="dll.a"
963             EXEEXT=".exe"
964             DLLPREFIX=""
965         ;;
966         *-pc-msdosdjgpp )
967             EXEEXT=".exe"
968             DLLPREFIX=""
969         ;;
970         *-pc-os2_emx | *-pc-os2-emx )
971             SO_SUFFIX="dll"
972             SO_SUFFIX_MODULE="dll"
973             DLLIMP_SUFFIX=$OS2_LIBEXT
974             EXEEXT=".exe"
975             DLLPREFIX=""
976             LIBPREFIX=""
977             LIBEXT=".$OS2_LIBEXT"
978         ;;
979         powerpc-*-darwin* )
980             SO_SUFFIX="dylib"
981             SO_SUFFIX_MODULE="bundle"
982         ;;
983     esac
984
985     if test "x$DLLIMP_SUFFIX" = "x" ; then
986         DLLIMP_SUFFIX="$SO_SUFFIX"
987     fi
988
989     AC_SUBST(SO_SUFFIX)
990     AC_SUBST(SO_SUFFIX_MODULE)
991     AC_SUBST(DLLIMP_SUFFIX)
992     AC_SUBST(EXEEXT)
993     AC_SUBST(LIBPREFIX)
994     AC_SUBST(LIBEXT)
995     AC_SUBST(DLLPREFIX)
996     AC_SUBST(DLLPREFIX_MODULE)
997 ])
998
999
1000 dnl ---------------------------------------------------------------------------
1001 dnl AC_BAKEFILE_SHARED_LD
1002 dnl
1003 dnl Detects command for making shared libraries, substitutes SHARED_LD_CC
1004 dnl and SHARED_LD_CXX.
1005 dnl ---------------------------------------------------------------------------
1006
1007 AC_DEFUN([AC_BAKEFILE_SHARED_LD],
1008 [
1009     dnl the extra compiler flags needed for compilation of shared library
1010     PIC_FLAG=""
1011     if test "x$GCC" = "xyes"; then
1012         dnl the switch for gcc is the same under all platforms
1013         PIC_FLAG="-fPIC"
1014     fi
1015     
1016     dnl Defaults for GCC and ELF .so shared libs:
1017     SHARED_LD_CC="\$(CC) -shared ${PIC_FLAG} -o"
1018     SHARED_LD_CXX="\$(CXX) -shared ${PIC_FLAG} -o"
1019
1020     case "${BAKEFILE_HOST}" in
1021       *-hp-hpux* )
1022         dnl default settings are good for gcc but not for the native HP-UX
1023         if test "x$GCC" != "xyes"; then
1024             dnl no idea why it wants it, but it does
1025             LDFLAGS="$LDFLAGS -L/usr/lib"
1026
1027             SHARED_LD_CC="${CC} -b -o"
1028             SHARED_LD_CXX="${CXX} -b -o"
1029             PIC_FLAG="+Z"
1030         fi
1031       ;;
1032
1033       *-*-linux* )
1034         if test "x$GCC" != "xyes"; then
1035             AC_CACHE_CHECK([for Intel compiler], bakefile_cv_prog_icc,
1036             [
1037                 AC_TRY_COMPILE([],
1038                     [
1039                         #ifndef __INTEL_COMPILER
1040                         #error Not icc
1041                         #endif
1042                     ],
1043                     bakefile_cv_prog_icc=yes,
1044                     bakefile_cv_prog_icc=no
1045                 )
1046             ])
1047             if test "$bakefile_cv_prog_icc" = "yes"; then
1048                 PIC_FLAG="-KPIC"
1049             fi
1050         fi
1051       ;;
1052
1053       *-*-solaris2* )
1054         if test "x$GCC" != xyes ; then
1055             SHARED_LD_CC="${CC} -G -o"
1056             SHARED_LD_CXX="${CXX} -G -o"
1057             PIC_FLAG="-KPIC"
1058         fi
1059       ;;
1060
1061       *-*-darwin* )
1062         dnl Most apps benefit from being fully binded (its faster and static
1063         dnl variables initialized at startup work).
1064         dnl This can be done either with the exe linker flag -Wl,-bind_at_load
1065         dnl or with a double stage link in order to create a single module
1066         dnl "-init _wxWindowsDylibInit" not useful with lazy linking solved
1067
1068         dnl If using newer dev tools then there is a -single_module flag that
1069         dnl we can use to do this, otherwise we'll need to use a helper
1070         dnl script.  Check the version of gcc to see which way we can go:
1071         AC_CACHE_CHECK([for gcc 3.1 or later], wx_cv_gcc31, [
1072            AC_TRY_COMPILE([],
1073                [
1074                    #if (__GNUC__ < 3) || \
1075                        ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1))
1076                        #error old gcc
1077                    #endif
1078                ],
1079                [
1080                    wx_cv_gcc31=yes
1081                ],
1082                [
1083                    wx_cv_gcc31=no
1084                ]
1085            )
1086         ])
1087         if test "$wx_cv_gcc31" = "no"; then
1088             AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH
1089             chmod +x shared-ld-sh
1090
1091             dnl Use the shared-ld-sh helper script
1092             SHARED_LD_CC="`pwd`/shared-ld-sh -dynamiclib -headerpad_max_install_names -o"
1093             SHARED_LD_MODULE_CC="`pwd`/shared-ld-sh -bundle -headerpad_max_install_names -o"
1094             SHARED_LD_CXX="$SHARED_LD_CC"
1095             SHARED_LD_MODULE_CXX="$SHARED_LD_MODULE_CC"
1096         else
1097             dnl Use the -single_module flag and let the linker do it for us
1098             SHARED_LD_CC="\${CC} -dynamiclib -single_module -headerpad_max_install_names -o"
1099             SHARED_LD_MODULE_CC="\${CC} -bundle -single_module -headerpad_max_install_names -o"
1100             SHARED_LD_CXX="\${CXX} -dynamiclib -single_module -headerpad_max_install_names -o"
1101             SHARED_LD_MODULE_CXX="\${CXX} -bundle -single_module -headerpad_max_install_names -o"
1102         fi
1103
1104         PIC_FLAG="-dynamic -fPIC"
1105       ;;
1106
1107       *-*-aix* )
1108         dnl default settings are ok for gcc
1109         if test "x$GCC" != "xyes"; then
1110             dnl the abs path below used to be hardcoded here so I guess it must
1111             dnl be some sort of standard location under AIX?
1112             AC_CHECK_PROG(AIX_CXX_LD, makeC++SharedLib,
1113                           makeC++SharedLib, /usr/lpp/xlC/bin/makeC++SharedLib)
1114             dnl FIXME - what about makeCSharedLib?            
1115             SHARED_LD_CC="$AIX_CC_LD -p 0 -o"
1116             SHARED_LD_CXX="$AIX_CXX_LD -p 0 -o"
1117         fi
1118       ;;
1119
1120       *-*-beos* )
1121         dnl can't use gcc under BeOS for shared library creation because it
1122         dnl complains about missing 'main'
1123         SHARED_LD_CC="${LD} -nostart -o"
1124         SHARED_LD_CXX="${LD} -nostart -o"
1125       ;;
1126
1127       *-*-irix* )
1128         dnl default settings are ok for gcc
1129         if test "x$GCC" != "xyes"; then
1130             PIC_FLAG="-KPIC"
1131         fi
1132       ;;
1133       
1134       *-*-cygwin* | *-*-mingw32* )
1135         PIC_FLAG=""
1136         SHARED_LD_CC="\$(CC) -shared -o"
1137         SHARED_LD_CXX="\$(CXX) -shared -o"
1138       ;;
1139
1140       *-pc-os2_emx | *-pc-os2-emx )
1141         SHARED_LD_CC="`pwd`/dllar.sh -libf INITINSTANCE -libf TERMINSTANCE -o"
1142         SHARED_LD_CXX="`pwd`/dllar.sh -libf INITINSTANCE -libf TERMINSTANCE -o"
1143         PIC_FLAG=""
1144         AC_BAKEFILE_CREATE_FILE_DLLAR_SH
1145         chmod +x dllar.sh
1146       ;;
1147       
1148       powerpc-apple-macos* | \
1149       *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | \
1150       *-*-sunos4* | \
1151       *-*-osf* | \
1152       *-*-dgux5* | \
1153       *-*-sysv5* )
1154         dnl defaults are ok
1155       ;;
1156
1157       *)
1158         AC_MSG_ERROR(unknown system type $BAKEFILE_HOST.)
1159     esac
1160
1161     if test "x$PIC_FLAG" != "x" ; then
1162         PIC_FLAG="$PIC_FLAG -DPIC"
1163     fi
1164
1165     if test "x$SHARED_LD_MODULE_CC" = "x" ; then
1166         SHARED_LD_MODULE_CC="$SHARED_LD_CC"
1167     fi
1168     if test "x$SHARED_LD_MODULE_CXX" = "x" ; then
1169         SHARED_LD_MODULE_CXX="$SHARED_LD_CXX"
1170     fi
1171
1172     AC_SUBST(SHARED_LD_CC)
1173     AC_SUBST(SHARED_LD_CXX)
1174     AC_SUBST(SHARED_LD_MODULE_CC)
1175     AC_SUBST(SHARED_LD_MODULE_CXX)
1176     AC_SUBST(PIC_FLAG)
1177 ])
1178
1179
1180 dnl ---------------------------------------------------------------------------
1181 dnl AC_BAKEFILE_SHARED_VERSIONS
1182 dnl
1183 dnl Detects linker options for attaching versions (sonames) to shared  libs.
1184 dnl ---------------------------------------------------------------------------
1185
1186 AC_DEFUN([AC_BAKEFILE_SHARED_VERSIONS],
1187 [
1188     USE_SOVERSION=0
1189     USE_SOVERLINUX=0
1190     USE_SOVERSOLARIS=0
1191     USE_SOSYMLINKS=0
1192     USE_MACVERSION=0
1193     SONAME_FLAG=
1194
1195     case "${BAKEFILE_HOST}" in
1196       *-*-linux* | *-*-freebsd* )
1197         SONAME_FLAG="-Wl,-soname,"
1198         USE_SOVERSION=1
1199         USE_SOVERLINUX=1
1200         USE_SOSYMLINKS=1
1201       ;;
1202
1203       *-*-solaris2* )
1204         SONAME_FLAG="-h "
1205         USE_SOVERSION=1
1206         USE_SOVERSOLARIS=1
1207         USE_SOSYMLINKS=1
1208       ;;
1209
1210       *-*-darwin* )
1211         USE_MACVERSION=1
1212         USE_SOVERSION=1
1213         USE_SOSYMLINKS=1
1214       ;;      
1215     esac
1216
1217     AC_SUBST(USE_SOVERSION)
1218     AC_SUBST(USE_SOVERLINUX)
1219     AC_SUBST(USE_SOVERSOLARIS)
1220     AC_SUBST(USE_MACVERSION)
1221     AC_SUBST(USE_SOSYMLINKS)
1222     AC_SUBST(SONAME_FLAG)
1223 ])
1224
1225
1226 dnl ---------------------------------------------------------------------------
1227 dnl AC_BAKEFILE_DEPS
1228 dnl
1229 dnl Detects available C/C++ dependency tracking options
1230 dnl ---------------------------------------------------------------------------
1231
1232 AC_DEFUN([AC_BAKEFILE_DEPS],
1233 [
1234     AC_MSG_CHECKING([for dependency tracking method])
1235     DEPS_TRACKING=0
1236
1237     if test "x$GCC" = "xyes"; then
1238         DEPSMODE=gcc
1239         DEPS_TRACKING=1
1240         case "${BAKEFILE_HOST}" in
1241             powerpc-*-darwin* )
1242                 dnl -cpp-precomp (the default) conflicts with -MMD option
1243                 dnl used by bk-deps (see also http://developer.apple.com/documentation/Darwin/Conceptual/PortingUnix/compiling/chapter_4_section_3.html)
1244                 DEPSFLAG_GCC="-no-cpp-precomp -MMD"
1245             ;;
1246             * )
1247                 DEPSFLAG_GCC="-MMD"
1248             ;;
1249         esac
1250         AC_MSG_RESULT([gcc])
1251     elif test "x$MWCC" = "xyes"; then
1252         DEPSMODE=mwcc
1253         DEPS_TRACKING=1
1254         DEPSFLAG_MWCC="-MM"
1255         AC_MSG_RESULT([mwcc])
1256     else
1257         AC_MSG_RESULT([none])
1258     fi
1259
1260     if test $DEPS_TRACKING = 1 ; then
1261         AC_BAKEFILE_CREATE_FILE_BK_DEPS
1262         chmod +x bk-deps
1263     fi
1264     
1265     AC_SUBST(DEPS_TRACKING)
1266 ])
1267
1268 dnl ---------------------------------------------------------------------------
1269 dnl AC_BAKEFILE_CHECK_BASIC_STUFF
1270 dnl
1271 dnl Checks for presence of basic programs, such as C and C++ compiler, "ranlib"
1272 dnl or "install"
1273 dnl ---------------------------------------------------------------------------
1274
1275 AC_DEFUN([AC_BAKEFILE_CHECK_BASIC_STUFF],
1276 [
1277     AC_PROG_RANLIB
1278     AC_PROG_INSTALL
1279     AC_PROG_LN_S
1280
1281     AC_PROG_MAKE_SET
1282     AC_SUBST(MAKE_SET)
1283     
1284     AC_CHECK_TOOL(AR, ar, ar)
1285     AC_CHECK_TOOL(STRIP, strip, :)
1286     AC_CHECK_TOOL(NM, nm, :)
1287
1288     case ${BAKEFILE_HOST} in
1289         *-hp-hpux* )
1290             dnl HP-UX install doesn't handle the "-d" switch so don't
1291             dnl use it there
1292             INSTALL_DIR="mkdir -p"
1293             ;;
1294         *)  INSTALL_DIR="$INSTALL -d"
1295             ;;
1296     esac
1297     AC_SUBST(INSTALL_DIR)
1298
1299     LDFLAGS_GUI=
1300     case ${BAKEFILE_HOST} in
1301         *-*-cygwin* | *-*-mingw32* )
1302         LDFLAGS_GUI="-mwindows"
1303     esac
1304     AC_SUBST(LDFLAGS_GUI)
1305 ])
1306
1307
1308 dnl ---------------------------------------------------------------------------
1309 dnl AC_BAKEFILE_RES_COMPILERS
1310 dnl
1311 dnl Checks for presence of resource compilers for win32 or mac
1312 dnl ---------------------------------------------------------------------------
1313
1314 AC_DEFUN([AC_BAKEFILE_RES_COMPILERS],
1315 [
1316     RESCOMP=
1317     SETFILE=
1318
1319     case ${BAKEFILE_HOST} in 
1320         *-*-cygwin* | *-*-mingw32* )
1321             dnl Check for win32 resources compiler:
1322             if test "$build" != "$host" ; then
1323                 RESCOMP=$host_alias-windres
1324             else
1325                 AC_CHECK_PROG(RESCOMP, windres, windres, windres)
1326             fi
1327          ;;
1328  
1329       *-*-darwin* | powerpc-apple-macos* )
1330             AC_CHECK_PROG(RESCOMP, Rez, Rez, /Developer/Tools/Rez)
1331             AC_CHECK_PROG(SETFILE, SetFile, SetFile, /Developer/Tools/SetFile)
1332         ;;
1333     esac
1334
1335     AC_SUBST(RESCOMP)
1336     AC_SUBST(SETFILE)
1337 ])
1338
1339 dnl ---------------------------------------------------------------------------
1340 dnl AC_BAKEFILE_PRECOMP_HEADERS
1341 dnl
1342 dnl Check for precompiled headers support (GCC >= 3.4)
1343 dnl ---------------------------------------------------------------------------
1344
1345 AC_DEFUN([AC_BAKEFILE_PRECOMP_HEADERS],
1346 [
1347
1348     AC_ARG_ENABLE([precomp-headers],
1349                   AS_HELP_STRING([--disable-precomp-headers],
1350                                  [don't use precompiled headers even if compiler can]),
1351                   [bk_use_pch="$enableval"])
1352
1353     GCC_PCH=0
1354
1355     if test "x$bk_use_pch" = "x" -o "x$bk_use_pch" = "xyes" ; then
1356         if test "x$GCC" = "xyes"; then
1357             dnl test if we have gcc-3.4:
1358             AC_MSG_CHECKING([if the compiler supports precompiled headers])
1359             AC_TRY_COMPILE([],
1360                 [
1361                     #if !defined(__GNUC__) || !defined(__GNUC_MINOR__)
1362                         #error "no pch support"
1363                     #endif
1364                     #if (__GNUC__ < 3)
1365                         #error "no pch support"
1366                     #endif
1367                     #if (__GNUC__ == 3) && \
1368                        ((!defined(__APPLE_CC__) && (__GNUC_MINOR__ < 4)) || \
1369                        ( defined(__APPLE_CC__) && (__GNUC_MINOR__ < 3)))
1370                         #error "no pch support"
1371                     #endif
1372                 ],
1373                 [
1374                     AC_MSG_RESULT([yes])
1375                     GCC_PCH=1
1376                 ],
1377                 [
1378                     AC_MSG_RESULT([no])
1379                 ])
1380             if test $GCC_PCH = 1 ; then
1381                 AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH
1382                 chmod +x bk-make-pch
1383             fi
1384         fi
1385     fi
1386
1387     AC_SUBST(GCC_PCH)
1388 ])
1389
1390
1391
1392 dnl ---------------------------------------------------------------------------
1393 dnl AC_BAKEFILE([autoconf_inc.m4 inclusion])
1394 dnl
1395 dnl To be used in configure.in of any project using Bakefile-generated mks
1396 dnl
1397 dnl Behaviour can be modified by setting following variables:
1398 dnl    BAKEFILE_CHECK_BASICS    set to "no" if you don't want bakefile to
1399 dnl                             to perform check for basic tools like ranlib
1400 dnl    BAKEFILE_HOST            set this to override host detection, defaults
1401 dnl                             to ${host}
1402 dnl    BAKEFILE_FORCE_PLATFORM  set to override platform detection
1403 dnl
1404 dnl Example usage:
1405 dnl
1406 dnl   AC_BAKEFILE([FOO(autoconf_inc.m4)])
1407 dnl
1408 dnl (replace FOO with m4_include above, aclocal would die otherwise)
1409 dnl (yes, it's ugly, but thanks to a bug in aclocal, it's the only thing
1410 dnl we can do...)
1411 dnl ---------------------------------------------------------------------------
1412
1413 AC_DEFUN([AC_BAKEFILE],
1414 [
1415     AC_PREREQ(2.58)
1416
1417     if test "x$BAKEFILE_HOST" = "x"; then
1418         BAKEFILE_HOST="${host}"
1419     fi
1420
1421     if test "x$BAKEFILE_CHECK_BASICS" != "xno"; then
1422         AC_BAKEFILE_CHECK_BASIC_STUFF
1423     fi
1424     AC_BAKEFILE_GNUMAKE
1425     AC_BAKEFILE_PLATFORM
1426     AC_BAKEFILE_PLATFORM_SPECIFICS
1427     AC_BAKEFILE_SUFFIXES
1428     AC_BAKEFILE_SHARED_LD
1429     AC_BAKEFILE_SHARED_VERSIONS
1430     AC_BAKEFILE_DEPS
1431     AC_BAKEFILE_RES_COMPILERS
1432
1433     BAKEFILE_BAKEFILE_M4_VERSION="0.1.7"
1434    
1435     dnl includes autoconf_inc.m4:
1436     $1
1437     
1438     if test "$BAKEFILE_BAKEFILE_M4_VERSION" != "$BAKEFILE_AUTOCONF_INC_M4_VERSION" ; then
1439         AC_MSG_ERROR([Versions of Bakefile used to generate makefiles ($BAKEFILE_AUTOCONF_INC_M4_VERSION) and configure ($BAKEFILE_BAKEFILE_M4_VERSION) do not match.])
1440     fi
1441 ])
1442         
1443
1444 dnl ---------------------------------------------------------------------------
1445 dnl              Embedded copies of helper scripts follow:
1446 dnl ---------------------------------------------------------------------------
1447
1448 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_DLLAR_SH],
1449 [
1450 dnl ===================== dllar.sh begins here =====================
1451 dnl    (Created by merge-scripts.py from dllar.sh
1452 dnl     file do not edit here!)
1453 D='$'
1454 cat <<EOF >dllar.sh
1455 #!/bin/sh
1456 #
1457 # dllar - a tool to build both a .dll and an .a file
1458 # from a set of object (.o) files for EMX/OS2.
1459 #
1460 #  Written by Andrew Zabolotny, bit@freya.etu.ru
1461 #  Ported to Unix like shell by Stefan Neis, Stefan.Neis@t-online.de
1462 #
1463 #  This script will accept a set of files on the command line.
1464 #  All the public symbols from the .o files will be exported into
1465 #  a .DEF file, then linker will be run (through gcc) against them to
1466 #  build a shared library consisting of all given .o files. All libraries
1467 #  (.a) will be first decompressed into component .o files then act as
1468 #  described above. You can optionally give a description (-d "description")
1469 #  which will be put into .DLL. To see the list of accepted options (as well
1470 #  as command-line format) simply run this program without options. The .DLL
1471 #  is built to be imported by name (there is no guarantee that new versions
1472 #  of the library you build will have same ordinals for same symbols).
1473 #
1474 #  dllar is free software; you can redistribute it and/or modify
1475 #  it under the terms of the GNU General Public License as published by
1476 #  the Free Software Foundation; either version 2, or (at your option)
1477 #  any later version.
1478 #
1479 #  dllar is distributed in the hope that it will be useful,
1480 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
1481 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
1482 #  GNU General Public License for more details.
1483 #
1484 #  You should have received a copy of the GNU General Public License
1485 #  along with dllar; see the file COPYING.  If not, write to the Free
1486 #  Software Foundation, 59 Temple Place - Suite 330, Boston, MA
1487 #  02111-1307, USA.
1488
1489 # To successfuly run this program you will need:
1490 #  - Current drive should have LFN support (HPFS, ext2, network, etc)
1491 #    (Sometimes dllar generates filenames which won't fit 8.3 scheme)
1492 #  - gcc
1493 #    (used to build the .dll)
1494 #  - emxexp
1495 #    (used to create .def file from .o files)
1496 #  - emximp
1497 #    (used to create .a file from .def file)
1498 #  - GNU text utilites (cat, sort, uniq)
1499 #    used to process emxexp output
1500 #  - GNU file utilities (mv, rm)
1501 #  - GNU sed
1502 #  - lxlite (optional, see flag below)
1503 #    (used for general .dll cleanup)
1504 #
1505
1506 flag_USE_LXLITE=1;
1507
1508 #
1509 # helper functions
1510 # basnam, variant of basename, which does _not_ remove the path, _iff_
1511 #                              second argument (suffix to remove) is given
1512 basnam(){
1513     case ${D}# in
1514     1)
1515         echo ${D}1 | sed 's/.*\\///' | sed 's/.*\\\\//'
1516         ;;
1517     2)
1518         echo ${D}1 | sed 's/'${D}2'${D}//'
1519         ;;
1520     *)
1521         echo "error in basnam ${D}*"
1522         exit 8
1523         ;;
1524     esac
1525 }
1526
1527 # Cleanup temporary files and output
1528 CleanUp() {
1529     cd ${D}curDir
1530     for i in ${D}inputFiles ; do
1531         case ${D}i in
1532         *!)
1533             rm -rf \`basnam ${D}i !\`
1534             ;;
1535         *)
1536             ;;
1537         esac
1538     done
1539
1540     # Kill result in case of failure as there is just to many stupid make/nmake
1541     # things out there which doesn't do this.
1542     if @<:@ ${D}# -eq 0 @:>@; then
1543         rm -f ${D}arcFile ${D}arcFile2 ${D}defFile ${D}dllFile
1544     fi
1545 }
1546
1547 # Print usage and exit script with rc=1.
1548 PrintHelp() {
1549  echo 'Usage: dllar.sh @<:@-o@<:@utput@:>@ output_file@:>@ @<:@-i@<:@mport@:>@ importlib_name@:>@'
1550  echo '       @<:@-name-mangler-script script.sh@:>@'
1551  echo '       @<:@-d@<:@escription@:>@ "dll descrption"@:>@ @<:@-cc "CC"@:>@ @<:@-f@<:@lags@:>@ "CFLAGS"@:>@'
1552  echo '       @<:@-ord@<:@inals@:>@@:>@ -ex@<:@clude@:>@ "symbol(s)"'
1553  echo '       @<:@-libf@<:@lags@:>@ "{INIT|TERM}{GLOBAL|INSTANCE}"@:>@ @<:@-nocrt@<:@dll@:>@@:>@ @<:@-nolxl@<:@ite@:>@@:>@'
1554  echo '       @<:@*.o@:>@ @<:@*.a@:>@'
1555  echo '*> "output_file" should have no extension.'
1556  echo '   If it has the .o, .a or .dll extension, it is automatically removed.'
1557  echo '   The import library name is derived from this and is set to "name".a,'
1558  echo '   unless overridden by -import'
1559  echo '*> "importlib_name" should have no extension.'
1560  echo '   If it has the .o, or .a extension, it is automatically removed.'
1561  echo '   This name is used as the import library name and may be longer and'
1562  echo '   more descriptive than the DLL name which has to follow the old '
1563  echo '   8.3 convention of FAT.'
1564  echo '*> "script.sh may be given to override the output_file name by a'
1565  echo '   different name. It is mainly useful if the regular make process'
1566  echo '   of some package does not take into account OS/2 restriction of'
1567  echo '   DLL name lengths. It takes the importlib name as input and is'
1568  echo '   supposed to procude a shorter name as output. The script should'
1569  echo '   expect to get importlib_name without extension and should produce'
1570  echo '   a (max.) 8 letter name without extension.'
1571  echo '*> "cc" is used to use another GCC executable.   (default: gcc.exe)'
1572  echo '*> "flags" should be any set of valid GCC flags. (default: -s -Zcrtdll)'
1573  echo '   These flags will be put at the start of GCC command line.'
1574  echo '*> -ord@<:@inals@:>@ tells dllar to export entries by ordinals. Be careful.'
1575  echo '*> -ex@<:@clude@:>@ defines symbols which will not be exported. You can define'
1576  echo '   multiple symbols, for example -ex "myfunc yourfunc _GLOBAL*".'
1577  echo '   If the last character of a symbol is "*", all symbols beginning'
1578  echo '   with the prefix before "*" will be exclude, (see _GLOBAL* above).'
1579  echo '*> -libf@<:@lags@:>@ can be used to add INITGLOBAL/INITINSTANCE and/or'
1580  echo '   TERMGLOBAL/TERMINSTANCE flags to the dynamically-linked library.'
1581  echo '*> -nocrt@<:@dll@:>@ switch will disable linking the library against emx''s'
1582  echo '   C runtime DLLs.'
1583  echo '*> -nolxl@<:@ite@:>@ switch will disable running lxlite on the resulting DLL.'
1584  echo '*> All other switches (for example -L./ or -lmylib) will be passed'
1585  echo '   unchanged to GCC at the end of command line.'
1586  echo '*> If you create a DLL from a library and you do not specify -o,'
1587  echo '   the basename for DLL and import library will be set to library name,'
1588  echo '   the initial library will be renamed to 'name'_s.a (_s for static)'
1589  echo '   i.e. "dllar gcc.a" will create gcc.dll and gcc.a, and the initial'
1590  echo '   library will be renamed into gcc_s.a.'
1591  echo '--------'
1592  echo 'Example:'
1593  echo '   dllar -o gcc290.dll libgcc.a -d "GNU C runtime library" -ord'
1594  echo '    -ex "__main __ctordtor*" -libf "INITINSTANCE TERMINSTANCE"'
1595  CleanUp
1596  exit 1
1597 }
1598
1599 # Execute a command.
1600 # If exit code of the commnad <> 0 CleanUp() is called and we'll exit the script.
1601 # @Uses    Whatever CleanUp() uses.
1602 doCommand() {
1603     echo "${D}*"
1604     eval ${D}*
1605     rcCmd=${D}?
1606
1607     if @<:@ ${D}rcCmd -ne 0 @:>@; then
1608         echo "command failed, exit code="${D}rcCmd
1609         CleanUp
1610         exit ${D}rcCmd
1611     fi
1612 }
1613
1614 # main routine
1615 # setup globals
1616 cmdLine=${D}*
1617 outFile=""
1618 outimpFile=""
1619 inputFiles=""
1620 renameScript=""
1621 description=""
1622 CC=gcc.exe
1623 CFLAGS="-s -Zcrtdll"
1624 EXTRA_CFLAGS=""
1625 EXPORT_BY_ORDINALS=0
1626 exclude_symbols=""
1627 library_flags=""
1628 curDir=\`pwd\`
1629 curDirS=curDir
1630 case ${D}curDirS in
1631 */)
1632   ;;
1633 *)
1634   curDirS=${D}{curDirS}"/"
1635   ;;
1636 esac
1637 # Parse commandline
1638 libsToLink=0
1639 omfLinking=0
1640 while @<:@ ${D}1 @:>@; do
1641     case ${D}1 in
1642     -ord*)
1643         EXPORT_BY_ORDINALS=1;
1644         ;;
1645     -o*)
1646         shift
1647         outFile=${D}1
1648         ;;
1649     -i*)
1650         shift
1651         outimpFile=${D}1
1652         ;;
1653     -name-mangler-script)
1654         shift
1655         renameScript=${D}1
1656         ;;
1657     -d*)
1658         shift
1659         description=${D}1
1660         ;;
1661     -f*)
1662         shift
1663         CFLAGS=${D}1
1664         ;;
1665     -c*)
1666         shift
1667         CC=${D}1
1668         ;;
1669     -h*)
1670         PrintHelp
1671         ;;
1672     -ex*)
1673         shift
1674         exclude_symbols=${D}{exclude_symbols}${D}1" "
1675         ;;
1676     -libf*)
1677         shift
1678         library_flags=${D}{library_flags}${D}1" "
1679         ;;
1680     -nocrt*)
1681         CFLAGS="-s"
1682         ;;
1683     -nolxl*)
1684         flag_USE_LXLITE=0
1685         ;;
1686     -* | /*)
1687         case ${D}1 in
1688         -L* | -l*)
1689             libsToLink=1
1690             ;;
1691         -Zomf)
1692             omfLinking=1
1693             ;;
1694         *)
1695             ;;
1696         esac
1697         EXTRA_CFLAGS=${D}{EXTRA_CFLAGS}" "${D}1
1698         ;;
1699     *.dll)
1700         EXTRA_CFLAGS="${D}{EXTRA_CFLAGS} \`basnam ${D}1 .dll\`"
1701         if @<:@ ${D}omfLinking -eq 1 @:>@; then
1702             EXTRA_CFLAGS="${D}{EXTRA_CFLAGS}.lib"
1703         else
1704             EXTRA_CFLAGS="${D}{EXTRA_CFLAGS}.a"
1705         fi
1706         ;;
1707     *)
1708         found=0;
1709         if @<:@ ${D}libsToLink -ne 0 @:>@; then
1710             EXTRA_CFLAGS=${D}{EXTRA_CFLAGS}" "${D}1
1711         else
1712             for file in ${D}1 ; do
1713                 if @<:@ -f ${D}file @:>@; then
1714                     inputFiles="${D}{inputFiles} ${D}file"
1715                     found=1
1716                 fi
1717             done
1718             if @<:@ ${D}found -eq 0 @:>@; then
1719                 echo "ERROR: No file(s) found: "${D}1
1720                 exit 8
1721             fi
1722         fi
1723       ;;
1724     esac
1725     shift
1726 done # iterate cmdline words
1727
1728 #
1729 if @<:@ -z "${D}inputFiles" @:>@; then
1730     echo "dllar: no input files"
1731     PrintHelp
1732 fi
1733
1734 # Now extract all .o files from .a files
1735 newInputFiles=""
1736 for file in ${D}inputFiles ; do
1737     case ${D}file in
1738     *.a | *.lib)
1739         case ${D}file in
1740         *.a)
1741             suffix=".a"
1742             AR="ar"
1743             ;;
1744         *.lib)
1745             suffix=".lib"
1746             AR="emxomfar"
1747             EXTRA_CFLAGS="${D}EXTRA_CFLAGS -Zomf"
1748             ;;
1749         *)
1750             ;;
1751         esac
1752         dirname=\`basnam ${D}file ${D}suffix\`"_%"
1753         mkdir ${D}dirname
1754         if @<:@ ${D}? -ne 0 @:>@; then
1755             echo "Failed to create subdirectory ./${D}dirname"
1756             CleanUp
1757             exit 8;
1758         fi
1759         # Append '!' to indicate archive
1760         newInputFiles="${D}newInputFiles ${D}{dirname}!"
1761         doCommand "cd ${D}dirname; ${D}AR x ../${D}file"
1762         cd ${D}curDir
1763         found=0;
1764         for subfile in ${D}dirname/*.o* ; do
1765             if @<:@ -f ${D}subfile @:>@; then
1766                 found=1
1767                 if @<:@ -s ${D}subfile @:>@; then
1768                     # FIXME: This should be: is file size > 32 byte, _not_ > 0!
1769                     newInputFiles="${D}newInputFiles ${D}subfile"
1770                 fi
1771             fi
1772         done
1773         if @<:@ ${D}found -eq 0 @:>@; then
1774             echo "WARNING: there are no files in archive \\'${D}file\\'"
1775         fi
1776         ;;
1777     *)
1778         newInputFiles="${D}{newInputFiles} ${D}file"
1779         ;;
1780     esac
1781 done
1782 inputFiles="${D}newInputFiles"
1783
1784 # Output filename(s).
1785 do_backup=0;
1786 if @<:@ -z ${D}outFile @:>@; then
1787     do_backup=1;
1788     set outFile ${D}inputFiles; outFile=${D}2
1789 fi
1790
1791 # If it is an archive, remove the '!' and the '_%' suffixes
1792 case ${D}outFile in
1793 *_%!)
1794     outFile=\`basnam ${D}outFile _%!\`
1795     ;;
1796 *)
1797     ;;
1798 esac
1799 case ${D}outFile in
1800 *.dll)
1801     outFile=\`basnam ${D}outFile .dll\`
1802     ;;
1803 *.DLL)
1804     outFile=\`basnam ${D}outFile .DLL\`
1805     ;;
1806 *.o)
1807     outFile=\`basnam ${D}outFile .o\`
1808     ;;
1809 *.obj)
1810     outFile=\`basnam ${D}outFile .obj\`
1811     ;;
1812 *.a)
1813     outFile=\`basnam ${D}outFile .a\`
1814     ;;
1815 *.lib)
1816     outFile=\`basnam ${D}outFile .lib\`
1817     ;;
1818 *)
1819     ;;
1820 esac
1821 case ${D}outimpFile in
1822 *.a)
1823     outimpFile=\`basnam ${D}outimpFile .a\`
1824     ;;
1825 *.lib)
1826     outimpFile=\`basnam ${D}outimpFile .lib\`
1827     ;;
1828 *)
1829     ;;
1830 esac
1831 if @<:@ -z ${D}outimpFile @:>@; then
1832     outimpFile=${D}outFile
1833 fi
1834 defFile="${D}{outFile}.def"
1835 arcFile="${D}{outimpFile}.a"
1836 arcFile2="${D}{outimpFile}.lib"
1837
1838 #create ${D}dllFile as something matching 8.3 restrictions,
1839 if @<:@ -z ${D}renameScript @:>@ ; then
1840     dllFile="${D}outFile"
1841 else
1842     dllFile=\`${D}renameScript ${D}outimpFile\`
1843 fi
1844
1845 if @<:@ ${D}do_backup -ne 0 @:>@ ; then
1846     if @<:@ -f ${D}arcFile @:>@ ; then
1847         doCommand "mv ${D}arcFile ${D}{outFile}_s.a"
1848     fi
1849     if @<:@ -f ${D}arcFile2 @:>@ ; then
1850         doCommand "mv ${D}arcFile2 ${D}{outFile}_s.lib"
1851     fi
1852 fi
1853
1854 # Extract public symbols from all the object files.
1855 tmpdefFile=${D}{defFile}_%
1856 rm -f ${D}tmpdefFile
1857 for file in ${D}inputFiles ; do
1858     case ${D}file in
1859     *!)
1860         ;;
1861     *)
1862         doCommand "emxexp -u ${D}file >> ${D}tmpdefFile"
1863         ;;
1864     esac
1865 done
1866
1867 # Create the def file.
1868 rm -f ${D}defFile
1869 echo "LIBRARY \`basnam ${D}dllFile\` ${D}library_flags" >> ${D}defFile
1870 dllFile="${D}{dllFile}.dll"
1871 if @<:@ ! -z ${D}description @:>@; then
1872     echo "DESCRIPTION  \\"${D}{description}\\"" >> ${D}defFile
1873 fi
1874 echo "EXPORTS" >> ${D}defFile
1875
1876 doCommand "cat ${D}tmpdefFile | sort.exe | uniq.exe > ${D}{tmpdefFile}%"
1877 grep -v "^ *;" < ${D}{tmpdefFile}% | grep -v "^ *${D}" >${D}tmpdefFile
1878
1879 # Checks if the export is ok or not.
1880 for word in ${D}exclude_symbols; do
1881     grep -v ${D}word < ${D}tmpdefFile >${D}{tmpdefFile}%
1882     mv ${D}{tmpdefFile}% ${D}tmpdefFile
1883 done
1884
1885
1886 if @<:@ ${D}EXPORT_BY_ORDINALS -ne 0 @:>@; then
1887     sed "=" < ${D}tmpdefFile | \\
1888     sed '
1889       N
1890       : loop
1891       s/^\\(@<:@0-9@:>@\\+\\)\\(@<:@^;@:>@*\\)\\(;.*\\)\\?/\\2 @\\1 NONAME/
1892       t loop
1893     ' > ${D}{tmpdefFile}%
1894     grep -v "^ *${D}" < ${D}{tmpdefFile}% > ${D}tmpdefFile
1895 else
1896     rm -f ${D}{tmpdefFile}%
1897 fi
1898 cat ${D}tmpdefFile >> ${D}defFile
1899 rm -f ${D}tmpdefFile
1900
1901 # Do linking, create implib, and apply lxlite.
1902 gccCmdl="";
1903 for file in ${D}inputFiles ; do
1904     case ${D}file in
1905     *!)
1906         ;;
1907     *)
1908         gccCmdl="${D}gccCmdl ${D}file"
1909         ;;
1910     esac
1911 done
1912 doCommand "${D}CC ${D}CFLAGS -Zdll -o ${D}dllFile ${D}defFile ${D}gccCmdl ${D}EXTRA_CFLAGS"
1913 touch "${D}{outFile}.dll"
1914
1915 doCommand "emximp -o ${D}arcFile ${D}defFile"
1916 if @<:@ ${D}flag_USE_LXLITE -ne 0 @:>@; then
1917     add_flags="";
1918     if @<:@ ${D}EXPORT_BY_ORDINALS -ne 0 @:>@; then
1919         add_flags="-ynd"
1920     fi
1921     doCommand "lxlite -cs -t: -mrn -mln ${D}add_flags ${D}dllFile"
1922 fi
1923 doCommand "emxomf -s -l ${D}arcFile"
1924
1925 # Successful exit.
1926 CleanUp 1
1927 exit 0
1928 EOF
1929 dnl ===================== dllar.sh ends here =====================
1930 ])
1931
1932 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_DEPS],
1933 [
1934 dnl ===================== bk-deps begins here =====================
1935 dnl    (Created by merge-scripts.py from bk-deps
1936 dnl     file do not edit here!)
1937 D='$'
1938 cat <<EOF >bk-deps
1939 #!/bin/sh
1940
1941 # This script is part of Bakefile (http://bakefile.sourceforge.net) autoconf
1942 # script. It is used to track C/C++ files dependencies in portable way.
1943 #
1944 # Permission is given to use this file in any way.
1945
1946 DEPSMODE=${DEPSMODE}
1947 DEPSDIR=.deps
1948 DEPSFLAG_GCC="${DEPSFLAG_GCC}"
1949 DEPSFLAG_MWCC="${DEPSFLAG_MWCC}"
1950
1951 mkdir -p ${D}DEPSDIR
1952
1953 if test ${D}DEPSMODE = gcc ; then
1954     ${D}* ${D}{DEPSFLAG_GCC}
1955     status=${D}?
1956     if test ${D}{status} != 0 ; then
1957         exit ${D}{status}
1958     fi
1959     # move created file to the location we want it in:
1960     while test ${D}# -gt 0; do
1961         case "${D}1" in
1962             -o )
1963                 shift
1964                 objfile=${D}1
1965             ;;
1966             -* )
1967             ;;
1968             * )
1969                 srcfile=${D}1
1970             ;;
1971         esac
1972         shift
1973     done
1974     depfile=\`basename ${D}srcfile | sed -e 's/\\..*${D}/.d/g'\`
1975     depobjname=\`echo ${D}depfile |sed -e 's/\\.d/.o/g'\`
1976     if test -f ${D}depfile ; then
1977         sed -e "s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{DEPSDIR}/${D}{objfile}.d
1978         rm -f ${D}depfile
1979     else
1980         depfile=\`basename ${D}objfile | sed -e 's/\\..*${D}/.d/g'\`
1981         if test -f ${D}depfile ; then
1982             sed -e "/^${D}objfile/!s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{DEPSDIR}/${D}{objfile}.d
1983             rm -f ${D}depfile
1984         fi
1985     fi
1986     exit 0
1987 elif test ${D}DEPSMODE = mwcc ; then
1988     ${D}*
1989     status=${D}?
1990     if test ${D}{status} != 0 ; then
1991         exit ${D}{status}
1992     fi
1993     # Run mwcc again with -MM and redirect into the dep file we want
1994     # NOTE: We can't use shift here because we need ${D}* to be valid
1995     prevarg=
1996     for arg in ${D}* ; do
1997         if test "${D}prevarg" = "-o"; then
1998             objfile=${D}arg
1999         else
2000             case "${D}arg" in
2001                 -* )
2002                 ;;
2003                 * )
2004                     srcfile=${D}arg
2005                 ;;
2006             esac
2007         fi
2008         prevarg="${D}arg"
2009     done
2010     ${D}* ${D}DEPSFLAG_MWCC >${D}{DEPSDIR}/${D}{objfile}.d
2011     exit 0
2012 else
2013     ${D}*
2014     exit ${D}?
2015 fi
2016 EOF
2017 dnl ===================== bk-deps ends here =====================
2018 ])
2019
2020 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH],
2021 [
2022 dnl ===================== shared-ld-sh begins here =====================
2023 dnl    (Created by merge-scripts.py from shared-ld-sh
2024 dnl     file do not edit here!)
2025 D='$'
2026 cat <<EOF >shared-ld-sh
2027 #!/bin/sh
2028 #-----------------------------------------------------------------------------
2029 #-- Name:        distrib/mac/shared-ld-sh
2030 #-- Purpose:     Link a mach-o dynamic shared library for Darwin / Mac OS X
2031 #-- Author:      Gilles Depeyrot
2032 #-- Copyright:   (c) 2002 Gilles Depeyrot
2033 #-- Licence:     any use permitted
2034 #-----------------------------------------------------------------------------
2035
2036 verbose=0
2037 args=""
2038 objects=""
2039 linking_flag="-dynamiclib"
2040
2041 while test ${D}# -gt 0; do
2042     case ${D}1 in
2043
2044        -v)
2045         verbose=1
2046         ;;
2047
2048        -o|-compatibility_version|-current_version|-framework|-undefined|-install_name)
2049         # collect these options and values
2050         args="${D}{args} ${D}1 ${D}2"
2051         shift
2052         ;;
2053
2054        -l*|-L*|-flat_namespace|-headerpad_max_install_names)
2055         # collect these options
2056         args="${D}{args} ${D}1"
2057         ;;
2058
2059        -dynamiclib|-bundle)
2060         linking_flag="${D}1"
2061         ;;
2062
2063        -*)
2064         echo "shared-ld: unhandled option '${D}1'"
2065         exit 1
2066         ;;
2067
2068         *.o | *.a | *.dylib)
2069         # collect object files
2070         objects="${D}{objects} ${D}1"
2071         ;;
2072
2073         *)
2074         echo "shared-ld: unhandled argument '${D}1'"
2075         exit 1
2076         ;;
2077
2078     esac
2079     shift
2080 done
2081
2082 #
2083 # Link one module containing all the others
2084 #
2085 if test ${D}{verbose} = 1; then
2086     echo "c++ -r -keep_private_externs -nostdlib ${D}{objects} -o master.${D}${D}.o"
2087 fi
2088 c++ -r -keep_private_externs -nostdlib ${D}{objects} -o master.${D}${D}.o
2089 status=${D}?
2090 if test ${D}{status} != 0; then
2091     exit ${D}{status}
2092 fi
2093
2094 #
2095 # Link the shared library from the single module created
2096 #
2097 if test ${D}{verbose} = 1; then
2098     echo "cc ${D}{linking_flag} master.${D}${D}.o ${D}{args}"
2099 fi
2100 c++ ${D}{linking_flag} master.${D}${D}.o ${D}{args}
2101 status=${D}?
2102 if test ${D}{status} != 0; then
2103     exit ${D}{status}
2104 fi
2105
2106 #
2107 # Remove intermediate module
2108 #
2109 rm -f master.${D}${D}.o
2110
2111 exit 0
2112 EOF
2113 dnl ===================== shared-ld-sh ends here =====================
2114 ])
2115
2116 AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_MAKE_PCH],
2117 [
2118 dnl ===================== bk-make-pch begins here =====================
2119 dnl    (Created by merge-scripts.py from bk-make-pch
2120 dnl     file do not edit here!)
2121 D='$'
2122 cat <<EOF >bk-make-pch
2123 #!/bin/sh
2124
2125 # This script is part of Bakefile (http://bakefile.sourceforge.net) autoconf
2126 # script. It is used to generated precompiled headers.
2127 #
2128 # Permission is given to use this file in any way.
2129
2130 outfile="${D}{1}"
2131 header="${D}{2}"
2132 shift
2133 shift
2134
2135 compiler=
2136 headerfile=
2137 while test ${D}{#} -gt 0; do
2138     case "${D}{1}" in
2139         -I* )
2140             incdir=\`echo ${D}{1} | sed -e 's/-I\\(.*\\)/\\1/g'\`
2141             if test "x${D}{headerfile}" = "x" -a -f "${D}{incdir}/${D}{header}" ; then
2142                 headerfile="${D}{incdir}/${D}{header}"
2143             fi
2144         ;;
2145     esac
2146     compiler="${D}{compiler} ${D}{1}"
2147     shift
2148 done
2149
2150 if test "x${D}{headerfile}" = "x" ; then
2151     echo "error: can't find header ${D}{header} in include paths" >2
2152 else
2153     if test -f ${D}{outfile} ; then
2154         rm -f ${D}{outfile}
2155     else
2156         mkdir -p \`dirname ${D}{outfile}\`
2157     fi
2158     depsfile=".deps/\`echo ${D}{outfile} | tr '/.' '__'\`.d"
2159     mkdir -p .deps
2160     # can do this because gcc is >= 3.4:
2161     ${D}{compiler} -o ${D}{outfile} -MMD -MF "${D}{depsfile}" "${D}{headerfile}"
2162     exit ${D}{?}
2163 fi
2164 EOF
2165 dnl ===================== bk-make-pch ends here =====================
2166 ])
2167
2168 # Configure paths for GTK+
2169 # Owen Taylor     1997-2001
2170
2171 dnl AM_PATH_GTK_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
2172 dnl Test for GTK+, and define GTK_CFLAGS and GTK_LIBS, if gthread is specified in MODULES, 
2173 dnl pass to pkg-config
2174 dnl
2175 AC_DEFUN([AM_PATH_GTK_2_0],
2176 [dnl 
2177 dnl Get the cflags and libraries from pkg-config
2178 dnl
2179 AC_ARG_ENABLE(gtktest, [  --disable-gtktest       do not try to compile and run a test GTK+ program],
2180                     , enable_gtktest=yes)
2181
2182   pkg_config_args=gtk+-2.0
2183   for module in . $4
2184   do
2185       case "$module" in
2186          gthread) 
2187              pkg_config_args="$pkg_config_args gthread-2.0"
2188          ;;
2189       esac
2190   done
2191
2192   no_gtk=""
2193
2194   AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
2195
2196   if test x$PKG_CONFIG != xno ; then
2197     if pkg-config --atleast-pkgconfig-version 0.7 ; then
2198       :
2199     else
2200       echo "*** pkg-config too old; version 0.7 or better required."
2201       no_gtk=yes
2202       PKG_CONFIG=no
2203     fi
2204   else
2205     no_gtk=yes
2206   fi
2207
2208   min_gtk_version=ifelse([$1], ,2.0.0,$1)
2209   AC_MSG_CHECKING(for GTK+ - version >= $min_gtk_version)
2210
2211   if test x$PKG_CONFIG != xno ; then
2212     ## don't try to run the test against uninstalled libtool libs
2213     if $PKG_CONFIG --uninstalled $pkg_config_args; then
2214           echo "Will use uninstalled version of GTK+ found in PKG_CONFIG_PATH"
2215           enable_gtktest=no
2216     fi
2217
2218     if $PKG_CONFIG --atleast-version $min_gtk_version $pkg_config_args; then
2219           :
2220     else
2221           no_gtk=yes
2222     fi
2223   fi
2224
2225   if test x"$no_gtk" = x ; then
2226     GTK_CFLAGS=`$PKG_CONFIG $pkg_config_args --cflags`
2227     GTK_LIBS=`$PKG_CONFIG $pkg_config_args --libs`
2228     gtk_config_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2229            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
2230     gtk_config_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2231            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
2232     gtk_config_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
2233            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
2234     if test "x$enable_gtktest" = "xyes" ; then
2235       ac_save_CFLAGS="$CFLAGS"
2236       ac_save_LIBS="$LIBS"
2237       CFLAGS="$CFLAGS $GTK_CFLAGS"
2238       LIBS="$GTK_LIBS $LIBS"
2239 dnl
2240 dnl Now check if the installed GTK+ is sufficiently new. (Also sanity
2241 dnl checks the results of pkg-config to some extent)
2242 dnl
2243       rm -f conf.gtktest
2244       AC_TRY_RUN([
2245 #include <gtk/gtk.h>
2246 #include <stdio.h>
2247 #include <stdlib.h>
2248
2249 int 
2250 main ()
2251 {
2252   int major, minor, micro;
2253   char *tmp_version;
2254
2255   system ("touch conf.gtktest");
2256
2257   /* HP/UX 9 (%@#!) writes to sscanf strings */
2258   tmp_version = g_strdup("$min_gtk_version");
2259   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2260      printf("%s, bad version string\n", "$min_gtk_version");
2261      exit(1);
2262    }
2263
2264   if ((gtk_major_version != $gtk_config_major_version) ||
2265       (gtk_minor_version != $gtk_config_minor_version) ||
2266       (gtk_micro_version != $gtk_config_micro_version))
2267     {
2268       printf("\n*** 'pkg-config --modversion gtk+-2.0' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n", 
2269              $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
2270              gtk_major_version, gtk_minor_version, gtk_micro_version);
2271       printf ("*** was found! If pkg-config was correct, then it is best\n");
2272       printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
2273       printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
2274       printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
2275       printf("*** required on your system.\n");
2276       printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
2277       printf("*** to point to the correct configuration files\n");
2278     } 
2279   else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
2280            (gtk_minor_version != GTK_MINOR_VERSION) ||
2281            (gtk_micro_version != GTK_MICRO_VERSION))
2282     {
2283       printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
2284              GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
2285       printf("*** library (version %d.%d.%d)\n",
2286              gtk_major_version, gtk_minor_version, gtk_micro_version);
2287     }
2288   else
2289     {
2290       if ((gtk_major_version > major) ||
2291         ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2292         ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
2293       {
2294         return 0;
2295        }
2296      else
2297       {
2298         printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
2299                gtk_major_version, gtk_minor_version, gtk_micro_version);
2300         printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
2301                major, minor, micro);
2302         printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
2303         printf("***\n");
2304         printf("*** If you have already installed a sufficiently new version, this error\n");
2305         printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
2306         printf("*** being found. The easiest way to fix this is to remove the old version\n");
2307         printf("*** of GTK+, but you can also set the PKG_CONFIG environment to point to the\n");
2308         printf("*** correct copy of pkg-config. (In this case, you will have to\n");
2309         printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
2310         printf("*** so that the correct libraries are found at run-time))\n");
2311       }
2312     }
2313   return 1;
2314 }
2315 ],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2316        CFLAGS="$ac_save_CFLAGS"
2317        LIBS="$ac_save_LIBS"
2318      fi
2319   fi
2320   if test "x$no_gtk" = x ; then
2321      AC_MSG_RESULT(yes (version $gtk_config_major_version.$gtk_config_minor_version.$gtk_config_micro_version))
2322      ifelse([$2], , :, [$2])     
2323   else
2324      AC_MSG_RESULT(no)
2325      if test "$PKG_CONFIG" = "no" ; then
2326        echo "*** A new enough version of pkg-config was not found."
2327        echo "*** See http://pkgconfig.sourceforge.net"
2328      else
2329        if test -f conf.gtktest ; then
2330         :
2331        else
2332           echo "*** Could not run GTK+ test program, checking why..."
2333           ac_save_CFLAGS="$CFLAGS"
2334           ac_save_LIBS="$LIBS"
2335           CFLAGS="$CFLAGS $GTK_CFLAGS"
2336           LIBS="$LIBS $GTK_LIBS"
2337           AC_TRY_LINK([
2338 #include <gtk/gtk.h>
2339 #include <stdio.h>
2340 ],      [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
2341         [ echo "*** The test program compiled, but did not run. This usually means"
2342           echo "*** that the run-time linker is not finding GTK+ or finding the wrong"
2343           echo "*** version of GTK+. If it is not finding GTK+, you'll need to set your"
2344           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
2345           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
2346           echo "*** is required on your system"
2347           echo "***"
2348           echo "*** If you have an old version installed, it is best to remove it, although"
2349           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
2350         [ echo "*** The test program failed to compile or link. See the file config.log for the"
2351           echo "*** exact error that occured. This usually means GTK+ is incorrectly installed."])
2352           CFLAGS="$ac_save_CFLAGS"
2353           LIBS="$ac_save_LIBS"
2354        fi
2355      fi
2356      GTK_CFLAGS=""
2357      GTK_LIBS=""
2358      ifelse([$3], , :, [$3])
2359   fi
2360   AC_SUBST(GTK_CFLAGS)
2361   AC_SUBST(GTK_LIBS)
2362   rm -f conf.gtktest
2363 ])
2364
2365 # Configure paths for GTK+
2366 # Owen Taylor     97-11-3
2367
2368 dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
2369 dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
2370 dnl
2371 AC_DEFUN(AM_PATH_GTK,
2372 [dnl 
2373 dnl Get the cflags and libraries from the gtk-config script
2374 dnl
2375 AC_ARG_WITH(gtk-prefix,[  --with-gtk-prefix=PFX   Prefix where GTK is installed (optional)],
2376             gtk_config_prefix="$withval", gtk_config_prefix="")
2377 AC_ARG_WITH(gtk-exec-prefix,[  --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)],
2378             gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="")
2379 AC_ARG_ENABLE(gtktest, [  --disable-gtktest       Do not try to compile and run a test GTK program],
2380                     , enable_gtktest=yes)
2381
2382   for module in . $4
2383   do
2384       case "$module" in
2385          gthread) 
2386              gtk_config_args="$gtk_config_args gthread"
2387          ;;
2388       esac
2389   done
2390
2391   if test x$gtk_config_exec_prefix != x ; then
2392      gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix"
2393      if test x${GTK_CONFIG+set} != xset ; then
2394         GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config
2395      fi
2396   fi
2397   if test x$gtk_config_prefix != x ; then
2398      gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix"
2399      if test x${GTK_CONFIG+set} != xset ; then
2400         GTK_CONFIG=$gtk_config_prefix/bin/gtk-config
2401      fi
2402   fi
2403
2404   AC_PATH_PROG(GTK_CONFIG, gtk-config, no)
2405   min_gtk_version=ifelse([$1], ,0.99.7,$1)
2406   AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
2407   no_gtk=""
2408   if test "$GTK_CONFIG" = "no" ; then
2409     no_gtk=yes
2410   else
2411     GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags`
2412     GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs`
2413     gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \
2414            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
2415     gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \
2416            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
2417     gtk_config_micro_version=`$GTK_CONFIG $gtk_config_args --version | \
2418            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
2419     if test "x$enable_gtktest" = "xyes" ; then
2420       ac_save_CFLAGS="$CFLAGS"
2421       ac_save_LIBS="$LIBS"
2422       CFLAGS="$CFLAGS $GTK_CFLAGS"
2423       LIBS="$GTK_LIBS $LIBS"
2424 dnl
2425 dnl Now check if the installed GTK is sufficiently new. (Also sanity
2426 dnl checks the results of gtk-config to some extent
2427 dnl
2428       rm -f conf.gtktest
2429       AC_TRY_RUN([
2430 #include <gtk/gtk.h>
2431 #include <stdio.h>
2432 #include <stdlib.h>
2433
2434 int 
2435 main ()
2436 {
2437   int major, minor, micro;
2438   char *tmp_version;
2439
2440   system ("touch conf.gtktest");
2441
2442   /* HP/UX 9 (%@#!) writes to sscanf strings */
2443   tmp_version = g_strdup("$min_gtk_version");
2444   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2445      printf("%s, bad version string\n", "$min_gtk_version");
2446      exit(1);
2447    }
2448
2449   if ((gtk_major_version != $gtk_config_major_version) ||
2450       (gtk_minor_version != $gtk_config_minor_version) ||
2451       (gtk_micro_version != $gtk_config_micro_version))
2452     {
2453       printf("\n*** 'gtk-config --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n", 
2454              $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
2455              gtk_major_version, gtk_minor_version, gtk_micro_version);
2456       printf ("*** was found! If gtk-config was correct, then it is best\n");
2457       printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
2458       printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
2459       printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
2460       printf("*** required on your system.\n");
2461       printf("*** If gtk-config was wrong, set the environment variable GTK_CONFIG\n");
2462       printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n");
2463       printf("*** before re-running configure\n");
2464     } 
2465 #if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION)
2466   else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
2467            (gtk_minor_version != GTK_MINOR_VERSION) ||
2468            (gtk_micro_version != GTK_MICRO_VERSION))
2469     {
2470       printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
2471              GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
2472       printf("*** library (version %d.%d.%d)\n",
2473              gtk_major_version, gtk_minor_version, gtk_micro_version);
2474     }
2475 #endif /* defined (GTK_MAJOR_VERSION) ... */
2476   else
2477     {
2478       if ((gtk_major_version > major) ||
2479         ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
2480         ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
2481       {
2482         return 0;
2483        }
2484      else
2485       {
2486         printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
2487                gtk_major_version, gtk_minor_version, gtk_micro_version);
2488         printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
2489                major, minor, micro);
2490         printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
2491         printf("***\n");
2492         printf("*** If you have already installed a sufficiently new version, this error\n");
2493         printf("*** probably means that the wrong copy of the gtk-config shell script is\n");
2494         printf("*** being found. The easiest way to fix this is to remove the old version\n");
2495         printf("*** of GTK+, but you can also set the GTK_CONFIG environment to point to the\n");
2496         printf("*** correct copy of gtk-config. (In this case, you will have to\n");
2497         printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
2498         printf("*** so that the correct libraries are found at run-time))\n");
2499       }
2500     }
2501   return 1;
2502 }
2503 ],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2504        CFLAGS="$ac_save_CFLAGS"
2505        LIBS="$ac_save_LIBS"
2506      fi
2507   fi
2508   if test "x$no_gtk" = x ; then
2509      AC_MSG_RESULT(yes)
2510      ifelse([$2], , :, [$2])     
2511   else
2512      AC_MSG_RESULT(no)
2513      if test "$GTK_CONFIG" = "no" ; then
2514        echo "*** The gtk-config script installed by GTK could not be found"
2515        echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in"
2516        echo "*** your path, or set the GTK_CONFIG environment variable to the"
2517        echo "*** full path to gtk-config."
2518      else
2519        if test -f conf.gtktest ; then
2520         :
2521        else
2522           echo "*** Could not run GTK test program, checking why..."
2523           CFLAGS="$CFLAGS $GTK_CFLAGS"
2524           LIBS="$LIBS $GTK_LIBS"
2525           AC_TRY_LINK([
2526 #include <gtk/gtk.h>
2527 #include <stdio.h>
2528 ],      [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
2529         [ echo "*** The test program compiled, but did not run. This usually means"
2530           echo "*** that the run-time linker is not finding GTK or finding the wrong"
2531           echo "*** version of GTK. If it is not finding GTK, you'll need to set your"
2532           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
2533           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
2534           echo "*** is required on your system"
2535           echo "***"
2536           echo "*** If you have an old version installed, it is best to remove it, although"
2537           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
2538           echo "***"
2539           echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
2540           echo "*** came with the system with the command"
2541           echo "***"
2542           echo "***    rpm --erase --nodeps gtk gtk-devel" ],
2543         [ echo "*** The test program failed to compile or link. See the file config.log for the"
2544           echo "*** exact error that occured. This usually means GTK was incorrectly installed"
2545           echo "*** or that you have moved GTK since it was installed. In the latter case, you"
2546           echo "*** may want to edit the gtk-config script: $GTK_CONFIG" ])
2547           CFLAGS="$ac_save_CFLAGS"
2548           LIBS="$ac_save_LIBS"
2549        fi
2550      fi
2551      GTK_CFLAGS=""
2552      GTK_LIBS=""
2553      ifelse([$3], , :, [$3])
2554   fi
2555   AC_SUBST(GTK_CFLAGS)
2556   AC_SUBST(GTK_LIBS)
2557   rm -f conf.gtktest
2558 ])
2559
2560
2561 dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not)
2562 dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
2563 dnl also defines GSTUFF_PKG_ERRORS on error
2564 AC_DEFUN(PKG_CHECK_MODULES, [
2565   succeeded=no
2566
2567   if test -z "$PKG_CONFIG"; then
2568     AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
2569   fi
2570
2571   if test "$PKG_CONFIG" = "no" ; then
2572      echo "*** The pkg-config script could not be found. Make sure it is"
2573      echo "*** in your path, or set the PKG_CONFIG environment variable"
2574      echo "*** to the full path to pkg-config."
2575      echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
2576   else
2577      PKG_CONFIG_MIN_VERSION=0.9.0
2578      if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
2579         AC_MSG_CHECKING(for $2)
2580
2581         if $PKG_CONFIG --exists "$2" ; then
2582             AC_MSG_RESULT(yes)
2583             succeeded=yes
2584
2585             AC_MSG_CHECKING($1_CFLAGS)
2586             $1_CFLAGS=`$PKG_CONFIG --cflags "$2"`
2587             AC_MSG_RESULT($$1_CFLAGS)
2588
2589             AC_MSG_CHECKING($1_LIBS)
2590             $1_LIBS=`$PKG_CONFIG --libs "$2"`
2591             AC_MSG_RESULT($$1_LIBS)
2592         else
2593             $1_CFLAGS=""
2594             $1_LIBS=""
2595             ## If we have a custom action on failure, don't print errors, but 
2596             ## do set a variable so people can do so.
2597             $1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
2598             ifelse([$4], ,echo $$1_PKG_ERRORS,)
2599         fi
2600
2601         AC_SUBST($1_CFLAGS)
2602         AC_SUBST($1_LIBS)
2603      else
2604         echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
2605         echo "*** See http://www.freedesktop.org/software/pkgconfig"
2606      fi
2607   fi
2608
2609   if test $succeeded = yes; then
2610      ifelse([$3], , :, [$3])
2611   else
2612      ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4])
2613   fi
2614 ])
2615
2616
2617
2618 # Configure paths for SDL
2619 # Sam Lantinga 9/21/99
2620 # stolen from Manish Singh
2621 # stolen back from Frank Belew
2622 # stolen from Manish Singh
2623 # Shamelessly stolen from Owen Taylor
2624
2625 dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
2626 dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
2627 dnl
2628 AC_DEFUN([AM_PATH_SDL],
2629 [dnl 
2630 dnl Get the cflags and libraries from the sdl-config script
2631 dnl
2632 AC_ARG_WITH(sdl-prefix,[  --with-sdl-prefix=PFX   Prefix where SDL is installed (optional)],
2633             sdl_prefix="$withval", sdl_prefix="")
2634 AC_ARG_WITH(sdl-exec-prefix,[  --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
2635             sdl_exec_prefix="$withval", sdl_exec_prefix="")
2636 AC_ARG_ENABLE(sdltest, [  --disable-sdltest       Do not try to compile and run a test SDL program],
2637                     , enable_sdltest=yes)
2638
2639   if test x$sdl_exec_prefix != x ; then
2640      sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix"
2641      if test x${SDL_CONFIG+set} != xset ; then
2642         SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
2643      fi
2644   fi
2645   if test x$sdl_prefix != x ; then
2646      sdl_args="$sdl_args --prefix=$sdl_prefix"
2647      if test x${SDL_CONFIG+set} != xset ; then
2648         SDL_CONFIG=$sdl_prefix/bin/sdl-config
2649      fi
2650   fi
2651
2652   AC_REQUIRE([AC_CANONICAL_TARGET])
2653   PATH="$prefix/bin:$prefix/usr/bin:$PATH"
2654   AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH])
2655   min_sdl_version=ifelse([$1], ,0.11.0,$1)
2656   AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
2657   no_sdl=""
2658   if test "$SDL_CONFIG" = "no" ; then
2659     no_sdl=yes
2660   else
2661     SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags`
2662     SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs`
2663
2664     sdl_major_version=`$SDL_CONFIG $sdl_args --version | \
2665            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
2666     sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \
2667            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
2668     sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
2669            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
2670     if test "x$enable_sdltest" = "xyes" ; then
2671       ac_save_CFLAGS="$CFLAGS"
2672       ac_save_CXXFLAGS="$CXXFLAGS"
2673       ac_save_LIBS="$LIBS"
2674       CFLAGS="$CFLAGS $SDL_CFLAGS"
2675       CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
2676       LIBS="$LIBS $SDL_LIBS"
2677 dnl
2678 dnl Now check if the installed SDL is sufficiently new. (Also sanity
2679 dnl checks the results of sdl-config to some extent
2680 dnl
2681       rm -f conf.sdltest
2682       AC_TRY_RUN([
2683 #include <stdio.h>
2684 #include <stdlib.h>
2685 #include <string.h>
2686 #include "SDL.h"
2687
2688 char*
2689 my_strdup (char *str)
2690 {
2691   char *new_str;
2692   
2693   if (str)
2694     {
2695       new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
2696       strcpy (new_str, str);
2697     }
2698   else
2699     new_str = NULL;
2700   
2701   return new_str;
2702 }
2703
2704 int main (int argc, char *argv[])
2705 {
2706   int major, minor, micro;
2707   char *tmp_version;
2708
2709   /* This hangs on some systems (?)
2710   system ("touch conf.sdltest");
2711   */
2712   { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
2713
2714   /* HP/UX 9 (%@#!) writes to sscanf strings */
2715   tmp_version = my_strdup("$min_sdl_version");
2716   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
2717      printf("%s, bad version string\n", "$min_sdl_version");
2718      exit(1);
2719    }
2720
2721    if (($sdl_major_version > major) ||
2722       (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
2723       (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
2724     {
2725       return 0;
2726     }
2727   else
2728     {
2729       printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
2730       printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
2731       printf("*** best to upgrade to the required version.\n");
2732       printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
2733       printf("*** to point to the correct copy of sdl-config, and remove the file\n");
2734       printf("*** config.cache before re-running configure\n");
2735       return 1;
2736     }
2737 }
2738
2739 ],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
2740        CFLAGS="$ac_save_CFLAGS"
2741        CXXFLAGS="$ac_save_CXXFLAGS"
2742        LIBS="$ac_save_LIBS"
2743      fi
2744   fi
2745   if test "x$no_sdl" = x ; then
2746      AC_MSG_RESULT(yes)
2747      ifelse([$2], , :, [$2])     
2748   else
2749      AC_MSG_RESULT(no)
2750      if test "$SDL_CONFIG" = "no" ; then
2751        echo "*** The sdl-config script installed by SDL could not be found"
2752        echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
2753        echo "*** your path, or set the SDL_CONFIG environment variable to the"
2754        echo "*** full path to sdl-config."
2755      else
2756        if test -f conf.sdltest ; then
2757         :
2758        else
2759           echo "*** Could not run SDL test program, checking why..."
2760           CFLAGS="$CFLAGS $SDL_CFLAGS"
2761           CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
2762           LIBS="$LIBS $SDL_LIBS"
2763           AC_TRY_LINK([
2764 #include <stdio.h>
2765 #include "SDL.h"
2766
2767 int main(int argc, char *argv[])
2768 { return 0; }
2769 #undef  main
2770 #define main K_and_R_C_main
2771 ],      [ return 0; ],
2772         [ echo "*** The test program compiled, but did not run. This usually means"
2773           echo "*** that the run-time linker is not finding SDL or finding the wrong"
2774           echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
2775           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
2776           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
2777           echo "*** is required on your system"
2778           echo "***"
2779           echo "*** If you have an old version installed, it is best to remove it, although"
2780           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
2781         [ echo "*** The test program failed to compile or link. See the file config.log for the"
2782           echo "*** exact error that occured. This usually means SDL was incorrectly installed"
2783           echo "*** or that you have moved SDL since it was installed. In the latter case, you"
2784           echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
2785           CFLAGS="$ac_save_CFLAGS"
2786           CXXFLAGS="$ac_save_CXXFLAGS"
2787           LIBS="$ac_save_LIBS"
2788        fi
2789      fi
2790      SDL_CFLAGS=""
2791      SDL_LIBS=""
2792      ifelse([$3], , :, [$3])
2793   fi
2794   AC_SUBST(SDL_CFLAGS)
2795   AC_SUBST(SDL_LIBS)
2796   rm -f conf.sdltest
2797 ])
2798
2799 dnl Perform a check for a GStreamer element using gst-inspect
2800 dnl Thomas Vander Stichele <thomas at apestaart dot org>
2801 dnl Last modification: 25/01/2005
2802
2803 dnl AM_GST_ELEMENT_CHECK(ELEMENT-NAME, ACTION-IF-FOUND, ACTION-IF-NOT-FOUND)
2804
2805 AC_DEFUN([AM_GST_ELEMENT_CHECK],
2806 [
2807   if test "x$GST_INSPECT" == "x"; then
2808     AC_CHECK_PROG(GST_INSPECT, gst-inspect, gst-inspect, [])
2809   fi
2810
2811   if test "x$GST_INSPECT" != "x"; then
2812     AC_MSG_CHECKING(GStreamer element $1)
2813     if [ $GST_INSPECT $1 > /dev/null 2> /dev/null ]; then
2814       AC_MSG_RESULT(found.)
2815       $2
2816     else
2817       AC_MSG_RESULT(not found.)
2818       $3
2819     fi
2820   fi
2821 ])
2822
2823 dnl
2824 dnl AM_PATH_CPPUNIT(MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
2825 dnl
2826 AC_DEFUN(AM_PATH_CPPUNIT,
2827 [
2828
2829 AC_ARG_WITH(cppunit-prefix,[  --with-cppunit-prefix=PFX   Prefix where CppUnit is installed (optional)],
2830             cppunit_config_prefix="$withval", cppunit_config_prefix="")
2831 AC_ARG_WITH(cppunit-exec-prefix,[  --with-cppunit-exec-prefix=PFX  Exec prefix where CppUnit is installed (optional)],
2832             cppunit_config_exec_prefix="$withval", cppunit_config_exec_prefix="")
2833
2834   if test x$cppunit_config_exec_prefix != x ; then
2835      cppunit_config_args="$cppunit_config_args --exec-prefix=$cppunit_config_exec_prefix"
2836      if test x${CPPUNIT_CONFIG+set} != xset ; then
2837         CPPUNIT_CONFIG=$cppunit_config_exec_prefix/bin/cppunit-config
2838      fi
2839   fi
2840   if test x$cppunit_config_prefix != x ; then
2841      cppunit_config_args="$cppunit_config_args --prefix=$cppunit_config_prefix"
2842      if test x${CPPUNIT_CONFIG+set} != xset ; then
2843         CPPUNIT_CONFIG=$cppunit_config_prefix/bin/cppunit-config
2844      fi
2845   fi
2846
2847   AC_PATH_PROG(CPPUNIT_CONFIG, cppunit-config, no)
2848   cppunit_version_min=$1
2849
2850   AC_MSG_CHECKING(for Cppunit - version >= $cppunit_version_min)
2851   no_cppunit=""
2852   if test "$CPPUNIT_CONFIG" = "no" ; then
2853     no_cppunit=yes
2854   else
2855     CPPUNIT_CFLAGS=`$CPPUNIT_CONFIG --cflags`
2856     CPPUNIT_LIBS=`$CPPUNIT_CONFIG --libs`
2857     cppunit_version=`$CPPUNIT_CONFIG --version`
2858
2859     cppunit_major_version=`echo $cppunit_version | \
2860            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
2861     cppunit_minor_version=`echo $cppunit_version | \
2862            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
2863     cppunit_micro_version=`echo $cppunit_version | \
2864            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
2865
2866     cppunit_major_min=`echo $cppunit_version_min | \
2867            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
2868     cppunit_minor_min=`echo $cppunit_version_min | \
2869            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
2870     cppunit_micro_min=`echo $cppunit_version_min | \
2871            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
2872
2873     cppunit_version_proper=`expr \
2874         $cppunit_major_version \> $cppunit_major_min \| \
2875         $cppunit_major_version \= $cppunit_major_min \& \
2876         $cppunit_minor_version \> $cppunit_minor_min \| \
2877         $cppunit_major_version \= $cppunit_major_min \& \
2878         $cppunit_minor_version \= $cppunit_minor_min \& \
2879         $cppunit_micro_version \>= $cppunit_micro_min `
2880
2881     if test "$cppunit_version_proper" = "1" ; then
2882       AC_MSG_RESULT([$cppunit_major_version.$cppunit_minor_version.$cppunit_micro_version])
2883     else
2884       AC_MSG_RESULT(no)
2885       no_cppunit=yes
2886     fi
2887   fi
2888
2889   if test "x$no_cppunit" = x ; then
2890      ifelse([$2], , :, [$2])     
2891   else
2892      CPPUNIT_CFLAGS=""
2893      CPPUNIT_LIBS=""
2894      ifelse([$3], , :, [$3])
2895   fi
2896
2897   AC_SUBST(CPPUNIT_CFLAGS)
2898   AC_SUBST(CPPUNIT_LIBS)
2899 ])
2900
2901
2902
2903