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