]> git.ipfire.org Git - thirdparty/rrdtool-1.x.git/blame - configure.ac
Merge pull request #1085 from zeising/zeising/zfs-fallocate
[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
8e6915c6 28LIBVERS=10:1:2
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
696# Options to pass when configuring perl module
e7d79940 697langpref=$prefix
c862de08 698test "$langpref" = '$(DESTDIR)NONE' && langpref='$(DESTDIR)'$ac_default_prefix
e7d79940 699test "$langpref" = "NONE" && langpref=$ac_default_prefix
4936b460 700
ce493cbc 701PERL_MAKE_OPTIONS="PREFIX=$langpref INSTALL_BASE= LIB=$langpref/lib/perl/$PERL_VERSION"
4b73bd05
TO
702
703dnl pass additional perl options when generating Makefile from Makefile.PL
704AC_ARG_ENABLE(perl-site-install,
a76b432b 705AS_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
706[PERL_MAKE_OPTIONS=],[])
707
f4b13c4e
TO
708if test ! -z "$PERLCC"; then
709 PERL_MAKE_OPTIONS="$PERL_MAKE_OPTIONS CC=$PERLCC"
710
711 if test ! -z "$PERLCCFLAGS"; then
712 PERL_MAKE_OPTIONS="$PERL_MAKE_OPTIONS CCFLAGS=$PERLCCFLAGS"
713 fi
0cbdf24b 714
f4b13c4e
TO
715 if test -z "$PERLLD"; then
716 PERLLD=$PERLCC
717 fi
718 PERL_MAKE_OPTIONS="$PERL_MAKE_OPTIONS LD=$PERLLD"
0cbdf24b 719
f4b13c4e
TO
720 if test ! -z "$PERLLDFLAGS"; then
721 PERL_MAKE_OPTIONS="$PERL_MAKE_OPTIONS LDFLAGS=$PERLLDFLAGS"
722 fi
723fi
0cbdf24b 724
4b73bd05
TO
725AC_ARG_WITH(perl-options,
726[ --with-perl-options=[OPTIONS] options to pass on command-line when
727 generating Makefile from Makefile.PL. If you set this
728 option, interesting things may happen unless you know
729 what you are doing!],
730[PERL_MAKE_OPTIONS=$withval])
731
732AC_SUBST(PERL_MAKE_OPTIONS)
733AC_SUBST(PERL)
37fc6638 734AC_SUBST(COMP_PERL)
4b73bd05 735AC_SUBST(PERL_VERSION)
37fc6638 736
6d14fd1d
TO
737dnl Check for Ruby.
738AC_PATH_PROG(RUBY, ruby, no)
739
a76b432b 740AC_ARG_ENABLE(ruby,AS_HELP_STRING([--disable-ruby],[do not build the ruby modules]),
6d14fd1d
TO
741[],[enable_ruby=yes])
742
b07a3abc 743AC_MSG_CHECKING(if ruby modules can be built)
6d14fd1d
TO
744
745if test "x$RUBY" = "xno" -o x$enable_ruby = xno; then
746 COMP_RUBY=
b07a3abc 747 AC_MSG_RESULT(No .. Ruby not found or disabled)
6d14fd1d 748else
b07a3abc
TO
749 if $RUBY -e 'require "mkmf"' >/dev/null 2>&1; then
750 COMP_RUBY="ruby"
751 AC_MSG_RESULT(YES)
752 else
753 COMP_RUBY=
0cbdf24b
TO
754 AC_MSG_RESULT(Ruby found but mkmf is missing! Install the -dev package)
755 fi
6d14fd1d
TO
756fi
757
6d14fd1d
TO
758dnl pass additional ruby options when generating Makefile from Makefile.PL
759AC_ARG_ENABLE(ruby-site-install,
a76b432b 760AS_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 761[RUBY_MAKE_OPTIONS=],[RUBY_MAKE_OPTIONS="sitedir=$langpref/lib/ruby"])
6d14fd1d 762
0cbdf24b 763
6d14fd1d
TO
764AC_ARG_WITH(ruby-options,
765[ --with-ruby-options=[OPTIONS] options to pass on command-line when
766 generating Makefile from extconf.rb. If you set this
767 option, interesting things may happen unless you know
768 what you are doing!],
769[RUBY_MAKE_OPTIONS=$withval])
770
771AC_SUBST(RUBY_MAKE_OPTIONS)
772AC_SUBST(RUBY)
773AC_SUBST(COMP_RUBY)
1181b81a 774AM_CONDITIONAL(BUILD_RUBY,[test $enable_ruby = "yes"])
6d14fd1d 775
e7d79940
TO
776dnl Check for Lua.
777AC_PATH_PROG(LUA, lua, no)
778
a76b432b 779AC_ARG_ENABLE(lua,AS_HELP_STRING([--disable-lua],[do not build the lua modules]),
e7d79940
TO
780[],[enable_lua=yes])
781
e7d79940 782COMP_LUA=
b4cc220b
TO
783if test "$LUA" = "no" -o "$enable_lua" = "no"; then
784 enable_lua=no
e7d79940 785else
b4cc220b
TO
786 AC_MSG_CHECKING(for lua >= 5.0)
787 read LUA_MAJOR LUA_MINOR LUA_POINT <<LUA_EOF
788 $($LUA -v 2>&1 | cut -f2 -d' ' | sed -e 's/\./ /g')
789LUA_EOF
790 if test 0$LUA_MAJOR -lt 5; then
791 AC_MSG_RESULT([no, version found is $LUA_MAJOR.$LUA_MINOR])
792 else
793 AC_MSG_RESULT([$LUA_MAJOR.$LUA_MINOR found])
71c7ff72
TO
794 lua_vdot=$LUA_MAJOR.$LUA_MINOR
795 lua_vndot=$LUA_MAJOR$LUA_MINOR
b4cc220b 796 lua_version=$LUA_MAJOR.$LUA_MINOR.$LUA_POINT
71c7ff72
TO
797 AC_CHECK_HEADERS(lua$lua_vndot/lua.h,
798 [AC_CHECK_HEADERS(lua$lua_vndot/lualib.h,
799 [AC_CHECK_HEADER(lua$lua_vndot/lauxlib.h,
800 [lua_headerdir=lua$lua_vndot],
b4cc220b
TO
801 [])],
802 [])],
71c7ff72
TO
803 [AC_CHECK_HEADERS(lua$lua_vdot/lua.h,
804 [AC_CHECK_HEADERS(lua$lua_vdot/lualib.h,
805 [AC_CHECK_HEADER(lua$lua_vdot/lauxlib.h,
806 [lua_headerdir=lua$lua_vdot],
b4cc220b
TO
807 [])],
808 [])],
809 [AC_CHECK_HEADERS(lua.h,
810 [AC_CHECK_HEADERS(lualib.h,
811 [AC_CHECK_HEADER(lauxlib.h,
812 [lua_headerdir=""],
813 [lua_headerdir="no"])],
814 [])],
815 [])])])
816
817 if test "$lua_headerdir" = "no"; then
818 enable_lua=no
819 else
820 COMP_LUA=lua
e7d79940 821 fi
e7d79940 822
b4cc220b
TO
823 if test "$COMP_LUA" != "lua"; then
824 enable_lua=no
71c7ff72 825 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
826 else
827 # OK, headers found, let's check the libraries (LIBS is not used)
828 LIBS=
829 lua_havelib=no
830 LUA_HAVE_COMPAT51=DONT_HAVE_COMPAT51
7af5f762
YR
831 RRD_SEARCH_LIBS(lua_call, [#include <${lua_headerdir:+$lua_headerdir/}lua.h>], [0, 0, 0], lua$lua_vdot lua$lua_vndot lua,
832 [AC_SEARCH_LIBS(luaL_openlibs, lua$lua_vdot lua$lua_vndot lua,
71c7ff72
TO
833 [lua_havelib=LUA$lua_vndot],
834 [AC_SEARCH_LIBS(luaL_module, lualib$lua_vndot lualib$lua_vdot lualib,
835 [lua_havelib=$lua_vndot; $LUA -l compat-5.1 2>/dev/null;
836 test "$?" = "0" && LUA_HAVE_COMPAT51=HAVE_COMPAT51],
837 [AC_SEARCH_LIBS(luaL_openlib, lualib$lua_vdot lualib$lua_vndot lualib,
838 [lua_havelib=$lua_vndot],
b4cc220b
TO
839 [COMP_LUA=], [-lm])], [-lm])], [-lm])],
840 [COMP_LUA=], [-lm])
841 lua_libs=$LIBS
842 LIBS=
843
844 # Options to pass when configuring Lua module
845 if test "$lua_havelib" != "no"; then
71c7ff72
TO
846 # OK, headers and libs found. Try to set lua flags
847 # and modules installation dirs with pkg-config
b4cc220b 848 if test "$PKGCONFIG" != "no"; then
71c7ff72 849 if test "$lua_vndot" = "50"; then
b4cc220b
TO
850 lua_pkg_prefix=lualib
851 else
852 lua_pkg_prefix=lua
853 fi
854 # try with dot, without dot and finally without version
71c7ff72
TO
855 for f in $lua_pkg_prefix$lua_vdot $lua_pkg_prefix$lua_vndot $lua_pkg_prefix; do
856 lua_exec_prefix=`$PKGCONFIG --variable=prefix $f 2>/dev/null`
857 # same binaries?
0cbdf24b 858 if test "$lua_exec_prefix/bin/lua" = "$LUA"; then
71c7ff72
TO
859 # OK, found CFLAGS. Get Lua LFLAGS and modules install dir
860 LUA_CFLAGS=`$PKGCONFIG --cflags $f 2>/dev/null`
861 LUA_LFLAGS=`$PKGCONFIG --libs $f 2>/dev/null`
862 LUA_INSTALL_CMOD=`$PKGCONFIG --variable=INSTALL_CMOD $f 2>/dev/null`
863 LUA_INSTALL_LMOD=`$PKGCONFIG --variable=INSTALL_LMOD $f 2>/dev/null`
864 break
b4cc220b
TO
865 fi
866 done
867 fi
e7d79940 868
9cda1be4 869 LUA_RRD_LIBDIR="$libdir/lua/$lua_vdot"
71c7ff72
TO
870 # if lua 5.0 can't find compat-5.1, force installation of
871 # compat-5.1.lua together with RRDtool.
872 if test "$lua_vdot" = "5.0" -a "$LUA_HAVE_COMPAT51" != "HAVE_COMPAT51"; then
0cbdf24b 873 lua_need_compat51=1
71c7ff72 874 LUA_INSTALL_LMOD="$LUA_RRD_LIBDIR"
b4cc220b 875 fi
71c7ff72
TO
876
877 # if not set with pkg-config, use default values in src packages compat-5.1, lua 5.1
878 if test "$LUA_CFLAGS" = ""; then
879 AC_MSG_WARN(Setting Lua include and lib flags to defaults in compat-5.1 and lua 5.1 sources)
880 LUA_CFLAGS="-I/usr/local/include -I/usr/local/include/lua -I/usr/local/include/lua/$lua_vdot"
881 LUA_LFLAGS="-L/usr/local/lib -L/usr/local/lib/lua -L/usr/local/lib/lua/$lua_vdot $lua_libs"
882 LUA_INSTALL_CMOD="/usr/local/lib/lua/$lua_vdot"
b4cc220b 883 fi
e7d79940 884
b4cc220b 885 dnl pass additional lua options
71c7ff72
TO
886 dnl if lua-site-install is not set, overwrite LUA_INSTALL_CMOD already
887 dnl found and install together with RRDtool, under $langpref.
b4cc220b 888 AC_ARG_ENABLE(lua-site-install,
a76b432b 889 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 890 [],
71c7ff72 891 [LUA_INSTALL_CMOD="$LUA_RRD_LIBDIR"; LUA_INSTALL_LMOD="$LUA_RRD_LIBDIR"])
b4cc220b 892
71c7ff72 893 LUA_DEFINES="-DLUA$lua_vndot -D$LUA_HAVE_COMPAT51"
b4cc220b
TO
894 AC_SUBST(LUA)
895 AC_SUBST(COMP_LUA)
b4cc220b 896 AC_SUBST(LUA_INSTALL_CMOD)
71c7ff72 897 AC_SUBST(LUA_INSTALL_LMOD)
b4cc220b
TO
898 AC_SUBST(LUA_CFLAGS)
899 AC_SUBST(LUA_LFLAGS)
71c7ff72 900 AC_SUBST(LUA_DEFINES)
b4cc220b
TO
901 else
902 enable_lua=no
903 AC_MSG_RESULT([Lua headers found but not the libraries! Please reinstall the dev packages for Lua $LUA_MAJOR.$LUA_MINOR])
904 fi
905 fi
906 fi
907fi
71c7ff72
TO
908dnl If Lua 5.0, we need compat-5.1. Add ours unless already
909dnl integrated as in Debian/Ubuntu 5.0 -dev packages.
910AM_CONDITIONAL(LUA_NEED_OUR_COMPAT51,
911 [test "$lua_vdot" = "5.0" -a "$LUA_HAVE_COMPAT51" != "HAVE_COMPAT51"])
912AM_CONDITIONAL(LUA_SITE_CINSTALL, [test "$LUA_INSTALL_CMOD" != "$LUA_RRD_LIBDIR"])
913AM_CONDITIONAL(LUA_SITE_LINSTALL, [test "$LUA_INSTALL_LMOD" != "$LUA_RRD_LIBDIR"])
914AM_CONDITIONAL(LUA50, [test "$lua_vndot" = "50"])
915AM_CONDITIONAL(BUILD_LUA, [test "$enable_lua" = "yes"])
6d14fd1d 916
cf5a9eb4
TO
917enable_tcl_site=no
918
a76b432b 919AC_ARG_ENABLE(tcl,AS_HELP_STRING([--disable-tcl],[do not build the tcl modules]),
e93d17d9 920[],[enable_tcl=yes])
965d0f77 921
e93d17d9
TO
922if test "$enable_tcl" = "yes"; then
923 dnl Check for Tcl.
924 withval=""
925 AC_ARG_WITH(tcllib,[ --with-tcllib=DIR location of the tclConfig.sh])
926 enable_tcl=no
3973781b 927 for dir in $withval /usr/lib /usr/lib64 /usr/local/lib /usr/lib/tcl8.4 /usr/lib/tcl8.3 ; do
d363449b
TO
928 AC_MSG_CHECKING(for tclConfig.sh in $dir)
929 if test -f "$dir/tclConfig.sh" ; then
930 tcl_config=$dir/tclConfig.sh
e93d17d9 931 enable_tcl=yes
37fc6638
TO
932 AC_MSG_RESULT(yes)
933 break
d363449b 934 else
37fc6638 935 AC_MSG_RESULT(no)
d363449b
TO
936 fi
937 done
37fc6638 938
e93d17d9 939 if test "$enable_tcl" = "no"; then
777e0070 940 AC_MSG_WARN([tclConfig.sh not found - Tcl interface will not be built])
e93d17d9 941 else
37fc6638 942 . $tcl_config
d363449b 943 TCL_PACKAGE_DIR="$TCL_PACKAGE_PATH/tclrrd$VERSION"
6d0ed52e
TO
944 if test -n "$TCL_INC_DIR"; then
945 TCL_INCLUDE_SPEC="$TCL_INCLUDE_SPEC -I$TCL_INC_DIR"
946 fi
e93d17d9 947 fi
fa922b40 948 AC_ARG_ENABLE(tcl-site,AS_HELP_STRING([--enable-tcl-site],[install the tcl extension in the tcl tree]),
cf5a9eb4
TO
949 [],[enable_tcl_site=yes])
950
37fc6638
TO
951fi
952
e93d17d9 953AM_CONDITIONAL(BUILD_TCL, test "$enable_tcl" = "yes" )
cf5a9eb4 954AM_CONDITIONAL(BUILD_TCL_SITE, test "$enable_tcl_site" = "yes" )
37fc6638 955
58cc8383 956
37fc6638
TO
957AC_SUBST(TCL_PREFIX)
958AC_SUBST(TCL_SHLIB_CFLAGS)
959AC_SUBST(TCL_SHLIB_LD)
960AC_SUBST(TCL_SHLIB_SUFFIX)
961AC_SUBST(TCL_PACKAGE_PATH)
962AC_SUBST(TCL_LD_SEARCH_FLAGS)
0fc6019b 963AC_SUBST(TCL_STUB_LIB_SPEC)
d363449b
TO
964AC_SUBST(TCL_VERSION)
965AC_SUBST(TCL_PACKAGE_DIR)
6d0ed52e 966AC_SUBST(TCL_INCLUDE_SPEC)
37fc6638 967
a76b432b 968AC_ARG_ENABLE(python,AS_HELP_STRING([--disable-python],[do not build the python modules]),
e93d17d9
TO
969[],[enable_python=yes])
970
971if test "$enable_python" = "yes"; then
3f437d5c 972dnl Check for python
e93d17d9
TO
973AM_PATH_PYTHON(2.3,[],[enable_python=no])
974AM_CHECK_PYTHON_HEADERS(,[enable_python=no;AC_MSG_WARN(could not find Python headers)])
975fi
37fc6638 976
7a83911d
TO
977if test x$enable_python = xno; then
978 COMP_PYTHON=
979else
980 COMP_PYTHON="python"
981fi
982
983AC_SUBST(COMP_PYTHON)
1181b81a 984AM_CONDITIONAL(BUILD_PYTHON,[test $enable_python = "yes"])
37fc6638 985
deaef079
GZ
986if test $enable_docs != no; then
987
37fc6638 988dnl Check for nroff
654651f7
TO
989AC_ARG_VAR(NROFF, [path to the local nroff version])
990AC_PATH_PROGS(NROFF, [gnroff nroff])
991if test x$NROFF = x; then
992 AC_MSG_ERROR([I need a copy of *nroff to format the documentation])
993fi
994AC_ARG_VAR(TROFF, [path to the local troff version])
995AC_PATH_PROGS(TROFF, [groff troff])
996if test x$TROFF = x; then
997 AC_MSG_ERROR([I need a copy of *troff to format the documentation])
998fi
37fc6638 999
f4b13c4e
TO
1000AC_ARG_VAR(RRDDOCDIR, [[DATADIR/doc/PACKAGE-VERSION] Documentation directory])
1001if test -z "$RRDDOCDIR"; then
1002 RRDDOCDIR='${datadir}/doc/${PACKAGE}-${VERSION}'; fi
1003
deaef079
GZ
1004fi
1005
f6537a47
WS
1006# Check for MinGW-w64 build and pass to automake
1007build_mingw_w64=no
1008AC_MSG_CHECKING([for MinGW-w64 build])
1009case "$host" in
1010 *w64-mingw32*)
1011 AC_MSG_RESULT([yes])
1012 build_mingw_w64=yes
1013 ;;
1014 *)
1015 AC_MSG_RESULT([no])
1016 ;;
1017esac
1018# Pass the conditional to automake
1019AM_CONDITIONAL([MINGW_W64], [test "$build_mingw_w64" = "yes"])
1020
134ed0d3
TO
1021# systemd check
1022PKG_PROG_PKG_CONFIG
1023AC_ARG_WITH([systemdsystemunitdir],
1024 AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files]),
1025 [], [with_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)])
1026if test "x$with_systemdsystemunitdir" != xno; then
1027 AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])
1028 AC_OUTPUT([etc/rrdcached.socket etc/rrdcached.service])
1029fi
1030AM_CONDITIONAL(HAVE_SYSTEMD, [test -n "$with_systemdsystemunitdir" -a "x$with_systemdsystemunitdir" != xno ])
1031
37fc6638 1032
b672fc87 1033CONFIGURE_PART(Apply Configuration Information)
0cbdf24b 1034
deb6b836
TO
1035AC_CONFIG_FILES([examples/shared-demo.pl])
1036AC_CONFIG_FILES([examples/piped-demo.pl])
1037AC_CONFIG_FILES([examples/stripes.pl])
1038AC_CONFIG_FILES([examples/bigtops.pl])
1039AC_CONFIG_FILES([examples/minmax.pl])
deb6b836 1040AC_CONFIG_FILES([examples/4charts.pl])
7adfdafc 1041AC_CONFIG_FILES([examples/perftest.pl])
deb6b836 1042AC_CONFIG_FILES([examples/Makefile])
873f61f9 1043AC_CONFIG_FILES([examples/rrdcached/Makefile])
4fa84a99 1044AC_CONFIG_FILES([etc/rrdcached-default-lsb])
64e74e75 1045AC_CONFIG_FILES([tests/Makefile])
deb6b836 1046AC_CONFIG_FILES([doc/Makefile])
020fde35 1047AC_CONFIG_FILES([etc/Makefile])
0cbdf24b 1048AC_CONFIG_FILES([po/Makefile.in])
deb6b836 1049AC_CONFIG_FILES([src/Makefile])
9e5b1bb7 1050AC_CONFIG_FILES([src/librrd.pc])
deb6b836
TO
1051AC_CONFIG_FILES([bindings/Makefile])
1052AC_CONFIG_FILES([bindings/tcl/Makefile])
1053AC_CONFIG_FILES([bindings/tcl/ifOctets.tcl])
125593ce 1054AC_CONFIG_FILES([bindings/lua/Makefile])
0cbdf24b 1055AC_CONFIG_FILES([Makefile])
72b4ce71 1056
398cb63e 1057AC_CONFIG_COMMANDS([default],[[ chmod +x examples/*.pl]],[[]])
bb94a87f 1058
cdab6835 1059AC_OUTPUT
37fc6638
TO
1060
1061AC_MSG_CHECKING(in)
1062AC_MSG_RESULT(and out again)
1063
eea2e745 1064echo $ECHO_N "ordering CD from https://tobi.oetiker.ch/wish $ECHO_C" 1>&6
37fc6638 1065sleep 1
cdab6835 1066echo $ECHO_N ".$ECHO_C" 1>&6
37fc6638 1067sleep 1
cdab6835 1068echo $ECHO_N ".$ECHO_C" 1>&6
37fc6638 1069sleep 1
cdab6835 1070echo $ECHO_N ".$ECHO_C" 1>&6
37fc6638 1071sleep 1
cdab6835 1072echo $ECHO_N ".$ECHO_C" 1>&6
37fc6638
TO
1073sleep 1
1074AC_MSG_RESULT([ just kidding ;-)])
1075echo
1076echo "----------------------------------------------------------------"
1077echo "Config is DONE!"
1078echo
1e48a62f 1079echo " With MMAP IO: $enable_mmap"
0033ee5d 1080echo " With Locking: $enable_flock"
52018ea3 1081echo " Build rrd_graph: $enable_rrd_graph"
91ce7bd4 1082echo " Build rrd_restore: $enable_rrd_restore"
81ff9dac 1083echo " Static programs: $staticprogs"
e93d17d9
TO
1084echo " Perl Modules: $COMP_PERL"
1085echo " Perl Binary: $PERL"
1086echo " Perl Version: $PERL_VERSION"
1087echo " Perl Options: $PERL_MAKE_OPTIONS"
6d14fd1d
TO
1088echo " Ruby Modules: $COMP_RUBY"
1089echo " Ruby Binary: $RUBY"
1090echo " Ruby Options: $RUBY_MAKE_OPTIONS"
b4cc220b 1091echo " Build Lua Bindings: $enable_lua"
71c7ff72 1092if test "$enable_lua" = "yes"; then
e7d79940 1093echo " Lua Binary: $LUA"
b4cc220b 1094echo " Lua Version: $lua_version"
71c7ff72
TO
1095echo " Lua C-modules dir: $LUA_INSTALL_CMOD"
1096if test "$lua_need_compat51" = "1"; then
1097echo " Lua Lua-modules dir: $LUA_INSTALL_LMOD"
1098fi
1099fi
020fde35 1100echo " Systemd unit dir: $with_systemdsystemunitdir"
e93d17d9
TO
1101echo " Build Tcl Bindings: $enable_tcl"
1102echo " Build Python Bindings: $enable_python"
e24e014c 1103echo " Build examples: $enable_examples"
38fb0ad1 1104echo " Build rrdcached: $enable_rrdcached"
e93d17d9
TO
1105echo " Build rrdcgi: $enable_rrdcgi"
1106echo " Build librrd MT: $enable_pthread"
c862de08 1107echo " Use gettext: $USE_NLS"
311f41ad 1108echo " With libDBI: $have_libdbi"
e0ec619b 1109echo " With librados: $have_librados"
2740ecc9 1110echo " With libwrap: $have_libwrap"
134ed0d3 1111echo " With systemd dir: $with_systemdsystemunitdir"
e3f3fc54 1112echo
58cc8383 1113echo " Libraries: $ALL_LIBS"
f37148b1 1114echo
37fc6638
TO
1115echo "Type 'make' to compile the software and use 'make install' to "
1116echo "install everything to: $prefix."
020fde35
TO
1117if test "x$with_systemdsystemunitdir" != xno; then
1118echo
1119echo "Type 'make etc-install' to install systemd support for rrdcached"
1120fi
0cbdf24b 1121echo
37fc6638 1122echo " ... that wishlist is NO JOKE. If you find RRDtool useful"
eea2e745 1123echo "make me happy. Go to https://tobi.oetiker.ch/wish and"
37fc6638 1124echo "place an order."
0cbdf24b 1125echo
37fc6638
TO
1126echo " -- Tobi Oetiker <tobi@oetiker.ch>"
1127echo "----------------------------------------------------------------"