]> git.mxchange.org Git - simgear.git/blob - acinclude.m4
use correct parameter types for SGText::UpdateCallback
[simgear.git] / acinclude.m4
1 dnl
2 dnl originally from ncftp 2.3.0
3 dnl added wi_EXTRA_PDIR and wi_ANSI_C
4 dnl $Id$
5 dnl
6 AC_DEFUN([wi_EXTRA_IDIR], [
7 incdir="$1"
8 if test -r $incdir ; then
9     already=""
10     for CPPflag in $CPPFLAGS ; do
11         if test  "_$CPPflag" = "_-I${incdir}" ; then 
12             already=yes
13             break
14         fi
15     done
16     if test -n "$already" ; then
17         echo "   + already had -I$incdir" 1>&AS_MESSAGE_LOG_FD
18     else
19         if test "$CPPFLAGS" = "" ; then
20                 CPPFLAGS="-I$incdir"
21         else
22                 CPPFLAGS="$CPPFLAGS -I$incdir"
23         fi
24         echo "   + added -I$incdir" 1>&AS_MESSAGE_LOG_FD
25     fi
26 else 
27     echo "   + IDIR is not accessible: '$myincdir'" 1>&AS_MESSAGE_LOG_FD
28 fi
29 ])
30 dnl
31 dnl
32 dnl
33 dnl
34 AC_DEFUN([wi_EXTRA_LDIR], [
35 mylibdir="$1"
36 if test -r $mylibdir ; then
37     already=""
38     for LDflag in $LDFLAGS ; do
39         if test  "_$LDflag" = "_-L${mylibdir}" ; then 
40             already=yes
41             break
42         fi
43     done
44     if test -n "$already" ; then
45         echo "   + already had -L$mylibdir" 1>&AS_MESSAGE_LOG_FD
46     else
47         if test "$LDFLAGS" = "" ; then
48                 LDFLAGS="-L$mylibdir"
49         else
50                 LDFLAGS="$LDFLAGS -L$mylibdir"
51         fi
52         echo "   + added -L$mylibdir" 1>&AS_MESSAGE_LOG_FD
53     fi
54 else 
55     echo "   + LDIR is not accessible: '$mylibdir'" 1>&AS_MESSAGE_LOG_FD
56 fi
57 ])
58 dnl
59 dnl __FP__
60 dnl
61 dnl
62 AC_DEFUN([wi_EXTRA_PDIR], [
63 progdir="$1"
64 if test -r $progdir ; then
65         case ":$PATH:" in
66                 *:${progdir}:*)
67                         echo "   + already had $progdir in \$PATH" 1>&AS_MESSAGE_LOG_FD
68                         ;;
69                 *)
70                         if test "$PATH" = "" ; then
71                                 PATH="$progdir"
72                         else
73                                 PATH="$PATH:$progdir"
74                         fi
75                         echo "   + appended $progdir to \$PATH" 1>&AS_MESSAGE_LOG_FD
76                         ;;
77         esac
78 else 
79        echo "   + PDIR is not accessible: '$progdir'" 1>&AS_MESSAGE_LOG_FD
80 fi
81 ])
82 dnl
83 dnl
84 dnl If you want to also look for include and lib subdirectories in the
85 dnl $HOME tree, you supply "yes" as the first argument to this macro.
86 dnl
87 dnl If you want to look for subdirectories in include/lib directories,
88 dnl you pass the names in argument 3, otherwise pass a dash.
89 dnl
90 AC_DEFUN([wi_EXTRA_DIRS], [echo "checking for extra include and lib directories..." 1>&6
91 ifelse([$1], yes, [dnl
92 b1=`cd .. ; pwd`
93 b2=`cd ../.. ; pwd`
94 exdirs="$HOME $j $b1 $b2 $prefix $2"
95 ],[dnl
96 exdirs="$prefix $2"
97 ])
98 subexdirs="$3"
99 if test "$subexdirs" = "" ; then
100         subexdirs="-"
101 fi
102 for subexdir in $subexdirs ; do
103     if test "$subexdir" = "-" ; then
104             subexdir=""
105     else
106             subexdir="/$subexdir"
107     fi
108     for exdir in $exdirs ; do
109         if test "$exdir" != "/usr" || test "$subexdir" != ""; then
110             incdir="${exdir}/include${subexdir}"
111             wi_EXTRA_IDIR($incdir)
112
113 dnl On 64-bit machines, if lib64/ exists and is not identical to lib/
114 dnl then it should be listed here, listed ahead of lib/.
115             mylibdir64="${exdir}/lib64${subexdir}"
116             mylibdir32="${exdir}/lib${subexdir}"
117
118             if test "x86_64" = $(uname -m) \
119               -a ! ${mylibdir64} -ef ${mylibdir32} ; then
120                 wi_EXTRA_LDIR($mylibdir64)
121             fi
122
123             wi_EXTRA_LDIR($mylibdir32)
124
125             progdir="${exdir}/bin${subexdir}"
126             wi_EXTRA_PDIR($progdir)
127         fi
128     done
129 done
130 ])
131 dnl
132 dnl
133 dnl
134 AC_DEFUN([wi_HPUX_CFLAGS],
135 [AC_MSG_CHECKING(if HP-UX ansi C compiler flags are needed)
136 AC_REQUIRE([AC_PROG_CC])
137 os=`uname -s | tr '[A-Z]' '[a-z]'`
138 ac_cv_hpux_flags=no
139 if test "$os" = hp-ux ; then
140         if test "$ac_cv_prog_gcc" = yes ; then
141                 if test "$CFLAGS" != "" ; then
142                         # Shouldn't be in there.
143                         CFLAGS=`echo "$CFLAGS" | sed 's/-Aa//g'`
144                 fi
145         else
146                 # If you're not using gcc, then you better have a cc/c89
147                 # that is usable.  If you have the barebones compiler, it
148                 # won't work.  The good compiler uses -Aa for the ANSI
149                 # compatible stuff.
150                 x=`echo $CFLAGS | grep 'Aa' 2>/dev/null`
151                 if test "$x" = "" ; then
152                         CFLAGS="$CFLAGS -Aa"
153                 fi
154                 ac_cv_hpux_flags=yes
155         fi
156         # Also add _HPUX_SOURCE to get the extended namespace.
157         x=`echo $CFLAGS | grep '_HPUX_SOURCE' 2>/dev/null`
158         if test "$x" = "" ; then
159                 CFLAGS="$CFLAGS -D_HPUX_SOURCE"
160         fi
161 fi
162 AC_MSG_RESULT($ac_cv_hpux_flags)
163 ])
164 dnl
165 dnl
166 dnl
167 AC_DEFUN([wi_CFLAGS], [AC_REQUIRE([AC_PROG_CC])
168 wi_HPUX_CFLAGS
169         if test "$CFLAGS" = "" ; then
170                 CFLAGS="-O"
171         elif test "$ac_cv_prog_gcc" = "yes" ; then
172                 case "$CFLAGS" in
173                         *"-g -O"*)
174                                 #echo "using -g as default gcc CFLAGS" 1>&6
175                                 CFLAGS=`echo $CFLAGS | sed 's/-g\ -O/-O/'`
176                                 ;;
177                         *"-O -g"*)
178                                 # Leave the -g, but remove all -O options.
179                                 #echo "using -g as default gcc CFLAGS" 1>&6
180                                 CFLAGS=`echo $CFLAGS | sed 's/-O\ -g/-O/'`
181                                 ;;
182                 esac
183         fi
184 ])
185 dnl
186 dnl
187 dnl
188 AC_DEFUN([wi_PROTOTYPES], [
189 AC_MSG_CHECKING(if the compiler supports function prototypes)
190 AC_TRY_COMPILE(,[extern void exit(int status);],[wi_cv_prototypes=yes
191 AC_DEFINE(PROTOTYPES)],wi_cv_prototypes=no)
192 AC_MSG_RESULT($wi_cv_prototypes)
193 ])
194 dnl
195 dnl
196 dnl
197 AC_DEFUN([wi_ANSI_C], [
198 AC_MSG_CHECKING(ANSI-style function definitions)
199 AC_TRY_COMPILE(,[int blubb(int x) { return 0; }],[wi_cv_ansi_funcs=yes
200 AC_DEFINE(ANSI_FUNCS)],wi_cv_ansi_funcs=no)
201 AC_MSG_RESULT($wi_cv_ansi_funcs)
202 ])
203 dnl
204 dnl
205 dnl
206 AC_DEFUN([wi_HEADER_SYS_SELECT_H], [
207 # See if <sys/select.h> is includable after <sys/time.h>
208 if test "$ac_cv_header_sys_time_h" = no ; then
209 AC_CHECK_HEADERS(sys/time.h sys/select.h)
210 else
211 AC_CHECK_HEADERS(sys/select.h)
212 fi
213 if test "$ac_cv_header_sys_select_h" = yes ; then
214         AC_MSG_CHECKING([if <sys/select.h> is compatible with <sys/time.h>])
215         selecth=yes
216         if test "$ac_cv_header_sys_time_h" = yes ; then
217                 AC_TRY_COMPILE([#include <sys/time.h>
218                 #include <sys/select.h>],[
219                 fd_set a;
220                 struct timeval tmval;
221
222                 tmval.tv_sec = 0;],selecth=yes,selecth=no)
223
224                 if test "$selecth" = yes ; then
225                         AC_DEFINE(CAN_USE_SYS_SELECT_H)
226                 fi
227         fi
228         AC_MSG_RESULT($selecth)
229 fi
230 ])
231 dnl
232 dnl
233 dnl
234 AC_DEFUN([wi_LIB_RESOLV], [
235 # See if we could access two well-known sites without help of any special
236 # libraries, like resolv.
237
238 AC_TRY_RUN([
239 #include <sys/types.h>
240 #include <sys/socket.h>
241 #include <netinet/in.h>
242 #include <netdb.h>
243  
244 main()
245 {
246         struct hostent *hp1, *hp2;
247         int result;
248
249         hp1 = gethostbyname("gatekeeper.dec.com");
250         hp2 = gethostbyname("ftp.ncsa.uiuc.edu");
251         result = ((hp1 != (struct hostent *) 0) && (hp2 != (struct hostent *) 0));
252         exit(! result);
253 }],look_for_resolv=no,look_for_resolv=yes,look_for_resolv=yes)
254
255 AC_MSG_CHECKING([if we need to look for -lresolv])
256 AC_MSG_RESULT($look_for_resolv)
257 if test "$look_for_resolv" = yes ; then
258 AC_CHECK_LIB(resolv,main)
259 else
260         ac_cv_lib_resolv=no
261 fi
262 ])
263 dnl
264 dnl
265 dnl
266
267 AC_DEFUN([wi_LIB_NSL], [
268 AC_MSG_CHECKING(if we can use -lnsl)
269 ac_save_LIBS="$LIBS";
270 LIBS="$LIBS -lnsl";
271 AC_CACHE_VAL(r_cv_use_libnsl, [
272 AC_TRY_RUN(
273 main() { if (getpwuid(getuid())) exit(0); exit(-1); },
274 nc_cv_use_libnsl=yes, nc_cv_use_libnsl=no, nc_cv_use_libnsl=no)
275 ])
276 if test "$nc_cv_use_libnsl" = "no"; then LIBS="$ac_save_LIBS"; fi
277 AC_MSG_RESULT($nc_cv_use_libnsl)
278 ])dnl
279
280 dnl
281 dnl
282 dnl
283
284 AC_DEFUN([nc_PATH_PROG_ZCAT], [
285 AC_PATH_PROG(GZCAT,gzcat)
286 AC_PATH_PROG(ZCAT,zcat)
287 if test "x$GZCAT" = x ; then
288         if test "x$ZCAT" != x ; then
289                 # See if zcat is really gzcat.  gzcat has a --version option, regular
290                 # zcat does not.
291                 AC_MSG_CHECKING(if zcat is really gzcat in disguise)
292                 if $ZCAT --version 2> /dev/null ; then
293                         AC_DEFINE_UNQUOTED(GZCAT, "$ZCAT")
294                         AC_MSG_RESULT(yes)
295                 else
296                         AC_MSG_RESULT(no)
297                 fi
298         fi
299 else
300         AC_DEFINE_UNQUOTED(GZCAT, "$GZCAT")
301 fi
302
303 if test "x$ZCAT" != x ; then
304         AC_DEFINE_UNQUOTED(ZCAT, "$ZCAT")
305 fi
306 ])
307 dnl
308 dnl
309 dnl
310 AC_DEFUN([wi_SYSV_EXTRA_DIRS], [
311 # Use System V because their curses extensions are required.  This must
312 # be done early so we use the -I and -L in the library checks also.
313 # This is mostly a Solaris/SunOS hack.  Note that doing this will also
314 # use all of the other System V libraries and headers.
315
316 AC_MSG_CHECKING(for alternative System V libraries)
317 if test -f /usr/5include/curses.h ; then
318         CPPFLAGS="$CPPFLAGS -I/usr/5include"
319         LDFLAGS="$LDFLAGS -L/usr/5lib"
320         AC_MSG_RESULT(yes)
321 else
322         AC_MSG_RESULT(no)
323 fi
324 ])
325 dnl
326 dnl
327 dnl
328 AC_DEFUN([wi_DEFINE_UNAME], [
329 # Get first 127 chars of all uname information.  Some folks have
330 # way too much stuff there, so grab only the first 127.
331 unam=`uname -a 2>/dev/null | cut -c1-127`
332 if test "$unam" != "" ; then
333         AC_DEFINE_UNQUOTED(UNAME, "$unam")
334 fi
335 ])
336 dnl
337 dnl
338 dnl
339 AC_DEFUN([wi_READLINE_WITH_NCURSES], [
340 # Readline and Ncurses could both define "backspace".
341 # Warn about this if we have both things in our definitions list.
342
343 if test "$ac_cv_lib_readline" = yes && test "$ac_cv_lib_ncurses" = yes ; then
344
345 AC_MSG_CHECKING(if readline and ncurses will link together)
346 j="$LIBS"
347 LIBS="-lreadline -lncurses"
348 AC_TRY_LINK(,[
349 readline("prompt");
350 endwin();
351 ],k=yes,k=no)
352 if test "$k" = no ; then
353         AC_MSG_RESULT(no)
354         # Remove '-lreadline' from LIBS.
355         LIBS=`echo $j | sed s/-lreadline//g`
356         ac_cv_lib_readline=no
357         AC_WARN([The versions of GNU readline and ncurses you have installed on this system
358 can't be used together, because they use the same symbol, backspace. If
359 possible, recompile one of the libraries with -Dbackspace=back_space, then
360 re-run configure.])
361
362 else
363         AC_MSG_RESULT(yes)
364         LIBS="$j"
365 fi
366
367 fi
368 ])
369 dnl
370 dnl
371 dnl
372
373 dnl AC_EXT_DAYLIGHT
374 dnl Check for an external variable daylight. Stolen from w3c-libwww.
375 AC_DEFUN([AC_EXT_DAYLIGHT],
376 [ AC_MSG_CHECKING(int daylight variable)
377 AC_TRY_COMPILE([#include <time.h>], [return daylight;],
378   have_daylight=yes,
379   have_daylight=no)
380 AC_MSG_RESULT($have_daylight)
381 ])dnl
382
383 dnl AC_EXT_TIMEZONE
384 dnl Check for an external variable timezone. Stolen from tcl-8.0.
385 AC_DEFUN([AC_EXT_TIMEZONE],
386 [
387 #
388 # Its important to include time.h in this check, as some systems (like convex)
389 # have timezone functions, etc.
390 #
391 have_timezone=no
392 AC_MSG_CHECKING([long timezone variable])
393 AC_TRY_COMPILE([#include <time.h>],
394         [extern long timezone;
395          timezone += 1;
396          exit (0);],
397         [have_timezone=yes
398          AC_MSG_RESULT(yes)],
399          AC_MSG_RESULT(no))
400
401 #
402 # On some systems (eg IRIX 6.2), timezone is a time_t and not a long.
403 #
404 if test "$have_timezone" = no; then
405    AC_MSG_CHECKING([time_t timezone variable])
406    AC_TRY_COMPILE([#include <time.h>],
407         [extern time_t timezone;
408          timezone += 1;
409          exit (0);],
410         [have_timezone=yes
411          AC_MSG_RESULT(yes)],
412          AC_MSG_RESULT(no))
413 fi
414 ])dnl
415
416 ## AC_BZ_SET_COMPILER: Addition by Theodore Papadopoulo
417 ## Patch by Jim McKelvey: change sed -e 's/ /@/g' to sed -e 's/ /@/'
418 AC_DEFUN([AC_SG_SET_COMPILER],
419   [cxxwith=`echo $1 | sed -e 's/ /@/'`
420    case "$cxxwith" in
421      *:*@*)                 # Full initialization syntax
422        CXX=`echo "$cxxwith" | sed  -n -e 's/.*:\(.*\)@.*/\1/p'`
423        CXXFLAGS=`echo "$cxxwith" | sed  -n -e 's/.*:.*@\(.*\)/\1/p'`
424      ;;
425      *:*)                   # Simple initialization syntax
426        CXX=`echo "$cxxwith" | sed  -n -e 's/.*:\(.*\)/\1/p'`
427        CXXFLAGS=$3
428      ;;
429      *)                     # Default values
430        CXX=$2
431        CXXFLAGS=$3
432        CC="$2 --c"
433 ##       CFLAGS=
434      ;;
435    esac])
436
437 pushdef([AC_PROG_INSTALL],
438 [
439   dnl our own version, testing for a -p flag
440   popdef([AC_PROG_INSTALL])
441   dnl as AC_PROG_INSTALL works as it works we first have
442   dnl to save if the user didn't specify INSTALL, as the
443   dnl autoconf one overwrites INSTALL and we have no chance to find
444   dnl out afterwards
445   AC_PROG_INSTALL
446
447     # OK, user hasn't given any INSTALL, autoconf found one for us
448     # now we test, if it supports the -p flag
449     AC_MSG_CHECKING(for -p flag to install)
450     rm -f confinst.$$.* > /dev/null 2>&1
451     echo "Testtest" > confinst.$$.orig
452     ac_res=no
453     if ${INSTALL} -p confinst.$$.orig confinst.$$.new > /dev/null 2>&1 ; then
454       if test -f confinst.$$.new ; then
455         # OK, -p seems to do no harm to install
456         INSTALL="${INSTALL} -p"
457         ac_res=yes
458       fi
459     fi
460     rm -f confinst.$$.*
461     AC_MSG_RESULT($ac_res)
462   dnl the following tries to resolve some signs and wonders coming up
463   dnl with different autoconf/automake versions
464   dnl e.g.:
465   dnl  *automake 1.4 install-strip sets A_M_INSTALL_PROGRAM_FLAGS to -s
466   dnl   and has INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(A_M_INSTALL_PROGRAM_FLAGS)
467   dnl   it header-vars.am, so there the actual INSTALL_PROGRAM gets the -s
468   dnl  *automake 1.4a (and above) use INSTALL_STRIP_FLAG and only has
469   dnl   INSTALL_PROGRAM = @INSTALL_PROGRAM@ there, but changes the
470   dnl   install-@DIR@PROGRAMS targets to explicitly use that flag
471   dnl  *autoconf 2.13 is dumb, and thinks it can use INSTALL_PROGRAM as
472   dnl   INSTALL_SCRIPT, which breaks with automake <= 1.4
473   dnl  *autoconf >2.13 (since 10.Apr 1999) has not that failure
474   dnl to clean up that mess we:
475   dnl  +set INSTALL_PROGRAM to use INSTALL_STRIP_FLAG
476   dnl   which cleans KDE's program with automake > 1.4;
477   dnl  +set INSTALL_SCRIPT to only use INSTALL, to clean up autoconf's problems
478   dnl   with automake<=1.4
479   dnl  note that dues to this sometimes two '-s' flags are used
480     INSTALL_PROGRAM='${INSTALL} $(INSTALL_STRIP_FLAG)'
481     INSTALL_SCRIPT='${INSTALL}'
482 ])dnl
483
484 # ===========================================================================
485 #             http://autoconf-archive.cryp.to/ax_boost_base.html
486 # ===========================================================================
487 #
488 # SYNOPSIS
489 #
490 #   AX_BOOST_BASE([MINIMUM-VERSION])
491 #
492 # DESCRIPTION
493 #
494 #   Test for the Boost C++ libraries of a particular version (or newer)
495 #
496 #   If no path to the installed boost library is given the macro searchs
497 #   under /usr, /usr/local, /opt and /opt/local and evaluates the
498 #   $BOOST_ROOT environment variable. Further documentation is available at
499 #   <http://randspringer.de/boost/index.html>.
500 #
501 #   This macro calls:
502 #
503 #     AC_SUBST(BOOST_CPPFLAGS) / AC_SUBST(BOOST_LDFLAGS)
504 #
505 #   And sets:
506 #
507 #     HAVE_BOOST
508 #
509 # LAST MODIFICATION
510 #
511 #   2008-04-12
512 #
513 # COPYLEFT
514 #
515 #   Copyright (c) 2008 Thomas Porschberg <thomas@randspringer.de>
516 #
517 #   Copying and distribution of this file, with or without modification, are
518 #   permitted in any medium without royalty provided the copyright notice
519 #   and this notice are preserved.
520
521 AC_DEFUN([AX_BOOST_BASE],
522 [
523 AC_ARG_WITH([boost],
524         AS_HELP_STRING([--with-boost@<:@=DIR@:>@], [use boost (default is yes) - it is possible to specify the root directory for boost (optional)]),
525         [
526     if test "$withval" = "no"; then
527                 want_boost="no"
528     elif test "$withval" = "yes"; then
529         want_boost="yes"
530         ac_boost_path=""
531     else
532             want_boost="yes"
533         ac_boost_path="$withval"
534         fi
535     ],
536     [want_boost="yes"])
537
538
539 AC_ARG_WITH([boost-libdir],
540         AS_HELP_STRING([--with-boost-libdir=LIB_DIR],
541         [Force given directory for boost libraries. Note that this will overwrite library path detection, so use this parameter only if default library detection fails and you know exactly where your boost libraries are located.]),
542         [
543         if test -d $withval
544         then
545                 ac_boost_lib_path="$withval"
546         else
547                 AC_MSG_ERROR(--with-boost-libdir expected directory name)
548         fi
549         ],
550         [ac_boost_lib_path=""]
551 )
552
553 if test "x$want_boost" = "xyes"; then
554         boost_lib_version_req=ifelse([$1], ,1.20.0,$1)
555         boost_lib_version_req_shorten=`expr $boost_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
556         boost_lib_version_req_major=`expr $boost_lib_version_req : '\([[0-9]]*\)'`
557         boost_lib_version_req_minor=`expr $boost_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
558         boost_lib_version_req_sub_minor=`expr $boost_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
559         if test "x$boost_lib_version_req_sub_minor" = "x" ; then
560                 boost_lib_version_req_sub_minor="0"
561         fi
562         WANT_BOOST_VERSION=`expr $boost_lib_version_req_major \* 100000 \+  $boost_lib_version_req_minor \* 100 \+ $boost_lib_version_req_sub_minor`
563         AC_MSG_CHECKING(for boostlib >= $boost_lib_version_req)
564         succeeded=no
565
566         dnl first we check the system location for boost libraries
567         dnl this location ist chosen if boost libraries are installed with the --layout=system option
568         dnl or if you install boost with RPM
569         if test "$ac_boost_path" != ""; then
570                 BOOST_LDFLAGS="-L$ac_boost_path/lib"
571                 BOOST_CPPFLAGS="-I$ac_boost_path/include"
572         else
573                 for ac_boost_path_tmp in /usr /usr/local /opt /opt/local ; do
574                         if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then
575                                 BOOST_LDFLAGS="-L$ac_boost_path_tmp/lib"
576                                 BOOST_CPPFLAGS="-I$ac_boost_path_tmp/include"
577                                 break;
578                         fi
579                 done
580         fi
581
582     dnl overwrite ld flags if we have required special directory with
583     dnl --with-boost-libdir parameter
584     if test "$ac_boost_lib_path" != ""; then
585        BOOST_LDFLAGS="-L$ac_boost_lib_path"
586     fi
587
588         CPPFLAGS_SAVED="$CPPFLAGS"
589         CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
590         export CPPFLAGS
591
592         LDFLAGS_SAVED="$LDFLAGS"
593         LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
594         export LDFLAGS
595
596         AC_LANG_PUSH(C++)
597         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
598         @%:@include <boost/version.hpp>
599         ]], [[
600         #if BOOST_VERSION >= $WANT_BOOST_VERSION
601         // Everything is okay
602         #else
603         #  error Boost version is too old
604         #endif
605         ]])],[
606         AC_MSG_RESULT(yes)
607         succeeded=yes
608         found_system=yes
609         ],[
610         ])
611         AC_LANG_POP([C++])
612
613
614
615         dnl if we found no boost with system layout we search for boost libraries
616         dnl built and installed without the --layout=system option or for a staged(not installed) version
617         if test "x$succeeded" != "xyes"; then
618                 _version=0
619                 if test "$ac_boost_path" != ""; then
620                         if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
621                                 for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
622                                         _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
623                                         V_CHECK=`expr $_version_tmp \> $_version`
624                                         if test "$V_CHECK" = "1" ; then
625                                                 _version=$_version_tmp
626                                         fi
627                                         VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
628                                         BOOST_CPPFLAGS="-I$ac_boost_path/include/boost-$VERSION_UNDERSCORE"
629                                 done
630                         fi
631                 else
632                         for ac_boost_path in /usr /usr/local /opt /opt/local ; do
633                                 if test -d "$ac_boost_path" && test -r "$ac_boost_path"; then
634                                         for i in `ls -d $ac_boost_path/include/boost-* 2>/dev/null`; do
635                                                 _version_tmp=`echo $i | sed "s#$ac_boost_path##" | sed 's/\/include\/boost-//' | sed 's/_/./'`
636                                                 V_CHECK=`expr $_version_tmp \> $_version`
637                                                 if test "$V_CHECK" = "1" ; then
638                                                         _version=$_version_tmp
639                                                         best_path=$ac_boost_path
640                                                 fi
641                                         done
642                                 fi
643                         done
644
645                         VERSION_UNDERSCORE=`echo $_version | sed 's/\./_/'`
646                         BOOST_CPPFLAGS="-I$best_path/include/boost-$VERSION_UNDERSCORE"
647             if test "$ac_boost_lib_path" = ""
648             then
649                BOOST_LDFLAGS="-L$best_path/lib"
650             fi
651
652                         if test "x$BOOST_ROOT" != "x"; then
653                                 if test -d "$BOOST_ROOT" && test -r "$BOOST_ROOT" && test -d "$BOOST_ROOT/stage/lib" && test -r "$BOOST_ROOT/stage/lib"; then
654                                         version_dir=`expr //$BOOST_ROOT : '.*/\(.*\)'`
655                                         stage_version=`echo $version_dir | sed 's/boost_//' | sed 's/_/./g'`
656                                         stage_version_shorten=`expr $stage_version : '\([[0-9]]*\.[[0-9]]*\)'`
657                                         V_CHECK=`expr $stage_version_shorten \>\= $_version`
658                     if test "$V_CHECK" = "1" -a "$ac_boost_lib_path" = "" ; then
659                                                 AC_MSG_NOTICE(We will use a staged boost library from $BOOST_ROOT)
660                                                 BOOST_CPPFLAGS="-I$BOOST_ROOT"
661                                                 BOOST_LDFLAGS="-L$BOOST_ROOT/stage/lib"
662                                         fi
663                                 fi
664                         fi
665                 fi
666
667                 CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
668                 export CPPFLAGS
669                 LDFLAGS="$LDFLAGS $BOOST_LDFLAGS"
670                 export LDFLAGS
671
672                 AC_LANG_PUSH(C++)
673                 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
674                 @%:@include <boost/version.hpp>
675                 ]], [[
676                 #if BOOST_VERSION >= $WANT_BOOST_VERSION
677                 // Everything is okay
678                 #else
679                 #  error Boost version is too old
680                 #endif
681                 ]])],[
682                 AC_MSG_RESULT(yes)
683                 succeeded=yes
684                 found_system=yes
685                 ],[
686                 ])
687                 AC_LANG_POP([C++])
688         fi
689
690         if test "$succeeded" != "yes" ; then
691                 if test "$_version" = "0" ; then
692                         AC_MSG_ERROR([[We could not detect the boost libraries (version $boost_lib_version_req_shorten or higher). If you have a staged boost library (still not installed) please specify \$BOOST_ROOT in your environment and do not give a PATH to --with-boost option.  If you are sure you have boost installed, then check your version number looking in <boost/version.hpp>. See http://randspringer.de/boost for more documentation.]])
693                 else
694                         AC_MSG_ERROR([Your boost libraries seems to old (version $_version).])
695                 fi
696         else
697                 AC_SUBST(BOOST_CPPFLAGS)
698                 AC_SUBST(BOOST_LDFLAGS)
699                 AC_DEFINE(HAVE_BOOST,,[define if the Boost library is available])
700         fi
701
702         CPPFLAGS="$CPPFLAGS_SAVED"
703         LDFLAGS="$LDFLAGS_SAVED"
704 fi
705
706 ])