forked from ackirby88/p4est-overset-tester
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makescript.sh
executable file
·179 lines (152 loc) · 4.11 KB
/
makescript.sh
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
#!/bin/bash
#================#
# config options #
#================#
CLEAN_DIST=0
CONF_P4EST=0
BUILD_P4EST=0
CONF_SOLVER=0
BUILD_SOLVER=0
DEBUG_ON=1
BUILD_TYPE="Debug"
#===========#
# compilers #
#===========#
CC=mpicc
CXX=mpicxx
#CC=mpiicc
#CXX=mpiicpc
# compiler paths #
CC_PATH="`which $CC`"
CXX_PATH="`which $CXX`"
LD_PATH="`which ld`"
help() {
echo " +--------- p4est-overset-tester ---------+"
echo " Configure + Build: ./makescript.sh -go "
echo " ======================================== "
echo " Configure p4est: ./makescript.sh -cp "
echo " Build p4est: ./makescript.sh -bp "
echo " Configure solver: ./makescript.sh -cs "
echo " Build solver: ./makescript.sh -bs "
echo " +----------------------------------------+"
}
if [[ $# -lt 1 ]]; then
help
exit 1
fi
for var in "$@"
do
if [ "$var" == "--help" -o "$var" == "-help" -o "$var" == "-h" ]; then
help
exit 0
elif [ "$var" == "-distclean" -o "$var" == "-dc" ]; then
echo "Found known argument: $var"
echo "Cleaning the distribution..."
CLEAN_DIST=1
elif [ "$var" == "-go" ]; then
echo -e "Found known argument: ${gC}$var${eC}"
CONF_P4EST=1
CONF_SOLVER=1
BUILD_P4EST=1
BUILD_SOLVER=1
elif [ "$var" == "-cp" ]; then
echo "Found known argument: $var"
echo "Configuring p4est..."
CONF_P4EST=1
elif [ "$var" == "-bp" ]; then
echo "Found known argument: $var"
echo "Building p4est..."
BUILD_P4EST=1
elif [ "$var" == "-cs" ]; then
echo "Found known argument: $var"
echo "Configuring solver..."
CONF_SOLVER=1
elif [ "$var" == "-bs" ]; then
echo -e "Found known argument: $var"
BUILD_SOLVER=1
else
echo "Unknown option: $var"
echo "See available options: ./makescript.sh -help"
exit
fi
done
# ========================= #
# display command line args
# ========================= #
echo "$0 $@"
cmd_args="${@:1}"
# =================================================================== #
if [ $CLEAN_DIST == 1 ]; then
rm -rf build
exit 0
fi
# =================================================================== #
# ========== #
# make p4est #
# ========== #
cd 3PL/p4est
if [ $CONF_P4EST == 1 ]; then
git submodule init
git submodule update
git checkout feature-multi
git submodule init && git submodule update
./bootstrap
fi
if [ $BUILD_P4EST == 1 ]; then
if [ $DEBUG_ON == 1 ]; then
./configure --enable-debug \
--enable-mpi \
--enable-shared \
--disable-static \
"CC=$CC" "CXX=$CXX" \
"CFLAGS=-Wall -O0 -g -Wextra -Wno-unused-parameter" \
| tee config.out
else
./configure --enable-shared \
--disable-static \
--enable-mpi \
--without-blas \
"CC=$CC" "CXX=$CXX" \
| tee config.out
fi
make;
make install
fi
cd ../..
# ============ #
# make pdriver #
# ============ #
MY_PATH="$( cd "$( dirname "$0" )" && pwd )"
P4EST_DIRECTORY=${MY_PATH}/3PL/p4est
P4EST_DIR_INSTALL=${P4EST_DIRECTORY}/local
if [ $CONF_SOLVER == 1 ]; then
if [ ! -d "${P4EST_DIR_INSTALL}" ]; then
echo "Error:"
echo "${P4EST_DIR_INSTALL} does not exist."
echo " Please build p4est first: ./makescript.sh -bp"
exit
fi
mkdir -p build
cd build
cmake -D CMAKE_C_COMPILER=${CC_PATH} \
-D CMAKE_CXX_COMPILER=${CXX_PATH} \
-D CMAKE_LINKER=${LD_PATH} \
-D CMAKE_BUILD_TYPE:STRING=${BUILD_TYPE} \
-D p4est_dir=${P4EST_DIRECTORY}/local \
-D p4est_home=${P4EST_DIRECTORY} \
-G "Unix Makefiles" .. | tee cmake_config.out
cd ..
fi
if [ $BUILD_SOLVER == 1 ]; then
if [ ! -d "${P4EST_DIR_INSTALL}" ]; then
echo "Error:"
echo "${P4EST_DIR_INSTALL} does not exist."
echo " Please build p4est first: ./makescript.sh -p4est"
exit
fi
cd build
make
cp -r ../example/* bin/.
cd ..
ln -s -f build/bin
fi