# This file is part of vmod-sql -*- autoconf -*- # Copyright (C) 2013-2014 Sergey Poznyakoff # # Vmod-sql is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3, or (at your option) # any later version. # # Vmod-sql is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with vmod-sql. If not, see . AC_PREREQ(2.69) AC_INIT([vmod-sql], 1.0.90, [gray@gnu.org]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SRCDIR(src/vmod-sql.c) AM_CONFIG_HEADER(config.h) AC_CANONICAL_SYSTEM AC_LANG(C) AM_INIT_AUTOMAKE([1.14 gnu tar-ustar]) AC_GNU_SOURCE AC_PROG_CC AC_PROG_CC_STDC if test "x$ac_cv_prog_cc_c99" = xno; then AC_MSG_ERROR([could not find a C99 compatible compiler]) fi AC_PROG_CPP AC_PROG_INSTALL AC_PROG_LIBTOOL AC_PROG_MAKE_SET # Check for pkg-config PKG_PROG_PKG_CONFIG # Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS([sys/stdlib.h]) # Check for python AC_CHECK_PROGS(PYTHON, [python], [ AC_MSG_ERROR([python is not found.])]) # Varnish source tree AC_ARG_VAR([VARNISHSRC], [path to Varnish source tree]) AC_ARG_WITH([varnish-source], AC_HELP_STRING([--with-varnish-source=DIR], [Varnish sources are located in DIR]), [VARNISHSRC=$withval]) if test -z "$VARNISHSRC"; then AC_MSG_ERROR([no Varnish source tree specified]) fi case "$VARNISHSRC" in /*) ;; *) AC_MSG_ERROR([varnish source path must be absolute pathname]) esac VARNISHSRC=`cd $VARNISHSRC && pwd` VARNISHVERSION= AC_CHECK_FILE([$VARNISHSRC/include/varnishapi.h], [VARNISHVERSION=3], [AC_CHECK_FILE([$VARNISHSRC/include/vapi/vsm.h], [VARNISHVERSION=4], [AC_MSG_FAILURE(["$VARNISHSRC" is not a Varnish source directory])]) ]) AC_DEFINE_UNQUOTED([VARNISHVERSION],$VARNISHVERSION,[Varnish major version number]) AM_CONDITIONAL([VARNISH3],[test $VARNISHVERSION -eq 3]) AM_CONDITIONAL([VARNISH4],[test $VARNISHVERSION -eq 4]) # Check that varnishtest is built in the varnish source directory AC_CHECK_FILE([$VARNISHSRC/bin/varnishtest/varnishtest], [], [AC_MSG_FAILURE([cannot find "$VARNISHSRC/bin/varnishtest/varnishtest". Please build your varnish source directory])] ) # vmod installation dir AC_ARG_VAR([VMODDIR], [vmod installation directory]) AC_ARG_WITH([vmoddir], AC_HELP_STRING([--with-vmoddir=DIR], [install modules to DIR]), [case "$withval" in /*) VMODDIR=$withval;; no) unset VMODDIR;; *) AC_MSG_ERROR([argument to --with-vmoddir must be absolute pathname]) esac],[VMODDIR=`pkg-config --variable=vmoddir varnishapi` if test -z "$VMODDIR"; then AC_MSG_FAILURE([cannot determine vmod installation directory]) fi]) if test -z "$VMODDIR"; then VMODDIR='$(libdir)/varnish/mods' fi ########### # Check for SQL support build_mysql=probe build_pgsql=probe AC_ARG_WITH(mysql, AC_HELP_STRING([--without-mysql], [Configure to work without MySQL]), [build_mysql=$withval]) AC_ARG_WITH(pgsql, AC_HELP_STRING([--without-pgsql], [Configure to work without Postgres]), [build_pgsql=$withval]) AC_ARG_WITH(postgres, AC_HELP_STRING([--without-postgres], [Same as --without-pgsql]), [build_pgsql=$withval]) GR_ENABLE(mysql, [ GR_CHECK_LIB(mysqlclient, mysql_real_connect, "-lm", [ AC_DEFINE(USE_SQL_MYSQL,1, [Define this if you are going to use MySQL]) AC_DEFINE(HAVE_LIBMYSQL,1, [Define this if you have mysqlclient library]) MYSQLLIBS="$pm_cv_lib_mysqlclient" build_mysql=yes ], [ test "$build_mysql" = yes && AC_MSG_ERROR([MySQL support cannot be built because MySQL libraries are not present]) build_mysql=no ], [/usr/lib/mysql /usr/local/lib/mysql])], $build_mysql) GR_ENABLE(pgsql, [ GR_CHECK_LIB(pq, PQconnectStart, [], [ save_CPPFLAGS=$CPPFLAGS for dir in /usr/local/pgsql/include /usr/pgsql/include do CPPFLAGS="$save_CPPFLAGS -I$dir" AC_CHECK_HEADER([libpq-fe.h], [break]) CPPFLAGS="$save_CPPFLAGS" done if test $ac_cv_header_libpq_fe_h != yes; then test "$build_pgsql" = yes && AC_MSG_ERROR([PostgreSQL support cannot be built because PostgreSQL headers are not present]) else AC_DEFINE(USE_SQL_PGSQL,1, [Define this if you are going to use PostgreSQL]) AC_DEFINE(HAVE_LIBPQ,1, [Define this if you have libpq]) PGSQLLIBS="$pm_cv_lib_pq" build_pgsql=yes fi], [ test "$build_pgsql" = yes && AC_MSG_ERROR([PostgreSQL support cannot be built because PostgreSQL libraries are not present]) build_pgsql=no ], [/usr/pgsql/lib /usr/local/pgsql/lib])], $build_pgsql) AC_SUBST(MYSQLLIBS) AC_SUBST(PGSQLLIBS) AM_CONDITIONAL([USE_MYSQL],[test $build_mysql = yes]) AM_CONDITIONAL([USE_PGSQL],[test $build_pgsql = yes]) AC_CONFIG_COMMANDS([status],[ echo "" delim="-------------------------------------------------------------------" echo $delim | tr '-' '*' echo "Building for Varnish version $VARNISHVERSION" echo "Backends to build:" res= for module in mysql pgsql do eval enable=\${build_$module} str=`echo ${module}" yes" | sed 's/./-/g'` dstr=`echo $delim | sed "s/^$str//" | tr '-' '.'` echo ${module}$dstr $enable res="$res$enable" done echo $delim | tr '-' '*' case "$res" in *yes*) ;; *) AC_MSG_ERROR([Nothing to build?]) esac ],[ VARNISHVERSION=$VARNISHVERSION build_pgsql=$build_pgsql build_mysql=$build_mysql]) dnl FIXME: tests/Makefile AC_CONFIG_FILES([ Makefile doc/Makefile src/Makefile ]) AC_OUTPUT