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 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
12 dnl is in there
13 AC_CONFIG_AUX_DIR(config)
15 dnl determine the type of system we are running on
16 AC_CANONICAL_SYSTEM
18 dnl tell automake the this script is for rrdtool
19 AM_INIT_AUTOMAKE(rrdtool, 1.0.33)
20 AC_SUBST(VERSION)
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.
29 AC_PREREQ(2.13)
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
38 AC_SUBST(CGI_LIB_DIR)
39 AC_SUBST(GD_LIB_DIR)
40 AC_SUBST(PNG_LIB_DIR)
41 AC_SUBST(ZLIB_LIB_DIR)
42 AC_SUBST(PERLFLAGS)
44 dnl Check for Perl.
45 AC_PATH_PROG(PERL, perl, no)
46 if test "x$PERL" = "xno"; then
47 COMP_PERL=
48 else
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
56 AC_MSG_RESULT(no)
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
61 exit 1
62 else
63 AC_MSG_RESULT(found)
64 fi
65 fi
66 AC_SUBST(COMP_PERL)
67 AC_SUBST(SO_EXT)
69 dnl Check for Tcl.
70 withval=""
71 AC_ARG_WITH(tcllib,[ --with-tcllib=DIR location of the tclConfig.sh])
72 found=0
73 AC_MSG_CHECKING(for tclConfig.sh in $withval)
74 if test -f "$withval/tclConfig.sh" ; then
75 tcl_config=$withval/tclConfig.sh
76 found=1
77 AC_MSG_RESULT(yes)
78 break
79 else
80 AC_MSG_RESULT(no)
81 fi
83 if test $found -eq 0 ; then
84 AC_MSG_WARN([tclConfig.sh not found - Tcl interface won't be built])
85 else
86 . $tcl_config
87 fi
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 )
99 AC_SUBST(TCL_PREFIX)
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.
107 AC_PROG_CC
108 AC_PROG_CPP
109 dnl RRD_ACLOCAL_FIND_LIBTOOL
111 dnl don't build a shared library ...
112 dnl this can be changed when running configure
113 AC_DISABLE_SHARED
115 AM_PROG_LIBTOOL
117 dnl Checks for header files.
118 AC_HEADER_STDC
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.
122 AC_C_CONST
123 AC_HEADER_TIME
124 AC_STRUCT_TM
126 dnl Checks for libraries.
127 AC_CHECK_FUNC(acos, , AC_CHECK_LIB(m, acos))
129 dnl Check for nroff
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
135 oCFLAGS=$CFLAGS
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 ,
139 rd_cv_gcc_opt=yes,
140 rd_cv_gcc_opt=no )
141 ]
142 )
143 if test $rd_cv_gcc_opt = no; then
144 CFLAGS=$oCFLAGS
145 fi
146 fi
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 ZLIB_CFLAGS=$CFLAGS
152 dnl it seems that hpux chockes on -fPIC for some reason
153 case $target_os in
154 *hpux*)
155 ZLIB_CFLAGS=`echo $CFLAGS|sed -e 's/-fPIC/-fpic/g'`
156 ;;
157 esac
158 AC_SUBST(ZLIB_CFLAGS)
160 dnl Checks for library functions.
161 AC_FUNC_STRFTIME
162 AC_FUNC_VPRINTF
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)],
173 AC_MSG_RESULT(yes)
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)],
179 AC_MSG_RESULT(yes)
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)],
184 AC_MSG_RESULT(yes)
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>
191 int main(void){
192 char *x = NULL;
193 x = realloc (x,10);
194 if (x==NULL) return 1;
195 return 0;
196 }],
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)
201 fi
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]])
207 AC_DEFUN(AC_IEEE,
208 AC_MSG_CHECKING([if IEEE math works $1])
209 AC_CACHE_VAL([rd_cv_ieee_$2],
210 [AC_TRY_RUN([$3
212 #if HAVE_MATH_H
213 # include <math.h>
214 #endif
216 #if HAVE_FLOAT_H
217 # include <float.h>
218 #endif
220 #if HAVE_IEEEFP_H
221 # include <ieeefp.h>
222 #endif
224 #if HAVE_FP_CLASS_H
225 # include <fp_class.h>
226 #endif
228 /* Solaris */
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)
232 #endif
234 /* Digital UNIX */
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)
238 #endif
240 /* AIX */
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)
244 #endif
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)
249 #endif
251 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_INFINITE))
252 # define HAVE_ISINF 1
253 # define isinf(a) (fpclassify(a) == FP_INFINITE)
254 #endif
256 #include <stdio.h>
257 int main(void){
258 double nan,inf,c,zero;
259 $4;
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 */
265 c = inf + nan;
266 c = inf / nan;
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;}
273 return 0;
274 }],
276 rd_cv_ieee_$2=yes,
277 rd_cv_ieee_$2=no,
278 :)])
279 dnl these we run regardles is cached or not
280 if test x${rd_cv_ieee_$2} = "xyes"; then
281 AC_MSG_RESULT(yes)
282 $5
283 else
284 AC_MSG_RESULT(no)
285 $6
286 fi
288 )
290 _cflags=${CFLAGS}
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, , , ,
304 [CFLAGS=$_cflags
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"],
313 AC_MSG_ERROR([
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 ...
317 ]))])])])])])])])])
320 AC_OUTPUT(examples/shared-demo.pl \
321 examples/piped-demo.pl \
322 examples/stripes.pl \
323 examples/bigtops.pl \
324 examples/minmax.pl \
325 examples/cgi-demo.cgi \
326 examples/Makefile \
327 doc/Makefile \
328 libraries/Makefile \
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 \
333 src/Makefile \
334 bindings/Makefile \
335 bindings/tcl/Makefile \
336 Makefile, \
337 [chmod +x examples/*.cgi examples/*.pl])
339 AC_MSG_CHECKING(in)
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
343 sleep 1
344 echo $ac_n ".$ac_c" 1>&6
345 sleep 1
346 echo $ac_n ".$ac_c" 1>&6
347 sleep 1
348 echo $ac_n ".$ac_c" 1>&6
349 sleep 1
350 echo $ac_n ".$ac_c" 1>&6
351 sleep 1
352 AC_MSG_RESULT([ just kidding ;-)])
353 echo
354 echo "----------------------------------------------------------------"
355 echo "Config is DONE!"
356 echo
357 echo "Type 'make' to compile the software and use 'make install' to "
358 echo "install everything to: $prefix."
359 echo
360 echo "If you want to install the perl"
361 echo "modules in site-perl, try 'make site-perl-install'."
362 echo
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."
366 echo
367 echo " -- Tobi Oetiker <tobi@oetiker.ch>"
368 echo "----------------------------------------------------------------"