From: Michael R. Crusoe <michael.crusoe@gmail.com>
Subject: Improve build flexibility

Improves hardening and enable cross building
--- bedtools.orig/src/utils/htslib/Makefile
+++ bedtools/src/utils/htslib/Makefile
@@ -22,20 +22,18 @@
 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 # DEALINGS IN THE SOFTWARE.
 
-CC     = gcc
-AR     = ar
-RANLIB = ranlib
+CC     ?= gcc
+AR     ?= ar
+RANLIB ?= ranlib
 
 # Default libraries to link if configure is not used
 htslib_default_libs = -lz -lm -lbz2 -llzma
 
-CPPFLAGS =
 # 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
+CFLAGS   ?= -g -Wall -O2
 EXTRA_CFLAGS_PIC = -fpic
-LDFLAGS  =
 LIBS     = $(htslib_default_libs)
 
 prefix      = /usr/local
@@ -51,7 +49,7 @@
 pkgconfigdir= $(libdir)/pkgconfig
 
 MKDIR_P = mkdir -p
-INSTALL = install -p
+INSTALL ?= install -p
 INSTALL_DATA    = $(INSTALL) -m 644
 INSTALL_DIR     = $(MKDIR_P) -m 755
 INSTALL_LIB     = $(INSTALL_DATA)
--- bedtools.orig/Makefile
+++ bedtools/Makefile
@@ -199,7 +199,7 @@
 
 .PHONY: all
 
-install: all
+install:
 	mkdir -p $(DESTDIR)$(prefix)/bin
 	for file in bin/* ; do \
 		cp -f $$file $(DESTDIR)$(prefix)/bin; \
@@ -225,7 +225,7 @@
 	@test -e src/utils/htslib/config.mk || rm -f src/utils/htslib/config.h
 .PHONY: clean
 
-test: all
+test: 
 	@cd test; bash test.sh
 
 .PHONY: test
