Skip to content

Instantly share code, notes, and snippets.

@AndiH
Created October 2, 2019 13:13
Show Gist options
  • Save AndiH/9240a880e8061e24b65af2c11f76d30f to your computer and use it in GitHub Desktop.
Save AndiH/9240a880e8061e24b65af2c11f76d30f to your computer and use it in GitHub Desktop.
#!/usr/bin/make -f
# Makefile for installing OpenMPI
#
# -Andreas Herten, 15 Dec 2017
SHELL = /bin/bash
PRGNAME = openmpi
VERSION = 4.0.1
SOURCEADDRESS = https://download.open-mpi.org/release/open-mpi/v4.0/openmpi-${VERSION}.tar.gz
COMPILER_MODULE = gcc/5.4.0
CUDA_MODULE = cuda/10.0.130
OTHER_MODULES =
# These are the directories for JURON:
SOURCEBASE = /gpfs/software/src
PREFIXBASE = /gpfs/software/opt
# MODULEVERSION = $(shell echo "${VERSION}-${COMPILER_MODULE}" | sed 's./._.g')
# MODULEVERSION = ${VERSION}
MODULEVERSION = $(shell echo "${VERSION}-${COMPILER_MODULE}-${CUDA_MODULE}" | sed 's./._.g')
PREFIX = ${PREFIXBASE}/${PRGNAME}/${MODULEVERSION}
SOURCE = ${SOURCEBASE}/${PRGNAME}/${MODULEVERSION}
SOURCEDIR = ${SOURCE}/source
BUILDDIR = ${SOURCE}/build
MODULES = ${COMPILER_MODULE} ${CUDA_MODULE} ${OTHER_MODULES}
NTHREADS = 20
.PHONY: hello all
hello:
@echo "Building ${PRGNAME}, version ${VERSION}"
@echo "Installing from ${SOURCE}"
@echo " into ${PREFIX}"
all: hello all
all: hello all
.PHONY: download configure build install all
download: ${SOURCEDIR}/.downloaded
build: ${BUILDDIR}/.built
configure: ${BUILDDIR}/.configured
install: ${PREFIX}/.installed
all: download build install
${SOURCEDIR}/.downloaded:
cd ${SOURCEBASE} && \
mkdir -p ${SOURCEDIR} && \
cd ${SOURCEDIR} && \
curl ${SOURCEADDRESS} | tar xz --directory ${SOURCEDIR} --strip-components 1
echo "$$(date)" > $@
${BUILDDIR}/.configured: ${SOURCEDIR}/.downloaded
mkdir -p ${BUILDDIR}/ && \
cd ${BUILDDIR}/ && \
module load ${MODULES} && \
${SOURCEDIR}/configure \
--prefix=${PREFIX} \
--enable-mpi-ext=affinity,cuda \
--with-verbs \
--with-lsf \
--enable-mpi-cxx \
--without-munge \
--without-slurm \
--without-ucx \
--with-cuda=$$CUDA_ROOT
echo "$$(date)" > $@
${BUILDDIR}/.built: ${BUILDDIR}/.configured
cd ${BUILDDIR}/ && \
module load ${MODULES} && \
make -j ${NTHREADS}
echo "$$(date)" > $@
${PREFIX}/.installed: ${BUILDDIR}/.built
cd ${BUILDDIR}/ && \
module load ${MODULES} && \
make install
echo "$$(date)" > $@
### RESET & CLEAN
.PHONY: reset-download reset-build reset-install reset clean-build clean-source clean-install clean-all clean
reset-download:
rm ${SOURCEDIR}/.downloaded
reset-configure:
rm ${BUILDDIR}/.configured
reset-build:
rm ${BUILDDIR}/.built
reset-install:
rm ${PREFIX}/.installed
reset: reset-download reset-build reset-install
clean-build:
rm -rf ${BUILDDIR}/
clean-source:
rm -rf ${SOURCEDIR}/
clean-install:
rm -rf ${PREFIX}/
clean-all: clean-build clean-source
clean:
@echo "Please use make clean-all and be sure abou it!"
# check:
# ifneq ("${CURRENTGCCVERSION}","${SUPPOSEGCCVERSION}")
# @$(error "This is suppose to be built with GCC ${SUPPOSEGCCVERSION}")
# else
# @echo "Passed all checks"
# endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment