Changeset 3350


Ignore:
Timestamp:
Nov 20, 2014, 2:25:34 PM (7 years ago)
Author:
Peter
Message:

Make configure htslib aware. Header detection changed to look for
'sam.h', 'htslib/sam.h', 'bam/sam.h', and 'samtools/sam.h'; if second
alternative is detected, YAT_HAVE_HTSLIB_SAM_H is
#defined. YAT_SAM_HEADER is defined appropriately; since 'bam.h'
doesn't exist in htslib, YAT_BAM_HEADER is not defined (users should
#include YAT_SAM_HEADER instead). Likewise linker test is modified so
it tries '-lhts' before trying '-lbam'.

Note, configure now works against htslib, but compilation still fails
due to API changes between bamlib and htslib. For that reason
configure also checks if header 'hts.h' is available and #defined
YAT_HAVE_HTSLIB, which will be used for conditional implementations.

#refs 794

Location:
trunk
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/configure.ac

    r3330 r3350  
    370370    { z_streamp zs; inflateEnd(zs); return 0; }
    371371  ], [$LIBZ $user_LIBS], [$LIBZ], [YAT_STATIC_LIBS])
    372   YAT_CHECK_HEADER_BAM([],[AC_MSG_FAILURE([header file 'bam.h' was not found])])
     372
     373  YAT_CHECK_HEADER_SAM([],[AC_MSG_FAILURE([header file 'sam.h' was not found])])
     374  # check if we have hts
     375  YAT_CHECK_HEADER_HTS([AC_DEFINE([YAT_HAVE_HTSLIB],
     376                                  [1], [Define to 1 if HTS is available])])
    373377  # try link against libbam
    374378  YAT_CHECK_LIBBAM([LIBS="$BAM_LIBS $LIBS"
     
    487491
    488492AS_IF([test x$enable_debug = xyes], [
     493  suppress_long_long_warnings=no
    489494  # some versions of boost uses long long - turn off compiler warnings
    490495  # with -Wno-long-long
    491496  yat_save_CXXFLAGS=$CXXFLAGS
    492   AC_MSG_CHECKING([whether boost uses long long])
     497  AC_MSG_CHECKING([whether boost causes long long warnings])
    493498  CXXFLAGS="$INTERNAL_CXXFLAGS $CXXFLAGS"
    494499  AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
     
    510515  [AC_MSG_RESULT([no])],
    511516  [AC_MSG_RESULT([yes])
    512    YAT_CXX_ADD_FLAG([INTERNAL_CXXFLAGS], [-Wno-long-long])
     517   suppress_long_long_warnings=yes
     518  ])
     519  AS_IF([test x"$suppress_long_long_warnings" = x"no"], [
     520    AC_MSG_CHECKING([whether samtools causes long long warnings])
     521    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([_YAT_BAM_INCLUDES],[])],
     522                      [AC_MSG_RESULT([no])],
     523                      [AC_MSG_RESULT([yes])
     524                       suppress_long_long_warnings=yes])
     525  ])
     526  AS_IF([test x"$suppress_long_long_warnings" = x"yes"], [
     527    YAT_CXX_ADD_FLAG([INTERNAL_CXXFLAGS], [-Wno-long-long])
    513528  ])
    514529  # restore CXXFLAGS
  • trunk/m4/yat_check_libbam.m4

    r3306 r3350  
    11## $Id$
    22#
    3 # serial 5 (yat 0.12.1)
     3# serial 6 (yat 0.13)
    44#
    55#
     
    2121#   along with yat. If not, see <http://www.gnu.org/licenses/>.
    2222
    23 # YAT_CHECK_HEADER_BAM([action-if-found], [action-if-not-found])
     23# YAT_CHECK_HEADER_SAM([action-if-found], [action-if-not-found])
    2424# ==============================================================
    2525#
    26 AC_DEFUN([YAT_CHECK_HEADER_BAM],
     26AC_DEFUN([YAT_CHECK_HEADER_SAM],
    2727[
    28 yat_bam_header=no
    29 # check how to #include <bam.h>
    30 m4_foreach_w([myheader], [bam.h bam/bam.h samtools/bam.h],
    31              [_YAT_CHECK_HEADER_BAM(myheader)
     28yat_sam_header=no
     29# check how to #include <sam.h>
     30m4_foreach_w([myheader], [sam.h htslib/sam.h bam/sam.h samtools/sam.h],
     31             [_YAT_CHECK_HEADER_SAM(myheader)
    3232])
    33 AS_IF([test x$yat_bam_header = xyes], [$1], [$2])
    34 ]) # YAT_CHECK_HEADER_BAM
     33AS_IF([test x$yat_sam_header = xyes], [$1], [$2])
     34]) # YAT_CHECK_HEADER_SAM
    3535
    3636
    37 # _YAT_CHECK_HEADER_BAM
     37# _YAT_CHECK_HEADER_SAM
    3838# =====================
    39 # Private macro used in YAT_CHECK_HEADER_BAM
    40 AC_DEFUN([_YAT_CHECK_HEADER_BAM],
     39# Private macro used in YAT_CHECK_HEADER_SAM
     40AC_DEFUN([_YAT_CHECK_HEADER_SAM],
    4141[
    42 AS_IF([test x$yat_bam_header = xno], [dnl
     42AS_IF([test x$yat_sam_header = xno], [dnl
    4343  AC_CHECK_HEADER([$1], [
    4444    AC_DEFINE_UNQUOTED(AS_TR_CPP([YAT_HAVE_$1]), [1],
    4545                       [Define to 1 if you have <$1> header file])
    46     yat_bam_header=yes;
     46    yat_sam_header=yes;
    4747  ])
    4848])
    49 ]) # _YAT_CHECK_HEADER_BAM
     49]) # _YAT_CHECK_HEADER_SAM
     50
     51
     52# YAT_CHECK_HEADER_HTS([action-if-found], [action-if-not-found])
     53# =====================
     54# Check if header hts.h is available
     55AC_DEFUN([YAT_CHECK_HEADER_HTS],
     56[
     57AC_CHECK_HEADER([hts.h], [$1],
     58  [AC_CHECK_HEADER([htslib/hts.h], [$1], [$2])])
     59]) # YAT_CHECK_HEADER_HTS
    5060
    5161
     
    5666[
    5767BAM_LIBS=no
    58 AC_MSG_CHECKING([for library containing bam_header_destroy])
    59 for libs in "" "-lbam" "-lbam -lpthread"; do
     68AC_MSG_CHECKING([for library containing bam_hdr_destroy])
     69for libs in "" "-lhts" "-lbam" "-lbam -lpthread"; do
    6070  AS_IF([test x"$BAM_LIBS" = x"no"], [
    6171    YAT_LINK_BAM_IFELSE([$libs], [BAM_LIBS=$libs])
     
    8191AC_LINK_IFELSE([AC_LANG_PROGRAM([_YAT_BAM_INCLUDES],
    8292                                [
     93                                 #if YAT_HAVE_HTSLIB
     94                                 bam_hdr_t* hdr = bam_hdr_init();
     95                                 bam_hdr_destroy(hdr);
     96                                 #else
    8397                                 bam_header_t* hdr = bam_header_init();
    8498                                 bam_header_destroy(hdr);
     99                                 #endif
    85100                                ])],
    86101               [$2], [$3])
     
    164179# Private macro that expand PP magic we see in 'yat/omic/bam_config.h'
    165180AC_DEFUN([_YAT_BAM_INCLUDES],
    166 [AC_REQUIRE([YAT_CHECK_HEADER_BAM])
    167 @%:@if YAT_HAVE_BAM_H
    168 @%:@ include <bam.h>
     181[AC_REQUIRE([YAT_CHECK_HEADER_SAM])
     182@%:@if YAT_HAVE_SAM_H
    169183@%:@ include <sam.h>
    170 @%:@elif YAT_HAVE_BAM_BAM_H
     184@%:@elif YAT_HAVE_HTSLIB_SAM_H
     185@%:@ include <htslib/sam.h>
     186@%:@elif YAT_HAVE_BAM_SAM_H
    171187@%:@ include <bam/bam.h>
    172188@%:@ include <bam/sam.h>
    173 @%:@elif YAT_HAVE_SAMTOOLS_BAM_H
     189@%:@elif YAT_HAVE_SAMTOOLS_SAM_H
    174190@%:@ include <samtools/bam.h>
    175191@%:@ include <samtools/sam.h>
  • trunk/yat/omic/BamFile.cc

    r3166 r3350  
    2828#include "yat/utility/Exception.h"
    2929
    30 #include YAT_BAM_HEADER
     30#include YAT_SAM_HEADER
    3131
    3232#include <cassert>
  • trunk/yat/omic/BamHeader.h

    r3188 r3350  
    2525#include "config_bam.h"
    2626
    27 #include YAT_BAM_HEADER
     27#include YAT_SAM_HEADER
    2828
    2929#include <string>
  • trunk/yat/omic/BamRead.h

    r3306 r3350  
    2424
    2525#include "config_bam.h"
    26 #include YAT_BAM_HEADER
    2726#include YAT_SAM_HEADER
    2827
  • trunk/yat/omic/BamReadFilter.h

    r3081 r3350  
    2424
    2525#include "config_bam.h"
    26 #include YAT_BAM_HEADER
     26#include YAT_SAM_HEADER
    2727
    2828#include <functional>
  • trunk/yat/omic/config_bam.h

    r3068 r3350  
    3434#include "yat/utility/config_public.h"
    3535
    36 #ifdef YAT_HAVE_BAM_H
     36#ifdef YAT_HAVE_SAM_H
    3737# define YAT_BAM_HEADER "bam.h"
    3838# define YAT_SAM_HEADER "sam.h"
    3939#else
    40 # ifdef YAT_HAVE_BAM_BAM_H
    41 #  define YAT_BAM_HEADER "bam/bam.h"
    42 #  define YAT_SAM_HEADER "bam/sam.h"
     40# ifdef YAT_HAVE_HTSLIB_SAM_H
     41#  define YAT_SAM_HEADER "htslib/sam.h"
    4342# else
    44 #  ifdef YAT_HAVE_SAMTOOLS_BAM_H
    45 #   define YAT_BAM_HEADER "samtools/bam.h"
    46 #   define YAT_SAM_HEADER "samtools/sam.h"
     43#  ifdef YAT_HAVE_BAM_SAM_H
     44#   define YAT_BAM_HEADER "bam/bam.h"
     45#   define YAT_SAM_HEADER "bam/sam.h"
     46#  else
     47#   ifdef YAT_HAVE_SAMTOOLS_SAM_H
     48#    define YAT_BAM_HEADER "samtools/bam.h"
     49#    define YAT_SAM_HEADER "samtools/sam.h"
     50#   endif
    4751#  endif
    4852# endif
    4953#endif
    5054
    51 #ifndef YAT_BAM_HEADER
     55#ifndef YAT_SAM_HEADER
    5256#error This file requires samtools header files and cannot be used when \
    5357yat was configured with switch '--without-samtools'.
  • trunk/yat/utility/Cigar.h

    r3306 r3350  
    3131#ifdef YAT_HAVE_LIBBAM
    3232#include "yat/omic/config_bam.h"
    33 #include YAT_BAM_HEADER
     33#include YAT_SAM_HEADER
    3434#else // if bam.h is not available #define CIGAR
    3535/// describe how CIGAR operation/length is packed into a 32-bit
  • trunk/yat/utility/config_public.h.in

    r3258 r3350  
    2828///
    2929
    30 /// Define to 1 if you have the <bam/bam.h> header file.
    31 #undef YAT_HAVE_BAM_BAM_H
    3230
    33 /// Define to 1 if you have the <bam.h> header file.
    34 #undef YAT_HAVE_BAM_H
     31/// Define to 1 if you have the <bam/sam.h> header file.
     32#undef YAT_HAVE_BAM_SAM_H
    3533
    36 /// Define to 1 if you have the <samtools/bam.h> header file.
    37 #undef YAT_HAVE_SAMTOOLS_BAM_H
     34/// Define to 1 if you have the <htslib/sam.h> header file.
     35#undef YAT_HAVE_HTSLIB_SAM_H
     36
     37/// Define to 1 if you have the <sam.h> header file.
     38#undef YAT_HAVE_SAM_H
     39
     40/// Define to 1 if you have the <samtools/sam.h> header file.
     41#undef YAT_HAVE_SAMTOOLS_SAM_H
     42
     43/// Define to 1 if HTS is available
     44#undef YAT_HAVE_HTSLIB
     45
     46/// Define to 1 if you have 'bam_header_t'
     47#undef YAT_HAVE_BAM_HEADER_T
    3848
    3949/// Define to 1 if libbam is available
     
    6373#undef YAT_DEV_BUILD
    6474
     75// for backward compatibility
     76
     77#ifdef YAT_HAVE_SAM_H
     78/// \deprecated defined for backward compatibility with 0.12 API
     79#define YAT_HAVE_BAM_H YAT_HAVE_SAM_H
    6580#endif
     81
     82#ifdef YAT_HAVE_BAM_SAM_H
     83/// \deprecated defined for backward compatibility with 0.12 API
     84#define YAT_HAVE_BAM_BAM_H YAT_HAVE_BAM_SAM_H
     85#endif
     86
     87#ifdef YAT_HAVE_SAMTOOLS_SAM_H
     88/// \deprecated defined for backward compatibility with 0.12 API
     89#define YAT_HAVE_SAMTOOLS_BAM_H YAT_HAVE_SAMTOOLS_SAM_H
     90#endif
     91
     92#endif
Note: See TracChangeset for help on using the changeset viewer.