1 dnl RRDtool AutoConf script ...
2 dnl ---------------------------
4 dnl Created by Jeff Allen, Tobi Oetiker, Blair Zajac
8 dnl make sure we are being executed in the right place
9 AC_INIT(src/rrd_tool.c)
11 dnl all our local stuff like install scripts and include files
13 AC_CONFIG_AUX_DIR(config)
15 dnl determine the type of system we are running on
18 dnl tell automake the this script is for rrdtool
19 AM_INIT_AUTOMAKE(rrdtool, 1.0.33)
22 dnl where we install our stuff ...
23 AC_PREFIX_DEFAULT( /usr/local/rrdtool-1.0.33 )
25 dnl tell automake which file to use as config header
26 AM_CONFIG_HEADER(config/config.h)
28 dnl Minimum Autoconf version required.
31 dnl Define library subdirectory names here.
32 CGI_LIB_DIR=libraries/cgilib-0.4
33 GD_LIB_DIR=libraries/gd1.3
34 PNG_LIB_DIR=libraries/libpng-1.0.9
35 ZLIB_LIB_DIR=libraries/zlib-1.1.3
37 dnl substitute them in all the files listed in AC_OUTPUT
41 AC_SUBST(ZLIB_LIB_DIR)
45 AC_PATH_PROG(PERL, perl, no)
46 if test "x$PERL" = "xno"; then
49 COMP_PERL="perl_piped perl_shared"
50 AC_MSG_CHECKING(for shared library extension)
51 SO_EXT=`$PERL -e 'use Config; if (defined $Config{so} and $Config{so} ne 'a') {print "$Config{so}\n"} else {print "so\n"};'`
52 AC_MSG_RESULT($SO_EXT)
59 AC_ARG_WITH(tcllib,[ --with-tcllib=DIR location of the tclConfig.sh])
61 AC_MSG_CHECKING(for tclConfig.sh in $withval)
62 if test -f "$withval/tclConfig.sh" ; then
63 tcl_config=$withval/tclConfig.sh
71 if test $found -eq 0 ; then
72 AC_MSG_WARN([tclConfig.sh not found - Tcl interface won't be built])
77 dnl Pass additional perl options when generating Makefile from Makefile.PL
78 # Options to pass when configuring perl module
79 AC_ARG_WITH(perl-options,
80 [ --with-perl-options=[OPTIONS] options to pass on command-line when
81 generating Makefile from Makefile.PL],
82 [PERL_MAKE_OPTIONS=$withval])
83 AC_SUBST(PERL_MAKE_OPTIONS)
85 AM_CONDITIONAL(COMP_TCL, test x$found = x1 )
88 AC_SUBST(TCL_SHLIB_CFLAGS)
89 AC_SUBST(TCL_SHLIB_LD)
90 AC_SUBST(TCL_SHLIB_SUFFIX)
91 AC_SUBST(TCL_PACKAGE_PATH)
92 AC_SUBST(TCL_LD_SEARCH_FLAGS)
94 dnl Check for the compiler and static/shared library creation.
97 dnl RRD_ACLOCAL_FIND_LIBTOOL
99 dnl don't build a shared library ...
100 dnl this can be changed when running configure
105 dnl Checks for header files.
107 AC_CHECK_HEADERS(fcntl.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)
109 dnl Checks for typedefs, structures, and compiler characteristics.
114 dnl Checks for libraries.
115 AC_CHECK_FUNC(acos, , AC_CHECK_LIB(m, acos))
118 AC_PATH_PROGS(NROFF, gnroff nroff)
119 AC_PATH_PROGS(TROFF, groff troff)
121 dnl Does the compiler like -Wall and -pedantic?
122 if test "x$GCC" = "xyes"; then
124 CFLAGS="$CFLAGS -Wall -pedantic -Wshadow -Wpointer-arith -Wcast-align -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline"
125 AC_CACHE_CHECK(if we can use GCC-specific compiler options, rd_cv_gcc_opt,
126 [AC_TRY_COMPILE( , return 0 ,
131 if test $rd_cv_gcc_opt = no; then
136 dnl add pic flag in any case this makes sure all our code is relocatable
137 CFLAGS="$CFLAGS "`grep pic_flag= libtool | sed -e 's/.*pic_flag=//' -e 's/"//g'`
139 dnl it seems that hpux chockes on -fPIC for some reason
142 CLFAGS=`echo $CFLAGS|sed -e 's/-fPIC/-fpic/g'`
146 dnl Checks for library functions.
150 dnl for each function found we get a definition in config.h
151 dnl of the form HAVE_FUNCTION
153 AC_CHECK_FUNCS(strerror snprintf vsnprintf fpclass class fp_class isnan memmove strchr mktime getrusage gettimeofday)
155 dnl HP-UX 11.00 does not have finite but does have isfinite as a macro
156 AC_CHECK_FUNCS(fpclassify, ,
157 [AC_MSG_CHECKING(for fpclassify with <math.h>)
158 AC_TRY_LINK([#include <math.h>], [float f = 0.0; fpclassify(f)],
160 AC_DEFINE(HAVE_FPCLASSIFY), AC_MSG_RESULT(no))])
161 AC_CHECK_FUNCS(finite, ,
162 [AC_CHECK_FUNCS(isfinite, ,
163 [AC_MSG_CHECKING(for isfinite with <math.h>)
164 AC_TRY_LINK([#include <math.h>], [float f = 0.0; isfinite(f)],
166 AC_DEFINE(HAVE_ISFINITE), AC_MSG_RESULT(no))])])
167 AC_CHECK_FUNCS(isinf, ,
168 [AC_MSG_CHECKING(for isinf with <math.h>)
169 AC_TRY_LINK([#include <math.h>], [float f = 0.0; isinf(f)],
171 AC_DEFINE(HAVE_ISINF), AC_MSG_RESULT(no))])
173 dnl what does realloc do if it gets called with a NULL pointer
175 AC_CACHE_CHECK([if realloc can deal with NULL], rd_cv_null_realloc,
176 [AC_TRY_RUN([#include <stdlib.h>
180 if (x==NULL) return 1;
183 [rd_cv_null_realloc=yes],[rd_cv_null_realloc=nope],:)])
185 if test x"$rd_cv_null_realloc" = xnope; then
186 AC_DEFINE(NO_NULL_REALLOC)
189 dnl determine how to get IEEE math working
190 dnl AC_IEEE(MESSAGE, set rd_cv_ieee_[var] variable, INCLUDES,
191 dnl FUNCTION-BODY, [ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]])
194 AC_MSG_CHECKING([if IEEE math works $1])
195 AC_CACHE_VAL([rd_cv_ieee_$2],
211 # include <fp_class.h>
215 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASS))
216 # define HAVE_ISINF 1
217 # define isinf(a) (fpclass(a) == FP_NINF || fpclass(a) == FP_PINF)
221 #if (! defined(HAVE_ISINF) && defined(HAVE_FP_CLASS) && defined(HAVE_FP_CLASS_H))
222 # define HAVE_ISINF 1
223 # define isinf(a) (fp_class(a) == FP_NEG_INF || fp_class(a) == FP_POS_INF)
227 #if (! defined(HAVE_ISINF) && defined(HAVE_CLASS))
228 # define HAVE_ISINF 1
229 # define isinf(a) (class(a) == FP_MINUS_INF || class(a) == FP_PLUS_INF)
232 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_PLUS_INF) && defined(FP_MINUS_INF))
233 # define HAVE_ISINF 1
234 # define isinf(a) (fpclassify(a) == FP_MINUS_INF || fpclassify(a) == FP_PLUS_INF)
237 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_INFINITE))
238 # define HAVE_ISINF 1
239 # define isinf(a) (fpclassify(a) == FP_INFINITE)
244 double nan,inf,c,zero;
246 /* some math to see if we get a floating point exception */
247 zero=sin(0.0); /* don't let the compiler optimize us away */
248 nan=0.0/zero; /* especially here */
249 inf=1.0/zero; /* and here. I want to know if it can do the magic */
250 /* at run time without sig fpe */
253 if (! isnan(nan)) {printf ("not isnan(NaN) ... "); return 1;}
254 if (nan == nan) {printf ("nan == nan ... "); return 1;}
255 if (! isinf(inf)) {printf ("not isinf(oo) ... "); return 1;}
256 if (! isinf(-inf)) {printf ("not isinf(-oo) ... "); return 1;}
257 if (! inf > 0) {printf ("not inf > 0 ... "); return 1;}
258 if (! -inf < 0) {printf ("not -inf < 0 ... "); return 1;}
265 dnl these we run regardles is cached or not
266 if test x${rd_cv_ieee_$2} = "xyes"; then
277 AC_IEEE([out of the box], works, , , ,
278 [CFLAGS="$_cflags -ieee"
279 AC_IEEE([with the -ieee switch], switch, , , ,
280 [CFLAGS="$_cflags -qfloat=nofold"
281 AC_IEEE([with the -qfloat=nofold switch], nofold, , , ,
282 [CFLAGS="$_cflags -w -qflttrap=enable:zerodivide"
283 AC_IEEE([with the -w -qflttrap=enable:zerodivide], flttrap, , , ,
284 [CFLAGS="$_cflags -mieee"
285 AC_IEEE([with the -mieee switch], mswitch, , , ,
286 [CFLAGS="$_cflags -q float=rndsngl"
287 AC_IEEE([with the -q float=rndsngl switch], qswitch, , , ,
288 [CFLAGS="$_cflags -OPT:IEEE_comparisons=ON"
289 AC_IEEE([with the -OPT:IEEE_comparisons=ON switch], ieeecmpswitch, , , ,
291 AC_IEEE([with fpsetmask(0)], mask,
292 [#include <floatingpoint.h>], [fpsetmask(0)],
293 [AC_DEFINE(MUST_DISABLE_FPMASK)
294 PERLFLAGS="CCFLAGS=-DMUST_DISABLE_FPMASK"],
295 [AC_IEEE([with signal(SIGFPE,SIG_IGN)], sigfpe,
296 [#include <signal.h>], [signal(SIGFPE,SIG_IGN)],
297 [AC_DEFINE(MUST_DISABLE_SIGFPE)
298 PERLFLAGS="CCFLAGS=-DMUST_DISABLE_SIGFPE"],
300 Your Compiler does not do propper IEEE math ... Please find out how to
301 make IEEE math work with your compiler and let me know (oetiker@ee.ethz.ch).
302 Check config.log to see what went wrong ...
306 AC_OUTPUT(examples/shared-demo.pl \
307 examples/piped-demo.pl \
308 examples/stripes.pl \
309 examples/bigtops.pl \
311 examples/cgi-demo.cgi \
315 libraries/cgilib-0.4/Makefile \
316 libraries/gd1.3/Makefile \
317 libraries/libpng-1.0.9/Makefile \
318 libraries/zlib-1.1.3/Makefile \
321 bindings/tcl/Makefile \
323 [chmod +x examples/*.cgi examples/*.pl])
326 AC_MSG_RESULT(and out again)
328 echo $ac_n "ordering CD from http://ee-staff.ethz.ch/~oetiker/wish $ac_c" 1>&6
330 echo $ac_n ".$ac_c" 1>&6
332 echo $ac_n ".$ac_c" 1>&6
334 echo $ac_n ".$ac_c" 1>&6
336 echo $ac_n ".$ac_c" 1>&6
338 AC_MSG_RESULT([ just kidding ;-)])
340 echo "----------------------------------------------------------------"
341 echo "Config is DONE!"
343 echo "Type 'make' to compile the software and use 'make install' to "
344 echo "install everything to: $prefix."
346 echo "If you want to install the perl"
347 echo "modules in site-perl, try 'make site-perl-install'."
349 echo " ... that wishlist is NO JOKE. If you find RRDtool useful"
350 echo "make me happy. Go to http://ee-staff.ethz.ch/~oetiker/wish and"
351 echo "place an order."
353 echo " -- Tobi Oetiker <tobi@oetiker.ch>"
354 echo "----------------------------------------------------------------"