-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.rb_monitor
261 lines (218 loc) · 9.11 KB
/
configure.rb_monitor
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
#!/bin/bash
#
mkl_require good_cflags
mkl_require gitversion as GITVERSION
mkl_require atomics must pass
#mkl_mkvar_append CPPFLAGS CPPFLAGS "-DFORTIFY_SOURCE=2"
mkl_mkvar_append CPPFLAGS CPPFLAGS "-DNDEBUG"
mkl_mkvar_append CPPFLAGS CPPFLAGS "-std=gnu99"
mkl_mkvar_append CPPFLAGS CPPFLAGS "-D_GNU_SOURCE"
mkl_mkvar_append CPPFLAGS CPPFLAGS "-Wunused -Wcast-align -Wdisabled-optimization -Winit-self"
mkl_mkvar_append CPPFLAGS CPPFLAGS "-Wlogical-op -Wmissing-include-dirs -Wstrict-overflow=5"
mkl_mkvar_append CPPFLAGS CPPFLAGS "-Wundef -Wall -Wextra -Wshadow -Wsign-conversion"
mkl_mkvar_append CPPFLAGS CPPFLAGS "-Wswitch-default -Wmissing-declarations"
mkl_mkvar_append CPPFLAGS CPPFLAGS "-I. -Isrc/"
#mkl_mkvar_append CPPFLAGS CPPFLAGS "-ftrack-macro-expansion=2 -Wcast-qual "
#mkl_mkvar_append CPPFLAGS CPPFLAGS "-Wjump-misses-init" # New in gcc 4.5
#mkl_mkvar_append CPPFLAGS CPPFLAGS "-Wdouble-promotion" # New in gcc 4.6
#mkl_mkvar_append CPPFLAGS CPPFLAGS "-Wunused-local-typedefs" # New in gcc 4.7
mkl_toggle_option "Standard" WITH_ZOOKEEPER "--enable-zookeeper" "Apache Zookeeper support" "n"
mkl_toggle_option "Standard" WITH_RBHTTP "--enable-rbhttp" "redBorder HTTP library to send monitors over POST messages" "n"
mkl_toggle_option "Debug" WITH_COVERAGE "--enable-coverage" "Coverage build" "n"
LIBRD_COMMIT=bb4ec7e65c8d3d411837e506e8d02f293b9a0a20
function bootstrap_librd {
if [[ -d "librd" ]]; then
# Already bootstrapped
return 0
fi
mv "librd-${LIBRD_COMMIT}" librd
cd librd
if [[ $HAVE_LTO = 'y' ]]; then
local -r cflag_lto='-flto'
local -r ar_lto='gcc-ar'
local -r ld_lto='gcc'
sed -i 's%-soname%-Wl,-soname%' Makefile
fi
CC=gcc CFLAGS="$cflag_lto" AR="$ar_lto" LD="$ld_lto" make libs
}
function checks_librd {
mkl_meta_set "librd" "desc" "Magnus Edenhill lib for rapid development"
mkl_meta_set "librd" "bootstrap_url" "https://github.com/eugpermar/librd/archive/${LIBRD_COMMIT}.zip"
mkl_meta_set "librd" "bootstrap_cppflags" "-DLIBRD_VERSION=${LIBRD_COMMIT} -I./vendor/librd"
mkl_meta_set "librd" "bootstrap_static_lib" "vendor/librd/librd/librd.a"
mkl_meta_set "librd" "bootstrap_makefn" "bootstrap_librd"
mkl_lib_check --static=-lrd "librd" "" fail CC "-lrd -lpthread -lz -lrt" \
"#include <librd/rd.h>"
}
JSON_C_VERSION=0.12.1-20160607
function bootstrap_json_c {
if [[ -d "json-c" ]]; then
# Already bootstrapped
return 0
fi
mv "json-c-json-c-${JSON_C_VERSION}" json-c
cd json-c
if [[ $HAVE_LTO = 'y' ]]; then
local -r cflag_lto='-flto'
local -r ar_lto='gcc-ar'
local -r ld_lto='gcc'
local -r ranlib_lto='gcc-ranlib'
fi
CC=gcc CFLAGS="$cflag_lto" AR="$ar_lto" LD="$ld_lto" RANLIB="$ranlib_lto" \
./configure
make
}
function checks_json_c {
mkl_meta_set "json_c" "desc" "A JSON implementation in C"
mkl_meta_set "json_c" "bootstrap_url" "https://github.com/json-c/json-c/archive/json-c-${JSON_C_VERSION}.tar.gz"
mkl_meta_set "json_c" "bootstrap_cppflags" "-I./vendor/json_c"
mkl_meta_set "json_c" "bootstrap_static_lib" "./vendor/json_c/json-c/.libs/libjson-c.a"
mkl_meta_set "json_c" "bootstrap_makefn" "bootstrap_json_c"
mkl_lib_check --static=-ljson-c "json_c" '' fail CC "-ljson-c" \
"#include <json-c/json.h>"
}
LIBMATHEVAL_VERSION=1.1.11
function bootstrap_libmatheval {
if [[ -d "libmatheval" ]]; then
# Already bootstrapped
return 0
fi
mv "libmatheval-${LIBMATHEVAL_VERSION}" libmatheval
cd libmatheval
if [[ $HAVE_LTO = 'y' ]]; then
local -r cflag_lto='-flto'
local -r ar_lto='gcc-ar'
local -r ld_lto='gcc'
local -r ranlib_lto='gcc-ranlib'
fi
CC=gcc CFLAGS="$cflag_lto" CPPFLAGS='-DSCM_ENABLE_DEPRECATED=1' AR="$ar_lto" LD="$ld_lto" RANLIB="$ranlib_lto" \
./configure
(cd lib; make) # Skip tests
}
function checks_libmatheval {
mkl_meta_set "libmatheval" "desc" "Parser and evaluator of symbolic expressions"
mkl_meta_set "libmatheval" "bootstrap_url" "https://ftp.gnu.org/gnu/libmatheval/libmatheval-${LIBMATHEVAL_VERSION}.tar.gz"
mkl_meta_set "libmatheval" "bootstrap_cppflags" "-DLIBMATHEVAL_VERSION=${LIBMATHEVAL_VERSION} -I./vendor/libmatheval/libmatheval/lib"
mkl_meta_set "libmatheval" "bootstrap_static_lib" "./vendor/libmatheval/libmatheval/lib/.libs/libmatheval.a"
mkl_meta_set "libmatheval" "bootstrap_makefn" "bootstrap_libmatheval"
mkl_lib_check --static=-lmatheval "libmatheval" "" fail CC "-lmatheval" \
"#include <matheval.h>"
}
FLEX_VERSION=2.6.4
function bootstrap_flex {
if [[ -d "flex" ]]; then
# Already bootstrapped
return 0
fi
mv "flex-${FLEX_VERSION}" flex
cd flex
if [[ $HAVE_LTO = 'y' ]]; then
local -r cflag_lto='-flto'
local -r ar_lto='gcc-ar'
local -r ld_lto='gcc'
local -r ranlib_lto='gcc-ranlib'
fi
CC=gcc CFLAGS="$cflag_lto" AR="$ar_lto" LD="$ld_lto" RANLIB="$ranlib_lto" \
./configure
make
}
function checks_flex {
mkl_meta_set "flex" "desc" "The Fast Lexical Analyzer"
mkl_meta_set "flex" "bootstrap_url" "https://github.com/westes/flex/releases/download/v${FLEX_VERSION}/flex-${FLEX_VERSION}.tar.gz"
mkl_meta_set "flex" "bootstrap_cppflags" "-I./vendor/flex/flex/lib"
mkl_meta_set "flex" "bootstrap_static_lib" "./vendor/flex/flex/src/.libs/libfl.a"
mkl_meta_set "flex" "bootstrap_makefn" "bootstrap_flex"
mkl_lib_check --static=-lfl "flex" "" fail CC "-lfl" "void *f(); void *f(){return f;}"
}
NET_SNMP_VERSION=5.7.3
function bootstrap_net_snmp {
if [[ -d "net_snmp" ]]; then
# Already bootstrapped
return 0
fi
configure_opts='--disable-agent --disable-applications --disable-manuals'
configure_opts="$configure_opts --disable-scripts"
configure_opts="$configure_opts --with-default-snmp-version=3"
configure_opts="$configure_opts --with-sys-contact='who@where'"
configure_opts="$configure_opts --with-sys-location='location'"
configure_opts="$configure_opts --with-logfile='/dev/null'"
configure_opts="$configure_opts --with-persistent-directory='/var/net-snmp'"
mv "net-snmp-${NET_SNMP_VERSION}" net_snmp
cd net_snmp
if [[ $HAVE_LTO = 'y' ]]; then
local -r cflag_lto='-flto'
local -r ar_lto='gcc-ar'
local -r ld_lto='gcc'
local -r ranlib_lto='gcc-ranlib'
fi
CC=gcc CFLAGS="$cflag_lto" CPPFLAGS='' AR="$ar_lto" LD="$ld_lto" RANLIB="$ranlib_lto" \
./configure $configure_opts
make
}
# Check for snmp library
# Arg1: Name
# Arg2: -l<> flags
# Arg3: fail / cont
function check_snmp0 {
DISPLAY_NAME=$1
SNMP_LDFLAG=$2
ACTION=$3
mkl_lib_check --static=$2 "$1" HAVE_NET_SNMP $3 CC "$2" \
"#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>"
}
function check_snmp {
mkl_meta_set "net_snmp" "desc" "libraries relating to SNMP"
check_snmp0 "net_snmp" -lsnmp "cont"
if [[ "x$HAVE_NET_SNMP" != "xy" ]]; then
# Centos >6
# Provide bootstrap instructions in case of failure
mkl_meta_set "net_snmp" "bootstrap_url" "https://sourceforge.net/projects/net-snmp/files/net-snmp/${NET_SNMP_VERSION}/net-snmp-${NET_SNMP_VERSION}.tar.gz"
# Need to add
mkl_meta_set "net_snmp" "bootstrap_cppflags" "-DNET_SNMP_VERSION=${NET_SNMP_VERSION} -DHAVE_DMALLOC_H=0 -I./vendor/net_snmp/net_snmp/include"
mkl_meta_set "net_snmp" "bootstrap_static_lib" "./vendor/net_snmp/net_snmp/snmplib/.libs/libnetsnmp.a"
mkl_meta_set "net_snmp" "bootstrap_makefn" "bootstrap_net_snmp"
check_snmp0 "net_snmp" -lnetsnmp "fail"
fi
}
function checks {
mkl_define_set "OS name" "osName" "`uname`"
mkl_lib_check pthread '' fail CC "-lpthread" \
"#include <pthread.h>
void *f();void *f(){return pthread_mutex_init;}"
mkl_lib_check --static=-lm "libmath" "" fail CC "-lm" \
"#include <math.h>"
checks_librd
checks_json_c
checks_flex
checks_libmatheval
check_snmp
# Check that librdkafka is available, and allow to link it statically.
mkl_meta_set "librdkafka" "desc" "librdkafka is available at http://github.com/edenhill/librdkafka."
mkl_meta_set "librdkafka" "deb" "librdkafka-dev"
mkl_lib_check --static=-lrdkafka "librdkafka" "" fail CC "-lrdkafka -lpthread -lz" \
"#include <librdkafka/rdkafka.h>"
# Optionals libs
mkl_meta_set "zookeeper" "desc" "Zookeeper development libraries"
mkl_meta_set "zookeeper" "deb" "libzookeeper-mt-dev"
if [ "x$WITH_ZOOKEEPER" == "xy" ]; then
mkl_lib_check "zookeeper" HAVE_ZOOKEEPER fail CC "-lzookeeper_mt" \
"#include <zookeeper/zookeeper.h>"
mkl_define_set "Zookeeper Support" "HAVE_ZOOKEEPER" "1"
fi
if [ "x$WITH_RBHTTP" == "xy" ]; then
mkl_lib_check "rbhttp" HAVE_RBHTTP fail CC "-lrbhttp -lrd" \
"#include <librbhttp/rb_http_handler.h>"
mkl_define_set "HTTP Support" "HAVE_RBHTTP" "1"
fi
# Enable assertions if we compile with no optimizations and we are not doing
# coverage testing
if [[ "x$WITHOUT_OPTIMIZATION" != "xy" || "x$WITH_COVERAGE" != "xy" ]]; then
mkl_mkvar_append CPPFLAGS CPPFLAGS "-DNDEBUG"
fi
# Enable coverage tests
if [[ "x$WITH_COVERAGE" != "xn" ]]; then
mkl_mkvar_append CPPFLAGS CPPFLAGS "--coverage"
mkl_mkvar_append LDFLAGS LDFLAGS "--coverage"
fi
}