| 1 |
# This makefile will build the C++ components of Porechop. |
| 2 |
|
| 3 |
# Example commands: |
| 4 |
# make (build in release mode) |
| 5 |
# make debug (build in debug mode) |
| 6 |
# make clean (deletes *.o files, which aren't required to run the aligner) |
| 7 |
# make distclean (deletes *.o files and the *.so file, which is required to run the aligner) |
| 8 |
# make CXX=g++-5 (build with a particular compiler) |
| 9 |
# make CXXFLAGS="-Werror -g3" (build with particular compiler flags) |
| 10 |
|
| 11 |
|
| 12 |
# CXX and CXXFLAGS can be overridden by the user. |
| 13 |
CXX ?= g++ |
| 14 |
CXXFLAGS ?= -Wall -Wextra -pedantic -mtune=native |
| 15 |
|
| 16 |
# These flags are required for the build to work. |
| 17 |
FLAGS = -std=c++14 -Iporechop/include -fPIC |
| 18 |
LDFLAGS = -shared |
| 19 |
|
| 20 |
# Different debug/optimisation levels for debug/release builds. |
| 21 |
DEBUGFLAGS = -DSEQAN_ENABLE_DEBUG=1 -g |
| 22 |
RELEASEFLAGS = -O3 -D NDEBUG |
| 23 |
|
| 24 |
TARGET = porechop/cpp_functions.so |
| 25 |
SHELL = /bin/sh |
| 26 |
SOURCES = $(shell find porechop -name "*.cpp") |
| 27 |
HEADERS = $(shell find porechop -name "*.h") |
| 28 |
OBJECTS = $(SOURCES:.cpp=.o) |
| 29 |
|
| 30 |
# Linux needs '-soname' while Mac needs '-install_name' |
| 31 |
PLATFORM = $(shell uname) |
| 32 |
ifeq ($(PLATFORM), Darwin) |
| 33 |
SONAME = -install_name |
| 34 |
else |
| 35 |
SONAME = -soname |
| 36 |
endif |
| 37 |
|
| 38 |
.PHONY: release |
| 39 |
release: FLAGS+=$(RELEASEFLAGS) |
| 40 |
release: $(TARGET) |
| 41 |
|
| 42 |
.PHONY: debug |
| 43 |
debug: FLAGS+=$(DEBUGFLAGS) |
| 44 |
debug: $(TARGET) |
| 45 |
|
| 46 |
$(TARGET): $(OBJECTS) |
| 47 |
$(CXX) $(FLAGS) $(CXXFLAGS) $(LDFLAGS) -o $(TARGET) $(OBJECTS) |
| 48 |
|
| 49 |
clean: |
| 50 |
$(RM) $(OBJECTS) |
| 51 |
|
| 52 |
distclean: clean |
| 53 |
$(RM) $(TARGET) |
| 54 |
|
| 55 |
%.o: %.cpp $(HEADERS) |
| 56 |
$(CXX) $(FLAGS) $(CXXFLAGS) -c -o $@ $< |