Find attached the patch I promised to send to you. Please note that there
[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=cgilib-0.4
141 FREETYPE_LIB_DIR=freetype-2.0.5
142 ART_LIB_DIR=libart_lgpl-2.3.7
143 PNG_LIB_DIR=libpng-1.2.0
144 ZLIB_LIB_DIR=zlib-1.1.4
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 INCLUDED_LIB(cgi,cgiInit)
155 INCLUDED_LIB(art_lgpl,art_vpath_add_point)
156 INCLUDED_LIB(png,png_access_version_number)
157 INCLUDED_LIB(freetype,FT_Init_FreeType)
158 INCLUDED_LIB(z,zlibVersion)
159
160 dnl Check for Perl.
161 AC_PATH_PROG(PERL, perl, no)
162 if test "x$PERL" = "xno"; then
163         COMP_PERL=
164 else
165         COMP_PERL="perl_piped perl_shared"
166         AC_MSG_CHECKING(for shared library extension)
167         SO_EXT=`$PERL -e 'use Config; if (defined $Config{so} and $Config{so} ne 'a') {print "$Config{so}\n"} else {print "so\n"};'`
168         AC_MSG_RESULT($SO_EXT)
169         AC_MSG_CHECKING(for the C compiler perl wants to use to build its modules)
170         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}'`
171         if test x$PROBLEMCC != x; then
172                 AC_MSG_RESULT(no)
173                 echo Could not find the Compiler: '"'$PROBLEMCC'"'
174                 echo which has been used to build perl. You may have to compile
175                 echo your own copy of perl to make this work. Binary perls often
176                 echo exhibit this problem
177                 exit 1
178         else
179                 AC_MSG_RESULT(found)
180         fi
181 fi
182 AC_SUBST(COMP_PERL)
183 AC_SUBST(SO_EXT)
184
185 dnl Check for Tcl.
186 withval=""
187 AC_ARG_WITH(tcllib,[  --with-tcllib=DIR       location of the tclConfig.sh])
188 found=0
189 AC_MSG_CHECKING(for tclConfig.sh in $withval)
190 if test -f "$withval/tclConfig.sh" ; then
191         tcl_config=$withval/tclConfig.sh
192         found=1
193         AC_MSG_RESULT(yes)
194         break
195 else
196         AC_MSG_RESULT(no)
197 fi
198
199 if test $found -eq 0 ; then
200         AC_MSG_WARN([tclConfig.sh not found - Tcl interface won't be built])
201 else
202         . $tcl_config
203 fi
204
205 dnl Pass additional perl options when generating Makefile from Makefile.PL
206 # Options to pass when configuring perl module
207 AC_ARG_WITH(perl-options,
208 [  --with-perl-options=[OPTIONS]  options to pass on command-line when
209                           generating Makefile from Makefile.PL],
210 [PERL_MAKE_OPTIONS=$withval])
211 AC_SUBST(PERL_MAKE_OPTIONS)
212
213 AM_CONDITIONAL(COMP_TCL, test x$found = x1 )
214
215 AC_SUBST(TCL_PREFIX)
216 AC_SUBST(TCL_SHLIB_CFLAGS)
217 AC_SUBST(TCL_SHLIB_LD)
218 AC_SUBST(TCL_SHLIB_SUFFIX)
219 AC_SUBST(TCL_PACKAGE_PATH)
220 AC_SUBST(TCL_LD_SEARCH_FLAGS)
221
222 dnl Check for the compiler and static/shared library creation.
223 AC_PROG_CC
224 AC_PROG_CPP
225
226 dnl don't build a shared library ...
227 dnl this can be changed when running configure
228 AC_DISABLE_SHARED
229 AC_PROG_LIBTOOL
230
231 dnl Checks for header files.
232 AC_HEADER_STDC
233 AC_HEADER_DIRENT
234 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)
235
236 dnl Checks for typedefs, structures, and compiler characteristics.
237 AC_C_CONST
238 AC_HEADER_TIME
239 AC_STRUCT_TM
240
241 dnl Checks for libraries.
242 AC_CHECK_FUNC(acos, , AC_CHECK_LIB(m, acos))
243
244 dnl Check for nroff
245 AC_PATH_PROGS(NROFF, gnroff nroff)
246 AC_PATH_PROGS(TROFF, groff troff)
247
248 dnl Does the compiler like -Wall and -pedantic?
249 if test "x$GCC" = "xyes"; then
250   oCFLAGS=$CFLAGS
251   CFLAGS="$CFLAGS -Wall -pedantic -Wshadow -Wpointer-arith -Wcast-align -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -W"
252   AC_CACHE_CHECK(if we can use GCC-specific compiler options, rd_cv_gcc_opt,
253                 [AC_TRY_COMPILE( , return 0 ,
254                     rd_cv_gcc_opt=yes,
255                     rd_cv_gcc_opt=no )
256                ]
257         )
258   if test $rd_cv_gcc_opt = no; then
259          CFLAGS=$oCFLAGS
260   fi
261 fi
262
263 dnl add pic flag in any case this makes sure all our code is relocatable
264 CFLAGS="$CFLAGS "`grep pic_flag= libtool | sed -e 's/.*pic_flag=//' -e 's/"//g'`
265
266 ZLIB_CFLAGS=$CFLAGS
267 dnl it seems that hpux chockes on -fPIC for some reason
268 case $target_os in
269 *hpux*)
270         ZLIB_CFLAGS=`echo $CFLAGS|sed -e 's/-fPIC/-fpic/g'`
271 ;;
272 esac
273 AC_SUBST(ZLIB_CFLAGS)
274
275 dnl Checks for library functions.
276 AC_FUNC_STRFTIME
277 AC_FUNC_VPRINTF
278
279 dnl for each function found we get a definition in config.h 
280 dnl of the form HAVE_FUNCTION
281
282 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)
283
284 dnl HP-UX 11.00 does not have finite but does have isfinite as a macro
285 AC_CHECK_FUNCS(fpclassify, ,
286   [AC_MSG_CHECKING(for fpclassify with <math.h>)
287     AC_TRY_LINK([#include <math.h>], [float f = 0.0; fpclassify(f)],
288       AC_MSG_RESULT(yes)
289       AC_DEFINE(HAVE_FPCLASSIFY), AC_MSG_RESULT(no))])
290 AC_CHECK_FUNCS(finite, ,
291   [AC_CHECK_FUNCS(isfinite, ,
292     [AC_MSG_CHECKING(for isfinite with <math.h>)
293     AC_TRY_LINK([#include <math.h>], [float f = 0.0; isfinite(f)],
294       AC_MSG_RESULT(yes)
295       AC_DEFINE(HAVE_ISFINITE), AC_MSG_RESULT(no))])])
296 AC_CHECK_FUNCS(isinf, ,
297   [AC_MSG_CHECKING(for isinf with <math.h>)
298     AC_TRY_LINK([#include <math.h>], [float f = 0.0; isinf(f)],
299       AC_MSG_RESULT(yes)
300       AC_DEFINE(HAVE_ISINF), AC_MSG_RESULT(no))])
301
302 dnl what does realloc do if it gets called with a NULL pointer
303
304 AC_CACHE_CHECK([if realloc can deal with NULL], rd_cv_null_realloc,
305 [AC_TRY_RUN([#include <stdlib.h>
306               int main(void){
307               char *x = NULL;
308               x = realloc (x,10);
309               if (x==NULL) return 1;
310               return 0;
311              }],
312            [rd_cv_null_realloc=yes],[rd_cv_null_realloc=nope],:)])
313
314 if test x"$rd_cv_null_realloc" = xnope; then
315 AC_DEFINE(NO_NULL_REALLOC)
316 fi
317
318 dnl determine how to get IEEE math working
319 dnl AC_IEEE(MESSAGE, set rd_cv_ieee_[var] variable, INCLUDES,
320 dnl   FUNCTION-BODY, [ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]])
321
322 AC_C_BIGENDIAN
323
324 AC_DEFUN(AC_IEEE, 
325 AC_MSG_CHECKING([if IEEE math works $1])
326 AC_CACHE_VAL([rd_cv_ieee_$2],
327 [AC_TRY_RUN([$3
328
329 #if HAVE_MATH_H
330 #  include <math.h>
331 #endif
332
333 #if HAVE_FLOAT_H
334 #  include <float.h>  
335 #endif
336
337 #if HAVE_IEEEFP_H
338 #  include <ieeefp.h>
339 #endif
340
341 #if HAVE_FP_CLASS_H
342 #  include <fp_class.h>
343 #endif
344
345 /* Solaris */
346 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASS))
347 #  define HAVE_ISINF 1
348 #  define isinf(a) (fpclass(a) == FP_NINF || fpclass(a) == FP_PINF)
349 #endif
350
351 /* Digital UNIX */
352 #if (! defined(HAVE_ISINF) && defined(HAVE_FP_CLASS) && defined(HAVE_FP_CLASS_H))
353 #  define HAVE_ISINF 1
354 #  define isinf(a) (fp_class(a) == FP_NEG_INF || fp_class(a) == FP_POS_INF)
355 #endif 
356
357 /* AIX */
358 #if (! defined(HAVE_ISINF) && defined(HAVE_CLASS))
359 #  define HAVE_ISINF 1
360 #  define isinf(a) (class(a) == FP_MINUS_INF || class(a) == FP_PLUS_INF)
361 #endif
362
363 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_PLUS_INF) && defined(FP_MINUS_INF))
364 #  define HAVE_ISINF 1
365 #  define isinf(a) (fpclassify(a) == FP_MINUS_INF || fpclassify(a) == FP_PLUS_INF)
366 #endif
367
368 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_INFINITE))
369 #  define HAVE_ISINF 1
370 #  define isinf(a) (fpclassify(a) == FP_INFINITE)
371 #endif
372
373 #include <stdio.h>
374 int main(void){
375     double nan,inf,c,zero;
376     $4;
377     /* some math to see if we get a floating point exception */
378     zero=sin(0.0); /* don't let the compiler optimize us away */
379     nan=0.0/zero; /* especially here */
380     inf=1.0/zero; /* and here. I want to know if it can do the magic */
381                   /* at run time without sig fpe */
382     c = inf + nan;
383     c = inf / nan;
384     if (! isnan(nan)) {printf ("not isnan(NaN) ... "); return 1;}
385     if (nan == nan) {printf ("nan == nan ... "); return 1;}
386     if (! isinf(inf)) {printf ("not isinf(oo) ... "); return 1;}
387     if (! isinf(-inf)) {printf ("not isinf(-oo) ... "); return 1;}
388     if (! inf > 0) {printf ("not inf > 0 ... "); return 1;}
389     if (! -inf < 0) {printf ("not -inf < 0 ... "); return 1;}
390     return 0;
391  }],
392
393 rd_cv_ieee_$2=yes,
394 rd_cv_ieee_$2=no,
395 :)])
396 dnl these we run regardles is cached or not
397 if test x${rd_cv_ieee_$2} = "xyes"; then
398  AC_MSG_RESULT(yes)
399  $5
400 else
401  AC_MSG_RESULT(no)
402  $6
403 fi
404
405 )
406
407 _cflags=${CFLAGS}
408 AC_IEEE([out of the box], works, , , ,
409   [CFLAGS="$_cflags -ieee"
410   AC_IEEE([with the -ieee switch], switch, , , ,
411     [CFLAGS="$_cflags -qfloat=nofold"
412     AC_IEEE([with the -qfloat=nofold switch], nofold, , , ,
413       [CFLAGS="$_cflags -w -qflttrap=enable:zerodivide"
414       AC_IEEE([with the -w -qflttrap=enable:zerodivide], flttrap, , , ,
415        [CFLAGS="$_cflags -mieee"
416        AC_IEEE([with the -mieee switch], mswitch, , , ,
417          [CFLAGS="$_cflags -q float=rndsngl"
418          AC_IEEE([with the -q float=rndsngl switch], qswitch, , , ,
419            [CFLAGS="$_cflags -OPT:IEEE_NaN_inf=ON"
420            AC_IEEE([with the -OPT:IEEE_NaN_inf=ON switch], ieeenaninfswitch, , , ,
421              [CFLAGS="$_cflags -OPT:IEEE_comparisons=ON"
422              AC_IEEE([with the -OPT:IEEE_comparisons=ON switch], ieeecmpswitch, , , ,
423                [CFLAGS=$_cflags
424                AC_IEEE([with fpsetmask(0)], mask,
425                  [#include <floatingpoint.h>], [fpsetmask(0)],
426                  [AC_DEFINE(MUST_DISABLE_FPMASK)
427                  PERLFLAGS="CCFLAGS=-DMUST_DISABLE_FPMASK"],
428                  [AC_IEEE([with signal(SIGFPE,SIG_IGN)], sigfpe,
429                    [#include <signal.h>], [signal(SIGFPE,SIG_IGN)],
430                    [AC_DEFINE(MUST_DISABLE_SIGFPE)
431                    PERLFLAGS="CCFLAGS=-DMUST_DISABLE_SIGFPE"],          
432                    AC_MSG_ERROR([
433 Your Compiler does not do propper IEEE math ... Please find out how to
434 make IEEE math work with your compiler and let me know (oetiker@ee.ethz.ch).
435 Check config.log to see what went wrong ...
436 ]))])])])])])])])])])
437
438
439 AC_CONFIG_FILES([examples/shared-demo.pl                        \
440           examples/piped-demo.pl                        \
441           examples/stripes.pl                           \
442           examples/bigtops.pl                           \
443           examples/minmax.pl                            \
444           examples/cgi-demo.cgi                         \
445           examples/Makefile                             \
446           doc/Makefile                                  \
447           libraries/Makefile                            \
448           libraries/cgilib-0.4/Makefile                 \
449           libraries/libart_lgpl-2.3.7/Makefile          \
450           libraries/libpng-1.2.0/Makefile               \
451           libraries/zlib-1.1.4/Makefile                 \
452           libraries/freetype-2.0.5/Makefile             \
453           libraries/afm/Makefile                        \
454           src/Makefile                                  \
455           bindings/Makefile                             \
456           bindings/tcl/Makefile                         \
457           Makefile])
458 AC_CONFIG_COMMANDS([default],[[\
459           chmod +x examples/*.cgi examples/*.pl]],[[]])
460 AC_OUTPUT
461
462 AC_MSG_CHECKING(in)
463 AC_MSG_RESULT(and out again)
464
465 echo $ECHO_N "ordering CD from http://people.ee.ethz.ch/~oetiker/wish $ECHO_C" 1>&6
466 sleep 1
467 echo $ECHO_N ".$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 AC_MSG_RESULT([ just kidding ;-)])
476 echo
477 echo "----------------------------------------------------------------"
478 echo "Config is DONE!"
479 echo
480 echo "Type 'make' to compile the software and use 'make install' to "
481 echo "install everything to: $prefix."
482 echo
483 echo "If you want to install the perl"
484 echo "modules in site-perl, try 'make site-perl-install'."
485 echo 
486 echo "       ... that wishlist is NO JOKE. If you find RRDtool useful"
487 echo "make me happy. Go to http://people.ee.ethz.ch/~oetiker/wish and"
488 echo "place an order."
489 echo 
490 echo "                               -- Tobi Oetiker <tobi@oetiker.ch>"
491 echo "----------------------------------------------------------------"