source: trunk/m4/yat_check_libbam.m4 @ 2943

Last change on this file since 2943 was 2943, checked in by Peter, 9 years ago

merge release 0.10 into trunk

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Date
File size: 2.6 KB
Line 
1## $Id: yat_check_libbam.m4 2943 2013-01-04 06:38:38Z peter $
2#
3# serial 1 (yat 0.10)
4#
5#
6#   Copyright (C) 2012 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
Note: See TracBrowser for help on using the repository browser.