@@ -236,3 +236,181 @@ MOSTLYCLEANFILES += $(valgrind_log_files)
236
236
AC_SUBST ( [ VALGRIND_CHECK_RULES] )
237
237
m4_ifdef ( [ _AM_SUBST_NOTMAKE] , [ _AM_SUBST_NOTMAKE([ VALGRIND_CHECK_RULES] )] )
238
238
] )
239
+
240
+ # ===========================================================================
241
+ # http://www.gnu.org/software/autoconf-archive/ax_compare_version.html
242
+ # ===========================================================================
243
+ #
244
+ # SYNOPSIS
245
+ #
246
+ # AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE])
247
+ #
248
+ # DESCRIPTION
249
+ #
250
+ # This macro compares two version strings. Due to the various number of
251
+ # minor-version numbers that can exist, and the fact that string
252
+ # comparisons are not compatible with numeric comparisons, this is not
253
+ # necessarily trivial to do in a autoconf script. This macro makes doing
254
+ # these comparisons easy.
255
+ #
256
+ # The six basic comparisons are available, as well as checking equality
257
+ # limited to a certain number of minor-version levels.
258
+ #
259
+ # The operator OP determines what type of comparison to do, and can be one
260
+ # of:
261
+ #
262
+ # eq - equal (test A == B)
263
+ # ne - not equal (test A != B)
264
+ # le - less than or equal (test A <= B)
265
+ # ge - greater than or equal (test A >= B)
266
+ # lt - less than (test A < B)
267
+ # gt - greater than (test A > B)
268
+ #
269
+ # Additionally, the eq and ne operator can have a number after it to limit
270
+ # the test to that number of minor versions.
271
+ #
272
+ # eq0 - equal up to the length of the shorter version
273
+ # ne0 - not equal up to the length of the shorter version
274
+ # eqN - equal up to N sub-version levels
275
+ # neN - not equal up to N sub-version levels
276
+ #
277
+ # When the condition is true, shell commands ACTION-IF-TRUE are run,
278
+ # otherwise shell commands ACTION-IF-FALSE are run. The environment
279
+ # variable 'ax_compare_version' is always set to either 'true' or 'false'
280
+ # as well.
281
+ #
282
+ # Examples:
283
+ #
284
+ # AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8])
285
+ # AX_COMPARE_VERSION([3.15],[lt],[3.15.8])
286
+ #
287
+ # would both be true.
288
+ #
289
+ # AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8])
290
+ # AX_COMPARE_VERSION([3.15],[gt],[3.15.8])
291
+ #
292
+ # would both be false.
293
+ #
294
+ # AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8])
295
+ #
296
+ # would be true because it is only comparing two minor versions.
297
+ #
298
+ # AX_COMPARE_VERSION([3.15.7],[eq0],[3.15])
299
+ #
300
+ # would be true because it is only comparing the lesser number of minor
301
+ # versions of the two values.
302
+ #
303
+ # Note: The characters that separate the version numbers do not matter. An
304
+ # empty string is the same as version 0. OP is evaluated by autoconf, not
305
+ # configure, so must be a string, not a variable.
306
+ #
307
+ # The author would like to acknowledge Guido Draheim whose advice about
308
+ # the m4_case and m4_ifvaln functions make this macro only include the
309
+ # portions necessary to perform the specific comparison specified by the
310
+ # OP argument in the final configure script.
311
+ #
312
+ # LICENSE
313
+ #
314
+ # Copyright (c) 2008 Tim Toolan <[email protected] >
315
+ #
316
+ # Copying and distribution of this file, with or without modification, are
317
+ # permitted in any medium without royalty provided the copyright notice
318
+ # and this notice are preserved. This file is offered as-is, without any
319
+ # warranty.
320
+
321
+ # serial 11
322
+
323
+ dnl #########################################################################
324
+ AC_DEFUN ( [ AX_COMPARE_VERSION ] , [
325
+ AC_REQUIRE ( [ AC_PROG_AWK ] )
326
+
327
+ # Used to indicate true or false condition
328
+ ax_compare_version=false
329
+
330
+ # Convert the two version strings to be compared into a format that
331
+ # allows a simple string comparison. The end result is that a version
332
+ # string of the form 1.12.5-r617 will be converted to the form
333
+ # 0001001200050617. In other words, each number is zero padded to four
334
+ # digits, and non digits are removed.
335
+ AS_VAR_PUSHDEF ( [ A] ,[ ax_compare_version_A] )
336
+ A=`echo "$1 " | sed -e 's/\([ [ 0-9] ] *\)/Z\1Z/g' \
337
+ -e 's/Z\([ [ 0-9] ] \)Z/Z0\1Z/g' \
338
+ -e 's/Z\([ [ 0-9] ] [ [ 0-9] ] \)Z/Z0\1Z/g' \
339
+ -e 's/Z\([ [ 0-9] ] [ [ 0-9] ] [ [ 0-9] ] \)Z/Z0\1Z/g' \
340
+ -e 's/[ [ ^0-9] ] //g'`
341
+
342
+ AS_VAR_PUSHDEF ( [ B] ,[ ax_compare_version_B] )
343
+ B=`echo "$3 " | sed -e 's/\([ [ 0-9] ] *\)/Z\1Z/g' \
344
+ -e 's/Z\([ [ 0-9] ] \)Z/Z0\1Z/g' \
345
+ -e 's/Z\([ [ 0-9] ] [ [ 0-9] ] \)Z/Z0\1Z/g' \
346
+ -e 's/Z\([ [ 0-9] ] [ [ 0-9] ] [ [ 0-9] ] \)Z/Z0\1Z/g' \
347
+ -e 's/[ [ ^0-9] ] //g'`
348
+
349
+ dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary
350
+ dnl # then the first line is used to determine if the condition is true.
351
+ dnl # The sed right after the echo is to remove any indented white space.
352
+ m4_case ( m4_tolower ( $2 ) ,
353
+ [ lt] ,[
354
+ ax_compare_version=`echo "x$A
355
+ x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"`
356
+ ] ,
357
+ [ gt] ,[
358
+ ax_compare_version=`echo "x$A
359
+ x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"`
360
+ ] ,
361
+ [ le] ,[
362
+ ax_compare_version=`echo "x$A
363
+ x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"`
364
+ ] ,
365
+ [ ge] ,[
366
+ ax_compare_version=`echo "x$A
367
+ x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"`
368
+ ] ,[
369
+ dnl Split the operator from the subversion count if present.
370
+ m4_bmatch ( m4_substr ( $2 ,2 ) ,
371
+ [ 0] ,[
372
+ # A count of zero means use the length of the shorter version.
373
+ # Determine the number of characters in A and B.
374
+ ax_compare_version_len_A=`echo "$A" | $AWK '{print(length)}'`
375
+ ax_compare_version_len_B=`echo "$B" | $AWK '{print(length)}'`
376
+
377
+ # Set A to no more than B's length and B to no more than A's length.
378
+ A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"`
379
+ B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"`
380
+ ] ,
381
+ [ [ 0-9] +] ,[
382
+ # A count greater than zero means use only that many subversions
383
+ A=`echo "$A" | sed "s/\(\([ [ 0-9] ] \{4\}\)\{m4_substr ( $2 ,2 ) \}\).*/\1/"`
384
+ B=`echo "$B" | sed "s/\(\([ [ 0-9] ] \{4\}\)\{m4_substr ( $2 ,2 ) \}\).*/\1/"`
385
+ ] ,
386
+ [ .+] ,[
387
+ AC_WARNING (
388
+ [ illegal OP numeric parameter: $2 ] )
389
+ ] ,[ ] )
390
+
391
+ # Pad zeros at end of numbers to make same length.
392
+ ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`"
393
+ B="$B`echo $A | sed 's/./0/g'`"
394
+ A="$ax_compare_version_tmp_A"
395
+
396
+ # Check for equality or inequality as necessary.
397
+ m4_case ( m4_tolower ( m4_substr ( $2 ,0 ,2 ) ) ,
398
+ [ eq] ,[
399
+ test "x$A" = "x$B" && ax_compare_version=true
400
+ ] ,
401
+ [ ne] ,[
402
+ test "x$A" != "x$B" && ax_compare_version=true
403
+ ] ,[
404
+ AC_WARNING ( [ illegal OP parameter: $2 ] )
405
+ ] )
406
+ ] )
407
+
408
+ AS_VAR_POPDEF ( [ A] ) dnl
409
+ AS_VAR_POPDEF ( [ B] ) dnl
410
+
411
+ dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE.
412
+ if test "$ax_compare_version" = "true" ; then
413
+ m4_ifvaln ( [ $4 ] ,[ $4 ] ,[ :] ) dnl
414
+ m4_ifvaln ( [ $5 ] ,[ else $5 ] ) dnl
415
+ fi
416
+ ] ) dnl AX_COMPARE_VERSION
0 commit comments