/
bootstrap
executable file
·224 lines (171 loc) · 6.51 KB
/
bootstrap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
#!/usr/bin/env bash
# This script creates a build directory and sticks a config.sh script into it.
# Then config.sh can be edited and run within the build directory.
# Print usage info.
if [ "$1" = "" ]; then
echo "Usage: bootstrap build_dir"
exit 1
fi
# Create the build directory if it doesn't exist.
if [ ! -d $1 ]; then
mkdir -p $1
fi
# Copy our template config script into place.
echo "SOURCE_DIR=$PWD" > $1/config.sh
cat <<EOT >> $1/config.sh
# ^^^^^^ location of polymec source code.
# config.sh -- A CMake configuration script.
# Edit this file to change the parameters in your build. Uncomment exactly one
# value for each parameter.
#-----------------------------------------------------------------------------
# Installation prefix
#-----------------------------------------------------------------------------
PREFIX=\$HOME/opt
#-----------------------------------------------------------------------------
# MPI
#-----------------------------------------------------------------------------
# Build with MPI for parallel simulations.
#MPI=ON
#-----------------------------------------------------------------------------
# OPENMP
#-----------------------------------------------------------------------------
# Enable OpenMP threading.
#OPENMP=ON
#-----------------------------------------------------------------------------
# Address Sanitizer (Asan)
#-----------------------------------------------------------------------------
# Enable Asan.
#ASAN=ON
#-----------------------------------------------------------------------------
# Floating Point Precision
#-----------------------------------------------------------------------------
# Choose one of the following.
# Double precision.
PRECISION=double
# Single precision.
#PRECISION=single
#-----------------------------------------------------------------------------
# Build type
#-----------------------------------------------------------------------------
# Choose one of the following.
# Debug executable (debugging symbols, no optimization).
BUILD_TYPE=Debug
# Release executable (No symbols, optimization).
#BUILD_TYPE=Release
#-----------------------------------------------------------------------------
# Shared libraries
#-----------------------------------------------------------------------------
# Uncomment to build polymec libraries as shared libraries.
#SHARED_LIBS=ON
#-----------------------------------------------------------------------------
# Build generator
#-----------------------------------------------------------------------------
# Choose one of the following.
# Good old-fashioned UNIX makefiles.
GENERATOR="Unix Makefiles"
# Ninja, a speedy make replacement. Use if available!
#GENERATOR="Ninja"
# Code::Blocks (with UNIX makefiles underneath).
#GENERATOR="CodeBlocks - Unix Makefiles"
# Code::Blocks (with Ninja underneath).
#GENERATOR="CodeBlocks - Ninja"
# Xcode. You can't use this for parallel (MPI) builds.
#GENERATOR="Xcode"
# CodeLite (with UNIX makefiles underneath).
#GENERATOR="CodeLite - Unix Makefiles"
# CodeLite (with Ninja underneath).
#GENERATOR="CodeLite - Ninja"
# Eclipse CDT4 (with UNIX makefiles underneath).
#GENERATOR="Eclipse CDT4 - Unix Makefiles"
# Eclipse CDT4 (with Ninja underneath).
#GENERATOR="Eclipse CDT4 - Ninja"
# Kate (with UNIX makefiles underneath).
#GENERATOR="Kate - Unix Makefiles"
# Kate (with Ninja underneath).
#GENERATOR="Kate - Ninja"
# Sublime Text 2 (with UNIX makefiles underneath).
#GENERATOR="Sublime Text 2 - Unix Makefiles"
# Sublime Text 2 (with Ninja underneath).
#GENERATOR="Sublime Text 2 - Ninja"
#-----------------------------------------------------------------------------
# Verbose builds
#-----------------------------------------------------------------------------
# Uncomment this if you want really verbose builds.
#VERBOSE=ON
#-----------------------------------------------------------------------------
# Building on Special Machines
#-----------------------------------------------------------------------------
# Uncomment this to indicate that we're building on a special, named machine.
#MACHINE=mymachine
#-----------------------------------------------------------------------------
# Code Coverage Analysis
#-----------------------------------------------------------------------------
#COVERAGE=ON
#-----------------------------------------------------------------------------
# Continuous Integration
#-----------------------------------------------------------------------------
# Use this if you want to pretend that you're building on Travis CI.
#TRAVIS=ON
#-----------------------------------------------------------------------------
# Compilers
#-----------------------------------------------------------------------------
if [ "\$MPI" = "ON" ]; then
CC=mpicc
CXX=mpic++
else
CC=cc
CXX=c++
fi
# Override compilers here (ONLY if you know what you're doing!).
# C compiler.
#CC=cc
# C++ compiler.
#CXX=c++
#-----------------------------------------------------------------------------
# Don't change anything below here.
#-----------------------------------------------------------------------------
OPTIONS=""
if [ "\$MPI" = "ON" ]; then
OPTIONS="-DHAVE_MPI=ON"
fi
if [ "\$OPENMP" = "ON" ]; then
OPTIONS="\$OPTIONS -DUSE_OPENMP=ON"
fi
if [ "\$ASAN" = "ON" ]; then
OPTIONS="\$OPTIONS -DUSE_ASAN=ON"
fi
if [ "\$SHARED_LIBS" = "ON" ]; then
OPTIONS="\$OPTIONS -DBUILD_SHARED_LIBS=ON"
fi
if [ "\$VERBOSE" = "ON" ]; then
OPTIONS="\$OPTIONS -DCMAKE_VERBOSE_MAKEFILE=ON"
fi
if [ "\$TRAVIS" = "ON" ]; then
OPTIONS="\$OPTIONS -DTRAVIS=ON"
fi
if [ "\$COVERAGE" = "ON" ]; then
OPTIONS="\$OPTIONS -DCOVERAGE=ON"
fi
if [ ! "\$MACHINE" = "" ]; then
OPTIONS="\$OPTIONS -DPOLYMEC_MACHINE=\$MACHINE"
fi
# Clear the build cache.
rm -f CMakeCache.txt
# Configure the build.
cmake \
-DCMAKE_INSTALL_PREFIX:PATH=\$PREFIX \
-DCMAKE_BUILD_TYPE=\$BUILD_TYPE \
-DCMAKE_C_COMPILER=\$CC \
-DCMAKE_CXX_COMPILER=\$CXX \
-DPOLYMEC_PRECISION=\$PRECISION \
\$OPTIONS \
-G "\$GENERATOR" \
\$SOURCE_DIR
EOT
# Give instructions.
echo "Your build directory $1 is ready."
echo "To configure your build:"
echo " 1. cd $1"
echo " 2. Edit config.sh"
echo " 3. sh config.sh"
echo " 4. Build using 'make' or your selected IDE."