File: configure.ac

package info (click to toggle)
netmrg 0.20-2.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 2,820 kB
  • ctags: 2,009
  • sloc: php: 9,401; sh: 4,597; cpp: 2,898; perl: 621; ansic: 381; makefile: 331; xml: 92; sql: 71; sed: 16
file content (390 lines) | stat: -rw-r--r-- 10,126 bytes parent folder | download | duplicates (4)
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
# Process this file with autoconf to produce a configure script.

#############################################################
#
#  Autoconf requirements
#  AC_INIT(package, version, bug-report-address)
#  information on the package
#  checks for programs
#  checks for libraries
#  checks for header files
#  checks for types
#  checks for structures
#  checks for compiler characteristics
#  checks for library functions
#  checks for system services
#  AC_CONFIG_FILES([file...])
#  AC_OUTPUT
#
#############################################################

AC_PREREQ(2.53)
AC_INIT(NetMRG,0.20)
AC_REVISION($Revision:1281 $)
AC_CONFIG_SRCDIR(src/netmrg.cpp)
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE
AM_CONFIG_HEADER(src/include/config.h)
AC_PROG_MAKE_SET

# We wanna use C++, not that silly C language ;)
AC_LANG(C++)

#
# Autoconf is dumb and doesn't expand ${prefix} for this variable
# If it does this in the future, this can probably be removed
#
if test "x$exec_prefix" = "xNONE"; then
	if test "x$prefix" = "xNONE" ; then
		exec_prefix="/usr/local"
	else
		exec_prefix="$prefix"
	fi
	ac_configure_args="$ac_configure_args --exec-prefix=$exec_prefix"
fi

#
# --with configs
#

# rrdtool
AC_ARG_WITH(rrdtool,
        AC_HELP_STRING(
                [--with-rrdtool=PROGRAM],
                [location of the rrdtool program]),
        [rrdtool_prog=$withval])
AC_PATH_PROG(RRDTOOL, rrdtool, $rrdtool_prog)

if test "x$RRDTOOL" = "x"; then
	AC_MSG_ERROR([Couldn't find rrdtool. Please verify that it is installed.])
fi

# mysql
AC_ARG_WITH(mysql_config,
        AC_HELP_STRING(
                [--with-mysql_config=PROGRAM],
                [location of the mysql_config program]),
        [mysql_config_prog=$withval])
AC_PATH_PROG(MYSQL_CONFIG, mysql_config, $mysql_config_prog)

if test "x$MYSQL_CONFIG" = "x"; then
	AC_MSG_ERROR([Couldn't find mysql_config. Please verify that it is installed.])
fi

# snmp
AC_ARG_WITH(snmp-include-dir,
	AC_HELP_STRING(
		[--with-snmp-include-dir],
		[SNMP include base directory [[/usr/(local/)include]]]),
	[snmp_include_dir=$withval])
AC_ARG_WITH(snmp-lib-dir,
	AC_HELP_STRING(
		[--with-snmp-lib-dir],
		[SNMP library directory [[/usr/(local/)lib[64]]]]),
	[snmp_lib_dir=$withval])

# xml2
AC_ARG_WITH(xml2-include-dir,
	AC_HELP_STRING(
		[--with-xml2-include-dir],
		[XML2 include directory]),
	[xml2_include_dir=$withval])
AC_ARG_WITH(xml2-lib-dir,
	AC_HELP_STRING(
		[--with-xml2-lib-dir],
		[XML2 library directory]),
	[xml2_lib_dir=$withval])

# www dir
www_dir="${localstatedir}/www/${PACKAGE}"
AC_ARG_WITH(www-dir,
	AC_HELP_STRING(
		[--with-www-dir],
		[install directory for web files]),
	[www_dir=$withval])
AC_SUBST(WWWDIR, $www_dir)


#
# Special hacks for certain operating systems
#

# 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

# Platform-specific tweaks
case $host_alias in
*solaris*)
    AC_DEFINE(HAVE_LONG_LONG_SCANF, 1, scanf supports long long)
    LDFLAGS="$LDFLAGS -L/usr/local/ssl/lib"
    LIBS="-lkstat $LIBS";;
*linux*)
    AC_DEFINE(HAVE_LONG_LONG_SCANF, 1, scanf supports long long);;
*freebsd*)
    CPPFLAGS="$CPPFLAGS -I/usr/local/include";;
*openbsd*)
    LIBS="-ldes $LIBS";;
esac


### Checks for programs.
AC_PROG_CXX
AC_PROG_CPP
AC_PROG_INSTALL

AC_MSG_CHECKING([whether to enable -Wall])
AC_ARG_ENABLE(warnings,
	AC_HELP_STRING(
		[--enable-warnings],
		[Enable -Wall if using g++]),
	[ if test -n "$GXX"; then
		AC_MSG_RESULT(adding -Wall to CPPFLAGS.)
		CPPFLAGS="$CPPFLAGS -Wall"
	  fi],
	AC_MSG_RESULT(no))


### Checks for libraries.
AC_CHECK_LIB(intl, bindtextdomain)
AC_CHECK_LIB(dl, dlopen)
AC_CHECK_LIB(z, compress)
AC_CHECK_LIB(pthread, pthread_create,
	[ CPPFLAGS="$CPPFLAGS -D_REENTRANT -D_POSIX_PTHREAD_SEMANTICS"
	  LIBS="-lpthread $LIBS" ],
	AC_CHECK_LIB(c_r, pthread_create,
		[ CPPFLAGS="$CPPFLAGS -D_THREAD_SAFE"
		  LIBS="-pthread $LIBS"],
		AC_MSG_ERROR([POSIX threads not found.])
	)
)
AC_CHECK_LIB(stdc++, main)

## Determine XML2 library path
# try and find libs without any additional libraries
AC_CHECK_LIB(xml2, xmlParseFile,
	XML2_LIBS=" ",
	XML2_LIBS=
)

# hunt through several directories trying to find the libraries
if test "x$XML2_LIBS" = "x"; then
	old_LDFLAGS="$LDFLAGS"
	for try in $xml2_lib_dir /usr/lib64 /usr/lib /usr/local/lib ; do
		LDFLAGS="$old_LDFLAGS -L$try"
		unset ac_cv_lib_xml2_xmlParseFile
		AC_CHECK_LIB(xml2, xmlParseFile,
			XML2_LIBS="-L$try",
			XML2_LIBS=
		)
		if test "x$XML2_LIBS" != "x"; then
			break;
		fi
	done
	LDFLAGS="$old_LDFLAGS $XML2_LIBS"
fi

if test "x$XML2_LIBS" = "x"; then
	AC_MSG_ERROR([XML2 libraries not found.  Use --with-xml2-lib-dir=<path>])
fi
# don't forget to add xml2 to the list of libraries
LIBS="-lxml2 $LIBS"

## Determine MySQL library path
MYSQL_LIBS=$($MYSQL_CONFIG --libs)
LIBS="$LIBS $MYSQL_LIBS"

# now that we've found the libraries, check for MySQL < 4.0
MYSQL_VERSION=$($MYSQL_CONFIG --version)
if test "x${MYSQL_VERSION//.*/}" = "x3"; then
	AC_DEFINE(OLD_MYSQL, 1, [Old MySQL version])
fi


### Checks for header files.
AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_HEADER_TIME
AC_CHECK_HEADERS( \
	cstdio \
	cstdlib \
	string \
	list \
	unistd.h \
	netinet/in.h
)

## Determine XML2 include path
AC_MSG_CHECKING(for libxml/xmlmemory.h)

# Can we include headers using system include dirs?
AC_TRY_COMPILE([#include <libxml/xmlmemory.h>], [int a = 1;],
	XML2_INCLUDE=" ",
	XML2_INCLUDE=
)

# hunt through several directories trying to find the includes
if test "x$XML2_INCLUDE" = "x"; then
	old_CPPFLAGS="$CPPFLAGS"
	for i in $xml2_include_dir /usr/include /usr/local/include /usr/include/libxml2 /usr/local/include/libxml2 ; do
		CPPFLAGS="$old_CPPFLAGS -I$i"
		AC_TRY_COMPILE([#include <libxml/xmlmemory.h>], [int a = 1;],
			XML2_INCLUDE="-I$i",
			XML2_INCLUDE=
		)
		if test "x$XML2_INCLUDE" != "x"; then
			break;
		fi
	done
	CPPFLAGS="$old_CPPFLAGS $XML2_INCLUDE"
fi

if test "x$XML2_INCLUDE" = "x"; then
	AC_MSG_RESULT(no) 
	AC_MSG_ERROR([XML2 headers not found.  Use --with-xml2-include-dir=<path>])
fi
AC_MSG_RESULT(yes) 

## Determine MySQL include path
MYSQL_INCLUDE=$($MYSQL_CONFIG --cflags)
CPPFLAGS="$CPPFLAGS $MYSQL_INCLUDE"


### Checks for typedefs, structures, and compiler characteristics.
#AC_CHECK_TYPES([long long])
AC_C_CONST
AC_TYPE_SIZE_T


### Checks for library functions.
AC_TYPE_SIGNAL
AC_FUNC_MEMCMP
AC_FUNC_STAT
AC_CHECK_FUNCS( \
	memmove \
	llround \
	setenv
)
AC_SEARCH_LIBS(nanosleep, rt posix4,, AC_ERROR([nanosleep function not found.]))

# Determine UCD or Net-SNMP include path
if test "x$snmp_include_dir" != "x"; then
  for i in / /ucd-snmp /include/ucd-snmp; do
    test -f $snmp_include_dir/$i/snmp.h && SNMP_INCDIR=$snmp_include_dir/$i
  done
  for i in / /net-snmp /include/net-snmp; do
    test -f $snmp_include_dir/$i/net-snmp-config.h && SNMP_INCDIR=$snmp_include_dir/$i
  done
else
  for i in /usr/local/include /usr/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
fi

# Determine UCD or Net-SNMP library path
if test "x$snmp_lib_dir" != "x"; then
  test -f $snmp_lib_dir/libsnmp.a -o -f $snmp_lib_dir/libsnmp.so -o -f $snmp_lib_dir/libsnmp.dylib && SNMP_LIBDIR=$snmp_lib_dir
  test -f $snmp_lib_dir/libnetsnmp.a -o -f $snmp_lib_dir/libnetsnmp.so -o -f $snmp_lib_dir/libnetsnmp.dylib && SNMP_LIBDIR=$snmp_lib_dir
else
  for i in /usr/local/lib /usr/sfw/lib /usr/lib /usr/lib64 ; do
    test -f $i/libsnmp.a -o -f $i/libsnmp.so -o -f $i/libsnmp.dylib && SNMP_LIBDIR=$i
    test -f $i/libnetsnmp.a -o -f $i/libnetsnmp.so -o -f $i/libnetsnmp.dylib && SNMP_LIBDIR=$i
  done
fi

if test -z "$SNMP_INCDIR"; then
  if test "x$snmp_include_dir" != "x";then
    AC_MSG_ERROR(Cannot find SNMP headers under $snmp_include_dir)
  else
    AC_MSG_ERROR(Cannot find SNMP headers.  Use --with-snmp-include-dir= to specify non-default path.)
  fi
fi

if test -z "$SNMP_LIBDIR"; then
  if test "x$snmp_lib_dir" != "x";then
    AC_MSG_ERROR(Cannot find SNMP libraries under $snmp_lib_dir)
  else
    AC_MSG_ERROR(Cannot find SNMP libraries.  Use --with-snmp-lib-dir= to specify non-default path.)
  fi
fi

LDFLAGS="$LDFLAGS -L$SNMP_LIBDIR"
CPPFLAGS="$CPPFLAGS -I$SNMP_INCDIR"

# Net/UCD-SNMP includes v3 support and insists on crypto unless 
# compiled --without-openssl
SNMP_SSL=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))
AC_MSG_CHECKING([if UCD-SNMP needs crypto support])
AC_TRY_COMPILE([#include <ucd-snmp-config.h>],
	[exit(USE_OPENSSL != 1);],
	[AC_MSG_RESULT(yes)
	 SNMP_SSL=yes ],
	AC_MSG_RESULT(no))

if test "$SNMP_SSL" = "yes"; then
  AC_CHECK_LIB(crypto, CRYPTO_free,,AC_MSG_ERROR(libcrypto not found!))
fi

HAVE_NET_SNMP=no
AC_CHECK_LIB(netsnmp, snmp_timeout,
	[LIBS="-lnetsnmp $LIBS"
	 AC_DEFINE(HAVE_NET_SNMP, 1, Net-SNMP Version) 
	 HAVE_NET_SNMP=yes ],
	AC_MSG_RESULT(Cannot find Net-SNMP libraries...checking for UCD-SNMP))

if test "$HAVE_NET_SNMP" = "no"; then
  AC_CHECK_LIB(snmp, snmp_timeout,,
	AC_MSG_ERROR(Cannot find UCD-SNMP libraries))
fi

# Internationalization support
AM_GNU_GETTEXT([external])

#
#  Run configure in directories
#
#AC_CONFIG_SUBDIRS(src)

AC_CONFIG_FILES( \
	Makefile \
	subst \
	bin/rrdedit \
	etc/Makefile \
	etc/cron.d-netmrg \
	etc/init.d-netmrg \
	etc/netmrg.conf \
	etc/netmrg.xml \
	m4/Makefile \
	po/Makefile.in \
	src/Makefile \
	src/include/netmrg.h \
	var/Makefile \
	var/lib/Makefile \
	var/lib/rrd/Makefile \
	www/Makefile \
	www/include/config.php

)

AC_OUTPUT

perl subst etc/cron.d-netmrg
perl subst etc/init.d-netmrg
perl subst etc/netmrg.conf
perl subst etc/netmrg.xml
perl subst src/include/netmrg.h
perl subst src/include/config.h
perl subst www/Makefile