1 dnl RRDtool AutoConf script ...
2 dnl ---------------------------
3 dnl
4 dnl Created by Jeff Allen, Tobi Oetiker, Blair Zajac
5 dnl
6 dnl
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.h)
15 dnl all our local stuff like install scripts and include files
16 dnl is in there
19 dnl determine the type of system we are running on
22 AC_SUBST(VERSION)
24 dnl where we install our stuff ...
25 AC_PREFIX_DEFAULT( /usr/local/rrdtool-1.1.0 )
27 dnl Minimum Autoconf version required.
28 AC_PREREQ(2.52)
30 dnl At the TOP of the HEADER
32 AH_TOP([
34 #ifndef CONFIG_H
35 #define CONFIG_H
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
45 ])
47 AH_BOTTOM([
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 */
52 #if STDC_HEADERS
53 # include <string.h>
54 #else
55 # ifndef HAVE_STRCHR
56 # define strchr index
57 # define strrchr rindex
58 # endif
59 char *strchr (), *strrchr ();
60 # ifndef HAVE_MEMMOVE
61 # define memcpy(d, s, n) bcopy ((s), (d), (n))
62 # define memmove(d, s, n) bcopy ((s), (d), (n))
63 # endif
64 #endif
67 #if NO_NULL_REALLOC
68 # define rrd_realloc(a,b) ( (a) == NULL ? malloc( (b) ) : realloc( (a) , (b) ))
69 #else
70 # define rrd_realloc(a,b) realloc((a), (b))
71 #endif
73 #if HAVE_MATH_H
74 # include <math.h>
75 #endif
77 #if HAVE_FLOAT_H
78 # include <float.h>
79 #endif
81 #if HAVE_IEEEFP_H
82 # include <ieeefp.h>
83 #endif
85 #if HAVE_FP_CLASS_H
86 # include <fp_class.h>
87 #endif
89 /* for Solaris */
90 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASS))
91 # define HAVE_ISINF 1
92 # define isinf(a) (fpclass(a) == FP_NINF || fpclass(a) == FP_PINF)
93 #endif
95 /* for OSF1 Digital Unix */
96 #if (! defined(HAVE_ISINF) && defined(HAVE_FP_CLASS) && defined(HAVE_FP_CLASS_H))
97 # define HAVE_ISINF 1
98 # define isinf(a) (fp_class(a) == FP_NEG_INF || fp_class(a) == FP_POS_INF)
99 #endif
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)
104 #endif
106 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_INFINITE))
107 # define HAVE_ISINF 1
108 # define isinf(a) (fpclassify(a) == FP_INFINITE)
109 #endif
111 /* for AIX */
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)
115 #endif
117 #if (! defined (HAVE_FINITE) && defined (HAVE_ISFINITE))
118 # define HAVE_FINITE 1
119 # define finite(a) isfinite(a)
120 #endif
122 #if (! defined(HAVE_FINITE) && defined(HAVE_ISNAN) && defined(HAVE_ISINF))
123 # define HAVE_FINITE 1
124 # define finite(a) (! isnan(a) && ! isinf(a))
125 #endif
127 #ifndef HAVE_FINITE
128 #error "Can't compile without finite function"
129 #endif
131 #ifndef HAVE_ISINF
132 #error "Can't compile without isinf function"
133 #endif
135 #endif /* CONFIG_H */
136 ])
140 dnl Check for the compiler and static/shared library creation.
141 AC_PROG_CC
142 AC_PROG_CPP
143 AC_PROG_LIBTOOL
145 dnl Checks for header files.
146 AC_HEADER_STDC
147 AC_HEADER_DIRENT
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.
151 AC_C_CONST
152 AC_HEADER_TIME
153 AC_STRUCT_TM
155 dnl substitute them in all the files listed in AC_OUTPUT
156 AC_SUBST(PERLFLAGS)
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}"],AC_MSG_ERROR([Adjust CPPFLAGS so that the $4 header $3 gets found])) ],
164 [ AC_MSG_ERROR([
165 ############################################################################
166 I could not find a working copy of $4. Check config.log for hints on why
167 this is the case. Maybe you need to set LDFLAGS appropriately so that the
168 linker can find lib$1. If you have not installed $4, you can get it
169 either from its original home on
171 $6
173 Or you can find an archive copy on
175 http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/pub/libs
177 The last tested version of $4 is $5.
178 ############################################################################
179 ])] )
180 ]
181 )
183 EX_CHECK_ALL(cgi, cgiInit, cgi.h, cgilib, 0.5, http://www.infodrom.org/projects/cgilib)
184 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/)
185 EX_CHECK_ALL(z, zlibVersion, zlib.h, zlib, 1.2.1, http://www.gzip.org/zlib/)
186 EX_CHECK_ALL(png, png_access_version_number, png.h, libpng, 1.2.5, http://prdownloads.sourceforge.net/libpng/)
187 EX_CHECK_ALL(freetype, FT_Init_FreeType, ft2build.h, freetype, 2.1.5, http://prdownloads.sourceforge.net/freetype/)
189 dnl Check for Perl.
190 AC_PATH_PROG(PERL, perl, no)
191 if test "x$PERL" = "xno"; then
192 COMP_PERL=
193 else
194 COMP_PERL="perl_piped perl_shared"
195 AC_MSG_CHECKING(for shared library extension)
196 SO_EXT=`$PERL -e 'use Config; if (defined $Config{so} and $Config{so} ne 'a') {print "$Config{so}\n"} else {print "so\n"};'`
197 AC_MSG_RESULT($SO_EXT)
198 AC_MSG_CHECKING(for the C compiler perl wants to use to build its modules)
199 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}'`
200 if test x$PROBLEMCC != x; then
201 AC_MSG_RESULT(no)
202 echo Could not find the Compiler: '"'$PROBLEMCC'"'
203 echo which has been used to build perl. You may have to compile
204 echo your own copy of perl to make this work. Binary perls often
205 echo exhibit this problem
206 exit 1
207 else
208 AC_MSG_RESULT(found)
209 fi
210 fi
211 AC_SUBST(COMP_PERL)
212 AC_SUBST(SO_EXT)
214 dnl Check for Tcl.
215 withval=""
216 AC_ARG_WITH(tcllib,[ --with-tcllib=DIR location of the tclConfig.sh])
217 found=0
218 AC_MSG_CHECKING(for tclConfig.sh in $withval)
219 if test -f "$withval/tclConfig.sh" ; then
220 tcl_config=$withval/tclConfig.sh
221 found=1
222 AC_MSG_RESULT(yes)
223 break
224 else
225 AC_MSG_RESULT(no)
226 fi
228 if test $found -eq 0 ; then
229 AC_MSG_WARN([tclConfig.sh not found - Tcl interface won't be built])
230 else
231 . $tcl_config
232 fi
234 dnl Pass additional perl options when generating Makefile from Makefile.PL
235 # Options to pass when configuring perl module
236 AC_ARG_WITH(perl-options,
237 [ --with-perl-options=[OPTIONS] options to pass on command-line when
238 generating Makefile from Makefile.PL],
239 [PERL_MAKE_OPTIONS=$withval])
240 AC_SUBST(PERL_MAKE_OPTIONS)
242 AM_CONDITIONAL(COMP_TCL, test x$found = x1 )
244 AC_SUBST(TCL_PREFIX)
245 AC_SUBST(TCL_SHLIB_CFLAGS)
246 AC_SUBST(TCL_SHLIB_LD)
247 AC_SUBST(TCL_SHLIB_SUFFIX)
248 AC_SUBST(TCL_PACKAGE_PATH)
249 AC_SUBST(TCL_LD_SEARCH_FLAGS)
253 dnl Check for nroff
254 AC_PATH_PROGS(NROFF, gnroff nroff)
255 AC_PATH_PROGS(TROFF, groff troff)
257 dnl Does the compiler like -Wall and -pedantic?
258 if test "x$GCC" = "xyes"; then
259 oCFLAGS=$CFLAGS
260 CFLAGS="$CFLAGS -Wall -pedantic -Wshadow -Wpointer-arith -Wcast-align -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -W"
261 AC_CACHE_CHECK(if we can use GCC-specific compiler options, rd_cv_gcc_opt,
262 [AC_TRY_COMPILE( , return 0 ,
263 rd_cv_gcc_opt=yes,
264 rd_cv_gcc_opt=no )
265 ]
266 )
267 if test $rd_cv_gcc_opt = no; then
268 CFLAGS=$oCFLAGS
269 fi
270 fi
272 dnl add pic flag in any case this makes sure all our code is relocatable
273 CFLAGS="$CFLAGS "`grep pic_flag= libtool | head -1|sed -e 's/.*pic_flag=//' -e 's/"//g'`
275 ZLIB_CFLAGS=$CFLAGS
276 dnl it seems that hpux chockes on -fPIC for some reason
277 case $target_os in
278 *hpux*)
279 ZLIB_CFLAGS=`echo $CFLAGS|sed -e 's/-fPIC/-fpic/g'`
280 ;;
281 esac
282 AC_SUBST(ZLIB_CFLAGS)
284 dnl Checks for library functions.
285 AC_FUNC_STRFTIME
286 AC_FUNC_VPRINTF
288 dnl for each function found we get a definition in config.h
289 dnl of the form HAVE_FUNCTION
291 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)
293 dnl HP-UX 11.00 does not have finite but does have isfinite as a macro
294 AC_CHECK_FUNCS(fpclassify, ,
295 [AC_MSG_CHECKING(for fpclassify with <math.h>)
296 AC_TRY_LINK([#include <math.h>], [float f = 0.0; fpclassify(f)],
297 AC_MSG_RESULT(yes)
298 AC_DEFINE(HAVE_FPCLASSIFY), AC_MSG_RESULT(no))])
299 AC_CHECK_FUNCS(finite, ,
300 [AC_CHECK_FUNCS(isfinite, ,
301 [AC_MSG_CHECKING(for isfinite with <math.h>)
302 AC_TRY_LINK([#include <math.h>], [float f = 0.0; isfinite(f)],
303 AC_MSG_RESULT(yes)
304 AC_DEFINE(HAVE_ISFINITE), AC_MSG_RESULT(no))])])
305 AC_CHECK_FUNCS(isinf, ,
306 [AC_MSG_CHECKING(for isinf with <math.h>)
307 AC_TRY_LINK([#include <math.h>], [float f = 0.0; isinf(f)],
308 AC_MSG_RESULT(yes)
309 AC_DEFINE(HAVE_ISINF), AC_MSG_RESULT(no))])
311 dnl what does realloc do if it gets called with a NULL pointer
313 AC_CACHE_CHECK([if realloc can deal with NULL], rd_cv_null_realloc,
314 [AC_TRY_RUN([#include <stdlib.h>
315 int main(void){
316 char *x = NULL;
317 x = realloc (x,10);
318 if (x==NULL) return 1;
319 return 0;
320 }],
321 [rd_cv_null_realloc=yes],[rd_cv_null_realloc=nope],:)])
323 if test x"$rd_cv_null_realloc" = xnope; then
324 AC_DEFINE(NO_NULL_REALLOC)
325 fi
327 dnl determine how to get IEEE math working
328 dnl AC_IEEE(MESSAGE, set rd_cv_ieee_[var] variable, INCLUDES,
329 dnl FUNCTION-BODY, [ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]])
331 AC_C_BIGENDIAN
333 AC_DEFUN(AC_IEEE,
334 AC_MSG_CHECKING([if IEEE math works $1])
335 AC_CACHE_VAL([rd_cv_ieee_$2],
336 [AC_TRY_RUN([$3
338 #if HAVE_MATH_H
339 # include <math.h>
340 #endif
342 #if HAVE_FLOAT_H
343 # include <float.h>
344 #endif
346 #if HAVE_IEEEFP_H
347 # include <ieeefp.h>
348 #endif
350 #if HAVE_FP_CLASS_H
351 # include <fp_class.h>
352 #endif
354 /* Solaris */
355 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASS))
356 # define HAVE_ISINF 1
357 # define isinf(a) (fpclass(a) == FP_NINF || fpclass(a) == FP_PINF)
358 #endif
360 /* Digital UNIX */
361 #if (! defined(HAVE_ISINF) && defined(HAVE_FP_CLASS) && defined(HAVE_FP_CLASS_H))
362 # define HAVE_ISINF 1
363 # define isinf(a) (fp_class(a) == FP_NEG_INF || fp_class(a) == FP_POS_INF)
364 #endif
366 /* AIX */
367 #if (! defined(HAVE_ISINF) && defined(HAVE_CLASS))
368 # define HAVE_ISINF 1
369 # define isinf(a) (class(a) == FP_MINUS_INF || class(a) == FP_PLUS_INF)
370 #endif
372 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_PLUS_INF) && defined(FP_MINUS_INF))
373 # define HAVE_ISINF 1
374 # define isinf(a) (fpclassify(a) == FP_MINUS_INF || fpclassify(a) == FP_PLUS_INF)
375 #endif
377 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_INFINITE))
378 # define HAVE_ISINF 1
379 # define isinf(a) (fpclassify(a) == FP_INFINITE)
380 #endif
382 #include <stdio.h>
383 int main(void){
384 double nan,inf,c,zero;
385 $4;
386 /* some math to see if we get a floating point exception */
387 zero=sin(0.0); /* don't let the compiler optimize us away */
388 nan=0.0/zero; /* especially here */
389 inf=1.0/zero; /* and here. I want to know if it can do the magic */
390 /* at run time without sig fpe */
391 c = inf + nan;
392 c = inf / nan;
393 if (! isnan(nan)) {printf ("not isnan(NaN) ... "); return 1;}
394 if (nan == nan) {printf ("nan == nan ... "); return 1;}
395 if (! isinf(inf)) {printf ("not isinf(oo) ... "); return 1;}
396 if (! isinf(-inf)) {printf ("not isinf(-oo) ... "); return 1;}
397 if (! inf > 0) {printf ("not inf > 0 ... "); return 1;}
398 if (! -inf < 0) {printf ("not -inf < 0 ... "); return 1;}
399 return 0;
400 }],
402 rd_cv_ieee_$2=yes,
403 rd_cv_ieee_$2=no,
404 :)])
405 dnl these we run regardles is cached or not
406 if test x${rd_cv_ieee_$2} = "xyes"; then
407 AC_MSG_RESULT(yes)
408 $5
409 else
410 AC_MSG_RESULT(no)
411 $6
412 fi
414 )
416 _cflags=${CFLAGS}
417 AC_IEEE([out of the box], works, , , ,
418 [CFLAGS="$_cflags -ieee"
419 AC_IEEE([with the -ieee switch], switch, , , ,
420 [CFLAGS="$_cflags -qfloat=nofold"
421 AC_IEEE([with the -qfloat=nofold switch], nofold, , , ,
422 [CFLAGS="$_cflags -w -qflttrap=enable:zerodivide"
423 AC_IEEE([with the -w -qflttrap=enable:zerodivide], flttrap, , , ,
424 [CFLAGS="$_cflags -mieee"
425 AC_IEEE([with the -mieee switch], mswitch, , , ,
426 [CFLAGS="$_cflags -q float=rndsngl"
427 AC_IEEE([with the -q float=rndsngl switch], qswitch, , , ,
428 [CFLAGS="$_cflags -OPT:IEEE_NaN_inf=ON"
429 AC_IEEE([with the -OPT:IEEE_NaN_inf=ON switch], ieeenaninfswitch, , , ,
430 [CFLAGS="$_cflags -OPT:IEEE_comparisons=ON"
431 AC_IEEE([with the -OPT:IEEE_comparisons=ON switch], ieeecmpswitch, , , ,
432 [CFLAGS=$_cflags
433 AC_IEEE([with fpsetmask(0)], mask,
434 [#include <floatingpoint.h>], [fpsetmask(0)],
435 [AC_DEFINE(MUST_DISABLE_FPMASK)
436 PERLFLAGS="CCFLAGS=-DMUST_DISABLE_FPMASK"],
437 [AC_IEEE([with signal(SIGFPE,SIG_IGN)], sigfpe,
438 [#include <signal.h>], [signal(SIGFPE,SIG_IGN)],
439 [AC_DEFINE(MUST_DISABLE_SIGFPE)
440 PERLFLAGS="CCFLAGS=-DMUST_DISABLE_SIGFPE"],
441 AC_MSG_ERROR([
442 Your Compiler does not do propper IEEE math ... Please find out how to
443 make IEEE math work with your compiler and let me know (oetiker@ee.ethz.ch).
444 Check config.log to see what went wrong ...
445 ]))])])])])])])])])])
448 AC_CONFIG_FILES([examples/shared-demo.pl \
449 examples/piped-demo.pl \
450 examples/stripes.pl \
451 examples/bigtops.pl \
452 examples/minmax.pl \
453 examples/cgi-demo.cgi \
454 examples/Makefile \
455 doc/Makefile \
456 src/Makefile \
457 bindings/Makefile \
458 bindings/tcl/Makefile \
459 Makefile])
460 AC_CONFIG_COMMANDS([default],[[\
461 chmod +x examples/*.cgi examples/*.pl]],[[]])
462 AC_OUTPUT
464 AC_MSG_CHECKING(in)
465 AC_MSG_RESULT(and out again)
467 echo $ECHO_N "ordering CD from http://people.ee.ethz.ch/~oetiker/wish $ECHO_C" 1>&6
468 sleep 1
469 echo $ECHO_N ".$ECHO_C" 1>&6
470 sleep 1
471 echo $ECHO_N ".$ECHO_C" 1>&6
472 sleep 1
473 echo $ECHO_N ".$ECHO_C" 1>&6
474 sleep 1
475 echo $ECHO_N ".$ECHO_C" 1>&6
476 sleep 1
477 AC_MSG_RESULT([ just kidding ;-)])
478 echo
479 echo "----------------------------------------------------------------"
480 echo "Config is DONE!"
481 echo
482 echo "Type 'make' to compile the software and use 'make install' to "
483 echo "install everything to: $prefix."
484 echo
485 echo "If you want to install the perl"
486 echo "modules in site-perl, try 'make site-perl-install'."
487 echo
488 echo " ... that wishlist is NO JOKE. If you find RRDtool useful"
489 echo "make me happy. Go to http://people.ee.ethz.ch/~oetiker/wish and"
490 echo "place an order."
491 echo
492 echo " -- Tobi Oetiker <tobi@oetiker.ch>"
493 echo "----------------------------------------------------------------"