From: "Michael R. Crusoe" <crusoe@debian.org>
Date: Sat, 1 Feb 2020 16:13:23 +0100
Subject: Enable cross building

Forwarded: https://github.com/benedictpaten/sonLib/pull/41
Forwarded: https://github.com/yoheirosen/sublinear-Li-Stephens/pull/7
Forwarded: https://github.com/benedictpaten/sonLib/pull/42
Forwarded: https://github.com/vgteam/cpp_progress_bar/pull/2
Forwarded: https://github.com/vgteam/gfakluge/pull/6
---
 deps/progress_bar/makefile | 11 ++++-------
 deps/sonLib/include.mk     |  3 ++-
 source_me.sh               |  4 ++--
 3 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/deps/progress_bar/makefile b/deps/progress_bar/makefile
index 3d5d8d7..2ab06c1 100644
--- a/deps/progress_bar/makefile
+++ b/deps/progress_bar/makefile
@@ -1,4 +1,4 @@
-CC = g++
+CXX ?= g++
 CPPFLAGS += -std=c++11
 TARGET = progress_bar
 OBJ = main.o progress_bar.o
@@ -6,16 +6,13 @@ OBJ = main.o progress_bar.o
 all : progress_bar
 
 progress_bar : $(OBJ)
-	@echo "<***Linking***> $@"
-	@$(CC) $(CPPFLAGS) $(OBJ) -o $(TARGET)
+	$(CXX) $(LDFLAGS) $(CXXFLAGS) $(CPPFLAGS) $(OBJ) -o $(TARGET) $(LOADLIBES) $(LDLIBS)
 
 main.o : main.cpp
-	@echo "<**Compiling**> $@"
-	@$(CC) $(CPPFLAGS) -c $^
+	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $^
 
 progress_bar.o : progress_bar.cpp
-	@echo "<**Compiling**> $@"
-	@$(CC) $(CPPFLAGS) -c $^
+	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $^
 
 clean :
 	@rm -rf progress_bar $(OBJ)
diff --git a/deps/sonLib/include.mk b/deps/sonLib/include.mk
index 8f52bbd..fef4872 100644
--- a/deps/sonLib/include.mk
+++ b/deps/sonLib/include.mk
@@ -3,6 +3,7 @@ HOSTNAME = $(shell hostname)
 MACH = $(shell uname -m)
 SYS =  $(shell uname -s)
 
+CC ?= gcc
 #C compiler. FIXME: for some reason the cxx variable is used, which
 #typically means C++ compiler.
 ifeq (${CC},cc)
@@ -13,7 +14,7 @@ ifeq (${CC},cc)
   else ifeq ($(SYS),Darwin) #This is to deal with the Mavericks replacing gcc with clang fully
 	cxx = clang -std=c99 
   else
-    cxx = gcc -std=c99
+    cxx = ${CC} -std=c99
   endif
 else
   cxx = ${CC} -std=c99
diff --git a/source_me.sh b/source_me.sh
index 0bb948c..6a75fd2 100755
--- a/source_me.sh
+++ b/source_me.sh
@@ -9,8 +9,8 @@ export LD_INCLUDE_PATH=`pwd`/include:$LD_INCLUDE_PATH
 export CFLAGS="-I $(pwd)/include ${CFLAGS}"
 export CXXFLAGS="-I $(pwd)/include -I$(pwd)/include/dynamic ${CXXFLAGS}"
 export PATH=`pwd`/bin:`pwd`/scripts:"$PATH"
-export CC=$(which gcc)
-export CXX=$(which g++)
+export CC="${CC:=gcc}"
+export CXX="${CXX:=g++}"
 
 #
 #  disable until file arguments work as in normal bash :(
