Include Henry's out-of-memory check.
authorDiane Trout <diane@caltech.edu>
Mon, 24 Oct 2011 21:52:53 +0000 (14:52 -0700)
committerDiane Trout <diane@caltech.edu>
Mon, 24 Oct 2011 21:52:53 +0000 (14:52 -0700)
Builld samtools with a shared library

debian/control
debian/libbam1.install [new file with mode: 0644]
debian/libbam1.postinst [new file with mode: 0644]
debian/libbam1.postrm [new file with mode: 0644]
debian/patches/build-so [new file with mode: 0644]
debian/patches/razip-oom-check [new file with mode: 0644]
debian/patches/series
debian/patches/use-shlib [new file with mode: 0644]
debian/rules
debian/shlibs.libbam1 [new file with mode: 0644]

index f6080865fb7608e24755aca06e94e3e9cce91fbc..8b96cd1bf65d474675ab8b126de6627717107be8 100644 (file)
@@ -25,7 +25,7 @@ Package: libbam-dev
 Architecture: any
 Section: libdevel
 Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: manipulates nucleotide sequence alignments in BAM or SAM format 
+Description: manipulates nucleotide sequence alignments in BAM or SAM format
  The BAM library provides I/O and various operations on manipulating nucleotide
  sequence alignments in the BAM (Binary Alignment/Mapping) or SAM (Sequence
  Alignment/Map) format. It now supports importing from or exporting to SAM,
@@ -33,3 +33,14 @@ Description: manipulates nucleotide sequence alignments in BAM or SAM format
  with a specified region.
  .
  This library is part SAMtools.
+
+Package: libbam1
+Architecture: any
+Section: libdevel
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: manipulates nucleotide sequence alignments in BAM or SAM format
+ The BAM library provides I/O and various operations on manipulating nucleotide
+ sequence alignments in the BAM (Binary Alignment/Mapping) or SAM (Sequence
+ Alignment/Map) format. It now supports importing from or exporting to SAM,
+ sorting, merging, generating pileup, and quickly retrieval of reads overlapped
+ with a specified region.
diff --git a/debian/libbam1.install b/debian/libbam1.install
new file mode 100644 (file)
index 0000000..5bdd3a0
--- /dev/null
@@ -0,0 +1 @@
+libbam.so.1    usr/lib
diff --git a/debian/libbam1.postinst b/debian/libbam1.postinst
new file mode 100644 (file)
index 0000000..c120531
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+# postinst script for libbam1
+set -e
+
+if [ "$1" = "configure" ]; then
+       ldconfig
+fi
diff --git a/debian/libbam1.postrm b/debian/libbam1.postrm
new file mode 100644 (file)
index 0000000..345d667
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/sh
+# postinst script for libbam1
+set -e
+
+if [ "$1" = "remove" ]; then
+       ldconfig
+fi
diff --git a/debian/patches/build-so b/debian/patches/build-so
new file mode 100644 (file)
index 0000000..ffe66d2
--- /dev/null
@@ -0,0 +1,38 @@
+diff --git a/Makefile b/Makefile
+index db18333..926059b 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1,5 +1,5 @@
+ CC=                   gcc
+-CFLAGS=               -g -Wall -O2 #-m64 #-arch ppc
++CFLAGS=               -g -Wall -O2 -fPIC #-m64 #-arch ppc
+ DFLAGS=               -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_USE_KNETFILE -D_CURSES_LIB=1
+ KNETFILE_O=   knetfile.o
+ LOBJS=                bgzf.o kstring.o bam_aux.o bam.o bam_import.o sam.o bam_index.o \
+@@ -35,13 +35,13 @@ all:$(PROG)
+ .PHONY:all lib clean cleanlocal
+ .PHONY:all-recur lib-recur clean-recur cleanlocal-recur install-recur
+-lib:libbam.a
++lib:libbam.so.1
+ libbam.a:$(LOBJS)
+               $(AR) -csru $@ $(LOBJS)
+ samtools:lib-recur $(AOBJS)
+-              $(CC) $(CFLAGS) -o $@ $(AOBJS) -Lbcftools $(LIBPATH) libbam.a -lbcf $(LIBCURSES) -lm -lz
++              $(CC) $(CFLAGS) -o $@ $(AOBJS) -Lbcftools $(LIBPATH) -L. -lbam -lbcf $(LIBCURSES) -lm -lz
+ razip:razip.o razf.o $(KNETFILE_O)
+               $(CC) $(CFLAGS) -o $@ razf.o razip.o $(KNETFILE_O) -lz
+@@ -75,8 +75,9 @@ faidx_main.o:faidx.h razf.h
+ libbam.1.dylib-local:$(LOBJS)
+               libtool -dynamic $(LOBJS) -o libbam.1.dylib -lc -lz
+-libbam.so.1-local:$(LOBJS)
++libbam.so.1:$(LOBJS)
+               $(CC) -shared -Wl,-soname,libbam.so -o libbam.so.1 $(LOBJS) -lc -lz
++              ln -s $@ libbam.so
+ dylib:
+               @$(MAKE) cleanlocal; \
diff --git a/debian/patches/razip-oom-check b/debian/patches/razip-oom-check
new file mode 100644 (file)
index 0000000..d4cc299
--- /dev/null
@@ -0,0 +1,18 @@
+--- a/razip.c  2011-10-20 11:05:21.020305754 -0700
++++ b/razip.c  2011-10-20 11:48:26.208271871 -0700
+@@ -79,7 +79,13 @@
+                       if(pstdout){
+                               f_dst = fileno(stdout);
+                       } else {
+-                              char *name = malloc(sizeof(strlen(argv[optind]) + 5));
++                              char *name = (char *)malloc(sizeof(char) * (strlen(argv[optind]) + 5));
++                              if (name == NULL)
++                              {
++                                      fprintf(stderr, " -- Out of memory --\n");
++                                      return 1;
++                              }
++
+                               strcpy(name, argv[optind]);
+                               strcat(name, ".rz");
+                               f_dst = write_open(name, is_forced);
+
index ed908a5af6e69e8225f62b0bf8c1195766ac0c2d..180fd32a6eb585c95944e7bdca224122f57646eb 100644 (file)
@@ -1 +1,3 @@
 no-pileup-tests.patch
+razip-oom-check
+build-so
\ No newline at end of file
diff --git a/debian/patches/use-shlib b/debian/patches/use-shlib
new file mode 100644 (file)
index 0000000..e747a11
--- /dev/null
@@ -0,0 +1,38 @@
+Index: samtools-0.1.17/Makefile
+===================================================================
+--- samtools-0.1.17.orig/Makefile      2011-07-25 21:00:44.145494440 -0700
++++ samtools-0.1.17/Makefile   2011-07-25 21:09:46.265494761 -0700
+@@ -1,5 +1,5 @@
+ CC=                   gcc
+-CFLAGS=               -g -Wall -O2 #-m64 #-arch ppc
++CFLAGS=               -g -Wall -O2 -fPIC #-m64 #-arch ppc
+ DFLAGS=               -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_USE_KNETFILE -D_CURSES_LIB=1
+ KNETFILE_O=   knetfile.o
+ LOBJS=                bgzf.o kstring.o bam_aux.o bam.o bam_import.o sam.o bam_index.o \
+@@ -35,13 +35,13 @@
+ .PHONY:all lib clean cleanlocal
+ .PHONY:all-recur lib-recur clean-recur cleanlocal-recur install-recur
+-lib:libbam.a
++lib:libbam.so.1
+ libbam.a:$(LOBJS)
+               $(AR) -csru $@ $(LOBJS)
+ samtools:lib-recur $(AOBJS)
+-              $(CC) $(CFLAGS) -o $@ $(AOBJS) -Lbcftools $(LIBPATH) libbam.a -lbcf $(LIBCURSES) -lm -lz
++              $(CC) $(CFLAGS) -o $@ $(AOBJS) -Lbcftools $(LIBPATH) -L. -lbam -lbcf $(LIBCURSES) -lm -lz
+ razip:razip.o razf.o $(KNETFILE_O)
+               $(CC) $(CFLAGS) -o $@ razf.o razip.o $(KNETFILE_O) -lz
+@@ -75,8 +75,9 @@
+ libbam.1.dylib-local:$(LOBJS)
+               libtool -dynamic $(LOBJS) -o libbam.1.dylib -lc -lz
+-libbam.so.1-local:$(LOBJS)
++libbam.so.1:$(LOBJS)
+               $(CC) -shared -Wl,-soname,libbam.so -o libbam.so.1 $(LOBJS) -lc -lz
++              ln -s $@ libbam.so
+ dylib:
+               @$(MAKE) cleanlocal; \
index e4a25660cd642d4782f6dd5d2b8e1932f56d641b..b3cf88ddbee62a9a66e7f09f47ef657cdca41c11 100755 (executable)
@@ -7,7 +7,7 @@ include /usr/share/cdbs/1/rules/patchsys-quilt.mk
 CFLAGS += -fPIC
 
 DEB_MAKE_BUILD_TARGET = all all-recur razip lib
-DEB_MAKE_CHECK_TARGET = -C examples all
+DEB_MAKE_CHECK_TARGET = LD_LIBRARY_PATH=$(CURDIR) -C examples all
 
 DEB_DH_BUILDDEB_ARGS = -- -Z=xz
 
diff --git a/debian/shlibs.libbam1 b/debian/shlibs.libbam1
new file mode 100644 (file)
index 0000000..90480ec
--- /dev/null
@@ -0,0 +1 @@
+libbam 1 samtools (>= 1.1.17)