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