]> git.saurik.com Git - wxWidgets.git/blame - aclocal.m4
Fix for probably rare but potential refcount leak.
[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
ecfd48ca
VZ
611dnl and http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_static_cast.html
612AC_DEFUN([AC_CXX_STATIC_CAST],
613[AC_CACHE_CHECK(whether the compiler supports static_cast<>,
614ac_cv_cxx_static_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 () {} };
620int g (Derived&) { return 0; }],[
621Derived d; Base& b = d; Derived& s = static_cast<Derived&> (b); return g (s);],
622 ac_cv_cxx_static_cast=yes, ac_cv_cxx_static_cast=no)
623 AC_LANG_RESTORE
624])
625if test "$ac_cv_cxx_static_cast" = yes; then
626 AC_DEFINE(HAVE_STATIC_CAST,, [define if the compiler supports static_cast<>])
627fi
628])
629
9e691f46
VZ
630# Configure paths for GTK+
631# Owen Taylor 1997-2001
b040e242
VS
632
633dnl AM_PATH_GTK_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
9e691f46
VZ
634dnl Test for GTK+, and define GTK_CFLAGS and GTK_LIBS, if gthread is specified in MODULES,
635dnl pass to pkg-config
3f345b47 636dnl
c2218763 637AC_DEFUN([AM_PATH_GTK_2_0],
9e691f46
VZ
638[dnl
639dnl Get the cflags and libraries from pkg-config
3f345b47 640dnl
9e691f46
VZ
641AC_ARG_ENABLE(gtktest, [ --disable-gtktest do not try to compile and run a test GTK+ program],
642 , enable_gtktest=yes)
3f345b47 643
9e691f46 644 pkg_config_args=gtk+-2.0
3f345b47
VZ
645 for module in . $4
646 do
647 case "$module" in
9e691f46
VZ
648 gthread)
649 pkg_config_args="$pkg_config_args gthread-2.0"
3f345b47
VZ
650 ;;
651 esac
652 done
653
9e691f46
VZ
654 no_gtk=""
655
656 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
657
658 if test x$PKG_CONFIG != xno ; then
659 if pkg-config --atleast-pkgconfig-version 0.7 ; then
660 :
661 else
c2218763 662 echo "*** pkg-config too old; version 0.7 or better required."
9e691f46
VZ
663 no_gtk=yes
664 PKG_CONFIG=no
665 fi
666 else
667 no_gtk=yes
8168de4c 668 fi
9e691f46
VZ
669
670 min_gtk_version=ifelse([$1], ,2.0.0,$1)
671 AC_MSG_CHECKING(for GTK+ - version >= $min_gtk_version)
672
673 if test x$PKG_CONFIG != xno ; then
674 ## don't try to run the test against uninstalled libtool libs
675 if $PKG_CONFIG --uninstalled $pkg_config_args; then
676 echo "Will use uninstalled version of GTK+ found in PKG_CONFIG_PATH"
677 enable_gtktest=no
678 fi
679
680 if $PKG_CONFIG --atleast-version $min_gtk_version $pkg_config_args; then
681 :
682 else
683 no_gtk=yes
684 fi
8168de4c
VZ
685 fi
686
9e691f46
VZ
687 if test x"$no_gtk" = x ; then
688 GTK_CFLAGS=`$PKG_CONFIG $pkg_config_args --cflags`
689 GTK_LIBS=`$PKG_CONFIG $pkg_config_args --libs`
690 gtk_config_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
3f345b47 691 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
9e691f46 692 gtk_config_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
3f345b47 693 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
9e691f46 694 gtk_config_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
3f345b47
VZ
695 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
696 if test "x$enable_gtktest" = "xyes" ; then
697 ac_save_CFLAGS="$CFLAGS"
698 ac_save_LIBS="$LIBS"
699 CFLAGS="$CFLAGS $GTK_CFLAGS"
700 LIBS="$GTK_LIBS $LIBS"
8168de4c 701dnl
9e691f46
VZ
702dnl Now check if the installed GTK+ is sufficiently new. (Also sanity
703dnl checks the results of pkg-config to some extent)
8168de4c 704dnl
3f345b47
VZ
705 rm -f conf.gtktest
706 AC_TRY_RUN([
8168de4c 707#include <gtk/gtk.h>
8168de4c
VZ
708#include <stdio.h>
709#include <stdlib.h>
710
9e691f46 711int
8168de4c
VZ
712main ()
713{
714 int major, minor, micro;
3f345b47 715 char *tmp_version;
8168de4c 716
3f345b47 717 system ("touch conf.gtktest");
8168de4c 718
3f345b47
VZ
719 /* HP/UX 9 (%@#!) writes to sscanf strings */
720 tmp_version = g_strdup("$min_gtk_version");
721 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
722 printf("%s, bad version string\n", "$min_gtk_version");
8168de4c
VZ
723 exit(1);
724 }
725
3f345b47
VZ
726 if ((gtk_major_version != $gtk_config_major_version) ||
727 (gtk_minor_version != $gtk_config_minor_version) ||
728 (gtk_micro_version != $gtk_config_micro_version))
729 {
9e691f46 730 printf("\n*** 'pkg-config --modversion gtk+-2.0' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
3f345b47
VZ
731 $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
732 gtk_major_version, gtk_minor_version, gtk_micro_version);
9e691f46 733 printf ("*** was found! If pkg-config was correct, then it is best\n");
3f345b47
VZ
734 printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
735 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
736 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
737 printf("*** required on your system.\n");
9e691f46
VZ
738 printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
739 printf("*** to point to the correct configuration files\n");
740 }
3f345b47 741 else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
9e691f46 742 (gtk_minor_version != GTK_MINOR_VERSION) ||
3f345b47
VZ
743 (gtk_micro_version != GTK_MICRO_VERSION))
744 {
745 printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
9e691f46 746 GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
3f345b47 747 printf("*** library (version %d.%d.%d)\n",
9e691f46 748 gtk_major_version, gtk_minor_version, gtk_micro_version);
3f345b47 749 }
3f345b47
VZ
750 else
751 {
752 if ((gtk_major_version > major) ||
753 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
754 ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
755 {
756 return 0;
757 }
758 else
759 {
760 printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
761 gtk_major_version, gtk_minor_version, gtk_micro_version);
762 printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
9e691f46 763 major, minor, micro);
3f345b47
VZ
764 printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
765 printf("***\n");
766 printf("*** If you have already installed a sufficiently new version, this error\n");
9e691f46 767 printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
3f345b47 768 printf("*** being found. The easiest way to fix this is to remove the old version\n");
9e691f46
VZ
769 printf("*** of GTK+, but you can also set the PKG_CONFIG environment to point to the\n");
770 printf("*** correct copy of pkg-config. (In this case, you will have to\n");
3f345b47
VZ
771 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
772 printf("*** so that the correct libraries are found at run-time))\n");
773 }
774 }
775 return 1;
8168de4c
VZ
776}
777],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
3f345b47
VZ
778 CFLAGS="$ac_save_CFLAGS"
779 LIBS="$ac_save_LIBS"
780 fi
8168de4c
VZ
781 fi
782 if test "x$no_gtk" = x ; then
b040e242 783 AC_MSG_RESULT(yes (version $gtk_config_major_version.$gtk_config_minor_version.$gtk_config_micro_version))
9e691f46 784 ifelse([$2], , :, [$2])
8168de4c
VZ
785 else
786 AC_MSG_RESULT(no)
9e691f46
VZ
787 if test "$PKG_CONFIG" = "no" ; then
788 echo "*** A new enough version of pkg-config was not found."
789 echo "*** See http://pkgconfig.sourceforge.net"
3f345b47
VZ
790 else
791 if test -f conf.gtktest ; then
792 :
793 else
9e691f46 794 echo "*** Could not run GTK+ test program, checking why..."
579d8138
VS
795 ac_save_CFLAGS="$CFLAGS"
796 ac_save_LIBS="$LIBS"
3f345b47
VZ
797 CFLAGS="$CFLAGS $GTK_CFLAGS"
798 LIBS="$LIBS $GTK_LIBS"
799 AC_TRY_LINK([
800#include <gtk/gtk.h>
801#include <stdio.h>
802], [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
803 [ echo "*** The test program compiled, but did not run. This usually means"
9e691f46
VZ
804 echo "*** that the run-time linker is not finding GTK+ or finding the wrong"
805 echo "*** version of GTK+. If it is not finding GTK+, you'll need to set your"
3f345b47
VZ
806 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
807 echo "*** to the installed location Also, make sure you have run ldconfig if that"
808 echo "*** is required on your system"
9e691f46 809 echo "***"
3f345b47 810 echo "*** If you have an old version installed, it is best to remove it, although"
9e691f46 811 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
3f345b47 812 [ echo "*** The test program failed to compile or link. See the file config.log for the"
579d8138 813 echo "*** exact error that occured. This usually means GTK+ is incorrectly installed."])
3f345b47
VZ
814 CFLAGS="$ac_save_CFLAGS"
815 LIBS="$ac_save_LIBS"
816 fi
817 fi
8168de4c
VZ
818 GTK_CFLAGS=""
819 GTK_LIBS=""
820 ifelse([$3], , :, [$3])
821 fi
822 AC_SUBST(GTK_CFLAGS)
823 AC_SUBST(GTK_LIBS)
3f345b47 824 rm -f conf.gtktest
8168de4c
VZ
825])
826
b040e242
VS
827# Configure paths for GTK+
828# Owen Taylor 97-11-3
829
830dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
ecc7ceee
OK
831dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
832dnl
b040e242
VS
833AC_DEFUN(AM_PATH_GTK,
834[dnl
835dnl Get the cflags and libraries from the gtk-config script
ecc7ceee
OK
836dnl
837AC_ARG_WITH(gtk-prefix,[ --with-gtk-prefix=PFX Prefix where GTK is installed (optional)],
838 gtk_config_prefix="$withval", gtk_config_prefix="")
839AC_ARG_WITH(gtk-exec-prefix,[ --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)],
840 gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="")
841AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
b040e242 842 , enable_gtktest=yes)
ecc7ceee
OK
843
844 for module in . $4
845 do
846 case "$module" in
b040e242 847 gthread)
ecc7ceee
OK
848 gtk_config_args="$gtk_config_args gthread"
849 ;;
850 esac
851 done
852
853 if test x$gtk_config_exec_prefix != x ; then
854 gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix"
b040e242
VS
855 if test x${GTK_CONFIG+set} != xset ; then
856 GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config
ecc7ceee
OK
857 fi
858 fi
859 if test x$gtk_config_prefix != x ; then
860 gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix"
b040e242
VS
861 if test x${GTK_CONFIG+set} != xset ; then
862 GTK_CONFIG=$gtk_config_prefix/bin/gtk-config
ecc7ceee
OK
863 fi
864 fi
865
b040e242
VS
866 AC_PATH_PROG(GTK_CONFIG, gtk-config, no)
867 min_gtk_version=ifelse([$1], ,0.99.7,$1)
ecc7ceee
OK
868 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
869 no_gtk=""
b040e242 870 if test "$GTK_CONFIG" = "no" ; then
ecc7ceee
OK
871 no_gtk=yes
872 else
b040e242
VS
873 GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags`
874 GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs`
875 gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \
ecc7ceee 876 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
b040e242 877 gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \
ecc7ceee 878 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
b040e242 879 gtk_config_micro_version=`$GTK_CONFIG $gtk_config_args --version | \
ecc7ceee
OK
880 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
881 if test "x$enable_gtktest" = "xyes" ; then
882 ac_save_CFLAGS="$CFLAGS"
883 ac_save_LIBS="$LIBS"
884 CFLAGS="$CFLAGS $GTK_CFLAGS"
885 LIBS="$GTK_LIBS $LIBS"
886dnl
887dnl Now check if the installed GTK is sufficiently new. (Also sanity
b040e242 888dnl checks the results of gtk-config to some extent
ecc7ceee
OK
889dnl
890 rm -f conf.gtktest
891 AC_TRY_RUN([
892#include <gtk/gtk.h>
893#include <stdio.h>
894#include <stdlib.h>
895
b040e242 896int
ecc7ceee
OK
897main ()
898{
899 int major, minor, micro;
900 char *tmp_version;
901
902 system ("touch conf.gtktest");
903
904 /* HP/UX 9 (%@#!) writes to sscanf strings */
905 tmp_version = g_strdup("$min_gtk_version");
906 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
907 printf("%s, bad version string\n", "$min_gtk_version");
908 exit(1);
909 }
910
911 if ((gtk_major_version != $gtk_config_major_version) ||
912 (gtk_minor_version != $gtk_config_minor_version) ||
913 (gtk_micro_version != $gtk_config_micro_version))
914 {
b040e242 915 printf("\n*** 'gtk-config --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
ecc7ceee
OK
916 $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
917 gtk_major_version, gtk_minor_version, gtk_micro_version);
b040e242 918 printf ("*** was found! If gtk-config was correct, then it is best\n");
ecc7ceee
OK
919 printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
920 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
921 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
922 printf("*** required on your system.\n");
b040e242
VS
923 printf("*** If gtk-config was wrong, set the environment variable GTK_CONFIG\n");
924 printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n");
ecc7ceee 925 printf("*** before re-running configure\n");
b040e242 926 }
ecc7ceee
OK
927#if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION)
928 else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
b040e242 929 (gtk_minor_version != GTK_MINOR_VERSION) ||
ecc7ceee
OK
930 (gtk_micro_version != GTK_MICRO_VERSION))
931 {
932 printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
b040e242 933 GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
ecc7ceee 934 printf("*** library (version %d.%d.%d)\n",
b040e242 935 gtk_major_version, gtk_minor_version, gtk_micro_version);
ecc7ceee
OK
936 }
937#endif /* defined (GTK_MAJOR_VERSION) ... */
938 else
939 {
940 if ((gtk_major_version > major) ||
941 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
942 ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
943 {
944 return 0;
945 }
946 else
947 {
948 printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
949 gtk_major_version, gtk_minor_version, gtk_micro_version);
950 printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
b040e242 951 major, minor, micro);
ecc7ceee
OK
952 printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
953 printf("***\n");
954 printf("*** If you have already installed a sufficiently new version, this error\n");
b040e242 955 printf("*** probably means that the wrong copy of the gtk-config shell script is\n");
ecc7ceee 956 printf("*** being found. The easiest way to fix this is to remove the old version\n");
b040e242
VS
957 printf("*** of GTK+, but you can also set the GTK_CONFIG environment to point to the\n");
958 printf("*** correct copy of gtk-config. (In this case, you will have to\n");
ecc7ceee
OK
959 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
960 printf("*** so that the correct libraries are found at run-time))\n");
961 }
962 }
963 return 1;
964}
965],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
966 CFLAGS="$ac_save_CFLAGS"
967 LIBS="$ac_save_LIBS"
968 fi
969 fi
970 if test "x$no_gtk" = x ; then
b040e242
VS
971 AC_MSG_RESULT(yes)
972 ifelse([$2], , :, [$2])
ecc7ceee
OK
973 else
974 AC_MSG_RESULT(no)
b040e242
VS
975 if test "$GTK_CONFIG" = "no" ; then
976 echo "*** The gtk-config script installed by GTK could not be found"
ecc7ceee 977 echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in"
b040e242
VS
978 echo "*** your path, or set the GTK_CONFIG environment variable to the"
979 echo "*** full path to gtk-config."
ecc7ceee
OK
980 else
981 if test -f conf.gtktest ; then
982 :
983 else
984 echo "*** Could not run GTK test program, checking why..."
985 CFLAGS="$CFLAGS $GTK_CFLAGS"
986 LIBS="$LIBS $GTK_LIBS"
987 AC_TRY_LINK([
988#include <gtk/gtk.h>
989#include <stdio.h>
990], [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
991 [ echo "*** The test program compiled, but did not run. This usually means"
992 echo "*** that the run-time linker is not finding GTK or finding the wrong"
993 echo "*** version of GTK. If it is not finding GTK, you'll need to set your"
994 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
995 echo "*** to the installed location Also, make sure you have run ldconfig if that"
996 echo "*** is required on your system"
b040e242 997 echo "***"
ecc7ceee
OK
998 echo "*** If you have an old version installed, it is best to remove it, although"
999 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
1000 echo "***"
1001 echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
1002 echo "*** came with the system with the command"
1003 echo "***"
1004 echo "*** rpm --erase --nodeps gtk gtk-devel" ],
1005 [ echo "*** The test program failed to compile or link. See the file config.log for the"
1006 echo "*** exact error that occured. This usually means GTK was incorrectly installed"
1007 echo "*** or that you have moved GTK since it was installed. In the latter case, you"
b040e242 1008 echo "*** may want to edit the gtk-config script: $GTK_CONFIG" ])
ecc7ceee
OK
1009 CFLAGS="$ac_save_CFLAGS"
1010 LIBS="$ac_save_LIBS"
1011 fi
1012 fi
1013 GTK_CFLAGS=""
1014 GTK_LIBS=""
1015 ifelse([$3], , :, [$3])
1016 fi
1017 AC_SUBST(GTK_CFLAGS)
1018 AC_SUBST(GTK_LIBS)
1019 rm -f conf.gtktest
1020])
8168de4c 1021
2b5f62a0
VZ
1022
1023dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not)
1024dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
1025dnl also defines GSTUFF_PKG_ERRORS on error
1026AC_DEFUN(PKG_CHECK_MODULES, [
1027 succeeded=no
1028
1029 if test -z "$PKG_CONFIG"; then
1030 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
1031 fi
1032
1033 if test "$PKG_CONFIG" = "no" ; then
1034 echo "*** The pkg-config script could not be found. Make sure it is"
1035 echo "*** in your path, or set the PKG_CONFIG environment variable"
1036 echo "*** to the full path to pkg-config."
1037 echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
1038 else
1039 PKG_CONFIG_MIN_VERSION=0.9.0
1040 if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
1041 AC_MSG_CHECKING(for $2)
1042
1043 if $PKG_CONFIG --exists "$2" ; then
1044 AC_MSG_RESULT(yes)
1045 succeeded=yes
1046
1047 AC_MSG_CHECKING($1_CFLAGS)
1048 $1_CFLAGS=`$PKG_CONFIG --cflags "$2"`
1049 AC_MSG_RESULT($$1_CFLAGS)
1050
1051 AC_MSG_CHECKING($1_LIBS)
1052 $1_LIBS=`$PKG_CONFIG --libs "$2"`
1053 AC_MSG_RESULT($$1_LIBS)
1054 else
1055 $1_CFLAGS=""
1056 $1_LIBS=""
1057 ## If we have a custom action on failure, don't print errors, but
1058 ## do set a variable so people can do so.
1059 $1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
1060 ifelse([$4], ,echo $$1_PKG_ERRORS,)
1061 fi
1062
1063 AC_SUBST($1_CFLAGS)
1064 AC_SUBST($1_LIBS)
1065 else
1066 echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
1067 echo "*** See http://www.freedesktop.org/software/pkgconfig"
1068 fi
1069 fi
1070
1071 if test $succeeded = yes; then
1072 ifelse([$3], , :, [$3])
1073 else
1074 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])
1075 fi
1076])
1077
1078
1079
f93ca9fd
VS
1080# Configure paths for SDL
1081# Sam Lantinga 9/21/99
1082# stolen from Manish Singh
1083# stolen back from Frank Belew
1084# stolen from Manish Singh
1085# Shamelessly stolen from Owen Taylor
1086
1087dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
1088dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
1089dnl
670ec357 1090AC_DEFUN([AM_PATH_SDL],
f93ca9fd
VS
1091[dnl
1092dnl Get the cflags and libraries from the sdl-config script
1093dnl
1094AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)],
1095 sdl_prefix="$withval", sdl_prefix="")
1096AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
1097 sdl_exec_prefix="$withval", sdl_exec_prefix="")
1098AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program],
1099 , enable_sdltest=yes)
1100
1101 if test x$sdl_exec_prefix != x ; then
1102 sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix"
1103 if test x${SDL_CONFIG+set} != xset ; then
1104 SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
1105 fi
1106 fi
1107 if test x$sdl_prefix != x ; then
1108 sdl_args="$sdl_args --prefix=$sdl_prefix"
1109 if test x${SDL_CONFIG+set} != xset ; then
1110 SDL_CONFIG=$sdl_prefix/bin/sdl-config
1111 fi
1112 fi
1113
1114 AC_REQUIRE([AC_CANONICAL_TARGET])
1115 PATH="$prefix/bin:$prefix/usr/bin:$PATH"
1116 AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH])
1117 min_sdl_version=ifelse([$1], ,0.11.0,$1)
1118 AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
1119 no_sdl=""
1120 if test "$SDL_CONFIG" = "no" ; then
1121 no_sdl=yes
1122 else
1123 SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags`
1124 SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs`
1125
1126 sdl_major_version=`$SDL_CONFIG $sdl_args --version | \
1127 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
1128 sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \
1129 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
1130 sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
1131 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
1132 if test "x$enable_sdltest" = "xyes" ; then
1133 ac_save_CFLAGS="$CFLAGS"
1134 ac_save_LIBS="$LIBS"
1135 CFLAGS="$CFLAGS $SDL_CFLAGS"
1136 LIBS="$LIBS $SDL_LIBS"
1137dnl
1138dnl Now check if the installed SDL is sufficiently new. (Also sanity
1139dnl checks the results of sdl-config to some extent
1140dnl
1141 rm -f conf.sdltest
1142 AC_TRY_RUN([
1143#include <stdio.h>
1144#include <stdlib.h>
1145#include <string.h>
1146#include "SDL.h"
1147
1148char*
1149my_strdup (char *str)
1150{
1151 char *new_str;
1152
1153 if (str)
1154 {
1155 new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
1156 strcpy (new_str, str);
1157 }
1158 else
1159 new_str = NULL;
1160
1161 return new_str;
1162}
1163
1164int main (int argc, char *argv[])
1165{
1166 int major, minor, micro;
1167 char *tmp_version;
1168
1169 /* This hangs on some systems (?)
1170 system ("touch conf.sdltest");
1171 */
1172 { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
1173
1174 /* HP/UX 9 (%@#!) writes to sscanf strings */
1175 tmp_version = my_strdup("$min_sdl_version");
1176 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
1177 printf("%s, bad version string\n", "$min_sdl_version");
1178 exit(1);
1179 }
1180
1181 if (($sdl_major_version > major) ||
1182 (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
1183 (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
1184 {
1185 return 0;
1186 }
1187 else
1188 {
1189 printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
1190 printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
1191 printf("*** best to upgrade to the required version.\n");
1192 printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
1193 printf("*** to point to the correct copy of sdl-config, and remove the file\n");
1194 printf("*** config.cache before re-running configure\n");
1195 return 1;
1196 }
1197}
1198
1199],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
1200 CFLAGS="$ac_save_CFLAGS"
1201 LIBS="$ac_save_LIBS"
1202 fi
1203 fi
1204 if test "x$no_sdl" = x ; then
1205 AC_MSG_RESULT(yes)
1206 ifelse([$2], , :, [$2])
1207 else
1208 AC_MSG_RESULT(no)
1209 if test "$SDL_CONFIG" = "no" ; then
1210 echo "*** The sdl-config script installed by SDL could not be found"
1211 echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
1212 echo "*** your path, or set the SDL_CONFIG environment variable to the"
1213 echo "*** full path to sdl-config."
1214 else
1215 if test -f conf.sdltest ; then
1216 :
1217 else
1218 echo "*** Could not run SDL test program, checking why..."
1219 CFLAGS="$CFLAGS $SDL_CFLAGS"
1220 LIBS="$LIBS $SDL_LIBS"
1221 AC_TRY_LINK([
1222#include <stdio.h>
1223#include "SDL.h"
1224
1225int main(int argc, char *argv[])
1226{ return 0; }
1227#undef main
1228#define main K_and_R_C_main
1229], [ return 0; ],
1230 [ echo "*** The test program compiled, but did not run. This usually means"
1231 echo "*** that the run-time linker is not finding SDL or finding the wrong"
1232 echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
1233 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
1234 echo "*** to the installed location Also, make sure you have run ldconfig if that"
1235 echo "*** is required on your system"
1236 echo "***"
1237 echo "*** If you have an old version installed, it is best to remove it, although"
1238 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
1239 [ echo "*** The test program failed to compile or link. See the file config.log for the"
1240 echo "*** exact error that occured. This usually means SDL was incorrectly installed"
1241 echo "*** or that you have moved SDL since it was installed. In the latter case, you"
1242 echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
1243 CFLAGS="$ac_save_CFLAGS"
1244 LIBS="$ac_save_LIBS"
1245 fi
1246 fi
1247 SDL_CFLAGS=""
1248 SDL_LIBS=""
1249 ifelse([$3], , :, [$3])
1250 fi
1251 AC_SUBST(SDL_CFLAGS)
1252 AC_SUBST(SDL_LIBS)
1253 rm -f conf.sdltest
1254])
1255
fe0895cf
VS
1256dnl ---------------------------------------------------------------------------
1257dnl Support macros for makefiles generated by BAKEFILE.
1258dnl ---------------------------------------------------------------------------
1259
1260dnl Lots of compiler & linker detection code contained here was taken from
1261dnl wxWindows configure.in script (see http://www.wxwindows.org)
1262
1263
1264
1265dnl ---------------------------------------------------------------------------
1266dnl AC_BAKEFILE_GNUMAKE
1267dnl
1268dnl Detects GNU make
1269dnl ---------------------------------------------------------------------------
1270
af8ebe8a 1271AC_DEFUN([AC_BAKEFILE_GNUMAKE],
fe0895cf
VS
1272[
1273 dnl does make support "-include" (only GNU make does AFAIK)?
49b0a3aa 1274 AC_CACHE_CHECK([if make is GNU make], bakefile_cv_prog_makeisgnu,
fe0895cf
VS
1275 [
1276 if ( ${SHELL-sh} -c "${MAKE-make} --version" 2> /dev/null |
1277 egrep -s GNU > /dev/null); then
1278 bakefile_cv_prog_makeisgnu="yes"
1279 else
1280 bakefile_cv_prog_makeisgnu="no"
1281 fi
1282 ])
1283
1284 if test "x$bakefile_cv_prog_makeisgnu" = "xyes"; then
1285 IF_GNU_MAKE=""
1286 else
1287 IF_GNU_MAKE="#"
1288 fi
1289 AC_SUBST(IF_GNU_MAKE)
1290])
1291
1292dnl ---------------------------------------------------------------------------
1293dnl AC_BAKEFILE_PLATFORM
1294dnl
1295dnl Detects platform and sets PLATFORM_XXX variables accordingly
1296dnl ---------------------------------------------------------------------------
1297
af8ebe8a 1298AC_DEFUN([AC_BAKEFILE_PLATFORM],
fe0895cf
VS
1299[
1300 PLATFORM_UNIX=0
1301 PLATFORM_WIN32=0
1302 PLATFORM_MSDOS=0
1303 PLATFORM_MAC=0
1304 PLATFORM_MACOSX=0
96c1699d 1305 PLATFORM_OS2=0
f93ca9fd
VS
1306
1307 if test "x$BAKEFILE_FORCE_PLATFORM" = "x"; then
1308 case "${BAKEFILE_HOST}" in
1309 *-*-cygwin* | *-*-mingw32* )
1310 PLATFORM_WIN32=1
1311 ;;
1312 *-pc-msdosdjgpp )
1313 PLATFORM_MSDOS=1
1314 ;;
1315 *-pc-os2_emx | *-pc-os2-emx )
1316 PLATFORM_OS2=1
1317 ;;
1318 powerpc-*-darwin* )
1319 PLATFORM_MAC=1
1320 PLATFORM_MACOSX=1
1321 ;;
1322 * )
1323 PLATFORM_UNIX=1
1324 ;;
1325 esac
1326 else
1327 case "$BAKEFILE_FORCE_PLATFORM" in
1328 win32 )
1329 PLATFORM_WIN32=1
1330 ;;
1331 msdos )
1332 PLATFORM_MSDOS=1
1333 ;;
1334 os2 )
1335 PLATFORM_OS2=1
1336 ;;
1337 darwin )
1338 PLATFORM_MAC=1
1339 PLATFORM_MACOSX=1
1340 ;;
1341 unix )
1342 PLATFORM_UNIX=1
1343 ;;
1344 * )
1345 AC_MSG_ERROR([Unknown platform: $BAKEFILE_FORCE_PLATFORM])
1346 ;;
1347 esac
1348 fi
fe0895cf
VS
1349
1350 AC_SUBST(PLATFORM_UNIX)
1351 AC_SUBST(PLATFORM_WIN32)
1352 AC_SUBST(PLATFORM_MSDOS)
1353 AC_SUBST(PLATFORM_MAC)
1354 AC_SUBST(PLATFORM_MACOSX)
96c1699d 1355 AC_SUBST(PLATFORM_OS2)
fe0895cf
VS
1356])
1357
1358
3fd9c298
DE
1359dnl ---------------------------------------------------------------------------
1360dnl AC_BAKEFILE_PLATFORM_SPECIFICS
1361dnl
1362dnl Sets misc platform-specific settings
1363dnl ---------------------------------------------------------------------------
1364
af8ebe8a 1365AC_DEFUN([AC_BAKEFILE_PLATFORM_SPECIFICS],
3fd9c298 1366[
af8ebe8a
VS
1367 AC_ARG_ENABLE([omf], AS_HELP_STRING([--enable-omf],
1368 [use OMF object format (OS/2)]),
3fd9c298
DE
1369 [bk_os2_use_omf="$enableval"])
1370
1371 case "${BAKEFILE_HOST}" in
1372 *-*-darwin* )
1373 dnl For Unix to MacOS X porting instructions, see:
1374 dnl http://fink.sourceforge.net/doc/porting/porting.html
1375 CFLAGS="$CFLAGS -fno-common"
1376 CXXFLAGS="$CXXFLAGS -fno-common"
1377 ;;
1378
1379 *-pc-os2_emx | *-pc-os2-emx )
1380 if test "x$bk_os2_use_omf" = "xyes" ; then
1381 AR=emxomfar
1382 RANLIB=:
1383 LDFLAGS="-Zomf $LDFLAGS"
1384 CFLAGS="-Zomf $CFLAGS"
1385 CXXFLAGS="-Zomf $CXXFLAGS"
1386 OS2_LIBEXT="lib"
1387 else
1388 OS2_LIBEXT="a"
1389 fi
1390 ;;
1391 esac
1392])
fe0895cf
VS
1393
1394dnl ---------------------------------------------------------------------------
1395dnl AC_BAKEFILE_SUFFIXES
1396dnl
1397dnl Detects shared various suffixes for shared libraries, libraries, programs,
1398dnl plugins etc.
1399dnl ---------------------------------------------------------------------------
1400
af8ebe8a 1401AC_DEFUN([AC_BAKEFILE_SUFFIXES],
fe0895cf
VS
1402[
1403 SO_SUFFIX="so"
131f235d 1404 SO_SUFFIX_MODULE="so"
fe0895cf 1405 EXEEXT=""
3fd9c298
DE
1406 LIBPREFIX="lib"
1407 LIBEXT=".a"
1408 DLLPREFIX="lib"
1409 DLLPREFIX_MODULE=""
1410 DLLIMP_SUFFIX=""
fe0895cf 1411
f93ca9fd 1412 case "${BAKEFILE_HOST}" in
fe0895cf
VS
1413 *-hp-hpux* )
1414 SO_SUFFIX="sl"
131f235d 1415 SO_SUFFIX_MODULE="sl"
fe0895cf
VS
1416 ;;
1417 *-*-aix* )
1418 dnl quoting from
1419 dnl http://www-1.ibm.com/servers/esdd/articles/gnu.html:
1420 dnl Both archive libraries and shared libraries on AIX have an
1421 dnl .a extension. This will explain why you can't link with an
1422 dnl .so and why it works with the name changed to .a.
1423 SO_SUFFIX="a"
131f235d 1424 SO_SUFFIX_MODULE="a"
fe0895cf
VS
1425 ;;
1426 *-*-cygwin* | *-*-mingw32* )
1427 SO_SUFFIX="dll"
131f235d 1428 SO_SUFFIX_MODULE="dll"
3fd9c298 1429 DLLIMP_SUFFIX="dll.a"
fe0895cf
VS
1430 EXEEXT=".exe"
1431 DLLPREFIX=""
1432 ;;
4b1f6360
VS
1433 *-pc-msdosdjgpp )
1434 EXEEXT=".exe"
1435 DLLPREFIX=""
1436 ;;
1437 *-pc-os2_emx | *-pc-os2-emx )
11a20c3a
SN
1438 SO_SUFFIX="dll"
1439 SO_SUFFIX_MODULE="dll"
3fd9c298 1440 DLLIMP_SUFFIX=$OS2_LIBEXT
fe0895cf
VS
1441 EXEEXT=".exe"
1442 DLLPREFIX=""
4b1f6360 1443 LIBPREFIX=""
3fd9c298 1444 LIBEXT=".$OS2_LIBEXT"
fe0895cf
VS
1445 ;;
1446 powerpc-*-darwin* )
1447 SO_SUFFIX="dylib"
131f235d 1448 SO_SUFFIX_MODULE="bundle"
fe0895cf
VS
1449 ;;
1450 esac
1451
3fd9c298
DE
1452 if test "x$DLLIMP_SUFFIX" = "x" ; then
1453 DLLIMP_SUFFIX="$SO_SUFFIX"
1454 fi
1455
fe0895cf 1456 AC_SUBST(SO_SUFFIX)
131f235d 1457 AC_SUBST(SO_SUFFIX_MODULE)
3fd9c298 1458 AC_SUBST(DLLIMP_SUFFIX)
fe0895cf 1459 AC_SUBST(EXEEXT)
4b1f6360 1460 AC_SUBST(LIBPREFIX)
3fd9c298 1461 AC_SUBST(LIBEXT)
fe0895cf 1462 AC_SUBST(DLLPREFIX)
131f235d 1463 AC_SUBST(DLLPREFIX_MODULE)
fe0895cf
VS
1464])
1465
1466
1467dnl ---------------------------------------------------------------------------
1468dnl AC_BAKEFILE_SHARED_LD
1469dnl
1470dnl Detects command for making shared libraries, substitutes SHARED_LD_CC
1471dnl and SHARED_LD_CXX.
1472dnl ---------------------------------------------------------------------------
1473
af8ebe8a 1474AC_DEFUN([AC_BAKEFILE_SHARED_LD],
fe0895cf
VS
1475[
1476 dnl Defaults for GCC and ELF .so shared libs:
1477 SHARED_LD_CC="\$(CC) -shared -o"
1478 SHARED_LD_CXX="\$(CXX) -shared -o"
1479
1480 dnl the extra compiler flags needed for compilation of shared library
1481 if test "x$GCC" = "xyes"; then
1482 dnl the switch for gcc is the same under all platforms
1483 PIC_FLAG="-fPIC"
1484 fi
1485
f93ca9fd 1486 case "${BAKEFILE_HOST}" in
fe0895cf
VS
1487 *-hp-hpux* )
1488 dnl default settings are good for gcc but not for the native HP-UX
1489 if test "x$GCC" = "xyes"; then
1490 dnl -o flag must be after PIC flag
1491 SHARED_LD_CC="${CC} -shared ${PIC_FLAG} -o"
1492 SHARED_LD_CXX="${CXX} -shared ${PIC_FLAG} -o"
1493 else
1494 dnl no idea why it wants it, but it does
1495 LDFLAGS="$LDFLAGS -L/usr/lib"
1496
1497 SHARED_LD_CC="${CC} -b -o"
1498 SHARED_LD_CXX="${CXX} -b -o"
1499 PIC_FLAG="+Z"
1500 fi
1501 ;;
1502
1503 *-*-linux* )
1504 if test "x$GCC" != "xyes"; then
1505 AC_CACHE_CHECK([for Intel compiler], bakefile_cv_prog_icc,
1506 [
1507 AC_TRY_COMPILE([],
1508 [
1509 #ifndef __INTEL_COMPILER
1510 #error Not icc
1511 #endif
1512 ],
1513 bakefile_cv_prog_icc=yes,
1514 bakefile_cv_prog_icc=no
1515 )
1516 ])
1517 if test "$bakefile_cv_prog_icc" = "yes"; then
1518 PIC_FLAG="-KPIC"
1519 fi
1520 fi
1521 ;;
1522
1523 *-*-solaris2* )
1524 if test "x$GCC" != xyes ; then
1525 SHARED_LD_CC="${CC} -G -o"
1526 SHARED_LD_CXX="${CXX} -G -o"
1527 PIC_FLAG="-KPIC"
1528 fi
1529 ;;
1530
1531 *-*-darwin* )
fe0895cf
VS
1532 dnl Most apps benefit from being fully binded (its faster and static
1533 dnl variables initialized at startup work).
1534 dnl This can be done either with the exe linker flag -Wl,-bind_at_load
1535 dnl or with a double stage link in order to create a single module
1536 dnl "-init _wxWindowsDylibInit" not useful with lazy linking solved
1537
2a879853
VS
1538 dnl If using newer dev tools then there is a -single_module flag that
1539 dnl we can use to do this, otherwise we'll need to use a helper
1540 dnl script. Check the version of gcc to see which way we can go:
1541 AC_CACHE_CHECK([for gcc 3.1 or later], wx_cv_gcc31, [
1542 AC_TRY_COMPILE([],
1543 [
1544 #if (__GNUC__ < 3) || \
1545 ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1))
1546 #error old gcc
1547 #endif
1548 ],
1549 [
1550 wx_cv_gcc31=yes
1551 ],
1552 [
1553 wx_cv_gcc31=no
1554 ]
1555 )
1556 ])
1557 if test "$wx_cv_gcc31" = "no"; then
3fd9c298 1558 AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH
43948499
RD
1559 chmod +x shared-ld-sh
1560
2a879853 1561 dnl Use the shared-ld-sh helper script
7f523214
VS
1562 SHARED_LD_CC="`pwd`/shared-ld-sh -dynamiclib -headerpad_max_install_names -o"
1563 SHARED_LD_MODULE_CC="`pwd`/shared-ld-sh -bundle -headerpad_max_install_names -o"
2a879853
VS
1564 SHARED_LD_CXX="$SHARED_LD_CC"
1565 SHARED_LD_MODULE_CXX="$SHARED_LD_MODULE_CC"
1566 else
1567 dnl Use the -single_module flag and let the linker do it for us
7f523214
VS
1568 SHARED_LD_CC="\${CC} -dynamiclib -single_module -headerpad_max_install_names -o"
1569 SHARED_LD_MODULE_CC="\${CC} -bundle -single_module -headerpad_max_install_names -o"
1570 SHARED_LD_CXX="\${CXX} -dynamiclib -single_module -headerpad_max_install_names -o"
1571 SHARED_LD_MODULE_CXX="\${CXX} -bundle -single_module -headerpad_max_install_names -o"
2a879853
VS
1572 fi
1573
fe0895cf 1574 PIC_FLAG="-dynamic -fPIC"
fe0895cf
VS
1575 ;;
1576
1577 *-*-aix* )
1578 dnl default settings are ok for gcc
1579 if test "x$GCC" != "xyes"; then
1580 dnl the abs path below used to be hardcoded here so I guess it must
1581 dnl be some sort of standard location under AIX?
1582 AC_CHECK_PROG(AIX_CXX_LD, makeC++SharedLib,
1583 makeC++SharedLib, /usr/lpp/xlC/bin/makeC++SharedLib)
1584 dnl FIXME - what about makeCSharedLib?
1585 SHARED_LD_CC="$AIX_CC_LD -p 0 -o"
1586 SHARED_LD_CXX="$AIX_CXX_LD -p 0 -o"
1587 fi
1588 ;;
1589
1590 *-*-beos* )
1591 dnl can't use gcc under BeOS for shared library creation because it
1592 dnl complains about missing 'main'
1593 SHARED_LD_CC="${LD} -shared -o"
1594 SHARED_LD_CXX="${LD} -shared -o"
1595 ;;
1596
1597 *-*-irix* )
1598 dnl default settings are ok for gcc
1599 if test "x$GCC" != "xyes"; then
1600 PIC_FLAG="-KPIC"
1601 fi
1602 ;;
1603
1604 *-*-cygwin* | *-*-mingw32* )
1605 PIC_FLAG=""
1606 ;;
3fd9c298 1607
11a20c3a 1608 *-pc-os2_emx | *-pc-os2-emx )
3fd9c298
DE
1609 SHARED_LD_CC="`pwd`/dllar.sh -o"
1610 SHARED_LD_CXX="`pwd`/dllar.sh -o"
11a20c3a 1611 PIC_FLAG=""
3fd9c298
DE
1612 AC_BAKEFILE_CREATE_FILE_DLLAR_SH
1613 chmod +x dllar.sh
11a20c3a
SN
1614 ;;
1615
fe0895cf
VS
1616 *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | \
1617 *-*-sunos4* | \
1618 *-*-osf* | \
1619 *-*-dgux5* | \
d5fc095c 1620 *-*-sysv5* )
fe0895cf
VS
1621 dnl defaults are ok
1622 ;;
1623
1624 *)
f93ca9fd 1625 AC_MSG_ERROR(unknown system type $BAKEFILE_HOST.)
fe0895cf
VS
1626 esac
1627
af8ebe8a
VS
1628 if test "x$PIC_FLAG" != "x" ; then
1629 PIC_FLAG="$PIC_FLAG -DPIC"
1630 fi
1631
131f235d
VS
1632 if test "x$SHARED_LD_MODULE_CC" = "x" ; then
1633 SHARED_LD_MODULE_CC="$SHARED_LD_CC"
1634 fi
1635 if test "x$SHARED_LD_MODULE_CXX" = "x" ; then
239394fb 1636 SHARED_LD_MODULE_CXX="$SHARED_LD_CXX"
131f235d
VS
1637 fi
1638
fe0895cf
VS
1639 AC_SUBST(SHARED_LD_CC)
1640 AC_SUBST(SHARED_LD_CXX)
131f235d
VS
1641 AC_SUBST(SHARED_LD_MODULE_CC)
1642 AC_SUBST(SHARED_LD_MODULE_CXX)
fe0895cf
VS
1643 AC_SUBST(PIC_FLAG)
1644])
1645
1646
1647dnl ---------------------------------------------------------------------------
1648dnl AC_BAKEFILE_SHARED_VERSIONS
1649dnl
1650dnl Detects linker options for attaching versions (sonames) to shared libs.
1651dnl ---------------------------------------------------------------------------
1652
af8ebe8a 1653AC_DEFUN([AC_BAKEFILE_SHARED_VERSIONS],
fe0895cf
VS
1654[
1655 USE_SOVERSION=0
1656 USE_SOVERLINUX=0
1657 USE_SOVERSOLARIS=0
1658 USE_SOSYMLINKS=0
1659 USE_MACVERSION=0
1660 SONAME_FLAG=
1661
f93ca9fd 1662 case "${BAKEFILE_HOST}" in
fe0895cf
VS
1663 *-*-linux* )
1664 SONAME_FLAG="-Wl,-soname,"
1665 USE_SOVERSION=1
1666 USE_SOVERLINUX=1
1667 USE_SOSYMLINKS=1
1668 ;;
1669
1670 *-*-solaris2* )
1671 SONAME_FLAG="-h "
1672 USE_SOVERSION=1
1673 USE_SOVERSOLARIS=1
1674 USE_SOSYMLINKS=1
1675 ;;
1676
1677 *-*-darwin* )
1678 USE_MACVERSION=1
1679 USE_SOVERSION=1
1680 USE_SOSYMLINKS=1
1681 ;;
1682 esac
1683
1684 AC_SUBST(USE_SOVERSION)
1685 AC_SUBST(USE_SOVERLINUX)
1686 AC_SUBST(USE_SOVERSOLARIS)
1687 AC_SUBST(USE_MACVERSION)
1688 AC_SUBST(USE_SOSYMLINKS)
1689 AC_SUBST(SONAME_FLAG)
1690])
1691
1692
1693dnl ---------------------------------------------------------------------------
1694dnl AC_BAKEFILE_DEPS
1695dnl
1696dnl Detects available C/C++ dependency tracking options
1697dnl ---------------------------------------------------------------------------
1698
af8ebe8a 1699AC_DEFUN([AC_BAKEFILE_DEPS],
fe0895cf 1700[
49b0a3aa
VS
1701 AC_MSG_CHECKING([for dependency tracking method])
1702 DEPS_TRACKING=0
1703
fe0895cf 1704 if test "x$GCC" = "xyes"; then
49b0a3aa
VS
1705 DEPSMODE=gcc
1706 DEPS_TRACKING=1
f93ca9fd 1707 case "${BAKEFILE_HOST}" in
3e5c3c83
VS
1708 powerpc-*-darwin* )
1709 dnl -cpp-precomp (the default) conflicts with -MMD option
1710 dnl used by bk-deps (see also http://developer.apple.com/documentation/Darwin/Conceptual/PortingUnix/compiling/chapter_4_section_3.html)
1711 DEPSFLAG_GCC="-no-cpp-precomp -MMD"
1712 ;;
1713 * )
1714 DEPSFLAG_GCC="-MMD"
1715 ;;
1716 esac
49b0a3aa
VS
1717 AC_MSG_RESULT([gcc])
1718 else
1719 AC_MSG_RESULT([none])
1720 fi
1721
1722 if test $DEPS_TRACKING = 1 ; then
3fd9c298 1723 AC_BAKEFILE_CREATE_FILE_BK_DEPS
49b0a3aa 1724 chmod +x bk-deps
fe0895cf
VS
1725 fi
1726
49b0a3aa 1727 AC_SUBST(DEPS_TRACKING)
fe0895cf
VS
1728])
1729
1730dnl ---------------------------------------------------------------------------
1731dnl AC_BAKEFILE_CHECK_BASIC_STUFF
1732dnl
1733dnl Checks for presence of basic programs, such as C and C++ compiler, "ranlib"
1734dnl or "install"
1735dnl ---------------------------------------------------------------------------
1736
af8ebe8a 1737AC_DEFUN([AC_BAKEFILE_CHECK_BASIC_STUFF],
fe0895cf
VS
1738[
1739 AC_PROG_RANLIB
1740 AC_PROG_INSTALL
1741 AC_PROG_LN_S
1742
1743 AC_PROG_MAKE_SET
1744 AC_SUBST(MAKE_SET)
1745
874d12cf
VS
1746 AC_CHECK_TOOL(AR, ar, ar)
1747 AC_CHECK_TOOL(STRIP, strip, :)
1748 AC_CHECK_TOOL(NM, nm, :)
fe0895cf 1749
f93ca9fd 1750 case ${BAKEFILE_HOST} in
fe0895cf 1751 *-hp-hpux* )
af8ebe8a 1752 INSTALL_DIR="mkdir -p"
fe0895cf
VS
1753 ;;
1754 *) INSTALL_DIR="$INSTALL -d"
1755 ;;
1756 esac
1757 AC_SUBST(INSTALL_DIR)
6b9d41a5
VS
1758
1759 LDFLAGS_GUI=
f93ca9fd 1760 case ${BAKEFILE_HOST} in
6b9d41a5 1761 *-*-cygwin* | *-*-mingw32* )
3fd9c298 1762 LDFLAGS_GUI="-mwindows"
6b9d41a5
VS
1763 esac
1764 AC_SUBST(LDFLAGS_GUI)
fe0895cf
VS
1765])
1766
1767
1768dnl ---------------------------------------------------------------------------
1769dnl AC_BAKEFILE_RES_COMPILERS
1770dnl
1771dnl Checks for presence of resource compilers for win32 or mac
1772dnl ---------------------------------------------------------------------------
1773
af8ebe8a 1774AC_DEFUN([AC_BAKEFILE_RES_COMPILERS],
fe0895cf
VS
1775[
1776 RESCOMP=
1777 SETFILE=
1778
f93ca9fd 1779 case ${BAKEFILE_HOST} in
fe0895cf
VS
1780 *-*-cygwin* | *-*-mingw32* )
1781 dnl Check for win32 resources compiler:
1782 if test "$build" != "$host" ; then
1783 RESCOMP=$host_alias-windres
1784 else
1785 AC_CHECK_PROG(RESCOMP, windres, windres, windres)
1786 fi
1787 ;;
1788
1789 *-*-darwin* )
1790 AC_CHECK_PROG(RESCOMP, Rez, Rez, /Developer/Tools/Rez)
1791 AC_CHECK_PROG(SETFILE, SetFile, SetFile, /Developer/Tools/SetFile)
1792 ;;
1793 esac
1794
1795 AC_SUBST(RESCOMP)
1796 AC_SUBST(SETFILE)
1797])
1798
45842500
VS
1799dnl ---------------------------------------------------------------------------
1800dnl AC_BAKEFILE_PRECOMP_HEADERS
1801dnl
1802dnl Check for precompiled headers support (GCC >= 3.4)
1803dnl ---------------------------------------------------------------------------
1804
af8ebe8a 1805AC_DEFUN([AC_BAKEFILE_PRECOMP_HEADERS],
45842500
VS
1806[
1807
1808 AC_ARG_ENABLE([precomp-headers],
af8ebe8a
VS
1809 AS_HELP_STRING([--disable-precomp-headers],
1810 [don't use precompiled headers even if compiler can]),
45842500
VS
1811 [bk_use_pch="$enableval"])
1812
1813 GCC_PCH=0
1814
1815 if test "x$bk_use_pch" = "x" -o "x$bk_use_pch" = "xyes" ; then
1816 if test "x$GCC" = "xyes"; then
1817 dnl test if we have gcc-3.4:
1818 AC_MSG_CHECKING([if the compiler supports precompiled headers])
1819 AC_TRY_COMPILE([],
1820 [
e06468e8
VS
1821 #if !defined(__GNUC__) || !defined(__GNUC_MINOR__)
1822 #error "no pch support"
1823 #endif
1824 #if (__GNUC__ < 3)
1825 #error "no pch support"
1826 #endif
1827 #if (__GNUC__ == 3) && \
1828 ((!defined(__APPLE_CC__) && (__GNUC_MINOR__ < 4)) || \
1829 ( defined(__APPLE_CC__) && (__GNUC_MINOR__ < 3)))
1830 #error "no pch support"
45842500
VS
1831 #endif
1832 ],
1833 [
1834 AC_MSG_RESULT([yes])
45842500
VS
1835 GCC_PCH=1
1836 ],
1837 [
1838 AC_MSG_RESULT([no])
1839 ])
1840 if test $GCC_PCH = 1 ; then
1841 cat <<EOF >bk-make-pch
1842#!/bin/sh
1843
1844# This script is part of Bakefile (http://bakefile.sourceforge.net) autoconf
1845# script. It is used to generated precompiled headers.
1846#
1847# Permission is given to use this file in any way.
1848
1849outfile="\${1}"
1850header="\${2}"
1851shift
1852shift
1853
1854compiler=
1855headerfile=
1856while test \${#} -gt 0; do
1857 case "\${1}" in
1858 -I* )
1859 incdir=\`echo \${1} | sed -e 's/-I\(.*\)/\1/g'\`
1860 if test "x\${headerfile}" = "x" -a -f "\${incdir}/\${header}" ; then
1861 headerfile="\${incdir}/\${header}"
1862 fi
1863 ;;
1864 esac
1865 compiler="\${compiler} \${1}"
1866 shift
1867done
1868
1869if test "x\${headerfile}" = "x" ; then
1870 echo "error: can't find header \${header} in include paths" >2
1871else
1872 if test -f \${outfile} ; then
1873 rm -f \${outfile}
1874 else
1875 mkdir -p \`dirname \${outfile}\`
1876 fi
1877 depsfile=".deps/\`basename \${outfile}\`.d"
1878 mkdir -p .deps
1879 # can do this because gcc is >= 3.4:
1880 \${compiler} -o \${outfile} -MMD -MF "\${depsfile}" "\${headerfile}"
1881 exit \${?}
1882fi
1883EOF
1884 chmod +x bk-make-pch
1885 fi
1886 fi
1887 fi
1888
1889 AC_SUBST(GCC_PCH)
1890])
1891
1892
1893
fe0895cf
VS
1894dnl ---------------------------------------------------------------------------
1895dnl AC_BAKEFILE
1896dnl
1897dnl To be used in configure.in of any project using Bakefile-generated mks
f93ca9fd
VS
1898dnl
1899dnl Behaviour can be modified by setting following variables:
1900dnl BAKEFILE_CHECK_BASICS set to "no" if you don't want bakefile to
1901dnl to perform check for basic tools like ranlib
1902dnl BAKEFILE_HOST set this to override host detection, defaults
1903dnl to ${host}
1904dnl BAKEFILE_FORCE_PLATFORM set to override platform detection
fe0895cf
VS
1905dnl ---------------------------------------------------------------------------
1906
af8ebe8a 1907AC_DEFUN([AC_BAKEFILE],
fe0895cf 1908[
f93ca9fd
VS
1909 if test "x$BAKEFILE_HOST" = "x"; then
1910 BAKEFILE_HOST="${host}"
1911 fi
1912
fe0895cf
VS
1913 if test "x$BAKEFILE_CHECK_BASICS" != "xno"; then
1914 AC_BAKEFILE_CHECK_BASIC_STUFF
1915 fi
1916 AC_BAKEFILE_GNUMAKE
1917 AC_BAKEFILE_PLATFORM
3fd9c298 1918 AC_BAKEFILE_PLATFORM_SPECIFICS
fe0895cf
VS
1919 AC_BAKEFILE_SUFFIXES
1920 AC_BAKEFILE_SHARED_LD
1921 AC_BAKEFILE_SHARED_VERSIONS
1922 AC_BAKEFILE_DEPS
1923 AC_BAKEFILE_RES_COMPILERS
1924
af8ebe8a
VS
1925 BAKEFILE_BAKEFILE_M4_VERSION="0.1.4"
1926
fe0895cf 1927 builtin(include, autoconf_inc.m4)
af8ebe8a
VS
1928
1929 if test "$BAKEFILE_BAKEFILE_M4_VERSION" != "$BAKEFILE_AUTOCONF_INC_M4_VERSION" ; then
1930 AC_MSG_ERROR([Versions of Bakefile used to generate makefiles ($BAKEFILE_AUTOCONF_INC_M4_VERSION) and configure ($BAKEFILE_BAKEFILE_M4_VERSION) do not match.])
1931 fi
fe0895cf 1932])
3fd9c298
DE
1933
1934
1935dnl ---------------------------------------------------------------------------
1936dnl Embedded copies of helper scripts follow:
1937dnl ---------------------------------------------------------------------------
1938
af8ebe8a 1939AC_DEFUN([AC_BAKEFILE_CREATE_FILE_DLLAR_SH],
3fd9c298
DE
1940[
1941dnl ===================== dllar.sh begins here =====================
1942D='$'
1943cat <<EOF >dllar.sh
1944#!/bin/sh
1945#
1946# dllar - a tool to build both a .dll and an .a file
1947# from a set of object (.o) files for EMX/OS2.
1948#
1949# Written by Andrew Zabolotny, bit@freya.etu.ru
1950# Ported to Unix like shell by Stefan Neis, Stefan.Neis@t-online.de
1951#
1952# This script will accept a set of files on the command line.
1953# All the public symbols from the .o files will be exported into
1954# a .DEF file, then linker will be run (through gcc) against them to
1955# build a shared library consisting of all given .o files. All libraries
1956# (.a) will be first decompressed into component .o files then act as
1957# described above. You can optionally give a description (-d "description")
1958# which will be put into .DLL. To see the list of accepted options (as well
1959# as command-line format) simply run this program without options. The .DLL
1960# is built to be imported by name (there is no guarantee that new versions
1961# of the library you build will have same ordinals for same symbols).
1962#
1963# dllar is free software; you can redistribute it and/or modify
1964# it under the terms of the GNU General Public License as published by
1965# the Free Software Foundation; either version 2, or (at your option)
1966# any later version.
1967#
1968# dllar is distributed in the hope that it will be useful,
1969# but WITHOUT ANY WARRANTY; without even the implied warranty of
1970# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1971# GNU General Public License for more details.
1972#
1973# You should have received a copy of the GNU General Public License
1974# along with dllar; see the file COPYING. If not, write to the Free
1975# Software Foundation, 59 Temple Place - Suite 330, Boston, MA
1976# 02111-1307, USA.
1977
1978# To successfuly run this program you will need:
1979# - Current drive should have LFN support (HPFS, ext2, network, etc)
1980# (Sometimes dllar generates filenames which won't fit 8.3 scheme)
1981# - gcc
1982# (used to build the .dll)
1983# - emxexp
1984# (used to create .def file from .o files)
1985# - emximp
1986# (used to create .a file from .def file)
1987# - GNU text utilites (cat, sort, uniq)
1988# used to process emxexp output
1989# - GNU file utilities (mv, rm)
1990# - GNU sed
1991# - lxlite (optional, see flag below)
1992# (used for general .dll cleanup)
1993#
1994
1995flag_USE_LXLITE=1;
1996
1997#
1998# helper functions
1999# basnam, variant of basename, which does _not_ remove the path, _iff_
2000# second argument (suffix to remove) is given
2001basnam(){
2002 case ${D}# in
2003 1)
2004 echo ${D}1 | sed 's/.*\///' | sed 's/.*\\//'
2005 ;;
2006 2)
2007 echo ${D}1 | sed 's/'${D}2'${D}//'
2008 ;;
2009 *)
2010 echo "error in basnam ${D}*"
2011 exit 8
2012 ;;
2013 esac
2014}
2015
2016# Cleanup temporary files and output
2017CleanUp() {
2018 cd ${D}curDir
2019 for i in ${D}inputFiles ; do
2020 case ${D}i in
2021 *!)
2022 rm -rf \`basnam ${D}i !\`
2023 ;;
2024 *)
2025 ;;
2026 esac
2027 done
2028
2029 # Kill result in case of failure as there is just to many stupid make/nmake
2030 # things out there which doesn't do this.
af8ebe8a 2031 if [[] ${D}# -eq 0 []]; then
3fd9c298
DE
2032 rm -f ${D}arcFile ${D}arcFile2 ${D}defFile ${D}dllFile
2033 fi
2034}
2035
2036# Print usage and exit script with rc=1.
2037PrintHelp() {
af8ebe8a
VS
2038 echo 'Usage: dllar [[]-o[[]utput[]] output_file[]] [[]-i[[]mport[]] importlib_name[]]'
2039 echo ' [[]-d[[]escription[]] "dll descrption"[]] [[]-cc "CC"[]] [[]-f[[]lags[]] "CFLAGS"[]]'
2040 echo ' [[]-ord[[]inals[]][]] -ex[[]clude[]] "symbol(s)"'
2041 echo ' [[]-libf[[]lags[]] "{INIT|TERM}{GLOBAL|INSTANCE}"[]] [[]-nocrt[[]dll[]][]] [[]-nolxl[[]ite[]][]]'
2042 echo ' [[]*.o[]] [[]*.a[]]'
3fd9c298
DE
2043 echo '*> "output_file" should have no extension.'
2044 echo ' If it has the .o, .a or .dll extension, it is automatically removed.'
2045 echo ' The import library name is derived from this and is set to "name".a,'
2046 echo ' unless overridden by -import'
2047 echo '*> "importlib_name" should have no extension.'
2048 echo ' If it has the .o, or .a extension, it is automatically removed.'
2049 echo ' This name is used as the import library name and may be longer and'
2050 echo ' more descriptive than the DLL name which has to follow the old '
2051 echo ' 8.3 convention of FAT.'
2052 echo '*> "cc" is used to use another GCC executable. (default: gcc.exe)'
2053 echo '*> "flags" should be any set of valid GCC flags. (default: -s -Zcrtdll)'
2054 echo ' These flags will be put at the start of GCC command line.'
af8ebe8a
VS
2055 echo '*> -ord[[]inals[]] tells dllar to export entries by ordinals. Be careful.'
2056 echo '*> -ex[[]clude[]] defines symbols which will not be exported. You can define'
3fd9c298
DE
2057 echo ' multiple symbols, for example -ex "myfunc yourfunc _GLOBAL*".'
2058 echo ' If the last character of a symbol is "*", all symbols beginning'
2059 echo ' with the prefix before "*" will be exclude, (see _GLOBAL* above).'
af8ebe8a 2060 echo '*> -libf[[]lags[]] can be used to add INITGLOBAL/INITINSTANCE and/or'
3fd9c298 2061 echo ' TERMGLOBAL/TERMINSTANCE flags to the dynamically-linked library.'
af8ebe8a 2062 echo '*> -nocrt[[]dll[]] switch will disable linking the library against emx''s'
3fd9c298 2063 echo ' C runtime DLLs.'
af8ebe8a 2064 echo '*> -nolxl[[]ite[]] switch will disable running lxlite on the resulting DLL.'
3fd9c298
DE
2065 echo '*> All other switches (for example -L./ or -lmylib) will be passed'
2066 echo ' unchanged to GCC at the end of command line.'
2067 echo '*> If you create a DLL from a library and you do not specify -o,'
2068 echo ' the basename for DLL and import library will be set to library name,'
2069 echo ' the initial library will be renamed to 'name'_s.a (_s for static)'
2070 echo ' i.e. "dllar gcc.a" will create gcc.dll and gcc.a, and the initial'
2071 echo ' library will be renamed into gcc_s.a.'
2072 echo '--------'
2073 echo 'Example:'
2074 echo ' dllar -o gcc290.dll libgcc.a -d "GNU C runtime library" -ord'
2075 echo ' -ex "__main __ctordtor*" -libf "INITINSTANCE TERMINSTANCE"'
2076 CleanUp
2077 exit 1
2078}
2079
2080# Execute a command.
2081# If exit code of the commnad <> 0 CleanUp() is called and we'll exit the script.
2082# @Uses Whatever CleanUp() uses.
2083doCommand() {
2084 echo "${D}*"
2085 eval ${D}*
2086 rcCmd=${D}?
2087
af8ebe8a 2088 if [[] ${D}rcCmd -ne 0 []]; then
3fd9c298
DE
2089 echo "command failed, exit code="${D}rcCmd
2090 CleanUp
2091 exit ${D}rcCmd
2092 fi
2093}
2094
2095# main routine
2096# setup globals
2097cmdLine=${D}*
2098outFile=""
2099outimpFile=""
2100inputFiles=""
2101description=""
2102CC=gcc.exe
2103CFLAGS="-s -Zcrtdll"
2104EXTRA_CFLAGS=""
2105EXPORT_BY_ORDINALS=0
2106exclude_symbols=""
2107library_flags=""
2108curDir=\`pwd\`
2109curDirS=curDir
2110case ${D}curDirS in
2111*/)
2112 ;;
2113*)
2114 curDirS=${D}{curDirS}"/"
2115 ;;
2116esac
2117# Parse commandline
2118libsToLink=0
af8ebe8a 2119while [[] ${D}1 []]; do
3fd9c298
DE
2120 case ${D}1 in
2121 -ord*)
2122 EXPORT_BY_ORDINALS=1;
2123 ;;
2124 -o*)
2125 shift
2126 outFile=${D}1
2127 ;;
2128 -i*)
2129 shift
2130 outimpFile=${D}1
2131 ;;
2132 -d*)
2133 shift
2134 description=${D}1
2135 ;;
2136 -f*)
2137 shift
2138 CFLAGS=${D}1
2139 ;;
2140 -c*)
2141 shift
2142 CC=${D}1
2143 ;;
2144 -h*)
2145 PrintHelp
2146 ;;
2147 -ex*)
2148 shift
2149 exclude_symbols=${D}{exclude_symbols}${D}1" "
2150 ;;
2151 -libf*)
2152 shift
2153 library_flags=${D}{library_flags}${D}1" "
2154 ;;
2155 -nocrt*)
2156 CFLAGS="-s"
2157 ;;
2158 -nolxl*)
2159 flag_USE_LXLITE=0
2160 ;;
2161 -* | /*)
2162 case ${D}1 in
2163 -L* | -l*)
2164 libsToLink=1
2165 ;;
2166 *)
2167 ;;
2168 esac
2169 EXTRA_CFLAGS=${D}{EXTRA_CFLAGS}" "${D}1
2170 ;;
2171 *)
2172 found=0;
af8ebe8a 2173 if [[] ${D}libsToLink -ne 0 []]; then
3fd9c298
DE
2174 EXTRA_CFLAGS=${D}{EXTRA_CFLAGS}" "${D}1
2175 else
2176 for file in ${D}1 ; do
af8ebe8a 2177 if [[] -f ${D}file []]; then
3fd9c298
DE
2178 inputFiles="${D}{inputFiles} ${D}file"
2179 found=1
2180 fi
2181 done
af8ebe8a 2182 if [[] ${D}found -eq 0 []]; then
3fd9c298
DE
2183 echo "ERROR: No file(s) found: "${D}1
2184 exit 8
2185 fi
2186 fi
2187 ;;
2188 esac
2189 shift
2190done # iterate cmdline words
2191
2192#
af8ebe8a 2193if [[] -z "${D}inputFiles" []]; then
3fd9c298
DE
2194 echo "dllar: no input files"
2195 PrintHelp
2196fi
2197
2198# Now extract all .o files from .a files
2199newInputFiles=""
2200for file in ${D}inputFiles ; do
2201 case ${D}file in
2202 *.a | *.lib)
2203 case ${D}file in
2204 *.a)
2205 suffix=".a"
2206 AR="ar"
2207 ;;
2208 *.lib)
2209 suffix=".lib"
2210 AR="emxomfar"
2211 EXTRA_CFLAGS="${D}EXTRA_CFLAGS -Zomf"
2212 ;;
2213 *)
2214 ;;
2215 esac
2216 dirname=\`basnam ${D}file ${D}suffix\`"_%"
2217 mkdir ${D}dirname
af8ebe8a 2218 if [[] ${D}? -ne 0 []]; then
3fd9c298
DE
2219 echo "Failed to create subdirectory ./${D}dirname"
2220 CleanUp
2221 exit 8;
2222 fi
2223 # Append '!' to indicate archive
2224 newInputFiles="${D}newInputFiles ${D}{dirname}!"
2225 doCommand "cd ${D}dirname; ${D}AR x ../${D}file"
2226 cd ${D}curDir
2227 found=0;
2228 for subfile in ${D}dirname/*.o* ; do
af8ebe8a 2229 if [[] -f ${D}subfile []]; then
3fd9c298 2230 found=1
af8ebe8a 2231 if [[] -s ${D}subfile []]; then
3fd9c298
DE
2232 # FIXME: This should be: is file size > 32 byte, _not_ > 0!
2233 newInputFiles="${D}newInputFiles ${D}subfile"
2234 fi
2235 fi
2236 done
af8ebe8a 2237 if [[] ${D}found -eq 0 []]; then
3fd9c298
DE
2238 echo "WARNING: there are no files in archive \'${D}file\'"
2239 fi
2240 ;;
2241 *)
2242 newInputFiles="${D}{newInputFiles} ${D}file"
2243 ;;
2244 esac
2245done
2246inputFiles="${D}newInputFiles"
2247
2248# Output filename(s).
2249do_backup=0;
af8ebe8a 2250if [[] -z ${D}outFile []]; then
3fd9c298
DE
2251 do_backup=1;
2252 set outFile ${D}inputFiles; outFile=${D}2
2253fi
2254
2255# If it is an archive, remove the '!' and the '_%' suffixes
2256case ${D}outFile in
2257*_%!)
2258 outFile=\`basnam ${D}outFile _%!\`
2259 ;;
2260*)
2261 ;;
2262esac
2263case ${D}outFile in
2264*.dll)
2265 outFile=\`basnam ${D}outFile .dll\`
2266 ;;
2267*.DLL)
2268 outFile=\`basnam ${D}outFile .DLL\`
2269 ;;
2270*.o)
2271 outFile=\`basnam ${D}outFile .o\`
2272 ;;
2273*.obj)
2274 outFile=\`basnam ${D}outFile .obj\`
2275 ;;
2276*.a)
2277 outFile=\`basnam ${D}outFile .a\`
2278 ;;
2279*.lib)
2280 outFile=\`basnam ${D}outFile .lib\`
2281 ;;
2282*)
2283 ;;
2284esac
2285case ${D}outimpFile in
2286*.a)
2287 outimpFile=\`basnam ${D}outimpFile .a\`
2288 ;;
2289*.lib)
2290 outimpFile=\`basnam ${D}outimpFile .lib\`
2291 ;;
2292*)
2293 ;;
2294esac
af8ebe8a 2295if [[] -z ${D}outimpFile []]; then
3fd9c298
DE
2296 outimpFile=${D}outFile
2297fi
2298defFile="${D}{outFile}.def"
2299arcFile="${D}{outimpFile}.a"
2300arcFile2="${D}{outimpFile}.lib"
2301dllFile="${D}outFile"
2302# Add suffix to dllFile later, first we need a version to use as
2303# name in .def file.
2304
af8ebe8a
VS
2305if [[] ${D}do_backup -ne 0 []] ; then
2306 if [[] -f ${D}arcFile []] ; then
3fd9c298
DE
2307 doCommand "mv ${D}arcFile ${D}{outFile}_s.a"
2308 fi
af8ebe8a 2309 if [[] -f ${D}arcFile2 []] ; then
3fd9c298
DE
2310 doCommand "mv ${D}arcFile2 ${D}{outFile}_s.lib"
2311 fi
2312fi
2313
2314# Extract public symbols from all the object files.
2315tmpdefFile=${D}{defFile}_%
2316rm -f ${D}tmpdefFile
2317for file in ${D}inputFiles ; do
2318 case ${D}file in
2319 *!)
2320 ;;
2321 *)
2322 doCommand "emxexp -u ${D}file >> ${D}tmpdefFile"
2323 ;;
2324 esac
2325done
2326
2327# Create the def file.
2328rm -f ${D}defFile
2329echo "LIBRARY \`basnam ${D}dllFile\` ${D}library_flags" >> ${D}defFile
2330dllFile="${D}dllFile.dll"
af8ebe8a 2331if [[] -n ${D}description []]; then
3fd9c298
DE
2332 echo "DESCRIPTION \"${D}{description}\"" >> ${D}defFile
2333fi
2334echo "EXPORTS" >> ${D}defFile
2335
2336doCommand "cat ${D}tmpdefFile | sort.exe | uniq.exe > ${D}{tmpdefFile}%"
2337grep -v "^ *;" < ${D}{tmpdefFile}% | grep -v "^ *${D}" >${D}tmpdefFile
2338
2339# Checks if the export is ok or not.
2340for word in ${D}exclude_symbols; do
2341 grep -v ${D}word < ${D}tmpdefFile >${D}{tmpdefFile}%
2342 mv ${D}{tmpdefFile}% ${D}tmpdefFile
2343done
2344
2345
af8ebe8a 2346if [[] ${D}EXPORT_BY_ORDINALS -ne 0 []]; then
3fd9c298
DE
2347 sed "=" < ${D}tmpdefFile | \
2348 sed '
2349 N
2350 : loop
af8ebe8a 2351 s/^\([[]0-9[]]\+\)\([[]^;[]]*\)\(;.*\)\?/\2 @\1 NONAME/
3fd9c298
DE
2352 t loop
2353 ' > ${D}{tmpdefFile}%
2354 grep -v "^ *${D}" < ${D}{tmpdefFile}% > ${D}tmpdefFile
2355else
2356 rm -f ${D}{tmpdefFile}%
2357fi
2358cat ${D}tmpdefFile >> ${D}defFile
2359rm -f ${D}tmpdefFile
2360
2361# Do linking, create implib, and apply lxlite.
2362gccCmdl="";
2363for file in ${D}inputFiles ; do
2364 case ${D}file in
2365 *!)
2366 ;;
2367 *)
2368 gccCmdl="${D}gccCmdl ${D}file"
2369 ;;
2370 esac
2371done
2372doCommand "${D}CC ${D}CFLAGS -Zdll -o ${D}dllFile ${D}defFile ${D}gccCmdl ${D}EXTRA_CFLAGS"
2373touch "${D}{outFile}.dll"
2374
2375doCommand "emximp -o ${D}arcFile ${D}defFile"
af8ebe8a 2376if [[] ${D}flag_USE_LXLITE -ne 0 []]; then
3fd9c298 2377 add_flags="";
af8ebe8a 2378 if [[] ${D}EXPORT_BY_ORDINALS -ne 0 []]; then
3fd9c298
DE
2379 add_flags="-ynd"
2380 fi
2381 doCommand "lxlite -cs -t: -mrn -mln ${D}add_flags ${D}dllFile"
2382fi
2383doCommand "emxomf -s -l ${D}arcFile"
2384
2385# Successful exit.
2386CleanUp 1
2387exit 0
2388EOF
2389dnl ===================== dllar.sh ends here =====================
2390])
2391
af8ebe8a 2392AC_DEFUN([AC_BAKEFILE_CREATE_FILE_BK_DEPS],
3fd9c298
DE
2393[
2394dnl ===================== bk-deps begins here =====================
2395D='$'
2396cat <<EOF >bk-deps
2397#!/bin/sh
2398
2399# This script is part of Bakefile (http://bakefile.sourceforge.net) autoconf
2400# script. It is used to track C/C++ files dependencies in portable way.
2401#
2402# Permission is given to use this file in any way.
2403
2404DEPSMODE=${DEPSMODE}
2405DEPSDIR=.deps
2406DEPSFLAG_GCC="${DEPSFLAG_GCC}"
2407
2408mkdir -p ${D}DEPSDIR
2409
2410if test ${D}DEPSMODE = gcc ; then
2411 ${D}* ${D}{DEPSFLAG_GCC}
2412 status=${D}?
2413 if test ${D}{status} != 0 ; then
2414 exit ${D}{status}
2415 fi
2416 # move created file to the location we want it in:
2417 while test ${D}# -gt 0; do
2418 case "${D}1" in
2419 -o )
2420 shift
2421 objfile=${D}1
2422 ;;
2423 -* )
2424 ;;
2425 * )
2426 srcfile=${D}1
2427 ;;
2428 esac
2429 shift
2430 done
2431 depfile=\`basename ${D}srcfile | sed -e 's/\..*${D}/.d/g'\`
2432 depobjname=\`echo ${D}depfile |sed -e 's/\.d/.o/g'\`
2433 if test -f ${D}depfile ; then
2434 sed -e "s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{DEPSDIR}/${D}{objfile}.d
2435 rm -f ${D}depfile
2436 else
2437 depfile=\`basename ${D}objfile | sed -e 's/\..*${D}/.d/g'\`
2438 if test -f ${D}depfile ; then
2439 sed -e "/^${D}objfile/!s,${D}depobjname:,${D}objfile:,g" ${D}depfile >${D}{DEPSDIR}/${D}{objfile}.d
2440 rm -f ${D}depfile
2441 fi
2442 fi
2443 exit 0
2444else
2445 ${D}*
2446 exit ${D}?
2447fi
2448EOF
2449dnl ===================== bk-deps ends here =====================
2450])
2451
af8ebe8a 2452AC_DEFUN([AC_BAKEFILE_CREATE_FILE_SHARED_LD_SH],
3fd9c298
DE
2453[
2454dnl ===================== shared-ld-sh begins here =====================
2455D='$'
2456cat <<EOF >shared-ld-sh
2457#!/bin/sh
2458#-----------------------------------------------------------------------------
2459#-- Name: distrib/mac/shared-ld-sh
2460#-- Purpose: Link a mach-o dynamic shared library for Darwin / Mac OS X
2461#-- Author: Gilles Depeyrot
2462#-- Copyright: (c) 2002 Gilles Depeyrot
2463#-- Licence: any use permitted
2464#-----------------------------------------------------------------------------
2465
2466verbose=0
2467args=""
2468objects=""
2469linking_flag="-dynamiclib"
2470
2471while test ${D}# -gt 0; do
2472 case ${D}1 in
2473
2474 -v)
2475 verbose=1
2476 ;;
2477
2478 -o|-compatibility_version|-current_version|-framework|-undefined|-install_name)
2479 # collect these options and values
2480 args="${D}{args} ${D}1 ${D}2"
2481 shift
2482 ;;
2483
2484 -l*|-L*|-flat_namespace|-headerpad_max_install_names)
2485 # collect these options
2486 args="${D}{args} ${D}1"
2487 ;;
2488
2489 -dynamiclib|-bundle)
2490 linking_flag="${D}1"
2491 ;;
2492
2493 -*)
2494 echo "shared-ld: unhandled option '${D}1'"
2495 exit 1
2496 ;;
2497
2498 *.o | *.a | *.dylib)
2499 # collect object files
2500 objects="${D}{objects} ${D}1"
2501 ;;
2502
2503 *)
2504 echo "shared-ld: unhandled argument '${D}1'"
2505 exit 1
2506 ;;
2507
2508 esac
2509 shift
2510done
2511
2512#
2513# Link one module containing all the others
2514#
2515if test ${D}{verbose} = 1; then
2516 echo "c++ -r -keep_private_externs -nostdlib ${D}{objects} -o master.${D}${D}.o"
2517fi
2518c++ -r -keep_private_externs -nostdlib ${D}{objects} -o master.${D}${D}.o
2519status=${D}?
2520if test ${D}{status} != 0; then
2521 exit ${D}{status}
2522fi
2523
2524#
2525# Link the shared library from the single module created
2526#
2527if test ${D}{verbose} = 1; then
2528 echo "cc ${D}{linking_flag} master.${D}${D}.o ${D}{args}"
2529fi
2530c++ ${D}{linking_flag} master.${D}${D}.o ${D}{args}
2531status=${D}?
2532if test ${D}{status} != 0; then
2533 exit ${D}{status}
2534fi
2535
2536#
2537# Remove intermediate module
2538#
2539rm -f master.${D}${D}.o
2540
2541exit 0
2542EOF
2543dnl ===================== shared-ld-sh ends here =====================
2544])
fe0895cf 2545
670ec357 2546dnl
af8ebe8a 2547dnl AM_PATH_CPPUNIT(MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
670ec357
VS
2548dnl
2549AC_DEFUN(AM_PATH_CPPUNIT,
2550[
2551
2552AC_ARG_WITH(cppunit-prefix,[ --with-cppunit-prefix=PFX Prefix where CppUnit is installed (optional)],
2553 cppunit_config_prefix="$withval", cppunit_config_prefix="")
2554AC_ARG_WITH(cppunit-exec-prefix,[ --with-cppunit-exec-prefix=PFX Exec prefix where CppUnit is installed (optional)],
2555 cppunit_config_exec_prefix="$withval", cppunit_config_exec_prefix="")
2556
2557 if test x$cppunit_config_exec_prefix != x ; then
2558 cppunit_config_args="$cppunit_config_args --exec-prefix=$cppunit_config_exec_prefix"
2559 if test x${CPPUNIT_CONFIG+set} != xset ; then
2560 CPPUNIT_CONFIG=$cppunit_config_exec_prefix/bin/cppunit-config
2561 fi
2562 fi
2563 if test x$cppunit_config_prefix != x ; then
2564 cppunit_config_args="$cppunit_config_args --prefix=$cppunit_config_prefix"
2565 if test x${CPPUNIT_CONFIG+set} != xset ; then
2566 CPPUNIT_CONFIG=$cppunit_config_prefix/bin/cppunit-config
2567 fi
2568 fi
2569
2570 AC_PATH_PROG(CPPUNIT_CONFIG, cppunit-config, no)
2571 cppunit_version_min=$1
2572
2573 AC_MSG_CHECKING(for Cppunit - version >= $cppunit_version_min)
2574 no_cppunit=""
2575 if test "$CPPUNIT_CONFIG" = "no" ; then
2576 no_cppunit=yes
2577 else
2578 CPPUNIT_CFLAGS=`$CPPUNIT_CONFIG --cflags`
2579 CPPUNIT_LIBS=`$CPPUNIT_CONFIG --libs`
2580 cppunit_version=`$CPPUNIT_CONFIG --version`
2581
2582 cppunit_major_version=`echo $cppunit_version | \
2583 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
2584 cppunit_minor_version=`echo $cppunit_version | \
2585 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
2586 cppunit_micro_version=`echo $cppunit_version | \
2587 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
2588
2589 cppunit_major_min=`echo $cppunit_version_min | \
2590 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
2591 cppunit_minor_min=`echo $cppunit_version_min | \
2592 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
2593 cppunit_micro_min=`echo $cppunit_version_min | \
2594 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
2595
2596 cppunit_version_proper=`expr \
2597 $cppunit_major_version \> $cppunit_major_min \| \
2598 $cppunit_major_version \= $cppunit_major_min \& \
2599 $cppunit_minor_version \> $cppunit_minor_min \| \
2600 $cppunit_major_version \= $cppunit_major_min \& \
2601 $cppunit_minor_version \= $cppunit_minor_min \& \
2602 $cppunit_micro_version \>= $cppunit_micro_min `
2603
2604 if test "$cppunit_version_proper" = "1" ; then
2605 AC_MSG_RESULT([$cppunit_major_version.$cppunit_minor_version.$cppunit_micro_version])
2606 else
2607 AC_MSG_RESULT(no)
2608 no_cppunit=yes
2609 fi
2610 fi
2611
2612 if test "x$no_cppunit" = x ; then
2613 ifelse([$2], , :, [$2])
2614 else
2615 CPPUNIT_CFLAGS=""
2616 CPPUNIT_LIBS=""
2617 ifelse([$3], , :, [$3])
2618 fi
2619
2620 AC_SUBST(CPPUNIT_CFLAGS)
2621 AC_SUBST(CPPUNIT_LIBS)
2622])
2623
2624
2625
2626