| 1 |
### modify these paths to local Boost and NLopt install directories |
| •2 |
BOOST_INSTALL_DIR = |
| 3 |
NLOPT_INSTALL_DIR = |
| 4 |
|
| 5 |
INTELROOT = /n/groups/price/poru/external_software/intel_mkl_2019u4 |
| 6 |
MKLROOT = ${INTELROOT}/mkl |
| 7 |
ZLIB_STATIC_DIR = /n/groups/price/poru/external_software/zlib/zlib-1.2.11 # probably unnecessary on most systems |
| 8 |
LIBSTDCXX_STATIC_DIR = /n/groups/price/poru/external_software/libstdc++/usr/lib/gcc/x86_64-redhat-linux/4.8.5/ |
| 9 |
GLIBC_STATIC_DIR = /home/pl88/glibc-static/usr/lib64 |
| 10 |
|
| 11 |
ZSTD_DIR = /n/data1/bwh/medicine/loh/ploh/external_software/zstd-1.5.2/lib |
| 12 |
|
| 13 |
ifeq ($(strip ${linking}),) |
| 14 |
linking = dynamic |
| 15 |
endif |
| 16 |
|
| •17 |
CC = g++ |
| 18 |
# CC = icpc |
| 19 |
|
| 20 |
ifeq (${debug},true) |
| 21 |
CFLAGS += -g |
| 22 |
else |
| 23 |
CFLAGS += -O2 |
| 24 |
endif |
| 25 |
|
| •26 |
CFLAGS += |
| 27 |
CFLAGS += -DMEASURE_DGEMM -DVERBOSE |
| 28 |
CFLAGS += -Wall |
| 29 |
|
| 30 |
|
| 31 |
# add Boost include and lib paths |
| 32 |
ifneq ($(strip ${BOOST_INSTALL_DIR}),) |
| 33 |
CPATHS += -I${BOOST_INSTALL_DIR}/include |
| 34 |
LPATHS += -L${BOOST_INSTALL_DIR}/lib |
| 35 |
ifeq (${linking},dynamic) |
| 36 |
LPATHS += -Wl,-rpath,${BOOST_INSTALL_DIR}/lib |
| 37 |
endif |
| 38 |
endif |
| 39 |
|
| 40 |
# add NLopt include and lib paths |
| 41 |
ifneq ($(strip ${NLOPT_INSTALL_DIR}),) |
| 42 |
CPATHS += -I${NLOPT_INSTALL_DIR}/api |
| 43 |
LPATHS += -L${NLOPT_INSTALL_DIR}/.libs |
| 44 |
ifeq (${linking},dynamic) |
| 45 |
LPATHS += -Wl,-rpath,${NLOPT_INSTALL_DIR}/.libs |
| 46 |
endif |
| 47 |
endif |
| 48 |
|
| 49 |
# add zlib.a path for static linking on Orchestra |
| 50 |
ifneq ($(strip ${ZLIB_STATIC_DIR}),) |
| 51 |
ifneq (${linking},dynamic) |
| 52 |
LPATHS += -L${ZLIB_STATIC_DIR} |
| 53 |
endif |
| 54 |
endif |
| 55 |
|
| 56 |
# add libzstd path |
| 57 |
CPATHS += -I${ZSTD_DIR} |
| 58 |
LPATHS += -L${ZSTD_DIR} |
| 59 |
|
| 60 |
# add MKL paths (if not compiling with g++, i.e., compiling with icpc) |
| 61 |
ifneq (${CC},g++) |
| 62 |
CPATHS += -I${MKLROOT}/include |
| 63 |
ifeq (${linking},static) |
| 64 |
LPATHS += -L${INTELROOT}/lib/intel64 '-Wl,-rpath,$$ORIGIN/lib' # for libiomp5.so (now packaged with binary) |
| 65 |
else ifeq (${linking},static-except-glibc) |
| 66 |
LPATHS += -L${INTELROOT}/lib/intel64 '-Wl,-rpath,$$ORIGIN/lib' # for libiomp5.so (now packaged with binary) |
| 67 |
else |
| 68 |
LPATHS += -L${MKLROOT}/lib/intel64 -Wl,-rpath,${MKLROOT}/lib/intel64 # for libmkl* |
| 69 |
LPATHS += -L${INTELROOT}/lib/intel64 -Wl,-rpath,${INTELROOT}/lib/intel64 # for libiomp5.so |
| 70 |
endif |
| 71 |
endif |
| 72 |
|
| 73 |
# add flags for static linking; build LAPACK/MKL component of link line |
| 74 |
ifeq (${CC},g++) |
| 75 |
CFLAGS += -fopenmp |
| 76 |
LFLAGS += -fopenmp |
| 77 |
LLAPACK = -llapack -lgfortran |
| 78 |
ifeq (${linking},static) |
| 79 |
LFLAGS += -static |
| 80 |
LPATHS += -L${GLIBC_STATIC_DIR} -L${ZLIB_STATIC_DIR} |
| 81 |
else ifeq (${linking},static-except-glibc) |
| 82 |
LFLAGS += -static-libgcc -static-libstdc++ |
| 83 |
LPATHS += -L${ZLIB_STATIC_DIR} |
| 84 |
endif |
| 85 |
else |
| 86 |
CFLAGS += -DUSE_MKL #-DUSE_MKL_MALLOC |
| 87 |
CFLAGS += -qopenmp |
| 88 |
LFLAGS += -qopenmp |
| 89 |
CFLAGS += -Wunused-variable -Wpointer-arith -Wuninitialized -Wreturn-type -Wcheck -Wshadow |
| 90 |
LIOMP5 = -liomp5 |
| 91 |
LDL = -ldl |
| 92 |
ifeq (${linking},static) |
| 93 |
LFLAGS += -static |
| 94 |
LPATHS += -L${GLIBC_STATIC_DIR} -L${ZLIB_STATIC_DIR} |
| 95 |
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 |
| 96 |
else ifeq (${linking},static-except-glibc) |
| 97 |
LFLAGS += -static-intel -static-libstdc++ -static-libgcc |
| 98 |
LPATHS += -L${ZLIB_STATIC_DIR} |
| 99 |
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 |
| 100 |
else ifeq (${linking},static-except-glibc-intel) |
| 101 |
LFLAGS += -static-libstdc++ -static-libgcc |
| 102 |
LPATHS += -L${ZLIB_STATIC_DIR} |
| 103 |
LLAPACK = -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core |
| 104 |
else |
| 105 |
LLAPACK = -lmkl_intel_lp64 -lmkl_intel_thread -lmkl_core |
| 106 |
endif |
| 107 |
# Note: If MKL LAPACK routines are called with arrays of size >= 2^31, |
| 108 |
# interface layer ILP64 (64-bit integer) is required. |
| 109 |
# However, since BOLT-LMM makes linear algebra calls in blocks, LP64 (32-bit) |
| 110 |
# should be sufficient. |
| 111 |
endif |
| 112 |
|
| 113 |
# build link line (minus flags) |
| •114 |
LLIBS = -lboost_program_options -lboost_iostreams -lzstd -lz -lnlopt -lopenblas |
| 115 |
ifeq (${linking},static-except-glibc) |
| 116 |
L = -L${LIBSTDCXX_STATIC_DIR} ${LPATHS} -Wl,--wrap=memcpy -Wl,-Bstatic ${LLIBS} ${LLAPACK} -Wl,-Bdynamic ${LIOMP5} -lpthread -lm ${LDL} |
| 117 |
else ifeq (${linking},static-except-glibc-intel) |
| 118 |
L = -L${LIBSTDCXX_STATIC_DIR} ${LPATHS} -Wl,--wrap=memcpy -Wl,-Bstatic ${LLIBS} -Wl,-Bdynamic ${LLAPACK} ${LIOMP5} -lpthread -lm ${LDL} |
| 119 |
else |
| 120 |
L = ${LPATHS} ${LLIBS} ${LLAPACK} ${LIOMP5} -lpthread -lm ${LDL} |
| 121 |
endif |
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
T = bolt |
| 126 |
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 |
| 127 |
OMAIN = BoltMain.o $O |
| 128 |
|
| 129 |
.PHONY: clean |
| 130 |
|
| 131 |
%.o: %.cpp |
| •132 |
${CC} ${CFLAGS} ${CPPFLAGS} ${CXXFLAGS} ${CPATHS} -o $@ -c $< |
| 133 |
|
| 134 |
$T: ${OMAIN} |
| •135 |
${CC} ${LFLAGS} ${LDFLAGS} -o $T ${OMAIN} $L |
| 136 |
|
| 137 |
clean: |
| 138 |
rm -f *.o |
| 139 |
rm -f $T |