Changeset: c2cb389ff8d1 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=c2cb389ff8d1
Modified Files:
        NT/monetdb_config.h.in
        NT/rules.msc
        configure.ag
        sql/backends/monet5/Makefile.ag
        sql/backends/monet5/bam/Makefile.ag
        sql/backends/monet5/bam/README
        testing/Mtest.py.in
Branch: DVframework_bam
Log Message:

use configure (via --with-samtools=...) to find samtools,
and compile sql/backends/monet5/bam/ only if samtools were found.

This is more convenient than editing
sql/backends/monet5/bam/Makefile.ag
by hand ...


diffs (163 lines):

diff --git a/NT/monetdb_config.h.in b/NT/monetdb_config.h.in
--- a/NT/monetdb_config.h.in
+++ b/NT/monetdb_config.h.in
@@ -386,6 +386,9 @@
 /* Define to 1 if you have the `round' function. */
 /* #undef HAVE_ROUND */
 
+/* Define if you have the samtools (providing the bam library) */
+/* #undef HAVE_SAMTOOLS */
+
 /* Define to 1 if you have the `sbrk' function. */
 /* #undef HAVE_SBRK */
 
diff --git a/NT/rules.msc b/NT/rules.msc
--- a/NT/rules.msc
+++ b/NT/rules.msc
@@ -391,6 +391,11 @@ create_winconfig_conds_new_py:
 !ELSE
        $(ECHO) HAVE_RUBYGEM_FALSE='' >> "$(TOPDIR)\winconfig_conds_new.py"
 !ENDIF
+!IFDEF HAVE_SAMTOOLS
+       $(ECHO) HAVE_SAMTOOLS_FALSE='#' >> "$(TOPDIR)\winconfig_conds_new.py"
+!ELSE
+       $(ECHO) HAVE_SAMTOOLS_FALSE='' >> "$(TOPDIR)\winconfig_conds_new.py"
+!ENDIF
 !IFDEF HAVE_SPHINXCLIENT
        $(ECHO) HAVE_SPHINXCLIENT_FALSE='#' >> 
"$(TOPDIR)\winconfig_conds_new.py"
 !ELSE
diff --git a/configure.ag b/configure.ag
--- a/configure.ag
+++ b/configure.ag
@@ -2209,6 +2209,45 @@ AC_SUBST(MSEED_CFLAGS, $MSEED_CFLAGS)
 AC_SUBST(MSEED_LIBS, $MSEED_LIBS)
 AM_CONDITIONAL(HAVE_MSEED, test x"$have_mseed" != xno)
 
+# samtools, only used by sql
+have_samtools="auto"
+AC_ARG_WITH(samtools,
+    AS_HELP_STRING([--with-samtools=DIR],[samtools (providing bam library) are 
installed in DIR]),
+    [have_samtools="$withval"], [have_samtools="auto"])
+if test "x$have_samtools" != xno; then
+
+       case "$have_samtools" in
+       auto|yes)
+           ;;
+       *)
+           SAMTOOLS_CFLAGS="-I$have_samtools/include"
+           SAMTOOLS_LIBS="-L$have_samtools/lib -lbam"
+           ;;
+       esac
+
+       save_CPPFLAGS="$CPPFLAGS"
+       save_LDFLAGS="$LDFLAGS"
+       CPPFLAGS="$CPPFLAGS $SAMTOOLS_CFLAGS"
+       LDFLAGS="$LDFLAGS $SAMTOOLS_LIBS"
+       AC_CHECK_HEADER(bam.h,
+               AC_CHECK_HEADER(bgzf.h,
+                       AC_CHECK_LIB(bam, bam_header_read,
+                               AC_DEFINE(HAVE_SAMTOOLS, 1, [Define if you have 
the samtools (providing the bam library)]),
+                               [ if test "x$have_samtoouls" != xauto; then 
AC_MSG_ERROR([-lbam library not found]); fi; have_samtools=no ],
+                               [-lpthread -lz]),
+                       [ if test "x$have_samtools" != xauto; then 
AC_MSG_ERROR([bgzf.h header not found]); fi; have_samtools=no ]),
+               [ if test "x$have_samtools" != xauto; then AC_MSG_ERROR([bam.h 
header not found]); fi; have_samtools=no ])
+       LDFLAGS="$save_LDFLAGS"
+       CPPFLAGS="$save_CPPFLAGS"
+  if test "x$have_samtools" = "xyes" -o "x$have_samtools" = "xauto"; then
+           SAMTOOLS_CFLAGS=
+           SAMTOOLS_LIBS="-lbam"
+  fi
+fi
+AC_SUBST(SAMTOOLS_CFLAGS, $SAMTOOLS_CFLAGS)
+AC_SUBST(SAMTOOLS_LIBS, $SAMTOOLS_LIBS)
+AM_CONDITIONAL(HAVE_SAMTOOLS, test x"$have_samtools" != xno)
+
 # geos, only used in geom module
 have_geos=auto
 GEOS_INCS=''
diff --git a/sql/backends/monet5/Makefile.ag b/sql/backends/monet5/Makefile.ag
--- a/sql/backends/monet5/Makefile.ag
+++ b/sql/backends/monet5/Makefile.ag
@@ -15,7 +15,7 @@
 # Copyright August 2008-2013 MonetDB B.V.
 # All Rights Reserved.
 
-SUBDIRS = NOT_WIN32?vaults UDF bam LSST ENABLE_DATACELL?datacell 
HAVE_MSEED?miniseed
+SUBDIRS = NOT_WIN32?vaults UDF HAVE_SAMTOOLS?bam LSST ENABLE_DATACELL?datacell 
HAVE_MSEED?miniseed
 
 INCLUDES = ../../include ../../common ../../storage ../../server \
                   ../../../monetdb5/modules/atoms \
diff --git a/sql/backends/monet5/bam/Makefile.ag 
b/sql/backends/monet5/bam/Makefile.ag
--- a/sql/backends/monet5/bam/Makefile.ag
+++ b/sql/backends/monet5/bam/Makefile.ag
@@ -29,7 +29,7 @@ INCLUDES = .. \
        ../../../../common/options \
        ../../../../common/stream \
        ../../../../gdk \
-    -I$(HOME)/Documents/BAM/samtools/include
+       $(SAMTOOLS_CFLAGS)
 
 lib__bam = {
        MODULE
@@ -37,8 +37,7 @@ lib__bam = {
        SOURCES = bamloader.c bamloader.h
        LIBS = ../../../../monetdb5/tools/libmonetdb5 \
                   ../../../../gdk/libbat \
-           -L$(HOME)/Documents/BAM/samtools/lib -lbam
-                  
+       $(SAMTOOLS_LIBS)
 }
 
 headers_mal = {
diff --git a/sql/backends/monet5/bam/README b/sql/backends/monet5/bam/README
--- a/sql/backends/monet5/bam/README
+++ b/sql/backends/monet5/bam/README
@@ -4,26 +4,30 @@ This document describes how to use the c
 
***************************************************************************************************
 Installation
 
***************************************************************************************************
-In order to run the code, samtools has to be installed. To do so, create a 
directory named
+In order to run the code, samtools [1][2] has to be installed. To do so, 
create a directory named
 samtools in some location <samtools_location> and unpack the contents of 
samtools into
 <samtools_location>/samtools. Then, create symbolic links 
<samtools_location>/lib and 
 <samtools_location>/include that both link to <samtools_location>/samtools. 
Now install
 samtools with the compiler flag -fPIC (in my case, I had to alter the by 
samtools provided
 Makefile by setting the constant CFLAGS to -g -Wall -O2 -fPIC.
 
-In order to link samtools to MonetDB, edit sql/backends/monet5/bam/Makefile.ag 
by changing
-$(HOME)/Documents/BAM/ to <samtools_location>.
-
 The bamloader writes messages to a log file. For now, this logfile is 
specified in sql/
 backends/monet5/bam/bamloader.h in the constant LOG_FILE. Change this to a 
filepath of 
 choice. The given directory must exist, while the file does not. If the file 
doesn't
 exist it is automatically created.
 
-That should be enough to compile and install MonetDB. Do so by running the 
bootstrap, 
-configure, make and make install steps described on 
-http://www.monetdb.org/wiki/MonetDB:Building_from_sources
+Then you can compile and install MonetDB with BAM file support using the usual 
sequence
+as described at http://www.monetdb.org/wiki/MonetDB:Building_from_sources ,
+but telling configure where to find your samtools installation, i.e., 
+       bootstrap
+       configure --with-samtools=<samtools_location>
+       make
+       make install
 
 
+[1] http://samtools.sourceforge.net/
+[2] http://en.wikipedia.org/wiki/SAMtools
+
 
 
***************************************************************************************************
 Loading BAM files in the database
diff --git a/testing/Mtest.py.in b/testing/Mtest.py.in
--- a/testing/Mtest.py.in
+++ b/testing/Mtest.py.in
@@ -329,6 +329,7 @@ CONDITIONALS = {
     'HAVE_PYTHON3'         : "@HAVE_PYTHON3_FALSE@",
     'HAVE_RAPTOR'          : "@HAVE_RAPTOR_FALSE@",
     'HAVE_RUBYGEM'         : "@HAVE_RUBYGEM_FALSE@",
+    'HAVE_SAMTOOLS'        : "@HAVE_SAMTOOLS_FALSE@",
     'HAVE_SPHINXCLIENT'    : "@HAVE_SPHINXCLIENT_FALSE@",
     'HAVE_SQL'             : "@HAVE_SQL_FALSE@",
     'HAVE_TESTING'         : "@HAVE_TESTING_FALSE@",
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to