forked from hfp/xconfigure
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure-get.sh
executable file
·122 lines (112 loc) · 4.18 KB
/
configure-get.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
#!/usr/bin/env bash
###############################################################################
# Copyright (c) Intel Corporation - All rights reserved. #
# This file is part of the XCONFIGURE project. #
# #
# For information on the license, see the LICENSE file. #
# Further information: https://github.com/hfp/xconfigure/ #
# SPDX-License-Identifier: BSD-3-Clause #
###############################################################################
# Hans Pabst (Intel Corp.)
###############################################################################
BASENAME=$(command -v basename)
CHMOD=$(command -v chmod)
WGET=$(command -v wget)
CAT=$(command -v cat)
CUT=$(command -v cut)
TR=$(command -v tr)
LS=$(command -v ls)
RM=$(command -v rm)
MV=$(command -v mv)
BASEURL=https://github.com/hfp/xconfigure/raw/master/config
ERROR_NOTFOUND=8
APPLICATION=$1
ARCHS=$2
KINDS=$3
if [ "" = "${BASENAME}" ] || [ "" = "${CHMOD}" ] || [ "" = "${WGET}" ] || \
[ "" = "${CAT}" ] || [ "" = "${CUT}" ] || [ "" = "${TR}" ] || \
[ "" = "${LS}" ] || [ "" = "${RM}" ] || [ "" = "${MV}" ];
then
echo "Error: prerequisites not found!"
exit 1
fi
WGET="${WGET} --no-check-certificate --no-cache"
if [ "" = "${APPLICATION}" ]; then
echo "Please use: $0 <application-name>"
exit 1
fi
echo "Be patient, it can take up to 30 seconds before progress is shown..."
echo
if [ "0" != $(${WGET} -S --spider ${BASEURL}/${APPLICATION}/README.md 2>/dev/null; echo $?) ]; then
echo "Error: cannot find a recipe for application \"${APPLICATION}\"!"
exit 1
fi
MSGBUFFER=$(mktemp .configure-XXXXXX.buf)
if [ "" = "${ARCHS}" ]; then
ARCHS="snb hsw knl skx"
fi
if [ "" = "${KINDS}" ]; then
KINDS="omp gnu gnu-omp"
for KIND in ${KINDS} ; do
if [ "${ERROR_NOTFOUND}" != "$(${WGET} -N ${BASEURL}/${APPLICATION}/configure-${APPLICATION}-${KIND}.sh 2>${MSGBUFFER}; echo $?)" ]; then
${CAT} ${MSGBUFFER}
fi
done
for ARCH in ${ARCHS} ; do
if [ "${ERROR_NOTFOUND}" != "$(${WGET} -N ${BASEURL}/${APPLICATION}/configure-${APPLICATION}-${ARCH}.sh 2>${MSGBUFFER}; echo $?)" ]; then
${CAT} ${MSGBUFFER}
fi
for KIND in ${KINDS} ; do
if [ "${ERROR_NOTFOUND}" != "$(${WGET} -N ${BASEURL}/${APPLICATION}/configure-${APPLICATION}-${ARCH}-${KIND}.sh 2>${MSGBUFFER}; echo $?)" ]; then
${CAT} ${MSGBUFFER}
fi
done
done
if [ "${ERROR_NOTFOUND}" != "$(${WGET} -N ${BASEURL}/${APPLICATION}/configure-${APPLICATION}.sh 2>${MSGBUFFER}; echo $?)" ]; then
${CAT} ${MSGBUFFER}
fi
else
for ARCH in ${ARCHS} ; do
for KIND in ${KINDS} ; do
if [ "${ERROR_NOTFOUND}" != "$(${WGET} -N ${BASEURL}/${APPLICATION}/configure-${APPLICATION}-${ARCH}-${KIND}.sh 2>${MSGBUFFER}; echo $?)" ]; then
${CAT} ${MSGBUFFER}
fi
done
done
if [ "${ERROR_NOTFOUND}" != "$(${WGET} -N ${BASEURL}/${APPLICATION}/configure-${APPLICATION}.sh 2>${MSGBUFFER}; echo $?)" ]; then
${CAT} ${MSGBUFFER}
fi
fi
# attempt to get a list of non-default file names, and then download each file
if [ "${ERROR_NOTFOUND}" != "$(${WGET} -N ${BASEURL}/${APPLICATION}/.filelist 2>${MSGBUFFER}; echo $?)" ]; then
${CAT} ${MSGBUFFER}
fi
if [ -e .filelist ]; then
${CAT} .filelist | ${TR} -s " " | \
while read LINE; do
FILE=$(echo "${LINE}" | ${CUT} -d" " -f1)
DIR=$(echo "${LINE}" | ${CUT} -d" " -f2)
if [ "" != "${LINE}" ]; then # skip empty lines
if [[ "${FILE}" =~ "://" ]]; then
${WGET} -N ${FILE}
else
${WGET} -N ${BASEURL}/${APPLICATION}/${FILE}
fi
if [ "${FILE}" != "${DIR}" ] && [ -d ${DIR} ]; then
${MV} $(${BASENAME} ${FILE}) ${DIR}
fi
fi
done
# cleanup list of file names
${RM} .filelist
fi
# make all scripts executable (beyond application)
${CHMOD} +x *.sh 2>/dev/null
# cleanup message buffer
${RM} ${MSGBUFFER}
if [ "" = "$(${LS} -1 configure-${APPLICATION}*.sh 2>/dev/null)" ]; then
# display reminder about build recipe
echo
echo "There is no configuration needed! Please read:"
echo "https://xconfigure.readthedocs.io/${APPLICATION}/"
fi