blob: 2ccb09427ed919bf37847dd85063a6276bfe2237 (
plain)
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
|
#!/bin/bash
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# Author: Derek Dolney <dolney@astro.physics.upenn.edu>
# Based on gcc-config by Martin Schlemmer <azarah@gentoo.org>
source /etc/init.d/functions.sh || {
echo "$0: Could not source /etc/init.d/functions.sh!"
exit 1
}
get_libdir() {
MY_LIBDIR="$(portageq envvar CONF_LIBDIR)"
# This is for < portage-2.0.51_pre20 support
echo ${MY_LIBDIR:=lib}
}
# Some variables you might want to know about:
# (* = C, F77, ...)
#
# C_PROFILE and F77_PROFILE: profile requested by user on command line
#
# C_CURRENT and F77_CURRENT: full path to current profile recorded in
# CONFIG_FILE
PROFILE_PATH=/usr/$(get_libdir)/lapack
CONFIG_FILE=${PROFILE_PATH}/current
usage() {
cat << "USAGE_END"
Usage: lapack-config [Option] [LAPACK Profile]
Change the current LAPACK profile, or give info about profiles.
Options:
-p, --print-current-profile
Print currently used LAPACK profiles.
-l, --list-profiles
Print a list of available profiles.
--f77libs Print flags to link with the LAPACK library for the
given/current LAPACK profile.
USAGE_END
exit 1
}
if [ "$#" -lt 1 ]
then
usage
fi
check_root() {
if [ "$(id -u)" -ne 0 ]
then
eerror "$0: Must be root."
exit 1
fi
}
get_current_profile() {
if [ -f ${CONFIG_FILE} ]
then
source ${CONFIG_FILE}
C_CURRENT="${PROFILE_PATH}/${C_CURRENT}"
F77_CURRENT="${PROFILE_PATH}/${F77_CURRENT}"
fi
}
print_current_profile() {
local FP="none"
# local CP="none"
if [ -n "${F77_CURRENT}" ]
then
FP="${F77_CURRENT##*/}"
FP="${F77_CURRENT##f77-/}"
fi
# if [ -n "${C_CURRENT}" ]
# then
# CP="${C_CURRENT##*/}"
# CP="${C_CURRENT##c-/}"
# fi
echo
echo "Current profile:"
echo "F77 LAPACK: ${FP}"
# echo "C LAPACK: ${CP}"
}
list_profiles() {
local i=1
# echo
# echo "Available C profiles:"
# for x in ${PROFILE_PATH}/c-*
# do
# if [ -f "${x}" ]
# then
# x=${x##*/}
# x=${x/c-/}
# echo "[${i}] ${x##*/}"
# i=$((i + 1))
# fi
# done
echo
i=1
echo "Available F77 profiles:"
for x in ${PROFILE_PATH}/f77-*
do
if [ -f "${x}" ]
then
x=${x##*/}
x=${x/f77-/}
echo "[${i}] ${x}"
i=$((i + 1))
fi
done
}
set_c_profile() {
check_root
if [ -z "${C_PROFILE}" ]
then
usage
else
source ${PROFILE_PATH}/${C_PROFILE}
setup
C_PROFILE_CHANGED="yes"
fi
}
set_f77_profile() {
check_root
if [ -z "${F77_PROFILE}" ]
then
usage
else
source ${PROFILE_PATH}/${F77_PROFILE}
setup
F77_PROFILE_CHANGED="yes"
fi
}
list_cflags() {
if [ -n "${C_PROFILE}" ]
then
source ${PROFILE_PATH}/${C_PROFILE}
echo -n "${CFLAGS} "
elif [ -n "${C_CURRENT}" ]
then
source ${C_CURRENT}
echo -n "${CFLAGS} "
else
eerror "No C LAPACK profile is active."
fi
}
list_clibs() {
if [ -n "${C_PROFILE}" ]
then
source ${PROFILE_PATH}/${C_PROFILE}
echo -n "${CLIBS} "
elif [ -n "${C_CURRENT}" ]
then
source ${C_CURRENT}
echo -n "${CLIBS} "
else
eerror "No C LAPACK profile is active."
fi
}
list_f77libs() {
if [ -n "${F77_PROFILE}" ]
then
source ${PROFILE_PATH}/${F77_PROFILE}
echo -n "${F77LIBS} "
elif [ -n "${F77_CURRENT}" ]
then
source ${F77_CURRENT}
echo -n "${F77LIBS} "
else
eerror "No F77 LAPACK profile is active."
fi
}
TODO=""
C_PROFILE_CHANGED="no"
F77_PROFILE_CHANGED="no"
for x in $*
do
case "${x}" in
-p|--print-current-profile)
TODO="${TODO}print_current_profile;"
;;
-l|--list-profiles)
TODO="${TODO}list_profiles;"
;;
# -c|--set-c-profile)
# if [ "${TODO}" != "${TODO#set_f77_profile}" ]
# then
# usage
# else
# TODO="${TODO}set_c_profile;"
# fi
# ;;
# -f|--set-f77-profile)
# if [ "${TODO}" != "${TODO#set_c_profile}" ]
# then
# usage
# else
# TODO="${TODO}set_f77_profile;"
# fi
# ;;
# --cflags)
# TODO="${TODO}list_cflags;"
# ;;
# --clibs)
# TODO="${TODO}list_clibs;"
# ;;
--f77libs)
TODO="${TODO}list_f77libs;"
;;
-*)
eerror "$0: Invalid switch! Run $0 without parameters for help."
exit 1
;;
*)
if [ -z "${PROFILE}" ]
then
for y in ${PROFILE_PATH}/*
do
[ "${y}" == "${CONFIG_FILE}" ] && continue
if [ -f "${y}" ]
then
if [ "${x}" == "${y##*/}" ]
then
PROFILE="${x}"
if [ "${PROFILE}" != "${PROFILE#c-}" ]
then
C_PROFILE="${PROFILE}"
elif [ "${PROFILE}" != "${PROFILE#f77-}" ]
then
F77_PROFILE="${PROFILE}"
fi
else
if [ "c-${x}" == "${y##*/}" ]
then
PROFILE="${x}"
C_PROFILE="c-${x}"
fi
if [ "f77-${x}" == "${y##*/}" ]
then
PROFILE="${x}"
F77_PROFILE="f77-${x}"
fi
fi
fi
done
if [ -z "${PROFILE}" ]
then
eerror "$0: ${x} is not a valid profile!"
exit 1
fi
else
usage
fi
;;
esac
done
get_current_profile
if [ -z "${TODO}" ]
then
if [ -z "${PROFILE}" ]
then
usage
else
# if [ -n "${C_PROFILE}" ]
# then
# set_c_profile
# fi
if [ -n "${F77_PROFILE}" ]
then
set_f77_profile
fi
fi
fi
eval ${TODO}
echo
NEW_CONFIG_FILE=""
if [ "${C_PROFILE_CHANGED}" == "yes" -o "${F77_PROFILE_CHANGED}" == "yes" ]
then
# if [ "${C_PROFILE_CHANGED}" == "yes" ]
# then
# NEW_CONFIG_FILE="C_CURRENT=\"${C_PROFILE}\""
# elif [ -n "${C_CURRENT}" ]
# then
# NEW_CONFIG_FILE="C_CURRENT=\"${C_CURRENT##*/}\""
# fi
if [ "${F77_PROFILE_CHANGED}" == "yes" ]
then
NEW_CONFIG_FILE="F77_CURRENT=\"${F77_PROFILE}\""
elif [ -n "${F77_CURRENT}" ]
then
NEW_CONFIG_FILE="F77_CURRENT=\"${F77_CURRENT##*/}\""
fi
echo -e "${NEW_CONFIG_FILE}" > ${CONFIG_FILE}
exec /usr/sbin/env-update
fi
# vim:ts=8
|