-
Notifications
You must be signed in to change notification settings - Fork 34
/
configure
executable file
·239 lines (218 loc) · 7.08 KB
/
configure
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
#!/bin/bash
# Simple configuration script for people who expect such a script to exist.
# Please do not convert istatd to autotools. We will likely not accept such
# a conversion. Thanks for your interest in istatd, and good luck!
set -e
set -o nounset
rm -f makevars.config
rm -f config.h
# Find Python version 3.
# If this fails, you need to create appropriate aliases or symlinks for
# testing to work!
/usr/bin/env python3 -V
if curl --help >/dev/null 2>&1; then echo "Found curl in path."; else
echo "You need to install the command-line tool 'curl'."
exit 1
fi
if cat /dev/null | zlib-flate -compress; then echo "Found zlib-flate in path."; else
echo "You need to install the command-line tool 'zlib-flate'."
echo "On debian systems run 'sudo apt-get install qpdf'"
exit 1
fi
echo "# makevars.config for istatd generated on " `date` > makevars.config
BOOST_SYSTEM=""
BOOST_FILESYSTEM=""
BOOST_THREAD=""
BOOST_IOSTREAMS=""
STATGRAB=""
LIBRT=""
DESTDIR=""
USR_PREFIX=""
VAR_PREFIX=""
ETC_PREFIX=""
while [ $# -gt 0 ]; do
case $1 in
--boost_system)
shift
BOOST_SYSTEM="$1"
;;
--boost_filesystem)
shift
BOOST_FILESYSTEM="$1"
;;
--boost_thread)
shift
BOOST_THREAD="$1"
;;
--boost_iostreams)
shift
BOOST_IOSTREAMS="$1"
;;
--statgrab)
shift
STATGRAB="$1"
;;
--librt)
shift
LIBRT="$1"
;;
--prefix)
shift
DESTDIR="$1"
;;
--usr-prefix)
shift
USR_PREFIX="$1"
;;
--var-prefix)
shift
VAR_PREFIX="$1"
;;
--etc-prefix)
shift
ETC_PREFIX="$1"
;;
*)
echo "Options:"
echo "--boost_system -lboost_system-mt What is the boost_system library name?"
echo "--boost_filesystem -lboost_filesystem-mt What is the boost_filesystem library name?"
echo "--boost_thread -lboost_thread-mt What is the boost_thread library name?"
echo "--boost_iostreams -lboost_iostreams-mt What is the boost_iostreams library name?"
echo "--statgrab -lstatgrab What is the statgrab library name?"
echo "--librt -lrt What is the librt library name (if any)?"
echo "--prefix / What is the root of the install?"
echo "--usr-prefix /usr What is the '/usr' directory for executables?"
echo "--var-prefix /var What is the '/var' directory for database data?"
echo "--etc-prefix /etc What is the '/etc/ directory for rc.d scripts?"
echo "No equal sign for option values."
exit 1
;;
esac
shift
done
# see if we need to install boost
if [ ! -d /usr/include/boost -a ! -d /usr/local/include/boost ]; then
echo "You need to install libboost-all-dev for your distribution."
exit 1
fi
if [ ! -r /usr/include/statgrab.h -a ! -r /usr/local/include/statgrab.h ]; then
echo "You need to install libstatgrab-dev for your distribution, or "
echo "download and install it from source. See README.md"
exit 1
fi
function findone() {
libs=$*
mkdir -p tmp
fn=tmp/tt$$.c
echo "int main() { return 0; }" > "$fn"
for i in $libs; do
if gcc -o tmp/tt "$fn" $i > /dev/null 2>&1; then
echo -n $i
rm -rf tmp
return
fi
done
}
# boost_system is a pain across versions
if [ -z "$BOOST_SYSTEM" ]; then
BOOST_SYSTEM=`findone -lboost_system -lboost_system-mt`
if [ -z "$BOOST_SYSTEM" ]; then
echo "Cannot find boost_system-mt.so (or boost_system.so)"
echo "Specify it with --boost_system or install libboost-all-dev."
echo "Ubuntu users can also use ./install-boost-dev.sh as root"
exit 1
fi
fi
# boost_filesystem is also somewhat a pain
if [ -z "$BOOST_FILESYSTEM" ]; then
BOOST_FILESYSTEM=`findone -lboost_filesystem -lboost_filesystem-mt`
if [ -z "$BOOST_FILESYSTEM" ]; then
echo "Cannot find boost_filesystem-mt.so (or boost_filesystem.so)"
echo "Specify it with --boost_filesystem or install libboost-all-dev."
exit 1
fi
fi
# RHEL can't find boost_thread on its own.
if [ -z "$BOOST_THREAD" ]; then
BOOST_THREAD=`findone -lboost_thread -lboost_thread-mt`
if [ -z "$BOOST_THREAD" ]; then
echo "Cannot find boost_thread-mt.so (or boost_thread.so)"
echo "Specify it with --boost_thread or install libboost-all-dev."
exit 1
fi
fi
if [ -z "$BOOST_IOSTREAMS" ]; then
BOOST_IOSTREAMS=`findone -lboost_iostreams -lboost_iostreams-mt`
if [ -z "$BOOST_IOSTREAMS" ]; then
echo "Cannot find boost_iostreams-mt.so (or boost_iostreams.so)"
echo "Specify it with --boost_iostreams or install libboost-all-dev."
exit 1
fi
fi
if [ -z "$STATGRAB" ]; then
STATGRAB=`findone -lstatgrab`
if [ -z "$STATGRAB" ]; then
echo "Cannot find libstatgrab.so"
echo "Specify it with --statgrab or install libstatgrab-dev."
echo "Or try https://github.com/imvu-open/libstatgrab"
exit 1
fi
fi
if [ -z "$LIBRT" ]; then
mkdir -p tmp
fn=tmp/tt$$.c
echo "#include <time.h>" > "$fn"
echo "int main() { (void)clock_gettime(0, NULL); }" >> "$fn"
if gcc -o tmp/tt "$fn" > /dev/null 2>&1; then
LIBRT=""
else
LIBRT="-lrt"
fi
rm -rf tmp
fi
if [ ! -z "$BOOST_SYSTEM" ]; then
echo "BOOST_SYSTEM=$BOOST_SYSTEM" >> makevars.config
fi
if [ ! -z "$BOOST_FILESYSTEM" ]; then
echo "BOOST_FILESYSTEM=$BOOST_FILESYSTEM" >> makevars.config
fi
if [ ! -z "$BOOST_THREAD" ]; then
echo "BOOST_THREAD=$BOOST_THREAD" >> makevars.config
fi
if [ ! -z "$BOOST_IOSTREAMS" ]; then
echo "BOOST_IOSTREAMS=$BOOST_IOSTREAMS" >> makevars.config
fi
if [ ! -z "$STATGRAB" ]; then
echo "STATGRAB=$STATGRAB" >> makevars.config
fi
if [ ! -z "$LIBRT" ]; then
echo "LIBRT=$LIBRT" >> makevars.config
fi
if [ ! -z "$DESTDIR" ]; then
echo "DESTDIR=$DESTDIR" >> makevars.config
fi
if [ ! -z "$USR_PREFIX" ]; then
echo "USR_PREFIX=$USR_PREFIX" >> makevars.config
fi
if [ ! -z "$VAR_PREFIX" ]; then
echo "VAR_PREFIX=$VAR_PREFIX" >> makevars.config
fi
if [ ! -z "$ETC_PREFIX" ]; then
echo "ETC_PREFIX=$ETC_PREFIX" >> makevars.config
fi
echo "checking for libstatgrab interface version"
echo "/* config.h generated by configure script */" >> config.h
echo "" >> config.h
mkdir -p tmp
fn=tmp/sg.c
echo "#include <statgrab.h>" > "$fn"
echo "int main() { sg_get_cpu_percents(); }" >> "$fn"
if ! gcc -o tmp/sg.o -c "$fn" > /dev/null 2>&1; then
echo "libstatgrab 0.17 interface doesn't work, assuming 0.90"
echo "#define LIBSTATGRAB_API_0_90" >> config.h
else
echo "found libstatgrab 0.17 interface"
echo "#define LIBSTATGRAB_API_0_17" >> config.h
fi
rm -rf tmp
echo "All done"