build-clang.sh 2.75 KB
Newer Older
1
2
3
4
5
#!/bin/bash

# Build script for Linux distribution, for use in automated packaging.
# Note that this must be run from outside the checked-out openmm/ directory.

6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Fix hbb issues.
# If statements needed because multiple Python versions are built in same docker image.
if [ ! -e /opt/rh/devtoolset-2/root/usr/lib/gcc/x86_64-redhat-linux ]; then
   ln -s /opt/rh/devtoolset-2/root/usr/lib/gcc/x86_64-CentOS-linux/ /opt/rh/devtoolset-2/root/usr/lib/gcc/x86_64-redhat-linux
fi
if [ ! -e /opt/rh/devtoolset-2/root/usr/include/c++/4.8.2/x86_64-redhat-linux ]; then
   ln -s /opt/rh/devtoolset-2/root/usr/include/c++/4.8.2/x86_64-CentOS-linux/ /opt/rh/devtoolset-2/root/usr/include/c++/4.8.2/x86_64-redhat-linux
fi

# Clang paths
export CLANG_PREFIX="/opt/clang"
export PATH=$PATH:$CLANG_PREFIX/bin

# enable devtoolset-2
source /opt/rh/devtoolset-2/enable

export MINIMAL_CFLAGS="-g -O3"
export CFLAGS="$MINIMAL_CFLAGS"
export CXXFLAGS="$MINIMAL_CFLAGS"
export LDFLAGS="$LDPATHFLAGS"

27
28
29
# Set relative workspace path.
export WORKSPACE=`pwd`

30
# Add conda binaries to path.
31
PATH=$WORKSPACE/miniconda/bin:$PATH
32

33
INSTALL=`pwd`/install
34
35
36
37
if [ -e $INSTALL ]; then
    rm -rf $INSTALL
fi

38
39
CMAKE_FLAGS="-DCMAKE_INSTALL_PREFIX=$INSTALL"

40
41
42
43
44
45
46
47
48
# Don't build tests
CMAKE_FLAGS+=" -DBUILD_TESTING=OFF"

# Use clang
CMAKE_FLAGS+=" -DCMAKE_C_COMPILER=$CLANG_PREFIX/bin/clang -DCMAKE_CXX_COMPILER=$CLANG_PREFIX/bin/clang++"

# Ensure we build a release
CMAKE_FLAGS+=" -DCMAKE_BUILD_TYPE=Release"

49
50
# setting the rpath so that libOpenMMPME.so finds the right libfftw3
#CMAKE_FLAGS+=" -DCMAKE_INSTALL_RPATH=.."
51
# Use NVIDIA CUDA 8.0
jchodera's avatar
jchodera committed
52
53
54
55
56
CMAKE_FLAGS+=" -DCUDA_CUDART_LIBRARY=/usr/local/cuda-8.0/lib64/libcudart.so"
CMAKE_FLAGS+=" -DCUDA_NVCC_EXECUTABLE=/usr/local/cuda-8.0/bin/nvcc"
CMAKE_FLAGS+=" -DCUDA_SDK_ROOT_DIR=/usr/local/cuda-8.0/"
CMAKE_FLAGS+=" -DCUDA_TOOLKIT_INCLUDE=/usr/local/cuda-8.0/include"
CMAKE_FLAGS+=" -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0/"
57
# Use AMD APP SDK 3.0
58
59
CMAKE_FLAGS+=" -DOPENCL_INCLUDE_DIR=/opt/AMDAPPSDK-3.0/include/"
CMAKE_FLAGS+=" -DOPENCL_LIBRARY=/opt/AMDAPPSDK-3.0/lib/x86_64/libOpenCL.so"
60
# Generate API docs
peastman's avatar
peastman committed
61
CMAKE_FLAGS+=" -DOPENMM_GENERATE_API_DOCS=ON"
62
# Set location for FFTW3
63
PREFIX="$WORKSPACE/miniconda"
64
65
66
CMAKE_FLAGS+=" -DFFTW_INCLUDES=$PREFIX/include"
CMAKE_FLAGS+=" -DFFTW_LIBRARY=$PREFIX/lib/libfftw3f.so"
CMAKE_FLAGS+=" -DFFTW_THREADS_LIBRARY=$PREFIX/lib/libfftw3f_threads.so"
67
68
# Necessary to find GL headers
CMAKE_FLAGS+=" -DCMAKE_CXX_FLAGS_RELEASE=-I/usr/include/nvidia/"
69
70

# Build in subdirectory.
71
72
73
if [ -e build ]; then
    rm -rf build
fi
74
75
76
mkdir build
cd build
cmake ../openmm $CMAKE_FLAGS
77
make -j4 all install
78
79
80
81
82

export CFLAGS="$MINIMAL_CFLAGS"
export CXXFLAGS="$MINIMAL_CFLAGS"
export LDFLAGS="$LDPATHFLAGS"

83
make -j4 PythonInstall C++ApiDocs PythonApiDocs sphinxpdf
84
85

# Install.
86
make install
jchodera's avatar
jchodera committed
87
88

cd ..