The BIG graph update
[rrdtool.git] / configure.ac
1 dnl RRDtool AutoConf script ... 
2 dnl ---------------------------
3 dnl
4 dnl Created by Jeff Allen, Tobi Oetiker, Blair Zajac
5 dnl
6 dnl
7
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/config.h)
14
15 dnl all our local stuff like install scripts and include files
16 dnl is in there
17
18
19 dnl determine the type of system we are running on
20
21
22 AC_SUBST(VERSION)
23
24 dnl where we install our stuff ...
25 AC_PREFIX_DEFAULT( /usr/local/rrdtool-1.1.0 )
26
27 dnl Minimum Autoconf version required.
28 AC_PREREQ(2.52)
29
30 dnl At the TOP of the HEADER
31
32 AH_TOP([
33
34 #ifndef CONFIG_H
35 #define CONFIG_H
36 /* IEEE can be prevented from raising signals with fpsetmask(0) */
37 #undef MUST_DISABLE_FPMASK
38
39 /* IEEE math only works if SIGFPE gets actively set to IGNORE */
40
41 #undef MUST_DISABLE_SIGFPE
42
43 /* realloc does not support NULL as argument */
44 #undef NO_NULL_REALLOC
45  ])
46
47 AH_BOTTOM([
48
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 */
51       
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
65
66
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      
72
73 #if HAVE_MATH_H
74 #  include <math.h>
75 #endif
76
77 #if HAVE_FLOAT_H
78 #  include <float.h>
79 #endif
80
81 #if HAVE_IEEEFP_H
82 #  include <ieeefp.h>
83 #endif
84
85 #if HAVE_FP_CLASS_H
86 #  include <fp_class.h>
87 #endif
88
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
94
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
100
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
105
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
110
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
116
117 #if (! defined (HAVE_FINITE) && defined (HAVE_ISFINITE))
118 #  define HAVE_FINITE 1
119 #  define finite(a) isfinite(a)
120 #endif
121
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
126
127 #ifndef HAVE_FINITE
128 #error "Can't compile without finite function"
129 #endif
130
131 #ifndef HAVE_ISINF
132 #error "Can't compile without isinf function"
133 #endif
134
135 #endif /* CONFIG_H */
136 ])
137
138
139 dnl Define library subdirectory names here.
140 CGI_LIB_DIR=libraries/cgilib-0.4
141 FREETYPE_LIB_DIR=libraries/freetype-2.0.5
142 ART_LIB_DIR=libraries/libart_lgpl-2.3.7
143 PNG_LIB_DIR=libraries/libpng-1.2.0
144 ZLIB_LIB_DIR=libraries/zlib-1.1.3
145
146 dnl substitute them in all the files listed in AC_OUTPUT
147 AC_SUBST(CGI_LIB_DIR)
148 AC_SUBST(ART_LIB_DIR)
149 AC_SUBST(PNG_LIB_DIR)
150 AC_SUBST(FREETYPE_LIB_DIR)
151 AC_SUBST(ZLIB_LIB_DIR)
152 AC_SUBST(PERLFLAGS)
153
154 dnl Check for Perl.
155 AC_PATH_PROG(PERL, perl, no)
156 if test "x$PERL" = "xno"; then
157         COMP_PERL=
158 else
159         COMP_PERL="perl_piped perl_shared"
160         AC_MSG_CHECKING(for shared library extension)
161         SO_EXT=`$PERL -e 'use Config; if (defined $Config{so} and $Config{so} ne 'a') {print "$Config{so}\n"} else {print "so\n"};'`
162         AC_MSG_RESULT($SO_EXT)
163         AC_MSG_CHECKING(for the C compiler perl wants to use to build its modules)
164         PROBLEMCC=`$PERL -e 'use Config; map {if (-x "$_/$Config{cc}"){exit 0}} split /:/, $ENV{PATH};print $Config{cc}'`
165         if test x$PROBLEMCC != x; then
166                 AC_MSG_RESULT(no)
167                 echo Could not find the Compiler: '"'$PROBLEMCC'"'
168                 echo which has been used to build perl. You may have to compile
169                 echo your own copy of perl to make this work. Binary perls often
170                 echo exhibit this problem
171                 exit 1
172         else
173                 AC_MSG_RESULT(found)
174         fi
175 fi
176 AC_SUBST(COMP_PERL)
177 AC_SUBST(SO_EXT)
178
179 dnl Check for Tcl.
180 withval=""
181 AC_ARG_WITH(tcllib,[  --with-tcllib=DIR       location of the tclConfig.sh])
182 found=0
183 AC_MSG_CHECKING(for tclConfig.sh in $withval)
184 if test -f "$withval/tclConfig.sh" ; then
185         tcl_config=$withval/tclConfig.sh
186         found=1
187         AC_MSG_RESULT(yes)
188         break
189 else
190         AC_MSG_RESULT(no)
191 fi
192
193 if test $found -eq 0 ; then
194         AC_MSG_WARN([tclConfig.sh not found - Tcl interface won't be built])
195 else
196         . $tcl_config
197 fi
198
199 dnl Pass additional perl options when generating Makefile from Makefile.PL
200 # Options to pass when configuring perl module
201 AC_ARG_WITH(perl-options,
202 [  --with-perl-options=[OPTIONS]  options to pass on command-line when
203                           generating Makefile from Makefile.PL],
204 [PERL_MAKE_OPTIONS=$withval])
205 AC_SUBST(PERL_MAKE_OPTIONS)
206
207 AM_CONDITIONAL(COMP_TCL, test x$found = x1 )
208
209 AC_SUBST(TCL_PREFIX)
210 AC_SUBST(TCL_SHLIB_CFLAGS)
211 AC_SUBST(TCL_SHLIB_LD)
212 AC_SUBST(TCL_SHLIB_SUFFIX)
213 AC_SUBST(TCL_PACKAGE_PATH)
214 AC_SUBST(TCL_LD_SEARCH_FLAGS)
215
216 dnl Check for the compiler and static/shared library creation.
217 AC_PROG_CC
218 AC_PROG_CPP
219
220 dnl don't build a shared library ...
221 dnl this can be changed when running configure
222 AC_DISABLE_SHARED
223 AC_PROG_LIBTOOL
224
225 dnl Checks for header files.
226 AC_HEADER_STDC
227 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)
228
229 dnl Checks for typedefs, structures, and compiler characteristics.
230 AC_C_CONST
231 AC_HEADER_TIME
232 AC_STRUCT_TM
233
234 dnl Checks for libraries.
235 AC_CHECK_FUNC(acos, , AC_CHECK_LIB(m, acos))
236
237 dnl Check for nroff
238 AC_PATH_PROGS(NROFF, gnroff nroff)
239 AC_PATH_PROGS(TROFF, groff troff)
240
241 dnl Does the compiler like -Wall and -pedantic?
242 if test "x$GCC" = "xyes"; then
243   oCFLAGS=$CFLAGS
244   CFLAGS="$CFLAGS -Wall -pedantic -Wshadow -Wpointer-arith -Wcast-align -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline"
245   AC_CACHE_CHECK(if we can use GCC-specific compiler options, rd_cv_gcc_opt,
246                 [AC_TRY_COMPILE( , return 0 ,
247                     rd_cv_gcc_opt=yes,
248                     rd_cv_gcc_opt=no )
249                ]
250         )
251   if test $rd_cv_gcc_opt = no; then
252          CFLAGS=$oCFLAGS
253   fi
254 fi
255
256 dnl add pic flag in any case this makes sure all our code is relocatable
257 CFLAGS="$CFLAGS "`grep pic_flag= libtool | sed -e 's/.*pic_flag=//' -e 's/"//g'`
258
259 ZLIB_CFLAGS=$CFLAGS
260 dnl it seems that hpux chockes on -fPIC for some reason
261 case $target_os in
262 *hpux*)
263         ZLIB_CFLAGS=`echo $CFLAGS|sed -e 's/-fPIC/-fpic/g'`
264 ;;
265 esac
266 AC_SUBST(ZLIB_CFLAGS)
267
268 dnl Checks for library functions.
269 AC_FUNC_STRFTIME
270 AC_FUNC_VPRINTF
271
272 dnl for each function found we get a definition in config.h 
273 dnl of the form HAVE_FUNCTION
274
275 AC_CHECK_FUNCS(strerror snprintf vsnprintf fpclass class fp_class isnan memmove strchr mktime getrusage gettimeofday)
276
277 dnl HP-UX 11.00 does not have finite but does have isfinite as a macro
278 AC_CHECK_FUNCS(fpclassify, ,
279   [AC_MSG_CHECKING(for fpclassify with <math.h>)
280     AC_TRY_LINK([#include <math.h>], [float f = 0.0; fpclassify(f)],
281       AC_MSG_RESULT(yes)
282       AC_DEFINE(HAVE_FPCLASSIFY), AC_MSG_RESULT(no))])
283 AC_CHECK_FUNCS(finite, ,
284   [AC_CHECK_FUNCS(isfinite, ,
285     [AC_MSG_CHECKING(for isfinite with <math.h>)
286     AC_TRY_LINK([#include <math.h>], [float f = 0.0; isfinite(f)],
287       AC_MSG_RESULT(yes)
288       AC_DEFINE(HAVE_ISFINITE), AC_MSG_RESULT(no))])])
289 AC_CHECK_FUNCS(isinf, ,
290   [AC_MSG_CHECKING(for isinf with <math.h>)
291     AC_TRY_LINK([#include <math.h>], [float f = 0.0; isinf(f)],
292       AC_MSG_RESULT(yes)
293       AC_DEFINE(HAVE_ISINF), AC_MSG_RESULT(no))])
294
295 dnl what does realloc do if it gets called with a NULL pointer
296
297 AC_CACHE_CHECK([if realloc can deal with NULL], rd_cv_null_realloc,
298 [AC_TRY_RUN([#include <stdlib.h>
299               int main(void){
300               char *x = NULL;
301               x = realloc (x,10);
302               if (x==NULL) return 1;
303               return 0;
304              }],
305            [rd_cv_null_realloc=yes],[rd_cv_null_realloc=nope],:)])
306
307 if test x"$rd_cv_null_realloc" = xnope; then
308 AC_DEFINE(NO_NULL_REALLOC)
309 fi
310
311 dnl determine how to get IEEE math working
312 dnl AC_IEEE(MESSAGE, set rd_cv_ieee_[var] variable, INCLUDES,
313 dnl   FUNCTION-BODY, [ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]])
314
315 AC_C_BIGENDIAN
316
317 AC_DEFUN(AC_IEEE, 
318 AC_MSG_CHECKING([if IEEE math works $1])
319 AC_CACHE_VAL([rd_cv_ieee_$2],
320 [AC_TRY_RUN([$3
321
322 #if HAVE_MATH_H
323 #  include <math.h>
324 #endif
325
326 #if HAVE_FLOAT_H
327 #  include <float.h>  
328 #endif
329
330 #if HAVE_IEEEFP_H
331 #  include <ieeefp.h>
332 #endif
333
334 #if HAVE_FP_CLASS_H
335 #  include <fp_class.h>
336 #endif
337
338 /* Solaris */
339 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASS))
340 #  define HAVE_ISINF 1
341 #  define isinf(a) (fpclass(a) == FP_NINF || fpclass(a) == FP_PINF)
342 #endif
343
344 /* Digital UNIX */
345 #if (! defined(HAVE_ISINF) && defined(HAVE_FP_CLASS) && defined(HAVE_FP_CLASS_H))
346 #  define HAVE_ISINF 1
347 #  define isinf(a) (fp_class(a) == FP_NEG_INF || fp_class(a) == FP_POS_INF)
348 #endif 
349
350 /* AIX */
351 #if (! defined(HAVE_ISINF) && defined(HAVE_CLASS))
352 #  define HAVE_ISINF 1
353 #  define isinf(a) (class(a) == FP_MINUS_INF || class(a) == FP_PLUS_INF)
354 #endif
355
356 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_PLUS_INF) && defined(FP_MINUS_INF))
357 #  define HAVE_ISINF 1
358 #  define isinf(a) (fpclassify(a) == FP_MINUS_INF || fpclassify(a) == FP_PLUS_INF)
359 #endif
360
361 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_INFINITE))
362 #  define HAVE_ISINF 1
363 #  define isinf(a) (fpclassify(a) == FP_INFINITE)
364 #endif
365
366 #include <stdio.h>
367 int main(void){
368     double nan,inf,c,zero;
369     $4;
370     /* some math to see if we get a floating point exception */
371     zero=sin(0.0); /* don't let the compiler optimize us away */
372     nan=0.0/zero; /* especially here */
373     inf=1.0/zero; /* and here. I want to know if it can do the magic */
374                   /* at run time without sig fpe */
375     c = inf + nan;
376     c = inf / nan;
377     if (! isnan(nan)) {printf ("not isnan(NaN) ... "); return 1;}
378     if (nan == nan) {printf ("nan == nan ... "); return 1;}
379     if (! isinf(inf)) {printf ("not isinf(oo) ... "); return 1;}
380     if (! isinf(-inf)) {printf ("not isinf(-oo) ... "); return 1;}
381     if (! inf > 0) {printf ("not inf > 0 ... "); return 1;}
382     if (! -inf < 0) {printf ("not -inf < 0 ... "); return 1;}
383     return 0;
384  }],
385
386 rd_cv_ieee_$2=yes,
387 rd_cv_ieee_$2=no,
388 :)])
389 dnl these we run regardles is cached or not
390 if test x${rd_cv_ieee_$2} = "xyes"; then
391  AC_MSG_RESULT(yes)
392  $5
393 else
394  AC_MSG_RESULT(no)
395  $6
396 fi
397
398 )
399
400 _cflags=${CFLAGS}
401 AC_IEEE([out of the box], works, , , ,
402   [CFLAGS="$_cflags -ieee"
403   AC_IEEE([with the -ieee switch], switch, , , ,
404     [CFLAGS="$_cflags -qfloat=nofold"
405     AC_IEEE([with the -qfloat=nofold switch], nofold, , , ,
406       [CFLAGS="$_cflags -w -qflttrap=enable:zerodivide"
407       AC_IEEE([with the -w -qflttrap=enable:zerodivide], flttrap, , , ,
408        [CFLAGS="$_cflags -mieee"
409        AC_IEEE([with the -mieee switch], mswitch, , , ,
410          [CFLAGS="$_cflags -q float=rndsngl"
411          AC_IEEE([with the -q float=rndsngl switch], qswitch, , , ,
412            [CFLAGS="$_cflags -OPT:IEEE_comparisons=ON"
413            AC_IEEE([with the -OPT:IEEE_comparisons=ON switch], ieeecmpswitch, , , ,
414              [CFLAGS=$_cflags
415              AC_IEEE([with fpsetmask(0)], mask,
416                [#include <floatingpoint.h>], [fpsetmask(0)],
417                [AC_DEFINE(MUST_DISABLE_FPMASK)
418                PERLFLAGS="CCFLAGS=-DMUST_DISABLE_FPMASK"],
419                [AC_IEEE([with signal(SIGFPE,SIG_IGN)], sigfpe,
420                  [#include <signal.h>], [signal(SIGFPE,SIG_IGN)],
421                  [AC_DEFINE(MUST_DISABLE_SIGFPE)
422                  PERLFLAGS="CCFLAGS=-DMUST_DISABLE_SIGFPE"],            
423                  AC_MSG_ERROR([
424 Your Compiler does not do propper IEEE math ... Please find out how to
425 make IEEE math work with your compiler and let me know (oetiker@ee.ethz.ch).
426 Check config.log to see what went wrong ...
427 ]))])])])])])])])])
428
429
430 AC_CONFIG_FILES([examples/shared-demo.pl                        \
431           examples/piped-demo.pl                        \
432           examples/stripes.pl                           \
433           examples/bigtops.pl                           \
434           examples/minmax.pl                            \
435           examples/cgi-demo.cgi                         \
436           examples/Makefile                             \
437           doc/Makefile                                  \
438           libraries/Makefile                            \
439           libraries/cgilib-0.4/Makefile                 \
440           libraries/libart_lgpl-2.3.7/Makefile          \
441           libraries/libpng-1.2.0/Makefile               \
442           libraries/zlib-1.1.3/Makefile                 \
443           libraries/freetype-2.0.5/Makefile             \
444           src/Makefile                                  \
445           bindings/Makefile                             \
446           bindings/tcl/Makefile                         \
447           Makefile])
448 AC_CONFIG_COMMANDS([default],[[\
449           chmod +x examples/*.cgi examples/*.pl]],[[]])
450 AC_OUTPUT
451
452 AC_MSG_CHECKING(in)
453 AC_MSG_RESULT(and out again)
454
455 echo $ECHO_N "ordering CD from http://ee-staff.ethz.ch/~oetiker/wish $ECHO_C" 1>&6
456 sleep 1
457 echo $ECHO_N ".$ECHO_C" 1>&6
458 sleep 1
459 echo $ECHO_N ".$ECHO_C" 1>&6
460 sleep 1
461 echo $ECHO_N ".$ECHO_C" 1>&6
462 sleep 1
463 echo $ECHO_N ".$ECHO_C" 1>&6
464 sleep 1
465 AC_MSG_RESULT([ just kidding ;-)])
466 echo
467 echo "----------------------------------------------------------------"
468 echo "Config is DONE!"
469 echo
470 echo "Type 'make' to compile the software and use 'make install' to "
471 echo "install everything to: $prefix."
472 echo
473 echo "If you want to install the perl"
474 echo "modules in site-perl, try 'make site-perl-install'."
475 echo 
476 echo "       ... that wishlist is NO JOKE. If you find RRDtool useful"
477 echo "make me happy. Go to http://ee-staff.ethz.ch/~oetiker/wish and"
478 echo "place an order."
479 echo 
480 echo "                               -- Tobi Oetiker <tobi@oetiker.ch>"
481 echo "----------------------------------------------------------------"