1 dnl RRDtool AutoConf script ...
2 dnl ---------------------------
4 dnl Created by Jeff Allen, Tobi Oetiker, Blair Zajac
8 dnl tell automake the this script is for rrdtool
9 AC_INIT([rrdtool],[1.1.0])
12 AM_CONFIG_HEADER(config.h)
13 # AC_CONFIG_AUX_DIR(config)
15 dnl all our local stuff like install scripts and include files
19 dnl determine the type of system we are running on
24 dnl where we install our stuff ...
25 AC_PREFIX_DEFAULT( /usr/local/rrdtool-1.1.0 )
27 dnl Minimum Autoconf version required.
30 dnl At the TOP of the HEADER
36 /* IEEE can be prevented from raising signals with fpsetmask(0) */
37 #undef MUST_DISABLE_FPMASK
39 /* IEEE math only works if SIGFPE gets actively set to IGNORE */
41 #undef MUST_DISABLE_SIGFPE
43 /* realloc does not support NULL as argument */
44 #undef NO_NULL_REALLOC
49 /* define strrchr, strchr and memcpy, memmove in terms of bsd funcs
50 make sure you are NOT using bcopy, index or rindex in the code */
57 # define strrchr rindex
59 char *strchr (), *strrchr ();
61 # define memcpy(d, s, n) bcopy ((s), (d), (n))
62 # define memmove(d, s, n) bcopy ((s), (d), (n))
68 # define rrd_realloc(a,b) ( (a) == NULL ? malloc( (b) ) : realloc( (a) , (b) ))
70 # define rrd_realloc(a,b) realloc((a), (b))
86 # include <fp_class.h>
90 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASS))
92 # define isinf(a) (fpclass(a) == FP_NINF || fpclass(a) == FP_PINF)
95 /* for OSF1 Digital Unix */
96 #if (! defined(HAVE_ISINF) && defined(HAVE_FP_CLASS) && defined(HAVE_FP_CLASS_H))
98 # define isinf(a) (fp_class(a) == FP_NEG_INF || fp_class(a) == FP_POS_INF)
101 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_PLUS_INF) && defined(FP_MINUS_INF))
102 # define HAVE_ISINF 1
103 # define isinf(a) (fpclassify(a) == FP_MINUS_INF || fpclassify(a) == FP_PLUS_INF)
106 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_INFINITE))
107 # define HAVE_ISINF 1
108 # define isinf(a) (fpclassify(a) == FP_INFINITE)
112 #if (! defined(HAVE_ISINF) && defined(HAVE_CLASS))
113 # define HAVE_ISINF 1
114 # define isinf(a) (class(a) == FP_MINUS_INF || class(a) == FP_PLUS_INF)
117 #if (! defined (HAVE_FINITE) && defined (HAVE_ISFINITE))
118 # define HAVE_FINITE 1
119 # define finite(a) isfinite(a)
122 #if (! defined(HAVE_FINITE) && defined(HAVE_ISNAN) && defined(HAVE_ISINF))
123 # define HAVE_FINITE 1
124 # define finite(a) (! isnan(a) && ! isinf(a))
128 #error "Can't compile without finite function"
132 #error "Can't compile without isinf function"
135 #endif /* CONFIG_H */
140 dnl Check for the compiler and static/shared library creation.
145 dnl Checks for header files.
148 AC_CHECK_HEADERS(sys/stat.h sys/types.h fcntl.h time.h locale.h fp_class.h malloc.h unistd.h ieeefp.h math.h sys/time.h sys/times.h sys/param.h sys/resource.h float.h)
150 dnl Checks for typedefs, structures, and compiler characteristics.
155 dnl substitute them in all the files listed in AC_OUTPUT
158 dnl Checks for libraries.
159 AC_CHECK_FUNC(acos, , AC_CHECK_LIB(m, acos))
161 AC_DEFUN([EX_CHECK_ALL],
162 [ AC_CHECK_LIB($1,$2,
163 [ AC_CHECK_HEADER($3,[LIBS="-l$1 ${LIBS}"],[
164 [ $echo "#include <$3>" | $CC -E - > /dev/null ]
165 AC_MSG_ERROR([Adjust CPPFLAGS so that the $4 header $3 AND its dependencies gets found])
168 ############################################################################
169 I could not find a working copy of $4. Check config.log for hints on why
170 this is the case. Maybe you need to set LDFLAGS appropriately so that the
171 linker can find lib$1. If you have not installed $4, you can get it
172 either from its original home on
176 Or you can find an archive copy on
178 http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/pub/libs
180 The last tested version of $4 is $5.
181 ############################################################################
186 dnl How the vertical axis label is printed
187 AC_ARG_VAR(RRDGRAPH_YLEGEND_ANGLE,
188 [Vertical label angle: 90.0 (default) or 270.0])
189 AC_DEFINE_UNQUOTED(RRDGRAPH_YLEGEND_ANGLE,${RRDGRAPH_YLEGEND_ANGLE:-90.0},
190 [Vertical label angle: 90.0 (default) or 270.0])
193 AC_ARG_ENABLE(rrdcgi,[ --disable-rrdcgi disable building of rrdcgi],
194 [],[enable_rrdcgi=yes])
195 AM_CONDITIONAL(BUILD_RRDCGI,[test $enable_rrdcgi != no])
197 if test $enable_rrdcgi != no; then
198 EX_CHECK_ALL(cgi, cgiInit, cgi.h, cgilib, 0.5, http://www.infodrom.org/projects/cgilib)
200 EX_CHECK_ALL(art_lgpl_2, art_vpath_add_point, libart_lgpl/libart.h, libart_lgpl, 2.3.16, ftp://ftp.gnome.org/pub/GNOME/sources/libart_lgpl/2.3/)
201 EX_CHECK_ALL(z, zlibVersion, zlib.h, zlib, 1.2.1, http://www.gzip.org/zlib/)
202 EX_CHECK_ALL(png, png_access_version_number, png.h, libpng, 1.2.5, http://prdownloads.sourceforge.net/libpng/)
203 EX_CHECK_ALL(freetype, FT_Init_FreeType, ft2build.h, freetype, 2.1.5, http://prdownloads.sourceforge.net/freetype/)
205 dnl Check for pthreads (pieces of code from Bert Driehuis)
207 AC_SUBST(MULTITHREAD_CFLAGS)
208 AC_SUBST(MULTITHREAD_LDFLAGS)
210 AC_DEFUN(AC_CHECK_PTHREAD, [
211 AC_MSG_CHECKING([pthreads: trying no flags])
212 AC_CACHE_VAL(ac_cv_flag_pthread,[
217 eval "ac_cv_flag_pthread=no",
219 AC_MSG_RESULT([didn't work])
220 AC_MSG_CHECKING([pthreads: trying to add -pthread])
221 ac_save_CFLAGS="$CFLAGS"
222 CFLAGS="$CFLAGS -pthread"
227 eval "ac_cv_flag_pthread=yes",
228 AC_MSG_ERROR([Can't figure out pthreads])
230 CFLAGS="$ac_save_CFLAGS"
234 if test "$ac_cv_flag_pthread" = "no"; then
235 AC_MSG_RESULT([good, -pthread flag not necessary])
237 AC_MSG_RESULT([adding -pthread flag])
238 MULTITHREAD_CFLAGS="-pthread"
241 AC_MSG_CHECKING([for libpthread])
242 AC_CACHE_VAL(ac_cv_lib_pthread,[
249 eval "ac_cv_lib_pthread=-lphtread",
250 eval "ac_cv_lib_pthread=no"
254 if test "$ac_cv_lib_pthread" = "no"; then
255 AC_MSG_RESULT([no -lpthread necessary])
257 AC_MSG_RESULT([adding -lpthread to LIBS])
258 MULTITHREAD_LDFLAGS="-lpthread"
262 AC_ARG_ENABLE(pthread,[ --disable-pthread disable multithread support],
263 [],[enable_pthread=yes])
265 if test $enable_pthread != no; then
269 AM_CONDITIONAL(BUILD_MULTITHREAD,[test $enable_pthread != no])
272 AC_PATH_PROG(PERL, perl, no)
273 if test "x$PERL" = "xno"; then
276 COMP_PERL="perl_piped perl_shared"
277 AC_MSG_CHECKING(for shared library extension)
278 SO_EXT=`$PERL -e 'use Config; if (defined $Config{so} and $Config{so} ne 'a') {print "$Config{so}\n"} else {print "so\n"};'`
279 AC_MSG_RESULT($SO_EXT)
280 AC_MSG_CHECKING(for the C compiler perl wants to use to build its modules)
281 PROBLEMCC=`$PERL -e 'use Config; ($cc = $Config{cc}) =~ s/\s.*//; exit 0 if -x $cc; map {if (-x "$_/$cc"){exit 0}} split /:/, $ENV{PATH};print $Config{cc}'`
282 if test x$PROBLEMCC != x; then
284 echo Could not find the Compiler: '"'$PROBLEMCC'"'
285 echo which has been used to build perl. You may have to compile
286 echo your own copy of perl to make this work. Binary perls often
287 echo exhibit this problem
298 AC_ARG_WITH(tcllib,[ --with-tcllib=DIR location of the tclConfig.sh])
300 AC_MSG_CHECKING(for tclConfig.sh in $withval)
301 if test -f "$withval/tclConfig.sh" ; then
302 tcl_config=$withval/tclConfig.sh
310 if test $found -eq 0 ; then
311 AC_MSG_WARN([tclConfig.sh not found - Tcl interface won't be built])
316 dnl Pass additional perl options when generating Makefile from Makefile.PL
317 # Options to pass when configuring perl module
318 AC_ARG_WITH(perl-options,
319 [ --with-perl-options=[OPTIONS] options to pass on command-line when
320 generating Makefile from Makefile.PL],
321 [PERL_MAKE_OPTIONS=$withval])
322 AC_SUBST(PERL_MAKE_OPTIONS)
324 AM_CONDITIONAL(COMP_TCL, test x$found = x1 )
327 AC_SUBST(TCL_SHLIB_CFLAGS)
328 AC_SUBST(TCL_SHLIB_LD)
329 AC_SUBST(TCL_SHLIB_SUFFIX)
330 AC_SUBST(TCL_PACKAGE_PATH)
331 AC_SUBST(TCL_LD_SEARCH_FLAGS)
336 AC_PATH_PROGS(NROFF, gnroff nroff)
337 AC_PATH_PROGS(TROFF, groff troff)
339 dnl Does the compiler like -Wall and -pedantic?
340 if test "x$GCC" = "xyes"; then
342 CFLAGS="$CFLAGS -Wall -pedantic -Wshadow -Wpointer-arith -Wcast-align -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -W"
343 AC_CACHE_CHECK(if we can use GCC-specific compiler options, rd_cv_gcc_opt,
344 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[return 0 ]])],[rd_cv_gcc_opt=yes],[rd_cv_gcc_opt=no ])
347 if test $rd_cv_gcc_opt = no; then
352 dnl add pic flag in any case this makes sure all our code is relocatable
353 CFLAGS="$CFLAGS "`grep pic_flag= libtool | head -1|sed -e 's/.*pic_flag=//' -e 's/"//g'`
356 dnl it seems that hpux chockes on -fPIC for some reason
359 ZLIB_CFLAGS=`echo $CFLAGS|sed -e 's/-fPIC/-fpic/g'`
362 AC_SUBST(ZLIB_CFLAGS)
364 dnl Checks for library functions.
368 dnl for each function found we get a definition in config.h
369 dnl of the form HAVE_FUNCTION
371 AC_CHECK_FUNCS(tzset opendir readdir chdir chroot getuid setlocale strerror strerror_r snprintf vsnprintf fpclass class fp_class isnan memmove strchr mktime getrusage gettimeofday)
373 dnl HP-UX 11.00 does not have finite but does have isfinite as a macro
374 AC_CHECK_FUNCS(fpclassify, ,
375 [AC_MSG_CHECKING(for fpclassify with <math.h>)
376 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]], [[float f = 0.0; fpclassify(f)]])],[AC_MSG_RESULT(yes)
377 AC_DEFINE(HAVE_FPCLASSIFY)],[AC_MSG_RESULT(no)])])
378 AC_CHECK_FUNCS(finite, ,
379 [AC_CHECK_FUNCS(isfinite, ,
380 [AC_MSG_CHECKING(for isfinite with <math.h>)
381 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]], [[float f = 0.0; isfinite(f)]])],[AC_MSG_RESULT(yes)
382 AC_DEFINE(HAVE_ISFINITE)],[AC_MSG_RESULT(no)])])])
383 AC_CHECK_FUNCS(isinf, ,
384 [AC_MSG_CHECKING(for isinf with <math.h>)
385 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]], [[float f = 0.0; isinf(f)]])],[AC_MSG_RESULT(yes)
386 AC_DEFINE(HAVE_ISINF)],[AC_MSG_RESULT(no)])])
388 dnl what does realloc do if it gets called with a NULL pointer
390 AC_CACHE_CHECK([if realloc can deal with NULL], rd_cv_null_realloc,
391 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
395 if (x==NULL) return 1;
397 }]])],[rd_cv_null_realloc=yes],[rd_cv_null_realloc=nope],[:])])
399 if test x"$rd_cv_null_realloc" = xnope; then
400 AC_DEFINE(NO_NULL_REALLOC)
403 dnl determine how to get IEEE math working
404 dnl AC_IEEE(MESSAGE, set rd_cv_ieee_[var] variable, INCLUDES,
405 dnl FUNCTION-BODY, [ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]])
410 AC_MSG_CHECKING([if IEEE math works $1])
411 AC_CACHE_VAL([rd_cv_ieee_$2],
412 [AC_RUN_IFELSE([AC_LANG_SOURCE([[$3
427 # include <fp_class.h>
431 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASS))
432 # define HAVE_ISINF 1
433 # define isinf(a) (fpclass(a) == FP_NINF || fpclass(a) == FP_PINF)
437 #if (! defined(HAVE_ISINF) && defined(HAVE_FP_CLASS) && defined(HAVE_FP_CLASS_H))
438 # define HAVE_ISINF 1
439 # define isinf(a) (fp_class(a) == FP_NEG_INF || fp_class(a) == FP_POS_INF)
443 #if (! defined(HAVE_ISINF) && defined(HAVE_CLASS))
444 # define HAVE_ISINF 1
445 # define isinf(a) (class(a) == FP_MINUS_INF || class(a) == FP_PLUS_INF)
448 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_PLUS_INF) && defined(FP_MINUS_INF))
449 # define HAVE_ISINF 1
450 # define isinf(a) (fpclassify(a) == FP_MINUS_INF || fpclassify(a) == FP_PLUS_INF)
453 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_INFINITE))
454 # define HAVE_ISINF 1
455 # define isinf(a) (fpclassify(a) == FP_INFINITE)
460 double nan,inf,c,zero;
462 /* some math to see if we get a floating point exception */
463 zero=sin(0.0); /* don't let the compiler optimize us away */
464 nan=0.0/zero; /* especially here */
465 inf=1.0/zero; /* and here. I want to know if it can do the magic */
466 /* at run time without sig fpe */
469 if (! isnan(nan)) {printf ("not isnan(NaN) ... "); return 1;}
470 if (nan == nan) {printf ("nan == nan ... "); return 1;}
471 if (! isinf(inf)) {printf ("not isinf(oo) ... "); return 1;}
472 if (! isinf(-inf)) {printf ("not isinf(-oo) ... "); return 1;}
473 if (! inf > 0) {printf ("not inf > 0 ... "); return 1;}
474 if (! -inf < 0) {printf ("not -inf < 0 ... "); return 1;}
476 }]])],[rd_cv_ieee_$2=yes],[rd_cv_ieee_$2=no],[:])])
477 dnl these we run regardles is cached or not
478 if test x${rd_cv_ieee_$2} = "xyes"; then
489 AC_IEEE([out of the box], works, , , ,
490 [CFLAGS="$_cflags -ieee"
491 AC_IEEE([with the -ieee switch], switch, , , ,
492 [CFLAGS="$_cflags -qfloat=nofold"
493 AC_IEEE([with the -qfloat=nofold switch], nofold, , , ,
494 [CFLAGS="$_cflags -w -qflttrap=enable:zerodivide"
495 AC_IEEE([with the -w -qflttrap=enable:zerodivide], flttrap, , , ,
496 [CFLAGS="$_cflags -mieee"
497 AC_IEEE([with the -mieee switch], mswitch, , , ,
498 [CFLAGS="$_cflags -q float=rndsngl"
499 AC_IEEE([with the -q float=rndsngl switch], qswitch, , , ,
500 [CFLAGS="$_cflags -OPT:IEEE_NaN_inf=ON"
501 AC_IEEE([with the -OPT:IEEE_NaN_inf=ON switch], ieeenaninfswitch, , , ,
502 [CFLAGS="$_cflags -OPT:IEEE_comparisons=ON"
503 AC_IEEE([with the -OPT:IEEE_comparisons=ON switch], ieeecmpswitch, , , ,
505 AC_IEEE([with fpsetmask(0)], mask,
506 [#include <floatingpoint.h>], [fpsetmask(0)],
507 [AC_DEFINE(MUST_DISABLE_FPMASK)
508 PERLFLAGS="CCFLAGS=-DMUST_DISABLE_FPMASK"],
509 [AC_IEEE([with signal(SIGFPE,SIG_IGN)], sigfpe,
510 [#include <signal.h>], [signal(SIGFPE,SIG_IGN)],
511 [AC_DEFINE(MUST_DISABLE_SIGFPE)
512 PERLFLAGS="CCFLAGS=-DMUST_DISABLE_SIGFPE"],
514 Your Compiler does not do propper IEEE math ... Please find out how to
515 make IEEE math work with your compiler and let me know (oetiker@ee.ethz.ch).
516 Check config.log to see what went wrong ...
517 ]))])])])])])])])])])
520 AC_CONFIG_FILES([examples/shared-demo.pl \
521 examples/piped-demo.pl \
522 examples/stripes.pl \
523 examples/bigtops.pl \
525 examples/cgi-demo.cgi \
530 bindings/tcl/Makefile \
532 AC_CONFIG_COMMANDS([default],[[\
533 chmod +x examples/*.cgi examples/*.pl]],[[]])
537 AC_MSG_RESULT(and out again)
539 echo $ECHO_N "ordering CD from http://people.ee.ethz.ch/~oetiker/wish $ECHO_C" 1>&6
541 echo $ECHO_N ".$ECHO_C" 1>&6
543 echo $ECHO_N ".$ECHO_C" 1>&6
545 echo $ECHO_N ".$ECHO_C" 1>&6
547 echo $ECHO_N ".$ECHO_C" 1>&6
549 AC_MSG_RESULT([ just kidding ;-)])
551 echo "----------------------------------------------------------------"
552 echo "Config is DONE!"
554 echo "Type 'make' to compile the software and use 'make install' to "
555 echo "install everything to: $prefix."
557 echo "If you want to install the perl"
558 echo "modules in site-perl, try 'make site-perl-install'."
560 echo " ... that wishlist is NO JOKE. If you find RRDtool useful"
561 echo "make me happy. Go to http://people.ee.ethz.ch/~oetiker/wish and"
562 echo "place an order."
564 echo " -- Tobi Oetiker <tobi@oetiker.ch>"
565 echo "----------------------------------------------------------------"