From 5c8af8862f403da4395a94b522fd17ebe1dc2cda Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sat, 7 Oct 2017 16:31:21 +0200 Subject: [PATCH 1/5] Makefile: Remove -march=native -march=native assumes that we build the program on the same system that we are going to run it, which can't be assument to always be true. The compiler might emit instructions which are not available on the target system. This option can be provided by the caller of the Makefile if needed. E.g.: make CXXFLAGS="-mtune=native" --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d94a391..746fc34 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ BINDIR ?= $(PREFIX)/bin BIN = $(DESTDIR)/$(BINDIR) # With pthreads -override CXXFLAGS+= -DMAXHITS=1000 -DTHREAD -funroll-loops -Lsamtools -Isamtools -Lgzstream -Igzstream -O3 -m64 -march=native -g +override CXXFLAGS+= -DMAXHITS=1000 -DTHREAD -funroll-loops -Lsamtools -Isamtools -Lgzstream -Igzstream -O3 -m64 -g # Without pthreads -#override CXXFLAGS+= -DMAXHITS=1000 -funroll-loops -Lsamtools -Isamtools -Lgzstream -Igzstream -O3 -m64 -march=native +#override CXXFLAGS+= -DMAXHITS=1000 -funroll-loops -Lsamtools -Isamtools -Lgzstream -Igzstream -O3 -m64 THREAD= -lpthread From 7650bcb87dc2cd64efb5b7f2b4013739f74ddfd7 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sat, 7 Oct 2017 16:59:21 +0200 Subject: [PATCH 2/5] Makefile: Add EXTRA_CXXFLAGS EXTRA_CXXFLAGS allow the caller to overwrite CXXFLAGS defined in the makefile. E.g.: make EXTRA_CXXFLAGS="-O0" --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 746fc34..da9a60e 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ BINDIR ?= $(PREFIX)/bin BIN = $(DESTDIR)/$(BINDIR) # With pthreads -override CXXFLAGS+= -DMAXHITS=1000 -DTHREAD -funroll-loops -Lsamtools -Isamtools -Lgzstream -Igzstream -O3 -m64 -g +override CXXFLAGS+= -DMAXHITS=1000 -DTHREAD -funroll-loops -Lsamtools -Isamtools -Lgzstream -Igzstream -O3 -m64 -g $(EXTRA_CXXFLAGS) # Without pthreads -#override CXXFLAGS+= -DMAXHITS=1000 -funroll-loops -Lsamtools -Isamtools -Lgzstream -Igzstream -O3 -m64 +#override CXXFLAGS+= -DMAXHITS=1000 -funroll-loops -Lsamtools -Isamtools -Lgzstream -Igzstream -O3 -m64 $(EXTRA_CXXFLAGS) THREAD= -lpthread From d36bd752be64a902e32f06601ebc6c4d4ba5583e Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sat, 7 Oct 2017 17:01:09 +0200 Subject: [PATCH 3/5] Makefile: Remove -g default This flags can be specified by the caller as needed. E.g: make EXTRA_CXXFLAGS="-g -O0" --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index da9a60e..4ff6807 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ BINDIR ?= $(PREFIX)/bin BIN = $(DESTDIR)/$(BINDIR) # With pthreads -override CXXFLAGS+= -DMAXHITS=1000 -DTHREAD -funroll-loops -Lsamtools -Isamtools -Lgzstream -Igzstream -O3 -m64 -g $(EXTRA_CXXFLAGS) +override CXXFLAGS+= -DMAXHITS=1000 -DTHREAD -funroll-loops -Lsamtools -Isamtools -Lgzstream -Igzstream -O3 -m64 $(EXTRA_CXXFLAGS) # Without pthreads #override CXXFLAGS+= -DMAXHITS=1000 -funroll-loops -Lsamtools -Isamtools -Lgzstream -Igzstream -O3 -m64 $(EXTRA_CXXFLAGS) From 6900deb6e4c4009072b15b9f9534d165d6186275 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sat, 7 Oct 2017 17:19:12 +0200 Subject: [PATCH 4/5] Makefile: Do not clean up in build target --- Makefile | 1 - 1 file changed, 1 deletion(-) diff --git a/Makefile b/Makefile index 4ff6807..b3d5b41 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,6 @@ bsmap: $(OBJS1) (cd samtools; make) (cd gzstream; make) $(CXX) $(CXXFLAGS) $^ -o $@ $(THREAD) -lbam -lz -lgzstream - rm -f *.o clean: rm -f *.o *~ bsmap From a8f3a4bc590002659ffb0cc3e9565bbf771adbc4 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sun, 8 Oct 2017 17:07:57 +0200 Subject: [PATCH 5/5] Makefile: Correct recursive usage Using $(MAKE) instead of "make", is special for gnu make. It correctly processes Makeflags and parallel execution. --- Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index b3d5b41..d248b9d 100644 --- a/Makefile +++ b/Makefile @@ -14,14 +14,14 @@ all: bsmap %.o:%.cpp $(CXX) $(CXXFLAGS) -c $< -o $@ bsmap: $(OBJS1) - (cd samtools; make) - (cd gzstream; make) + $(MAKE) -C samtools + $(MAKE) -C gzstream $(CXX) $(CXXFLAGS) $^ -o $@ $(THREAD) -lbam -lz -lgzstream clean: rm -f *.o *~ bsmap - (cd samtools; make clean) - (cd gzstream; make clean) + $(MAKE) -C samtools clean + $(MAKE) -C gzstream clean install: install -d $(BIN) install ./bsmap $(BIN)