forked from cole-trapnell-lab/cufflinks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathax_bam.m4
155 lines (138 loc) · 4.31 KB
/
ax_bam.m4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# SYNOPSIS
#
# AX_BAM
#
# DESCRIPTION
#
# Test for the BAM libraries (htslib or bamlib)
#
# If no path to the installed bam library is given the macro searchs
# under /usr, /usr/local, /opt and /opt/local and evaluates the
# $BAM_ROOT environment variable.
# Adapted from AX_BOOST_BASE
#
# This macro calls:
#
# AC_SUBST(BAM_CPPFLAGS) / AC_SUBST(BAM_LDFLAGS)
#
# And sets:
#
# HAVE_BAM, HAVE_HTSLIB
#
# LICENSE
#
# Copyright (c) 2010 Cole Trapnell <[email protected]>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved.
AC_DEFUN([AX_BAM],
[
AC_ARG_WITH([bam],
AS_HELP_STRING([--with-bam@<:@=DIR@:>@], [use BAM libraries (default is yes) - it is possible to specify the root directory for BAM (optional)]),
[
if test "$withval" = "no"; then
want_bam="no"
elif test "$withval" = "yes"; then
want_bam="yes"
ac_bam_path=""
else
want_bam="yes"
ac_bam_path="$withval"
fi
],
[want_bam="yes"])
AC_ARG_WITH([bam-libdir],
AS_HELP_STRING([--with-bam-libdir=LIB_DIR],
[Force given directory for bam libraries. Note that this will overwrite library path detection, so use this parameter only if default library detection fails and you know exactly where your bam libraries are located.]),
[
if test -d $withval
then
ac_bam_lib_path="$withval"
else
AC_MSG_ERROR(--with-bam-libdir expected directory name)
fi
],
[ac_bam_lib_path=""]
)
if test "x$want_bam" = "xyes"; then
# bam_lib_version_req=ifelse([$1], ,1.20.0,$1)
# bam_lib_version_req_shorten=`expr $bam_lib_version_req : '\([[0-9]]*\.[[0-9]]*\)'`
# bam_lib_version_req_major=`expr $bam_lib_version_req : '\([[0-9]]*\)'`
# bam_lib_version_req_minor=`expr $bam_lib_version_req : '[[0-9]]*\.\([[0-9]]*\)'`
# bam_lib_version_req_sub_minor=`expr $bam_lib_version_req : '[[0-9]]*\.[[0-9]]*\.\([[0-9]]*\)'`
# if test "x$bam_lib_version_req_sub_minor" = "x" ; then
# bam_lib_version_req_sub_minor="0"
# fi
# WANT_BAM_VERSION=`expr $bam_lib_version_req_major \* 100000 \+ $bam_lib_version_req_minor \* 100 \+ $bam_lib_version_req_sub_minor`
AC_MSG_CHECKING(for htslib or bamlib)
succeeded=no
USE_HTSLIB=0
dnl first we check the system location for bam libraries
SEARCH_DIRS="/usr /usr/local /opt /opt/local"
if test "$ac_bam_path" != ""; then
SEARCH_DIRS=$ac_bam_path
fi
for ac_bam_path_tmp in $SEARCH_DIRS ; do
if test -d "$ac_bam_path_tmp/include/htslib" && test -r "$ac_bam_path_tmp/include/htslib"; then
BAM_LDFLAGS="-L$ac_bam_path_tmp/lib"
BAM_CPPFLAGS="-I$ac_bam_path_tmp/include"
BAM_LIB_PARAM="-lhts"
USE_HTSLIB=1
AC_DEFINE(HAVE_HTSLIB,,[define if the BAM library is htslib])
break;
fi
if test -d "$ac_bam_path_tmp/include/bam" && test -r "$ac_bam_path_tmp/include/bam"; then
BAM_LDFLAGS="-L$ac_bam_path_tmp/lib"
BAM_CPPFLAGS="-I$ac_bam_path_tmp/include"
BAM_LIB_PARAM="-lbam"
break;
fi
done
dnl overwrite ld flags if we have required special directory with
dnl --with-bam-libdir parameter
if test "$ac_bam_lib_path" != ""; then
BAM_LDFLAGS="-L$ac_bam_lib_path"
fi
CPPFLAGS_SAVED="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $BAM_CPPFLAGS"
export CPPFLAGS
LDFLAGS_SAVED="$LDFLAGS"
LDFLAGS="$LDFLAGS $BAM_LDFLAGS"
export LDFLAGS
if test "$USE_HTSLIB" == "0"; then
AC_LANG_PUSH(C++)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
@%:@include <bam/bam.h>
]], [[]])],[
AC_MSG_RESULT(yes)
succeeded=yes
found_system=yes
],[
])
AC_LANG_POP([C++])
else
AC_LANG_PUSH(C++)
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
@%:@include <htslib/hts.h>
]], [[]])],[
AC_MSG_RESULT(yes)
succeeded=yes
found_system=yes
],[
])
AC_LANG_POP([C++])
fi
if test "$succeeded" != "yes" ; then
AC_MSG_ERROR([[We could not detect the bam libraries. Try installing htslib or libbam, or specifying a path to one with --with-bam=/some/path]])
else
BAM_LIB="$BAM_LIB_PARAM"
AC_SUBST(BAM_CPPFLAGS)
AC_SUBST(BAM_LDFLAGS)
AC_SUBST(BAM_LIB)
AC_DEFINE(HAVE_BAM,,[define if the BAM library is available])
fi
CPPFLAGS="$CPPFLAGS_SAVED"
LDFLAGS="$LDFLAGS_SAVED"
fi
])