From: Michael R. Crusoe <michael.crusoe@gmail.com>
Subject: Don't overwrite CXXFLAGS & include missing CPPFLAGS as needed
Index: bedtools/Makefile
===================================================================
--- bedtools.orig/Makefile
+++ bedtools/Makefile
@@ -22,9 +22,9 @@ export SRC_DIR	= src
 export UTIL_DIR	= src/utils
 export CXX		= g++
 ifeq ($(DEBUG),1)
-export CXXFLAGS = -Wconversion -Wall -Wextra -DDEBUG -D_DEBUG -g -O0 -D_FILE_OFFSET_BITS=64 -DWITH_HTS_CB_API $(INCLUDES)
+export CXXFLAGS += -Wconversion -Wall -Wextra -DDEBUG -D_DEBUG -g -O0 -D_FILE_OFFSET_BITS=64 -DWITH_HTS_CB_API $(INCLUDES)
 else
-export CXXFLAGS = -g -Wall -O2 -D_FILE_OFFSET_BITS=64 -DWITH_HTS_CB_API $(INCLUDES)
+export CXXFLAGS += -g -Wall -O2 -D_FILE_OFFSET_BITS=64 -DWITH_HTS_CB_API $(INCLUDES)
 endif
 
 # If the user has specified to do so, tell the compile to use rand() (instead of mt19937).
Index: bedtools/src/complementFile/Makefile
===================================================================
--- bedtools.orig/src/complementFile/Makefile
+++ bedtools/src/complementFile/Makefile
@@ -42,7 +42,7 @@ all: $(BUILT_OBJECTS)
 
 $(BUILT_OBJECTS): $(SOURCES)
 	@echo "  * compiling" $(*F).cpp
-	$(CCPREFIX) $(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(DFLAGS) $(INCLUDES)
+	$(CCPREFIX) $(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(DFLAGS) $(INCLUDES)
 	
 clean:
 	@echo "Cleaning up."
Index: bedtools/src/coverageFile/Makefile
===================================================================
--- bedtools.orig/src/coverageFile/Makefile
+++ bedtools/src/coverageFile/Makefile
@@ -38,7 +38,7 @@ all: $(BUILT_OBJECTS)
 
 $(BUILT_OBJECTS): $(SOURCES)
 	@echo "  * compiling" $(*F).cpp
-	$(CCPREFIX) $(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(DFLAGS) $(INCLUDES)
+	$(CCPREFIX) $(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(DFLAGS) $(INCLUDES)
 
 clean:
 	@echo "Cleaning up."
Index: bedtools/src/subtractFile/Makefile
===================================================================
--- bedtools.orig/src/subtractFile/Makefile
+++ bedtools/src/subtractFile/Makefile
@@ -40,7 +40,7 @@ all: $(BUILT_OBJECTS)
 
 $(BUILT_OBJECTS): $(SOURCES)
 	@echo "  * compiling" $(*F).cpp
-	$(CCPREFIX) $(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(DFLAGS) $(INCLUDES)
+	$(CCPREFIX) $(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(DFLAGS) $(INCLUDES)
 	
 clean:
 	@echo "Cleaning up."
Index: bedtools/src/utils/ToolBase/Makefile
===================================================================
--- bedtools.orig/src/utils/ToolBase/Makefile
+++ bedtools/src/utils/ToolBase/Makefile
@@ -30,7 +30,7 @@ BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%
 
 $(BUILT_OBJECTS): $(SOURCES)
 	@echo "  * compiling" $(*F).cpp
-	$(CCPREFIX) $(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES)
+	$(CCPREFIX) $(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES)
 
 $(EXT_OBJECTS):
 	@$(MAKE) --no-print-directory -C $(INCLUDES)
@@ -39,4 +39,4 @@ clean:
 	@echo "Cleaning up."
 	@rm -f $(OBJ_DIR)/ToolBase.o 
 
-.PHONY: clean
\ No newline at end of file
+.PHONY: clean
Index: bedtools/src/utils/driver/Makefile
===================================================================
--- bedtools.orig/src/utils/driver/Makefile
+++ bedtools/src/utils/driver/Makefile
@@ -85,7 +85,7 @@ all: $(BUILT_OBJECTS)
 
 $(BUILT_OBJECTS): $(SOURCES)
 	@echo "  * compiling" $(*F).cpp
-	$(CCPREFIX) $(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(DFLAGS) $(INCLUDES)
+	$(CCPREFIX) $(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(DFLAGS) $(INCLUDES)
 	
 clean:
 	@echo "Cleaning up."
