Last active
May 13, 2018 21:45
-
-
Save sadatnfs/f0b109f70394b6a0d1d61efd7efe8408 to your computer and use it in GitHub Desktop.
Makefile for building INLA in Debian:Buster
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Makefile for downloading the source code and building | |
## a binary package of R-INLA on Debian/Buster | |
## using a custom version of R and Intel MKL | |
## Intended for use by : Institute for Health Metrics and Evaulation | |
## | |
## Maintained by : Nafis Sadat, [email protected] | |
## | |
## Run 'make' with no arguments for usage instructions | |
## | |
## This Makefile has been tested under Debian GNU/Linux | |
## | |
## NOTE: Debian Stretch may require libatlas-dev as opposed to libatlas-base-dev | |
## | |
## Requirements: | |
## mercurial | |
## A full gcc/g++/gfortran installation | |
## lib*-dev packages, see target lib-install below | |
## | |
## If you already have a cloned inla code repository in a subdirectory 'inla', | |
## you can skip all 'download-' steps, and instead run | |
## make -f inla/build-user/linux/Makefile | |
## | |
## Finn Lindgren, 2014-08-24, [email protected] | |
#### 2018/01/28 Update: removing r-mathlib and adding metis5 | |
#### 2018/03/23 Update: update path to new MKL version installation | |
#### 2018/04/25 Update: remove metis installs (pointing to Metis 5.1.0 instead) and using base image | |
## NOTE: Changes to the Makefile should be made as needed for compilers and flags | |
## This version includes the use of MPI compilers and the Intel MKL libraries | |
SHELL = /bin/bash | |
## This Makefile is only supported for platform 'linux': | |
PLATFORM = linux | |
## Must match the machine architecture (32 or 64): | |
BITS = 64 | |
## Compiler flags | |
MKLROOT=/opt/intel/compilers_and_libraries_2018.2.199/linux/mkl | |
MKL="-L/opt/intel/compilers_and_libraries_2018.2.199/linux/mkl/mkl/lib/intel64_lin -Wl,--no-as-needed -lmkl_gf_lp64 -lmkl_rt -lmkl_intel_thread -lf77blas -latlas -lmkl_core -liomp5 -lpthread -lm -ldl" | |
INLA_LIBR="/opt/R/lib64/R/lib -I/opt/R/lib64/R/include/" | |
FLAGS=-m64 -std=gnu99 -Wall -g -O3 -mtune=generic -mfpmath=sse \ | |
-msse2 -I/opt/R/lib64/R/include/ -L/opt/R/lib64/R/lib -funroll-loops -fPIC -ftracer -fopenmp -pipe -m64 \ | |
-I${MKLROOT}/include ${MKL} -I/opt/metis-5.1.0/include \ | |
-L${INLA_LIBR} -lLIBR_SO -lRmath -llibR | |
## You probably don't need to edit anything below this line | |
## For Debian or Ubuntu package installation in lib-install: | |
APT=aptitude | |
## Path configuration: | |
MAINDIR=$(PWD) | |
PREFIX = $(MAINDIR)/local | |
BINPREFIX = $(PREFIX)/bin/$(PLATFORM) | |
LIBPREFIX = $(PREFIX)/lib | |
INCPREFIX = $(PREFIX)/include | |
## Compiler options: | |
#CC=mpicc | |
#CXX=mpic++ | |
#FC=mpifort | |
CC=gcc | |
CXX=g++ | |
FC=gfortran | |
LD=$(CXX) | |
ARGS = CC="$(CC)" CXX="$(CXX)" FC="$(FC)" LD="$(LD)" | |
all :; | |
@(echo "";\ | |
echo "Edit this Makefile, especially the 'FLAGS' variable,";\ | |
echo "check if you need to run 'sudo $(MAKE) lib-install', then do";\ | |
echo "";\ | |
echo " $(MAKE) lib-install";\ | |
echo " $(MAKE) download";\ | |
echo " $(MAKE) bin";\ | |
echo " $(MAKE) package";\ | |
echo "";\ | |
echo "If all goes well, you should have binaries for inla and fmesher at";\ | |
echo "";\ | |
echo " $(BINPREFIX)";\ | |
echo "";\ | |
echo "and an INLA_*.tgz binary R package in your working directory.";\ | |
echo "";\ | |
echo "To later download and build an updated package, do";\ | |
echo "";\ | |
echo " $(MAKE) update";\ | |
echo "";\ | |
echo "To build a package for the JSS 2015 paper, do";\ | |
echo "";\ | |
echo " $(MAKE) download-jss2014 && $(MAKE) bin && $(MAKE) package";\ | |
echo "";\ | |
echo "Note: Not all lapack versions contain all the needed routines,";\ | |
echo "so make sure that /usr/lib/lapack/liblapack.so is selected in";\ | |
echo "";\ | |
echo " sudo update-alternatives --config liblapack.so";\ | |
echo "";\ | |
echo "It's possible to link to both lapack and lapack_atlas.";\ | |
echo "";) | |
## Package list updated 2017-12-01 | |
LIBPKG = liblapack-dev libgsl0-dev zlib1g-dev libsuitesparse-dev \ | |
libxdmcp-dev libx11-dev libc6-dev \ | |
libatlas-base-dev \ | |
libblas-dev libmuparser-dev | |
lib-install : | |
$(APT) install -y $(LIBPKG) | |
init : | |
@mkdir -p $(LIBPREFIX) | |
@mkdir -p $(BINPREFIX) | |
@mkdir -p $(INCPREFIX) | |
download : init | |
@( test -d inla && $(MAKE) download-update ) || \ | |
( rm -rf inla && hg clone https://bitbucket.org/hrue/r-inla inla ) | |
@ln -sTf $(PREFIX) inla/local | |
download-update : init | |
@cd inla ; hg pull ; hg update | |
@ln -sTf $(PREFIX) inla/local | |
download-jss2014 : | |
@$(MAKE) download | |
@cd inla ; hg update -r jss2014 | |
@ln -sTf $(PREFIX) inla/local | |
bin : | |
$(MAKE) taucs | |
$(MAKE) fmesher | |
$(MAKE) GMRFLib | |
$(MAKE) inla | |
update : | |
$(MAKE) download-update | |
$(MAKE) bin | |
$(MAKE) package | |
fmesher : | |
$(MAKE) -C inla/fmesher PREFIX=$(PREFIX) $(ARGS) -k clean | |
$(MAKE) -C inla/fmesher PREFIX=$(PREFIX) FLAGS="$(FLAGS) -I/opt/R/lib64/R/include/ -I${MKLROOT}/include ${MKL}" $(ARGS) EXTLIBS="-lX11 -lgsl -lgslcblas -lxcb -lpthread -lXau -lXdmcp" | |
$(MAKE) -C inla/fmesher PREFIX=$(PREFIX) $(ARGS) install | |
@rsync -a $(PREFIX)/bin/fmesher $(BINPREFIX)/fmesher$(BITS) | |
@rm $(PREFIX)/bin/fmesher | |
inla : | |
ln -sTf /usr/include $(INCPREFIX)/muParser | |
$(MAKE) -C inla/inlaprog PREFIX=$(PREFIX) FLAGS="$(FLAGS) -fopenmp -I/opt/R/lib64/R/include/ -I${MKLROOT}/include ${MKL}" $(ARGS) -k clean | |
$(MAKE) -C inla/inlaprog PREFIX=$(PREFIX) FLAGS="$(FLAGS) -fopenmp -I/opt/R/lib64/R/include/ -I${MKLROOT}/include ${MKL}" $(ARGS) | |
$(MAKE) -C inla/inlaprog PREFIX=$(PREFIX) FLAGS="$(FLAGS) -fopenmp -I/opt/R/lib64/R/include/ -I${MKLROOT}/include ${MKL}" $(ARGS) install | |
@rsync -a $(PREFIX)/bin/inla $(BINPREFIX)/inla$(BITS) | |
@rm $(PREFIX)/bin/inla $(PREFIX)/bin/inla-snapshot | |
GMRFLib : | |
$(MAKE) -C inla/gmrflib PREFIX=$(PREFIX) FLAGS="$(FLAGS) -fopenmp -I/opt/R/lib64/R/include/ -I${MKLROOT}/include ${MKL}" $(ARGS) -k clean | |
$(MAKE) -C inla/gmrflib PREFIX=$(PREFIX) FLAGS="$(FLAGS) -fopenmp -I/opt/R/lib64/R/include/ -I${MKLROOT}/include ${MKL}" $(ARGS) | |
$(MAKE) -C inla/gmrflib PREFIX=$(PREFIX) FLAGS="$(FLAGS) -fopenmp -I/opt/R/lib64/R/include/ -I${MKLROOT}/include ${MKL}" $(ARGS) install | |
sync-taucs : | |
mkdir -p $(MAINDIR)/tmp | |
-rm -rf $(MAINDIR)/tmp/taucs-2.2--my-fix | |
cp inla/extlibs/taucs-2.2--my-fix.tgz $(MAINDIR)/tmp/ | |
cd $(MAINDIR)/tmp ; tar -zxf taucs-2.2--my-fix.tgz | |
taucs : sync-taucs | |
$(MAKE) -C $(MAINDIR)/tmp/taucs-2.2--my-fix CFLAGS="$(FLAGS)" FFLAGS="$(FLAGS)" $(ARGS) -k clean | |
$(MAKE) -C $(MAINDIR)/tmp/taucs-2.2--my-fix CFLAGS="$(FLAGS)" FFLAGS="$(FLAGS)" $(ARGS) | |
@cp -v -f $(MAINDIR)/tmp/taucs-2.2--my-fix/lib/linux/libtaucs.a $(PREFIX)/lib | |
# sync-taucs : | |
# mkdir -p $(MAINDIR)/tmp | |
# tar -xvzf inla/extlibs/taucs-2.2--my-fix.tgz | |
# cp -r $(MAINDIR)/inla/extlibs/taucs-2.2--my-fix $(MAINDIR)/taucs-2.2--my-fix | |
# taucs : sync-taucs | |
# $(MAKE) -C $(MAINDIR)/taucs-2.2--my-fix CFLAGS="$(FLAGS) " FFLAGS="$(FLAGS) -I/opt/R/lib/R/include/ -I${MKLROOT}/include ${MKL}" $(ARGS) -k clean | |
# $(MAKE) -C $(MAINDIR)/taucs-2.2--my-fix CFLAGS="$(FLAGS) " FFLAGS="$(FLAGS) -I/opt/R/lib/R/include/ -I${MKLROOT}/include ${MKL}" $(ARGS) | |
# @cp -v -f $(MAINDIR)/taucs-2.2--my-fix/lib/linux/libtaucs.a $(PREFIX)/lib | |
package : | |
@rm -f inla/INLA_*.tgz | |
cd inla ; utils/build-package-bin $(PREFIX)/bin $(MAINDIR)/tmp | |
.PHONY: all inla GMRFLib taucs download download-update update fmesher bin init download-jss2014 sync-taucs package |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment