File: configure.ac

package info (click to toggle)
libvmod-re2 2.0.0-7
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 1,020 kB
  • sloc: ansic: 1,514; cpp: 514; makefile: 111; sh: 76; ruby: 36
file content (193 lines) | stat: -rw-r--r-- 5,494 bytes parent folder | download
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
AC_PREREQ([2.68])
AC_INIT([libvmod-re2], [2.0.0], [varnish-support@uplex.de], [vmod-re2])
AC_COPYRIGHT([Copyright 2016-2017 UPLEX - Nils Goroll Systemoptimierung])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_SRCDIR(src/vmod_re2.vcc)
AC_CONFIG_HEADER([config.h])
AC_CANONICAL_SYSTEM
AC_LANG(C)

AM_INIT_AUTOMAKE([1.12 -Wall -Werror foreign parallel-tests])
AM_SILENT_RULES([yes])
AM_PROG_AR

LT_PREREQ([2.2.6])
LT_INIT([dlopen disable-static])

AX_PTHREAD(,[AC_MSG_ERROR([Could not configure pthreads support])])

LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
CC="$PTHREAD_CC"

AC_ARG_WITH([rst2man],
	[AS_HELP_STRING(
		[--with-rst2man=PATH],
		[Location of rst2man (auto)])],
	[RST2MAN="$withval"],
	[AC_CHECK_PROGS(RST2MAN, [rst2man rst2man.py], [])])

AC_ARG_WITH([lcov],
	[AS_HELP_STRING(
		[--with-lcov=PATH],
		[Location of lcov to generate coverage data (auto)])],
	[LCOV="$withval"],
	[AC_CHECK_PROGS(LCOV, [lcov], [])])
AM_CONDITIONAL(HAVE_LCOV, [test -n "$LCOV"])

AC_ARG_WITH([genhtml],
	[AS_HELP_STRING(
		[--with-genhtml=PATH],
		[Location of genhtml to generate coverage reports (auto)])],
	[GENHTML="$withval"],
	[AC_CHECK_PROGS(GENHTML, [genhtml], [])])
AM_CONDITIONAL(HAVE_GENHTML, [test -n "$GENHTML"])

AC_ARG_WITH([pandoc],
	[AS_HELP_STRING(
		[--with-pandoc=PATH],
		[Location of pandoc to generate README.md (auto)])],
	[PANDOC="$withval"],
	[AC_CHECK_PROGS(PANDOC, [pandoc], [])])
AM_CONDITIONAL(HAVE_PANDOC, [test -n "$PANDOC"])

m4_ifndef([VARNISH_PREREQ], AC_MSG_ERROR([Need varnish.m4 -- see INSTALL.rst]))

PKG_CHECK_MODULES([RE2], [re2])
if echo "$RE2_LIBS" | grep -- '-L' >/dev/null ; then
	if echo "$RE2_LIBS" | grep -- '-R' >/dev/null ; then
		:
	else
		RE2_LIBS=[$(echo $RE2_LIBS | sed 's:-L\([^ ]*\):-L\1 -R\1:')]
	fi
fi


VARNISH_VMODS([re2])

VMOD_TESTS="$(cd $srcdir/src && echo tests/*.vtc)"
AC_SUBST(VMOD_TESTS)

PKG_CHECK_VAR([LIBVARNISHAPI_LIBDIR], [varnishapi], [libdir])
AC_SUBST([VARNISH_LIBRARY_PATH],
	[$LIBVARNISHAPI_LIBDIR:$LIBVARNISHAPI_LIBDIR/varnish])

AC_CONFIG_FILES([
	Makefile
	src/Makefile
])

AM_CONDITIONAL(HAVE_RST2MAN, [test "x$RST2MAN" != "xno"])
AC_PROG_CPP
AC_PROG_CXX
AC_PROG_CXXCPP

# Checks for C sources
AC_CHECK_FUNCS([strdup])
AC_C_INLINE
AC_C_RESTRICT
AC_TYPE_SIZE_T
AC_FUNC_REALLOC

# Checks for C++ sources
AC_FUNC_ERROR_AT_LINE
AC_CHECK_HEADER_STDBOOL

# Check RE2 capabilities
AC_LANG(C++)
SAVE_CXXFLAGS="$CXXFLAGS"
SAVE_LDFLAGS="$LDFLAGS"
CXXFLAGS+=" -std=c++14"
LDFLAGS+=" -lre2"
# Check if the Set::Match() method supports error reporting, to notify
# if a match failed due to the DFA hitting the max_mem
# limit. Available since RE2 commit ee52f03, or since version
# 2017-12-01.
AC_MSG_CHECKING([for RE2::Set::Match() with ErrorInfo])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <re2/set.h>]], [[
re2::RE2::Set s(re2::RE2::DefaultOptions, re2::RE2::UNANCHORED);
s.Match("", NULL, NULL)]])],
		  [AC_MSG_RESULT([yes])
		   AC_DEFINE([HAVE_SET_MATCH_ERRORINFO], [1],
		 [Define to 1 if RE2::Set::Match() has the ErrorInfo parameter])
		  ],
		  [AC_MSG_RESULT([no])
		   AC_DEFINE([HAVE_SET_MATCH_ERRORINFO], [0],
		 [Define to 1 if RE2::Set::Match() has the ErrorInfo parameter])
		  ])

# RE2 versions up to 2016-03-01 require a pointer to vector<int> in
# Set::Match(), to identify the regex that was matched. Since commit
# df7a2dc in re2, the pointer may be NULL, if we just want to know
# whether there was a match. This check tests for that feature.
# Note: the test may cause a core dump if it fails.
AC_MSG_CHECKING([for RE2::Set::Match() with NULL index vector])
AC_RUN_IFELSE(
	[AC_LANG_SOURCE([[
#include "re2/set.h"
main() {
	re2::RE2::Set s(re2::RE2::DefaultOptions, re2::RE2::UNANCHORED);
	s.Add("", NULL);
	s.Compile();
	s.Match("", NULL);
}
	]])],
	[AC_MSG_RESULT([yes])
	 AC_DEFINE([HAVE_SET_MATCH_NULL_VECTOR], [1],
		[Define to 1 if RE2 Set::Match() permits a NULL vector])
	],
	[AC_MSG_RESULT([no])
	 AC_DEFINE([HAVE_SET_MATCH_NULL_VECTOR], [0],
		[Define to 1 if RE2 Set::Match() permits a NULL vector])
	])
CXXFLAGS="$SAVE_CXXFLAGS"
LDFLAGS="$SAVE_LDFLAGS"
AC_LANG(C)

# --enable-stack-protector
AC_ARG_ENABLE(stack-protector,
       AS_HELP_STRING([--enable-stack-protector],[enable stack protector (default is YES)]),
       [],
       [enable_stack_protector=yes])

if test "x$enable_stack_protector" != "xno"; then
	AX_CHECK_COMPILE_FLAG([-fstack-protector],
		AX_CHECK_LINK_FLAG([-fstack-protector],
			[CFLAGS="${CFLAGS} -fstack-protector"], [], []),
		[], [])
	AC_LANG_PUSH(C++)
	AX_CHECK_COMPILE_FLAG([-fstack-protector],
		AX_CHECK_LINK_FLAG([-fstack-protector],
			[CXXFLAGS="${CXXFLAGS} -fstack-protector"], [], []),
		[], [])
	AC_LANG_POP()
fi

# --enable-debugging
AC_ARG_ENABLE(debugging,
	AS_HELP_STRING([--enable-debugging],[enable debugging (default is NO)]),
	[],
	[enable_debugging=no])

# AC_PROG_CC and AC_PROG_CXX set CFLAGS and CXXFLAGS to '-g -O2'
# unless already set, so there's no need to add -g. Disable or change
# by explicitly setting CFLAGS and/or CXXFLAGS. If this option is
# enabled, then -Og or -O0 becomes the last optimization option, and
# hence takes precedence.
if test "x$enable_debugging" != "xno"; then
	CFLAGS="${CFLAGS} -fno-inline"
	AX_CHECK_COMPILE_FLAG([-Og],
		[CFLAGS="${CFLAGS} -Og"],
		[CFLAGS="${CFLAGS} -O0"],
		[])
	AC_LANG_PUSH(C++)
	CXXFLAGS="${CXXFLAGS} -fno-inline"
	AX_CHECK_COMPILE_FLAG([-Og],
		[CXXFLAGS="${CXXFLAGS} -Og"],
		[CXXFLAGS="${CXXFLAGS} -O0"],
		[])
	AC_LANG_POP()
fi

AC_OUTPUT