source: trunk/m4/yat_check_libbam.m4 @ 2986

Last change on this file since 2986 was 2986, checked in by Peter, 10 years ago

merge 0.10-stable branch into trunk

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Date
File size: 3.6 KB
Line 
1## $Id: yat_check_libbam.m4 2986 2013-02-18 08:07:44Z peter $
2#
3# serial 2 (yat 0.10.2)
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>
30AC_CHECK_HEADERS([bam/bam.h bam.h samtools/bam.h bam.h],
31                 [yat_bam_header=yes; break])
32AS_IF([test x$yat_bam_header = xyes], [$1], [$2])
33]) # YAT_CHECK_HEADER_BAM
34
35
36# YAT_CHECK_LIBBAM([action-if-found], [action-if-not-found])
37# ==========================================================
38#
39AC_DEFUN([YAT_CHECK_LIBBAM],
40[
41AC_REQUIRE([YAT_CHECK_HEADER_BAM])
42BAM_LIBS=no
43AC_MSG_CHECKING([for library containing bam_header_destroy])
44for libs in "" "-lbam" "-lbam -lpthread"; do
45  AS_IF([test x"$BAM_LIBS" = x"no"], [
46    YAT_LINK_BAM_IFELSE([$libs], [BAM_LIBS=$libs])
47  ])
48done
49AS_IF([test x"$BAM_LIBS" = x""], [
50  AC_MSG_RESULT([none required])
51],[
52  AC_MSG_RESULT([$BAM_LIBS])
53])
54AS_IF([test x"$BAM_LIBS" = xno], [$2], [$1])
55]) # YAT_CHECK_LIBBAM
56
57
58
59# YAT_LINK_BAM_IFELSE([lib], [action-if-found], [action-if-not-found])
60# ====================================================================
61# Add lib to LIBS and try to link some code using libbam
62AC_DEFUN([YAT_LINK_BAM_IFELSE],
63[
64save_LIBS=$LIBS
65LIBS="$1 $LIBS"
66AC_LINK_IFELSE([AC_LANG_PROGRAM([@%:@if HAVE_BAM_H
67                                 @%:@ include <bam.h>
68                                 @%:@elif HAVE_BAM_BAM_H
69                                 @%:@ include <bam/bam.h>
70                                 @%:@elif HAVE_SAMTOOLS_BAM_H
71                                 @%:@ include <samtools/bam.h>
72                                 @%:@endif
73                                ],[
74                                 bam_header_t* hdr = bam_header_init();
75                                 bam_header_destroy(hdr);
76                                ])],
77               [$2], [$3])
78LIBS=$save_LIBS
79]) # YAT_LINK_BAM_IFELSE
80
81# YAT_BAM_NT16_REV_TABLE
82# ====================================================================
83# Check if global variable bam_nt16_rev_table is available in
84# -lbam. If found call AC_DEFINE(HAVE_BAM_NT16_REV_TABLE).
85AC_DEFUN([YAT_BAM_NT16_REV_TABLE],
86[
87AC_MSG_CHECKING([for bam_nt16_rev_table])
88AC_LINK_IFELSE([AC_LANG_PROGRAM(
89                 [@%:@if HAVE_BAM_H
90                  @%:@ include <bam.h>
91                  @%:@elif HAVE_BAM_BAM_H
92                  @%:@ include <bam/bam.h>
93                  @%:@elif HAVE_SAMTOOLS_BAM_H
94                  @%:@ include <samtools/bam.h>
95                  @%:@endif
96                 ],[
97                  char c = bam_nt16_rev_table@<:@7@:>@;
98                 ])
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
Note: See TracBrowser for help on using the repository browser.