source: trunk/m4/yat_check_libbam.m4 @ 3130

Last change on this file since 3130 was 3130, checked in by Peter, 8 years ago

merge release 0.11 into trunk

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Date
File size: 3.7 KB
Line 
1## $Id: yat_check_libbam.m4 3130 2013-11-18 07:38:59Z peter $
2#
3# serial 4 (yat 0.11)
4#
5#
6#   Copyright (C) 2012, 2013 Peter Johansson
7#
8#   This file is part of the yat library, http://dev.thep.lu.se/yat
9#
10#   The yat library is free software; you can redistribute it and/or
11#   modify it under the terms of the GNU General Public License as
12#   published by the Free Software Foundation; either version 3 of the
13#   License, or (at your option) any later version.
14#
15#   The yat library is distributed in the hope that it will be useful,
16#   but WITHOUT ANY WARRANTY; without even the implied warranty of
17#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18#   General Public License for more details.
19#
20#   You should have received a copy of the GNU General Public License
21#   along with yat. If not, see <http://www.gnu.org/licenses/>.
22
23# YAT_CHECK_HEADER_BAM([action-if-found], [action-if-not-found])
24# ==============================================================
25#
26AC_DEFUN([YAT_CHECK_HEADER_BAM],
27[
28yat_bam_header=no
29# check how to #include <bam.h>
30m4_foreach_w([myheader], [bam.h bam/bam.h samtools/bam.h],
31             [_YAT_CHECK_HEADER_BAM(myheader)
32])
33AS_IF([test x$yat_bam_header = xyes], [$1], [$2])
34]) # YAT_CHECK_HEADER_BAM
35
36
37# _YAT_CHECK_HEADER_BAM
38# =====================
39# Private macro used in YAT_CHECK_HEADER_BAM
40AC_DEFUN([_YAT_CHECK_HEADER_BAM],
41[
42AS_IF([test x$yat_bam_header = xno], [dnl
43  AC_CHECK_HEADER([$1], [
44    AC_DEFINE_UNQUOTED(AS_TR_CPP([YAT_HAVE_$1]), [1],
45                       [Define to 1 if you have <$1> header file])
46    yat_bam_header=yes;
47  ])
48])
49]) # _YAT_CHECK_HEADER_BAM
50
51
52# YAT_CHECK_LIBBAM([action-if-found], [action-if-not-found])
53# ==========================================================
54#
55AC_DEFUN([YAT_CHECK_LIBBAM],
56[
57BAM_LIBS=no
58AC_MSG_CHECKING([for library containing bam_header_destroy])
59for libs in "" "-lbam" "-lbam -lpthread"; do
60  AS_IF([test x"$BAM_LIBS" = x"no"], [
61    YAT_LINK_BAM_IFELSE([$libs], [BAM_LIBS=$libs])
62  ])
63done
64AS_IF([test x"$BAM_LIBS" = x""], [
65  AC_MSG_RESULT([none required])
66],[
67  AC_MSG_RESULT([$BAM_LIBS])
68])
69AS_IF([test x"$BAM_LIBS" = xno], [$2], [$1])
70]) # YAT_CHECK_LIBBAM
71
72
73
74# YAT_LINK_BAM_IFELSE([lib], [action-if-found], [action-if-not-found])
75# ====================================================================
76# Add lib to LIBS and try to link some code using libbam
77AC_DEFUN([YAT_LINK_BAM_IFELSE],
78[
79save_LIBS=$LIBS
80LIBS="$1 $LIBS"
81AC_LINK_IFELSE([AC_LANG_PROGRAM([_YAT_BAM_INCLUDES],
82                                [
83                                 bam_header_t* hdr = bam_header_init();
84                                 bam_header_destroy(hdr);
85                                ])],
86               [$2], [$3])
87LIBS=$save_LIBS
88]) # YAT_LINK_BAM_IFELSE
89
90# YAT_BAM_NT16_REV_TABLE
91# ====================================================================
92# Check if global variable bam_nt16_rev_table is available in
93# -lbam. If found call AC_DEFINE(HAVE_BAM_NT16_REV_TABLE).
94AC_DEFUN([YAT_BAM_NT16_REV_TABLE],
95[
96AC_MSG_CHECKING([for bam_nt16_rev_table])
97AC_LINK_IFELSE([AC_LANG_PROGRAM([_YAT_BAM_INCLUDES],
98                  [char c = bam_nt16_rev_table@<:@7@:>@;])
99               ],[
100                 AC_MSG_RESULT([yes])
101                 AC_DEFINE([HAVE_BAM_NT16_REV_TABLE], [1],
102                           [Define to 1 if libbam contains bam_nt16_rev_table])
103               ],[
104                 AC_MSG_RESULT([no])
105               ])
106]) # YAT_BAM_NT16_REV_TABLE
107
108
109# _YAT_BAM_INCLUDES
110# =================
111# Private macro that expand PP magic we see in 'yat/omic/bam_config.h'
112AC_DEFUN([_YAT_BAM_INCLUDES],
113[AC_REQUIRE([YAT_CHECK_HEADER_BAM])
114@%:@if YAT_HAVE_BAM_H
115@%:@ include <bam.h>
116@%:@elif YAT_HAVE_BAM_BAM_H
117@%:@ include <bam/bam.h>
118@%:@elif YAT_HAVE_SAMTOOLS_BAM_H
119@%:@ include <samtools/bam.h>
120@%:@endif
121]) # _YAT_BAM_HEADER
Note: See TracBrowser for help on using the repository browser.