From e2c713f6d93dde9efff4a3dbeb76344ba9aeabee Mon Sep 17 00:00:00 2001 From: Jason Bacon Date: Sun, 24 Jan 2021 08:10:40 -0600 Subject: [PATCH 1/2] Minor patches for easier porting --- Makefile | 13 ++++++++----- src/utils/htslib/Makefile | 15 +++++++++------ 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index a3b3baa4a..4f54f9a84 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,8 @@ # (c) 2009 Aaron Quinlan # ========================== -SHELL := /bin/bash -e +# Use sh for portability and avoid bash extensions in shell commands +SHELL := /bin/sh -e VERSION_FILE=./src/utils/version/version_git.h RELEASED_VERSION_FILE=./src/utils/version/version_release.txt @@ -21,7 +22,8 @@ OBJ_DIR = obj BIN_DIR = bin SRC_DIR = src -CXX = g++ +# Default if not provided via the environment or make args +CXX ?= g++ ifeq ($(DEBUG),1) BT_CPPFLAGS = -DDEBUG -D_DEBUG -D_FILE_OFFSET_BITS=64 -DWITH_HTS_CB_API $(INCLUDES) @@ -41,7 +43,8 @@ endif BT_LDFLAGS = BT_LIBS = -lz -lm -lbz2 -llzma -lpthread -prefix ?= /usr/local +# Default if not provided via the environment or make args +PREFIX ?= /usr/local SUBDIRS = $(SRC_DIR)/annotateBed \ $(SRC_DIR)/bamToBed \ @@ -197,9 +200,9 @@ $(BIN_DIR)/intersectBed: | $(BIN_DIR) .PHONY: all install: all - mkdir -p $(DESTDIR)$(prefix)/bin + mkdir -p $(DESTDIR)$(PREFIX)/bin for file in bin/* ; do \ - cp -f $$file $(DESTDIR)$(prefix)/bin; \ + cp -f $$file $(DESTDIR)$(PREFIX)/bin; \ done print_banner: diff --git a/src/utils/htslib/Makefile b/src/utils/htslib/Makefile index 2931898ea..5d2bc4266 100644 --- a/src/utils/htslib/Makefile +++ b/src/utils/htslib/Makefile @@ -22,20 +22,23 @@ # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER # DEALINGS IN THE SOFTWARE. -CC = gcc -AR = ar -RANLIB = ranlib +# Defaults if not provided by the environment or make args +CC ?= gcc +AR ?= ar +RANLIB ?= ranlib # Default libraries to link if configure is not used htslib_default_libs = -lz -lm -lbz2 -llzma -CPPFLAGS = +# Defaults if not provided by the environment or make args +CPPFLAGS ?= +CFLAGS ?= -g -Wall -O2 +LDFLAGS ?= + # TODO: probably update cram code to make it compile cleanly with -Wc++-compat # For testing strict C99 support add -std=c99 -D_XOPEN_SOURCE=600 #CFLAGS = -g -Wall -O2 -pedantic -std=c99 -D_XOPEN_SOURCE=600 -D__FUNCTION__=__func__ -CFLAGS = -g -Wall -O2 EXTRA_CFLAGS_PIC = -fpic -LDFLAGS = LIBS = $(htslib_default_libs) prefix = /usr/local From 9f5c8c982e7c3aec7f291f5fcd73090312f4d0a0 Mon Sep 17 00:00:00 2001 From: Jason Bacon Date: Sun, 24 Jan 2021 12:18:28 -0600 Subject: [PATCH 2/2] Simple patch to silence most compiler warnings --- src/utils/BamTools/include/SamHeader.hpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/utils/BamTools/include/SamHeader.hpp b/src/utils/BamTools/include/SamHeader.hpp index a4bdd5ddd..c9340bafd 100644 --- a/src/utils/BamTools/include/SamHeader.hpp +++ b/src/utils/BamTools/include/SamHeader.hpp @@ -7,6 +7,7 @@ #include #include #include +#include #ifdef WITH_HTS_CB_API @@ -29,7 +30,11 @@ namespace htslib_future { ops.cb_data = buffer; samFile* fp = hts_open_callback(NULL, &ops, "w"); - sam_hdr_write(fp, hdr); + if ( sam_hdr_write(fp, hdr) != 0 ) + { + fputs("sam_hdr_rebuild: Error: sam_hdr_write() failed.\n", stderr); + exit(EX_IOERR); + } hts_close(fp);