From b014034d5c0efa7c4cb3eb9c1f0913c09cdce728 Mon Sep 17 00:00:00 2001 From: Milot Mirdita Date: Sun, 21 Mar 2021 18:33:55 +0100 Subject: [PATCH] Fix wrong include and refactor Makefile to build cleanly on macOS (#146) * Fix wrong included file * Refactor makefile and fix it to build cleanly on macOS --- src/Makefile | 32 ++++++++++++++++++++++++-------- src/ctime.cpp | 2 +- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/Makefile b/src/Makefile index 8622014..55bb38e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,13 +1,29 @@ -C++ = g++ -CFLAGS = -c -g -O3 -pedantic -std=c++11 -fopenmp +CXXFLAGS := -c -g -O3 -pedantic -std=c++11 -all: kmer_counter +UNAME_S := $(shell uname -s) +ifeq ($(UNAME_S),Darwin) + CXX := clang++ +else + CXX := g++ +endif -kmer_counter: kmer2read_distr.o ctime.o taxonomy.o kraken_processing.o - $(C++) -o kmer2read_distr ctime.o kmer2read_distr.o taxonomy.o kraken_processing.o -lgomp +IS_CLANG := $(findstring clang++,$(CXX)) +ifeq ($(IS_CLANG),clang++) + CXXFLAGS += -Xpreprocessor -fopenmp + LDFLAGS += -lomp +else + CXXFLAGS += -fopenmp + LDFLAGS += -lgomp +endif + +all: kmer2read_distr + +kmer2read_distr: kmer2read_distr.o ctime.o taxonomy.o kraken_processing.o + $(CXX) -o $@ $^ $(LDFLAGS) clean: - rm -f *.o + rm -f *.o + +%.o: %.cpp + $(CXX) $(CXXFLAGS) $< -%.o: %.cpp - $(C++) $(CFLAGS) $*.cpp diff --git a/src/ctime.cpp b/src/ctime.cpp index e79081d..eee1395 100644 --- a/src/ctime.cpp +++ b/src/ctime.cpp @@ -19,7 +19,7 @@ * Jennifer Lu, jlu26@jhmi.edu * Updated: 2018/09/06 */ -#include "time.h" +#include "ctime.h" /************************************************************************* * METHOD: timeval_subtract