]> git.saurik.com Git - wxWidgets.git/blame - aclocal.m4
configure got corrupted somehow, regenerated
[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
21dnl Version: $Id$
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
104dnl call WX_CPP_NEW_HEADERS(actiof-if-true, action-if-false-or-cross-compiling)
105dnl ---------------------------------------------------------------------------
106
107AC_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
127dnl ---------------------------------------------------------------------------
128dnl WX_CPP_BOOL checks whether the C++ compiler has a built in bool type
129dnl
130dnl call WX_CPP_BOOL - will define HAVE_BOOL if the compiler supports bool
131dnl ---------------------------------------------------------------------------
132
133AC_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
986ecc86
VZ
164dnl ---------------------------------------------------------------------------
165dnl WX_CPP_EXPLICIT checks whether the C++ compiler support the explicit
166dnl keyword and defines HAVE_EXPLICIT if this is the case
167dnl ---------------------------------------------------------------------------
168
169AC_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
b040e242
VS
211dnl ---------------------------------------------------------------------------
212dnl a slightly better AC_C_BIGENDIAN macro which allows cross-compiling
213dnl ---------------------------------------------------------------------------
214
215AC_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.
219AC_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.
224AC_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)])
229if test $ac_cv_c_bigendian = unknown; then
230AC_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])
240fi])
241if 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])
243fi
244if test $ac_cv_c_bigendian = yes; then
245 AC_DEFINE(WORDS_BIGENDIAN)
246fi
247])
248
249dnl ---------------------------------------------------------------------------
250dnl override AC_ARG_ENABLE/WITH to cache the results in .cache file
251dnl ---------------------------------------------------------------------------
252
253AC_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
262AC_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
268dnl this macro checks for a three-valued command line --with argument:
269dnl possible arguments are 'yes', 'no', 'sys', or 'builtin'
270dnl usage: WX_ARG_SYS_WITH(option, helpmessage, variable-name)
271AC_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
318dnl this macro checks for a command line argument and caches the result
319dnl usage: WX_ARG_WITH(option, helpmessage, variable-name)
320AC_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
355dnl like WX_ARG_WITH but uses AC_ARG_ENABLE instead of AC_ARG_WITH
5005acfe 356dnl usage: WX_ARG_ENABLE(option, helpmessage, variable-name, enablestring)
2b5f62a0
VZ
357dnl
358dnl enablestring is a hack and allows to show "checking for --disable-foo"
359dnl message when running configure instead of the default "checking for
360dnl --enable-foo" one whih is useful for the options enabled by default
b040e242
VS
361AC_DEFUN([WX_ARG_ENABLE],
362 [
5005acfe
VZ
363 enablestring=$4
364 AC_MSG_CHECKING([for --${enablestring:-enable}-$1])
b040e242
VS
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
2b5f62a0
VZ
398dnl ===========================================================================
399dnl Linker features test
400dnl ===========================================================================
401
402dnl ---------------------------------------------------------------------------
403dnl WX_VERSIONED_SYMBOLS checks whether the linker can create versioned
404dnl symbols. If it can, sets LDFLAGS_VERSIONING to $CXX flags needed to use
405dnl version script file named versionfile
406dnl
407dnl call WX_VERSIONED_SYMBOLS(versionfile)
408dnl ---------------------------------------------------------------------------
409AC_DEFUN([WX_VERSIONED_SYMBOLS],
410[
411 found_versioning=no
412
b4eecb7e
VS
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
2b5f62a0
VZ
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
b040e242
VS
451
452dnl ===========================================================================
453dnl "3rd party" macros included here because they are not widely available
454dnl ===========================================================================
455
b040e242
VS
456dnl ---------------------------------------------------------------------------
457dnl test for availability of iconv()
458dnl ---------------------------------------------------------------------------
459
b040e242
VS
460dnl From Bruno Haible.
461
462AC_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.])
b7043674 499 AC_CACHE_CHECK([if iconv needs const], wx_cv_func_iconv_const,
b040e242
VS
500 AC_TRY_COMPILE([
501#include <stdlib.h>
502#include <iconv.h>
503extern
504#ifdef __cplusplus
505"C"
506#endif
507#if defined(__STDC__) || defined(__cplusplus)
508size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
509#else
510size_t iconv();
511#endif
b7043674
VZ
512 ],
513 [],
514 wx_cv_func_iconv_const="no",
515 wx_cv_func_iconv_const="yes"
516 )
517 )
518
519 iconv_const=
1c405bb5 520 if test "x$wx_cv_func_iconv_const" = "xyes"; then
b7043674
VZ
521 iconv_const="const"
522 fi
523
524 AC_DEFINE_UNQUOTED(ICONV_CONST, $iconv_const,
b040e242
VS
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
90dd450c
VZ
534dnl ---------------------------------------------------------------------------
535dnl AC_SYS_LARGEFILE (partly based on the code from autoconf 2.5x)
536dnl ---------------------------------------------------------------------------
537
538dnl WX_SYS_LARGEFILE_TEST
539dnl
540dnl NB: original autoconf test was checking if compiler supported 6 bit off_t
541dnl arithmetic properly but this failed miserably with gcc under Linux
542dnl whereas the system still supports 64 bit files, so now simply check
543dnl that off_t is big enough
544define(WX_SYS_LARGEFILE_TEST,
545[typedef struct {
546 unsigned int field: sizeof(off_t) == 8;
547} wxlf;
548])
549
550
551dnl WX_SYS_LARGEFILE_MACRO_VALUE(C-MACRO, VALUE, CACHE-VAR)
552define(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
5a5d3c08 565 wx_largefile=yes
90dd450c
VZ
566 AC_DEFINE_UNQUOTED([$1], [$$3])
567 fi
568])
569
570
571dnl AC_SYS_LARGEFILE
572dnl ----------------
573dnl By default, many hosts won't let programs access large files;
574dnl one must use special compiler options to get large-file access to work.
575dnl For more details about this brain damage please see:
576dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
577AC_DEFUN([AC_SYS_LARGEFILE],
578[AC_ARG_ENABLE(largefile,
579 [ --disable-largefile omit support for large files])
580if test "$enable_largefile" != no; then
581 dnl _FILE_OFFSET_BITS==64 is needed for Linux, Solaris, ...
582 dnl _LARGE_FILES -- for AIX
5a5d3c08 583 wx_largefile=no
90dd450c
VZ
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
5a5d3c08 589 AC_MSG_CHECKING(if large file support is available)
90dd450c
VZ
590 if test "x$wx_largefile" = "xyes"; then
591 AC_DEFINE(HAVE_LARGEFILE_SUPPORT)
592 fi
5a5d3c08 593 AC_MSG_RESULT($wx_largefile)
90dd450c
VZ
594fi
595])
b040e242 596
521196a2
MB
597
598dnl Available from the GNU Autoconf Macro Archive at:
599dnl http://www.gnu.org/software/ac-archive/htmldoc/ac_cxx_const_cast.html
600dnl
601AC_DEFUN([AC_CXX_CONST_CAST],
602[AC_CACHE_CHECK(whether the compiler supports const_cast<>,
603ac_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])
610if test "$ac_cv_cxx_const_cast" = yes; then
611 AC_DEFINE(HAVE_CONST_CAST,,[define if the compiler supports const_cast<>])
612fi
613])
614
9e691f46
VZ
615# Configure paths for GTK+
616# Owen Taylor 1997-2001
b040e242
VS
617
618dnl AM_PATH_GTK_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
9e691f46
VZ
619dnl Test for GTK+, and define GTK_CFLAGS and GTK_LIBS, if gthread is specified in MODULES,
620dnl pass to pkg-config
3f345b47 621dnl
b040e242 622AC_DEFUN(AM_PATH_GTK_2_0,
9e691f46
VZ
623[dnl
624dnl Get the cflags and libraries from pkg-config
3f345b47 625dnl
9e691f46
VZ
626AC_ARG_ENABLE(gtktest, [ --disable-gtktest do not try to compile and run a test GTK+ program],
627 , enable_gtktest=yes)
3f345b47 628
9e691f46 629 pkg_config_args=gtk+-2.0
3f345b47
VZ
630 for module in . $4
631 do
632 case "$module" in
9e691f46
VZ
633 gthread)
634 pkg_config_args="$pkg_config_args gthread-2.0"
3f345b47
VZ
635 ;;
636 esac
637 done
638
9e691f46
VZ
639 no_gtk=""
640
641 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
642
643 if test x$PKG_CONFIG != xno ; then
644 if pkg-config --atleast-pkgconfig-version 0.7 ; then
645 :
646 else
647 echo *** pkg-config too old; version 0.7 or better required.
648 no_gtk=yes
649 PKG_CONFIG=no
650 fi
651 else
652 no_gtk=yes
8168de4c 653 fi
9e691f46
VZ
654
655 min_gtk_version=ifelse([$1], ,2.0.0,$1)
656 AC_MSG_CHECKING(for GTK+ - version >= $min_gtk_version)
657
658 if test x$PKG_CONFIG != xno ; then
659 ## don't try to run the test against uninstalled libtool libs
660 if $PKG_CONFIG --uninstalled $pkg_config_args; then
661 echo "Will use uninstalled version of GTK+ found in PKG_CONFIG_PATH"
662 enable_gtktest=no
663 fi
664
665 if $PKG_CONFIG --atleast-version $min_gtk_version $pkg_config_args; then
666 :
667 else
668 no_gtk=yes
669 fi
8168de4c
VZ
670 fi
671
9e691f46
VZ
672 if test x"$no_gtk" = x ; then
673 GTK_CFLAGS=`$PKG_CONFIG $pkg_config_args --cflags`
674 GTK_LIBS=`$PKG_CONFIG $pkg_config_args --libs`
675 gtk_config_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
3f345b47 676 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
9e691f46 677 gtk_config_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
3f345b47 678 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
9e691f46 679 gtk_config_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
3f345b47
VZ
680 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
681 if test "x$enable_gtktest" = "xyes" ; then
682 ac_save_CFLAGS="$CFLAGS"
683 ac_save_LIBS="$LIBS"
684 CFLAGS="$CFLAGS $GTK_CFLAGS"
685 LIBS="$GTK_LIBS $LIBS"
8168de4c 686dnl
9e691f46
VZ
687dnl Now check if the installed GTK+ is sufficiently new. (Also sanity
688dnl checks the results of pkg-config to some extent)
8168de4c 689dnl
3f345b47
VZ
690 rm -f conf.gtktest
691 AC_TRY_RUN([
8168de4c 692#include <gtk/gtk.h>
8168de4c
VZ
693#include <stdio.h>
694#include <stdlib.h>
695
9e691f46 696int
8168de4c
VZ
697main ()
698{
699 int major, minor, micro;
3f345b47 700 char *tmp_version;
8168de4c 701
3f345b47 702 system ("touch conf.gtktest");
8168de4c 703
3f345b47
VZ
704 /* HP/UX 9 (%@#!) writes to sscanf strings */
705 tmp_version = g_strdup("$min_gtk_version");
706 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
707 printf("%s, bad version string\n", "$min_gtk_version");
8168de4c
VZ
708 exit(1);
709 }
710
3f345b47
VZ
711 if ((gtk_major_version != $gtk_config_major_version) ||
712 (gtk_minor_version != $gtk_config_minor_version) ||
713 (gtk_micro_version != $gtk_config_micro_version))
714 {
9e691f46 715 printf("\n*** 'pkg-config --modversion gtk+-2.0' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
3f345b47
VZ
716 $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
717 gtk_major_version, gtk_minor_version, gtk_micro_version);
9e691f46 718 printf ("*** was found! If pkg-config was correct, then it is best\n");
3f345b47
VZ
719 printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
720 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
721 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
722 printf("*** required on your system.\n");
9e691f46
VZ
723 printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
724 printf("*** to point to the correct configuration files\n");
725 }
3f345b47 726 else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
9e691f46 727 (gtk_minor_version != GTK_MINOR_VERSION) ||
3f345b47
VZ
728 (gtk_micro_version != GTK_MICRO_VERSION))
729 {
730 printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
9e691f46 731 GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
3f345b47 732 printf("*** library (version %d.%d.%d)\n",
9e691f46 733 gtk_major_version, gtk_minor_version, gtk_micro_version);
3f345b47 734 }
3f345b47
VZ
735 else
736 {
737 if ((gtk_major_version > major) ||
738 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
739 ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
740 {
741 return 0;
742 }
743 else
744 {
745 printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
746 gtk_major_version, gtk_minor_version, gtk_micro_version);
747 printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
9e691f46 748 major, minor, micro);
3f345b47
VZ
749 printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
750 printf("***\n");
751 printf("*** If you have already installed a sufficiently new version, this error\n");
9e691f46 752 printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
3f345b47 753 printf("*** being found. The easiest way to fix this is to remove the old version\n");
9e691f46
VZ
754 printf("*** of GTK+, but you can also set the PKG_CONFIG environment to point to the\n");
755 printf("*** correct copy of pkg-config. (In this case, you will have to\n");
3f345b47
VZ
756 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
757 printf("*** so that the correct libraries are found at run-time))\n");
758 }
759 }
760 return 1;
8168de4c
VZ
761}
762],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
3f345b47
VZ
763 CFLAGS="$ac_save_CFLAGS"
764 LIBS="$ac_save_LIBS"
765 fi
8168de4c
VZ
766 fi
767 if test "x$no_gtk" = x ; then
b040e242 768 AC_MSG_RESULT(yes (version $gtk_config_major_version.$gtk_config_minor_version.$gtk_config_micro_version))
9e691f46 769 ifelse([$2], , :, [$2])
8168de4c
VZ
770 else
771 AC_MSG_RESULT(no)
9e691f46
VZ
772 if test "$PKG_CONFIG" = "no" ; then
773 echo "*** A new enough version of pkg-config was not found."
774 echo "*** See http://pkgconfig.sourceforge.net"
3f345b47
VZ
775 else
776 if test -f conf.gtktest ; then
777 :
778 else
9e691f46 779 echo "*** Could not run GTK+ test program, checking why..."
579d8138
VS
780 ac_save_CFLAGS="$CFLAGS"
781 ac_save_LIBS="$LIBS"
3f345b47
VZ
782 CFLAGS="$CFLAGS $GTK_CFLAGS"
783 LIBS="$LIBS $GTK_LIBS"
784 AC_TRY_LINK([
785#include <gtk/gtk.h>
786#include <stdio.h>
787], [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
788 [ echo "*** The test program compiled, but did not run. This usually means"
9e691f46
VZ
789 echo "*** that the run-time linker is not finding GTK+ or finding the wrong"
790 echo "*** version of GTK+. If it is not finding GTK+, you'll need to set your"
3f345b47
VZ
791 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
792 echo "*** to the installed location Also, make sure you have run ldconfig if that"
793 echo "*** is required on your system"
9e691f46 794 echo "***"
3f345b47 795 echo "*** If you have an old version installed, it is best to remove it, although"
9e691f46 796 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
3f345b47 797 [ echo "*** The test program failed to compile or link. See the file config.log for the"
579d8138 798 echo "*** exact error that occured. This usually means GTK+ is incorrectly installed."])
3f345b47
VZ
799 CFLAGS="$ac_save_CFLAGS"
800 LIBS="$ac_save_LIBS"
801 fi
802 fi
8168de4c
VZ
803 GTK_CFLAGS=""
804 GTK_LIBS=""
805 ifelse([$3], , :, [$3])
806 fi
807 AC_SUBST(GTK_CFLAGS)
808 AC_SUBST(GTK_LIBS)
3f345b47 809 rm -f conf.gtktest
8168de4c
VZ
810])
811
b040e242
VS
812# Configure paths for GTK+
813# Owen Taylor 97-11-3
814
815dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
ecc7ceee
OK
816dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
817dnl
b040e242
VS
818AC_DEFUN(AM_PATH_GTK,
819[dnl
820dnl Get the cflags and libraries from the gtk-config script
ecc7ceee
OK
821dnl
822AC_ARG_WITH(gtk-prefix,[ --with-gtk-prefix=PFX Prefix where GTK is installed (optional)],
823 gtk_config_prefix="$withval", gtk_config_prefix="")
824AC_ARG_WITH(gtk-exec-prefix,[ --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)],
825 gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="")
826AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program],
b040e242 827 , enable_gtktest=yes)
ecc7ceee
OK
828
829 for module in . $4
830 do
831 case "$module" in
b040e242 832 gthread)
ecc7ceee
OK
833 gtk_config_args="$gtk_config_args gthread"
834 ;;
835 esac
836 done
837
838 if test x$gtk_config_exec_prefix != x ; then
839 gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix"
b040e242
VS
840 if test x${GTK_CONFIG+set} != xset ; then
841 GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config
ecc7ceee
OK
842 fi
843 fi
844 if test x$gtk_config_prefix != x ; then
845 gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix"
b040e242
VS
846 if test x${GTK_CONFIG+set} != xset ; then
847 GTK_CONFIG=$gtk_config_prefix/bin/gtk-config
ecc7ceee
OK
848 fi
849 fi
850
b040e242
VS
851 AC_PATH_PROG(GTK_CONFIG, gtk-config, no)
852 min_gtk_version=ifelse([$1], ,0.99.7,$1)
ecc7ceee
OK
853 AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
854 no_gtk=""
b040e242 855 if test "$GTK_CONFIG" = "no" ; then
ecc7ceee
OK
856 no_gtk=yes
857 else
b040e242
VS
858 GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags`
859 GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs`
860 gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \
ecc7ceee 861 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
b040e242 862 gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \
ecc7ceee 863 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
b040e242 864 gtk_config_micro_version=`$GTK_CONFIG $gtk_config_args --version | \
ecc7ceee
OK
865 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
866 if test "x$enable_gtktest" = "xyes" ; then
867 ac_save_CFLAGS="$CFLAGS"
868 ac_save_LIBS="$LIBS"
869 CFLAGS="$CFLAGS $GTK_CFLAGS"
870 LIBS="$GTK_LIBS $LIBS"
871dnl
872dnl Now check if the installed GTK is sufficiently new. (Also sanity
b040e242 873dnl checks the results of gtk-config to some extent
ecc7ceee
OK
874dnl
875 rm -f conf.gtktest
876 AC_TRY_RUN([
877#include <gtk/gtk.h>
878#include <stdio.h>
879#include <stdlib.h>
880
b040e242 881int
ecc7ceee
OK
882main ()
883{
884 int major, minor, micro;
885 char *tmp_version;
886
887 system ("touch conf.gtktest");
888
889 /* HP/UX 9 (%@#!) writes to sscanf strings */
890 tmp_version = g_strdup("$min_gtk_version");
891 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
892 printf("%s, bad version string\n", "$min_gtk_version");
893 exit(1);
894 }
895
896 if ((gtk_major_version != $gtk_config_major_version) ||
897 (gtk_minor_version != $gtk_config_minor_version) ||
898 (gtk_micro_version != $gtk_config_micro_version))
899 {
b040e242 900 printf("\n*** 'gtk-config --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
ecc7ceee
OK
901 $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
902 gtk_major_version, gtk_minor_version, gtk_micro_version);
b040e242 903 printf ("*** was found! If gtk-config was correct, then it is best\n");
ecc7ceee
OK
904 printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
905 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
906 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
907 printf("*** required on your system.\n");
b040e242
VS
908 printf("*** If gtk-config was wrong, set the environment variable GTK_CONFIG\n");
909 printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n");
ecc7ceee 910 printf("*** before re-running configure\n");
b040e242 911 }
ecc7ceee
OK
912#if defined (GTK_MAJOR_VERSION) && defined (GTK_MINOR_VERSION) && defined (GTK_MICRO_VERSION)
913 else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
b040e242 914 (gtk_minor_version != GTK_MINOR_VERSION) ||
ecc7ceee
OK
915 (gtk_micro_version != GTK_MICRO_VERSION))
916 {
917 printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
b040e242 918 GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
ecc7ceee 919 printf("*** library (version %d.%d.%d)\n",
b040e242 920 gtk_major_version, gtk_minor_version, gtk_micro_version);
ecc7ceee
OK
921 }
922#endif /* defined (GTK_MAJOR_VERSION) ... */
923 else
924 {
925 if ((gtk_major_version > major) ||
926 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
927 ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
928 {
929 return 0;
930 }
931 else
932 {
933 printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
934 gtk_major_version, gtk_minor_version, gtk_micro_version);
935 printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
b040e242 936 major, minor, micro);
ecc7ceee
OK
937 printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
938 printf("***\n");
939 printf("*** If you have already installed a sufficiently new version, this error\n");
b040e242 940 printf("*** probably means that the wrong copy of the gtk-config shell script is\n");
ecc7ceee 941 printf("*** being found. The easiest way to fix this is to remove the old version\n");
b040e242
VS
942 printf("*** of GTK+, but you can also set the GTK_CONFIG environment to point to the\n");
943 printf("*** correct copy of gtk-config. (In this case, you will have to\n");
ecc7ceee
OK
944 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
945 printf("*** so that the correct libraries are found at run-time))\n");
946 }
947 }
948 return 1;
949}
950],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
951 CFLAGS="$ac_save_CFLAGS"
952 LIBS="$ac_save_LIBS"
953 fi
954 fi
955 if test "x$no_gtk" = x ; then
b040e242
VS
956 AC_MSG_RESULT(yes)
957 ifelse([$2], , :, [$2])
ecc7ceee
OK
958 else
959 AC_MSG_RESULT(no)
b040e242
VS
960 if test "$GTK_CONFIG" = "no" ; then
961 echo "*** The gtk-config script installed by GTK could not be found"
ecc7ceee 962 echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in"
b040e242
VS
963 echo "*** your path, or set the GTK_CONFIG environment variable to the"
964 echo "*** full path to gtk-config."
ecc7ceee
OK
965 else
966 if test -f conf.gtktest ; then
967 :
968 else
969 echo "*** Could not run GTK test program, checking why..."
970 CFLAGS="$CFLAGS $GTK_CFLAGS"
971 LIBS="$LIBS $GTK_LIBS"
972 AC_TRY_LINK([
973#include <gtk/gtk.h>
974#include <stdio.h>
975], [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
976 [ echo "*** The test program compiled, but did not run. This usually means"
977 echo "*** that the run-time linker is not finding GTK or finding the wrong"
978 echo "*** version of GTK. If it is not finding GTK, you'll need to set your"
979 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
980 echo "*** to the installed location Also, make sure you have run ldconfig if that"
981 echo "*** is required on your system"
b040e242 982 echo "***"
ecc7ceee
OK
983 echo "*** If you have an old version installed, it is best to remove it, although"
984 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
985 echo "***"
986 echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
987 echo "*** came with the system with the command"
988 echo "***"
989 echo "*** rpm --erase --nodeps gtk gtk-devel" ],
990 [ echo "*** The test program failed to compile or link. See the file config.log for the"
991 echo "*** exact error that occured. This usually means GTK was incorrectly installed"
992 echo "*** or that you have moved GTK since it was installed. In the latter case, you"
b040e242 993 echo "*** may want to edit the gtk-config script: $GTK_CONFIG" ])
ecc7ceee
OK
994 CFLAGS="$ac_save_CFLAGS"
995 LIBS="$ac_save_LIBS"
996 fi
997 fi
998 GTK_CFLAGS=""
999 GTK_LIBS=""
1000 ifelse([$3], , :, [$3])
1001 fi
1002 AC_SUBST(GTK_CFLAGS)
1003 AC_SUBST(GTK_LIBS)
1004 rm -f conf.gtktest
1005])
8168de4c 1006
2b5f62a0
VZ
1007
1008dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not)
1009dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
1010dnl also defines GSTUFF_PKG_ERRORS on error
1011AC_DEFUN(PKG_CHECK_MODULES, [
1012 succeeded=no
1013
1014 if test -z "$PKG_CONFIG"; then
1015 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
1016 fi
1017
1018 if test "$PKG_CONFIG" = "no" ; then
1019 echo "*** The pkg-config script could not be found. Make sure it is"
1020 echo "*** in your path, or set the PKG_CONFIG environment variable"
1021 echo "*** to the full path to pkg-config."
1022 echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
1023 else
1024 PKG_CONFIG_MIN_VERSION=0.9.0
1025 if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
1026 AC_MSG_CHECKING(for $2)
1027
1028 if $PKG_CONFIG --exists "$2" ; then
1029 AC_MSG_RESULT(yes)
1030 succeeded=yes
1031
1032 AC_MSG_CHECKING($1_CFLAGS)
1033 $1_CFLAGS=`$PKG_CONFIG --cflags "$2"`
1034 AC_MSG_RESULT($$1_CFLAGS)
1035
1036 AC_MSG_CHECKING($1_LIBS)
1037 $1_LIBS=`$PKG_CONFIG --libs "$2"`
1038 AC_MSG_RESULT($$1_LIBS)
1039 else
1040 $1_CFLAGS=""
1041 $1_LIBS=""
1042 ## If we have a custom action on failure, don't print errors, but
1043 ## do set a variable so people can do so.
1044 $1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
1045 ifelse([$4], ,echo $$1_PKG_ERRORS,)
1046 fi
1047
1048 AC_SUBST($1_CFLAGS)
1049 AC_SUBST($1_LIBS)
1050 else
1051 echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
1052 echo "*** See http://www.freedesktop.org/software/pkgconfig"
1053 fi
1054 fi
1055
1056 if test $succeeded = yes; then
1057 ifelse([$3], , :, [$3])
1058 else
1059 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])
1060 fi
1061])
1062
1063
1064
f93ca9fd
VS
1065# Configure paths for SDL
1066# Sam Lantinga 9/21/99
1067# stolen from Manish Singh
1068# stolen back from Frank Belew
1069# stolen from Manish Singh
1070# Shamelessly stolen from Owen Taylor
1071
1072dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
1073dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
1074dnl
1075AC_DEFUN(AM_PATH_SDL,
1076[dnl
1077dnl Get the cflags and libraries from the sdl-config script
1078dnl
1079AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)],
1080 sdl_prefix="$withval", sdl_prefix="")
1081AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
1082 sdl_exec_prefix="$withval", sdl_exec_prefix="")
1083AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program],
1084 , enable_sdltest=yes)
1085
1086 if test x$sdl_exec_prefix != x ; then
1087 sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix"
1088 if test x${SDL_CONFIG+set} != xset ; then
1089 SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
1090 fi
1091 fi
1092 if test x$sdl_prefix != x ; then
1093 sdl_args="$sdl_args --prefix=$sdl_prefix"
1094 if test x${SDL_CONFIG+set} != xset ; then
1095 SDL_CONFIG=$sdl_prefix/bin/sdl-config
1096 fi
1097 fi
1098
1099 AC_REQUIRE([AC_CANONICAL_TARGET])
1100 PATH="$prefix/bin:$prefix/usr/bin:$PATH"
1101 AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH])
1102 min_sdl_version=ifelse([$1], ,0.11.0,$1)
1103 AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
1104 no_sdl=""
1105 if test "$SDL_CONFIG" = "no" ; then
1106 no_sdl=yes
1107 else
1108 SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags`
1109 SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs`
1110
1111 sdl_major_version=`$SDL_CONFIG $sdl_args --version | \
1112 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
1113 sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \
1114 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
1115 sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
1116 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
1117 if test "x$enable_sdltest" = "xyes" ; then
1118 ac_save_CFLAGS="$CFLAGS"
1119 ac_save_LIBS="$LIBS"
1120 CFLAGS="$CFLAGS $SDL_CFLAGS"
1121 LIBS="$LIBS $SDL_LIBS"
1122dnl
1123dnl Now check if the installed SDL is sufficiently new. (Also sanity
1124dnl checks the results of sdl-config to some extent
1125dnl
1126 rm -f conf.sdltest
1127 AC_TRY_RUN([
1128#include <stdio.h>
1129#include <stdlib.h>
1130#include <string.h>
1131#include "SDL.h"
1132
1133char*
1134my_strdup (char *str)
1135{
1136 char *new_str;
1137
1138 if (str)
1139 {
1140 new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
1141 strcpy (new_str, str);
1142 }
1143 else
1144 new_str = NULL;
1145
1146 return new_str;
1147}
1148
1149int main (int argc, char *argv[])
1150{
1151 int major, minor, micro;
1152 char *tmp_version;
1153
1154 /* This hangs on some systems (?)
1155 system ("touch conf.sdltest");
1156 */
1157 { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
1158
1159 /* HP/UX 9 (%@#!) writes to sscanf strings */
1160 tmp_version = my_strdup("$min_sdl_version");
1161 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
1162 printf("%s, bad version string\n", "$min_sdl_version");
1163 exit(1);
1164 }
1165
1166 if (($sdl_major_version > major) ||
1167 (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
1168 (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
1169 {
1170 return 0;
1171 }
1172 else
1173 {
1174 printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
1175 printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
1176 printf("*** best to upgrade to the required version.\n");
1177 printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
1178 printf("*** to point to the correct copy of sdl-config, and remove the file\n");
1179 printf("*** config.cache before re-running configure\n");
1180 return 1;
1181 }
1182}
1183
1184],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
1185 CFLAGS="$ac_save_CFLAGS"
1186 LIBS="$ac_save_LIBS"
1187 fi
1188 fi
1189 if test "x$no_sdl" = x ; then
1190 AC_MSG_RESULT(yes)
1191 ifelse([$2], , :, [$2])
1192 else
1193 AC_MSG_RESULT(no)
1194 if test "$SDL_CONFIG" = "no" ; then
1195 echo "*** The sdl-config script installed by SDL could not be found"
1196 echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
1197 echo "*** your path, or set the SDL_CONFIG environment variable to the"
1198 echo "*** full path to sdl-config."
1199 else
1200 if test -f conf.sdltest ; then
1201 :
1202 else
1203 echo "*** Could not run SDL test program, checking why..."
1204 CFLAGS="$CFLAGS $SDL_CFLAGS"
1205 LIBS="$LIBS $SDL_LIBS"
1206 AC_TRY_LINK([
1207#include <stdio.h>
1208#include "SDL.h"
1209
1210int main(int argc, char *argv[])
1211{ return 0; }
1212#undef main
1213#define main K_and_R_C_main
1214], [ return 0; ],
1215 [ echo "*** The test program compiled, but did not run. This usually means"
1216 echo "*** that the run-time linker is not finding SDL or finding the wrong"
1217 echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
1218 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
1219 echo "*** to the installed location Also, make sure you have run ldconfig if that"
1220 echo "*** is required on your system"
1221 echo "***"
1222 echo "*** If you have an old version installed, it is best to remove it, although"
1223 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
1224 [ echo "*** The test program failed to compile or link. See the file config.log for the"
1225 echo "*** exact error that occured. This usually means SDL was incorrectly installed"
1226 echo "*** or that you have moved SDL since it was installed. In the latter case, you"
1227 echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
1228 CFLAGS="$ac_save_CFLAGS"
1229 LIBS="$ac_save_LIBS"
1230 fi
1231 fi
1232 SDL_CFLAGS=""
1233 SDL_LIBS=""
1234 ifelse([$3], , :, [$3])
1235 fi
1236 AC_SUBST(SDL_CFLAGS)
1237 AC_SUBST(SDL_LIBS)
1238 rm -f conf.sdltest
1239])
1240
fe0895cf
VS
1241dnl ---------------------------------------------------------------------------
1242dnl Support macros for makefiles generated by BAKEFILE.
1243dnl ---------------------------------------------------------------------------
1244
1245dnl Lots of compiler & linker detection code contained here was taken from
1246dnl wxWindows configure.in script (see http://www.wxwindows.org)
1247
1248
1249
1250dnl ---------------------------------------------------------------------------
1251dnl AC_BAKEFILE_GNUMAKE
1252dnl
1253dnl Detects GNU make
1254dnl ---------------------------------------------------------------------------
1255
1256AC_DEFUN(AC_BAKEFILE_GNUMAKE,
1257[
1258 dnl does make support "-include" (only GNU make does AFAIK)?
49b0a3aa 1259 AC_CACHE_CHECK([if make is GNU make], bakefile_cv_prog_makeisgnu,
fe0895cf
VS
1260 [
1261 if ( ${SHELL-sh} -c "${MAKE-make} --version" 2> /dev/null |
1262 egrep -s GNU > /dev/null); then
1263 bakefile_cv_prog_makeisgnu="yes"
1264 else
1265 bakefile_cv_prog_makeisgnu="no"
1266 fi
1267 ])
1268
1269 if test "x$bakefile_cv_prog_makeisgnu" = "xyes"; then
1270 IF_GNU_MAKE=""
1271 else
1272 IF_GNU_MAKE="#"
1273 fi
1274 AC_SUBST(IF_GNU_MAKE)
1275])
1276
1277dnl ---------------------------------------------------------------------------
1278dnl AC_BAKEFILE_PLATFORM
1279dnl
1280dnl Detects platform and sets PLATFORM_XXX variables accordingly
1281dnl ---------------------------------------------------------------------------
1282
1283AC_DEFUN(AC_BAKEFILE_PLATFORM,
1284[
1285 PLATFORM_UNIX=0
1286 PLATFORM_WIN32=0
1287 PLATFORM_MSDOS=0
1288 PLATFORM_MAC=0
1289 PLATFORM_MACOSX=0
96c1699d 1290 PLATFORM_OS2=0
f93ca9fd
VS
1291
1292 if test "x$BAKEFILE_FORCE_PLATFORM" = "x"; then
1293 case "${BAKEFILE_HOST}" in
1294 *-*-cygwin* | *-*-mingw32* )
1295 PLATFORM_WIN32=1
1296 ;;
1297 *-pc-msdosdjgpp )
1298 PLATFORM_MSDOS=1
1299 ;;
1300 *-pc-os2_emx | *-pc-os2-emx )
1301 PLATFORM_OS2=1
1302 ;;
1303 powerpc-*-darwin* )
1304 PLATFORM_MAC=1
1305 PLATFORM_MACOSX=1
1306 ;;
1307 * )
1308 PLATFORM_UNIX=1
1309 ;;
1310 esac
1311 else
1312 case "$BAKEFILE_FORCE_PLATFORM" in
1313 win32 )
1314 PLATFORM_WIN32=1
1315 ;;
1316 msdos )
1317 PLATFORM_MSDOS=1
1318 ;;
1319 os2 )
1320 PLATFORM_OS2=1
1321 ;;
1322 darwin )
1323 PLATFORM_MAC=1
1324 PLATFORM_MACOSX=1
1325 ;;
1326 unix )
1327 PLATFORM_UNIX=1
1328 ;;
1329 * )
1330 AC_MSG_ERROR([Unknown platform: $BAKEFILE_FORCE_PLATFORM])
1331 ;;
1332 esac
1333 fi
fe0895cf
VS
1334
1335 AC_SUBST(PLATFORM_UNIX)
1336 AC_SUBST(PLATFORM_WIN32)
1337 AC_SUBST(PLATFORM_MSDOS)
1338 AC_SUBST(PLATFORM_MAC)
1339 AC_SUBST(PLATFORM_MACOSX)
96c1699d 1340 AC_SUBST(PLATFORM_OS2)
fe0895cf
VS
1341])
1342
1343
1344
1345dnl ---------------------------------------------------------------------------
1346dnl AC_BAKEFILE_SUFFIXES
1347dnl
1348dnl Detects shared various suffixes for shared libraries, libraries, programs,
1349dnl plugins etc.
1350dnl ---------------------------------------------------------------------------
1351
1352AC_DEFUN(AC_BAKEFILE_SUFFIXES,
1353[
1354 SO_SUFFIX="so"
131f235d 1355 SO_SUFFIX_MODULE="so"
fe0895cf 1356 EXEEXT=""
4b1f6360 1357 LIBPREFIX=lib
fe0895cf 1358 DLLPREFIX=lib
131f235d 1359 DLLPREFIX_MODULE=
fe0895cf 1360
f93ca9fd 1361 case "${BAKEFILE_HOST}" in
fe0895cf
VS
1362 *-hp-hpux* )
1363 SO_SUFFIX="sl"
131f235d 1364 SO_SUFFIX_MODULE="sl"
fe0895cf
VS
1365 ;;
1366 *-*-aix* )
1367 dnl quoting from
1368 dnl http://www-1.ibm.com/servers/esdd/articles/gnu.html:
1369 dnl Both archive libraries and shared libraries on AIX have an
1370 dnl .a extension. This will explain why you can't link with an
1371 dnl .so and why it works with the name changed to .a.
1372 SO_SUFFIX="a"
131f235d 1373 SO_SUFFIX_MODULE="a"
fe0895cf
VS
1374 ;;
1375 *-*-cygwin* | *-*-mingw32* )
1376 SO_SUFFIX="dll"
131f235d 1377 SO_SUFFIX_MODULE="dll"
fe0895cf
VS
1378 EXEEXT=".exe"
1379 DLLPREFIX=""
1380 ;;
4b1f6360
VS
1381 *-pc-msdosdjgpp )
1382 EXEEXT=".exe"
1383 DLLPREFIX=""
1384 ;;
1385 *-pc-os2_emx | *-pc-os2-emx )
fe0895cf
VS
1386 EXEEXT=".exe"
1387 DLLPREFIX=""
4b1f6360 1388 LIBPREFIX=""
fe0895cf
VS
1389 ;;
1390 powerpc-*-darwin* )
1391 SO_SUFFIX="dylib"
131f235d 1392 SO_SUFFIX_MODULE="bundle"
fe0895cf
VS
1393 ;;
1394 esac
1395
1396 AC_SUBST(SO_SUFFIX)
131f235d 1397 AC_SUBST(SO_SUFFIX_MODULE)
fe0895cf 1398 AC_SUBST(EXEEXT)
4b1f6360 1399 AC_SUBST(LIBPREFIX)
fe0895cf 1400 AC_SUBST(DLLPREFIX)
131f235d 1401 AC_SUBST(DLLPREFIX_MODULE)
fe0895cf
VS
1402])
1403
1404
1405dnl ---------------------------------------------------------------------------
1406dnl AC_BAKEFILE_SHARED_LD
1407dnl
1408dnl Detects command for making shared libraries, substitutes SHARED_LD_CC
1409dnl and SHARED_LD_CXX.
1410dnl ---------------------------------------------------------------------------
1411
1412AC_DEFUN(AC_BAKEFILE_SHARED_LD,
1413[
1414 dnl Defaults for GCC and ELF .so shared libs:
1415 SHARED_LD_CC="\$(CC) -shared -o"
1416 SHARED_LD_CXX="\$(CXX) -shared -o"
1417
1418 dnl the extra compiler flags needed for compilation of shared library
1419 if test "x$GCC" = "xyes"; then
1420 dnl the switch for gcc is the same under all platforms
1421 PIC_FLAG="-fPIC"
1422 fi
1423
f93ca9fd 1424 case "${BAKEFILE_HOST}" in
fe0895cf
VS
1425 *-hp-hpux* )
1426 dnl default settings are good for gcc but not for the native HP-UX
1427 if test "x$GCC" = "xyes"; then
1428 dnl -o flag must be after PIC flag
1429 SHARED_LD_CC="${CC} -shared ${PIC_FLAG} -o"
1430 SHARED_LD_CXX="${CXX} -shared ${PIC_FLAG} -o"
1431 else
1432 dnl no idea why it wants it, but it does
1433 LDFLAGS="$LDFLAGS -L/usr/lib"
1434
1435 SHARED_LD_CC="${CC} -b -o"
1436 SHARED_LD_CXX="${CXX} -b -o"
1437 PIC_FLAG="+Z"
1438 fi
1439 ;;
1440
1441 *-*-linux* )
1442 if test "x$GCC" != "xyes"; then
1443 AC_CACHE_CHECK([for Intel compiler], bakefile_cv_prog_icc,
1444 [
1445 AC_TRY_COMPILE([],
1446 [
1447 #ifndef __INTEL_COMPILER
1448 #error Not icc
1449 #endif
1450 ],
1451 bakefile_cv_prog_icc=yes,
1452 bakefile_cv_prog_icc=no
1453 )
1454 ])
1455 if test "$bakefile_cv_prog_icc" = "yes"; then
1456 PIC_FLAG="-KPIC"
1457 fi
1458 fi
1459 ;;
1460
1461 *-*-solaris2* )
1462 if test "x$GCC" != xyes ; then
1463 SHARED_LD_CC="${CC} -G -o"
1464 SHARED_LD_CXX="${CXX} -G -o"
1465 PIC_FLAG="-KPIC"
1466 fi
1467 ;;
1468
1469 *-*-darwin* )
1470 dnl For Unix to MacOS X porting instructions, see:
1471 dnl http://fink.sourceforge.net/doc/porting/porting.html
1472 CFLAGS="$CFLAGS -fno-common"
1473 CXXFLAGS="$CXXFLAGS -fno-common"
1474
1475 dnl Most apps benefit from being fully binded (its faster and static
1476 dnl variables initialized at startup work).
1477 dnl This can be done either with the exe linker flag -Wl,-bind_at_load
1478 dnl or with a double stage link in order to create a single module
1479 dnl "-init _wxWindowsDylibInit" not useful with lazy linking solved
1480
2a879853
VS
1481 dnl If using newer dev tools then there is a -single_module flag that
1482 dnl we can use to do this, otherwise we'll need to use a helper
1483 dnl script. Check the version of gcc to see which way we can go:
1484 AC_CACHE_CHECK([for gcc 3.1 or later], wx_cv_gcc31, [
1485 AC_TRY_COMPILE([],
1486 [
1487 #if (__GNUC__ < 3) || \
1488 ((__GNUC__ == 3) && (__GNUC_MINOR__ < 1))
1489 #error old gcc
1490 #endif
1491 ],
1492 [
1493 wx_cv_gcc31=yes
1494 ],
1495 [
1496 wx_cv_gcc31=no
1497 ]
1498 )
1499 ])
1500 if test "$wx_cv_gcc31" = "no"; then
43948499 1501 cat <<EOF >shared-ld-sh
fe0895cf
VS
1502#!/bin/sh
1503#-----------------------------------------------------------------------------
1504#-- Name: distrib/mac/shared-ld-sh
1505#-- Purpose: Link a mach-o dynamic shared library for Darwin / Mac OS X
1506#-- Author: Gilles Depeyrot
1507#-- Copyright: (c) 2002 Gilles Depeyrot
1508#-- Licence: any use permitted
1509#-----------------------------------------------------------------------------
1510
1511verbose=0
1512args=""
1513objects=""
131f235d 1514linking_flag="-dynamiclib"
fe0895cf
VS
1515
1516while test \${#} -gt 0; do
1517 case \${1} in
1518
1519 -v)
1520 verbose=1
1521 ;;
1522
1523 -o|-compatibility_version|-current_version|-framework|-undefined|-install_name)
1524 # collect these options and values
1525 args="\${args} \${1} \${2}"
1526 shift
1527 ;;
1528
d3370310 1529 -l*|-L*|-flat_namespace|-headerpad_max_install_names)
fe0895cf
VS
1530 # collect these options
1531 args="\${args} \${1}"
1532 ;;
1533
131f235d
VS
1534 -dynamiclib|-bundle)
1535 linking_flag="\${1}"
fe0895cf
VS
1536 ;;
1537
1538 -*)
1539 echo "shared-ld: unhandled option '\${1}'"
1540 exit 1
1541 ;;
1542
4d264332 1543 *.o | *.a | *.dylib)
fe0895cf
VS
1544 # collect object files
1545 objects="\${objects} \${1}"
1546 ;;
1547
1548 *)
1549 echo "shared-ld: unhandled argument '\${1}'"
1550 exit 1
1551 ;;
1552
1553 esac
1554 shift
1555done
1556
1557#
1558# Link one module containing all the others
1559#
1560if test \${verbose} = 1; then
1561 echo "c++ -r -keep_private_externs -nostdlib \${objects} -o master.\$\$.o"
1562fi
1563c++ -r -keep_private_externs -nostdlib \${objects} -o master.\$\$.o
1564status=\$?
1565if test \${status} != 0; then
1566 exit \${status}
1567fi
1568
1569#
1570# Link the shared library from the single module created
1571#
1572if test \${verbose} = 1; then
2a879853 1573 echo "cc \${linking_flag} master.\$\$.o \${args}"
fe0895cf 1574fi
131f235d 1575c++ \${linking_flag} master.\$\$.o \${args}
fe0895cf
VS
1576status=\$?
1577if test \${status} != 0; then
1578 exit \${status}
1579fi
1580
1581#
1582# Remove intermediate module
1583#
1584rm -f master.\$\$.o
1585
1586exit 0
1587EOF
43948499
RD
1588 chmod +x shared-ld-sh
1589
2a879853 1590 dnl Use the shared-ld-sh helper script
7f523214
VS
1591 SHARED_LD_CC="`pwd`/shared-ld-sh -dynamiclib -headerpad_max_install_names -o"
1592 SHARED_LD_MODULE_CC="`pwd`/shared-ld-sh -bundle -headerpad_max_install_names -o"
2a879853
VS
1593 SHARED_LD_CXX="$SHARED_LD_CC"
1594 SHARED_LD_MODULE_CXX="$SHARED_LD_MODULE_CC"
1595 else
1596 dnl Use the -single_module flag and let the linker do it for us
7f523214
VS
1597 SHARED_LD_CC="\${CC} -dynamiclib -single_module -headerpad_max_install_names -o"
1598 SHARED_LD_MODULE_CC="\${CC} -bundle -single_module -headerpad_max_install_names -o"
1599 SHARED_LD_CXX="\${CXX} -dynamiclib -single_module -headerpad_max_install_names -o"
1600 SHARED_LD_MODULE_CXX="\${CXX} -bundle -single_module -headerpad_max_install_names -o"
2a879853
VS
1601 fi
1602
fe0895cf 1603 PIC_FLAG="-dynamic -fPIC"
fe0895cf
VS
1604 ;;
1605
1606 *-*-aix* )
1607 dnl default settings are ok for gcc
1608 if test "x$GCC" != "xyes"; then
1609 dnl the abs path below used to be hardcoded here so I guess it must
1610 dnl be some sort of standard location under AIX?
1611 AC_CHECK_PROG(AIX_CXX_LD, makeC++SharedLib,
1612 makeC++SharedLib, /usr/lpp/xlC/bin/makeC++SharedLib)
1613 dnl FIXME - what about makeCSharedLib?
1614 SHARED_LD_CC="$AIX_CC_LD -p 0 -o"
1615 SHARED_LD_CXX="$AIX_CXX_LD -p 0 -o"
1616 fi
1617 ;;
1618
1619 *-*-beos* )
1620 dnl can't use gcc under BeOS for shared library creation because it
1621 dnl complains about missing 'main'
1622 SHARED_LD_CC="${LD} -shared -o"
1623 SHARED_LD_CXX="${LD} -shared -o"
1624 ;;
1625
1626 *-*-irix* )
1627 dnl default settings are ok for gcc
1628 if test "x$GCC" != "xyes"; then
1629 PIC_FLAG="-KPIC"
1630 fi
1631 ;;
1632
1633 *-*-cygwin* | *-*-mingw32* )
1634 PIC_FLAG=""
1635 ;;
1636
1637 *-*-freebsd* | *-*-openbsd* | *-*-netbsd* | \
1638 *-*-sunos4* | \
1639 *-*-osf* | \
1640 *-*-dgux5* | \
4b1f6360 1641 *-pc-os2_emx | *-pc-os2-emx | \
d5fc095c 1642 *-*-sysv5* )
fe0895cf
VS
1643 dnl defaults are ok
1644 ;;
1645
1646 *)
f93ca9fd 1647 AC_MSG_ERROR(unknown system type $BAKEFILE_HOST.)
fe0895cf
VS
1648 esac
1649
131f235d
VS
1650 if test "x$SHARED_LD_MODULE_CC" = "x" ; then
1651 SHARED_LD_MODULE_CC="$SHARED_LD_CC"
1652 fi
1653 if test "x$SHARED_LD_MODULE_CXX" = "x" ; then
239394fb 1654 SHARED_LD_MODULE_CXX="$SHARED_LD_CXX"
131f235d
VS
1655 fi
1656
fe0895cf
VS
1657 AC_SUBST(SHARED_LD_CC)
1658 AC_SUBST(SHARED_LD_CXX)
131f235d
VS
1659 AC_SUBST(SHARED_LD_MODULE_CC)
1660 AC_SUBST(SHARED_LD_MODULE_CXX)
fe0895cf
VS
1661 AC_SUBST(PIC_FLAG)
1662])
1663
1664
1665dnl ---------------------------------------------------------------------------
1666dnl AC_BAKEFILE_SHARED_VERSIONS
1667dnl
1668dnl Detects linker options for attaching versions (sonames) to shared libs.
1669dnl ---------------------------------------------------------------------------
1670
1671AC_DEFUN(AC_BAKEFILE_SHARED_VERSIONS,
1672[
1673 USE_SOVERSION=0
1674 USE_SOVERLINUX=0
1675 USE_SOVERSOLARIS=0
1676 USE_SOSYMLINKS=0
1677 USE_MACVERSION=0
1678 SONAME_FLAG=
1679
f93ca9fd 1680 case "${BAKEFILE_HOST}" in
fe0895cf
VS
1681 *-*-linux* )
1682 SONAME_FLAG="-Wl,-soname,"
1683 USE_SOVERSION=1
1684 USE_SOVERLINUX=1
1685 USE_SOSYMLINKS=1
1686 ;;
1687
1688 *-*-solaris2* )
1689 SONAME_FLAG="-h "
1690 USE_SOVERSION=1
1691 USE_SOVERSOLARIS=1
1692 USE_SOSYMLINKS=1
1693 ;;
1694
1695 *-*-darwin* )
1696 USE_MACVERSION=1
1697 USE_SOVERSION=1
1698 USE_SOSYMLINKS=1
1699 ;;
1700 esac
1701
1702 AC_SUBST(USE_SOVERSION)
1703 AC_SUBST(USE_SOVERLINUX)
1704 AC_SUBST(USE_SOVERSOLARIS)
1705 AC_SUBST(USE_MACVERSION)
1706 AC_SUBST(USE_SOSYMLINKS)
1707 AC_SUBST(SONAME_FLAG)
1708])
1709
1710
1711dnl ---------------------------------------------------------------------------
1712dnl AC_BAKEFILE_DEPS
1713dnl
1714dnl Detects available C/C++ dependency tracking options
1715dnl ---------------------------------------------------------------------------
1716
1717AC_DEFUN(AC_BAKEFILE_DEPS,
1718[
49b0a3aa
VS
1719 AC_MSG_CHECKING([for dependency tracking method])
1720 DEPS_TRACKING=0
1721
fe0895cf 1722 if test "x$GCC" = "xyes"; then
49b0a3aa
VS
1723 DEPSMODE=gcc
1724 DEPS_TRACKING=1
f93ca9fd 1725 case "${BAKEFILE_HOST}" in
3e5c3c83
VS
1726 powerpc-*-darwin* )
1727 dnl -cpp-precomp (the default) conflicts with -MMD option
1728 dnl used by bk-deps (see also http://developer.apple.com/documentation/Darwin/Conceptual/PortingUnix/compiling/chapter_4_section_3.html)
1729 DEPSFLAG_GCC="-no-cpp-precomp -MMD"
1730 ;;
1731 * )
1732 DEPSFLAG_GCC="-MMD"
1733 ;;
1734 esac
49b0a3aa
VS
1735 AC_MSG_RESULT([gcc])
1736 else
1737 AC_MSG_RESULT([none])
1738 fi
1739
1740 if test $DEPS_TRACKING = 1 ; then
1741 cat <<EOF >bk-deps
1742#!/bin/sh
1743
45842500
VS
1744# This script is part of Bakefile (http://bakefile.sourceforge.net) autoconf
1745# script. It is used to track C/C++ files dependencies in portable way.
49b0a3aa
VS
1746#
1747# Permission is given to use this file in any way.
1748
1749DEPSMODE=$DEPSMODE
1750DEPSDIR=.deps
3e5c3c83 1751DEPSFLAG_GCC="$DEPSFLAG_GCC"
49b0a3aa
VS
1752
1753mkdir -p \$DEPSDIR
1754
1755if test \$DEPSMODE = gcc ; then
3e5c3c83 1756 \${*} \${DEPSFLAG_GCC}
49b0a3aa
VS
1757 status=\${?}
1758 if test \${status} != 0 ; then
1759 exit \${status}
1760 fi
1761 # move created file to the location we want it in:
1762 while test \${#} -gt 0; do
1763 case "\${1}" in
1764 -o )
1765 shift
1766 objfile=\${1}
1767 ;;
1768 -* )
1769 ;;
1770 * )
1771 srcfile=\${1}
1772 ;;
1773 esac
1774 shift
1775 done
1776 depfile=\`basename \$srcfile | sed -e 's/\..*$/.d/g'\`
1777 depobjname=\`echo \$depfile |sed -e 's/\.d/.o/g'\`
6b9d41a5
VS
1778 if test -f \$depfile ; then
1779 sed -e "s,\$depobjname:,\$objfile:,g" \$depfile >\${DEPSDIR}/\${objfile}.d
1780 rm -f \$depfile
1781 else
1782 depfile=\`basename \$objfile | sed -e 's/\..*$/.d/g'\`
1783 if test -f \$depfile ; then
9d0be83a 1784 sed -e "/^\$objfile/!s,\$depobjname:,\$objfile:,g" \$depfile >\${DEPSDIR}/\${objfile}.d
6b9d41a5
VS
1785 rm -f \$depfile
1786 fi
1787 fi
49b0a3aa
VS
1788 exit 0
1789else
1790 \${*}
1791 exit \${?}
1792fi
1793EOF
1794 chmod +x bk-deps
fe0895cf
VS
1795 fi
1796
49b0a3aa 1797 AC_SUBST(DEPS_TRACKING)
fe0895cf
VS
1798])
1799
1800dnl ---------------------------------------------------------------------------
1801dnl AC_BAKEFILE_CHECK_BASIC_STUFF
1802dnl
1803dnl Checks for presence of basic programs, such as C and C++ compiler, "ranlib"
1804dnl or "install"
1805dnl ---------------------------------------------------------------------------
1806
1807AC_DEFUN(AC_BAKEFILE_CHECK_BASIC_STUFF,
1808[
1809 AC_PROG_RANLIB
1810 AC_PROG_INSTALL
1811 AC_PROG_LN_S
1812
1813 AC_PROG_MAKE_SET
1814 AC_SUBST(MAKE_SET)
1815
874d12cf
VS
1816 AC_CHECK_TOOL(AR, ar, ar)
1817 AC_CHECK_TOOL(STRIP, strip, :)
1818 AC_CHECK_TOOL(NM, nm, :)
fe0895cf 1819
f93ca9fd 1820 case ${BAKEFILE_HOST} in
fe0895cf
VS
1821 *-hp-hpux* )
1822 INSTALL_DIR="mkdir"
1823 ;;
1824 *) INSTALL_DIR="$INSTALL -d"
1825 ;;
1826 esac
1827 AC_SUBST(INSTALL_DIR)
6b9d41a5
VS
1828
1829 LDFLAGS_GUI=
f93ca9fd 1830 case ${BAKEFILE_HOST} in
6b9d41a5
VS
1831 *-*-cygwin* | *-*-mingw32* )
1832 LDFLAGS_GUI="-Wl,--subsystem,windows -mwindows"
1833 esac
1834 AC_SUBST(LDFLAGS_GUI)
fe0895cf
VS
1835])
1836
1837
1838dnl ---------------------------------------------------------------------------
1839dnl AC_BAKEFILE_RES_COMPILERS
1840dnl
1841dnl Checks for presence of resource compilers for win32 or mac
1842dnl ---------------------------------------------------------------------------
1843
1844AC_DEFUN(AC_BAKEFILE_RES_COMPILERS,
1845[
1846 RESCOMP=
1847 SETFILE=
1848
f93ca9fd 1849 case ${BAKEFILE_HOST} in
fe0895cf
VS
1850 *-*-cygwin* | *-*-mingw32* )
1851 dnl Check for win32 resources compiler:
1852 if test "$build" != "$host" ; then
1853 RESCOMP=$host_alias-windres
1854 else
1855 AC_CHECK_PROG(RESCOMP, windres, windres, windres)
1856 fi
1857 ;;
1858
1859 *-*-darwin* )
1860 AC_CHECK_PROG(RESCOMP, Rez, Rez, /Developer/Tools/Rez)
1861 AC_CHECK_PROG(SETFILE, SetFile, SetFile, /Developer/Tools/SetFile)
1862 ;;
1863 esac
1864
1865 AC_SUBST(RESCOMP)
1866 AC_SUBST(SETFILE)
1867])
1868
45842500
VS
1869dnl ---------------------------------------------------------------------------
1870dnl AC_BAKEFILE_PRECOMP_HEADERS
1871dnl
1872dnl Check for precompiled headers support (GCC >= 3.4)
1873dnl ---------------------------------------------------------------------------
1874
1875AC_DEFUN(AC_BAKEFILE_PRECOMP_HEADERS,
1876[
1877
1878 AC_ARG_ENABLE([precomp-headers],
1879 [ --disable-precomp-headers don't use precompiled headers even if compiler can],
1880 [bk_use_pch="$enableval"])
1881
1882 GCC_PCH=0
1883
1884 if test "x$bk_use_pch" = "x" -o "x$bk_use_pch" = "xyes" ; then
1885 if test "x$GCC" = "xyes"; then
1886 dnl test if we have gcc-3.4:
1887 AC_MSG_CHECKING([if the compiler supports precompiled headers])
1888 AC_TRY_COMPILE([],
1889 [
e06468e8
VS
1890 #if !defined(__GNUC__) || !defined(__GNUC_MINOR__)
1891 #error "no pch support"
1892 #endif
1893 #if (__GNUC__ < 3)
1894 #error "no pch support"
1895 #endif
1896 #if (__GNUC__ == 3) && \
1897 ((!defined(__APPLE_CC__) && (__GNUC_MINOR__ < 4)) || \
1898 ( defined(__APPLE_CC__) && (__GNUC_MINOR__ < 3)))
1899 #error "no pch support"
45842500
VS
1900 #endif
1901 ],
1902 [
1903 AC_MSG_RESULT([yes])
1904 dnl FIXME - this is temporary, till .gch dependencies
1905 dnl are fixed in generated Makefiles
1906 CPPFLAGS="-fpch-deps $CPPFLAGS"
1907 GCC_PCH=1
1908 ],
1909 [
1910 AC_MSG_RESULT([no])
1911 ])
1912 if test $GCC_PCH = 1 ; then
1913 cat <<EOF >bk-make-pch
1914#!/bin/sh
1915
1916# This script is part of Bakefile (http://bakefile.sourceforge.net) autoconf
1917# script. It is used to generated precompiled headers.
1918#
1919# Permission is given to use this file in any way.
1920
1921outfile="\${1}"
1922header="\${2}"
1923shift
1924shift
1925
1926compiler=
1927headerfile=
1928while test \${#} -gt 0; do
1929 case "\${1}" in
1930 -I* )
1931 incdir=\`echo \${1} | sed -e 's/-I\(.*\)/\1/g'\`
1932 if test "x\${headerfile}" = "x" -a -f "\${incdir}/\${header}" ; then
1933 headerfile="\${incdir}/\${header}"
1934 fi
1935 ;;
1936 esac
1937 compiler="\${compiler} \${1}"
1938 shift
1939done
1940
1941if test "x\${headerfile}" = "x" ; then
1942 echo "error: can't find header \${header} in include paths" >2
1943else
1944 if test -f \${outfile} ; then
1945 rm -f \${outfile}
1946 else
1947 mkdir -p \`dirname \${outfile}\`
1948 fi
1949 depsfile=".deps/\`basename \${outfile}\`.d"
1950 mkdir -p .deps
1951 # can do this because gcc is >= 3.4:
1952 \${compiler} -o \${outfile} -MMD -MF "\${depsfile}" "\${headerfile}"
1953 exit \${?}
1954fi
1955EOF
1956 chmod +x bk-make-pch
1957 fi
1958 fi
1959 fi
1960
1961 AC_SUBST(GCC_PCH)
1962])
1963
1964
1965
fe0895cf
VS
1966dnl ---------------------------------------------------------------------------
1967dnl AC_BAKEFILE
1968dnl
1969dnl To be used in configure.in of any project using Bakefile-generated mks
f93ca9fd
VS
1970dnl
1971dnl Behaviour can be modified by setting following variables:
1972dnl BAKEFILE_CHECK_BASICS set to "no" if you don't want bakefile to
1973dnl to perform check for basic tools like ranlib
1974dnl BAKEFILE_HOST set this to override host detection, defaults
1975dnl to ${host}
1976dnl BAKEFILE_FORCE_PLATFORM set to override platform detection
fe0895cf
VS
1977dnl ---------------------------------------------------------------------------
1978
1979AC_DEFUN(AC_BAKEFILE,
1980[
f93ca9fd
VS
1981 if test "x$BAKEFILE_HOST" = "x"; then
1982 BAKEFILE_HOST="${host}"
1983 fi
1984
fe0895cf
VS
1985 if test "x$BAKEFILE_CHECK_BASICS" != "xno"; then
1986 AC_BAKEFILE_CHECK_BASIC_STUFF
1987 fi
1988 AC_BAKEFILE_GNUMAKE
1989 AC_BAKEFILE_PLATFORM
1990 AC_BAKEFILE_SUFFIXES
1991 AC_BAKEFILE_SHARED_LD
1992 AC_BAKEFILE_SHARED_VERSIONS
1993 AC_BAKEFILE_DEPS
1994 AC_BAKEFILE_RES_COMPILERS
1995
1996 builtin(include, autoconf_inc.m4)
1997])
1998