-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathdbuild
More file actions
executable file
·196 lines (187 loc) · 4.87 KB
/
dbuild
File metadata and controls
executable file
·196 lines (187 loc) · 4.87 KB
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
#!/bin/bash
# script to quickly build d code that uses dchem, blip, lapack (through NArray) and mpi
die() {
echo "$1"
exit $2
}
version=opt
clean=
relink=
out=
compiler=
out_name=
verbose=
run=
mpi=
remote=1
if [ -z "$D_HOME" ] ; then
D_HOME=$HOME
fi
while [ $# -gt 0 ]
do
case $1 in
--help)
echo "usage: build [--version x] [--full] [--d-home d_home] [--dchem-home dchemHome]"
echo " [--run] [--blip-home blipHome]"
echo " [--out outName] [--verbose] [--mpi] mainDFile.d [compiler options]"
echo ""
echo " builds mainDFile.d linking blip and all needed libs (lapack, bz2,...)"
echo " --version x builds the version x (typically dbg or opt"
echo " --run runs the executable if sucessfully created"
echo " --full forces a clean before rebuilding"
echo " --mpi builds an mpi executable"
echo " --verbose verbose building"
echo " --d-home x uses x as d home (default is $D_HOME )"
echo " --dchem-home x uses x as dchem home (default is $D_HOME/dchem )"
echo " --blip-home x uses x as blip home (default is $D_HOME/blip )"
exit 0
;;
--version)
shift
version=$1
;;
--mpi)
mpi=1
;;
--run)
run=1
;;
--full)
clean=1
;;
--verbose)
verbose="+v"
;;
--dchem-home)
shift
DCHEM_HOME=$1
;;
--d-home)
shift
D_HOME=$1
;;
--blip-home)
shift
BLIP_HOME=$1
;;
--out)
shift
out_name=$1
;;
*.d)
main_d=$1
shift
break
;;
*)
die "expected a .d file, got $1"
break
;;
esac
shift
done
if [ -z "$BLIP_HOME" ] ; then
BLIP_HOME="$D_HOME/blip"
fi
if [ -z "$DCHEM_HOME" ] ; then
DCHEM_HOME="$D_HOME/dchem"
fi
if [ -z "$compiler" ]; then
compiler=`$BLIP_HOME/build/tools/guessCompiler.sh --path $DC`
fi
compShort=`$BLIP_HOME/build/tools/guessCompiler.sh $compiler`
case $compShort in
dmd)
linkFlag="-L"
compFlags=
versionFlag="-version="
;;
ldc)
linkFlag="-L="
compFlags="-disable-d-passes +q"
versionFlag="-d-version="
;;
*)
die "unsupported compiler"
esac
mpiVersion=
mpiFlags=
if [ -n "$mpi" ] ; then
mpiFlags=
for f in `mpicc --showme:link` ; do
mpiFlags="$mpiFlags ${linkFlag}$f"
done
mpiFlags="$mpiFlags ${versionFlag}mpi"
mpiVersion="_mpi"
fi
if [ "${version}" == "opt" ]; then
libExt=
else
libExt="-${version}"
fi
if [ "${version}${mpiVersion}" == "opt" ]; then
libExtB=
else
libExtB="-${version}${mpiVersion}"
fi
case `uname` in
Darwin)
extra_libs_os="${linkFlag}-lhwloc ${linkFlag}-lev ${linkFlag}-framework ${linkFlag}Accelerate ${linkFlag}-lz ${linkFlag}-lbz2"
;;
Linux)
if [ -n "$MKLROOT" ] ; then
extra_libs_os="${versionFlag}CBlasDot ${linkFlag}-lhwloc ${linkFlag}-lev ${linkFlag}-L$MKLROOT/lib/em64t ${linkFlag}-lmkl_lapack ${linkFlag}--start-group ${linkFlag}-lmkl_intel_lp64 ${linkFlag}-lmkl_core ${linkFlag}-lmkl_sequential ${linkFlag}--end-group ${linkFlag}-ldl ${linkFlag}-lz ${linkFlag}-lbz2"
else
extra_libs_os="${linkFlag}-lhwloc ${linkFlag}-lev ${linkFlag}-llapack ${linkFlag}-lblas ${linkFlag}-lgfortran ${linkFlag}-ldl ${linkFlag}-lz ${linkFlag}-lbz2"
fi
;;
*)
die "unknown platform, you need to set extra_libs_os"
esac
extra_libs="${linkFlag}-L${D_HOME}/lib ${linkFlag}-lblip-${compShort}$libExtB ${linkFlag}-ltango-user-${compShort}$libExt $mpiFlags $extra_libs_os"
case $version in
opt)
flags="-release -O"
;;
dbg)
flags="-g"
;;
*)
die "unknown version"
;;
esac
if [ -z "$out_name" ]; then
out_name=`basename ${main_d%%d}`$version
fi
if [ -z "$D_BUILD_DIR" ] ; then
D_BUILD_DIR=.
fi
if [ -z "$remote" ] ; then
D_BUILD_DIR=.
out2=out_name
fi
mkdir -p $D_BUILD_DIR
MAIN_DIR=`pwd`
if [ -n "$clean" ]; then
echo "rm $D_BUILD_DIR/deps_${out_name} $D_BUILD_DIR/objs_${out_name}"
rm -rf "$D_BUILD_DIR/deps_${out_name}" "$D_BUILD_DIR/objs_${out_name}"
fi
rm -f $D_BUILD_DIR/_$out_name
if [ -n "$remote" ] ; then
MAIN_DIR=`pwd`
fi
cmd="xfbuild +c$compiler $compFlags +xtango +xblip +xstd +xldc +Ddeps_${out_name} +Oobjs_${out_name} $verbose +o_$out_name $MAIN_DIR/$main_d -I$MAIN_DIR -I$BLIP_HOME -I$DCHEM_HOME $flags $extra_libs $*"
if [ -n "$verbose" ] ; then
echo "$cmd"
fi
if [ -n "$remote" ] ; then
pushd $D_BUILD_DIR
fi
$cmd || exit 1
mv _$out_name $MAIN_DIR/$out_name
if [ -n "$remote" ] ; then
popd
fi
if [ -n "$run" ] ; then
./$out_name
fi