-dnl add pic flag in any case this makes sure all our code is relocatable
-CFLAGS="$CFLAGS "`grep pic_flag= libtool | head -1|sed -e 's/.*pic_flag=//' -e 's/"//g'`
-dnl" make joes highliter happy it does not grasp the quote in the line above
-
-ZLIB_CFLAGS=$CFLAGS
-dnl it seems that hpux chockes on -fPIC for some reason
-case $target_os in
-*hpux*)
- ZLIB_CFLAGS=`echo $CFLAGS|sed -e 's/-fPIC/-fpic/g'`
-;;
-esac
-AC_SUBST(ZLIB_CFLAGS)
-
-dnl Checks for library functions.
-AC_FUNC_STRFTIME
-AC_FUNC_VPRINTF
-
-dnl for each function found we get a definition in config.h
-dnl of the form HAVE_FUNCTION
-
-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)
-
-dnl HP-UX 11.00 does not have finite but does have isfinite as a macro
-AC_CHECK_FUNCS(fpclassify, ,
- [AC_MSG_CHECKING(for fpclassify with <math.h>)
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]], [[float f = 0.0; fpclassify(f)]])],[AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_FPCLASSIFY)],[AC_MSG_RESULT(no)])])
-AC_CHECK_FUNCS(finite, ,
- [AC_CHECK_FUNCS(isfinite, ,
- [AC_MSG_CHECKING(for isfinite with <math.h>)
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]], [[float f = 0.0; isfinite(f)]])],[AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_ISFINITE)],[AC_MSG_RESULT(no)])])])
-AC_CHECK_FUNCS(isinf, ,
- [AC_MSG_CHECKING(for isinf with <math.h>)
- AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]], [[float f = 0.0; isinf(f)]])],[AC_MSG_RESULT(yes)
- AC_DEFINE(HAVE_ISINF)],[AC_MSG_RESULT(no)])])
-
-dnl what does realloc do if it gets called with a NULL pointer
+dnl pass additional ruby options when generating Makefile from Makefile.PL
+AC_ARG_ENABLE(ruby-site-install,
+[ --enable-ruby-site-install by default the rrdtool ruby modules are installed
+ together with rrdtool in $prefix/lib/ruby. You have to
+ add $prefix/lib/ruby/$ruby_version/$sitearch to your $: variable
+ for ruby to find the RRD.so file.],
+[RUBY_MAKE_OPTIONS=],[RUBY_MAKE_OPTIONS="sitedir=$langpref/lib/ruby"])
+
+
+AC_ARG_WITH(ruby-options,
+[ --with-ruby-options=[OPTIONS] options to pass on command-line when
+ generating Makefile from extconf.rb. If you set this
+ option, interesting things may happen unless you know
+ what you are doing!],
+[RUBY_MAKE_OPTIONS=$withval])
+
+AC_SUBST(RUBY_MAKE_OPTIONS)
+AC_SUBST(RUBY)
+AC_SUBST(COMP_RUBY)
+
+dnl Check for Lua.
+AC_PATH_PROG(LUA, lua, no)
+
+AC_ARG_ENABLE(lua,[ --disable-lua do not build the lua modules],
+[],[enable_lua=yes])
+
+COMP_LUA=
+if test "$LUA" = "no" -o "$enable_lua" = "no"; then
+ enable_lua=no
+else
+ AC_MSG_CHECKING(for lua >= 5.0)
+ read LUA_MAJOR LUA_MINOR LUA_POINT <<LUA_EOF
+ $($LUA -v 2>&1 | cut -f2 -d' ' | sed -e 's/\./ /g')
+LUA_EOF
+ if test 0$LUA_MAJOR -lt 5; then
+ AC_MSG_RESULT([no, version found is $LUA_MAJOR.$LUA_MINOR])
+ else
+ AC_MSG_RESULT([$LUA_MAJOR.$LUA_MINOR found])
+ vdot=$LUA_MAJOR.$LUA_MINOR
+ vndot=$LUA_MAJOR$LUA_MINOR
+ lua_version=$LUA_MAJOR.$LUA_MINOR.$LUA_POINT
+ AC_CHECK_HEADERS(lua$vndot/lua.h,
+ [AC_CHECK_HEADERS(lua$vndot/lualib.h,
+ [AC_CHECK_HEADER(lua$vndot/lauxlib.h,
+ [lua_headerdir=lua$vndot],
+ [])],
+ [])],
+ [AC_CHECK_HEADERS(lua$vdot/lua.h,
+ [AC_CHECK_HEADERS(lua$vdot/lualib.h,
+ [AC_CHECK_HEADER(lua$vdot/lauxlib.h,
+ [lua_headerdir=lua$vdot],
+ [])],
+ [])],
+ [AC_CHECK_HEADERS(lua.h,
+ [AC_CHECK_HEADERS(lualib.h,
+ [AC_CHECK_HEADER(lauxlib.h,
+ [lua_headerdir=""],
+ [lua_headerdir="no"])],
+ [])],
+ [])])])
+
+ if test "$lua_headerdir" = "no"; then
+ enable_lua=no
+ else
+ COMP_LUA=lua
+ fi
+
+ if test "$COMP_LUA" != "lua"; then
+ enable_lua=no
+ AC_MSG_WARN([Lua $vdot found but not lua.h, lualib.h and lauxlib.h! Please install the -dev packages for Lua $vdot])
+ else
+ # OK, headers found, let's check the libraries (LIBS is not used)
+ LIBS=
+ lua_havelib=no
+ LUA_HAVE_COMPAT51=DONT_HAVE_COMPAT51
+ AC_SEARCH_LIBS(lua_call, lua$vdot lua$vndot lua,
+ [AC_SEARCH_LIBS(luaL_register, lua$vdot lua$vndot lua,
+ [lua_havelib=LUA$vndot],
+ [AC_SEARCH_LIBS(luaL_module, lualib$vndot lualib$vdot lualib,
+ [lua_havelib=$vndot ;
+ AC_CHECK_HEADERS(lua$vndot/compat-5.1.h,
+ [LUA_HAVE_COMPAT51=HAVE_COMPAT51], [],
+ [[#include <lua$vndot/lua.h>
+ #include <lua$vndot/lauxlib.h> ]])],
+ [AC_SEARCH_LIBS(luaL_openlib, lualib$vdot lualib$vndot lualib,
+ [lua_havelib=$vndot],
+ [COMP_LUA=], [-lm])], [-lm])], [-lm])],
+ [COMP_LUA=], [-lm])
+ lua_libs=$LIBS
+ LIBS=
+
+ # Options to pass when configuring Lua module
+ if test "$lua_havelib" != "no"; then
+ # OK, headers and libs found
+ # try to set lua include, lib and C installation dirs with pkg-config
+ if test "$PKGCONFIG" != "no"; then
+ if test "$vndot" = "50"; then
+ lua_pkg_prefix=lualib
+ else
+ lua_pkg_prefix=lua
+ fi
+ # try with dot, without dot and finally without version
+ for f in $lua_pkg_prefix$vdot $lua_pkg_prefix$vndot $lua_pkg_prefix; do
+ lua_cflags=$($PKGCONFIG --cflags $f 2>/dev/null)
+ if test "$lua_cflags" != ""; then
+ # OK, found CFLAGS. Get Lua LFLAGS and lib install dir
+ LUA_CFLAGS=$lua_cflags
+ LUA_LFLAGS=$($PKGCONFIG --libs $f)
+ LUA_INSTALL_CMOD=$($PKGCONFIG --variable=INSTALL_CMOD $f)
+ break
+ fi
+ done
+ fi