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'`
151 dnl it seems that hpux chockes on -fPIC for some reason
154 CLFAGS=`echo $CFLAGS|sed -e 's/-fPIC/-fpic/g'`
158 dnl Checks for library functions.
162 dnl for each function found we get a definition in config.h
163 dnl of the form HAVE_FUNCTION
165 AC_CHECK_FUNCS(strerror snprintf vsnprintf fpclass class fp_class isnan memmove strchr mktime getrusage gettimeofday)
167 dnl HP-UX 11.00 does not have finite but does have isfinite as a macro
168 AC_CHECK_FUNCS(fpclassify, ,
169 [AC_MSG_CHECKING(for fpclassify with <math.h>)
170 AC_TRY_LINK([#include <math.h>], [float f = 0.0; fpclassify(f)],
172 AC_DEFINE(HAVE_FPCLASSIFY), AC_MSG_RESULT(no))])
173 AC_CHECK_FUNCS(finite, ,
174 [AC_CHECK_FUNCS(isfinite, ,
175 [AC_MSG_CHECKING(for isfinite with <math.h>)
176 AC_TRY_LINK([#include <math.h>], [float f = 0.0; isfinite(f)],
178 AC_DEFINE(HAVE_ISFINITE), AC_MSG_RESULT(no))])])
179 AC_CHECK_FUNCS(isinf, ,
180 [AC_MSG_CHECKING(for isinf with <math.h>)
181 AC_TRY_LINK([#include <math.h>], [float f = 0.0; isinf(f)],
183 AC_DEFINE(HAVE_ISINF), AC_MSG_RESULT(no))])
185 dnl what does realloc do if it gets called with a NULL pointer
187 AC_CACHE_CHECK([if realloc can deal with NULL], rd_cv_null_realloc,
188 [AC_TRY_RUN([#include <stdlib.h>
192 if (x==NULL) return 1;
195 [rd_cv_null_realloc=yes],[rd_cv_null_realloc=nope],:)])
197 if test x"$rd_cv_null_realloc" = xnope; then
198 AC_DEFINE(NO_NULL_REALLOC)
201 dnl determine how to get IEEE math working
202 dnl AC_IEEE(MESSAGE, set rd_cv_ieee_[var] variable, INCLUDES,
203 dnl FUNCTION-BODY, [ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]])
206 AC_MSG_CHECKING([if IEEE math works $1])
207 AC_CACHE_VAL([rd_cv_ieee_$2],
223 # include <fp_class.h>
227 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASS))
228 # define HAVE_ISINF 1
229 # define isinf(a) (fpclass(a) == FP_NINF || fpclass(a) == FP_PINF)
233 #if (! defined(HAVE_ISINF) && defined(HAVE_FP_CLASS) && defined(HAVE_FP_CLASS_H))
234 # define HAVE_ISINF 1
235 # define isinf(a) (fp_class(a) == FP_NEG_INF || fp_class(a) == FP_POS_INF)
239 #if (! defined(HAVE_ISINF) && defined(HAVE_CLASS))
240 # define HAVE_ISINF 1
241 # define isinf(a) (class(a) == FP_MINUS_INF || class(a) == FP_PLUS_INF)
244 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_PLUS_INF) && defined(FP_MINUS_INF))
245 # define HAVE_ISINF 1
246 # define isinf(a) (fpclassify(a) == FP_MINUS_INF || fpclassify(a) == FP_PLUS_INF)
249 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_INFINITE))
250 # define HAVE_ISINF 1
251 # define isinf(a) (fpclassify(a) == FP_INFINITE)
256 double nan,inf,c,zero;
258 /* some math to see if we get a floating point exception */
259 zero=sin(0.0); /* don't let the compiler optimize us away */
260 nan=0.0/zero; /* especially here */
261 inf=1.0/zero; /* and here. I want to know if it can do the magic */
262 /* at run time without sig fpe */
265 if (! isnan(nan)) {printf ("not isnan(NaN) ... "); return 1;}
266 if (nan == nan) {printf ("nan == nan ... "); return 1;}
267 if (! isinf(inf)) {printf ("not isinf(oo) ... "); return 1;}
268 if (! isinf(-inf)) {printf ("not isinf(-oo) ... "); return 1;}
269 if (! inf > 0) {printf ("not inf > 0 ... "); return 1;}
270 if (! -inf < 0) {printf ("not -inf < 0 ... "); return 1;}
277 dnl these we run regardles is cached or not
278 if test x${rd_cv_ieee_$2} = "xyes"; then
289 AC_IEEE([out of the box], works, , , ,
290 [CFLAGS="$_cflags -ieee"
291 AC_IEEE([with the -ieee switch], switch, , , ,
292 [CFLAGS="$_cflags -qfloat=nofold"
293 AC_IEEE([with the -qfloat=nofold switch], nofold, , , ,
294 [CFLAGS="$_cflags -w -qflttrap=enable:zerodivide"
295 AC_IEEE([with the -w -qflttrap=enable:zerodivide], flttrap, , , ,
296 [CFLAGS="$_cflags -mieee"
297 AC_IEEE([with the -mieee switch], mswitch, , , ,
298 [CFLAGS="$_cflags -q float=rndsngl"
299 AC_IEEE([with the -q float=rndsngl switch], qswitch, , , ,
300 [CFLAGS="$_cflags -OPT:IEEE_comparisons=ON"
301 AC_IEEE([with the -OPT:IEEE_comparisons=ON switch], ieeecmpswitch, , , ,
303 AC_IEEE([with fpsetmask(0)], mask,
304 [#include <floatingpoint.h>], [fpsetmask(0)],
305 [AC_DEFINE(MUST_DISABLE_FPMASK)
306 PERLFLAGS="CCFLAGS=-DMUST_DISABLE_FPMASK"],
307 [AC_IEEE([with signal(SIGFPE,SIG_IGN)], sigfpe,
308 [#include <signal.h>], [signal(SIGFPE,SIG_IGN)],
309 [AC_DEFINE(MUST_DISABLE_SIGFPE)
310 PERLFLAGS="CCFLAGS=-DMUST_DISABLE_SIGFPE"],
312 Your Compiler does not do propper IEEE math ... Please find out how to
313 make IEEE math work with your compiler and let me know (oetiker@ee.ethz.ch).
314 Check config.log to see what went wrong ...
318 AC_OUTPUT(examples/shared-demo.pl \
319 examples/piped-demo.pl \
320 examples/stripes.pl \
321 examples/bigtops.pl \
323 examples/cgi-demo.cgi \
327 libraries/cgilib-0.4/Makefile \
328 libraries/gd1.3/Makefile \
329 libraries/libpng-1.0.9/Makefile \
330 libraries/zlib-1.1.3/Makefile \
333 bindings/tcl/Makefile \
335 [chmod +x examples/*.cgi examples/*.pl])
338 AC_MSG_RESULT(and out again)
340 echo $ac_n "ordering CD from http://ee-staff.ethz.ch/~oetiker/wish $ac_c" 1>&6
342 echo $ac_n ".$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 AC_MSG_RESULT([ just kidding ;-)])
352 echo "----------------------------------------------------------------"
353 echo "Config is DONE!"
355 echo "Type 'make' to compile the software and use 'make install' to "
356 echo "install everything to: $prefix."
358 echo "If you want to install the perl"
359 echo "modules in site-perl, try 'make site-perl-install'."
361 echo " ... that wishlist is NO JOKE. If you find RRDtool useful"
362 echo "make me happy. Go to http://ee-staff.ethz.ch/~oetiker/wish and"
363 echo "place an order."
365 echo " -- Tobi Oetiker <tobi@oetiker.ch>"
366 echo "----------------------------------------------------------------"