From 3268896c20735ca9aa3c733c687ef6bbed760bcc Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Sun, 27 Aug 2017 07:56:19 +0000 Subject: Makefile: clean up of the main Makefile and changed build instructions to align with normal build systems * Debug mode is now the default (use DEBUG= to disable) * Dynamic linking is now the default (use FORCE_STATIC=1 for static) * Removed references to 32-bit compilation (default is $arch) --- .travis.yml | 6 ++-- INSTALL.md | 17 ++++++---- Makefile | 105 +++++++++++++++++++++++++++++++++--------------------------- 3 files changed, 71 insertions(+), 57 deletions(-) diff --git a/.travis.yml b/.travis.yml index df74fb2..ec2d049 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,12 +35,12 @@ script: - eval "${MATRIX_EVAL}" - $CXX --version # build and test debug version - - make CXX=$CXX FORCE_DYNAMIC=1 WITH_OPENBLAS=1 DEBUG=1 -j 4 - - time make CXX=$CXX FORCE_DYNAMIC=1 WITH_OPENBLAS=1 DEBUG=1 check + - make CXX=$CXX WITH_OPENBLAS=1 -j 4 + - time make CXX=$CXX WITH_OPENBLAS=1 check - make clean # build and test release version - make CXX=$CXX FORCE_DYNAMIC=1 WITH_OPENBLAS=1 -j 4 - - time make CXX=$CXX FORCE_DYNAMIC=1 WITH_OPENBLAS=1 check + - time make CXX=$CXX WITH_OPENBLAS=1 DEBUG= check # build static release (fast-check only) # - make clean # - make CXX=$CXX TRAVIS_CI=1 -j 4 fast-check diff --git a/INSTALL.md b/INSTALL.md index 864b8e7..e450a2a 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -49,7 +49,7 @@ using the following command guix package -i gemma -To install the build tools with GNU Guix +To build GEMMA from source you can opt to install the build tools with GNU Guix guix package -i make gcc linux-libre-headers gsl eigen openblas lapack glibc ld-wrapper @@ -62,14 +62,15 @@ Install listed dependencies and run (the -j switch builds on 4 cores). if you get an Eigen error you may need to override the include -path. E.g. on GNU Guix with shared libs and DEBUG the following may -work +path. E.g. to build GEMMA on GNU Guix with shared libs the following +may work - make EIGEN_INCLUDE_PATH=~/.guix-profile/include/eigen3 FORCE_DYNAMIC=1 WITH_OPENBLAS=1 DEBUG=1 + make EIGEN_INCLUDE_PATH=~/.guix-profile/include/eigen3 WITH_OPENBLAS=1 -another example overriding optimization and LIB flags (so as to link against gslv1) would be +another example overriding optimization and LIB flags (so as to link +against gslv1) would be - make EIGEN_INCLUDE_PATH=~/.guix-profile/include/eigen3 WITH_OPENBLAS=1 DEBUG=1 FORCE_DYNAMIC=1 GCC_FLAGS="-Wall" LIBS="$HOME/opt/gsl1/lib/libgsl.a $HOME/opt/gsl1/lib/libgslcblas.a -L$HOME/.guix-profile/lib -pthread -llapack -lblas -lz" + make EIGEN_INCLUDE_PATH=~/.guix-profile/include/eigen3 WITH_OPENBLAS=1 GCC_FLAGS="-Wall" LIBS="$HOME/opt/gsl1/lib/libgsl.a $HOME/opt/gsl1/lib/libgslcblas.a -L$HOME/.guix-profile/lib -pthread -llapack -lblas -lz" to run GEMMA tests @@ -83,7 +84,9 @@ You can run gemma in the debugger with, for example -snps example/snps.txt -nind 400 -loco 1 -gk -debug -o myoutput Note that if you get warnings on inspecting variables you -should compile with GCC_FLAGS="" to disable optimizations (-O3). +should compile with GCC_FLAGS="" to disable optimizations (-O3). E.g. + + make EIGEN_INCLUDE_PATH=~/.guix-profile/include/eigen3 WITH_OPENBLAS=1 GCC_FLAGS= Other options, such as compiling with warnings, are listed in the Makefile. diff --git a/Makefile b/Makefile index a7e7adf..81367d6 100644 --- a/Makefile +++ b/Makefile @@ -1,43 +1,67 @@ -#Makefile - +# Generic Makefile for GEMMA +# # Supported platforms -# Unix / Linux LNX +# +# Unix / Linux LNX (default) # Mac MAC +# # Compilation options -# 32-bit binary FORCE_32BIT -# dynamic compilation FORCE_DYNAMIC +# static compilation FORCE_STATIC +# +# Examples: +# +# Make GEMMA on Linux with OPENBLAS support: +# +# make WITH_OPENBLAS=1 +# +# Disable debug info and checks (slightly faster release mode) +# +# make WITH_OPENBLAS=1 DEBUG= +# +# Force static compilation +# +# make FORCE_STATIC=1 +# +# Run tests with +# +# make check +# +# See also the INSTALL.md document in the source tree at +# +# https://github.com/genetics-statistics/GEMMA/blob/master/INSTALL.md # Set this variable to either LNX or MAC -SYS = LNX +SYS = LNX # LNX|MAC (Linux is the default) # Leave blank after "=" to disable; put "= 1" to enable +DIST_NAME = gemma-0.97.2 +DEBUG = 1 # DEBUG mode, set DEBUG=0 for a release SHOW_COMPILER_WARNINGS = -WITH_LAPACK = 1 -WITH_OPENBLAS = -NO_INTEL_COMPAT = -FORCE_32BIT = -FORCE_DYNAMIC = -GCC_FLAGS = -O3 # extra flags -Wl,--allow-multiple-definition -DIST_NAME = gemma-0.97.2 -TRAVIS_CI = +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 # -------------------------------------------------------------------- # Edit below this line with caution # -------------------------------------------------------------------- -EIGEN_INCLUDE_PATH=/usr/include/eigen3 - BIN_DIR = ./bin - SRC_DIR = ./src TEST_SRC_DIR = ./test/src -ifdef CXX +ifdef CXX # CXX defined in environment CPP = $(CXX) CC = $(CXX) else CPP = g++ endif +ifdef OPENBLAS + WITH_LAPACK = # OPENBLAS usually includes LAPACK +endif + ifdef DEBUG CPPFLAGS = -g $(GCC_FLAGS) -std=gnu++11 -isystem/$(EIGEN_INCLUDE_PATH) -Icontrib/catch-1.9.7 -Isrc else @@ -49,7 +73,7 @@ ifdef SHOW_COMPILER_WARNINGS CPPFLAGS += -Wall endif -ifdef FORCE_DYNAMIC +ifndef FORCE_STATIC LIBS = -lgsl -lgslcblas -pthread -lz else ifndef TRAVIS_CI # Travis static compile we cheat a little @@ -72,38 +96,25 @@ LIBS_MAC_D_LAPACK = -framework Veclib # 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 - -SOURCES += $(SRC_DIR)/param.cpp $(SRC_DIR)/gemma.cpp $(SRC_DIR)/io.cpp $(SRC_DIR)/lm.cpp $(SRC_DIR)/lmm.cpp $(SRC_DIR)/vc.cpp $(SRC_DIR)/mvlmm.cpp $(SRC_DIR)/bslmm.cpp $(SRC_DIR)/prdt.cpp $(SRC_DIR)/mathfunc.cpp $(SRC_DIR)/gzstream.cpp $(SRC_DIR)/eigenlib.cpp $(SRC_DIR)/ldr.cpp $(SRC_DIR)/bslmmdap.cpp $(SRC_DIR)/logistic.cpp $(SRC_DIR)/varcov.cpp $(SRC_DIR)/debug.cpp -HDR += $(SRC_DIR)/param.h $(SRC_DIR)/gemma.h $(SRC_DIR)/io.h $(SRC_DIR)/lm.h $(SRC_DIR)/lmm.h $(SRC_DIR)/vc.h $(SRC_DIR)/mvlmm.h $(SRC_DIR)/bslmm.h $(SRC_DIR)/prdt.h $(SRC_DIR)/mathfunc.h $(SRC_DIR)/gzstream.h $(SRC_DIR)/eigenlib.h - ifdef WITH_LAPACK - OBJS += $(SRC_DIR)/lapack.o -ifeq ($(SYS), MAC) - LIBS += $(LIBS_MAC_D_LAPACK) -else - ifdef FORCE_DYNAMIC - ifdef WITH_OPENBLAS - LIBS += $(LIBS_LNX_D_OPENBLAS) + ifeq ($(SYS), MAC) + LIBS += $(LIBS_MAC_D_LAPACK) + else + ifndef FORCE_STATIC + ifdef WITH_OPENBLAS + LIBS += $(LIBS_LNX_D_OPENBLAS) + else + LIBS += $(LIBS_LNX_D_BLAS) + endif + LIBS += $(LIBS_LNX_D_LAPACK) else - LIBS += $(LIBS_LNX_D_BLAS) + LIBS += $(LIBS_LNX_S_LAPACK) endif - LIBS += $(LIBS_LNX_D_LAPACK) - else - LIBS += $(LIBS_LNX_S_LAPACK) endif endif - SOURCES += $(SRC_DIR)/lapack.cpp - HDR += $(SRC_DIR)/lapack.h -endif -ifdef NO_INTEL_COMPAT - else - ifdef FORCE_32BIT - CPPFLAGS += -m32 - else - CPPFLAGS += -m64 - endif -endif +HDR = $(wildcard src/*.h) +SOURCES = $(wildcard src/*.cpp) # all OBJS = $(SOURCES:.cpp=.o) @@ -113,14 +124,14 @@ all: $(OUTPUT) $(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 - $(CPP) $(CPPFLAGS) $(TEST_SRC_DIR)/unittests-main.o $(TEST_SRC_DIR)/unittests-math.o $(filter-out $(SRC_DIR)/main.o, $(OBJS)) $(LIBS) -o ./bin/unittests-gemma + $(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 ./bin/unittests-gemma fast-check: all unittests -- cgit v1.2.3