Tidy up unused source
[bus.git] / origin-src / acinclude.m4
1 # ===========================================================================
2 # http://autoconf-archive.cryp.to/ax_with_prog.html
3 # ===========================================================================
4 #
5 # SYNOPSIS
6 #
7 # AX_WITH_PROG([VARIABLE],[program],[VALUE-IF-NOT-FOUND],[PATH])
8 #
9 # DESCRIPTION
10 #
11 # Locates an installed program binary, placing the result in the precious
12 # variable VARIABLE. Accepts a present VARIABLE, then --with-program, and
13 # failing that searches for program in the given path (which defaults to
14 # the system path). If program is found, VARIABLE is set to the full path
15 # of the binary; if it is not found VARIABLE is set to VALUE-IF-NOT-FOUND
16 # if provided, unchanged otherwise.
17 #
18 # A typical example could be the following one:
19 #
20 # AX_WITH_PROG(PERL,perl)
21 #
22 # NOTE: This macro is based upon the original AX_WITH_PYTHON macro from
23 # Dustin J. Mitchell <dustin@cs.uchicago.edu>.
24 #
25 # LAST MODIFICATION
26 #
27 # 2008-05-05
28 #
29 # COPYLEFT
30 #
31 # Copyright (c) 2008 Francesco Salvestrini <salvestrini@users.sourceforge.net>
32 # Copyright (c) 2008 Dustin J. Mitchell <dustin@cs.uchicago.edu>
33 #
34 # Copying and distribution of this file, with or without modification, are
35 # permitted in any medium without royalty provided the copyright notice
36 # and this notice are preserved.
37
38 AC_DEFUN([AX_WITH_PROG],[
39 AC_PREREQ([2.61])
40
41 pushdef([VARIABLE],$1)
42 pushdef([EXECUTABLE],$2)
43 pushdef([VALUE_IF_NOT_FOUND],$3)
44 pushdef([PATH_PROG],$4)
45
46 AC_ARG_VAR(VARIABLE,Absolute path to EXECUTABLE executable)
47
48 AS_IF(test -z "$VARIABLE",[
49 AC_MSG_CHECKING(whether EXECUTABLE executable path has been provided)
50 AC_ARG_WITH(EXECUTABLE,AS_HELP_STRING([--with-EXECUTABLE=[[[[PATH]]]]],absolute path to EXECUTABLE executable), [
51 AS_IF([test "$withval" != "yes"],[
52 VARIABLE="$withval"
53 AC_MSG_RESULT($VARIABLE)
54 ],[
55 VARIABLE=""
56 AC_MSG_RESULT([no])
57 ])
58 ],[
59 AC_MSG_RESULT([no])
60 ])
61
62 AS_IF(test -z "$VARIABLE",[
63 AC_PATH_PROG([]VARIABLE[],[]EXECUTABLE[],[]VALUE_IF_NOT_FOUND[],[]PATH_PROG[])
64 ])
65 ])
66
67 popdef([PATH_PROG])
68 popdef([VALUE_IF_NOT_FOUND])
69 popdef([EXECUTABLE])
70 popdef([VARIABLE])
71 ])
72
73 # ===========================================================================
74 # http://www.nongnu.org/autoconf-archive/ax_python_devel.html
75 # ===========================================================================
76 #
77 # SYNOPSIS
78 #
79 # AX_PYTHON_DEVEL([version])
80 #
81 # DESCRIPTION
82 #
83 # Note: Defines as a precious variable "PYTHON_VERSION". Don't override it
84 # in your configure.ac.
85 #
86 # This macro checks for Python and tries to get the include path to
87 # 'Python.h'. It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LDFLAGS)
88 # output variables. It also exports $(PYTHON_EXTRA_LIBS) and
89 # $(PYTHON_EXTRA_LDFLAGS) for embedding Python in your code.
90 #
91 # You can search for some particular version of Python by passing a
92 # parameter to this macro, for example ">= '2.3.1'", or "== '2.4'". Please
93 # note that you *have* to pass also an operator along with the version to
94 # match, and pay special attention to the single quotes surrounding the
95 # version number. Don't use "PYTHON_VERSION" for this: that environment
96 # variable is declared as precious and thus reserved for the end-user.
97 #
98 # This macro should work for all versions of Python >= 2.1.0. As an end
99 # user, you can disable the check for the python version by setting the
100 # PYTHON_NOVERSIONCHECK environment variable to something else than the
101 # empty string.
102 #
103 # If you need to use this macro for an older Python version, please
104 # contact the authors. We're always open for feedback.
105 #
106 # LICENSE
107 #
108 # Copyright (c) 2009 Sebastian Huber <sebastian-huber@web.de>
109 # Copyright (c) 2009 Alan W. Irwin <irwin@beluga.phys.uvic.ca>
110 # Copyright (c) 2009 Rafael Laboissiere <rafael@laboissiere.net>
111 # Copyright (c) 2009 Andrew Collier <colliera@ukzn.ac.za>
112 # Copyright (c) 2009 Matteo Settenvini <matteo@member.fsf.org>
113 # Copyright (c) 2009 Horst Knorr <hk_classes@knoda.org>
114 #
115 # This program is free software: you can redistribute it and/or modify it
116 # under the terms of the GNU General Public License as published by the
117 # Free Software Foundation, either version 3 of the License, or (at your
118 # option) any later version.
119 #
120 # This program is distributed in the hope that it will be useful, but
121 # WITHOUT ANY WARRANTY; without even the implied warranty of
122 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
123 # Public License for more details.
124 #
125 # You should have received a copy of the GNU General Public License along
126 # with this program. If not, see <http://www.gnu.org/licenses/>.
127 #
128 # As a special exception, the respective Autoconf Macro's copyright owner
129 # gives unlimited permission to copy, distribute and modify the configure
130 # scripts that are the output of Autoconf when processing the Macro. You
131 # need not follow the terms of the GNU General Public License when using
132 # or distributing such scripts, even though portions of the text of the
133 # Macro appear in them. The GNU General Public License (GPL) does govern
134 # all other use of the material that constitutes the Autoconf Macro.
135 #
136 # This special exception to the GPL applies to versions of the Autoconf
137 # Macro released by the Autoconf Archive. When you make and distribute a
138 # modified version of the Autoconf Macro, you may extend this special
139 # exception to the GPL to apply to your modified version as well.
140
141 AU_ALIAS([AC_PYTHON_DEVEL], [AX_PYTHON_DEVEL])
142 AC_DEFUN([AX_PYTHON_DEVEL],[
143 #
144 # Allow the use of a (user set) custom python version
145 #
146 AC_ARG_VAR([PYTHON_VERSION],[The installed Python
147 version to use, for example '2.3'. This string
148 will be appended to the Python interpreter
149 canonical name.])
150
151 AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]])
152 if test -z "$PYTHON"; then
153 AC_MSG_ERROR([Cannot find python$PYTHON_VERSION in your system path])
154 PYTHON_VERSION=""
155 fi
156
157 #
158 # Check for a version of Python >= 2.1.0
159 #
160 AC_MSG_CHECKING([for a version of Python >= '2.1.0'])
161 ac_supports_python_ver=`$PYTHON -c "import sys; \
162 ver = sys.version.split ()[[0]]; \
163 print (ver >= '2.1.0')"`
164 if test "$ac_supports_python_ver" != "True"; then
165 if test -z "$PYTHON_NOVERSIONCHECK"; then
166 AC_MSG_RESULT([no])
167 AC_MSG_FAILURE([
168 This version of the AC@&t@_PYTHON_DEVEL macro
169 doesn't work properly with versions of Python before
170 2.1.0. You may need to re-run configure, setting the
171 variables PYTHON_CPPFLAGS, PYTHON_LDFLAGS, PYTHON_SITE_PKG,
172 PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand.
173 Moreover, to disable this check, set PYTHON_NOVERSIONCHECK
174 to something else than an empty string.
175 ])
176 else
177 AC_MSG_RESULT([skip at user request])
178 fi
179 else
180 AC_MSG_RESULT([yes])
181 fi
182
183 #
184 # if the macro parameter ``version'' is set, honour it
185 #
186 if test -n "$1"; then
187 AC_MSG_CHECKING([for a version of Python $1])
188 ac_supports_python_ver=`$PYTHON -c "import sys; \
189 ver = sys.version.split ()[[0]]; \
190 print (ver $1)"`
191 if test "$ac_supports_python_ver" = "True"; then
192 AC_MSG_RESULT([yes])
193 else
194 AC_MSG_RESULT([no])
195 AC_MSG_ERROR([this package requires Python $1.
196 If you have it installed, but it isn't the default Python
197 interpreter in your system path, please pass the PYTHON_VERSION
198 variable to configure. See ``configure --help'' for reference.
199 ])
200 PYTHON_VERSION=""
201 fi
202 fi
203
204 #
205 # Check if you have distutils, else fail
206 #
207 AC_MSG_CHECKING([for the distutils Python package])
208 ac_distutils_result=`$PYTHON -c "import distutils" 2>&1`
209 if test -z "$ac_distutils_result"; then
210 AC_MSG_RESULT([yes])
211 else
212 AC_MSG_RESULT([no])
213 AC_MSG_ERROR([cannot import Python module "distutils".
214 Please check your Python installation. The error was:
215 $ac_distutils_result])
216 PYTHON_VERSION=""
217 fi
218
219 #
220 # Check for Python include path
221 #
222 AC_MSG_CHECKING([for Python include path])
223 if test -z "$PYTHON_CPPFLAGS"; then
224 python_path=`$PYTHON -c "import distutils.sysconfig; \
225 print (distutils.sysconfig.get_python_inc ());"`
226 if test -n "${python_path}"; then
227 python_path="-I$python_path"
228 fi
229 PYTHON_CPPFLAGS=$python_path
230 fi
231 AC_MSG_RESULT([$PYTHON_CPPFLAGS])
232 AC_SUBST([PYTHON_CPPFLAGS])
233
234 #
235 # Check for Python library path
236 #
237 AC_MSG_CHECKING([for Python library path])
238 if test -z "$PYTHON_LDFLAGS"; then
239 # (makes two attempts to ensure we've got a version number
240 # from the interpreter)
241 ac_python_version=`cat<<EOD | $PYTHON -
242
243 # join all versioning strings, on some systems
244 # major/minor numbers could be in different list elements
245 from distutils.sysconfig import *
246 ret = ''
247 for e in get_config_vars ('VERSION'):
248 if (e != None):
249 ret += e
250 print (ret)
251 EOD`
252
253 if test -z "$ac_python_version"; then
254 if test -n "$PYTHON_VERSION"; then
255 ac_python_version=$PYTHON_VERSION
256 else
257 ac_python_version=`$PYTHON -c "import sys; \
258 print (sys.version[[:3]])"`
259 fi
260 fi
261
262 # Make the versioning information available to the compiler
263 AC_DEFINE_UNQUOTED([HAVE_PYTHON], ["$ac_python_version"],
264 [If available, contains the Python version number currently in use.])
265
266 # First, the library directory:
267 ac_python_libdir=`cat<<EOD | $PYTHON -
268
269 # There should be only one
270 import distutils.sysconfig
271 for e in distutils.sysconfig.get_config_vars ('LIBDIR'):
272 if e != None:
273 print (e)
274 break
275 EOD`
276
277 # Before checking for libpythonX.Y, we need to know
278 # the extension the OS we're on uses for libraries
279 # (we take the first one, if there's more than one fix me!):
280 ac_python_soext=`$PYTHON -c \
281 "import distutils.sysconfig; \
282 print (distutils.sysconfig.get_config_vars('SO')[[0]])"`
283
284 # Now, for the library:
285 ac_python_soname=`$PYTHON -c \
286 "import distutils.sysconfig; \
287 print (distutils.sysconfig.get_config_vars('LDLIBRARY')[[0]])"`
288
289 # Strip away extension from the end to canonicalize its name:
290 ac_python_library=`echo "$ac_python_soname" | sed "s/${ac_python_soext}$//"`
291
292 # This small piece shamelessly adapted from PostgreSQL python macro;
293 # credits goes to momjian, I think. I'd like to put the right name
294 # in the credits, if someone can point me in the right direction... ?
295 #
296 if test -n "$ac_python_libdir" -a -n "$ac_python_library" \
297 -a x"$ac_python_library" != x"$ac_python_soname"
298 then
299 # use the official shared library
300 ac_python_library=`echo "$ac_python_library" | sed "s/^lib//"`
301 PYTHON_LDFLAGS="-L$ac_python_libdir -l$ac_python_library"
302 else
303 # old way: use libpython from python_configdir
304 ac_python_libdir=`$PYTHON -c \
305 "from distutils.sysconfig import get_python_lib as f; \
306 import os; \
307 print (os.path.join(f(plat_specific=1, standard_lib=1), 'config'));"`
308 PYTHON_LDFLAGS="-L$ac_python_libdir -lpython$ac_python_version"
309 fi
310
311 if test -z "PYTHON_LDFLAGS"; then
312 AC_MSG_ERROR([
313 Cannot determine location of your Python DSO. Please check it was installed with
314 dynamic libraries enabled, or try setting PYTHON_LDFLAGS by hand.
315 ])
316 fi
317 fi
318 AC_MSG_RESULT([$PYTHON_LDFLAGS])
319 AC_SUBST([PYTHON_LDFLAGS])
320
321 #
322 # Check for site packages
323 #
324 AC_MSG_CHECKING([for Python site-packages path])
325 if test -z "$PYTHON_SITE_PKG"; then
326 PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \
327 print (distutils.sysconfig.get_python_lib(0,0));"`
328 fi
329 AC_MSG_RESULT([$PYTHON_SITE_PKG])
330 AC_SUBST([PYTHON_SITE_PKG])
331
332 #
333 # libraries which must be linked in when embedding
334 #
335 AC_MSG_CHECKING(python extra libraries)
336 if test -z "$PYTHON_EXTRA_LIBS"; then
337 PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \
338 conf = distutils.sysconfig.get_config_var; \
339 print (conf('LOCALMODLIBS') + ' ' + conf('LIBS'))"`
340 fi
341 AC_MSG_RESULT([$PYTHON_EXTRA_LIBS])
342 AC_SUBST(PYTHON_EXTRA_LIBS)
343
344 #
345 # linking flags needed when embedding
346 #
347 AC_MSG_CHECKING(python extra linking flags)
348 if test -z "$PYTHON_EXTRA_LDFLAGS"; then
349 PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \
350 conf = distutils.sysconfig.get_config_var; \
351 print (conf('LINKFORSHARED'))"`
352 fi
353 AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS])
354 AC_SUBST(PYTHON_EXTRA_LDFLAGS)
355
356 #
357 # final check to see if everything compiles alright
358 #
359 AC_MSG_CHECKING([consistency of all components of python development environment])
360 # save current global flags
361 ac_save_LIBS="$LIBS"
362 ac_save_CPPFLAGS="$CPPFLAGS"
363 LIBS="$ac_save_LIBS $PYTHON_LDFLAGS $PYTHON_EXTRA_LDFLAGS $PYTHON_EXTRA_LIBS"
364 CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS"
365 AC_LANG_PUSH([C])
366 AC_LINK_IFELSE([
367 AC_LANG_PROGRAM([[#include <Python.h>]],
368 [[Py_Initialize();]])
369 ],[pythonexists=yes],[pythonexists=no])
370 AC_LANG_POP([C])
371 # turn back to default flags
372 CPPFLAGS="$ac_save_CPPFLAGS"
373 LIBS="$ac_save_LIBS"
374
375 AC_MSG_RESULT([$pythonexists])
376
377 if test ! "x$pythonexists" = "xyes"; then
378 AC_MSG_FAILURE([
379 Could not link test program to Python. Maybe the main Python library has been
380 installed in some non-standard library path. If so, pass it to configure,
381 via the LDFLAGS environment variable.
382 Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib"
383 ============================================================================
384 ERROR!
385 You probably have to install the development version of the Python package
386 for your distribution. The exact name of this package varies among them.
387 ============================================================================
388 ])
389 PYTHON_VERSION=""
390 fi
391
392 #
393 # all done!
394 #
395 ])
396
397 # ===========================================================================
398 # http://autoconf-archive.cryp.to/ax_with_ruby.html
399 # ===========================================================================
400 #
401 # SYNOPSIS
402 #
403 # AX_WITH_RUBY([VALUE-IF-NOT-FOUND],[PATH])
404 #
405 # DESCRIPTION
406 #
407 # Locates an installed Ruby binary, placing the result in the precious
408 # variable $RUBY. Accepts a present $RUBY, then --with-ruby, and failing
409 # that searches for ruby in the given path (which defaults to the system
410 # path). If ruby is found, $RUBY is set to the full path of the binary; if
411 # it is not found $RUBY is set to VALUE-IF-NOT-FOUND if provided,
412 # unchanged otherwise.
413 #
414 # A typical use could be the following one:
415 #
416 # AX_WITH_RUBY
417 #
418 # LAST MODIFICATION
419 #
420 # 2008-05-05
421 #
422 # COPYLEFT
423 #
424 # Copyright (c) 2008 Francesco Salvestrini <salvestrini@users.sourceforge.net>
425 #
426 # Copying and distribution of this file, with or without modification, are
427 # permitted in any medium without royalty provided the copyright notice
428 # and this notice are preserved.
429
430 AC_DEFUN([AX_WITH_RUBY],[
431 AX_WITH_PROG(RUBY,ruby,$1,$2)
432 ])
433
434 # ===========================================================================
435 # http://autoconf-archive.cryp.to/ax_compare_version.html
436 # ===========================================================================
437 #
438 # SYNOPSIS
439 #
440 # AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
441 #
442 # DESCRIPTION
443 #
444 # This macro compares two version strings. Due to the various number of
445 # minor-version numbers that can exist, and the fact that string
446 # comparisons are not compatible with numeric comparisons, this is not
447 # necessarily trivial to do in a autoconf script. This macro makes doing
448 # these comparisons easy.
449 #
450 # The six basic comparisons are available, as well as checking equality
451 # limited to a certain number of minor-version levels.
452 #
453 # The operator OP determines what type of comparison to do, and can be one
454 # of:
455 #
456 # eq - equal (test A == B)
457 # ne - not equal (test A != B)
458 # le - less than or equal (test A <= B)
459 # ge - greater than or equal (test A >= B)
460 # lt - less than (test A < B)
461 # gt - greater than (test A > B)
462 #
463 # Additionally, the eq and ne operator can have a number after it to limit
464 # the test to that number of minor versions.
465 #
466 # eq0 - equal up to the length of the shorter version
467 # ne0 - not equal up to the length of the shorter version
468 # eqN - equal up to N sub-version levels
469 # neN - not equal up to N sub-version levels
470 #
471 # When the condition is true, shell commands ACTION-IF-TRUE are run,
472 # otherwise shell commands ACTION-IF-FALSE are run. The environment
473 # variable 'ax_compare_version' is always set to either 'true' or 'false'
474 # as well.
475 #
476 # Examples:
477 #
478 # AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8])
479 # AX_COMPARE_VERSION([3.15],[lt],[3.15.8])
480 #
481 # would both be true.
482 #
483 # AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8])
484 # AX_COMPARE_VERSION([3.15],[gt],[3.15.8])
485 #
486 # would both be false.
487 #
488 # AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8])
489 #
490 # would be true because it is only comparing two minor versions.
491 #
492 # AX_COMPARE_VERSION([3.15.7],[eq0],[3.15])
493 #
494 # would be true because it is only comparing the lesser number of minor
495 # versions of the two values.
496 #
497 # Note: The characters that separate the version numbers do not matter. An
498 # empty string is the same as version 0. OP is evaluated by autoconf, not
499 # configure, so must be a string, not a variable.
500 #
501 # The author would like to acknowledge Guido Draheim whose advice about
502 # the m4_case and m4_ifvaln functions make this macro only include the
503 # portions necessary to perform the specific comparison specified by the
504 # OP argument in the final configure script.
505 #
506 # LAST MODIFICATION
507 #
508 # 2008-04-12
509 #
510 # COPYLEFT
511 #
512 # Copyright (c) 2008 Tim Toolan <toolan@ele.uri.edu>
513 #
514 # Copying and distribution of this file, with or without modification, are
515 # permitted in any medium without royalty provided the copyright notice
516 # and this notice are preserved.
517
518 dnl #########################################################################
519 AC_DEFUN([AX_COMPARE_VERSION], [
520 AC_PROG_AWK
521
522 # Used to indicate true or false condition
523 ax_compare_version=false
524
525 # Convert the two version strings to be compared into a format that
526 # allows a simple string comparison. The end result is that a version
527 # string of the form 1.12.5-r617 will be converted to the form
528 # 0001001200050617. In other words, each number is zero padded to four
529 # digits, and non digits are removed.
530 AS_VAR_PUSHDEF([A],[ax_compare_version_A])
531 A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \
532 -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \
533 -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \
534 -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \
535 -e 's/[[^0-9]]//g'`
536
537 AS_VAR_PUSHDEF([B],[ax_compare_version_B])
538 B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \
539 -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \
540 -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \
541 -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \
542 -e 's/[[^0-9]]//g'`
543
544 dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary
545 dnl # then the first line is used to determine if the condition is true.
546 dnl # The sed right after the echo is to remove any indented white space.
547 m4_case(m4_tolower($2),
548 [lt],[
549 ax_compare_version=`echo "x$A
550 x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"`
551 ],
552 [gt],[
553 ax_compare_version=`echo "x$A
554 x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"`
555 ],
556 [le],[
557 ax_compare_version=`echo "x$A
558 x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"`
559 ],
560 [ge],[
561 ax_compare_version=`echo "x$A
562 x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"`
563 ],[
564 dnl Split the operator from the subversion count if present.
565 m4_bmatch(m4_substr($2,2),
566 [0],[
567 # A count of zero means use the length of the shorter version.
568 # Determine the number of characters in A and B.
569 ax_compare_version_len_A=`echo "$A" | $AWK '{print(length)}'`
570 ax_compare_version_len_B=`echo "$B" | $AWK '{print(length)}'`
571
572 # Set A to no more than B's length and B to no more than A's length.
573 A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"`
574 B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"`
575 ],
576 [[0-9]+],[
577 # A count greater than zero means use only that many subversions
578 A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"`
579 B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"`
580 ],
581 [.+],[
582 AC_WARNING(
583 [illegal OP numeric parameter: $2])
584 ],[])
585
586 # Pad zeros at end of numbers to make same length.
587 ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`"
588 B="$B`echo $A | sed 's/./0/g'`"
589 A="$ax_compare_version_tmp_A"
590
591 # Check for equality or inequality as necessary.
592 m4_case(m4_tolower(m4_substr($2,0,2)),
593 [eq],[
594 test "x$A" = "x$B" && ax_compare_version=true
595 ],
596 [ne],[
597 test "x$A" != "x$B" && ax_compare_version=true
598 ],[
599 AC_WARNING([illegal OP parameter: $2])
600 ])
601 ])
602
603 AS_VAR_POPDEF([A])dnl
604 AS_VAR_POPDEF([B])dnl
605
606 dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE.
607 if test "$ax_compare_version" = "true" ; then
608 m4_ifvaln([$4],[$4],[:])dnl
609 m4_ifvaln([$5],[else $5])dnl
610 fi
611 ]) dnl AX_COMPARE_VERSION
612
613
614 # ===========================================================================
615 # http://autoconf-archive.cryp.to/ax_prog_ruby_version.html
616 # ===========================================================================
617 #
618 # SYNOPSIS
619 #
620 # AX_PROG_RUBY_VERSION([VERSION],[ACTION-IF-TRUE],[ACTION-IF-FALSE])
621 #
622 # DESCRIPTION
623 #
624 # Makes sure that ruby supports the version indicated. If true the shell
625 # commands in ACTION-IF-TRUE are executed. If not the shell commands in
626 # ACTION-IF-FALSE are run. Note if $RUBY is not set (for example by
627 # running AC_CHECK_PROG or AC_PATH_PROG),
628 #
629 # Example:
630 #
631 # AC_PATH_PROG([RUBY],[ruby])
632 # AC_PROG_RUBY_VERSION([1.8.0],[ ... ],[ ... ])
633 #
634 # This will check to make sure that the ruby you have supports at least
635 # version 1.6.0.
636 #
637 # NOTE: This macro uses the $RUBY variable to perform the check.
638 # AX_WITH_RUBY can be used to set that variable prior to running this
639 # macro. The $RUBY_VERSION variable will be valorized with the detected
640 # version.
641 #
642 # LAST MODIFICATION
643 #
644 # 2008-04-12
645 #
646 # COPYLEFT
647 #
648 # Copyright (c) 2008 Francesco Salvestrini <salvestrini@users.sourceforge.net>
649 #
650 # Copying and distribution of this file, with or without modification, are
651 # permitted in any medium without royalty provided the copyright notice
652 # and this notice are preserved.
653
654 AC_DEFUN([AX_PROG_RUBY_VERSION],[
655 AC_REQUIRE([AC_PROG_SED])
656 AC_REQUIRE([AC_PROG_GREP])
657
658 AS_IF([test -n "$RUBY"],[
659 ax_ruby_version="$1"
660
661 AC_MSG_CHECKING([for ruby version])
662 changequote(<<,>>)
663 ruby_version=`$RUBY --version 2>&1 | $GREP "^ruby " | $SED -e 's/^.* \([0-9]*\.[0-9]*\.[0-9]*\) .*/\1/'`
664 changequote([,])
665 AC_MSG_RESULT($ruby_version)
666
667 AC_SUBST([RUBY_VERSION],[$ruby_version])
668
669 AX_COMPARE_VERSION([$ax_ruby_version],[le],[$ruby_version],[
670 :
671 $2
672 ],[
673 :
674 $3
675 ])
676 ],[
677 AC_MSG_WARN([could not find the ruby interpreter])
678 $3
679 ])
680 ])
681
682 # ===========================================================================
683 # http://autoconf-archive.cryp.to/ax_ruby_devel.html
684 # ===========================================================================
685 #
686 # SYNOPSIS
687 #
688 # AX_RUBY_DEVEL([version])
689 #
690 # DESCRIPTION
691 #
692 # This macro checks for Ruby and tries to get the include path to
693 # 'ruby.h'. It provides the $(RUBY_CPPFLAGS) and $(RUBY_LDFLAGS) output
694 # variables. It also exports $(RUBY_EXTRA_LIBS) for embedding Ruby in your
695 # code.
696 #
697 # You can search for some particular version of Ruby by passing a
698 # parameter to this macro, for example "1.8.6".
699 #
700 # LAST MODIFICATION
701 #
702 # 2008-04-12
703 #
704 # COPYLEFT
705 #
706 # Copyright (c) 2008 Rafal Rzepecki <divided.mind@gmail.com>
707 # Copyright (c) 2008 Sebastian Huber <sebastian-huber@web.de>
708 # Copyright (c) 2008 Alan W. Irwin <irwin@beluga.phys.uvic.ca>
709 # Copyright (c) 2008 Rafael Laboissiere <rafael@laboissiere.net>
710 # Copyright (c) 2008 Andrew Collier <colliera@ukzn.ac.za>
711 # Copyright (c) 2008 Matteo Settenvini <matteo@member.fsf.org>
712 # Copyright (c) 2008 Horst Knorr <hk_classes@knoda.org>
713 #
714 # This program is free software: you can redistribute it and/or modify it
715 # under the terms of the GNU General Public License as published by the
716 # Free Software Foundation, either version 3 of the License, or (at your
717 # option) any later version.
718 #
719 # This program is distributed in the hope that it will be useful, but
720 # WITHOUT ANY WARRANTY; without even the implied warranty of
721 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
722 # Public License for more details.
723 #
724 # You should have received a copy of the GNU General Public License along
725 # with this program. If not, see <http://www.gnu.org/licenses/>.
726 #
727 # As a special exception, the respective Autoconf Macro's copyright owner
728 # gives unlimited permission to copy, distribute and modify the configure
729 # scripts that are the output of Autoconf when processing the Macro. You
730 # need not follow the terms of the GNU General Public License when using
731 # or distributing such scripts, even though portions of the text of the
732 # Macro appear in them. The GNU General Public License (GPL) does govern
733 # all other use of the material that constitutes the Autoconf Macro.
734 #
735 # This special exception to the GPL applies to versions of the Autoconf
736 # Macro released by the Autoconf Macro Archive. When you make and
737 # distribute a modified version of the Autoconf Macro, you may extend this
738 # special exception to the GPL to apply to your modified version as well.
739
740 AC_DEFUN([AX_RUBY_DEVEL],[
741 AC_REQUIRE([AX_WITH_RUBY])
742 AS_IF([test -n "$1"], [AX_PROG_RUBY_VERSION([$1])])
743
744 #
745 # Check if you have mkmf, else fail
746 #
747 AC_MSG_CHECKING([for the mkmf Ruby package])
748 ac_mkmf_result=`$RUBY -rmkmf -e ";" 2>&1`
749 if test -z "$ac_mkmf_result"; then
750 AC_MSG_RESULT([yes])
751 else
752 AC_MSG_RESULT([no])
753 AC_MSG_ERROR([cannot import Ruby module "mkmf".
754 Please check your Ruby installation. The error was:
755 $ac_distutils_result])
756 fi
757
758 #
759 # Check for Ruby include path
760 #
761 AC_MSG_CHECKING([for Ruby include path])
762 if test -z "$RUBY_CPPFLAGS"; then
763 ruby_path=`$RUBY -rmkmf -e 'print Config::CONFIG[["archdir"]]'`
764 if test -n "${ruby_path}"; then
765 ruby_path="-I$ruby_path"
766 fi
767 RUBY_CPPFLAGS=$ruby_path
768 fi
769 AC_MSG_RESULT([$RUBY_CPPFLAGS])
770 AC_SUBST([RUBY_CPPFLAGS])
771
772 #
773 # Check for Ruby library path
774 #
775 AC_MSG_CHECKING([for Ruby library path])
776 if test -z "$RUBY_LDFLAGS"; then
777 RUBY_LDFLAGS=`$RUBY -rmkmf -e 'print Config::CONFIG[["LIBRUBYARG_SHARED"]]'`
778 fi
779 AC_MSG_RESULT([$RUBY_LDFLAGS])
780 AC_SUBST([RUBY_LDFLAGS])
781
782 #
783 # Check for site packages
784 #
785 AC_MSG_CHECKING([for Ruby site-packages path])
786 if test -z "$RUBY_SITE_PKG"; then
787 RUBY_SITE_PKG=`$RUBY -rmkmf -e 'print Config::CONFIG[["sitearchdir"]]'`
788 fi
789 AC_MSG_RESULT([$RUBY_SITE_PKG])
790 AC_SUBST([RUBY_SITE_PKG])
791
792 #
793 # libraries which must be linked in when embedding
794 #
795 AC_MSG_CHECKING(ruby extra libraries)
796 if test -z "$RUBY_EXTRA_LIBS"; then
797 RUBY_EXTRA_LIBS=`$RUBY -rmkmf -e 'print Config::CONFIG[["SOLIBS"]]'`
798 fi
799 AC_MSG_RESULT([$RUBY_EXTRA_LIBS])
800 AC_SUBST(RUBY_EXTRA_LIBS)
801
802 #
803 # linking flags needed when embedding
804 # (is it even needed for Ruby?)
805 #
806 # AC_MSG_CHECKING(ruby extra linking flags)
807 # if test -z "$RUBY_EXTRA_LDFLAGS"; then
808 # RUBY_EXTRA_LDFLAGS=`$RUBY -rmkmf -e 'print Config::CONFIG[["LINKFORSHARED"]]'`
809 # fi
810 # AC_MSG_RESULT([$RUBY_EXTRA_LDFLAGS])
811 # AC_SUBST(RUBY_EXTRA_LDFLAGS)
812
813 # this flags breaks ruby.h, and is sometimes defined by KDE m4 macros
814 CFLAGS="`echo "$CFLAGS" | sed -e 's/-std=iso9899:1990//g;'`"
815 #
816 # final check to see if everything compiles alright
817 #
818 AC_MSG_CHECKING([consistency of all components of ruby development environment])
819 AC_LANG_PUSH([C])
820 # save current global flags
821 ac_save_LIBS="$LIBS"
822 LIBS="$ac_save_LIBS $RUBY_LDFLAGS"
823 ac_save_CPPFLAGS="$CPPFLAGS"
824 CPPFLAGS="$ac_save_CPPFLAGS $RUBY_CPPFLAGS"
825 AC_TRY_LINK([
826 #include <ruby.h>
827 ],[
828 ruby_init();
829 ],[rubyexists=yes],[rubyexists=no])
830
831 AC_MSG_RESULT([$rubyexists])
832
833 if test ! "$rubyexists" = "yes"; then
834 AC_MSG_ERROR([
835 Could not link test program to Ruby. Maybe the main Ruby library has been
836 installed in some non-standard library path. If so, pass it to configure,
837 via the LDFLAGS environment variable.
838 Example: ./configure LDFLAGS="-L/usr/non-standard-path/ruby/lib"
839 ============================================================================
840 ERROR!
841 You probably have to install the development version of the Ruby package
842 for your distribution. The exact name of this package varies among them.
843 ============================================================================
844 ])
845 RUBY_VERSION=""
846 fi
847 AC_LANG_POP
848 # turn back to default flags
849 CPPFLAGS="$ac_save_CPPFLAGS"
850 LIBS="$ac_save_LIBS"
851
852 #
853 # all done!
854 #
855 ])
856