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(src/rrd_tool.c)
10 AC_CONFIG_AUX_DIR(config)
11 AC_CANONICAL_TARGET([])
12 AM_INIT_AUTOMAKE(rrdtool, 1.1.0)
13 AM_CONFIG_HEADER(config/config.h)
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 */
139 dnl Define library subdirectory names here.
140 CGI_LIB_DIR=cgilib-0.4
141 FREETYPE_LIB_DIR=freetype-2.0.5
142 ART_LIB_DIR=libart_lgpl-2.3.7
143 PNG_LIB_DIR=libpng-1.2.0
144 ZLIB_LIB_DIR=zlib-1.1.4
146 dnl substitute them in all the files listed in AC_OUTPUT
147 AC_SUBST(CGI_LIB_DIR)
148 AC_SUBST(ART_LIB_DIR)
149 AC_SUBST(PNG_LIB_DIR)
150 AC_SUBST(FREETYPE_LIB_DIR)
151 AC_SUBST(ZLIB_LIB_DIR)
154 INCLUDED_LIB(cgi,cgiInit)
155 INCLUDED_LIB(art_lgpl,art_vpath_add_point)
156 INCLUDED_LIB(png,png_access_version_number)
157 INCLUDED_LIB(freetype,FT_Init_FreeType)
158 INCLUDED_LIB(z,zlibVersion)
161 AC_PATH_PROG(PERL, perl, no)
162 if test "x$PERL" = "xno"; then
165 COMP_PERL="perl_piped perl_shared"
166 AC_MSG_CHECKING(for shared library extension)
167 SO_EXT=`$PERL -e 'use Config; if (defined $Config{so} and $Config{so} ne 'a') {print "$Config{so}\n"} else {print "so\n"};'`
168 AC_MSG_RESULT($SO_EXT)
169 AC_MSG_CHECKING(for the C compiler perl wants to use to build its modules)
170 PROBLEMCC=`$PERL -e 'use Config; map {if (-x "$_/$Config{cc}"){exit 0}} split /:/, $ENV{PATH};print $Config{cc}'`
171 if test x$PROBLEMCC != x; then
173 echo Could not find the Compiler: '"'$PROBLEMCC'"'
174 echo which has been used to build perl. You may have to compile
175 echo your own copy of perl to make this work. Binary perls often
176 echo exhibit this problem
187 AC_ARG_WITH(tcllib,[ --with-tcllib=DIR location of the tclConfig.sh])
189 AC_MSG_CHECKING(for tclConfig.sh in $withval)
190 if test -f "$withval/tclConfig.sh" ; then
191 tcl_config=$withval/tclConfig.sh
199 if test $found -eq 0 ; then
200 AC_MSG_WARN([tclConfig.sh not found - Tcl interface won't be built])
205 dnl Pass additional perl options when generating Makefile from Makefile.PL
206 # Options to pass when configuring perl module
207 AC_ARG_WITH(perl-options,
208 [ --with-perl-options=[OPTIONS] options to pass on command-line when
209 generating Makefile from Makefile.PL],
210 [PERL_MAKE_OPTIONS=$withval])
211 AC_SUBST(PERL_MAKE_OPTIONS)
213 AM_CONDITIONAL(COMP_TCL, test x$found = x1 )
216 AC_SUBST(TCL_SHLIB_CFLAGS)
217 AC_SUBST(TCL_SHLIB_LD)
218 AC_SUBST(TCL_SHLIB_SUFFIX)
219 AC_SUBST(TCL_PACKAGE_PATH)
220 AC_SUBST(TCL_LD_SEARCH_FLAGS)
222 dnl Check for the compiler and static/shared library creation.
226 dnl don't build a shared library ...
227 dnl this can be changed when running configure
231 dnl Checks for header files.
233 AC_CHECK_HEADERS(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)
235 dnl Checks for typedefs, structures, and compiler characteristics.
240 dnl Checks for libraries.
241 AC_CHECK_FUNC(acos, , AC_CHECK_LIB(m, acos))
244 AC_PATH_PROGS(NROFF, gnroff nroff)
245 AC_PATH_PROGS(TROFF, groff troff)
247 dnl Does the compiler like -Wall and -pedantic?
248 if test "x$GCC" = "xyes"; then
250 CFLAGS="$CFLAGS -Wall -pedantic -Wshadow -Wpointer-arith -Wcast-align -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline"
251 AC_CACHE_CHECK(if we can use GCC-specific compiler options, rd_cv_gcc_opt,
252 [AC_TRY_COMPILE( , return 0 ,
257 if test $rd_cv_gcc_opt = no; then
262 dnl add pic flag in any case this makes sure all our code is relocatable
263 CFLAGS="$CFLAGS "`grep pic_flag= libtool | sed -e 's/.*pic_flag=//' -e 's/"//g'`
266 dnl it seems that hpux chockes on -fPIC for some reason
269 ZLIB_CFLAGS=`echo $CFLAGS|sed -e 's/-fPIC/-fpic/g'`
272 AC_SUBST(ZLIB_CFLAGS)
274 dnl Checks for library functions.
278 dnl for each function found we get a definition in config.h
279 dnl of the form HAVE_FUNCTION
281 AC_CHECK_FUNCS(tzset setlocale strerror snprintf vsnprintf fpclass class fp_class isnan memmove strchr mktime getrusage gettimeofday)
283 dnl HP-UX 11.00 does not have finite but does have isfinite as a macro
284 AC_CHECK_FUNCS(fpclassify, ,
285 [AC_MSG_CHECKING(for fpclassify with <math.h>)
286 AC_TRY_LINK([#include <math.h>], [float f = 0.0; fpclassify(f)],
288 AC_DEFINE(HAVE_FPCLASSIFY), AC_MSG_RESULT(no))])
289 AC_CHECK_FUNCS(finite, ,
290 [AC_CHECK_FUNCS(isfinite, ,
291 [AC_MSG_CHECKING(for isfinite with <math.h>)
292 AC_TRY_LINK([#include <math.h>], [float f = 0.0; isfinite(f)],
294 AC_DEFINE(HAVE_ISFINITE), AC_MSG_RESULT(no))])])
295 AC_CHECK_FUNCS(isinf, ,
296 [AC_MSG_CHECKING(for isinf with <math.h>)
297 AC_TRY_LINK([#include <math.h>], [float f = 0.0; isinf(f)],
299 AC_DEFINE(HAVE_ISINF), AC_MSG_RESULT(no))])
301 dnl what does realloc do if it gets called with a NULL pointer
303 AC_CACHE_CHECK([if realloc can deal with NULL], rd_cv_null_realloc,
304 [AC_TRY_RUN([#include <stdlib.h>
308 if (x==NULL) return 1;
311 [rd_cv_null_realloc=yes],[rd_cv_null_realloc=nope],:)])
313 if test x"$rd_cv_null_realloc" = xnope; then
314 AC_DEFINE(NO_NULL_REALLOC)
317 dnl determine how to get IEEE math working
318 dnl AC_IEEE(MESSAGE, set rd_cv_ieee_[var] variable, INCLUDES,
319 dnl FUNCTION-BODY, [ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]])
324 AC_MSG_CHECKING([if IEEE math works $1])
325 AC_CACHE_VAL([rd_cv_ieee_$2],
341 # include <fp_class.h>
345 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASS))
346 # define HAVE_ISINF 1
347 # define isinf(a) (fpclass(a) == FP_NINF || fpclass(a) == FP_PINF)
351 #if (! defined(HAVE_ISINF) && defined(HAVE_FP_CLASS) && defined(HAVE_FP_CLASS_H))
352 # define HAVE_ISINF 1
353 # define isinf(a) (fp_class(a) == FP_NEG_INF || fp_class(a) == FP_POS_INF)
357 #if (! defined(HAVE_ISINF) && defined(HAVE_CLASS))
358 # define HAVE_ISINF 1
359 # define isinf(a) (class(a) == FP_MINUS_INF || class(a) == FP_PLUS_INF)
362 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_PLUS_INF) && defined(FP_MINUS_INF))
363 # define HAVE_ISINF 1
364 # define isinf(a) (fpclassify(a) == FP_MINUS_INF || fpclassify(a) == FP_PLUS_INF)
367 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_INFINITE))
368 # define HAVE_ISINF 1
369 # define isinf(a) (fpclassify(a) == FP_INFINITE)
374 double nan,inf,c,zero;
376 /* some math to see if we get a floating point exception */
377 zero=sin(0.0); /* don't let the compiler optimize us away */
378 nan=0.0/zero; /* especially here */
379 inf=1.0/zero; /* and here. I want to know if it can do the magic */
380 /* at run time without sig fpe */
383 if (! isnan(nan)) {printf ("not isnan(NaN) ... "); return 1;}
384 if (nan == nan) {printf ("nan == nan ... "); return 1;}
385 if (! isinf(inf)) {printf ("not isinf(oo) ... "); return 1;}
386 if (! isinf(-inf)) {printf ("not isinf(-oo) ... "); return 1;}
387 if (! inf > 0) {printf ("not inf > 0 ... "); return 1;}
388 if (! -inf < 0) {printf ("not -inf < 0 ... "); return 1;}
395 dnl these we run regardles is cached or not
396 if test x${rd_cv_ieee_$2} = "xyes"; then
407 AC_IEEE([out of the box], works, , , ,
408 [CFLAGS="$_cflags -ieee"
409 AC_IEEE([with the -ieee switch], switch, , , ,
410 [CFLAGS="$_cflags -qfloat=nofold"
411 AC_IEEE([with the -qfloat=nofold switch], nofold, , , ,
412 [CFLAGS="$_cflags -w -qflttrap=enable:zerodivide"
413 AC_IEEE([with the -w -qflttrap=enable:zerodivide], flttrap, , , ,
414 [CFLAGS="$_cflags -mieee"
415 AC_IEEE([with the -mieee switch], mswitch, , , ,
416 [CFLAGS="$_cflags -q float=rndsngl"
417 AC_IEEE([with the -q float=rndsngl switch], qswitch, , , ,
418 [CFLAGS="$_cflags -OPT:IEEE_comparisons=ON"
419 AC_IEEE([with the -OPT:IEEE_comparisons=ON switch], ieeecmpswitch, , , ,
421 AC_IEEE([with fpsetmask(0)], mask,
422 [#include <floatingpoint.h>], [fpsetmask(0)],
423 [AC_DEFINE(MUST_DISABLE_FPMASK)
424 PERLFLAGS="CCFLAGS=-DMUST_DISABLE_FPMASK"],
425 [AC_IEEE([with signal(SIGFPE,SIG_IGN)], sigfpe,
426 [#include <signal.h>], [signal(SIGFPE,SIG_IGN)],
427 [AC_DEFINE(MUST_DISABLE_SIGFPE)
428 PERLFLAGS="CCFLAGS=-DMUST_DISABLE_SIGFPE"],
430 Your Compiler does not do propper IEEE math ... Please find out how to
431 make IEEE math work with your compiler and let me know (oetiker@ee.ethz.ch).
432 Check config.log to see what went wrong ...
436 AC_CONFIG_FILES([examples/shared-demo.pl \
437 examples/piped-demo.pl \
438 examples/stripes.pl \
439 examples/bigtops.pl \
441 examples/cgi-demo.cgi \
445 libraries/cgilib-0.4/Makefile \
446 libraries/libart_lgpl-2.3.7/Makefile \
447 libraries/libpng-1.2.0/Makefile \
448 libraries/zlib-1.1.4/Makefile \
449 libraries/freetype-2.0.5/Makefile \
450 libraries/afm/Makefile \
453 bindings/tcl/Makefile \
455 AC_CONFIG_COMMANDS([default],[[\
456 chmod +x examples/*.cgi examples/*.pl]],[[]])
460 AC_MSG_RESULT(and out again)
462 echo $ECHO_N "ordering CD from http://people.ee.ethz.ch/~oetiker/wish $ECHO_C" 1>&6
464 echo $ECHO_N ".$ECHO_C" 1>&6
466 echo $ECHO_N ".$ECHO_C" 1>&6
468 echo $ECHO_N ".$ECHO_C" 1>&6
470 echo $ECHO_N ".$ECHO_C" 1>&6
472 AC_MSG_RESULT([ just kidding ;-)])
474 echo "----------------------------------------------------------------"
475 echo "Config is DONE!"
477 echo "Type 'make' to compile the software and use 'make install' to "
478 echo "install everything to: $prefix."
480 echo "If you want to install the perl"
481 echo "modules in site-perl, try 'make site-perl-install'."
483 echo " ... that wishlist is NO JOKE. If you find RRDtool useful"
484 echo "make me happy. Go to http://people.ee.ethz.ch/~oetiker/wish and"
485 echo "place an order."
487 echo " -- Tobi Oetiker <tobi@oetiker.ch>"
488 echo "----------------------------------------------------------------"