diff options
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 96 |
1 files changed, 64 insertions, 32 deletions
diff --git a/Makefile b/Makefile index 176dd2c..f8bacbf 100644 --- a/Makefile +++ b/Makefile @@ -10,13 +10,13 @@ # # Examples: # -# Make GEMMA on Linux with OPENBLAS support: +# Make GEMMA on Linux without OPENBLAS support: # -# make WITH_OPENBLAS=1 +# make WITH_OPENBLAS= # # Disable debug info and checks (slightly faster release mode) # -# make WITH_OPENBLAS=1 DEBUG= +# make DEBUG= # # Force static compilation # @@ -26,22 +26,35 @@ # # make check # +# Run quick (development) tests with +# +# make fast-check +# +# Run full (lengthy) tests with +# +# make check-all +# # See also the INSTALL.md document in the source tree at # # https://github.com/genetics-statistics/GEMMA/blob/master/INSTALL.md +GEMMA_VERSION = $(shell cat ./VERSION) + # Set this variable to either LNX or MAC SYS = LNX # LNX|MAC (Linux is the default) # Leave blank after "=" to disable; put "= 1" to enable -DIST_NAME = gemma-0.97.3 -DEBUG = 1 # DEBUG mode, set DEBUG=0 for a release +DIST_NAME = gemma-$(GEMMA_VERSION) +DEBUG = 1 # DEBUG mode, set DEBUG=0 for a release SHOW_COMPILER_WARNINGS = -WITH_LAPACK = 1 -WITH_OPENBLAS = # Defaults to LAPACK - OPENBLAS may be faster -FORCE_STATIC = # Static linking of libraries -GCC_FLAGS = -O3 # extra flags -Wl,--allow-multiple-definition -TRAVIS_CI = # used by TRAVIS for testing -EIGEN_INCLUDE_PATH=/usr/include/eigen3 +WITH_OPENBLAS = 1 # Without OpenBlas uses LAPACK +WITH_LAPACK = # Force linking LAPACK (if OpenBlas lacks it) +WITH_GSLCBLAS = # Force linking gslcblas (if OpenBlas lacks it) +OPENBLAS_LEGACY = # Using older OpenBlas +FORCE_STATIC = # Static linking of libraries +GCC_FLAGS = -Wall -O3 -std=gnu++11 # extra flags -Wl,--allow-multiple-definition +TRAVIS_CI = # used by TRAVIS for testing +EIGEN_INCLUDE_PATH = /usr/include/eigen3 +OPENBLAS_INCLUDE_PATH = /usr/local/opt/openblas/include # -------------------------------------------------------------------- # Edit below this line with caution @@ -58,15 +71,26 @@ else CPP = g++ endif -ifdef OPENBLAS - WITH_LAPACK = # OPENBLAS usually includes LAPACK +ifeq ($(CPP), clang++) + # macOS Homebrew settings (as used on Travis-CI) + GCC_FLAGS=-O3 -std=c++11 -stdlib=libc++ -isystem/$(OPENBLAS_INCLUDE_PATH) -isystem//usr/local/include/eigen3 -Wl,-L/usr/local/opt/openblas/lib +endif + +ifdef WITH_OPENBLAS + OPENBLAS=1 + # WITH_LAPACK = # OPENBLAS usually includes LAPACK + CPPFLAGS += -DOPENBLAS -isystem/$(OPENBLAS_INCLUDE_PATH) + ifdef OPENBLAS_LEGACY + # Legacy version (mostly for Travis-CI) + CPPFLAGS += -DOPENBLAS_LEGACY + endif endif ifdef DEBUG - CPPFLAGS = -g $(GCC_FLAGS) -std=gnu++11 -isystem/$(EIGEN_INCLUDE_PATH) -Icontrib/catch-1.9.7 -Isrc + CPPFLAGS += -g $(GCC_FLAGS) -isystem/$(EIGEN_INCLUDE_PATH) -Icontrib/catch-1.9.7 -Isrc else # release mode - CPPFLAGS = -DNDEBUG $(GCC_FLAGS) -std=gnu++11 -isystem/$(EIGEN_INCLUDE_PATH) -Icontrib/catch-1.9.7 -Isrc + CPPFLAGS += -DNDEBUG $(GCC_FLAGS) -isystem/$(EIGEN_INCLUDE_PATH) -Icontrib/catch-1.9.7 -Isrc endif ifdef SHOW_COMPILER_WARNINGS @@ -74,27 +98,30 @@ ifdef SHOW_COMPILER_WARNINGS endif ifndef FORCE_STATIC - LIBS = -lgsl -lgslcblas -pthread -lz + LIBS = -lgsl -lopenblas -pthread -lz + ifdef WITH_GSLCBLAS + LIBS += -lgslcblas + else + LIBS += -lgfortran -lquadmath + endif else ifndef TRAVIS_CI # Travis static compile we cheat a little CPPFLAGS += -static endif endif -OUTPUT = $(BIN_DIR)/gemma - -SOURCES = $(SRC_DIR)/main.cpp +.PHONY: all -HDR = +OUTPUT = $(BIN_DIR)/gemma # Detailed libary paths, D for dynamic and S for static -LIBS_LNX_D_LAPACK = -llapack -LIBS_LNX_D_BLAS = -lblas -LIBS_LNX_D_OPENBLAS = -lopenblas +ifdef WITH_LAPACK + LIBS_LNX_D_LAPACK = -llapack +endif LIBS_MAC_D_LAPACK = -framework Accelerate # LIBS_LNX_S_LAPACK = /usr/lib/libgsl.a /usr/lib/libgslcblas.a /usr/lib/lapack/liblapack.a -lz -LIBS_LNX_S_LAPACK = /usr/lib/lapack/liblapack.a -lgfortran /usr/lib/atlas-base/libatlas.a /usr/lib/libblas/libblas.a -Wl,--allow-multiple-definition +# LIBS_LNX_S_LAPACK = /usr/lib/lapack/liblapack.a -lgfortran /usr/lib/atlas-base/libatlas.a /usr/lib/libblas/libblas.a -Wl,--allow-multiple-definition ifdef WITH_LAPACK ifeq ($(SYS), MAC) @@ -102,7 +129,7 @@ ifdef WITH_LAPACK else ifndef FORCE_STATIC ifdef WITH_OPENBLAS - LIBS += $(LIBS_LNX_D_OPENBLAS) + LIBS += -lopenblas else LIBS += $(LIBS_LNX_D_BLAS) endif @@ -113,7 +140,7 @@ ifdef WITH_LAPACK endif endif -HDR = $(wildcard src/*.h) +HDR = $(wildcard src/*.h) ./src/version.h SOURCES = $(wildcard src/*.cpp) # all @@ -121,17 +148,20 @@ OBJS = $(SOURCES:.cpp=.o) all: $(OUTPUT) +./src/version.h: + ./scripts/gen_version_info.sh > src/version.h + $(OUTPUT): $(OBJS) $(CPP) $(CPPFLAGS) $(OBJS) $(LIBS) -o $(OUTPUT) -$(OBJS) : $(HDR) +$(OBJS): $(HDR) -.cpp.o: - $(CPP) $(CPPFLAGS) $(HEADERS) -c $*.cpp -o $*.o .SUFFIXES : .cpp .c .o $(SUFFIXES) -unittests: all contrib/catch-1.9.7/catch.hpp $(TEST_SRC_DIR)/unittests-main.o $(TEST_SRC_DIR)/unittests-math.o +./bin/unittests-gemma: contrib/catch-1.9.7/catch.hpp $(TEST_SRC_DIR)/unittests-main.o $(TEST_SRC_DIR)/unittests-math.o $(OBJS) $(CPP) $(CPPFLAGS) $(TEST_SRC_DIR)/unittests-main.o $(TEST_SRC_DIR)/unittests-math.o $(filter-out src/main.o, $(OBJS)) $(LIBS) -o ./bin/unittests-gemma + +unittests: ./bin/unittests-gemma ./bin/unittests-gemma fast-check: all unittests @@ -154,16 +184,18 @@ check: fast-check slow-check check-all: check lengthy-check clean: + rm $(SRC_DIR)/version.h rm -vf $(SRC_DIR)/*.o rm -vf $(SRC_DIR)/*~ rm -vf $(TEST_SRC_DIR)/*.o rm -vf $(OUTPUT) rm -vf ./bin/unittests-gemma -DIST_COMMON = COPYING.txt README.txt Makefile +DIST_COMMON = *.md LICENSE VERSION Makefile DIST_SUBDIRS = src doc example bin -tar: +tar: version all + @echo "Creating $(DIST_NAME)" mkdir -p ./$(DIST_NAME) cp $(DIST_COMMON) ./$(DIST_NAME)/ cp -r $(DIST_SUBDIRS) ./$(DIST_NAME)/ |
