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