-
Notifications
You must be signed in to change notification settings - Fork 19
/
configure.ac
422 lines (365 loc) · 11.7 KB
/
configure.ac
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
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
dnl Process this -*-m4-*- file with autoconf to produce a configure script.
dnl
dnl Copyright 2009-2014 Nagios Core Development Team and Community Contributors
dnl Copyright 2005-2009 Ethan Galstad
dnl
dnl This file is part of NDOUtils.
dnl
dnl NDOUtils is free software: you can redistribute it and/or modify
dnl it under the terms of the GNU General Public License version 2 as
dnl published by the Free Software Foundation.
dnl
dnl NDOUtils is distributed in the hope that it will be useful,
dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dnl GNU General Public License for more details.
dnl
dnl You should have received a copy of the GNU General Public License
dnl along with NDOUtils. If not, see <http://www.gnu.org/licenses/>.
dnl Disable caching
define([AC_CACHE_LOAD],)
define([AC_CACHE_SAVE],)
AC_INIT(src/ndo2db.c)
AC_CONFIG_HEADER(include/config.h)
AC_PREFIX_DEFAULT(/usr/local/nagios)
AC_DEFINE([DEFAULT_NAGIOS_USER], [nagios], [Default Nagios User])
AC_DEFINE([DEFAULT_NAGIOS_GROUP], [nagios], [Default Nagios Group])
PKG_NAME=ndoutils
INIT_PROG=ndo2db
PKG_VERSION="2.1.4"
PKG_HOME_URL="http://www.nagios.org/"
PKG_REL_DATE="2024-08-01"
dnl Figure out how to invoke "install" and what install options to use.
AC_PROG_INSTALL
AC_SUBST(INSTALL)
dnl Figure out how to invoke "perl"
AC_PATH_PROG(PERL,perl)
dnl What OS are we running?
AC_CANONICAL_HOST
dnl Checks for programs.
AC_PROG_CC
AC_PROG_MAKE_SET
dnl Nagios O/S, Distribution, Startup, Paths, Files macros
AC_NAGIOS_GET_OS
AC_NAGIOS_GET_DISTRIB_TYPE
AC_NAGIOS_GET_INIT
AC_NAGIOS_GET_INETD
AC_NAGIOS_GET_PATHS
AC_NAGIOS_GET_FILES
case $host_os in
*bsd*|darwin*)
root_grp=wheel
;;
*)
root_grp=root
;;
esac
dnl Checks for header files.
AC_HEADER_STDC
AC_HEADER_TIME
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(arpa/inet.h ctype.h dirent.h dlfcn.h errno.h fcntl.h float.h getopt.h grp.h inttypes.h limits.h ltdl.h math.h netdb.h netinet/in.h pthread.h pwd.h regex.h signal.h socket.h stdarg.h stdint.h string.h strings.h sys/ipc.h sys/mman.h sys/msg.h sys/poll.h sys/resource.h sys/sendfile.h sys/socket.h sys/stat.h sys/time.h sys/timeb.h sys/types.h sys/un.h sys/wait.h syslog.h tcpd.h unistd.h values.h)
dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_STRUCT_TM
AC_TYPE_MODE_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SIGNAL
AC_TYPE_GETGROUPS
dnl Check lengths for later tests of u_int32_t and int32_t
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(long)
dnl Define u_int32_t if we don't have it already (Solaris, etc.)
AC_CHECK_TYPE(uint32_t,unsigned int)
AC_CHECK_TYPE(u_int32_t,unsigned int)
if test "$ac_cv_type_u_int32_t" = no ; then
if test "$ac_cv_type_u_int32_t" = yes ; then
AC_DEFINE(U_INT32_T_IS_UINT32_T)
else
if test "$ac_cv_sizeof_int" = 4 ; then
AC_DEFINE(U_INT32_T_IS_UINT)
else
if test "$ac_cv_sizeof_long" = 4 ; then
AC_DEFINE(U_INT32_T_IS_ULONG)
else
if test "$ac_cv_sizeof_short" = 4 ; then
AC_DEFINE(U_INT32_T_IS_USHORT)
fi
fi
fi
fi
fi
dnl Define int32_t if we don't have it already
AC_CHECK_TYPE(int32_t,int)
if test "$ac_cv_type_int32_t" = no ; then
if test "$ac_cv_sizeof_int" = 4 ; then
AC_DEFINE(INT32_T_IS_UINT)
else
if test "$ac_cv_sizeof_long" = 4 ; then
AC_DEFINE(INT32_T_IS_ULONG)
else
if test "$ac_cv_sizeof_short" = 4 ; then
AC_DEFINE(INT32_T_IS_USHORT)
fi
fi
fi
fi
dnl Check for getopt_long (Solaris)
# AC_CHECK_FUNCS([getopt_long],,AC_CHECK_LIB([iberty],[getopt_long],OTHERLIBS="$OTHERLIBS -liberty"))
# AC_SUBST(OTHERLIBS)
dnl Checks for library functions.
AC_CHECK_LIB(nsl,main,SOCKETLIBS="$SOCKETLIBS -lnsl")
AC_CHECK_LIB(socket,socket,SOCKETLIBS="$SOCKETLIBS -lsocket")
AC_SUBST(SOCKETLIBS)
AC_CHECK_LIB(wrap,main,[
LIBWRAPLIBS="$LIBWRAPLIBS -lwrap"
AC_DEFINE(HAVE_LIBWRAP)
])
AC_SUBST(LIBWRAPLIBS)
AC_CHECK_FUNCS(getopt_long strdup strstr strtoul initgroups strtof nanosleep)
dnl Check for asprintf() and friends...
AC_CACHE_CHECK([for va_copy],ac_cv_HAVE_VA_COPY,[
AC_TRY_LINK([#include <stdarg.h>
va_list ap1,ap2;], [va_copy(ap1,ap2);],
ac_cv_HAVE_VA_COPY=yes,
ac_cv_HAVE_VA_COPY=no)])
if test x"$ac_cv_HAVE_VA_COPY" = x"yes"; then
AC_DEFINE(HAVE_VA_COPY,1,[Whether va_copy() is available])
else
AC_CACHE_CHECK([for __va_copy],ac_cv_HAVE___VA_COPY,[
AC_TRY_LINK([#include <stdarg.h>
va_list ap1,ap2;], [__va_copy(ap1,ap2);],
ac_cv_HAVE___VA_COPY=yes,
ac_cv_HAVE___VA_COPY=no)])
if test x"$ac_cv_HAVE___VA_COPY" = x"yes"; then
AC_DEFINE(HAVE___VA_COPY,1,[Whether __va_copy() is available])
fi
fi
AC_SUBST(SNPRINTF_O)
AC_CHECK_FUNC(snprintf,,SNPRINTF_O=./snprintf.o)
AC_CHECK_FUNC(asprintf,,SNPRINTF_O=./snprintf.o)
AC_MSG_CHECKING(for type of socket size)
AC_TRY_COMPILE([#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
],
[int a = send(1, (const void *)0, (size_t *) 0, (int *) 0);],
[AC_DEFINE(SOCKET_SIZE_TYPE, size_t) AC_MSG_RESULT(size_t)],
[AC_DEFINE(SOCKET_SIZE_TYPE, int) AC_MSG_RESULT(int)])
dnl Stolen from Python code: loewis@users.sourceforge.net
dnl AC_CHECK_TYPE(socklen_t,int,
dnl AC_DEFINE(socklen_t,int,
dnl Define to `int' if <sys/socket.h> does not define.),[
dnl #ifdef HAVE_SYS_TYPES_H
dnl #include <sys/types.h>
dnl #endif
dnl #ifdef HAVE_SYS_SOCKET_H
dnl #include <sys/socket.h>
dnl #endif
dnl ])
dnl Check if SUN_LEN exists
AC_TRY_LINK([
#include<sys/types.h>
#include<sys/un.h>],
[struct sockaddr_un su; int i = SUN_LEN(&su);],
[AC_DEFINE(HAVE_SUN_LEN)], )
dnl Check for location of init scripts
init_dir=/etc/rc.d/init.d
if test -d /etc/rc.d/init.d; then
init_dir="/etc/rc.d/init.d"
elif test -d /usr/local/etc/rc.d; then
init_dir="/usr/local/etc/rc.d"
elif test -d /etc/rc.d; then
init_dir="/etc/rc.d"
elif test -d /etc/init.d; then
init_dir="/etc/init.d"
elif test -d /sbin/init.d; then
init_dir="/sbin/init.d"
fi
AC_ARG_WITH([ndo2db_port],
AS_HELP_STRING([--with-ndo2db-port=<port>],
[sets port number for NDO2DB to listen on]),
[ndo2db_port=$withval],
[ndo2db_port=5668])
AC_DEFINE_UNQUOTED(DEFAULT_SERVER_PORT,$ndo2db_port,[Default port for NDO2DB daemon])
AC_SUBST(ndo2db_port)
dnl - Modified version from www.erlang.org
dnl - Some 12/15/05 mods made after reading http://xaxxon.slackworks.com/phuku/dl.html
AC_MSG_CHECKING(for linker flags for loadable modules)
case $host_os in
solaris2*|sysv4*)
MOD_LDFLAGS="-G"
MOD_CFLAGS="-fPIC"
;;
aix4*|aix5*)
#MOD_LDFLAGS="-G -bnoentry -bexpall"
MOD_LDFLAGS="-G -bM:SRE -bnoentry -bexpall"
;;
freebsd2*)
# Non-ELF GNU linker
MOD_LDFLAGS="-Bshareable"
;;
darwin*)
# Mach-O linker, a shared lib and a loadable
# object file is not the same thing.
MOD_LDFLAGS="-bundle -flat_namespace -undefined suppress"
MOD_CFLAGS="$MOD_CFLAGS -fno-common"
;;
linux* | k*bsd*-gnu*)
# assume GNU linker and ELF
MOD_LDFLAGS="-shared"
MOD_CFLAGS="-fPIC"
;;
*)
# assume GNU linker and ELF
MOD_LDFLAGS="-shared"
;;
esac
if test "$dist_type" = aix; then
MOD_LDFLAGS="$MOD_LDFLAGS -Wl,-berok"
fi
AC_MSG_RESULT([$MOD_LDFLAGS])
AC_SUBST(MOD_CFLAGS)
AC_SUBST(MOD_LDFLAGS)
dnl DB support options
USE_MYSQL=yes
AC_ARG_ENABLE(mysql,AC_HELP_STRING([--enable-mysql],[enables MySQL database support]))
AS_IF([test x$enable_mysql = xno], [USE_MYSQL=no])
dnl Are we using any MySQL routines?
if test $USE_MYSQL = yes; then
np_mysqlclient
if test $with_mysql = "no" ; then
echo ""
echo ""
echo "*** MySQL library could not be located... **************************"
echo ""
echo "You chose to compile NDOutils with MySQL support, but I was unable to"
echo "locate the MySQL library on your system. If the library is"
echo "installed, use the --with-mysql=DIR argument to specify the"
echo "location of the MySQL library, We assume mysql_config is in DIR/bin"
echo "NOTE: After you install the necessary libraries on your system:"
echo " 1. Make sure /etc/ld.so.conf has an entry for the directory in"
echo " which the MySQL libraries are installed."
echo " 2. Run 'ldconfig' to update the run-time linker options."
echo " 3. Run 'make devclean' in the NDBXT distribution to clean out"
echo " any old references to your previous compile."
echo " 4. Rerun the configure script."
echo ""
echo "TIP: Try the following...."
echo " ./configure --with-mysql=/usr/lib/mysql"
echo ""
echo "********************************************************************"
echo ""
echo ""
USE_MYSQL=no
else
echo "MySQL library and include file(s) were found!"
AC_DEFINE_UNQUOTED(USE_MYSQL)
DBLIBS="$DBLIBS $np_mysql_libs"
CFLAGS="$CFLAGS $np_mysql_include"
fi
fi
save_LDFLAGS="$LDFLAGS"
LDFLAGS="${LDFLAGS} ${DBLDFLAGS}"
save_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="${DBCFLAGS}"
save_CFLAGS="$CFLAGS"
CFLAGS="${DBCFLAGS}"
AC_SUBST(DBCFLAGS)
AC_SUBST(DBLDFLAGS)
AC_SUBST(DBLIBS)
LDFLAGS="$save_LDFLAGS"
CPPFLAGS="$save_CPPFLAGS"
CFLAGS="$save_CFLAGS"
dnl Moving this before the Mysql detection options breaks them....
AC_ARG_WITH(ndo2db_user,AC_HELP_STRING([--with-ndo2db-user=<user>],[sets user name to run NDO2DB]),ndo2db_user=$withval,ndo2db_user=nagios)
AC_ARG_WITH(ndo2db_group,AC_HELP_STRING([--with-ndo2db-group=<group>],[sets group name to run NDO2DB]),ndo2db_group=$withval,ndo2db_group=nagios)
AC_SUBST(ndo2db_user)
AC_SUBST(ndo2db_group)
dnl Does the user want to check for systemd?
AC_ARG_ENABLE([systemd-sockets],
AC_HELP_STRING([--enable-systemd-sockets],[enables systemd socket activation]),
[],[enable_systemd_sockets=auto])
dnl Try to compile and link a program that checks for systemd sockets.
if test x$enable_systemd_sockets != xno; then
have_systemd=no
AC_SEARCH_LIBS([sd_listen_fds],[systemd systemd-daemon],
AC_TRY_LINK([#include <systemd/sd-daemon.h>],[sd_listen_fds(0);],[have_systemd=yes]))
if test x$have_systemd = xyes; then
AC_DEFINE([HAVE_SYSTEMD])
elif test x$enable_systemd_sockets = xyes; then
AC_MSG_ERROR([systemd was requested, but could not be found])
fi
fi
dnl Does user want to check for SSL?
AC_ARG_ENABLE(ssl,AC_HELP_STRING([--enable-ssl],[enables native SSL support]),[
if test x$enableval = xyes; then
check_for_ssl=yes
else
check_for_ssl=no
fi
],check_for_ssl=no)
dnl Optional SSL library and include paths
if test x$check_for_ssl = xyes; then
# need_dh should only be set for NRPE and NDOUTILS
need_dh=yes
AC_NAGIOS_GET_SSL
fi
if test x$HAVE_NANOSLEEP = x; then
USE_NANOSLEEP=no
else
USE_NANOSLEEP=yes
AC_ARG_ENABLE(nanosleep,AC_HELP_STRING([--enable-nanosleep],[enables use of nanosleep (instead of sleep) in event timing]))
AS_IF([test x$enable_nanosleep = xno],[USE_NANOSLEEP=no],[USE_NANOSLEEP=yes])
if test x$USE_NANOSLEEP = xyes ; then
AC_DEFINE_UNQUOTED(USE_NANOSLEEP)
fi
fi
AC_CONFIG_FILES([Makefile
src/Makefile
config/ndo2db.cfg-sample
config/ndomod.cfg-sample
config/nagios.cfg
config/misccommands.cfg
docs/docbook/en-en/Makefile
include/io.h
include/common.h
startup/bsd-init
startup/debian-init
startup/default-init
startup/default-inetd
startup/default-service
startup/default-socket
startup/default-socket-svc
startup/default-xinetd
startup/mac-init.plist
startup/mac-inetd.plist
startup/newbsd-init
startup/openbsd-init
startup/openrc-conf
startup/openrc-init
startup/solaris-init.xml
startup/solaris-inetd.xml
startup/tmpfile.conf
startup/upstart-init
startup/rh-upstart-init
])
AC_OUTPUT()
dnl Review options
echo ""
echo ""
AC_MSG_RESULT([*** Configuration summary for $PKG_NAME $PKG_VERSION $PKG_REL_DATE ***:])
echo ""
echo " General Options:"
echo " -------------------------"
AC_MSG_RESULT([ NDO2DB user: $ndo2db_user])
AC_MSG_RESULT([ NDO2DB group: $ndo2db_group])
AC_MSG_RESULT([ NDO2DB tcp port: $ndo2db_port])
echo "";\
echo "";\
echo "Review the options above for accuracy. If they look";\
echo "okay, type 'make all' to compile the NDO utilities,";\
echo "or type 'make' to get a list of make options.";\
echo ""