summaryrefslogtreecommitdiffabout
path: root/configure.ac
blob: 58f7633561ac0c42c768da41c286af32d684d678 (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
# This file is part of vmod-tbf -*- autoconf -*-
# Copyright (C) 2013-2016 Sergey Poznyakoff
#
# Vmod-tbf 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-tbf 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-tbf.  If not, see <http://www.gnu.org/licenses/>.
AC_PREREQ(2.69)
AC_INIT([vmod-tbf], 2.0.90, [gray@gnu.org])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR(src/vmod_tbf.vcc)
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/sysinfo.h)

# Check for functions
AC_CHECK_FUNCS(sysinfo getloadavg)

# 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`


# pkg-config
PKG_PROG_PKG_CONFIG
PKG_CHECK_MODULES([libvarnishapi], [varnishapi])

varnishapi_version() {
    VARNISHAPI_MAJOR=$1
    VARNISHAPI_MINOR=$2
    VARNISHAPI_PATCH=$3
}

v=$($PKG_CONFIG --modversion varnishapi)
if test -n "$v"; then
    save_IFS=$IFS
    IFS='.'
    varnishapi_version $v
    IFS=$save_IFS
else
    AC_MSG_ERROR([unknown varnishapi version])
fi

if test $VARNISHAPI_MAJOR -ne 4; then
    AC_MSG_ERROR([unsupported varnishapi version])
fi

case $VARNISHAPI_MINOR in
0)  AC_MSG_ERROR([unsupported varnishapi version]);;
1)  ;;
*)  AC_MSG_WARN([varnishapi minor version probably unsupported])
esac

# 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 db.h and libdb
#
AC_CHECK_HEADER([db.h],,[AC_MSG_ERROR([Required header file db.h not found])])

AC_CHECK_LIB(db, db_create,
  [LIBS="$LIBS -ldb"
   AC_RUN_IFELSE(
     [AC_LANG_PROGRAM([#include "db.h"],
        [int v_major, v_minor, v_patch;
         db_version(&v_major, &v_minor, &v_patch);
         return !(v_major == DB_VERSION_MAJOR
                  && v_minor == DB_VERSION_MINOR
                  && v_patch == DB_VERSION_PATCH);
        ])],
     [],
     [AC_MSG_ERROR([header file db.h is not the same version as libdb])])])

AC_CONFIG_COMMANDS([status],[
delim="-------------------------------------------------------------------"
echo ""
echo $delim
echo "Building for Varnish version $VARNISHAPI_MAJOR.$VARNISHAPI_MINOR"
echo $delim
],
[VARNISHAPI_MAJOR=$VARNISHAPI_MAJOR
VARNISHAPI_MINOR=$VARNISHAPI_MINOR
])

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

Return to:

Send suggestions and report system problems to the System administrator.