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 dnl it seems that hpux chockes on -fPIC for some reason
152 case $target_os in
153 *hpux*)
154 CLFAGS=`echo $CFLAGS|sed -e 's/-fPIC/-fpic/g'`
155 ;;
156 esac
158 dnl Checks for library functions.
159 AC_FUNC_STRFTIME
160 AC_FUNC_VPRINTF
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)],
171 AC_MSG_RESULT(yes)
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)],
177 AC_MSG_RESULT(yes)
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)],
182 AC_MSG_RESULT(yes)
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>
189 int main(void){
190 char *x = NULL;
191 x = realloc (x,10);
192 if (x==NULL) return 1;
193 return 0;
194 }],
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)
199 fi
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]])
205 AC_DEFUN(AC_IEEE,
206 AC_MSG_CHECKING([if IEEE math works $1])
207 AC_CACHE_VAL([rd_cv_ieee_$2],
208 [AC_TRY_RUN([$3
210 #if HAVE_MATH_H
211 # include <math.h>
212 #endif
214 #if HAVE_FLOAT_H
215 # include <float.h>
216 #endif
218 #if HAVE_IEEEFP_H
219 # include <ieeefp.h>
220 #endif
222 #if HAVE_FP_CLASS_H
223 # include <fp_class.h>
224 #endif
226 /* Solaris */
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)
230 #endif
232 /* Digital UNIX */
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)
236 #endif
238 /* AIX */
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)
242 #endif
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)
247 #endif
249 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_INFINITE))
250 # define HAVE_ISINF 1
251 # define isinf(a) (fpclassify(a) == FP_INFINITE)
252 #endif
254 #include <stdio.h>
255 int main(void){
256 double nan,inf,c,zero;
257 $4;
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 */
263 c = inf + nan;
264 c = inf / nan;
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;}
271 return 0;
272 }],
274 rd_cv_ieee_$2=yes,
275 rd_cv_ieee_$2=no,
276 :)])
277 dnl these we run regardles is cached or not
278 if test x${rd_cv_ieee_$2} = "xyes"; then
279 AC_MSG_RESULT(yes)
280 $5
281 else
282 AC_MSG_RESULT(no)
283 $6
284 fi
286 )
288 _cflags=${CFLAGS}
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, , , ,
302 [CFLAGS=$_cflags
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"],
311 AC_MSG_ERROR([
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 ...
315 ]))])])])])])])])])
318 AC_OUTPUT(examples/shared-demo.pl \
319 examples/piped-demo.pl \
320 examples/stripes.pl \
321 examples/bigtops.pl \
322 examples/minmax.pl \
323 examples/cgi-demo.cgi \
324 examples/Makefile \
325 doc/Makefile \
326 libraries/Makefile \
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 \
331 src/Makefile \
332 bindings/Makefile \
333 bindings/tcl/Makefile \
334 Makefile, \
335 [chmod +x examples/*.cgi examples/*.pl])
337 AC_MSG_CHECKING(in)
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
341 sleep 1
342 echo $ac_n ".$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 AC_MSG_RESULT([ just kidding ;-)])
351 echo
352 echo "----------------------------------------------------------------"
353 echo "Config is DONE!"
354 echo
355 echo "Type 'make' to compile the software and use 'make install' to "
356 echo "install everything to: $prefix."
357 echo
358 echo "If you want to install the perl"
359 echo "modules in site-perl, try 'make site-perl-install'."
360 echo
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."
364 echo
365 echo " -- Tobi Oetiker <tobi@oetiker.ch>"
366 echo "----------------------------------------------------------------"