forked from intel/intel-pmwatch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_pmwatch.sh
executable file
·134 lines (126 loc) · 3.6 KB
/
build_pmwatch.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
#!/bin/bash
print_usage_and_exit()
{
echo "Usage: ./build_pmwatch.sh <-all|-cm|-m> with-libipmctl=<path_to_libipmctl> with-libipmctl-inc=<path_to_ipmctl_header_files> os=[esxi]"
exit $1
}
if [ $# = 0 ] ; then
print_usage_and_exit 0
fi
RUN_CONFIG=
RUN_MAKE=
RUN_CLEANMAKE=
BUILD_ESXI=
WITH_IPMCTL=
WITH_IPMCTL_INC=
while [ $# -gt 0 ] ; do
case "$1" in
--help | -h)
print_usage_and_exit 0
;;
-all)
RUN_CONFIG=1
RUN_CLEANMAKE=1
RUN_MAKE=1
;;
-cm)
RUN_CLEANMAKE=1
RUN_MAKE=1
;;
-m)
RUN_MAKE=1
;;
with-libipmctl=*)
WITH_IPMCTL=`echo $1 | sed s?^with-libipmctl=??g`
;;
with-libipmctl-inc=*)
WITH_IPMCTL_INC=`echo $1 | sed s?^with-libipmctl-inc=??g`
;;
os=*)
OS=`echo $1 | sed s?^os=??g`
if [[ ${OS} = "esxi" ]] ; then
BUILD_ESXI="BUILD_ESXI"
fi
;;
*)
echo ""
echo "Invalid option: \"$1\""
print_usage_and_exit 1
;;
esac
shift
done
if [[ -n "${RUN_CONFIG}" ]] ; then
echo "***************************************"
echo "Executing ./autogen.sh..."
echo "***************************************"
./autogen.sh
if [[ $? -eq 0 ]] ; then
echo "***************************************"
echo "Execution of autogen.sh successful."
echo "***************************************"
echo
else
echo "***************************************"
echo "Execution of autogen.sh failed."
echo "***************************************"
echo
exit 1
fi
echo "***************************************"
echo "Executing ./configure..."
echo "***************************************"
./configure BUILD_ESXI=${BUILD_ESXI} --with-libipmctl=${WITH_IPMCTL} --with-libipmctl-inc=${WITH_IPMCTL_INC}
if [[ $? -eq 0 ]] ; then
echo "***************************************"
echo "Execution of configure successful."
echo "***************************************"
echo
else
echo "***************************************"
echo "Execution of configure failed."
echo "***************************************"
echo
exit 1
fi
fi
if [[ -n "${RUN_CLEANMAKE}" ]] ; then
echo "***************************************"
echo "Executing make clean..."
echo "***************************************"
make clean
if [[ $? -eq 0 ]] ; then
echo "***************************************"
echo "Execution of make clean successful."
echo "***************************************"
echo
else
echo "***************************************"
echo "Execution of make clean failed."
echo "***************************************"
echo
exit 1
fi
fi
if [[ -n "${RUN_MAKE}" ]] ; then
echo "***************************************"
echo "Executing make..."
echo "***************************************"
make -j 10 | tee makelog.log
res=$?
cat makelog.log | grep "Nothing to be done for 'all'" >> /dev/null 2>&1
res_grep=$?
rm -rf makelog.log
if [[ ${res} -eq 0 && ${res_grep} -ne 0 ]] ; then
echo "***************************************"
echo "Execution of make successful."
echo "***************************************"
echo
else
echo "***************************************"
echo "Execution of make failed."
echo "***************************************"
echo
exit 1
fi
fi