]> git.saurik.com Git - wxWidgets.git/blob - aclocal.m4
distrib tweaks
[wxWidgets.git] / aclocal.m4
1 # aclocal.m4 generated automatically by aclocal 1.6.3 -*- Autoconf -*-
2
3 # Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002
4 # Free Software Foundation, Inc.
5 # This file is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 dnl ---------------------------------------------------------------------------
15 dnl
16 dnl Macros for configure.in for wxWindows by Robert Roebling, Phil Blecker,
17 dnl Vadim Zeitlin and Ron Lee
18 dnl
19 dnl This script is under the wxWindows licence.
20 dnl
21 dnl Version: $Id$
22 dnl ---------------------------------------------------------------------------
23
24 dnl ===========================================================================
25 dnl macros to find the a file in the list of include/lib paths
26 dnl ===========================================================================
27
28 dnl ---------------------------------------------------------------------------
29 dnl call WX_PATH_FIND_INCLUDES(search path, header name), sets ac_find_includes
30 dnl to the full name of the file that was found or leaves it empty if not found
31 dnl ---------------------------------------------------------------------------
32 AC_DEFUN([WX_PATH_FIND_INCLUDES],
33 [
34 ac_find_includes=
35 for ac_dir in $1 /usr/include;
36 do
37 if test -f "$ac_dir/$2"; then
38 ac_find_includes=$ac_dir
39 break
40 fi
41 done
42 ])
43
44 dnl ---------------------------------------------------------------------------
45 dnl call WX_PATH_FIND_LIBRARIES(search path, header name), sets ac_find_libraries
46 dnl to the full name of the file that was found or leaves it empty if not found
47 dnl ---------------------------------------------------------------------------
48 AC_DEFUN([WX_PATH_FIND_LIBRARIES],
49 [
50 ac_find_libraries=
51 for ac_dir in $1 /usr/lib;
52 do
53 for ac_extension in a so sl dylib; do
54 if test -f "$ac_dir/lib$2.$ac_extension"; then
55 ac_find_libraries=$ac_dir
56 break 2
57 fi
58 done
59 done
60 ])
61
62 dnl ---------------------------------------------------------------------------
63 dnl Path to include, already defined
64 dnl ---------------------------------------------------------------------------
65 AC_DEFUN([WX_INCLUDE_PATH_EXIST],
66 [
67 dnl never add -I/usr/include to the CPPFLAGS
68 if test "x$1" = "x/usr/include"; then
69 ac_path_to_include=""
70 else
71 echo "$2" | grep "\-I$1" > /dev/null
72 result=$?
73 if test $result = 0; then
74 ac_path_to_include=""
75 else
76 ac_path_to_include=" -I$1"
77 fi
78 fi
79 ])
80
81 dnl ---------------------------------------------------------------------------
82 dnl Path to link, already defined
83 dnl ---------------------------------------------------------------------------
84 AC_DEFUN([WX_LINK_PATH_EXIST],
85 [
86 echo "$2" | grep "\-L$1" > /dev/null
87 result=$?
88 if test $result = 0; then
89 ac_path_to_link=""
90 else
91 ac_path_to_link=" -L$1"
92 fi
93 ])
94
95 dnl ===========================================================================
96 dnl C++ features test
97 dnl ===========================================================================
98
99 dnl ---------------------------------------------------------------------------
100 dnl WX_CPP_NEW_HEADERS checks whether the compiler has "new" <iostream> header
101 dnl or only the old <iostream.h> one - it may be generally assumed that if
102 dnl <iostream> exists, the other "new" headers (without .h) exist too.
103 dnl
104 dnl call WX_CPP_NEW_HEADERS(actiof-if-true, action-if-false-or-cross-compiling)
105 dnl ---------------------------------------------------------------------------
106
107 AC_DEFUN([WX_CPP_NEW_HEADERS],
108 [
109 if test "$cross_compiling" = "yes"; then
110 ifelse([$2], , :, [$2])
111 else
112 AC_LANG_SAVE
113 AC_LANG_CPLUSPLUS
114
115 AC_CHECK_HEADERS(iostream)
116
117 if test "$ac_cv_header_iostream" = "yes" ; then
118 ifelse([$1], , :, [$1])
119 else
120 ifelse([$2], , :, [$2])
121 fi
122
123 AC_LANG_RESTORE
124 fi
125 ])
126
127 dnl ---------------------------------------------------------------------------
128 dnl WX_CPP_BOOL checks whether the C++ compiler has a built in bool type
129 dnl
130 dnl call WX_CPP_BOOL - will define HAVE_BOOL if the compiler supports bool
131 dnl ---------------------------------------------------------------------------
132
133 AC_DEFUN([WX_CPP_BOOL],
134 [
135 AC_CACHE_CHECK([if C++ compiler supports bool], wx_cv_cpp_bool,
136 [
137 AC_LANG_SAVE
138 AC_LANG_CPLUSPLUS
139
140 AC_TRY_COMPILE(
141 [
142 ],
143 [
144 bool b = true;
145
146 return 0;
147 ],
148 [
149 wx_cv_cpp_bool=yes
150 ],
151 [
152 wx_cv_cpp_bool=no
153 ]
154 )
155
156 AC_LANG_RESTORE
157 ])
158
159 if test "$wx_cv_cpp_bool" = "yes"; then
160 AC_DEFINE(HAVE_BOOL)
161 fi
162 ])
163
164 dnl ---------------------------------------------------------------------------
165 dnl WX_CPP_EXPLICIT checks whether the C++ compiler support the explicit
166 dnl keyword and defines HAVE_EXPLICIT if this is the case
167 dnl ---------------------------------------------------------------------------
168
169 AC_DEFUN([WX_CPP_EXPLICIT],
170 [
171 AC_CACHE_CHECK([if C++ compiler supports the explicit keyword],
172 wx_cv_explicit,
173 [
174 AC_LANG_SAVE
175 AC_LANG_CPLUSPLUS
176
177 dnl do the test in 2 steps: first check that the compiler knows about the
178 dnl explicit keyword at all and then verify that it really honours it
179 AC_TRY_COMPILE(
180 [
181 class Foo { public: explicit Foo(int) {} };
182 ],
183 [
184 return 0;
185 ],
186 [
187 AC_TRY_COMPILE(
188 [
189 class Foo { public: explicit Foo(int) {} };
190 static void TakeFoo(const Foo& foo) { }
191 ],
192 [
193 TakeFoo(17);
194 return 0;
195 ],
196 wx_cv_explicit=no,
197 wx_cv_explicit=yes
198 )
199 ],
200 wx_cv_explicit=no
201 )
202
203 AC_LANG_RESTORE
204 ])
205
206 if test "$wx_cv_explicit" = "yes"; then
207 AC_DEFINE(HAVE_EXPLICIT)
208 fi
209 ])
210
211 dnl ---------------------------------------------------------------------------
212 dnl a slightly better AC_C_BIGENDIAN macro which allows cross-compiling
213 dnl ---------------------------------------------------------------------------
214
215 AC_DEFUN([WX_C_BIGENDIAN],
216 [AC_CACHE_CHECK([whether byte ordering is bigendian], ac_cv_c_bigendian,
217 [ac_cv_c_bigendian=unknown
218 # See if sys/param.h defines the BYTE_ORDER macro.
219 AC_TRY_COMPILE([#include <sys/types.h>
220 #include <sys/param.h>], [
221 #if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
222 bogus endian macros
223 #endif], [# It does; now see whether it defined to BIG_ENDIAN or not.
224 AC_TRY_COMPILE([#include <sys/types.h>
225 #include <sys/param.h>], [
226 #if BYTE_ORDER != BIG_ENDIAN
227 not big endian
228 #endif], ac_cv_c_bigendian=yes, ac_cv_c_bigendian=no)])
229 if test $ac_cv_c_bigendian = unknown; then
230 AC_TRY_RUN([main () {
231 /* Are we little or big endian? From Harbison&Steele. */
232 union
233 {
234 long l;
235 char c[sizeof (long)];
236 } u;
237 u.l = 1;
238 exit (u.c[sizeof (long) - 1] == 1);
239 }], [ac_cv_c_bigendian=no], [ac_cv_c_bigendian=yes], [ac_cv_c_bigendian=unknown])
240 fi])
241 if test $ac_cv_c_bigendian = unknown; then
242 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])
243 fi
244 if test $ac_cv_c_bigendian = yes; then
245 AC_DEFINE(WORDS_BIGENDIAN)
246 fi
247 ])
248
249 dnl ---------------------------------------------------------------------------
250 dnl override AC_ARG_ENABLE/WITH to cache the results in .cache file
251 dnl ---------------------------------------------------------------------------
252
253 AC_DEFUN([WX_ARG_CACHE_INIT],
254 [
255 wx_arg_cache_file="configarg.cache"
256 echo "loading argument cache $wx_arg_cache_file"
257 rm -f ${wx_arg_cache_file}.tmp
258 touch ${wx_arg_cache_file}.tmp
259 touch ${wx_arg_cache_file}
260 ])
261
262 AC_DEFUN([WX_ARG_CACHE_FLUSH],
263 [
264 echo "saving argument cache $wx_arg_cache_file"
265 mv ${wx_arg_cache_file}.tmp ${wx_arg_cache_file}
266 ])
267
268 dnl this macro checks for a three-valued command line --with argument:
269 dnl possible arguments are 'yes', 'no', 'sys', or 'builtin'
270 dnl usage: WX_ARG_SYS_WITH(option, helpmessage, variable-name)
271 AC_DEFUN([WX_ARG_SYS_WITH],
272 [
273 AC_MSG_CHECKING([for --with-$1])
274 no_cache=0
275 AC_ARG_WITH($1, [$2],
276 [
277 if test "$withval" = yes; then
278 ac_cv_use_$1='$3=yes'
279 elif test "$withval" = no; then
280 ac_cv_use_$1='$3=no'
281 elif test "$withval" = sys; then
282 ac_cv_use_$1='$3=sys'
283 elif test "$withval" = builtin; then
284 ac_cv_use_$1='$3=builtin'
285 else
286 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
287 fi
288 ],
289 [
290 LINE=`grep "$3" ${wx_arg_cache_file}`
291 if test "x$LINE" != x ; then
292 eval "DEFAULT_$LINE"
293 else
294 no_cache=1
295 fi
296
297 ac_cv_use_$1='$3='$DEFAULT_$3
298 ])
299
300 eval "$ac_cv_use_$1"
301 if test "$no_cache" != 1; then
302 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
303 fi
304
305 if test "$$3" = yes; then
306 AC_MSG_RESULT(yes)
307 elif test "$$3" = no; then
308 AC_MSG_RESULT(no)
309 elif test "$$3" = sys; then
310 AC_MSG_RESULT([system version])
311 elif test "$$3" = builtin; then
312 AC_MSG_RESULT([builtin version])
313 else
314 AC_MSG_ERROR([Invalid value for --with-$1: should be yes, no, sys, or builtin])
315 fi
316 ])
317
318 dnl this macro checks for a command line argument and caches the result
319 dnl usage: WX_ARG_WITH(option, helpmessage, variable-name)
320 AC_DEFUN([WX_ARG_WITH],
321 [
322 AC_MSG_CHECKING([for --with-$1])
323 no_cache=0
324 AC_ARG_WITH($1, [$2],
325 [
326 if test "$withval" = yes; then
327 ac_cv_use_$1='$3=yes'
328 else
329 ac_cv_use_$1='$3=no'
330 fi
331 ],
332 [
333 LINE=`grep "$3" ${wx_arg_cache_file}`
334 if test "x$LINE" != x ; then
335 eval "DEFAULT_$LINE"
336 else
337 no_cache=1
338 fi
339
340 ac_cv_use_$1='$3='$DEFAULT_$3
341 ])
342
343 eval "$ac_cv_use_$1"
344 if test "$no_cache" != 1; then
345 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
346 fi
347
348 if test "$$3" = yes; then
349 AC_MSG_RESULT(yes)
350 else
351 AC_MSG_RESULT(no)
352 fi
353 ])
354
355 dnl like WX_ARG_WITH but uses AC_ARG_ENABLE instead of AC_ARG_WITH
356 dnl usage: WX_ARG_ENABLE(option, helpmessage, variable-name, enablestring)
357 dnl
358 dnl enablestring is a hack and allows to show "checking for --disable-foo"
359 dnl message when running configure instead of the default "checking for
360 dnl --enable-foo" one whih is useful for the options enabled by default
361 AC_DEFUN([WX_ARG_ENABLE],
362 [
363 enablestring=$4
364 AC_MSG_CHECKING([for --${enablestring:-enable}-$1])
365 no_cache=0
366 AC_ARG_ENABLE($1, [$2],
367 [
368 if test "$enableval" = yes; then
369 ac_cv_use_$1='$3=yes'
370 else
371 ac_cv_use_$1='$3=no'
372 fi
373 ],
374 [
375 LINE=`grep "$3" ${wx_arg_cache_file}`
376 if test "x$LINE" != x ; then
377 eval "DEFAULT_$LINE"
378 else
379 no_cache=1
380 fi
381
382 ac_cv_use_$1='$3='$DEFAULT_$3
383 ])
384
385 eval "$ac_cv_use_$1"
386 if test "$no_cache" != 1; then
387 echo $ac_cv_use_$1 >> ${wx_arg_cache_file}.tmp
388 fi
389
390 if test "$$3" = yes; then
391 AC_MSG_RESULT(yes)
392 else
393 AC_MSG_RESULT(no)
394 fi
395 ])
396
397
398 dnl ===========================================================================
399 dnl Linker features test
400 dnl ===========================================================================
401
402 dnl ---------------------------------------------------------------------------
403 dnl WX_VERSIONED_SYMBOLS checks whether the linker can create versioned
404 dnl symbols. If it can, sets LDFLAGS_VERSIONING to $CXX flags needed to use
405 dnl version script file named versionfile
406 dnl
407 dnl call WX_VERSIONED_SYMBOLS(versionfile)
408 dnl ---------------------------------------------------------------------------
409 AC_DEFUN([WX_VERSIONED_SYMBOLS],
410 [
411 found_versioning=no
412
413 dnl FIXME - doesn't work, Solaris linker doesn't accept wildcards
414 dnl in the script.
415 dnl dnl Check for known non-gcc cases:
416 dnl case "${host}" in
417 dnl *-*-solaris2* )
418 dnl if test "x$GCC" != "xyes" ; then
419 dnl LDFLAGS_VERSIONING="-M $1"
420 dnl found_versioning=yes
421 dnl fi
422 dnl ;;
423 dnl esac
424
425 dnl Generic check for GCC or GCC-like behaviour (Intel C++, GCC):
426 if test $found_versioning = no ; then
427 AC_CACHE_CHECK([if the linker accepts --version-script], wx_cv_version_script,
428 [
429 echo "VER_1 { *; };" >conftest.sym
430 echo "int main() { return 0; }" >conftest.cpp
431
432 if AC_TRY_COMMAND([
433 $CXX -o conftest.output $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.cpp
434 -Wl,--version-script,conftest.sym >/dev/null 2>conftest.stderr]) ; then
435 if test -s conftest.stderr ; then
436 wx_cv_version_script=no
437 else
438 wx_cv_version_script=yes
439 fi
440 else
441 wx_cv_version_script=no
442 fi
443 rm -f conftest.output conftest.stderr conftest.sym conftest.cpp
444 ])
445 if test $wx_cv_version_script = yes ; then
446 LDFLAGS_VERSIONING="-Wl,--version-script,$1"
447 fi
448 fi
449 ])
450
451
452 dnl ===========================================================================
453 dnl "3rd party" macros included here because they are not widely available
454 dnl ===========================================================================
455
456 dnl ---------------------------------------------------------------------------
457 dnl test for availability of iconv()
458 dnl ---------------------------------------------------------------------------
459
460 dnl From Bruno Haible.
461
462 AC_DEFUN([AM_ICONV],
463 [
464 dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
465 dnl those with the standalone portable GNU libiconv installed).
466
467 AC_ARG_WITH([libiconv-prefix],
468 [ --with-libiconv-prefix=DIR search for libiconv in DIR/include and DIR/lib], [
469 for dir in `echo "$withval" | tr : ' '`; do
470 if test -d $dir/include; then CPPFLAGS="$CPPFLAGS -I$dir/include"; fi
471 if test -d $dir/lib; then LDFLAGS="$LDFLAGS -L$dir/lib"; fi
472 done
473 ])
474
475 AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
476 am_cv_func_iconv="no, consider installing GNU libiconv"
477 am_cv_lib_iconv=no
478 AC_TRY_LINK([#include <stdlib.h>
479 #include <iconv.h>],
480 [iconv_t cd = iconv_open("","");
481 iconv(cd,NULL,NULL,NULL,NULL);
482 iconv_close(cd);],
483 am_cv_func_iconv=yes)
484 if test "$am_cv_func_iconv" != yes; then
485 am_save_LIBS="$LIBS"
486 LIBS="$LIBS -liconv"
487 AC_TRY_LINK([#include <stdlib.h>
488 #include <iconv.h>],
489 [iconv_t cd = iconv_open("","");
490 iconv(cd,NULL,NULL,NULL,NULL);
491 iconv_close(cd);],
492 am_cv_lib_iconv=yes
493 am_cv_func_iconv=yes)
494 LIBS="$am_save_LIBS"
495 fi
496 ])
497 if test "$am_cv_func_iconv" = yes; then
498 AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
499 AC_CACHE_CHECK([if iconv needs const], wx_cv_func_iconv_const,
500 AC_TRY_COMPILE([
501 #include <stdlib.h>
502 #include <iconv.h>
503 extern
504 #ifdef __cplusplus
505 "C"
506 #endif
507 #if defined(__STDC__) || defined(__cplusplus)
508 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
509 #else
510 size_t iconv();
511 #endif
512 ],
513 [],
514 wx_cv_func_iconv_const="no",
515 wx_cv_func_iconv_const="yes"
516 )
517 )
518
519 iconv_const=
520 if test "x$wx_cv_func_iconv_const" = "xyes"; then
521 iconv_const="const"
522 fi
523
524 AC_DEFINE_UNQUOTED(ICONV_CONST, $iconv_const,
525 [Define as const if the declaration of iconv() needs const.])
526 fi
527 LIBICONV=
528 if test "$am_cv_lib_iconv" = yes; then
529 LIBICONV="-liconv"
530 fi
531 AC_SUBST(LIBICONV)
532 ])
533
534 dnl ---------------------------------------------------------------------------
535 dnl AC_SYS_LARGEFILE (partly based on the code from autoconf 2.5x)
536 dnl ---------------------------------------------------------------------------
537
538 dnl WX_SYS_LARGEFILE_TEST
539 dnl
540 dnl NB: original autoconf test was checking if compiler supported 6 bit off_t
541 dnl arithmetic properly but this failed miserably with gcc under Linux
542 dnl whereas the system still supports 64 bit files, so now simply check
543 dnl that off_t is big enough
544 define(WX_SYS_LARGEFILE_TEST,
545 [typedef struct {
546 unsigned int field: sizeof(off_t) == 8;
547 } wxlf;
548 ])
549
550
551 dnl WX_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR)
552 define(WX_SYS_LARGEFILE_MACRO_VALUE,
553 [
554 AC_CACHE_CHECK([for $1 value needed for large files], [$3],
555 [
556 AC_TRY_COMPILE([#define $1 $2
557 #include <sys/types.h>],
558 WX_SYS_LARGEFILE_TEST,
559 [$3=$2],
560 [$3=no])
561 ]
562 )
563
564 if test "$$3" != no; then
565 wx_largefile=yes
566 AC_DEFINE_UNQUOTED([$1], [$$3])
567 fi
568 ])
569
570
571 dnl AC_SYS_LARGEFILE
572 dnl ----------------
573 dnl By default, many hosts won't let programs access large files;
574 dnl one must use special compiler options to get large-file access to work.
575 dnl For more details about this brain damage please see:
576 dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
577 AC_DEFUN([AC_SYS_LARGEFILE],
578 [AC_ARG_ENABLE(largefile,
579 [ --disable-largefile omit support for large files])
580 if test "$enable_largefile" != no; then
581 dnl _FILE_OFFSET_BITS==64 is needed for Linux, Solaris, ...
582 dnl _LARGE_FILES -- for AIX
583 wx_largefile=no
584 WX_SYS_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS, 64, ac_cv_sys_file_offset_bits)
585 if test "x$wx_largefile" != "xyes"; then
586 WX_SYS_LARGEFILE_MACRO_VALUE(_LARGE_FILES, 1, ac_cv_sys_large_files)
587 fi
588
589 AC_MSG_CHECKING(if large file support is available)
590 if test "x$wx_largefile" = "xyes"; then
591 AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
592 fi
593 AC_MSG_RESULT($wx_largefile)
594 fi
595 ])
596
597
598 dnl Available from the GNU Autoconf Macro Archive at:
599 dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_const_cast.html
600 dnl
601 AC_DEFUN([AC_CXX_CONST_CAST],
602 [AC_CACHE_CHECK(whether the compiler supports const_cast<>,
603 ac_cv_cxx_const_cast,
604 [AC_LANG_SAVE
605 AC_LANG_CPLUSPLUS
606 AC_TRY_COMPILE(,[int x = 0;const int& y = x;int& z = const_cast<int&>(y);return z;],
607 ac_cv_cxx_const_cast=yes, ac_cv_cxx_const_cast=no)
608 AC_LANG_RESTORE
609 ])
610 if test "$ac_cv_cxx_const_cast" = yes; then
611 AC_DEFINE(HAVE_CONST_CAST,,[define if the compiler supports const_cast<>])
612 fi
613 ])
614
615 dnl and http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_static_cast.html
616 AC_DEFUN([AC_CXX_STATIC_CAST],
617 [AC_CACHE_CHECK(whether the compiler supports static_cast<>,
618 ac_cv_cxx_static_cast,
619 [AC_LANG_SAVE
620 AC_LANG_CPLUSPLUS
621 AC_TRY_COMPILE([#include <typeinfo>
622 class Base { public : Base () {} virtual void f () = 0; };
623 class Derived : public Base { public : Derived () {} virtual void f () {} };
624 int g (Derived&) { return 0; }],[
625 Derived d; Base& b = d; Derived& s = static_cast<Derived&> (b); return g (s);],
626 ac_cv_cxx_static_cast=yes, ac_cv_cxx_static_cast=no)
627 AC_LANG_RESTORE
628 ])
629 if test "$ac_cv_cxx_static_cast" = yes; then
630 AC_DEFINE(HAVE_STATIC_CAST,, [define if the compiler supports static_cast<>])
631 fi
632 ])
633
634 # Configure paths for GTK+
635 # Owen Taylor 1997-2001
636
637 dnl AM_PATH_GTK_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
638 dnl Test for GTK+, and define GTK_CFLAGS and GTK_LIBS, if gthread is specified in MODULES,
639 dnl pass to pkg-config
640 dnl
641 AC_DEFUN(AM_PATH_GTK_2_0,
642 [dnl
643 dnl Get the cflags and libraries from pkg-config
644 dnl
645 AC_ARG_ENABLE(gtktest, [ --disable-gtktest do not try to compile and run a test GTK+ program],
646 , enable_gtktest=yes)
647
648 pkg_config_args=gtk+-2.0
649 for module in . $4
650 do
651 case "$module" in
652 gthread)
653 pkg_config_args="$pkg_config_args gthread-2.0"
654 ;;
655 esac
656 done
657
658 no_gtk=""
659
660 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
661
662 if test x$PKG_CONFIG != xno ; then
663 if pkg-config --atleast-pkgconfig-version 0.7 ; then
664 :
665 else
666 echo *** pkg-config too old; version 0.7 or better required.
667 no_gtk=yes
668 PKG_CONFIG=no
669 fi
670 else
671 no_gtk=yes
672 fi
673
674 min_gtk_version=ifelse([$1], ,2.0.0,$1)
675 AC_MSG_CHECKING(for GTK+ - version >= $min_gtk_version)
676
677 if test x$PKG_CONFIG != xno ; then
678 ## don't try to run the test against uninstalled libtool libs
679 if $PKG_CONFIG --uninstalled $pkg_config_args; then
680 echo "Will use uninstalled version of GTK+ found in PKG_CONFIG_PATH"
681 enable_gtktest=no
682 fi
683
684 if $PKG_CONFIG --atleast-version $min_gtk_version $pkg_config_args; then
685 :
686 else
687 no_gtk=yes
688 fi
689 fi
690
691 if test x"$no_gtk" = x ; then
692 GTK_CFLAGS=`$PKG_CONFIG $pkg_config_args --cflags`
693 GTK_LIBS=`$PKG_CONFIG $pkg_config_args --libs`
694 gtk_config_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
695 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
696 gtk_config_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
697 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
698 gtk_config_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
699 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
700 if test "x$enable_gtktest" = "xyes" ; then
701 ac_save_CFLAGS="$CFLAGS"
702 ac_save_LIBS="$LIBS"
703 CFLAGS="$CFLAGS $GTK_CFLAGS"
704 LIBS="$GTK_LIBS $LIBS"
705 dnl
706 dnl Now check if the installed GTK+ is sufficiently new. (Also sanity
707 dnl checks the results of pkg-config to some extent)
708 dnl
709 rm -f conf.gtktest
710 AC_TRY_RUN([
711 #include <gtk/gtk.h>
712 #include <stdio.h>
713 #include <stdlib.h>
714
715 int
716 main ()
717 {
718 int major, minor, micro;
719 char *tmp_version;
720
721 system ("touch conf.gtktest");
722
723 /* HP/UX 9 (%@#!) writes to sscanf strings */
724 tmp_version = g_strdup("$min_gtk_version");
725 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
726 printf("%s, bad version string\n", "$min_gtk_version");
727 exit(1);
728 }
729
730 if ((gtk_major_version != $gtk_config_major_version) ||
731 (gtk_minor_version != $gtk_config_minor_version) ||
732 (gtk_micro_version != $gtk_config_micro_version))
733 {
734 printf("\n*** 'pkg-config --modversion gtk+-2.0' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
735 $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
736 gtk_major_version, gtk_minor_version, gtk_micro_version);
737 printf ("*** was found! If pkg-config was correct, then it is best\n");
738 printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
739 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
740 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
741 printf("*** required on your system.\n");
742 printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
743 printf("*** to point to the correct configuration files\n");
744 }
745 else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
746 (gtk_minor_version != GTK_MINOR_VERSION) ||
747 (gtk_micro_version != GTK_MICRO_VERSION))
748 {
749 printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
750 GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
751 printf("*** library (version %d.%d.%d)\n",
752 gtk_major_version, gtk_minor_version, gtk_micro_version);
753 }
754 else
755 {
756 if ((gtk_major_version > major) ||
757 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
758 ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
759 {
760 return 0;
761 }
762 else
763 {
764 printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
765 gtk_major_version, gtk_minor_version, gtk_micro_version);
766 printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
767 major, minor, micro);
768 printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
769 printf("***\n");
770 printf("*** If you have already installed a sufficiently new version, this error\n");
771 printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
772 printf("*** being found. The easiest way to fix this is to remove the old version\n");
773 printf("*** of GTK+, but you can also set the PKG_CONFIG environment to point to the\n");
774 printf("*** correct copy of pkg-config. (In this case, you will have to\n");
775 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
776 printf("*** so that the correct libraries are found at run-time))\n");
777 }
778 }
779 return 1;
780 }
781 ],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
782 CFLAGS="$ac_save_CFLAGS"
783 LIBS="$ac_save_LIBS"
784 fi
785 fi
786 if test "x$no_gtk" = x ; then
787 AC_MSG_RESULT(yes (version $gtk_config_major_version.$gtk_config_minor_version.$gtk_config_micro_version))
788 ifelse([$2], , :, [$2])
789 else
790 AC_MSG_RESULT(no)
791 if test "$PKG_CONFIG" = "no" ; then
792 echo "*** A new enough version of pkg-config was not found."
793 echo "*** See http://pkgconfig.sourceforge.net"
794 else
795 if test -f conf.gtktest ; then
796 :
797 else
798 echo "*** Could not run GTK+ test program, checking why..."
799 ac_save_CFLAGS="$CFLAGS"
800 ac_save_LIBS="$LIBS"
801 CFLAGS="$CFLAGS $GTK_CFLAGS"
802 LIBS="$LIBS $GTK_LIBS"
803 AC_TRY_LINK([
804 #include <gtk/gtk.h>
805 #include <stdio.h>
806 ], [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
807 [ echo "*** The test program compiled, but did not run. This usually means"
808 echo "*** that the run-time linker is not finding GTK+ or finding the wrong"
809 echo "*** version of GTK+. If it is not finding GTK+, you'll need to set your"
810 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
811 echo "*** to the installed location Also, make sure you have run ldconfig if that"
812 echo "*** is required on your system"
813 echo "***"
814 echo "*** If you have an old version installed, it is best to remove it, although"
815 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
816 [ echo "*** The test program failed to compile or link. See the file config.log for the"
817 echo "*** exact error that occured. This usually means GTK+ is incorrectly installed."])
818 CFLAGS="$ac_save_CFLAGS"
819 LIBS="$ac_save_LIBS"
820 fi
821 fi
822 GTK_CFLAGS=""
823 GTK_LIBS=""
824 ifelse([$3], , :, [$3])
825 fi
826 AC_SUBST(GTK_CFLAGS)
827 AC_SUBST(GTK_LIBS)
828 rm -f conf.gtktest
829 ])
830
831 # Configure paths for GTK+
832 # Owen Taylor 97-11-3
833
834 dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
835 dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
836 dnl
837 AC_DEFUN(AM_PATH_GTK,
838 [dnl
839 dnl Get the cflags and libraries from the gtk-config script
840 dnl
841 AC_ARG_WITH(gtk-prefix,[ --with-gtk-prefix=PFX Prefix where GTK is installed (optional)],
842 gtk_config_prefix="$withval", gtk_config_prefix="")
843 AC_ARG_WITH(gtk-exec-prefix,[ --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)],
844 gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="")
845 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
846 , enable_gtktest=yes)
847
848 for module in . $4
849 do
850 case "$module" in
851 gthread)
852 gtk_config_args="$gtk_config_args gthread"
853 ;;
854 esac
855 done
856
857 if test x$gtk_config_exec_prefix != x ; then
858 gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix"
859 if test x${GTK_CONFIG+set} != xset ; then
860 GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config
861 fi
862 fi
863 if test x$gtk_config_prefix != x ; then
864 gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix"
865 if test x${GTK_CONFIG+set} != xset ; then
866 GTK_CONFIG=$gtk_config_prefix/bin/gtk-config
867 fi
868 fi
869
870 AC_PATH_PROG(GTK_CONFIG, gtk-config, no)
871 min_gtk_version=ifelse([$1], ,0.99.7,$1)
872 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
873 no_gtk=""
874 if test "$GTK_CONFIG" = "no" ; then
875 no_gtk=yes
876 else
877 GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags`
878 GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs`
879 gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \
880 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
881 gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \
882 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
883 gtk_config_micro_version=`$GTK_CONFIG $gtk_config_args --version | \
884 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
885 if test "x$enable_gtktest" = "xyes" ; then
886 ac_save_CFLAGS="$CFLAGS"
887 ac_save_LIBS="$LIBS"
888 CFLAGS="$CFLAGS $GTK_CFLAGS"
889 LIBS="$GTK_LIBS $LIBS"
890 dnl
891 dnl Now check if the installed GTK is sufficiently new. (Also sanity
892 dnl checks the results of gtk-config to some extent
893 dnl
894 rm -f conf.gtktest
895 AC_TRY_RUN([
896 #include <gtk/gtk.h>
897 #include <stdio.h>
898 #include <stdlib.h>
899
900 int
901 main ()
902 {
903 int major, minor, micro;
904 char *tmp_version;
905
906 system ("touch conf.gtktest");
907
908 /* HP/UX 9 (%@#!) writes to sscanf strings */
909 tmp_version = g_strdup("$min_gtk_version");
910 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
911 printf("%s, bad version string\n", "$min_gtk_version");
912 exit(1);
913 }
914
915 if ((gtk_major_version != $gtk_config_major_version) ||
916 (gtk_minor_version != $gtk_config_minor_version) ||
917 (gtk_micro_version != $gtk_config_micro_version))
918 {
919 printf("\n*** 'gtk-config --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
920 $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
921 gtk_major_version, gtk_minor_version, gtk_micro_version);
922 printf ("*** was found! If gtk-config was correct, then it is best\n");
923 printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
924 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
925 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
926 printf("*** required on your system.\n");
927 printf("*** If gtk-config was wrong, set the environment variable GTK_CONFIG\n");
928 printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n");
929 printf("*** before re-running configure\n");
930 }
931 #if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION)
932 else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
933 (gtk_minor_version != GTK_MINOR_VERSION) ||
934 (gtk_micro_version != GTK_MICRO_VERSION))
935 {
936 printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
937 GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
938 printf("*** library (version %d.%d.%d)\n",
939 gtk_major_version, gtk_minor_version, gtk_micro_version);
940 }
941 #endif /* defined (GTK_MAJOR_VERSION) ... */
942 else
943 {
944 if ((gtk_major_version > major) ||
945 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
946 ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
947 {
948 return 0;
949 }
950 else
951 {
952 printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
953 gtk_major_version, gtk_minor_version, gtk_micro_version);
954 printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
955 major, minor, micro);
956 printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
957 printf("***\n");
958 printf("*** If you have already installed a sufficiently new version, this error\n");
959 printf("*** probably means that the wrong copy of the gtk-config shell script is\n");
960 printf("*** being found. The easiest way to fix this is to remove the old version\n");
961 printf("*** of GTK+, but you can also set the GTK_CONFIG environment to point to the\n");
962 printf("*** correct copy of gtk-config. (In this case, you will have to\n");
963 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
964 printf("*** so that the correct libraries are found at run-time))\n");
965 }
966 }
967 return 1;
968 }
969 ],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
970 CFLAGS="$ac_save_CFLAGS"
971 LIBS="$ac_save_LIBS"
972 fi
973 fi
974 if test "x$no_gtk" = x ; then
975 AC_MSG_RESULT(yes)
976 ifelse([$2], , :, [$2])
977 else
978 AC_MSG_RESULT(no)
979 if test "$GTK_CONFIG" = "no" ; then
980 echo "*** The gtk-config script installed by GTK could not be found"
981 echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in"
982 echo "*** your path, or set the GTK_CONFIG environment variable to the"
983 echo "*** full path to gtk-config."
984 else
985 if test -f conf.gtktest ; then
986 :
987 else
988 echo "*** Could not run GTK test program, checking why..."
989 CFLAGS="$CFLAGS $GTK_CFLAGS"
990 LIBS="$LIBS $GTK_LIBS"
991 AC_TRY_LINK([
992 #include <gtk/gtk.h>
993 #include <stdio.h>
994 ], [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
995 [ echo "*** The test program compiled, but did not run. This usually means"
996 echo "*** that the run-time linker is not finding GTK or finding the wrong"
997 echo "*** version of GTK. If it is not finding GTK, you'll need to set your"
998 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
999 echo "*** to the installed location Also, make sure you have run ldconfig if that"
1000 echo "*** is required on your system"
1001 echo "***"
1002 echo "*** If you have an old version installed, it is best to remove it, although"
1003 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
1004 echo "***"
1005 echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
1006 echo "*** came with the system with the command"
1007 echo "***"
1008 echo "*** rpm --erase --nodeps gtk gtk-devel" ],
1009 [ echo "*** The test program failed to compile or link. See the file config.log for the"
1010 echo "*** exact error that occured. This usually means GTK was incorrectly installed"
1011 echo "*** or that you have moved GTK since it was installed. In the latter case, you"
1012 echo "*** may want to edit the gtk-config script: $GTK_CONFIG" ])
1013 CFLAGS="$ac_save_CFLAGS"
1014 LIBS="$ac_save_LIBS"
1015 fi
1016 fi
1017 GTK_CFLAGS=""
1018 GTK_LIBS=""
1019 ifelse([$3], , :, [$3])
1020 fi
1021 AC_SUBST(GTK_CFLAGS)
1022 AC_SUBST(GTK_LIBS)
1023 rm -f conf.gtktest
1024 ])
1025
1026
1027 dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not)
1028 dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
1029 dnl also defines GSTUFF_PKG_ERRORS on error
1030 AC_DEFUN(PKG_CHECK_MODULES, [
1031 succeeded=no
1032
1033 if test -z "$PKG_CONFIG"; then
1034 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
1035 fi
1036
1037 if test "$PKG_CONFIG" = "no" ; then
1038 echo "*** The pkg-config script could not be found. Make sure it is"
1039 echo "*** in your path, or set the PKG_CONFIG environment variable"
1040 echo "*** to the full path to pkg-config."
1041 echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
1042 else
1043 PKG_CONFIG_MIN_VERSION=0.9.0
1044 if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
1045 AC_MSG_CHECKING(for $2)
1046
1047 if $PKG_CONFIG --exists "$2" ; then
1048 AC_MSG_RESULT(yes)
1049 succeeded=yes
1050
1051 AC_MSG_CHECKING($1_CFLAGS)
1052 $1_CFLAGS=`$PKG_CONFIG --cflags "$2"`
1053 AC_MSG_RESULT($$1_CFLAGS)
1054
1055 AC_MSG_CHECKING($1_LIBS)
1056 $1_LIBS=`$PKG_CONFIG --libs "$2"`
1057 AC_MSG_RESULT($$1_LIBS)
1058 else
1059 $1_CFLAGS=""
1060 $1_LIBS=""
1061 ## If we have a custom action on failure, don't print errors, but
1062 ## do set a variable so people can do so.
1063 $1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
1064 ifelse([$4], ,echo $$1_PKG_ERRORS,)
1065 fi
1066
1067 AC_SUBST($1_CFLAGS)
1068 AC_SUBST($1_LIBS)
1069 else
1070 echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
1071 echo "*** See http://www.freedesktop.org/software/pkgconfig"
1072 fi
1073 fi
1074
1075 if test $succeeded = yes; then
1076 ifelse([$3], , :, [$3])
1077 else
1078 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])
1079 fi
1080 ])
1081
1082
1083
1084 # Configure paths for SDL
1085 # Sam Lantinga 9/21/99
1086 # stolen from Manish Singh
1087 # stolen back from Frank Belew
1088 # stolen from Manish Singh
1089 # Shamelessly stolen from Owen Taylor
1090
1091 dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
1092 dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
1093 dnl
1094 AC_DEFUN(AM_PATH_SDL,
1095 [dnl
1096 dnl Get the cflags and libraries from the sdl-config script
1097 dnl
1098 AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)],
1099 sdl_prefix="$withval", sdl_prefix="")
1100 AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
1101 sdl_exec_prefix="$withval", sdl_exec_prefix="")
1102 AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program],
1103 , enable_sdltest=yes)
1104
1105 if test x$sdl_exec_prefix != x ; then
1106 sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix"
1107 if test x${SDL_CONFIG+set} != xset ; then
1108 SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
1109 fi
1110 fi
1111 if test x$sdl_prefix != x ; then
1112 sdl_args="$sdl_args --prefix=$sdl_prefix"
1113 if test x${SDL_CONFIG+set} != xset ; then
1114 SDL_CONFIG=$sdl_prefix/bin/sdl-config
1115 fi
1116 fi
1117
1118 AC_REQUIRE([AC_CANONICAL_TARGET])
1119 PATH="$prefix/bin:$prefix/usr/bin:$PATH"
1120 AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH])
1121 min_sdl_version=ifelse([$1], ,0.11.0,$1)
1122 AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
1123 no_sdl=""
1124 if test "$SDL_CONFIG" = "no" ; then
1125 no_sdl=yes
1126 else
1127 SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags`
1128 SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs`
1129
1130 sdl_major_version=`$SDL_CONFIG $sdl_args --version | \
1131 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
1132 sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \
1133 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
1134 sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
1135 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
1136 if test "x$enable_sdltest" = "xyes" ; then
1137 ac_save_CFLAGS="$CFLAGS"
1138 ac_save_LIBS="$LIBS"
1139 CFLAGS="$CFLAGS $SDL_CFLAGS"
1140 LIBS="$LIBS $SDL_LIBS"
1141 dnl
1142 dnl Now check if the installed SDL is sufficiently new. (Also sanity
1143 dnl checks the results of sdl-config to some extent
1144 dnl
1145 rm -f conf.sdltest
1146 AC_TRY_RUN([
1147 #include <stdio.h>
1148 #include <stdlib.h>
1149 #include <string.h>
1150 #include "SDL.h"
1151
1152 char*
1153 my_strdup (char *str)
1154 {
1155 char *new_str;
1156
1157 if (str)
1158 {
1159 new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
1160 strcpy (new_str, str);
1161 }
1162 else
1163 new_str = NULL;
1164
1165 return new_str;
1166 }
1167
1168 int main (int argc, char *argv[])
1169 {
1170 int major, minor, micro;
1171 char *tmp_version;
1172
1173 /* This hangs on some systems (?)
1174 system ("touch conf.sdltest");
1175 */
1176 { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
1177
1178 /* HP/UX 9 (%@#!) writes to sscanf strings */
1179 tmp_version = my_strdup("$min_sdl_version");
1180 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
1181 printf("%s, bad version string\n", "$min_sdl_version");
1182 exit(1);
1183 }
1184
1185 if (($sdl_major_version > major) ||
1186 (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
1187 (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
1188 {
1189 return 0;
1190 }
1191 else
1192 {
1193 printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
1194 printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
1195 printf("*** best to upgrade to the required version.\n");
1196 printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
1197 printf("*** to point to the correct copy of sdl-config, and remove the file\n");
1198 printf("*** config.cache before re-running configure\n");
1199 return 1;
1200 }
1201 }
1202
1203 ],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
1204 CFLAGS="$ac_save_CFLAGS"
1205 LIBS="$ac_save_LIBS"
1206 fi
1207 fi
1208 if test "x$no_sdl" = x ; then
1209 AC_MSG_RESULT(yes)
1210 ifelse([$2], , :, [$2])
1211 else
1212 AC_MSG_RESULT(no)
1213 if test "$SDL_CONFIG" = "no" ; then
1214 echo "*** The sdl-config script installed by SDL could not be found"
1215 echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
1216 echo "*** your path, or set the SDL_CONFIG environment variable to the"
1217 echo "*** full path to sdl-config."
1218 else
1219 if test -f conf.sdltest ; then
1220 :
1221 else
1222 echo "*** Could not run SDL test program, checking why..."
1223 CFLAGS="$CFLAGS $SDL_CFLAGS"
1224 LIBS="$LIBS $SDL_LIBS"
1225 AC_TRY_LINK([
1226 #include <stdio.h>
1227 #include "SDL.h"
1228
1229 int main(int argc, char *argv[])
1230 { return 0; }
1231 #undef main
1232 #define main K_and_R_C_main
1233 ], [ return 0; ],
1234 [ echo "*** The test program compiled, but did not run. This usually means"
1235 echo "*** that the run-time linker is not finding SDL or finding the wrong"
1236 echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
1237 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
1238 echo "*** to the installed location Also, make sure you have run ldconfig if that"
1239 echo "*** is required on your system"
1240 echo "***"
1241 echo "*** If you have an old version installed, it is best to remove it, although"
1242 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
1243 [ echo "*** The test program failed to compile or link. See the file config.log for the"
1244 echo "*** exact error that occured. This usually means SDL was incorrectly installed"
1245 echo "*** or that you have moved SDL since it was installed. In the latter case, you"
1246 echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
1247 CFLAGS="$ac_save_CFLAGS"
1248 LIBS="$ac_save_LIBS"
1249 fi
1250 fi
1251 SDL_CFLAGS=""
1252 SDL_LIBS=""
1253 ifelse([$3], , :, [$3])
1254 fi
1255 AC_SUBST(SDL_CFLAGS)
1256 AC_SUBST(SDL_LIBS)
1257 rm -f conf.sdltest
1258 ])
1259
1260 dnl ---------------------------------------------------------------------------
1261 dnl Support macros for makefiles generated by BAKEFILE.
1262 dnl ---------------------------------------------------------------------------
1263
1264 dnl Lots of compiler & linker detection code contained here was taken from
1265 dnl wxWindows configure.in script (see http://www.wxwindows.org)
1266
1267
1268
1269 dnl ---------------------------------------------------------------------------
1270 dnl AC_BAKEFILE_GNUMAKE
1271 dnl
1272 dnl Detects GNU make
1273 dnl ---------------------------------------------------------------------------
1274
1275 AC_DEFUN(AC_BAKEFILE_GNUMAKE,
1276 [
1277 dnl does make support "-include" (only GNU make does AFAIK)?
1278 AC_CACHE_CHECK([if make is GNU make], bakefile_cv_prog_makeisgnu,
1279 [
1280 if ( ${SHELL-sh} -c "${MAKE-make} --version" 2> /dev/null |
1281 egrep -s GNU > /dev/null); then
1282 bakefile_cv_prog_makeisgnu="yes"
1283 else
1284 bakefile_cv_prog_makeisgnu="no"
1285 fi
1286 ])
1287
1288 if test "x$bakefile_cv_prog_makeisgnu" = "xyes"; then
1289 IF_GNU_MAKE=""
1290 else
1291 IF_GNU_MAKE="#"
1292 fi
1293 AC_SUBST(IF_GNU_MAKE)
1294 ])
1295
1296 dnl ---------------------------------------------------------------------------
1297 dnl AC_BAKEFILE_PLATFORM
1298 dnl
1299 dnl Detects platform and sets PLATFORM_XXX variables accordingly
1300 dnl ---------------------------------------------------------------------------
1301
1302 AC_DEFUN(AC_BAKEFILE_PLATFORM,
1303 [
1304 PLATFORM_UNIX=0
1305 PLATFORM_WIN32=0
1306 PLATFORM_MSDOS=0
1307 PLATFORM_MAC=0
1308 PLATFORM_MACOSX=0
1309 PLATFORM_OS2=0
1310
1311 if test "x$BAKEFILE_FORCE_PLATFORM" = "x"; then
1312 case "${BAKEFILE_HOST}" in
1313 *-*-cygwin* | *-*-mingw32* )
1314 PLATFORM_WIN32=1
1315 ;;
1316 *-pc-msdosdjgpp )
1317 PLATFORM_MSDOS=1
1318 ;;
1319 *-pc-os2_emx | *-pc-os2-emx )
1320 PLATFORM_OS2=1
1321 ;;
1322 powerpc-*-darwin* )
1323 PLATFORM_MAC=1
1324 PLATFORM_MACOSX=1
1325 ;;
1326 * )
1327 PLATFORM_UNIX=1
1328 ;;
1329 esac
1330 else
1331 case "$BAKEFILE_FORCE_PLATFORM" in
1332 win32 )
1333 PLATFORM_WIN32=1
1334 ;;
1335 msdos )
1336 PLATFORM_MSDOS=1
1337 ;;
1338 os2 )
1339 PLATFORM_OS2=1
1340 ;;
1341 darwin )
1342 PLATFORM_MAC=1
1343 PLATFORM_MACOSX=1
1344 ;;
1345 unix )
1346 PLATFORM_UNIX=1
1347 ;;
1348 * )
1349 AC_MSG_ERROR([Unknown platform: $BAKEFILE_FORCE_PLATFORM])
1350 ;;
1351 esac
1352 fi
1353
1354 AC_SUBST(PLATFORM_UNIX)
1355 AC_SUBST(PLATFORM_WIN32)
1356 AC_SUBST(PLATFORM_MSDOS)
1357 AC_SUBST(PLATFORM_MAC)
1358 AC_SUBST(PLATFORM_MACOSX)
1359 AC_SUBST(PLATFORM_OS2)
1360 ])
1361
1362
1363
1364 dnl ---------------------------------------------------------------------------
1365 dnl AC_BAKEFILE_SUFFIXES
1366 dnl
1367 dnl Detects shared various suffixes for shared libraries, libraries, programs,
1368 dnl plugins etc.
1369 dnl ---------------------------------------------------------------------------
1370
1371 AC_DEFUN(AC_BAKEFILE_SUFFIXES,
1372 [
1373 SO_SUFFIX="so"
1374 SO_SUFFIX_MODULE="so"
1375 EXEEXT=""
1376 LIBPREFIX=lib
1377 DLLPREFIX=lib
1378 DLLPREFIX_MODULE=
1379
1380 case "${BAKEFILE_HOST}" in
1381 *-hp-hpux* )
1382 SO_SUFFIX="sl"
1383 SO_SUFFIX_MODULE="sl"
1384 ;;
1385 *-*-aix* )
1386 dnl quoting from
1387 dnl http://www-1.ibm.com/servers/esdd/articles/gnu.html:
1388 dnl Both archive libraries and shared libraries on AIX have an
1389 dnl .a extension. This will explain why you can't link with an
1390 dnl .so and why it works with the name changed to .a.
1391 SO_SUFFIX="a"
1392 SO_SUFFIX_MODULE="a"
1393 ;;
1394 *-*-cygwin* | *-*-mingw32* )
1395 SO_SUFFIX="dll"
1396 SO_SUFFIX_MODULE="dll"
1397 EXEEXT=".exe"
1398 DLLPREFIX=""
1399 ;;
1400 *-pc-msdosdjgpp )
1401 EXEEXT=".exe"
1402 DLLPREFIX=""
1403 ;;
1404 *-pc-os2_emx | *-pc-os2-emx )
1405 EXEEXT=".exe"
1406 DLLPREFIX=""
1407 LIBPREFIX=""
1408 ;;
1409 powerpc-*-darwin* )
1410 SO_SUFFIX="dylib"
1411 SO_SUFFIX_MODULE="bundle"
1412 ;;
1413 esac
1414
1415 AC_SUBST(SO_SUFFIX)
1416 AC_SUBST(SO_SUFFIX_MODULE)
1417 AC_SUBST(EXEEXT)
1418 AC_SUBST(LIBPREFIX)
1419 AC_SUBST(DLLPREFIX)
1420 AC_SUBST(DLLPREFIX_MODULE)
1421 ])
1422
1423
1424 dnl ---------------------------------------------------------------------------
1425 dnl AC_BAKEFILE_SHARED_LD
1426 dnl
1427 dnl Detects command for making shared libraries, substitutes SHARED_LD_CC
1428 dnl and SHARED_LD_CXX.
1429 dnl ---------------------------------------------------------------------------
1430
1431 AC_DEFUN(AC_BAKEFILE_SHARED_LD,
1432 [
1433 dnl Defaults for GCC and ELF .so shared libs:
1434 SHARED_LD_CC="\$(CC) -shared -o"
1435 SHARED_LD_CXX="\$(CXX) -shared -o"
1436
1437 dnl the extra compiler flags needed for compilation of shared library
1438 if test "x$GCC" = "xyes"; then
1439 dnl the switch for gcc is the same under all platforms
1440 PIC_FLAG="-fPIC"
1441 fi
1442
1443 case "${BAKEFILE_HOST}" in
1444 *-hp-hpux* )
1445 dnl default settings are good for gcc but not for the native HP-UX
1446 if test "x$GCC" = "xyes"; then
1447 dnl -o flag must be after PIC flag
1448 SHARED_LD_CC="${CC} -shared ${PIC_FLAG} -o"
1449 SHARED_LD_CXX="${CXX} -shared ${PIC_FLAG} -o"
1450 else
1451 dnl no idea why it wants it, but it does
1452 LDFLAGS="$LDFLAGS -L/usr/lib"
1453
1454 SHARED_LD_CC="${CC} -b -o"
1455 SHARED_LD_CXX="${CXX} -b -o"
1456 PIC_FLAG="+Z"
1457 fi
1458 ;;
1459
1460 *-*-linux* )
1461 if test "x$GCC" != "xyes"; then
1462 AC_CACHE_CHECK([for Intel compiler], bakefile_cv_prog_icc,
1463 [
1464 AC_TRY_COMPILE([],
1465 [
1466 #ifndef __INTEL_COMPILER
1467 #error Not icc
1468 #endif
1469 ],
1470 bakefile_cv_prog_icc=yes,
1471 bakefile_cv_prog_icc=no
1472 )
1473 ])
1474 if test "$bakefile_cv_prog_icc" = "yes"; then
1475 PIC_FLAG="-KPIC"
1476 fi
1477 fi
1478 ;;
1479
1480 *-*-solaris2* )
1481 if test "x$GCC" != xyes ; then
1482 SHARED_LD_CC="${CC} -G -o"
1483 SHARED_LD_CXX="${CXX} -G -o"
1484 PIC_FLAG="-KPIC"
1485 fi
1486 ;;
1487
1488 *-*-darwin* )
1489 dnl For Unix to MacOS X porting instructions, see:
1490 dnl http://fink.sourceforge.net/doc/porting/porting.html
1491 CFLAGS="$CFLAGS -fno-common"
1492 CXXFLAGS="$CXXFLAGS -fno-common"
1493
1494 dnl Most apps benefit from being fully binded (its faster and static
1495 dnl variables initialized at startup work).
1496 dnl This can be done either with the exe linker flag -Wl,-bind_at_load
1497 dnl or with a double stage link in order to create a single module
1498 dnl "-init _wxWindowsDylibInit" not useful with lazy linking solved
1499
1500 dnl If using newer dev tools then there is a -single_module flag that
1501 dnl we can use to do this, otherwise we'll need to use a helper
1502 dnl script. Check the version of gcc to see which way we can go:
1503 AC_CACHE_CHECK([for gcc 3.1 or later], wx_cv_gcc31, [
1504 AC_TRY_COMPILE([],
1505 [
1506 #if (__GNUC__ < 3) || \
1507 ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1))
1508 #error old gcc
1509 #endif
1510 ],
1511 [
1512 wx_cv_gcc31=yes
1513 ],
1514 [
1515 wx_cv_gcc31=no
1516 ]
1517 )
1518 ])
1519 if test "$wx_cv_gcc31" = "no"; then
1520 cat <<EOF >shared-ld-sh
1521 #!/bin/sh
1522 #-----------------------------------------------------------------------------
1523 #-- Name: distrib/mac/shared-ld-sh
1524 #-- Purpose: Link a mach-o dynamic shared library for Darwin / Mac OS X
1525 #-- Author: Gilles Depeyrot
1526 #-- Copyright: (c) 2002 Gilles Depeyrot
1527 #-- Licence: any use permitted
1528 #-----------------------------------------------------------------------------
1529
1530 verbose=0
1531 args=""
1532 objects=""
1533 linking_flag="-dynamiclib"
1534
1535 while test \${#} -gt 0; do
1536 case \${1} in
1537
1538 -v)
1539 verbose=1
1540 ;;
1541
1542 -o|-compatibility_version|-current_version|-framework|-undefined|-install_name)
1543 # collect these options and values
1544 args="\${args} \${1} \${2}"
1545 shift
1546 ;;
1547
1548 -l*|-L*|-flat_namespace|-headerpad_max_install_names)
1549 # collect these options
1550 args="\${args} \${1}"
1551 ;;
1552
1553 -dynamiclib|-bundle)
1554 linking_flag="\${1}"
1555 ;;
1556
1557 -*)
1558 echo "shared-ld: unhandled option '\${1}'"
1559 exit 1
1560 ;;
1561
1562 *.o | *.a | *.dylib)
1563 # collect object files
1564 objects="\${objects} \${1}"
1565 ;;
1566
1567 *)
1568 echo "shared-ld: unhandled argument '\${1}'"
1569 exit 1
1570 ;;
1571
1572 esac
1573 shift
1574 done
1575
1576 #
1577 # Link one module containing all the others
1578 #
1579 if test \${verbose} = 1; then
1580 echo "c++ -r -keep_private_externs -nostdlib \${objects} -o master.\$\$.o"
1581 fi
1582 c++ -r -keep_private_externs -nostdlib \${objects} -o master.\$\$.o
1583 status=\$?
1584 if test \${status} != 0; then
1585 exit \${status}
1586 fi
1587
1588 #
1589 # Link the shared library from the single module created
1590 #
1591 if test \${verbose} = 1; then
1592 echo "cc \${linking_flag} master.\$\$.o \${args}"
1593 fi
1594 c++ \${linking_flag} master.\$\$.o \${args}
1595 status=\$?
1596 if test \${status} != 0; then
1597 exit \${status}
1598 fi
1599
1600 #
1601 # Remove intermediate module
1602 #
1603 rm -f master.\$\$.o
1604
1605 exit 0
1606 EOF
1607 chmod +x shared-ld-sh
1608
1609 dnl Use the shared-ld-sh helper script
1610 SHARED_LD_CC="`pwd`/shared-ld-sh -dynamiclib -headerpad_max_install_names -o"
1611 SHARED_LD_MODULE_CC="`pwd`/shared-ld-sh -bundle -headerpad_max_install_names -o"
1612 SHARED_LD_CXX="$SHARED_LD_CC"
1613 SHARED_LD_MODULE_CXX="$SHARED_LD_MODULE_CC"
1614 else
1615 dnl Use the -single_module flag and let the linker do it for us
1616 SHARED_LD_CC="\${CC} -dynamiclib -single_module -headerpad_max_install_names -o"
1617 SHARED_LD_MODULE_CC="\${CC} -bundle -single_module -headerpad_max_install_names -o"
1618 SHARED_LD_CXX="\${CXX} -dynamiclib -single_module -headerpad_max_install_names -o"
1619 SHARED_LD_MODULE_CXX="\${CXX} -bundle -single_module -headerpad_max_install_names -o"
1620 fi
1621
1622 PIC_FLAG="-dynamic -fPIC"
1623 ;;
1624
1625 *-*-aix* )
1626 dnl default settings are ok for gcc
1627 if test "x$GCC" != "xyes"; then
1628 dnl the abs path below used to be hardcoded here so I guess it must
1629 dnl be some sort of standard location under AIX?
1630 AC_CHECK_PROG(AIX_CXX_LD, makeC++SharedLib,
1631 makeC++SharedLib, /usr/lpp/xlC/bin/makeC++SharedLib)
1632 dnl FIXME - what about makeCSharedLib?
1633 SHARED_LD_CC="$AIX_CC_LD -p 0 -o"
1634 SHARED_LD_CXX="$AIX_CXX_LD -p 0 -o"
1635 fi
1636 ;;
1637
1638 *-*-beos* )
1639 dnl can't use gcc under BeOS for shared library creation because it
1640 dnl complains about missing 'main'
1641 SHARED_LD_CC="${LD} -shared -o"
1642 SHARED_LD_CXX="${LD} -shared -o"
1643 ;;
1644
1645 *-*-irix* )
1646 dnl default settings are ok for gcc
1647 if test "x$GCC" != "xyes"; then
1648 PIC_FLAG="-KPIC"
1649 fi
1650 ;;
1651
1652 *-*-cygwin* | *-*-mingw32* )
1653 PIC_FLAG=""
1654 ;;
1655
1656 *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | \
1657 *-*-sunos4* | \
1658 *-*-osf* | \
1659 *-*-dgux5* | \
1660 *-pc-os2_emx | *-pc-os2-emx | \
1661 *-*-sysv5* )
1662 dnl defaults are ok
1663 ;;
1664
1665 *)
1666 AC_MSG_ERROR(unknown system type $BAKEFILE_HOST.)
1667 esac
1668
1669 if test "x$SHARED_LD_MODULE_CC" = "x" ; then
1670 SHARED_LD_MODULE_CC="$SHARED_LD_CC"
1671 fi
1672 if test "x$SHARED_LD_MODULE_CXX" = "x" ; then
1673 SHARED_LD_MODULE_CXX="$SHARED_LD_CXX"
1674 fi
1675
1676 AC_SUBST(SHARED_LD_CC)
1677 AC_SUBST(SHARED_LD_CXX)
1678 AC_SUBST(SHARED_LD_MODULE_CC)
1679 AC_SUBST(SHARED_LD_MODULE_CXX)
1680 AC_SUBST(PIC_FLAG)
1681 ])
1682
1683
1684 dnl ---------------------------------------------------------------------------
1685 dnl AC_BAKEFILE_SHARED_VERSIONS
1686 dnl
1687 dnl Detects linker options for attaching versions (sonames) to shared libs.
1688 dnl ---------------------------------------------------------------------------
1689
1690 AC_DEFUN(AC_BAKEFILE_SHARED_VERSIONS,
1691 [
1692 USE_SOVERSION=0
1693 USE_SOVERLINUX=0
1694 USE_SOVERSOLARIS=0
1695 USE_SOSYMLINKS=0
1696 USE_MACVERSION=0
1697 SONAME_FLAG=
1698
1699 case "${BAKEFILE_HOST}" in
1700 *-*-linux* )
1701 SONAME_FLAG="-Wl,-soname,"
1702 USE_SOVERSION=1
1703 USE_SOVERLINUX=1
1704 USE_SOSYMLINKS=1
1705 ;;
1706
1707 *-*-solaris2* )
1708 SONAME_FLAG="-h "
1709 USE_SOVERSION=1
1710 USE_SOVERSOLARIS=1
1711 USE_SOSYMLINKS=1
1712 ;;
1713
1714 *-*-darwin* )
1715 USE_MACVERSION=1
1716 USE_SOVERSION=1
1717 USE_SOSYMLINKS=1
1718 ;;
1719 esac
1720
1721 AC_SUBST(USE_SOVERSION)
1722 AC_SUBST(USE_SOVERLINUX)
1723 AC_SUBST(USE_SOVERSOLARIS)
1724 AC_SUBST(USE_MACVERSION)
1725 AC_SUBST(USE_SOSYMLINKS)
1726 AC_SUBST(SONAME_FLAG)
1727 ])
1728
1729
1730 dnl ---------------------------------------------------------------------------
1731 dnl AC_BAKEFILE_DEPS
1732 dnl
1733 dnl Detects available C/C++ dependency tracking options
1734 dnl ---------------------------------------------------------------------------
1735
1736 AC_DEFUN(AC_BAKEFILE_DEPS,
1737 [
1738 AC_MSG_CHECKING([for dependency tracking method])
1739 DEPS_TRACKING=0
1740
1741 if test "x$GCC" = "xyes"; then
1742 DEPSMODE=gcc
1743 DEPS_TRACKING=1
1744 case "${BAKEFILE_HOST}" in
1745 powerpc-*-darwin* )
1746 dnl -cpp-precomp (the default) conflicts with -MMD option
1747 dnl used by bk-deps (see also http://developer.apple.com/documentation/Darwin/Conceptual/PortingUnix/compiling/chapter_4_section_3.html)
1748 DEPSFLAG_GCC="-no-cpp-precomp -MMD"
1749 ;;
1750 * )
1751 DEPSFLAG_GCC="-MMD"
1752 ;;
1753 esac
1754 AC_MSG_RESULT([gcc])
1755 else
1756 AC_MSG_RESULT([none])
1757 fi
1758
1759 if test $DEPS_TRACKING = 1 ; then
1760 cat <<EOF >bk-deps
1761 #!/bin/sh
1762
1763 # This script is part of Bakefile (http://bakefile.sourceforge.net) autoconf
1764 # script. It is used to track C/C++ files dependencies in portable way.
1765 #
1766 # Permission is given to use this file in any way.
1767
1768 DEPSMODE=$DEPSMODE
1769 DEPSDIR=.deps
1770 DEPSFLAG_GCC="$DEPSFLAG_GCC"
1771
1772 mkdir -p \$DEPSDIR
1773
1774 if test \$DEPSMODE = gcc ; then
1775 \${*} \${DEPSFLAG_GCC}
1776 status=\${?}
1777 if test \${status} != 0 ; then
1778 exit \${status}
1779 fi
1780 # move created file to the location we want it in:
1781 while test \${#} -gt 0; do
1782 case "\${1}" in
1783 -o )
1784 shift
1785 objfile=\${1}
1786 ;;
1787 -* )
1788 ;;
1789 * )
1790 srcfile=\${1}
1791 ;;
1792 esac
1793 shift
1794 done
1795 depfile=\`basename \$srcfile | sed -e 's/\..*$/.d/g'\`
1796 depobjname=\`echo \$depfile |sed -e 's/\.d/.o/g'\`
1797 if test -f \$depfile ; then
1798 sed -e "s,\$depobjname:,\$objfile:,g" \$depfile >\${DEPSDIR}/\${objfile}.d
1799 rm -f \$depfile
1800 else
1801 depfile=\`basename \$objfile | sed -e 's/\..*$/.d/g'\`
1802 if test -f \$depfile ; then
1803 sed -e "/^\$objfile/!s,\$depobjname:,\$objfile:,g" \$depfile >\${DEPSDIR}/\${objfile}.d
1804 rm -f \$depfile
1805 fi
1806 fi
1807 exit 0
1808 else
1809 \${*}
1810 exit \${?}
1811 fi
1812 EOF
1813 chmod +x bk-deps
1814 fi
1815
1816 AC_SUBST(DEPS_TRACKING)
1817 ])
1818
1819 dnl ---------------------------------------------------------------------------
1820 dnl AC_BAKEFILE_CHECK_BASIC_STUFF
1821 dnl
1822 dnl Checks for presence of basic programs, such as C and C++ compiler, "ranlib"
1823 dnl or "install"
1824 dnl ---------------------------------------------------------------------------
1825
1826 AC_DEFUN(AC_BAKEFILE_CHECK_BASIC_STUFF,
1827 [
1828 AC_PROG_RANLIB
1829 AC_PROG_INSTALL
1830 AC_PROG_LN_S
1831
1832 AC_PROG_MAKE_SET
1833 AC_SUBST(MAKE_SET)
1834
1835 AC_CHECK_TOOL(AR, ar, ar)
1836 AC_CHECK_TOOL(STRIP, strip, :)
1837 AC_CHECK_TOOL(NM, nm, :)
1838
1839 case ${BAKEFILE_HOST} in
1840 *-hp-hpux* )
1841 INSTALL_DIR="mkdir"
1842 ;;
1843 *) INSTALL_DIR="$INSTALL -d"
1844 ;;
1845 esac
1846 AC_SUBST(INSTALL_DIR)
1847
1848 LDFLAGS_GUI=
1849 case ${BAKEFILE_HOST} in
1850 *-*-cygwin* | *-*-mingw32* )
1851 LDFLAGS_GUI="-Wl,--subsystem,windows -mwindows"
1852 esac
1853 AC_SUBST(LDFLAGS_GUI)
1854 ])
1855
1856
1857 dnl ---------------------------------------------------------------------------
1858 dnl AC_BAKEFILE_RES_COMPILERS
1859 dnl
1860 dnl Checks for presence of resource compilers for win32 or mac
1861 dnl ---------------------------------------------------------------------------
1862
1863 AC_DEFUN(AC_BAKEFILE_RES_COMPILERS,
1864 [
1865 RESCOMP=
1866 SETFILE=
1867
1868 case ${BAKEFILE_HOST} in
1869 *-*-cygwin* | *-*-mingw32* )
1870 dnl Check for win32 resources compiler:
1871 if test "$build" != "$host" ; then
1872 RESCOMP=$host_alias-windres
1873 else
1874 AC_CHECK_PROG(RESCOMP, windres, windres, windres)
1875 fi
1876 ;;
1877
1878 *-*-darwin* )
1879 AC_CHECK_PROG(RESCOMP, Rez, Rez, /Developer/Tools/Rez)
1880 AC_CHECK_PROG(SETFILE, SetFile, SetFile, /Developer/Tools/SetFile)
1881 ;;
1882 esac
1883
1884 AC_SUBST(RESCOMP)
1885 AC_SUBST(SETFILE)
1886 ])
1887
1888 dnl ---------------------------------------------------------------------------
1889 dnl AC_BAKEFILE_PRECOMP_HEADERS
1890 dnl
1891 dnl Check for precompiled headers support (GCC >= 3.4)
1892 dnl ---------------------------------------------------------------------------
1893
1894 AC_DEFUN(AC_BAKEFILE_PRECOMP_HEADERS,
1895 [
1896
1897 AC_ARG_ENABLE([precomp-headers],
1898 [ --disable-precomp-headers don't use precompiled headers even if compiler can],
1899 [bk_use_pch="$enableval"])
1900
1901 GCC_PCH=0
1902
1903 if test "x$bk_use_pch" = "x" -o "x$bk_use_pch" = "xyes" ; then
1904 if test "x$GCC" = "xyes"; then
1905 dnl test if we have gcc-3.4:
1906 AC_MSG_CHECKING([if the compiler supports precompiled headers])
1907 AC_TRY_COMPILE([],
1908 [
1909 #if !defined(__GNUC__) || !defined(__GNUC_MINOR__)
1910 #error "no pch support"
1911 #endif
1912 #if (__GNUC__ < 3)
1913 #error "no pch support"
1914 #endif
1915 #if (__GNUC__ == 3) && \
1916 ((!defined(__APPLE_CC__) && (__GNUC_MINOR__ < 4)) || \
1917 ( defined(__APPLE_CC__) && (__GNUC_MINOR__ < 3)))
1918 #error "no pch support"
1919 #endif
1920 ],
1921 [
1922 AC_MSG_RESULT([yes])
1923 dnl FIXME - this is temporary, till .gch dependencies
1924 dnl are fixed in generated Makefiles
1925 CPPFLAGS="-fpch-deps $CPPFLAGS"
1926 GCC_PCH=1
1927 ],
1928 [
1929 AC_MSG_RESULT([no])
1930 ])
1931 if test $GCC_PCH = 1 ; then
1932 cat <<EOF >bk-make-pch
1933 #!/bin/sh
1934
1935 # This script is part of Bakefile (http://bakefile.sourceforge.net) autoconf
1936 # script. It is used to generated precompiled headers.
1937 #
1938 # Permission is given to use this file in any way.
1939
1940 outfile="\${1}"
1941 header="\${2}"
1942 shift
1943 shift
1944
1945 compiler=
1946 headerfile=
1947 while test \${#} -gt 0; do
1948 case "\${1}" in
1949 -I* )
1950 incdir=\`echo \${1} | sed -e 's/-I\(.*\)/\1/g'\`
1951 if test "x\${headerfile}" = "x" -a -f "\${incdir}/\${header}" ; then
1952 headerfile="\${incdir}/\${header}"
1953 fi
1954 ;;
1955 esac
1956 compiler="\${compiler} \${1}"
1957 shift
1958 done
1959
1960 if test "x\${headerfile}" = "x" ; then
1961 echo "error: can't find header \${header} in include paths" >2
1962 else
1963 if test -f \${outfile} ; then
1964 rm -f \${outfile}
1965 else
1966 mkdir -p \`dirname \${outfile}\`
1967 fi
1968 depsfile=".deps/\`basename \${outfile}\`.d"
1969 mkdir -p .deps
1970 # can do this because gcc is >= 3.4:
1971 \${compiler} -o \${outfile} -MMD -MF "\${depsfile}" "\${headerfile}"
1972 exit \${?}
1973 fi
1974 EOF
1975 chmod +x bk-make-pch
1976 fi
1977 fi
1978 fi
1979
1980 AC_SUBST(GCC_PCH)
1981 ])
1982
1983
1984
1985 dnl ---------------------------------------------------------------------------
1986 dnl AC_BAKEFILE
1987 dnl
1988 dnl To be used in configure.in of any project using Bakefile-generated mks
1989 dnl
1990 dnl Behaviour can be modified by setting following variables:
1991 dnl BAKEFILE_CHECK_BASICS set to "no" if you don't want bakefile to
1992 dnl to perform check for basic tools like ranlib
1993 dnl BAKEFILE_HOST set this to override host detection, defaults
1994 dnl to ${host}
1995 dnl BAKEFILE_FORCE_PLATFORM set to override platform detection
1996 dnl ---------------------------------------------------------------------------
1997
1998 AC_DEFUN(AC_BAKEFILE,
1999 [
2000 if test "x$BAKEFILE_HOST" = "x"; then
2001 BAKEFILE_HOST="${host}"
2002 fi
2003
2004 if test "x$BAKEFILE_CHECK_BASICS" != "xno"; then
2005 AC_BAKEFILE_CHECK_BASIC_STUFF
2006 fi
2007 AC_BAKEFILE_GNUMAKE
2008 AC_BAKEFILE_PLATFORM
2009 AC_BAKEFILE_SUFFIXES
2010 AC_BAKEFILE_SHARED_LD
2011 AC_BAKEFILE_SHARED_VERSIONS
2012 AC_BAKEFILE_DEPS
2013 AC_BAKEFILE_RES_COMPILERS
2014
2015 builtin(include, autoconf_inc.m4)
2016 ])
2017