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