]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/blame - configure.ac
Fix BUILD_DATE in rrdtool help output
[thirdparty/rrdtool-1.x.git] / configure.ac
CommitLineData
0cbdf24b 1dnl RRDtool AutoConf script ...
37fc6638 2dnl ---------------------------
43f53d99 3dnl $Id$
37fc6638
TO
4dnl
5dnl Created by Jeff Allen, Tobi Oetiker, Blair Zajac
6dnl
8b65ac0e 7dnl Inspiration from http://autoconf-archive.cryp.to
0cbdf24b 8
cdab6835 9dnl tell automake the this script is for rrdtool
777e0070 10
b0400c71
TO
11dnl Minimum Autoconf version required.
12AC_PREREQ(2.59)
13
7f1747cb
TO
14dnl the official version number is
15dnl a.b.c
0033ee5d 16AC_INIT([rrdtool],m4_esyscmd([tr -d '\n' < VERSION]))
6f1c8623 17AC_CONFIG_AUX_DIR(conftools)
777e0070 18
777e0070 19
5606e705
TO
20dnl for the linker to understand which versions the library are compatible with
21dnl each other we must keep a separate library version cout of the format c:r:a.
22dnl - if only implementation changed but all interfaces are kept, do r++
23dnl - if only functionality was added do c++,r=0,a++
24dnl - if any functionality was removed do c++,r=0,a=0.
777e0070
TO
25dnl
26dnl see http://sourceware.org/autobook/autobook/autobook_91.html
0cbdf24b 27dnl
003a907f 28LIBVERS=11:0:3
777e0070
TO
29AC_SUBST(LIBVERS)
30
45319c55 31AC_CANONICAL_TARGET
b0400c71 32m4_version_prereq(2.60, [AC_USE_SYSTEM_EXTENSIONS], [#])
a23d18c1 33AM_INIT_AUTOMAKE
58cc8383 34AM_MAINTAINER_MODE
a23d18c1
TO
35# Enable silent build rules by default, requires at least
36# Automake-1.11. Disable by either passing --disable-silent-rules to
37# configure or passing V=1 to make
38m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
b68117e0 39AC_CONFIG_HEADERS([src/rrd_config.h])
c862de08 40AC_CONFIG_MACRO_DIR([m4])
37fc6638
TO
41
42dnl all our local stuff like install scripts and include files
43dnl is in there
cdab6835 44
37fc6638
TO
45
46dnl determine the type of system we are running on
37fc6638 47
37fc6638
TO
48AC_SUBST(VERSION)
49
f9178759 50AC_PREFIX_DEFAULT( /opt/rrdtool-$PACKAGE_VERSION )
dea555a3 51
cdab6835
TO
52dnl At the TOP of the HEADER
53
54AH_TOP([
7fd68343
TO
55#ifndef RRD_CONFIG_H
56#define RRD_CONFIG_H
738d50c4 57
cdab6835
TO
58/* IEEE can be prevented from raising signals with fpsetmask(0) */
59#undef MUST_DISABLE_FPMASK
60
61/* IEEE math only works if SIGFPE gets actively set to IGNORE */
cdab6835
TO
62#undef MUST_DISABLE_SIGFPE
63
64/* realloc does not support NULL as argument */
65#undef NO_NULL_REALLOC
965d0f77 66
0cbdf24b 67/* lets enable madvise defines in NetBSD */
e1005301
TO
68#if defined(__NetBSD__)
69# if !defined(_NETBSD_SOURCE)
70# define _NETBSD_SOURCE
71# endif
72#endif
73
738d50c4 74])
cdab6835
TO
75
76AH_BOTTOM([
77
738d50c4 78#ifdef MUST_HAVE_MALLOC_MALLOC_H
3a44ef8a
TO
79# include <malloc/malloc.h>
80#endif
81
c238ca48 82#include "rrd_config_bottom.h"
f6d0c1c8 83
f6d0c1c8 84#endif
cdab6835
TO
85])
86
b672fc87
TO
87dnl Process Special Options
88dnl -----------------------------------
37fc6638 89
b672fc87 90dnl How the vertical axis label is printed
0cbdf24b 91AC_ARG_VAR(RRDGRAPH_YLEGEND_ANGLE,
9c4e67d9 92 [Vertical label angle: -90.0 (default) or 90.0])
b672fc87 93AC_DEFINE_UNQUOTED(RRDGRAPH_YLEGEND_ANGLE,${RRDGRAPH_YLEGEND_ANGLE:-90.0},
9c4e67d9 94 [Vertical label angle: -90.0 (default) or 90.0])
a89dc4f8 95
deaef079
GZ
96AC_ARG_ENABLE(docs,AS_HELP_STRING([--disable-docs],[disable building documentation]),
97[],[enable_docs=yes])
98
e24e014c
FB
99AC_ARG_ENABLE(examples,AS_HELP_STRING([--disable-examples],[disable building of examples]),
100[],[enable_examples=yes])
101
38fb0ad1
FB
102AC_ARG_ENABLE(rrdcached,AS_HELP_STRING([--disable-rrdcached],[disable building of rrdcached]),
103[],[enable_rrdcached=yes])
104
a76b432b 105AC_ARG_ENABLE(rrdcgi,AS_HELP_STRING([--disable-rrdcgi],[disable building of rrdcgi]),
b672fc87 106[],[enable_rrdcgi=yes])
a89dc4f8 107
52018ea3 108AC_ARG_ENABLE(rrd_graph,AS_HELP_STRING([--disable-rrd_graph],[disable all rrd_graph functions]),
0586762b 109[enable_rrdcgi=$enableval],[enable_rrd_graph=yes])
52018ea3 110
91ce7bd4
FB
111AC_ARG_ENABLE(rrd_restore,AS_HELP_STRING([--disable-rrd_restore],[disable rrd_restore XML import functions]),
112[],[enable_rrd_restore=yes])
113
deaef079 114AM_CONDITIONAL(BUILD_DOCS,[test $enable_docs != no])
e24e014c 115AM_CONDITIONAL(BUILD_EXAMPLES,[test $enable_examples != no])
e6c92e00 116AM_CONDITIONAL(BUILD_RRDCGI,[test $enable_rrdcgi != no])
38fb0ad1 117AM_CONDITIONAL(BUILD_RRDCACHED,[test $enable_rrdcached != no])
e6c92e00
TO
118
119
52018ea3
TO
120if test $enable_rrd_graph != no; then
121 AC_DEFINE([HAVE_RRD_GRAPH], [], [is rrd_graph supported by this install])
122fi
123
91ce7bd4
FB
124if test $enable_rrd_restore != no; then
125 AC_DEFINE([HAVE_RRD_RESTORE], [], [is rrd_restore supported by this install])
126fi
127
f3d2fe14
TO
128dnl Check if we run on a system that has fonts
129AC_ARG_WITH(rrd-default-font,
130[ --with-rrd-default-font=[OPTIONS] set the full path to your default font.],
131[RRD_DEFAULT_FONT=$withval],[
132 if test -d ${WINDIR:-nodir}/cour.ttf ; then
133 RRD_DEFAULT_FONT=`cd $WINDIR;pwd`/cour.ttf
134 else
00009660 135 RRD_DEFAULT_FONT='"DejaVu Sans Mono,Bitstream Vera Sans Mono,monospace,Courier"'
f3d2fe14
TO
136 fi
137])
138
b672fc87
TO
139dnl Use mmap in rrd_update instead of seek+write
140AC_ARG_ENABLE([mmap],
a76b432b 141AS_HELP_STRING([--disable-mmap],[disable mmap in rrd_update, use seek+write instead]),
b672fc87
TO
142[],
143[enable_mmap=yes])
1e48a62f 144
8c9a864d 145AC_ARG_ENABLE(pthread,AS_HELP_STRING([--disable-pthread],[disable multithread support]),
b672fc87
TO
146[],[enable_pthread=yes])
147
0033ee5d
TO
148AC_ARG_ENABLE([flock],
149AS_HELP_STRING([--disable-flock],[disable file locking]),
150[],
151[enable_flock=yes])
b5e33bfe 152if test x$enable_flock != xyes; then
0033ee5d
TO
153 AC_DEFINE([DISABLE_FLOCK], [], [disable flock calls in rrdtool])
154fi
155
81ff9dac 156AC_ARG_ENABLE(static-programs,
a76b432b 157 AS_HELP_STRING([--enable-static-programs],[Build static programs]),
81ff9dac
TO
158 [case "${enableval}" in
159 yes) staticprogs=yes ;;
160 no) staticprogs=no ;;
161 *) AC_MSG_ERROR(bad value ${enableval} for --enable-static-programs) ;;
162 esac],[staticprogs=no])
163AM_CONDITIONAL(STATIC_PROGRAMS,[test "x$staticprogs" = "xyes"])
b672fc87
TO
164
165
166CONFIGURE_PART(Audit Compilation Environment)
167
168
169dnl Check for the compiler and static/shared library creation.
b672fc87 170AC_PROG_CPP
c2f7bec9
TO
171AC_PROG_CC
172AM_PROG_CC_C_O
b672fc87
TO
173AC_PROG_LIBTOOL
174
1e48a62f
TO
175dnl Try to detect/use GNU features
176CFLAGS="$CFLAGS -D_GNU_SOURCE"
177
c8386f39 178dnl check for -Werror separately
c862de08 179dnl (quite a few autotool checks do not work with -Werror; also, the
b98afd17
TO
180dnl check for -Werror fails after checking and adding the other flags)
181AC_CACHE_CHECK([if gcc likes the -Werror flag], rd_cv_gcc_flag__Werror,
182 [AC_COMPILE_IFELSE(
183 [AC_LANG_PROGRAM([[]], [[return 0 ]])],
184 [rd_cv_gcc_flag__Werror="yes"],
185 [rd_cv_gcc_flag__Werror="no"])])
186if test "x$rd_cv_gcc_flag__Werror" = "xyes"; then
187 WERROR="-Werror"
188else
189 WERROR=""
190fi
191AC_SUBST(WERROR)
192
f6d0c1c8
TO
193dnl which flags does the compiler support?
194if test "x$GCC" = "xyes"; then
f07117d5 195 for flag in -fno-strict-aliasing -Wall -std=gnu99 -pedantic -Wundef -Wshadow -Wpointer-arith -Wcast-align -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wold-style-definition -W; do
f6d0c1c8 196 oCFLAGS="$CFLAGS"
be7203e9
TO
197 CFLAGS="$CFLAGS $flag"
198 cachename=rd_cv_gcc_flag_`echo $flag|sed 's/[[^A-Za-z]]/_/g'`
199 AC_CACHE_CHECK([if gcc likes the $flag flag], $cachename,
200 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[return 0 ]])],[eval $cachename=yes],[eval $cachename=no])])
201 if eval test \$$cachename = no; then
f6d0c1c8 202 CFLAGS="$oCFLAGS"
be7203e9
TO
203 fi
204 done
205fi
206
737d2959 207AC_TYPE_LONG_LONG_INT
b672fc87 208
f3d2fe14
TO
209AC_SUBST(RRD_DEFAULT_FONT)
210
b672fc87 211CONFIGURE_PART(Checking for Header Files)
0cbdf24b 212
a89dc4f8
TO
213dnl Checks for header files.
214AC_HEADER_STDC
215AC_HEADER_DIRENT
cc773897 216AC_CHECK_HEADERS(langinfo.h stdint.h inttypes.h libgen.h features.h sys/stat.h sys/types.h fcntl.h fp_class.h malloc.h unistd.h ieeefp.h math.h sys/times.h sys/param.h sys/resource.h signal.h float.h stdio.h stdlib.h errno.h string.h ctype.h grp.h pwd.h glob.h)
a89dc4f8
TO
217
218dnl Checks for typedefs, structures, and compiler characteristics.
219AC_C_CONST
220AC_HEADER_TIME
221AC_STRUCT_TM
37fc6638 222
0cbdf24b 223dnl figure out 'stuff' about
a9fb671a 224HW_FUNC_VA_COPY
f67fab60
TO
225HW_FUNC_VSNPRINTF
226HW_FUNC_SNPRINTF
227HW_FUNC_VASPRINTF
228HW_FUNC_ASPRINTF
229
58cc8383
TO
230CONFIGURE_PART(Test Library Functions)
231
a89dc4f8 232dnl Checks for libraries.
bca16bd4
TO
233AC_CHECK_FUNC(acos, , AC_CHECK_LIB(m, acos))
234AC_CHECK_FUNC(round, , AC_CHECK_LIB(m, round))
a89dc4f8 235
a1938ec6 236
505bfff7 237
31b49791 238dnl add pic flag in any case this makes sure all our code is relocatable
b3f6be4f
TO
239dnl eval `./libtool --config | grep pic_flag=`
240dnl CFLAGS="$CFLAGS $pic_flag"
31b49791 241
b672fc87 242
31b49791
TO
243dnl Checks for library functions.
244AC_FUNC_STRFTIME
245AC_FUNC_VPRINTF
246
247AC_C_BIGENDIAN
248
0cbdf24b 249dnl for each function found we get a definition in config.h
31b49791
TO
250dnl of the form HAVE_FUNCTION
251
71bc8365 252AC_CHECK_FUNCS(nl_langinfo tzset fsync mbstowcs opendir readdir chdir chroot getgid getuid setgid setuid strndup strerror snprintf vsnprintf vasprintf fpclass class fp_class isnan memmove strchr mktime getrusage gettimeofday getpwnam getgrnam get_current_dir_name)
f4f9f9c4
TO
253
254AC_FUNC_STRERROR_R
58cc8383
TO
255
256CONFIGURE_PART(Map/Fadvis/Madvise checking)
257
258dnl Could use these to know if we need to provide a prototype
259dnl AC_CHECK_DECLS(fdatasync, [], [], [#include <unistd.h>])
260
261dnl check for fdatasync. Solaris has fdatasync in the librt
262
263AC_CHECK_FUNCS(fdatasync, [], AC_CHECK_LIB(rt, fdatasync, [LIBS="${LIBS} -lrt"; AC_DEFINE(HAVE_FDATASYNC)],[]))
264dnl if there is no fdatasync we may get lucky with fsync
265AC_CHECK_FUNCS(fsync)
31b49791 266
86ad0116
TO
267dnl check for socket and nsl solaris again ... we need this for the new rrd_daemon stuff
268
6ca55fcf
WS
269dnl link with ws2_32 (Winsock2 library) in case of MinGW or MinGW-w64 builds
270case "${target}" in
271 *mingw*) LIBS="${LIBS} -lws2_32";;
272esac
86ad0116
TO
273AC_CHECK_FUNCS(socket, [], AC_CHECK_LIB(socket, socket, [LIBS="${LIBS} -lsocket"; AC_DEFINE(HAVE_SOCKET)],[]))
274AC_CHECK_FUNCS(getaddrinfo, [], AC_CHECK_LIB(nsl, getaddrinfo, [LIBS="${LIBS} -lnsl"; AC_DEFINE(HAVE_GETADDRINFO)],[]))
4213cef2 275AC_CHECK_FUNCS(sigwaitinfo, [], AC_CHECK_LIB(rt, sigwaitinfo, [LIBS="${LIBS} -lrt"; AC_DEFINE(HAVE_SIGWAITINFO)],[]))
965d0f77 276
f6d0c1c8
TO
277dnl XXX: dunno about windows.. add AC_CHECK_FUNCS(munmap) there too?
278if test "x$enable_mmap" = "xyes"; then
72b4ce71 279 case "$host" in
f6d0c1c8
TO
280 *cygwin*)
281 # the normal mmap test does not work in cygwin
282 AC_CHECK_FUNCS(mmap)
283 if test "x$ac_cv_func_mmap" = "xyes"; then
284 ac_cv_func_mmap_fixed_mapped=yes
285 fi
286 ;;
287 *)
288 AC_CHECK_HEADERS(sys/mman.h)
289 AC_FUNC_MMAP
61370c60 290 AC_CHECK_FUNCS(mmap munmap)
d085bb80 291 AC_CHECK_DECLS(madvise, [], [], [#ifdef HAVE_SYS_MMAN_H
f6d0c1c8
TO
292 # include <sys/mman.h>
293 #endif])
294 if test "x$ac_cv_have_decl_madvise" = "xyes";
295 then
296 AC_CHECK_FUNCS(madvise)
297 else
298 AC_CHECK_FUNCS(posix_madvise)
299 if test "x$ac_cv_func_posix_madvise" != "xyes"; then
300 AC_MSG_WARN([madvise() nor posix_madvise() found.])
301 fi
302 fi
303 ;;
72b4ce71 304 esac
f6d0c1c8
TO
305 if test "x$ac_cv_func_mmap" != "xyes";
306 then
307 AC_MSG_ERROR([--enable-mmap requested but mmap() was not detected])
1e48a62f 308dnl enable_mmap="no"
f6d0c1c8 309 fi
965d0f77
TO
310fi
311
bf11519c
TO
312dnl can we use posix_fadvise
313AC_CHECK_DECLS(posix_fadvise, [], [], [#define _XOPEN_SOURCE 600
1e48a62f 314#include <fcntl.h>])
bf11519c
TO
315AC_CHECK_FUNCS(posix_fadvise)
316
2597f442
TO
317dnl can we use posix_fallocate
318AC_CHECK_FUNCS(posix_fallocate)
319
58cc8383
TO
320CONFIGURE_PART(Libintl Processing)
321
0d76c044 322AM_GNU_GETTEXT_VERSION(0.17)
4d53064a 323AM_GNU_GETTEXT(external)
29046a7c 324
b672fc87 325CONFIGURE_PART(IEEE Math Checks)
0cbdf24b 326
f6d0c1c8 327
31b49791
TO
328dnl actual code to check if this works
329AC_CHECK_FUNCS(fpclassify, ,
330 [AC_MSG_CHECKING(for fpclassify with <math.h>)
9742cdcb
TO
331 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <math.h>
332volatile int x;volatile float f; ]], [[x = fpclassify(f)]])],[AC_MSG_RESULT(yes)
2c08b353 333 AC_DEFINE(HAVE_FPCLASSIFY)],[AC_MSG_RESULT(no)])])
f6d0c1c8 334
31b49791
TO
335AC_CHECK_FUNCS(isinf, ,
336 [AC_MSG_CHECKING(for isinf with <math.h>)
9742cdcb
TO
337 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <math.h>
338volatile int x;volatile float f; ]], [[x = isinf(f)]])],[AC_MSG_RESULT(yes)
31b49791
TO
339 AC_DEFINE(HAVE_ISINF)],[AC_MSG_RESULT(no)])])
340
f6d0c1c8 341dnl finite is BSD, isfinite is C99, so prefer the latter
738d50c4 342AC_CACHE_CHECK([whether isfinite is broken],[ac_cv_have_broken_isfinite],[
f6d0c1c8
TO
343AC_TRY_RUN([
344#ifdef HAVE_MATH_H
345#include <math.h>
346#endif
347#ifdef HAVE_FLOAT_H
348#include <float.h>
349#endif
350int main ()
351{
352#ifdef isfinite
353#ifdef LDBL_MAX
354 if (!isfinite(LDBL_MAX)) return 1;
355#endif
356#ifdef DBL_MAX
357 if (!isfinite(DBL_MAX)) return 1;
358#endif
359#endif
360return 0;
738d50c4 361}],[ac_cv_have_broken_isfinite=no],[ac_cv_have_broken_isfinite=yes],[
f6d0c1c8 362case "${target}" in
738d50c4 363 hppa*-*-hpux*) ac_cv_have_broken_isfinite=yes ;;
7f58a869
TO
364 *-solaris2.8) ac_cv_have_broken_isfinite=yes ;;
365 *-solaris2.9) ac_cv_have_broken_isfinite=yes ;;
738d50c4 366 *) ac_cv_have_broken_isfinite=no ;;
f6d0c1c8
TO
367esac])
368])
738d50c4
TO
369
370dnl the test does not seem to work on solaris 2.8
371dnl so lets fix this by hand
372case "${target}" in
7f58a869
TO
373 *-solaris2.8) ac_cv_have_broken_isfinite=yes ;;
374 *-solaris2.9) ac_cv_have_broken_isfinite=yes ;;
738d50c4
TO
375esac
376
377if test "x$ac_cv_have_broken_isfinite" = "xno"; then
f6d0c1c8
TO
378 AC_DEFINE(HAVE_ISFINITE)
379else
738d50c4
TO
380 AC_CHECK_FUNCS(finite,[],
381 [AC_CHECK_FUNCS(isfinite,[],
382 [AC_MSG_CHECKING(for isfinite with <math.h>)
383 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <math.h>
f6d0c1c8
TO
384volatile int x;volatile float f; ]],[[x = isfinite(f)]])],[AC_MSG_RESULT(yes)
385 AC_DEFINE(HAVE_ISFINITE)],[AC_MSG_RESULT(no)])])])
0cbdf24b 386fi
f6d0c1c8 387
31b49791
TO
388AC_FULL_IEEE
389
b672fc87 390CONFIGURE_PART(Resolve Portability Issues)
1b0379de 391
2e6d4a7a
TO
392GC_TIMEZONE()
393
00bc333f
TO
394
395AC_CACHE_CHECK(whether sigwait has 2 arguments,
396 ac_cv_libc_sigwait,
397 AC_TRY_COMPILE([
398 #define _POSIX_PTHREAD_SEMANTICS
399 #include <stdio.h>
400 #include <signal.h>],
401 [sigset_t sigs; int signo; sigwait(&sigs, &signo);],
402 AC_DEFINE(HAVE_SIGWAIT,1,[have two argument posix sigwait])
403 AC_MSG_RESULT(yes)
404 ,
0cbdf24b 405 AC_MSG_RESULT(no)
00bc333f
TO
406 )
407)
408
505bfff7 409
dcc2ea02
TO
410CHECK_FOR_WORKING_MS_ASYNC
411
52326128
TO
412dnl do we have nl_langinfo(_NL_TIME_WEEK_1STDAY)
413AC_CHECK_FUNCS(_NL_TIME_WEEK_1STDAY, ,
414 [AC_MSG_CHECKING([for nl_langinfo(_NL_TIME_WEEK_1STDAY) with langinfo.h])
415 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <langinfo.h>]], [[nl_langinfo(_NL_TIME_WEEK_1STDAY)]])],[AC_MSG_RESULT(yes)
416 AC_DEFINE(HAVE__NL_TIME_WEEK_1STDAY)],[AC_MSG_RESULT(no)])])
417
b672fc87 418dnl what does realloc do if it gets called with a NULL pointer
1b0379de 419
b672fc87
TO
420AC_CACHE_CHECK([if realloc can deal with NULL], rd_cv_null_realloc,
421[AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
422 int main(void){
423 char *x = NULL;
424 x = realloc (x,10);
425 if (x==NULL) return 1;
426 return 0;
427 }]])],[rd_cv_null_realloc=yes],[rd_cv_null_realloc=nope],[:])])
8b65ac0e 428
b672fc87
TO
429if test x"$rd_cv_null_realloc" = xnope; then
430AC_DEFINE(NO_NULL_REALLOC)
8b65ac0e
TO
431fi
432
31b49791 433AC_LANG_PUSH(C)
f6537a47 434dnl solaris has some odd defines it needs in order to properly compile ctime_r
8b65ac0e
TO
435AC_MSG_CHECKING([if ctime_r need special care to act posixly correct])
436AC_LINK_IFELSE(
c5794b2d 437 [AC_LANG_PROGRAM(
8b65ac0e 438 [[#include <time.h>]],
c5794b2d 439 [[ctime_r(NULL,NULL,0)]])],
8b65ac0e
TO
440 [ CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
441 AC_LINK_IFELSE(
c5794b2d 442 [AC_LANG_PROGRAM(
8b65ac0e 443 [[#include <time.h>]],
c5794b2d 444 [[ctime_r(NULL,NULL)]])],
8b65ac0e
TO
445 [AC_MSG_RESULT([yes, this seems to be solaris style])],
446 [AC_MSG_ERROR([Can't figure how to compile ctime_r])]
447 )
0cbdf24b 448 ],
8b65ac0e 449 [ AC_LINK_IFELSE(
c5794b2d 450 [AC_LANG_PROGRAM(
603de9af 451 [[#ifdef __MINGW32__
9f705650 452#define _POSIX_THREAD_SAFE_FUNCTIONS 200112L
603de9af
WS
453#endif
454#include <time.h>]],
c5794b2d 455 [[ctime_r(NULL,NULL)]])],
d05f6777 456 [AC_MSG_RESULT(no)],
8b65ac0e
TO
457 [AC_MSG_ERROR([Can't figure how to compile ctime_r])]
458 )
0cbdf24b 459 ]
8b65ac0e 460)
31b49791 461AC_LANG_POP(C)
8b65ac0e
TO
462
463dnl Check for pthreads
464dnl http://autoconf-archive.cryp.to/acx_pthread.m4
0cbdf24b 465
bdfab891
TO
466AC_SUBST(MULTITHREAD_CFLAGS)
467AC_SUBST(MULTITHREAD_LDFLAGS)
468
0cbdf24b 469if test $enable_pthread != no; then
8b65ac0e
TO
470 ACX_PTHREAD([
471 MULTITHREAD_CFLAGS=$PTHREAD_CFLAGS
472 MULTITHREAD_LDFLAGS=$PTHREAD_LIBS
473 ],
474 [])
bdfab891 475fi
8b65ac0e 476
e15ce81d
TO
477dnl since we use lots of *_r functions all over the code we better
478dnl make sure they are known
479
480if test "x$x_rflag" != "xno"; then
481 CPPFLAGS="$CPPFLAGS $x_rflag"
482fi
8b65ac0e 483
bdfab891 484AM_CONDITIONAL(BUILD_MULTITHREAD,[test $enable_pthread != no])
b672fc87
TO
485
486AC_LANG_PUSH(C)
487dnl see if we have to include malloc/malloc.h
488AC_MSG_CHECKING([do we need malloc/malloc.h])
489AC_LINK_IFELSE(
c5794b2d 490 [AC_LANG_PROGRAM(
b672fc87 491 [[#include <stdlib.h>]],
c5794b2d 492 [[malloc(1)]])],
b672fc87
TO
493 [ AC_MSG_RESULT([nope, works out of the box]) ],
494 [ AC_LINK_IFELSE(
c5794b2d 495 [AC_LANG_PROGRAM(
b672fc87
TO
496 [[#include <stdlib.h>
497 #include <malloc/malloc.h>]],
c5794b2d
SH
498 [[malloc(1)]])],
499 [AC_DEFINE([MUST_HAVE_MALLOC_MALLOC_H])
b672fc87 500 AC_MSG_RESULT([yes we do])],
6d14fd1d 501 [AC_MSG_ERROR([Can not figure how to compile malloc])]
b672fc87 502 )
0cbdf24b 503 ]
b672fc87 504)
5b2062c9 505AC_LANG_POP(C)
57e9361a 506
c86055b9 507dnl is time_t 32 of 64 bit ?
7a78d1a6 508AC_CHECK_SIZEOF([time_t])
b672fc87 509
e10fd700
JMV
510AC_CHECK_SIZEOF([long int])
511
c9808db5 512CONFIGURE_PART(Find 3rd-Party Libraries)
b672fc87 513
2609eb28
TO
514have_libdbi=no
515
620ae61e
516AC_ARG_ENABLE(libdbi,AS_HELP_STRING([--disable-libdbi],[do not build in support for libdbi]),
517[],
518[enable_libdbi=yes])
519
520AS_IF([test "x$enable_libdbi" != xno], [
0cbdf24b 521 AC_CHECK_HEADER(dbi/dbi.h, [
b5167667
TO
522 AC_CHECK_LIB(dbi, dbi_initialize, [
523 AC_DEFINE(HAVE_LIBDBI,[1],[have got libdbi installed])
4c0ff24a 524 LIBS="${LIBS} -ldbi"
b5167667
TO
525 have_libdbi=yes
526 ])
527 ])
311f41ad 528])
2609eb28 529
311f41ad 530AM_CONDITIONAL(BUILD_LIBDBI,[test $have_libdbi != no])
b672fc87 531
e0ec619b
SB
532have_librados=no
533
620ae61e
534AC_ARG_ENABLE(librados,AS_HELP_STRING([--disable-librados],[do not build in support for librados]),
535[],
536[enable_librados=yes])
537
538AS_IF([test "x$enable_librados" != xno], [
e0ec619b
SB
539 AC_CHECK_HEADER(rados/librados.h, [
540 AC_DEFINE(HAVE_LIBRADOS,[1],[have got librados installed])
541 LIBS="${LIBS} -lrados"
542 have_librados=yes
543 ])
544])
545
546AM_CONDITIONAL(BUILD_LIBRADOS,[test $have_librados != no])
547
b5167667
TO
548have_libwrap=no
549
620ae61e
550AC_ARG_ENABLE(libwrap, AS_HELP_STRING([--disable-libwrap], [do not build in support for libwrap (tcp wrapper)]),
551[],
552[enable_libwrap=yes])
553
554AS_IF([test "x$enable_libwrap" != xno], [
0cbdf24b 555 AC_CHECK_HEADER(tcpd.h,[
b5167667
TO
556 AC_CHECK_FUNCS(hosts_access, [
557 AC_DEFINE(HAVE_LIBWRAP,[1],[have got libwrap installed])
0cbdf24b
TO
558 have_libwrap=yes
559 ],
b5167667
TO
560 [
561 AC_CHECK_LIB(wrap, hosts_access, [
562 AC_DEFINE(HAVE_LIBWRAP,[1],[have got libwrap installed])
563 LIBS="${LIBS} -lwrap"
564 have_libwrap=yes
565 ])
566 ])
567 ])
568])
569
570
571AM_CONDITIONAL(BUILD_LIBWRAP,[test $have_libwrap != no])
b672fc87 572
52018ea3
TO
573AM_CONDITIONAL(BUILD_RRDGRAPH,[test $enable_rrd_graph != no])
574
91ce7bd4
FB
575AM_CONDITIONAL(BUILD_RRDRESTORE,[test $enable_rrd_restore != no])
576
cef27b4d 577EX_CHECK_ALL(glib-2.0, glib_check_version, glib.h, glib-2.0, 2.28.7, ftp://ftp.gtk.org/pub/glib/2.28/, "")
58cc8383 578
e35d4604 579AC_CACHE_CHECK([whether we need to include gthreads for g_thread_init],
580 [ac_cv_glibc_g_thread_init],
581 [AC_TRY_COMPILE([#include <glib.h>],
582 [#if !GLIB_CHECK_VERSION(2, 32, 0)
583 # error "glib needs g_thread_init"
584 #endif],
585 [AC_MSG_RESULT(no)],
586 [EX_CHECK_ALL(gthread-2.0, g_thread_init, glib.h, gthread-2.0, x.x.x, "", "")
587 AC_MSG_RESULT(yes)])])
588
0da4ceb3
TO
589AC_CHECK_FUNC(g_regex_new,[
590 AC_DEFINE(HAVE_G_REGEX_NEW,[1],[our glib has g_regex_new])
591],[
be6bc22d
TO
592 AC_MSG_CHECKING(if pcre is available to supply the missing regex support in glib)
593 AC_MSG_RESULT(checking now ...)
594 EX_CHECK_ALL(pcre, pcre_compile, pcre.h, pcre, x.x.x, [get a newer glib and you will not need pcre at all],"")
8743b41d 595 AC_CHECK_FUNC(pcre_compile,[
0da4ceb3
TO
596 AC_DEFINE(HAVE_PCRE_COMPILE,[1],[we have pcre to replace missing regexp support form glib])
597 ],[
598 AC_MSG_ERROR([you need either glib with g_regex support or libpcre to compile rrdtool.])
599 ])
be6bc22d
TO
600])
601
602
603
6d14fd1d
TO
604CORE_LIBS="$LIBS"
605
52018ea3 606if test $enable_rrd_graph != no; then
74538d88 607dnl EX_CHECK_ALL(z, zlibVersion, zlib.h, zlib, 1.2.5, http://zlib.net/, "")
a2e41a7f 608EX_CHECK_ALL(png, png_access_version_number, png.h, libpng, 1.4.8, ftp://ftp.simplesystems.org/pub/libpng/png/src/, "")
74538d88
TO
609dnl EX_CHECK_ALL(freetype, FT_Init_FreeType, ft2build.h, freetype2, 2.4.6, http://download.savannah.gnu.org/releases/freetype/, /usr/include/freetype2)
610dnl EX_CHECK_ALL(fontconfig, FcInit, fontconfig.h, fontconfig, 2.8.0, http://www.freedesktop.org/software/fontconfig/release/, /usr/include)
be6bc22d 611dnl EX_CHECK_ALL(cairo, cairo_font_options_create, cairo.h, cairo-png, 1.10.2, http://cairographics.org/releases/, "")
5daf953b
FB
612dnl EX_CHECK_ALL(cairo, cairo_svg_surface_create, cairo-svg.h, cairo-svg, 1.10.2, http://cairographics.org/releases/, "")
613dnl EX_CHECK_ALL(cairo, cairo_pdf_surface_create, cairo-pdf.h, cairo-pdf, 1.10.2, http://cairographics.org/releases/, "")
614dnl EX_CHECK_ALL(cairo, cairo_ps_surface_create, cairo-ps.h, cairo-ps, 1.10.2, http://cairographics.org/releases/, "")
6b50901a 615EX_CHECK_ALL(pangocairo-1.0, pango_cairo_context_set_font_options, pango/pango.h, pangocairo, 1.28.4, http://ftp.gnome.org/pub/GNOME/sources/pango/1.28, "")
a9f00dfb 616EX_CHECK_ALL(gobject-2.0, g_object_unref, glib-object.h, gobject-2.0, 2.58.1, https://download.gnome.org/sources/glib/2.58/, "")
52018ea3 617
bcba7428 618AC_CHECK_FUNCS(pango_font_map_create_context)
52018ea3 619fi
91ce7bd4
FB
620
621if test $enable_rrd_restore != no; then
a89aa806 622EX_CHECK_ALL(xml2, xmlParseFile, libxml/parser.h, libxml-2.0, 2.7.8, http://xmlsoft.org/downloads.html, "")
91ce7bd4 623fi
b672fc87
TO
624
625if test "$EX_CHECK_ALL_ERR" = "YES"; then
626 AC_MSG_ERROR([Please fix the library issues listed above and try again.])
627fi
628
3c041eea
WS
629dnl Sort and remove duplicate entries in LIBS before assigning to ALL_LIBS
630ALL_LIBS=$(echo "$LIBS"|tr -s " " "\n"|sort -u|tr "\n" " ")
6d14fd1d
TO
631LIBS=
632
633AC_SUBST(CORE_LIBS)
634AC_SUBST(ALL_LIBS)
b672fc87
TO
635
636CONFIGURE_PART(Prep for Building Language Bindings)
0cbdf24b 637
13b1511c
JMV
638dnl Allow "if enable_rpath" in Makefile.am
639AM_CONDITIONAL(ENABLE_RPATH,[test "x$enable_rpath" = "xyes"])
640
51e629f8 641dnl Check for Perl and friends
2d974270 642PATH=$PATH:/usr/perl5/bin
51e629f8 643export PATH
37fc6638 644AC_PATH_PROG(PERL, perl, no)
51e629f8
TO
645AC_PATH_PROG(POD2MAN, pod2man, no)
646AC_PATH_PROG(POD2HTML, pod2html, no)
647
29ae1780
TO
648dnl for testing a numerical version number comes handy
649dnl the released version are
650dnl a.bccc
651dnl the devel versions will be something like
652dnl a.b999yymmddhh
653NUMVERS=m4_esyscmd([perl -ne 'my @x=split /\./;printf "%d.%d%03d", @x' VERSION])
654AC_SUBST(NUMVERS)
f3d2fe14 655
a76b432b 656AC_ARG_ENABLE(perl,AS_HELP_STRING([--disable-perl],[do not build the perl modules]),
f3d2fe14
TO
657[],[enable_perl=yes])
658
659
e57de196
TO
660AC_ARG_VAR(PERLCC, [C compiler for Perl modules])
661AC_ARG_VAR(PERLCCFLAGS, [CC flags for Perl modules])
662AC_ARG_VAR(PERLLD, [Linker for Perl modules])
663AC_ARG_VAR(PERLLDFLAGS, [LD flags for Perl modules])
f4b13c4e 664
f3d2fe14 665if test "x$PERL" = "xno" -o x$enable_perl = xno; then
37fc6638
TO
666 COMP_PERL=
667else
12bf1a88 668 COMP_PERL="perl-piped perl-shared"
4b73bd05
TO
669 AC_MSG_CHECKING(for the perl version you are running)
670 PERL_VERSION=`$PERL -MConfig -e 'print $Config{version}'`
671 AC_MSG_RESULT($PERL_VERSION)
f4b13c4e
TO
672 if test -z "$PERLCC"; then
673 AC_MSG_CHECKING(for the C compiler perl wants to use to build its modules)
674 perlcc=`$PERL -MConfig -e 'print $Config{cc}'`
675 AC_MSG_RESULT($perlcc)
676 if test ! -x "$perlcc"; then
b608503b 677 AC_PATH_PROG(PERL_CC, ${perlcc}, no)
f4b13c4e
TO
678 if test "$PERL_CC" = "no"; then
679 AC_MSG_WARN([
680I would not find the Compiler ($perlcc) that was originally used to compile
681your perl binary. You should either make sure that this compiler is
682available on your system, pick an other compiler and set PERLCC
683appropriately, or use a different perl setup that was compiled locally.
684
685I will disable the compilation of the RRDs perl module for now.
4b73bd05 686])
12bf1a88 687 COMP_PERL="perl-piped"
f4b13c4e 688 fi
0cbdf24b 689 fi
a6e2fe4a 690 fi
37fc6638 691fi
b672fc87 692
4b73bd05
TO
693AC_MSG_CHECKING(Perl Modules to build)
694AC_MSG_RESULT(${COMP_PERL:-No Perl Modules will be built})
695
e933aae6
VK
696# Use reproducible build date and time
697if test "$SOURCE_DATE_EPOCH"; then
e59f703b 698 DATE_FMT="%b %d %Y %H:%M:%S"
e933aae6
VK
699 BUILD_DATE=$(LC_ALL=C date -u -d "@$SOURCE_DATE_EPOCH" "+$DATE_FMT")
700 AC_DEFINE_UNQUOTED([BUILD_DATE], ["$BUILD_DATE"], [Use reproducible build date])
701fi
702
4b73bd05 703# Options to pass when configuring perl module
e7d79940 704langpref=$prefix
c862de08 705test "$langpref" = '$(DESTDIR)NONE' && langpref='$(DESTDIR)'$ac_default_prefix
e7d79940 706test "$langpref" = "NONE" && langpref=$ac_default_prefix
4936b460 707
ce493cbc 708PERL_MAKE_OPTIONS="PREFIX=$langpref INSTALL_BASE= LIB=$langpref/lib/perl/$PERL_VERSION"
4b73bd05
TO
709
710dnl pass additional perl options when generating Makefile from Makefile.PL
711AC_ARG_ENABLE(perl-site-install,
a76b432b 712AS_HELP_STRING([--enable-perl-site-install],[by default the rrdtool perl modules are installed together with rrdtool in $prefix/lib/perl. You have to put a 'use lib qw($prefix/lib/perl)' into your scripts when you want to use them. When you set this option the perl modules will get installed wherever your perl setup thinks it is best.]),
4b73bd05
TO
713[PERL_MAKE_OPTIONS=],[])
714
f4b13c4e
TO
715if test ! -z "$PERLCC"; then
716 PERL_MAKE_OPTIONS="$PERL_MAKE_OPTIONS CC=$PERLCC"
717
718 if test ! -z "$PERLCCFLAGS"; then
719 PERL_MAKE_OPTIONS="$PERL_MAKE_OPTIONS CCFLAGS=$PERLCCFLAGS"
720 fi
0cbdf24b 721
f4b13c4e
TO
722 if test -z "$PERLLD"; then
723 PERLLD=$PERLCC
724 fi
725 PERL_MAKE_OPTIONS="$PERL_MAKE_OPTIONS LD=$PERLLD"
0cbdf24b 726
f4b13c4e
TO
727 if test ! -z "$PERLLDFLAGS"; then
728 PERL_MAKE_OPTIONS="$PERL_MAKE_OPTIONS LDFLAGS=$PERLLDFLAGS"
729 fi
730fi
0cbdf24b 731
4b73bd05
TO
732AC_ARG_WITH(perl-options,
733[ --with-perl-options=[OPTIONS] options to pass on command-line when
734 generating Makefile from Makefile.PL. If you set this
735 option, interesting things may happen unless you know
736 what you are doing!],
737[PERL_MAKE_OPTIONS=$withval])
738
739AC_SUBST(PERL_MAKE_OPTIONS)
740AC_SUBST(PERL)
37fc6638 741AC_SUBST(COMP_PERL)
4b73bd05 742AC_SUBST(PERL_VERSION)
37fc6638 743
6d14fd1d
TO
744dnl Check for Ruby.
745AC_PATH_PROG(RUBY, ruby, no)
746
a76b432b 747AC_ARG_ENABLE(ruby,AS_HELP_STRING([--disable-ruby],[do not build the ruby modules]),
6d14fd1d
TO
748[],[enable_ruby=yes])
749
b07a3abc 750AC_MSG_CHECKING(if ruby modules can be built)
6d14fd1d
TO
751
752if test "x$RUBY" = "xno" -o x$enable_ruby = xno; then
753 COMP_RUBY=
b07a3abc 754 AC_MSG_RESULT(No .. Ruby not found or disabled)
6d14fd1d 755else
b07a3abc
TO
756 if $RUBY -e 'require "mkmf"' >/dev/null 2>&1; then
757 COMP_RUBY="ruby"
758 AC_MSG_RESULT(YES)
759 else
760 COMP_RUBY=
0cbdf24b
TO
761 AC_MSG_RESULT(Ruby found but mkmf is missing! Install the -dev package)
762 fi
6d14fd1d
TO
763fi
764
6d14fd1d
TO
765dnl pass additional ruby options when generating Makefile from Makefile.PL
766AC_ARG_ENABLE(ruby-site-install,
a76b432b 767AS_HELP_STRING([--enable-ruby-site-install],[by default the rrdtool ruby modules are installed together with rrdtool in $prefix/lib/ruby. You have to add $prefix/lib/ruby/$ruby_version/$sitearch to your $: variable for ruby to find the RRD.so file.]),
e7d79940 768[RUBY_MAKE_OPTIONS=],[RUBY_MAKE_OPTIONS="sitedir=$langpref/lib/ruby"])
6d14fd1d 769
0cbdf24b 770
6d14fd1d
TO
771AC_ARG_WITH(ruby-options,
772[ --with-ruby-options=[OPTIONS] options to pass on command-line when
773 generating Makefile from extconf.rb. If you set this
774 option, interesting things may happen unless you know
775 what you are doing!],
776[RUBY_MAKE_OPTIONS=$withval])
777
778AC_SUBST(RUBY_MAKE_OPTIONS)
779AC_SUBST(RUBY)
780AC_SUBST(COMP_RUBY)
1181b81a 781AM_CONDITIONAL(BUILD_RUBY,[test $enable_ruby = "yes"])
6d14fd1d 782
e7d79940
TO
783dnl Check for Lua.
784AC_PATH_PROG(LUA, lua, no)
785
a76b432b 786AC_ARG_ENABLE(lua,AS_HELP_STRING([--disable-lua],[do not build the lua modules]),
e7d79940
TO
787[],[enable_lua=yes])
788
e7d79940 789COMP_LUA=
b4cc220b
TO
790if test "$LUA" = "no" -o "$enable_lua" = "no"; then
791 enable_lua=no
e7d79940 792else
b4cc220b
TO
793 AC_MSG_CHECKING(for lua >= 5.0)
794 read LUA_MAJOR LUA_MINOR LUA_POINT <<LUA_EOF
795 $($LUA -v 2>&1 | cut -f2 -d' ' | sed -e 's/\./ /g')
796LUA_EOF
797 if test 0$LUA_MAJOR -lt 5; then
798 AC_MSG_RESULT([no, version found is $LUA_MAJOR.$LUA_MINOR])
799 else
800 AC_MSG_RESULT([$LUA_MAJOR.$LUA_MINOR found])
71c7ff72
TO
801 lua_vdot=$LUA_MAJOR.$LUA_MINOR
802 lua_vndot=$LUA_MAJOR$LUA_MINOR
b4cc220b 803 lua_version=$LUA_MAJOR.$LUA_MINOR.$LUA_POINT
71c7ff72
TO
804 AC_CHECK_HEADERS(lua$lua_vndot/lua.h,
805 [AC_CHECK_HEADERS(lua$lua_vndot/lualib.h,
806 [AC_CHECK_HEADER(lua$lua_vndot/lauxlib.h,
807 [lua_headerdir=lua$lua_vndot],
b4cc220b
TO
808 [])],
809 [])],
71c7ff72
TO
810 [AC_CHECK_HEADERS(lua$lua_vdot/lua.h,
811 [AC_CHECK_HEADERS(lua$lua_vdot/lualib.h,
812 [AC_CHECK_HEADER(lua$lua_vdot/lauxlib.h,
813 [lua_headerdir=lua$lua_vdot],
b4cc220b
TO
814 [])],
815 [])],
816 [AC_CHECK_HEADERS(lua.h,
817 [AC_CHECK_HEADERS(lualib.h,
818 [AC_CHECK_HEADER(lauxlib.h,
819 [lua_headerdir=""],
820 [lua_headerdir="no"])],
821 [])],
822 [])])])
823
824 if test "$lua_headerdir" = "no"; then
825 enable_lua=no
826 else
827 COMP_LUA=lua
e7d79940 828 fi
e7d79940 829
b4cc220b
TO
830 if test "$COMP_LUA" != "lua"; then
831 enable_lua=no
71c7ff72 832 AC_MSG_WARN([Lua $lua_vdot found but not lua.h, lualib.h and lauxlib.h! Please install the -dev packages for Lua $lua_vdot])
b4cc220b
TO
833 else
834 # OK, headers found, let's check the libraries (LIBS is not used)
835 LIBS=
836 lua_havelib=no
837 LUA_HAVE_COMPAT51=DONT_HAVE_COMPAT51
7af5f762
YR
838 RRD_SEARCH_LIBS(lua_call, [#include <${lua_headerdir:+$lua_headerdir/}lua.h>], [0, 0, 0], lua$lua_vdot lua$lua_vndot lua,
839 [AC_SEARCH_LIBS(luaL_openlibs, lua$lua_vdot lua$lua_vndot lua,
71c7ff72
TO
840 [lua_havelib=LUA$lua_vndot],
841 [AC_SEARCH_LIBS(luaL_module, lualib$lua_vndot lualib$lua_vdot lualib,
842 [lua_havelib=$lua_vndot; $LUA -l compat-5.1 2>/dev/null;
843 test "$?" = "0" && LUA_HAVE_COMPAT51=HAVE_COMPAT51],
844 [AC_SEARCH_LIBS(luaL_openlib, lualib$lua_vdot lualib$lua_vndot lualib,
845 [lua_havelib=$lua_vndot],
b4cc220b
TO
846 [COMP_LUA=], [-lm])], [-lm])], [-lm])],
847 [COMP_LUA=], [-lm])
848 lua_libs=$LIBS
849 LIBS=
850
851 # Options to pass when configuring Lua module
852 if test "$lua_havelib" != "no"; then
71c7ff72
TO
853 # OK, headers and libs found. Try to set lua flags
854 # and modules installation dirs with pkg-config
b4cc220b 855 if test "$PKGCONFIG" != "no"; then
71c7ff72 856 if test "$lua_vndot" = "50"; then
b4cc220b
TO
857 lua_pkg_prefix=lualib
858 else
859 lua_pkg_prefix=lua
860 fi
861 # try with dot, without dot and finally without version
71c7ff72
TO
862 for f in $lua_pkg_prefix$lua_vdot $lua_pkg_prefix$lua_vndot $lua_pkg_prefix; do
863 lua_exec_prefix=`$PKGCONFIG --variable=prefix $f 2>/dev/null`
864 # same binaries?
0cbdf24b 865 if test "$lua_exec_prefix/bin/lua" = "$LUA"; then
71c7ff72
TO
866 # OK, found CFLAGS. Get Lua LFLAGS and modules install dir
867 LUA_CFLAGS=`$PKGCONFIG --cflags $f 2>/dev/null`
868 LUA_LFLAGS=`$PKGCONFIG --libs $f 2>/dev/null`
869 LUA_INSTALL_CMOD=`$PKGCONFIG --variable=INSTALL_CMOD $f 2>/dev/null`
870 LUA_INSTALL_LMOD=`$PKGCONFIG --variable=INSTALL_LMOD $f 2>/dev/null`
871 break
b4cc220b
TO
872 fi
873 done
874 fi
e7d79940 875
9cda1be4 876 LUA_RRD_LIBDIR="$libdir/lua/$lua_vdot"
71c7ff72
TO
877 # if lua 5.0 can't find compat-5.1, force installation of
878 # compat-5.1.lua together with RRDtool.
879 if test "$lua_vdot" = "5.0" -a "$LUA_HAVE_COMPAT51" != "HAVE_COMPAT51"; then
0cbdf24b 880 lua_need_compat51=1
71c7ff72 881 LUA_INSTALL_LMOD="$LUA_RRD_LIBDIR"
b4cc220b 882 fi
71c7ff72
TO
883
884 # if not set with pkg-config, use default values in src packages compat-5.1, lua 5.1
885 if test "$LUA_CFLAGS" = ""; then
886 AC_MSG_WARN(Setting Lua include and lib flags to defaults in compat-5.1 and lua 5.1 sources)
887 LUA_CFLAGS="-I/usr/local/include -I/usr/local/include/lua -I/usr/local/include/lua/$lua_vdot"
888 LUA_LFLAGS="-L/usr/local/lib -L/usr/local/lib/lua -L/usr/local/lib/lua/$lua_vdot $lua_libs"
889 LUA_INSTALL_CMOD="/usr/local/lib/lua/$lua_vdot"
b4cc220b 890 fi
e7d79940 891
b4cc220b 892 dnl pass additional lua options
71c7ff72
TO
893 dnl if lua-site-install is not set, overwrite LUA_INSTALL_CMOD already
894 dnl found and install together with RRDtool, under $langpref.
b4cc220b 895 AC_ARG_ENABLE(lua-site-install,
a76b432b 896 AS_HELP_STRING([--enable-lua-site-install],[by default the lua module is installed together with rrdtool in $prefix/lib/lua/$lua_version. You have to add $prefix/lib/lua/$lua_version/?.so to package.cpath for lua to find 'rrd.so'. For lua 5.0 you may also need to change LUA_PATH to the same dir, to require 'compat-5.1'. When you set this option the lua modules will get installed wherever your Lua setup thinks it is best. WARNING: if you set this option, system lua modules compat-5.1.lua and rrd.so, if any, may be overwritten.]),
b4cc220b 897 [],
71c7ff72 898 [LUA_INSTALL_CMOD="$LUA_RRD_LIBDIR"; LUA_INSTALL_LMOD="$LUA_RRD_LIBDIR"])
b4cc220b 899
71c7ff72 900 LUA_DEFINES="-DLUA$lua_vndot -D$LUA_HAVE_COMPAT51"
b4cc220b
TO
901 AC_SUBST(LUA)
902 AC_SUBST(COMP_LUA)
b4cc220b 903 AC_SUBST(LUA_INSTALL_CMOD)
71c7ff72 904 AC_SUBST(LUA_INSTALL_LMOD)
b4cc220b
TO
905 AC_SUBST(LUA_CFLAGS)
906 AC_SUBST(LUA_LFLAGS)
71c7ff72 907 AC_SUBST(LUA_DEFINES)
b4cc220b
TO
908 else
909 enable_lua=no
910 AC_MSG_RESULT([Lua headers found but not the libraries! Please reinstall the dev packages for Lua $LUA_MAJOR.$LUA_MINOR])
911 fi
912 fi
913 fi
914fi
71c7ff72
TO
915dnl If Lua 5.0, we need compat-5.1. Add ours unless already
916dnl integrated as in Debian/Ubuntu 5.0 -dev packages.
917AM_CONDITIONAL(LUA_NEED_OUR_COMPAT51,
918 [test "$lua_vdot" = "5.0" -a "$LUA_HAVE_COMPAT51" != "HAVE_COMPAT51"])
919AM_CONDITIONAL(LUA_SITE_CINSTALL, [test "$LUA_INSTALL_CMOD" != "$LUA_RRD_LIBDIR"])
920AM_CONDITIONAL(LUA_SITE_LINSTALL, [test "$LUA_INSTALL_LMOD" != "$LUA_RRD_LIBDIR"])
921AM_CONDITIONAL(LUA50, [test "$lua_vndot" = "50"])
922AM_CONDITIONAL(BUILD_LUA, [test "$enable_lua" = "yes"])
6d14fd1d 923
cf5a9eb4
TO
924enable_tcl_site=no
925
a76b432b 926AC_ARG_ENABLE(tcl,AS_HELP_STRING([--disable-tcl],[do not build the tcl modules]),
e93d17d9 927[],[enable_tcl=yes])
965d0f77 928
e93d17d9
TO
929if test "$enable_tcl" = "yes"; then
930 dnl Check for Tcl.
931 withval=""
932 AC_ARG_WITH(tcllib,[ --with-tcllib=DIR location of the tclConfig.sh])
933 enable_tcl=no
3973781b 934 for dir in $withval /usr/lib /usr/lib64 /usr/local/lib /usr/lib/tcl8.4 /usr/lib/tcl8.3 ; do
d363449b
TO
935 AC_MSG_CHECKING(for tclConfig.sh in $dir)
936 if test -f "$dir/tclConfig.sh" ; then
937 tcl_config=$dir/tclConfig.sh
e93d17d9 938 enable_tcl=yes
37fc6638
TO
939 AC_MSG_RESULT(yes)
940 break
d363449b 941 else
37fc6638 942 AC_MSG_RESULT(no)
d363449b
TO
943 fi
944 done
37fc6638 945
e93d17d9 946 if test "$enable_tcl" = "no"; then
777e0070 947 AC_MSG_WARN([tclConfig.sh not found - Tcl interface will not be built])
e93d17d9 948 else
37fc6638 949 . $tcl_config
d363449b 950 TCL_PACKAGE_DIR="$TCL_PACKAGE_PATH/tclrrd$VERSION"
6d0ed52e
TO
951 if test -n "$TCL_INC_DIR"; then
952 TCL_INCLUDE_SPEC="$TCL_INCLUDE_SPEC -I$TCL_INC_DIR"
953 fi
e93d17d9 954 fi
fa922b40 955 AC_ARG_ENABLE(tcl-site,AS_HELP_STRING([--enable-tcl-site],[install the tcl extension in the tcl tree]),
cf5a9eb4
TO
956 [],[enable_tcl_site=yes])
957
37fc6638
TO
958fi
959
e93d17d9 960AM_CONDITIONAL(BUILD_TCL, test "$enable_tcl" = "yes" )
cf5a9eb4 961AM_CONDITIONAL(BUILD_TCL_SITE, test "$enable_tcl_site" = "yes" )
37fc6638 962
58cc8383 963
37fc6638
TO
964AC_SUBST(TCL_PREFIX)
965AC_SUBST(TCL_SHLIB_CFLAGS)
966AC_SUBST(TCL_SHLIB_LD)
967AC_SUBST(TCL_SHLIB_SUFFIX)
968AC_SUBST(TCL_PACKAGE_PATH)
969AC_SUBST(TCL_LD_SEARCH_FLAGS)
0fc6019b 970AC_SUBST(TCL_STUB_LIB_SPEC)
d363449b
TO
971AC_SUBST(TCL_VERSION)
972AC_SUBST(TCL_PACKAGE_DIR)
6d0ed52e 973AC_SUBST(TCL_INCLUDE_SPEC)
37fc6638 974
a76b432b 975AC_ARG_ENABLE(python,AS_HELP_STRING([--disable-python],[do not build the python modules]),
e93d17d9
TO
976[],[enable_python=yes])
977
978if test "$enable_python" = "yes"; then
3f437d5c 979dnl Check for python
e93d17d9
TO
980AM_PATH_PYTHON(2.3,[],[enable_python=no])
981AM_CHECK_PYTHON_HEADERS(,[enable_python=no;AC_MSG_WARN(could not find Python headers)])
982fi
37fc6638 983
7a83911d
TO
984if test x$enable_python = xno; then
985 COMP_PYTHON=
986else
987 COMP_PYTHON="python"
988fi
989
990AC_SUBST(COMP_PYTHON)
1181b81a 991AM_CONDITIONAL(BUILD_PYTHON,[test $enable_python = "yes"])
37fc6638 992
deaef079
GZ
993if test $enable_docs != no; then
994
37fc6638 995dnl Check for nroff
654651f7
TO
996AC_ARG_VAR(NROFF, [path to the local nroff version])
997AC_PATH_PROGS(NROFF, [gnroff nroff])
998if test x$NROFF = x; then
999 AC_MSG_ERROR([I need a copy of *nroff to format the documentation])
1000fi
1001AC_ARG_VAR(TROFF, [path to the local troff version])
1002AC_PATH_PROGS(TROFF, [groff troff])
1003if test x$TROFF = x; then
1004 AC_MSG_ERROR([I need a copy of *troff to format the documentation])
1005fi
37fc6638 1006
f4b13c4e
TO
1007AC_ARG_VAR(RRDDOCDIR, [[DATADIR/doc/PACKAGE-VERSION] Documentation directory])
1008if test -z "$RRDDOCDIR"; then
1009 RRDDOCDIR='${datadir}/doc/${PACKAGE}-${VERSION}'; fi
1010
deaef079
GZ
1011fi
1012
f6537a47
WS
1013# Check for MinGW-w64 build and pass to automake
1014build_mingw_w64=no
1015AC_MSG_CHECKING([for MinGW-w64 build])
1016case "$host" in
1017 *w64-mingw32*)
1018 AC_MSG_RESULT([yes])
1019 build_mingw_w64=yes
1020 ;;
1021 *)
1022 AC_MSG_RESULT([no])
1023 ;;
1024esac
1025# Pass the conditional to automake
1026AM_CONDITIONAL([MINGW_W64], [test "$build_mingw_w64" = "yes"])
1027
134ed0d3
TO
1028# systemd check
1029PKG_PROG_PKG_CONFIG
1030AC_ARG_WITH([systemdsystemunitdir],
1031 AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
1032 [], [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
1033if test "x$with_systemdsystemunitdir" != xno; then
1034 AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
1035 AC_OUTPUT([etc/rrdcached.socket etc/rrdcached.service])
1036fi
1037AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
1038
37fc6638 1039
b672fc87 1040CONFIGURE_PART(Apply Configuration Information)
0cbdf24b 1041
deb6b836
TO
1042AC_CONFIG_FILES([examples/shared-demo.pl])
1043AC_CONFIG_FILES([examples/piped-demo.pl])
1044AC_CONFIG_FILES([examples/stripes.pl])
1045AC_CONFIG_FILES([examples/bigtops.pl])
1046AC_CONFIG_FILES([examples/minmax.pl])
deb6b836 1047AC_CONFIG_FILES([examples/4charts.pl])
7adfdafc 1048AC_CONFIG_FILES([examples/perftest.pl])
deb6b836 1049AC_CONFIG_FILES([examples/Makefile])
873f61f9 1050AC_CONFIG_FILES([examples/rrdcached/Makefile])
4fa84a99 1051AC_CONFIG_FILES([etc/rrdcached-default-lsb])
64e74e75 1052AC_CONFIG_FILES([tests/Makefile])
deb6b836 1053AC_CONFIG_FILES([doc/Makefile])
020fde35 1054AC_CONFIG_FILES([etc/Makefile])
0cbdf24b 1055AC_CONFIG_FILES([po/Makefile.in])
deb6b836 1056AC_CONFIG_FILES([src/Makefile])
9e5b1bb7 1057AC_CONFIG_FILES([src/librrd.pc])
deb6b836
TO
1058AC_CONFIG_FILES([bindings/Makefile])
1059AC_CONFIG_FILES([bindings/tcl/Makefile])
1060AC_CONFIG_FILES([bindings/tcl/ifOctets.tcl])
125593ce 1061AC_CONFIG_FILES([bindings/lua/Makefile])
0cbdf24b 1062AC_CONFIG_FILES([Makefile])
72b4ce71 1063
398cb63e 1064AC_CONFIG_COMMANDS([default],[[ chmod +x examples/*.pl]],[[]])
bb94a87f 1065
cdab6835 1066AC_OUTPUT
37fc6638
TO
1067
1068AC_MSG_CHECKING(in)
1069AC_MSG_RESULT(and out again)
1070
eea2e745 1071echo $ECHO_N "ordering CD from https://tobi.oetiker.ch/wish $ECHO_C" 1>&6
37fc6638 1072sleep 1
cdab6835 1073echo $ECHO_N ".$ECHO_C" 1>&6
37fc6638 1074sleep 1
cdab6835 1075echo $ECHO_N ".$ECHO_C" 1>&6
37fc6638 1076sleep 1
cdab6835 1077echo $ECHO_N ".$ECHO_C" 1>&6
37fc6638 1078sleep 1
cdab6835 1079echo $ECHO_N ".$ECHO_C" 1>&6
37fc6638
TO
1080sleep 1
1081AC_MSG_RESULT([ just kidding ;-)])
1082echo
1083echo "----------------------------------------------------------------"
1084echo "Config is DONE!"
1085echo
1e48a62f 1086echo " With MMAP IO: $enable_mmap"
0033ee5d 1087echo " With Locking: $enable_flock"
52018ea3 1088echo " Build rrd_graph: $enable_rrd_graph"
91ce7bd4 1089echo " Build rrd_restore: $enable_rrd_restore"
81ff9dac 1090echo " Static programs: $staticprogs"
e93d17d9
TO
1091echo " Perl Modules: $COMP_PERL"
1092echo " Perl Binary: $PERL"
1093echo " Perl Version: $PERL_VERSION"
1094echo " Perl Options: $PERL_MAKE_OPTIONS"
6d14fd1d
TO
1095echo " Ruby Modules: $COMP_RUBY"
1096echo " Ruby Binary: $RUBY"
1097echo " Ruby Options: $RUBY_MAKE_OPTIONS"
b4cc220b 1098echo " Build Lua Bindings: $enable_lua"
71c7ff72 1099if test "$enable_lua" = "yes"; then
e7d79940 1100echo " Lua Binary: $LUA"
b4cc220b 1101echo " Lua Version: $lua_version"
71c7ff72
TO
1102echo " Lua C-modules dir: $LUA_INSTALL_CMOD"
1103if test "$lua_need_compat51" = "1"; then
1104echo " Lua Lua-modules dir: $LUA_INSTALL_LMOD"
1105fi
1106fi
020fde35 1107echo " Systemd unit dir: $with_systemdsystemunitdir"
e93d17d9
TO
1108echo " Build Tcl Bindings: $enable_tcl"
1109echo " Build Python Bindings: $enable_python"
6be43f4a
WS
1110echo " Python Binary: $PYTHON"
1111echo " Python Version: $PYTHON_VERSION"
e24e014c 1112echo " Build examples: $enable_examples"
38fb0ad1 1113echo " Build rrdcached: $enable_rrdcached"
e93d17d9
TO
1114echo " Build rrdcgi: $enable_rrdcgi"
1115echo " Build librrd MT: $enable_pthread"
c862de08 1116echo " Use gettext: $USE_NLS"
311f41ad 1117echo " With libDBI: $have_libdbi"
e0ec619b 1118echo " With librados: $have_librados"
2740ecc9 1119echo " With libwrap: $have_libwrap"
134ed0d3 1120echo " With systemd dir: $with_systemdsystemunitdir"
e3f3fc54 1121echo
58cc8383 1122echo " Libraries: $ALL_LIBS"
f37148b1 1123echo
37fc6638
TO
1124echo "Type 'make' to compile the software and use 'make install' to "
1125echo "install everything to: $prefix."
020fde35
TO
1126if test "x$with_systemdsystemunitdir" != xno; then
1127echo
1128echo "Type 'make etc-install' to install systemd support for rrdcached"
1129fi
0cbdf24b 1130echo
37fc6638 1131echo " ... that wishlist is NO JOKE. If you find RRDtool useful"
eea2e745 1132echo "make me happy. Go to https://tobi.oetiker.ch/wish and"
37fc6638 1133echo "place an order."
0cbdf24b 1134echo
37fc6638
TO
1135echo " -- Tobi Oetiker <tobi@oetiker.ch>"
1136echo "----------------------------------------------------------------"