Changeset 4277


Ignore:
Timestamp:
Jan 26, 2023, 12:53:10 AM (2 months ago)
Author:
Peter
Message:

Check if wanted_version is empty at configure time (not autoconf time)
to allow it being a an empty shell variable. Replace use of sed, grep,
expr, and echo with variables and macros SED, GREP, AS_VAR_ARITH, and
AS_ECHO. Validate the version input before getting ugly error message
from expr.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure.ac

    r4276 r4277  
    354354
    355355# check for hts and samtools available from http://www.htslib.org
    356 YAT_CHECK_HTSLIB([1.10.0])
     356YAT_CHECK_HTSLIB([1.10])
    357357
    358358#support for large files
  • trunk/m4/yat_check_htslib.m4

    r4276 r4277  
    11## $Id$
    22#
    3 # serial 9 (yat 0.21)
     3# serial 10 (yat 0.21)
    44#
    55#   Copyright (C) 2016, 2018, 2020, 2023 Peter Johansson
     
    116116AC_DEFUN([YAT_CHECK_HTS_VERSION],
    117117[
    118   m4_if([$1], [], [
    119    dnl if min-version is empty, just do action-if-success
     118  AC_REQUIRE([AC_PROG_GREP])
     119  AC_REQUIRE([AC_PROG_SED])
     120  # trim off leading and trailing whitespaces
     121  yat_wanted_hts_version=`AS_ECHO(["$1"]) \
     122    | $SED 's/^[[ \t]]*//' | $SED 's/[[ \t]]*$//'`
     123  AS_VAR_IF([yat_wanted_hts_version], [], [
     124   # if wanted_hts_version is empty, just do action-if-success
    120125   $2
    121   ], [
    122     yat_hts_version=`echo $1 | sed 's/^[[ \t]]*//'`
    123     yat_hts_version_major=`echo $1 | sed 's/\([[0-9]][[0-9]]*\)\..*/\1/'`
    124     yat_hts_version_minor=`echo $1 | sed 's/[[0-9]][[0-9]]*.\([[0-9]][[0-9]]*\).*/\1/'`
    125     yat_hts_version_micro=`echo $1 | sed 's/[[0-9]][[0-9]]*.[[0-9]][[0-9]]*.\(.*\)/\1/'`
     126  ], [ # otherwise run compilation test
     127    yat_hts_version_major=`AS_ECHO([$yat_wanted_hts_version]) \
     128      | $SED 's/\([[^.]][[^.]]*\)\..*/\1/'`
     129    yat_hts_version_minor=`AS_ECHO([$yat_wanted_hts_version]) \
     130      | $SED 's/[[^.]][[^.]]*.\([[^.]][[^.]]*\).*/\1/'`
     131    yat_hts_version_micro=`AS_ECHO([$yat_wanted_hts_version]) \
     132      | $SED 's/[[^.]][[^.]]*.[[^.]][[^.]]*.\(.*\)/\1/'`
    126133    AS_VAR_IF([yat_hts_version_micro], [], [yat_hts_version_micro=0])
    127     yat_hts_pp_version=`expr 100000 \* $yat_hts_version_major + 100 \* $yat_hts_version_minor + $yat_hts_version_micro`
     134
     135    # Check that version number are integers before applying arithmetics
     136    m4_foreach([YAT_x_version],
     137            [[$yat_hts_version_major],
     138            [$yat_hts_version_minor],
     139            [$yat_hts_version_micro]],
     140           [AS_IF([AS_ECHO([YAT_x_version]) \
     141              | $GREP "^[[0-9]][[0-9]]*$" > /dev/null], [],
     142            [AC_MSG_ERROR([invalid hts min-version: $yat_wanted_hts_version])])
     143    ])
     144
     145    AS_VAR_ARITH([yat_hts_pp_version],
     146      [100000 \* $yat_hts_version_major + 100 \* $yat_hts_version_minor + $yat_hts_version_micro])
     147
    128148    AC_CACHE_CHECK([if HTS verson >= $yat_hts_version ($yat_hts_pp_version)],
    129149      [yat_cv_hts_version],
Note: See TracChangeset for help on using the changeset viewer.