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 | # |
---|
26 | AC_DEFUN([YAT_CHECK_HEADER_BAM], |
---|
27 | [ |
---|
28 | yat_bam_header=no |
---|
29 | # check how to #include <bam.h> |
---|
30 | AC_CHECK_HEADERS([bam/bam.h bam.h samtools/bam.h bam.h], |
---|
31 | [yat_bam_header=yes; break]) |
---|
32 | AS_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 | # |
---|
39 | AC_DEFUN([YAT_CHECK_LIBBAM], |
---|
40 | [ |
---|
41 | AC_REQUIRE([YAT_CHECK_HEADER_BAM]) |
---|
42 | BAM_LIBS=no |
---|
43 | AC_MSG_CHECKING([for library containing bam_header_destroy]) |
---|
44 | for 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 | ]) |
---|
48 | done |
---|
49 | AS_IF([test x"$BAM_LIBS" = x""], [ |
---|
50 | AC_MSG_RESULT([none required]) |
---|
51 | ],[ |
---|
52 | AC_MSG_RESULT([$BAM_LIBS]) |
---|
53 | ]) |
---|
54 | AS_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 |
---|
62 | AC_DEFUN([YAT_LINK_BAM_IFELSE], |
---|
63 | [ |
---|
64 | save_LIBS=$LIBS |
---|
65 | LIBS="$1 $LIBS" |
---|
66 | AC_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]) |
---|
78 | LIBS=$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). |
---|
85 | AC_DEFUN([YAT_BAM_NT16_REV_TABLE], |
---|
86 | [ |
---|
87 | AC_MSG_CHECKING([for bam_nt16_rev_table]) |
---|
88 | AC_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 |
---|