aboutsummaryrefslogtreecommitdiff
path: root/configure.ac
blob: 8b9ff5ced4440b8bbbacc939f1b5620ca00337ba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# This file is part of vmod-dbrw -*- autoconf -*-
# Copyright (C) 2013-2017 Sergey Poznyakoff
#
# Vmod-dbrw 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-dbrw 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-dbrw.  If not, see <http://www.gnu.org/licenses/>.
AC_PREREQ(2.69)
AC_INIT([vmod-dbrw], 2.2, [gray@gnu.org])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR(src/vmod_dbrw.vcc)
AM_CONFIG_HEADER(config.h)

AC_SUBST([AC_VMOD_BASENAME],[dbrw])
AC_CANONICAL_SYSTEM
AC_LANG(C)

AM_INIT_AUTOMAKE([gnu tar-ustar silent-rules])
AM_SILENT_RULES([yes])

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

# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([sys/stdlib.h])

AM_VARNISHAPI([4.1])

###########
# 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([sqlstatus],[
echo ""
delim="-------------------------------------------------------------------"
echo $delim | tr '-' '*'
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
],[
build_pgsql=$build_pgsql
build_mysql=$build_mysql])

# Initialize the test suite.
AC_ARG_VAR([DBRW_TEST_DBTYPE], [Test database type])
if test -z "$DBRW_TEST_DBTYPE"; then
	if test "$build_mysql" = "yes"; then
		DBRW_TEST_DBTYPE=mysql
	elif test "$build_pgsql" = "yes"; then
		DBRW_TEST_DBTYPE=pgsql
	fi
else
	eval val=\$build_$DBRW_TEST_DBTYPE
	case $val in
	yes) ;;
	no)  AC_MSG_ERROR([DBRW_TEST_DBTYPE is set to a disabled database type]);;
	*)   AC_MSG_ERROR([DBRW_TEST_DBTYPE is set to unknown database type]);;
	esac
fi	
AC_ARG_VAR([DBRW_TEST_PARAMS], [SQL connection parameters for testing])
AC_ARG_VAR([DBRW_TEST_SERVER], [Test SQL server])
AC_ARG_VAR([DBRW_TEST_DATABASE], [Test SQL database])
AC_ARG_VAR([DBRW_TEST_USER], [Test SQL user])
AC_ARG_VAR([DBRW_TEST_PASS], [Test SQL password])
AC_ARG_VAR([DBRW_TEST_DEBUG], [Debug settings for testing])

AC_CONFIG_TESTDIR(tests)
AC_CONFIG_FILES([tests/Makefile tests/atlocal])
AM_MISSING_PROG([AUTOM4TE], [autom4te])

AC_CONFIG_FILES([
	Makefile
	src/Makefile
	doc/Makefile
])
AC_OUTPUT

Return to:

Send suggestions and report system problems to the System administrator.