-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.in
359 lines (307 loc) · 11.7 KB
/
configure.in
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
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
#
# RTG 0.8.1 configure.in
# Author: Rob Beverly <[email protected]>
#
AC_INIT(src/rtg.h)
AC_CONFIG_AUX_DIR(config)
AC_SUBST(ac_aux_dir)
AM_INIT_AUTOMAKE(rtg2, 2.0.0)
AC_SUBST(VERSION)
AM_CONFIG_HEADER(config/config.h)
AC_CANONICAL_HOST
AC_PREFIX_DEFAULT(/usr/local/rtg2)
dnl Define auxiliary libraries
CGI_LIB_DIR=cgilib-0.4
dnl Compilation Setup
AC_ARG_WITH(mysql,
[ --with-mysql=PATH MySQL path [default=/usr/local]],,)
AC_ARG_WITH(pgsql,
[ --with-pgsql=PATH Postgres path [default=/usr/local]],,)
AC_ARG_WITH(snmp,
[ --with-snmp=PATH SNMP path [default=/usr/local]],,)
AC_ARG_WITH(gd,
[ --with-gd=PATH gd path [default=/usr/local]],,)
AC_ARG_WITH(png,
[ --with-png=PATH png path [default=/usr/local]],,)
dnl substitute them in all the files listed in AC_OUTPUT
AC_SUBST(CGI_LIB_DIR)
AC_SUBST(MYSQL_DIR)
AC_SUBST(RTG_HOME)
AC_SUBST(DBD_DRIVER)
dnl if host_alias is empty, ac_cv_host_alias may still have the info
if test -z "$host_alias"; then
host_alias=$ac_cv_host_alias
fi
dnl Platform-specific tweaks
case $host_alias in
*solaris*)
CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
CFLAGS="$CFLAGS -D_POSIX_PTHREAD_SEMANTICS";;
*freebsd*)
LIBS="$LIBS -pthread"
AC_DEFINE(HAVE_LIBPTHREAD, 1);;
esac
dnl Checks for programs.
AC_PROG_AWK
AC_PROG_CC
AC_PROG_CPP
AC_PROG_INSTALL
AC_PROG_LN_S
AC_DISABLE_STATIC
AC_PROG_LIBTOOL
AC_PROG_YACC
AM_PROG_LEX
AC_MSG_CHECKING([whether to enable -Wall])
AC_ARG_ENABLE(warnings,
[ --enable-warnings Enable -Wall if using gcc.],
[ if test -n "$GCC"; then
AC_MSG_RESULT(adding -Wall to CFLAGS.)
CFLAGS="$CFLAGS -Wall"
fi],AC_MSG_RESULT(no))
dnl Checks for libraries.
AC_CHECK_LIB(kstat, kstat_lookup)
AC_CHECK_LIB(nsl, gethostbyname)
AC_CHECK_LIB(socket, socket)
AC_CHECK_LIB(m, floor)
AC_CHECK_LIB(pthread, pthread_exit)
AC_CHECK_LIB(rt, clock_gettime)
dnl Some builds of MySQL require libz - try to detect
AC_CHECK_LIB(z, deflate)
dnl check for libtool
AC_MSG_CHECKING(libtool)
for i in /usr /usr/local; do
test -f $i/lib/x86_64-linux-gnu/libltdl.a -o -f $i/lib/libltdl.so && LT_LIBDIR=$i/lib/x86_64-linux-gnu/
test -f $i/lib/libltdl.a -o -f $i/lib/libltdl.so && LT_LIBDIR=$i/lib
test -f $i/lib64/libltdl.a -o -f $i/lib64/libltdl.so && LT_LIBDIR=$i/lib64
done
LDFLAGS="-L$LT_LIBDIR $LDFLAGS"
AC_CHECK_LIB(ltdl, lt_dlinit,,AC_MSG_ERROR(Cannot link with libtool libs! (libltdl)))
dnl Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS(malloc.h math.h syslog.h ctype.h sys/time.h netinet/in.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_TYPES([unsigned long long, long long])
AC_C_CONST
AC_TYPE_SIZE_T
AC_HEADER_TIME
AC_STRUCT_TM
dnl Checks for library functions.
AC_TYPE_SIGNAL
AC_CHECK_FUNCS(gettimeofday strerror strtoll)
dnl Determine RTG home installation path for script substitution
if test "x$prefix" != "xNONE"; then
RTG_HOME=$prefix
else
RTG_HOME=/usr/local/rtg2
fi
AC_DEFINE_UNQUOTED(RTG_HOME, "$RTG_HOME", RTG root installation prefix)
dnl ****************** Begin PNG checking ***********************
if test "x$with_png" != "x"; then
PNG_DIR=$with_png
for i in / /include /include/png /png; do
test -f $with_png/$i/png.h && PNG_INCDIR=$with_png/$i
done
test -f $with_png/lib/libpng.a -o -f $with_png/lib/libpng.so && PNG_LIBDIR=$with_png/lib
test -f $with_png/lib64/libpng.a -o -f $with_png/lib64/libpng.so && PNG_LIBDIR=$with_png/lib64
test -f $with_png/libpng.a -o -f $with_png/libpng.so && PNG_LIBDIR=$with_png
else
for i in /usr/include /usr/local/include; do
test -f $i/png.h && PNG_INCDIR=$i
done
for i in /usr /usr/local /usr/local/png; do
test -f $i/lib/libpng.a -o -f $i/lib/libpng.so && PNG_LIBDIR=$i/lib
test -f $i/lib64/libpng.a -o -f $i/lib64/libpng.so && PNG_LIBDIR=$i/lib64
done
fi
LDFLAGS="-L$PNG_LIBDIR $LDFLAGS"
dnl CFLAGS="-I$PNG_INCDIR $CFLAGS"
CPPFLAGS="$CPPFLAGS -I$PNG_INCDIR"
AC_CHECK_HEADER(png.h,[],AC_MSG_ERROR(Can't find png.h!))
AC_CHECK_LIB(png, png_read_info)
dnl ****************** End PNG checking ***********************
dnl ****************** Begin GD checking ***********************
if test "x$with_gd" != "x"; then
GD_DIR=$with_gd
for i in / /include /include/gd /gd; do
test -f $with_gd/$i/gd.h && GD_INCDIR=$with_gd/$i
done
test -f $with_gd/lib/libgd.a -o -f $with_gd/lib/libgd.so && GD_LIBDIR=$with_gd/lib
test -f $with_gd/libgd.a -o -f $with_gd/libgd.so && GD_LIBDIR=$with_gd
else
for i in /usr/include /usr/local/include /usr/local/include/gd; do
test -f $i/gd.h && GD_INCDIR=$i
done
for i in /usr /usr/local; do
test -f $i/lib/libgd.a -o -f $i/lib/libgd.so && GD_LIBDIR=$i/lib
test -f $i/lib64/libgd.a -o -f $i/lib64/libgd.so && GD_LIBDIR=$i/lib64
test -f $i/lib/gd/libgd.a -o -f $i/lib/gd/libgd.so && GD_LIBDIR=$i/lib/gd
test -f $i/lib64/gd/libgd.a -o -f $i/lib64/gd/libgd.so && GD_LIBDIR=$i/lib64/gd
done
fi
LDFLAGS="-L$GD_LIBDIR $LDFLAGS"
dnl CFLAGS="-I$GD_INCDIR $CFLAGS"
CPPFLAGS="$CPPFLAGS -I$GD_INCDIR"
AC_CHECK_HEADER(gd.h,[],AC_MSG_ERROR(Can't find gd.h!))
AC_CHECK_LIB(gd, gdImageCreateFromPng,[],AC_MSG_ERROR(Can't find libgd!))
dnl ****************** End GD checking ***********************
dnl if test "x$with_pgsql" != "x"; then
dnl ****************** Begin Postgres checking ***********************
AC_MSG_CHECKING(pgsql)
if test "x$with_pgsql" != "xyes"; then
PGSQL_DIR=$with_pgsql
else
for i in /usr /usr/local /usr/local/psql; do
test -f $i/bin/psql && PGSQL_DIR=$i
done
fi
for i in $PGSQL_DIR /usr /usr/local; do
test -f $i/include/libpq-fe.h && PGSQL_INC_DIR=$i/include
test -f $i/include/postgresql/libpq-fe.h && PGSQL_INC_DIR=$i/include/postgresql
done
if test -z "$PGSQL_INC_DIR"; then
if test "x$with_pgsql" != "x"; then
AC_MSG_ERROR(Cannot find Postgres header files under $PGSQL_DIR)
else
AC_MSG_WARN(Cannot find Postgres headers. Use --with-pgsql= to specify non-default path.)
fi
fi
AC_CHECK_LIB(pq, PQconnectdb,
[ LIBS="-lpq $LIBS"
ltlibraries="librtgpgsql.la $ltlibraries"
CPPFLAGS="$CPPFLAGS -I$PGSQL_INC_DIR"
AC_DEFINE(HAVE_PGSQL, 1, [Whether you have Postgres]) ],
AC_MSG_WARN(Cannot link with Postgres libs! (pq)))
DBD_DRIVER="Pg"
dnl ****************** End Postgres checking ***********************
dnl else
dnl ****************** Begin MySQL checking ***********************
AC_MSG_CHECKING(mysql)
AC_DEFUN([MYSQL_LIB_CHK],[
str="$1/libmysqlclient.*"
for j in `echo $str`; do
if test -r $j; then
MYSQL_LIB_DIR=$1
break 2
fi
done
])
if test "x$with_mysql" != "x"; then
MYSQL_DIR=$with_mysql
else
for i in /usr /usr/local /usr/local/mysql; do
test -f $i/bin/mysql && MYSQL_DIR=$i
done
fi
for i in $MYSQL_DIR /usr /usr/local /usr/local/mysql /usr/include/mariadb; do
test -f $i/mysql.h && MYSQL_INC_DIR=$i
test -f $i/include/mysql.h && MYSQL_INC_DIR=$i/include
test -f $i/include/mysql/mysql.h && MYSQL_INC_DIR=$i/include/mysql
test -f $i/mysql/include/mysql.h && MYSQL_INC_DIR=$i/mysql/include
done
if test -z "$MYSQL_INC_DIR"; then
if test "x$with_mysql" != "x"; then
AC_MSG_ERROR(Cannot find MySQL header files under $MYSQL_DIR)
else
AC_MSG_WARN(Cannot find MySQL headers. Use --with-mysql= to specify non-default path.)
fi
fi
for i in $MYSQL_DIR /usr /usr/local /usr/local/mysql; do
MYSQL_LIB_CHK($i/lib64)
MYSQL_LIB_CHK($i/lib)
MYSQL_LIB_CHK($i/lib64/mysql)
MYSQL_LIB_CHK($i/lib/mysql)
MYSQL_LIB_CHK($i/lib/x86_64-linux-gnu/)
done
if test -d "$MYSQL_LIB_DIR"; then
AC_DEFINE(HAVE_MYSQL, 1, [Whether you have MySQL])
else
AC_MSG_WARN(Cannot find thread-safe MySQL library (libmysqlclient_r))
fi
DBD_DRIVER="mysql"
LDFLAGS="-L$MYSQL_LIB_DIR $LDFLAGS"
CPPFLAGS="$CPPFLAGS -I$MYSQL_INC_DIR"
AC_CHECK_LIB(mysqlclient_r, mysql_thread_init,
[ LIBS="-lmysqlclient_r $LIBS"
ltlibraries="librtgmysql.la $ltlibraries" ],
AC_MSG_WARN(Cannot link with thread-safe MySQL lib (libmysqlclient_r)))
dnl ****************** End MySQL checking ***********************
dnl fi
dnl ****************** Begin SNMP checking ***********************
dnl Determine UCD or Net-SNMP installation paths
if test "x$with_snmp" != "x"; then
for i in / /ucd-snmp /include/ucd-snmp; do
test -f $with_snmp/$i/snmp.h && SNMP_INCDIR=$with_snmp/$i
done
for i in / /net-snmp /include/net-snmp; do
test -f $with_snmp/$i/net-snmp-config.h && SNMP_INCDIR=$with_snmp/$i
done
test -f $with_snmp/lib/libsnmp.a -o -f $with_snmp/lib/libsnmp.so && SNMP_LIBDIR=$with_snmp/lib
test -f $with_snmp/lib/libnetsnmp.a -o -f $with_snmp/lib/libnetsnmp.so && SNMP_LIBDIR=$with_snmp/lib
AC_DEFINE(IN_UCD_SNMP_SOURCE, 1, [UCD SNMP Path Explicitly Defined])
else
for i in /usr/include /usr/local/include; do
test -f $i/snmp.h && SNMP_INCDIR=$i
test -f $i/ucd-snmp/snmp.h && SNMP_INCDIR=$i/ucd-snmp
test -f $i/net-snmp/net-snmp-config.h && SNMP_INCDIR=$i/net-snmp
test -f $i/snmp/snmp.h && SNMP_INCDIR=$i/snmp
test -f $i/snmp/include/ucd-snmp/snmp.h && SNMP_INCDIR=$i/snmp/include/ucd-snmp
test -f $i/snmp/include/net-snmp/net-snmp-config.h && SNMP_INCDIR=$i/snmp/include/net-snmp
done
for i in /usr /usr/snmp /usr/local /usr/local/snmp; do
test -f $i/lib/libsnmp.a -o -f $i/lib/libsnmp.so && SNMP_LIBDIR=$i/lib
test -f $i/lib64/libsnmp.a -o -f $i/lib64/libsnmp.so && SNMP_LIBDIR=$i/lib64
test -f $i/lib/libnetsnmp.a -o -f $i/lib/libnetsnmp.so && SNMP_LIBDIR=$i/lib
test -f $i/lib64/libnetsnmp.a -o -f $i/lib64/libnetsnmp.so && SNMP_LIBDIR=$i/lib64
done
fi
if test -z "$SNMP_INCDIR"; then
if test "x$with_snmp" != "x";then
AC_MSG_ERROR(Cannot find SNMP header files under $with_snmp)
else
AC_MSG_ERROR(Cannot find SNMP headers. Use --with-snmp= to specify non-default path.)
fi
fi
LDFLAGS="-L$SNMP_LIBDIR $LDFLAGS"
CPPFLAGS="$CPPFLAGS -I$SNMP_INCDIR -I$SNMP_INCDIR/.."
dnl Net/UCD-SNMP includes v3 support and insists on crypto unless
dnl compiled --without-openssl
AC_MSG_CHECKING([if UCD-SNMP needs crypto support])
SNMP_SSL=no
AC_TRY_COMPILE([#include <ucd-snmp-config.h>], [exit(USE_OPENSSL != 1);],
[ AC_MSG_RESULT(yes)
SNMP_SSL=yes ],
AC_MSG_RESULT(no))
AC_MSG_CHECKING([if Net-SNMP needs crypto support])
AC_TRY_COMPILE([#include <net-snmp-config.h>], [exit(USE_OPENSSL != 1);],
[ AC_MSG_RESULT(yes)
SNMP_SSL=yes ],
AC_MSG_RESULT(no))
if test "$SNMP_SSL" = "yes"; then
LDFLAGS="-L/usr/local/ssl/lib $LDFLAGS"
AC_CHECK_LIB(crypto, CRYPTO_free,[],[AC_MSG_ERROR(libcrypto not found!)])
AC_CHECK_LIB(des, CRYPTO_free,[],[])
fi
AC_CHECK_LIB(netsnmp, snmp_timeout,
[ LIBS="-lnetsnmp $LIBS"
AC_DEFINE(HAVE_NET_SNMP, 1, Net-SNMP Found)
OLD_UCD_SNMP=no ],
[ AC_MSG_RESULT(Cannot find Net-SNMP libraries(netsnmp)... checking UCD-SNMP)
OLD_UCD_SNMP=yes ])
if test "$OLD_UCD_SNMP" = "yes"; then
AC_CHECK_LIB(snmp, snmp_timeout,
[ LIBS="-lsnmp $LIBS"
AC_DEFINE(OLD_UCD_SNMP, 1, Old UCD SNMP Version) ],
AC_MSG_ERROR(Cannot find UCD/Net-SNMP libraries))
fi
dnl ****************** End SNMP checking ***********************
AC_SUBST(ltlibraries)
AC_OUTPUT(Makefile \
cgilib-0.4/Makefile \
etc/Makefile \
src/Makefile \
contrib/Makefile \
etc/createdb \
etc/rtgtargmkr.pl \
etc/common.php \
man/rtgplot.1 \
man/rtgpoll.1)