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)
53 AC_MSG_CHECKING(for the C compiler perl wants to use to build its modules)
54 PROBLEMCC=`$PERL -e 'use Config; map {if (-x "$_/$Config{cc}"){exit 0}} split /:/, $ENV{PATH};print $Config{cc}'`
55 if test x$PROBLEMCC != x; then
57 echo Could not find the Compiler: '"'$PROBLEMCC'"'
58 echo which has been used to build perl. You may have to compile
59 echo your own copy of perl to make this work. Binary perls often
60 echo exhibit this problem
71 AC_ARG_WITH(tcllib,[ --with-tcllib=DIR location of the tclConfig.sh])
73 AC_MSG_CHECKING(for tclConfig.sh in $withval)
74 if test -f "$withval/tclConfig.sh" ; then
75 tcl_config=$withval/tclConfig.sh
83 if test $found -eq 0 ; then
84 AC_MSG_WARN([tclConfig.sh not found - Tcl interface won't be built])
89 dnl Pass additional perl options when generating Makefile from Makefile.PL
90 # Options to pass when configuring perl module
91 AC_ARG_WITH(perl-options,
92 [ --with-perl-options=[OPTIONS] options to pass on command-line when
93 generating Makefile from Makefile.PL],
94 [PERL_MAKE_OPTIONS=$withval])
95 AC_SUBST(PERL_MAKE_OPTIONS)
97 AM_CONDITIONAL(COMP_TCL, test x$found = x1 )
100 AC_SUBST(TCL_SHLIB_CFLAGS)
101 AC_SUBST(TCL_SHLIB_LD)
102 AC_SUBST(TCL_SHLIB_SUFFIX)
103 AC_SUBST(TCL_PACKAGE_PATH)
104 AC_SUBST(TCL_LD_SEARCH_FLAGS)
106 dnl Check for the compiler and static/shared library creation.
109 dnl RRD_ACLOCAL_FIND_LIBTOOL
111 dnl don't build a shared library ...
112 dnl this can be changed when running configure
117 dnl Checks for header files.
119 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)
121 dnl Checks for typedefs, structures, and compiler characteristics.
126 dnl Checks for libraries.
127 AC_CHECK_FUNC(acos, , AC_CHECK_LIB(m, acos))
130 AC_PATH_PROGS(NROFF, gnroff nroff)
131 AC_PATH_PROGS(TROFF, groff troff)
133 dnl Does the compiler like -Wall and -pedantic?
134 if test "x$GCC" = "xyes"; then
136 CFLAGS="$CFLAGS -Wall -pedantic -Wshadow -Wpointer-arith -Wcast-align -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline"
137 AC_CACHE_CHECK(if we can use GCC-specific compiler options, rd_cv_gcc_opt,
138 [AC_TRY_COMPILE( , return 0 ,
143 if test $rd_cv_gcc_opt = no; then
148 dnl add pic flag in any case this makes sure all our code is relocatable
149 CFLAGS="$CFLAGS "`grep pic_flag= libtool | sed -e 's/.*pic_flag=//' -e 's/"//g'`
152 dnl it seems that hpux chockes on -fPIC for some reason
155 ZLIB_CFLAGS=`echo $CFLAGS|sed -e 's/-fPIC/-fpic/g'`
158 AC_SUBST(ZLIB_CFLAGS)
160 dnl Checks for library functions.
164 dnl for each function found we get a definition in config.h
165 dnl of the form HAVE_FUNCTION
167 AC_CHECK_FUNCS(strerror snprintf vsnprintf fpclass class fp_class isnan memmove strchr mktime getrusage gettimeofday)
169 dnl HP-UX 11.00 does not have finite but does have isfinite as a macro
170 AC_CHECK_FUNCS(fpclassify, ,
171 [AC_MSG_CHECKING(for fpclassify with <math.h>)
172 AC_TRY_LINK([#include <math.h>], [float f = 0.0; fpclassify(f)],
174 AC_DEFINE(HAVE_FPCLASSIFY), AC_MSG_RESULT(no))])
175 AC_CHECK_FUNCS(finite, ,
176 [AC_CHECK_FUNCS(isfinite, ,
177 [AC_MSG_CHECKING(for isfinite with <math.h>)
178 AC_TRY_LINK([#include <math.h>], [float f = 0.0; isfinite(f)],
180 AC_DEFINE(HAVE_ISFINITE), AC_MSG_RESULT(no))])])
181 AC_CHECK_FUNCS(isinf, ,
182 [AC_MSG_CHECKING(for isinf with <math.h>)
183 AC_TRY_LINK([#include <math.h>], [float f = 0.0; isinf(f)],
185 AC_DEFINE(HAVE_ISINF), AC_MSG_RESULT(no))])
187 dnl what does realloc do if it gets called with a NULL pointer
189 AC_CACHE_CHECK([if realloc can deal with NULL], rd_cv_null_realloc,
190 [AC_TRY_RUN([#include <stdlib.h>
194 if (x==NULL) return 1;
197 [rd_cv_null_realloc=yes],[rd_cv_null_realloc=nope],:)])
199 if test x"$rd_cv_null_realloc" = xnope; then
200 AC_DEFINE(NO_NULL_REALLOC)
203 dnl determine how to get IEEE math working
204 dnl AC_IEEE(MESSAGE, set rd_cv_ieee_[var] variable, INCLUDES,
205 dnl FUNCTION-BODY, [ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]])
208 AC_MSG_CHECKING([if IEEE math works $1])
209 AC_CACHE_VAL([rd_cv_ieee_$2],
225 # include <fp_class.h>
229 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASS))
230 # define HAVE_ISINF 1
231 # define isinf(a) (fpclass(a) == FP_NINF || fpclass(a) == FP_PINF)
235 #if (! defined(HAVE_ISINF) && defined(HAVE_FP_CLASS) && defined(HAVE_FP_CLASS_H))
236 # define HAVE_ISINF 1
237 # define isinf(a) (fp_class(a) == FP_NEG_INF || fp_class(a) == FP_POS_INF)
241 #if (! defined(HAVE_ISINF) && defined(HAVE_CLASS))
242 # define HAVE_ISINF 1
243 # define isinf(a) (class(a) == FP_MINUS_INF || class(a) == FP_PLUS_INF)
246 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_PLUS_INF) && defined(FP_MINUS_INF))
247 # define HAVE_ISINF 1
248 # define isinf(a) (fpclassify(a) == FP_MINUS_INF || fpclassify(a) == FP_PLUS_INF)
251 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_INFINITE))
252 # define HAVE_ISINF 1
253 # define isinf(a) (fpclassify(a) == FP_INFINITE)
258 double nan,inf,c,zero;
260 /* some math to see if we get a floating point exception */
261 zero=sin(0.0); /* don't let the compiler optimize us away */
262 nan=0.0/zero; /* especially here */
263 inf=1.0/zero; /* and here. I want to know if it can do the magic */
264 /* at run time without sig fpe */
267 if (! isnan(nan)) {printf ("not isnan(NaN) ... "); return 1;}
268 if (nan == nan) {printf ("nan == nan ... "); return 1;}
269 if (! isinf(inf)) {printf ("not isinf(oo) ... "); return 1;}
270 if (! isinf(-inf)) {printf ("not isinf(-oo) ... "); return 1;}
271 if (! inf > 0) {printf ("not inf > 0 ... "); return 1;}
272 if (! -inf < 0) {printf ("not -inf < 0 ... "); return 1;}
279 dnl these we run regardles is cached or not
280 if test x${rd_cv_ieee_$2} = "xyes"; then
291 AC_IEEE([out of the box], works, , , ,
292 [CFLAGS="$_cflags -ieee"
293 AC_IEEE([with the -ieee switch], switch, , , ,
294 [CFLAGS="$_cflags -qfloat=nofold"
295 AC_IEEE([with the -qfloat=nofold switch], nofold, , , ,
296 [CFLAGS="$_cflags -w -qflttrap=enable:zerodivide"
297 AC_IEEE([with the -w -qflttrap=enable:zerodivide], flttrap, , , ,
298 [CFLAGS="$_cflags -mieee"
299 AC_IEEE([with the -mieee switch], mswitch, , , ,
300 [CFLAGS="$_cflags -q float=rndsngl"
301 AC_IEEE([with the -q float=rndsngl switch], qswitch, , , ,
302 [CFLAGS="$_cflags -OPT:IEEE_comparisons=ON"
303 AC_IEEE([with the -OPT:IEEE_comparisons=ON switch], ieeecmpswitch, , , ,
305 AC_IEEE([with fpsetmask(0)], mask,
306 [#include <floatingpoint.h>], [fpsetmask(0)],
307 [AC_DEFINE(MUST_DISABLE_FPMASK)
308 PERLFLAGS="CCFLAGS=-DMUST_DISABLE_FPMASK"],
309 [AC_IEEE([with signal(SIGFPE,SIG_IGN)], sigfpe,
310 [#include <signal.h>], [signal(SIGFPE,SIG_IGN)],
311 [AC_DEFINE(MUST_DISABLE_SIGFPE)
312 PERLFLAGS="CCFLAGS=-DMUST_DISABLE_SIGFPE"],
314 Your Compiler does not do propper IEEE math ... Please find out how to
315 make IEEE math work with your compiler and let me know (oetiker@ee.ethz.ch).
316 Check config.log to see what went wrong ...
320 AC_OUTPUT(examples/shared-demo.pl \
321 examples/piped-demo.pl \
322 examples/stripes.pl \
323 examples/bigtops.pl \
325 examples/cgi-demo.cgi \
329 libraries/cgilib-0.4/Makefile \
330 libraries/gd1.3/Makefile \
331 libraries/libpng-1.0.9/Makefile \
332 libraries/zlib-1.1.3/Makefile \
335 bindings/tcl/Makefile \
337 [chmod +x examples/*.cgi examples/*.pl])
340 AC_MSG_RESULT(and out again)
342 echo $ac_n "ordering CD from http://ee-staff.ethz.ch/~oetiker/wish $ac_c" 1>&6
344 echo $ac_n ".$ac_c" 1>&6
346 echo $ac_n ".$ac_c" 1>&6
348 echo $ac_n ".$ac_c" 1>&6
350 echo $ac_n ".$ac_c" 1>&6
352 AC_MSG_RESULT([ just kidding ;-)])
354 echo "----------------------------------------------------------------"
355 echo "Config is DONE!"
357 echo "Type 'make' to compile the software and use 'make install' to "
358 echo "install everything to: $prefix."
360 echo "If you want to install the perl"
361 echo "modules in site-perl, try 'make site-perl-install'."
363 echo " ... that wishlist is NO JOKE. If you find RRDtool useful"
364 echo "make me happy. Go to http://ee-staff.ethz.ch/~oetiker/wish and"
365 echo "place an order."
367 echo " -- Tobi Oetiker <tobi@oetiker.ch>"
368 echo "----------------------------------------------------------------"