Fixed ln for modules
[rrdtool.git] / configure.in
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 make sure we are being executed in the right place
9 AC_INIT(src/rrd_tool.c)
10
11 dnl all our local stuff like install scripts and include files
12 dnl is in there
13 AC_CONFIG_AUX_DIR(config)
14
15 dnl determine the type of system we are running on
16 AC_CANONICAL_SYSTEM
17
18 dnl tell automake the this script is for rrdtool
19 AM_INIT_AUTOMAKE(rrdtool, 1.0.33)
20 AC_SUBST(VERSION)
21
22 dnl where we install our stuff ...
23 AC_PREFIX_DEFAULT( /usr/local/rrdtool-1.0.33 )
24
25 dnl tell automake which file to use as config header
26 AM_CONFIG_HEADER(config/config.h)
27
28 dnl Minimum Autoconf version required.
29 AC_PREREQ(2.13)
30
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
36
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)
43
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 fi
54 AC_SUBST(COMP_PERL)
55 AC_SUBST(SO_EXT)
56
57 dnl Check for Tcl.
58 withval=""
59 AC_ARG_WITH(tcllib,[  --with-tcllib=DIR       location of the tclConfig.sh])
60 found=0
61 AC_MSG_CHECKING(for tclConfig.sh in $withval)
62 if test -f "$withval/tclConfig.sh" ; then
63         tcl_config=$withval/tclConfig.sh
64         found=1
65         AC_MSG_RESULT(yes)
66         break
67 else
68         AC_MSG_RESULT(no)
69 fi
70
71 if test $found -eq 0 ; then
72         AC_MSG_WARN([tclConfig.sh not found - Tcl interface won't be built])
73 else
74         . $tcl_config
75 fi
76
77 dnl Pass additional perl options when generating Makefile from Makefile.PL
78 # Options to pass when configuring perl module
79 AC_ARG_WITH(perl-options,
80 [  --with-perl-options=[OPTIONS]  options to pass on command-line when
81                           generating Makefile from Makefile.PL],
82 [PERL_MAKE_OPTIONS=$withval])
83 AC_SUBST(PERL_MAKE_OPTIONS)
84
85 AM_CONDITIONAL(COMP_TCL, test x$found = x1 )
86
87 AC_SUBST(TCL_PREFIX)
88 AC_SUBST(TCL_SHLIB_CFLAGS)
89 AC_SUBST(TCL_SHLIB_LD)
90 AC_SUBST(TCL_SHLIB_SUFFIX)
91 AC_SUBST(TCL_PACKAGE_PATH)
92 AC_SUBST(TCL_LD_SEARCH_FLAGS)
93
94 dnl Check for the compiler and static/shared library creation.
95 AC_PROG_CC
96 AC_PROG_CPP
97 dnl RRD_ACLOCAL_FIND_LIBTOOL
98
99 dnl don't build a shared library ...
100 dnl this can be changed when running configure
101 AC_DISABLE_SHARED
102
103 AM_PROG_LIBTOOL
104
105 dnl Checks for header files.
106 AC_HEADER_STDC
107 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)
108
109 dnl Checks for typedefs, structures, and compiler characteristics.
110 AC_C_CONST
111 AC_HEADER_TIME
112 AC_STRUCT_TM
113
114 dnl Checks for libraries.
115 AC_CHECK_FUNC(acos, , AC_CHECK_LIB(m, acos))
116
117 dnl Check for nroff
118 AC_PATH_PROGS(NROFF, gnroff nroff)
119 AC_PATH_PROGS(TROFF, groff troff)
120
121 dnl Does the compiler like -Wall and -pedantic?
122 if test "x$GCC" = "xyes"; then
123   oCFLAGS=$CFLAGS
124   CFLAGS="$CFLAGS -Wall -pedantic -Wshadow -Wpointer-arith -Wcast-align -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline"
125   AC_CACHE_CHECK(if we can use GCC-specific compiler options, rd_cv_gcc_opt,
126                 [AC_TRY_COMPILE( , return 0 ,
127                     rd_cv_gcc_opt=yes,
128                     rd_cv_gcc_opt=no )
129                ]
130         )
131   if test $rd_cv_gcc_opt = no; then
132          CFLAGS=$oCFLAGS
133   fi
134 fi
135
136 dnl add pic flag in any case this makes sure all our code is relocatable
137 CFLAGS="$CFLAGS "`grep pic_flag= libtool | sed -e 's/.*pic_flag=//' -e 's/"//g'`
138
139 dnl it seems that hpux chockes on -fPIC for some reason
140 case $target_os in
141 *hpux*)
142         CLFAGS=`echo $CFLAGS|sed -e 's/-fPIC/-fpic/g'`
143 ;;
144 esac
145
146 dnl Checks for library functions.
147 AC_FUNC_STRFTIME
148 AC_FUNC_VPRINTF
149
150 dnl for each function found we get a definition in config.h 
151 dnl of the form HAVE_FUNCTION
152
153 AC_CHECK_FUNCS(strerror snprintf vsnprintf fpclass class fp_class isnan memmove strchr mktime getrusage gettimeofday)
154
155 dnl HP-UX 11.00 does not have finite but does have isfinite as a macro
156 AC_CHECK_FUNCS(fpclassify, ,
157   [AC_MSG_CHECKING(for fpclassify with <math.h>)
158     AC_TRY_LINK([#include <math.h>], [float f = 0.0; fpclassify(f)],
159       AC_MSG_RESULT(yes)
160       AC_DEFINE(HAVE_FPCLASSIFY), AC_MSG_RESULT(no))])
161 AC_CHECK_FUNCS(finite, ,
162   [AC_CHECK_FUNCS(isfinite, ,
163     [AC_MSG_CHECKING(for isfinite with <math.h>)
164     AC_TRY_LINK([#include <math.h>], [float f = 0.0; isfinite(f)],
165       AC_MSG_RESULT(yes)
166       AC_DEFINE(HAVE_ISFINITE), AC_MSG_RESULT(no))])])
167 AC_CHECK_FUNCS(isinf, ,
168   [AC_MSG_CHECKING(for isinf with <math.h>)
169     AC_TRY_LINK([#include <math.h>], [float f = 0.0; isinf(f)],
170       AC_MSG_RESULT(yes)
171       AC_DEFINE(HAVE_ISINF), AC_MSG_RESULT(no))])
172
173 dnl what does realloc do if it gets called with a NULL pointer
174
175 AC_CACHE_CHECK([if realloc can deal with NULL], rd_cv_null_realloc,
176 [AC_TRY_RUN([#include <stdlib.h>
177               int main(void){
178               char *x = NULL;
179               x = realloc (x,10);
180               if (x==NULL) return 1;
181               return 0;
182              }],
183            [rd_cv_null_realloc=yes],[rd_cv_null_realloc=nope],:)])
184
185 if test x"$rd_cv_null_realloc" = xnope; then
186 AC_DEFINE(NO_NULL_REALLOC)
187 fi
188
189 dnl determine how to get IEEE math working
190 dnl AC_IEEE(MESSAGE, set rd_cv_ieee_[var] variable, INCLUDES,
191 dnl   FUNCTION-BODY, [ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]])
192
193 AC_DEFUN(AC_IEEE, 
194 AC_MSG_CHECKING([if IEEE math works $1])
195 AC_CACHE_VAL([rd_cv_ieee_$2],
196 [AC_TRY_RUN([$3
197
198 #if HAVE_MATH_H
199 #  include <math.h>
200 #endif
201
202 #if HAVE_FLOAT_H
203 #  include <float.h>  
204 #endif
205
206 #if HAVE_IEEEFP_H
207 #  include <ieeefp.h>
208 #endif
209
210 #if HAVE_FP_CLASS_H
211 #  include <fp_class.h>
212 #endif
213
214 /* Solaris */
215 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASS))
216 #  define HAVE_ISINF 1
217 #  define isinf(a) (fpclass(a) == FP_NINF || fpclass(a) == FP_PINF)
218 #endif
219
220 /* Digital UNIX */
221 #if (! defined(HAVE_ISINF) && defined(HAVE_FP_CLASS) && defined(HAVE_FP_CLASS_H))
222 #  define HAVE_ISINF 1
223 #  define isinf(a) (fp_class(a) == FP_NEG_INF || fp_class(a) == FP_POS_INF)
224 #endif 
225
226 /* AIX */
227 #if (! defined(HAVE_ISINF) && defined(HAVE_CLASS))
228 #  define HAVE_ISINF 1
229 #  define isinf(a) (class(a) == FP_MINUS_INF || class(a) == FP_PLUS_INF)
230 #endif
231
232 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_PLUS_INF) && defined(FP_MINUS_INF))
233 #  define HAVE_ISINF 1
234 #  define isinf(a) (fpclassify(a) == FP_MINUS_INF || fpclassify(a) == FP_PLUS_INF)
235 #endif
236
237 #if (! defined(HAVE_ISINF) && defined(HAVE_FPCLASSIFY) && defined(FP_INFINITE))
238 #  define HAVE_ISINF 1
239 #  define isinf(a) (fpclassify(a) == FP_INFINITE)
240 #endif
241
242 #include <stdio.h>
243 int main(void){
244     double nan,inf,c,zero;
245     $4;
246     /* some math to see if we get a floating point exception */
247     zero=sin(0.0); /* don't let the compiler optimize us away */
248     nan=0.0/zero; /* especially here */
249     inf=1.0/zero; /* and here. I want to know if it can do the magic */
250                   /* at run time without sig fpe */
251     c = inf + nan;
252     c = inf / nan;
253     if (! isnan(nan)) {printf ("not isnan(NaN) ... "); return 1;}
254     if (nan == nan) {printf ("nan == nan ... "); return 1;}
255     if (! isinf(inf)) {printf ("not isinf(oo) ... "); return 1;}
256     if (! isinf(-inf)) {printf ("not isinf(-oo) ... "); return 1;}
257     if (! inf > 0) {printf ("not inf > 0 ... "); return 1;}
258     if (! -inf < 0) {printf ("not -inf < 0 ... "); return 1;}
259     return 0;
260  }],
261
262 rd_cv_ieee_$2=yes,
263 rd_cv_ieee_$2=no,
264 :)])
265 dnl these we run regardles is cached or not
266 if test x${rd_cv_ieee_$2} = "xyes"; then
267  AC_MSG_RESULT(yes)
268  $5
269 else
270  AC_MSG_RESULT(no)
271  $6
272 fi
273
274 )
275
276 _cflags=${CFLAGS}
277 AC_IEEE([out of the box], works, , , ,
278   [CFLAGS="$_cflags -ieee"
279   AC_IEEE([with the -ieee switch], switch, , , ,
280     [CFLAGS="$_cflags -qfloat=nofold"
281     AC_IEEE([with the -qfloat=nofold switch], nofold, , , ,
282       [CFLAGS="$_cflags -w -qflttrap=enable:zerodivide"
283       AC_IEEE([with the -w -qflttrap=enable:zerodivide], flttrap, , , ,
284        [CFLAGS="$_cflags -mieee"
285        AC_IEEE([with the -mieee switch], mswitch, , , ,
286          [CFLAGS="$_cflags -q float=rndsngl"
287          AC_IEEE([with the -q float=rndsngl switch], qswitch, , , ,
288            [CFLAGS="$_cflags -OPT:IEEE_comparisons=ON"
289            AC_IEEE([with the -OPT:IEEE_comparisons=ON switch], ieeecmpswitch, , , ,
290              [CFLAGS=$_cflags
291              AC_IEEE([with fpsetmask(0)], mask,
292                [#include <floatingpoint.h>], [fpsetmask(0)],
293                [AC_DEFINE(MUST_DISABLE_FPMASK)
294                PERLFLAGS="CCFLAGS=-DMUST_DISABLE_FPMASK"],
295                [AC_IEEE([with signal(SIGFPE,SIG_IGN)], sigfpe,
296                  [#include <signal.h>], [signal(SIGFPE,SIG_IGN)],
297                  [AC_DEFINE(MUST_DISABLE_SIGFPE)
298                  PERLFLAGS="CCFLAGS=-DMUST_DISABLE_SIGFPE"],            
299                  AC_MSG_ERROR([
300 Your Compiler does not do propper IEEE math ... Please find out how to
301 make IEEE math work with your compiler and let me know (oetiker@ee.ethz.ch).
302 Check config.log to see what went wrong ...
303 ]))])])])])])])])])
304
305
306 AC_OUTPUT(examples/shared-demo.pl                       \
307           examples/piped-demo.pl                        \
308           examples/stripes.pl                           \
309           examples/bigtops.pl                           \
310           examples/minmax.pl                            \
311           examples/cgi-demo.cgi                         \
312           examples/Makefile                             \
313           doc/Makefile                                  \
314           libraries/Makefile                            \
315           libraries/cgilib-0.4/Makefile                 \
316           libraries/gd1.3/Makefile                      \
317           libraries/libpng-1.0.9/Makefile               \
318           libraries/zlib-1.1.3/Makefile                 \
319           src/Makefile                                  \
320           bindings/Makefile                             \
321           bindings/tcl/Makefile                         \
322           Makefile,                                     \
323           [chmod +x examples/*.cgi examples/*.pl])
324
325 AC_MSG_CHECKING(in)
326 AC_MSG_RESULT(and out again)
327
328 echo $ac_n "ordering CD from http://ee-staff.ethz.ch/~oetiker/wish $ac_c" 1>&6
329 sleep 1
330 echo $ac_n ".$ac_c" 1>&6
331 sleep 1
332 echo $ac_n ".$ac_c" 1>&6
333 sleep 1
334 echo $ac_n ".$ac_c" 1>&6
335 sleep 1
336 echo $ac_n ".$ac_c" 1>&6
337 sleep 1
338 AC_MSG_RESULT([ just kidding ;-)])
339 echo
340 echo "----------------------------------------------------------------"
341 echo "Config is DONE!"
342 echo
343 echo "Type 'make' to compile the software and use 'make install' to "
344 echo "install everything to: $prefix."
345 echo
346 echo "If you want to install the perl"
347 echo "modules in site-perl, try 'make site-perl-install'."
348 echo 
349 echo "       ... that wishlist is NO JOKE. If you find RRDtool useful"
350 echo "make me happy. Go to http://ee-staff.ethz.ch/~oetiker/wish and"
351 echo "place an order."
352 echo 
353 echo "                               -- Tobi Oetiker <tobi@oetiker.ch>"
354 echo "----------------------------------------------------------------"