--- src/Makefile.orig 2019-08-11 03:05:04 UTC +++ src/Makefile @@ -1,31 +1,35 @@ + ### modify these paths to local Boost and NLopt install directories -BOOST_INSTALL_DIR = /home/pl88/boost_1_58_0/install -NLOPT_INSTALL_DIR = /n/groups/price/poru/HSPH_SVN/src/BOLT-LMM/nlopt-2.4.2 +### by setting them in the environment or make command line args +### which will override variables set with ?= -INTELROOT = /n/groups/price/poru/external_software/intel_mkl_2019u4 -MKLROOT = ${INTELROOT}/mkl -ZLIB_STATIC_DIR = /n/groups/price/poru/external_software/zlib/zlib-1.2.11 # probably unnecessary on most systems -LIBSTDCXX_STATIC_DIR = /n/groups/price/poru/external_software/libstdc++/usr/lib/gcc/x86_64-redhat-linux/4.8.5/ -GLIBC_STATIC_DIR = /home/pl88/glibc-static/usr/lib64 +BOOST_INSTALL_DIR ?= /home/pl88/boost_1_58_0/install +NLOPT_INSTALL_DIR ?= /n/groups/price/poru/HSPH_SVN/src/BOLT-LMM/nlopt-2.4.2 +INTELROOT ?= /n/groups/price/poru/external_software/intel_mkl_2019u4 +MKLROOT ?= ${INTELROOT}/mkl +ZLIB_STATIC_DIR ?= /n/groups/price/poru/external_software/zlib/zlib-1.2.11 # probably unnecessary on most systems +LIBSTDCXX_STATIC_DIR ?= /n/groups/price/poru/external_software/libstdc++/usr/lib/gcc/x86_64-redhat-linux/4.8.5/ +GLIBC_STATIC_DIR ?= /home/pl88/glibc-static/usr/lib64 + ifeq ($(strip ${linking}),) linking = dynamic endif -# CC = g++ -CC = icpc +# CXX = g++ +CXX ?= icpc ifeq (${debug},true) - CFLAGS += -g + CXXFLAGS += -g else - CFLAGS += -O2 + CXXFLAGS += -O2 endif -CFLAGS += -msse -msse2 -CFLAGS += -DUSE_SSE -DMEASURE_DGEMM -DVERBOSE -CFLAGS += -Wall +# Set SSEFLAGS to empty string in the env or make command line if building on +# systems with no SSE such as PowerPC +SSEFLAGS ?= -msse -msse2 -DUSE_SSE +CXXFLAGS += ${SSEFLAGS} -DMEASURE_DGEMM -DVERBOSE -Wall - # add Boost include and lib paths ifneq ($(strip ${BOOST_INSTALL_DIR}),) CPATHS += -I${BOOST_INSTALL_DIR}/include @@ -52,7 +56,7 @@ ifneq ($(strip ${ZLIB_STATIC_DIR}),) endif # add MKL paths (if not compiling with g++, i.e., compiling with icpc) -ifneq (${CC},g++) +ifeq (${CXX},icpc) CPATHS += -I${MKLROOT}/include ifeq (${linking},static) LPATHS += -L${INTELROOT}/lib/intel64 '-Wl,-rpath,$$ORIGIN/lib' # for libiomp5.so (now packaged with binary) @@ -65,34 +69,34 @@ ifneq (${CC},g++) endif # add flags for static linking; build LAPACK/MKL component of link line -ifeq (${CC},g++) - CFLAGS += -fopenmp - LFLAGS += -fopenmp - LLAPACK = -llapack -lgfortran +ifneq (${CXX},icpc) + CXXFLAGS += -fopenmp + LDFLAGS += -fopenmp + LLAPACK ?= -llapack -lgfortran ifeq (${linking},static) - LFLAGS += -static + LDFLAGS += -static LPATHS += -L${GLIBC_STATIC_DIR} -L${ZLIB_STATIC_DIR} else ifeq (${linking},static-except-glibc) - LFLAGS += -static-libgcc -static-libstdc++ + LDFLAGS += -static-libgcc -static-libstdc++ LPATHS += -L${ZLIB_STATIC_DIR} endif else - CFLAGS += -DUSE_MKL #-DUSE_MKL_MALLOC - CFLAGS += -qopenmp - LFLAGS += -qopenmp - CFLAGS += -Wunused-variable -Wpointer-arith -Wuninitialized -Wreturn-type -Wcheck -Wshadow + CXXFLAGS += -DUSE_MKL #-DUSE_MKL_MALLOC + CXXFLAGS += -qopenmp + LDFLAGS += -qopenmp + CXXFLAGS += -Wunused-variable -Wpointer-arith -Wuninitialized -Wreturn-type -Wcheck -Wshadow LIOMP5 = -liomp5 LDL = -ldl ifeq (${linking},static) - LFLAGS += -static + LDFLAGS += -static LPATHS += -L${GLIBC_STATIC_DIR} -L${ZLIB_STATIC_DIR} LLAPACK = -Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_lp64.a ${MKLROOT}/lib/intel64/libmkl_intel_thread.a ${MKLROOT}/lib/intel64/libmkl_core.a -Wl,--end-group else ifeq (${linking},static-except-glibc) - LFLAGS += -static-intel -static-libstdc++ -static-libgcc + LDFLAGS += -static-intel -static-libstdc++ -static-libgcc LPATHS += -L${ZLIB_STATIC_DIR} LLAPACK = -Wl,--start-group ${MKLROOT}/lib/intel64/libmkl_intel_lp64.a ${MKLROOT}/lib/intel64/libmkl_intel_thread.a ${MKLROOT}/lib/intel64/libmkl_core.a -Wl,--end-group else ifeq (${linking},static-except-glibc-intel) - LFLAGS += -static-libstdc++ -static-libgcc + LDFLAGS += -static-libstdc++ -static-libgcc LPATHS += -L${ZLIB_STATIC_DIR} LLAPACK = -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core else @@ -105,7 +109,7 @@ else endif # build link line (minus flags) -LLIBS = -lboost_program_options -lboost_iostreams -lz -lnlopt +LLIBS = -lnlopt -lboost_program_options -lboost_iostreams -lz ifeq (${linking},static-except-glibc) L = -L${LIBSTDCXX_STATIC_DIR} ${LPATHS} -Wl,--wrap=memcpy -Wl,-Bstatic ${LLIBS} ${LLAPACK} -Wl,-Bdynamic ${LIOMP5} -lpthread -lm ${LDL} else ifeq (${linking},static-except-glibc-intel) @@ -117,16 +121,20 @@ endif T = bolt -O = Bolt.o BoltParams.o BoltParEstCV.o BoltReml.o CovariateBasis.o DataMatrix.o FileUtils.o Jackknife.o LDscoreCalibration.o MapInterpolater.o MatrixUtils.o MemoryUtils.o NonlinearOptMulti.o NumericUtils.o PhenoBuilder.o RestrictSnpSet.o SnpData.o SnpInfo.o SpectrumTools.o StatsUtils.o StringUtils.o Timer.o memcpy.o +# Set to empty string in env or make command line to use system memcpy +MEMCPY ?= memcpy.o +O = Bolt.o BoltParams.o BoltParEstCV.o BoltReml.o CovariateBasis.o DataMatrix.o FileUtils.o Jackknife.o LDscoreCalibration.o MapInterpolater.o MatrixUtils.o MemoryUtils.o NonlinearOptMulti.o NumericUtils.o PhenoBuilder.o RestrictSnpSet.o SnpData.o SnpInfo.o SpectrumTools.o StatsUtils.o StringUtils.o Timer.o ${MEMCPY} OMAIN = BoltMain.o $O -.PHONY: clean +.PHONY: clean all +all: ${T} + %.o: %.cpp - ${CC} ${CFLAGS} ${CPATHS} -o $@ -c $< + ${CXX} ${CXXFLAGS} ${CPATHS} -o $@ -c $< $T: ${OMAIN} - ${CC} ${LFLAGS} -o $T ${OMAIN} $L + ${CXX} ${LDFLAGS} -o $T ${OMAIN} $L clean: rm -f *.o