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