Skip to content

Commit ec9dce9

Browse files
committed
add build ordner
1 parent d058914 commit ec9dce9

23 files changed

+3030
-0
lines changed

build/.empty

Whitespace-only changes.

build/ax_cxx_compile_stdcxx.m4

Lines changed: 1018 additions & 0 deletions
Large diffs are not rendered by default.

build/ax_prog_doxygen.m4

Lines changed: 533 additions & 0 deletions
Large diffs are not rendered by default.

build/ax_valgrind_check.m4

Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
# ===========================================================================
2+
# http://www.gnu.org/software/autoconf-archive/ax_valgrind_check.html
3+
# ===========================================================================
4+
#
5+
# SYNOPSIS
6+
#
7+
# AX_VALGRIND_DFLT(memcheck|helgrind|drd|sgcheck, on|off)
8+
# AX_VALGRIND_CHECK()
9+
#
10+
# DESCRIPTION
11+
#
12+
# AX_VALGRIND_CHECK checks whether Valgrind is present and, if so, allows
13+
# running `make check` under a variety of Valgrind tools to check for
14+
# memory and threading errors.
15+
#
16+
# Defines VALGRIND_CHECK_RULES which should be substituted in your
17+
# Makefile; and $enable_valgrind which can be used in subsequent configure
18+
# output. VALGRIND_ENABLED is defined and substituted, and corresponds to
19+
# the value of the --enable-valgrind option, which defaults to being
20+
# enabled if Valgrind is installed and disabled otherwise. Individual
21+
# Valgrind tools can be disabled via --disable-valgrind-<tool>, the
22+
# default is configurable via the AX_VALGRIND_DFLT command or is to use
23+
# all commands not disabled via AX_VALGRIND_DFLT. All AX_VALGRIND_DFLT
24+
# calls must be made before the call to AX_VALGRIND_CHECK.
25+
#
26+
# If unit tests are written using a shell script and automake's
27+
# LOG_COMPILER system, the $(VALGRIND) variable can be used within the
28+
# shell scripts to enable Valgrind, as described here:
29+
#
30+
# https://www.gnu.org/software/gnulib/manual/html_node/Running-self_002dtests-under-valgrind.html
31+
#
32+
# Usage example:
33+
#
34+
# configure.ac:
35+
#
36+
# AX_VALGRIND_DFLT([sgcheck], [off])
37+
# AX_VALGRIND_CHECK
38+
#
39+
# Makefile.am:
40+
#
41+
# @VALGRIND_CHECK_RULES@
42+
# VALGRIND_SUPPRESSIONS_FILES = my-project.supp
43+
# EXTRA_DIST = my-project.supp
44+
#
45+
# This results in a "check-valgrind" rule being added to any Makefile.am
46+
# which includes "@VALGRIND_CHECK_RULES@" (assuming the module has been
47+
# configured with --enable-valgrind). Running `make check-valgrind` in
48+
# that directory will run the module's test suite (`make check`) once for
49+
# each of the available Valgrind tools (out of memcheck, helgrind and drd)
50+
# while the sgcheck will be skipped unless enabled again on the
51+
# commandline with --enable-valgrind-sgcheck. The results for each check
52+
# will be output to test-suite-$toolname.log. The target will succeed if
53+
# there are zero errors and fail otherwise.
54+
#
55+
# Alternatively, a "check-valgrind-$TOOL" rule will be added, for $TOOL in
56+
# memcheck, helgrind, drd and sgcheck. These are useful because often only
57+
# some of those tools can be ran cleanly on a codebase.
58+
#
59+
# The macro supports running with and without libtool.
60+
#
61+
# LICENSE
62+
#
63+
# Copyright (c) 2014, 2015, 2016 Philip Withnall <philip.withnall@collabora.co.uk>
64+
#
65+
# Copying and distribution of this file, with or without modification, are
66+
# permitted in any medium without royalty provided the copyright notice
67+
# and this notice are preserved. This file is offered as-is, without any
68+
# warranty.
69+
70+
#serial 13
71+
72+
dnl Configured tools
73+
m4_define([valgrind_tool_list], [[memcheck], [helgrind], [drd], [sgcheck]])
74+
m4_set_add_all([valgrind_exp_tool_set], [sgcheck])
75+
m4_foreach([vgtool], [valgrind_tool_list],
76+
[m4_define([en_dflt_valgrind_]vgtool, [on])])
77+
78+
AC_DEFUN([AX_VALGRIND_DFLT],[
79+
m4_define([en_dflt_valgrind_$1], [$2])
80+
])dnl
81+
82+
AC_DEFUN([AX_VALGRIND_CHECK],[
83+
dnl Check for --enable-valgrind
84+
AC_ARG_ENABLE([valgrind],
85+
[AS_HELP_STRING([--enable-valgrind], [Whether to enable Valgrind on the unit tests])],
86+
[enable_valgrind=$enableval],[enable_valgrind=])
87+
88+
AS_IF([test "$enable_valgrind" != "no"],[
89+
# Check for Valgrind.
90+
AC_CHECK_PROG([VALGRIND],[valgrind],[valgrind])
91+
AS_IF([test "$VALGRIND" = ""],[
92+
AS_IF([test "$enable_valgrind" = "yes"],[
93+
AC_MSG_ERROR([Could not find valgrind; either install it or reconfigure with --disable-valgrind])
94+
],[
95+
enable_valgrind=no
96+
])
97+
],[
98+
enable_valgrind=yes
99+
])
100+
])
101+
102+
AM_CONDITIONAL([VALGRIND_ENABLED],[test "$enable_valgrind" = "yes"])
103+
AC_SUBST([VALGRIND_ENABLED],[$enable_valgrind])
104+
105+
# Check for Valgrind tools we care about.
106+
[valgrind_enabled_tools=]
107+
m4_foreach([vgtool],[valgrind_tool_list],[
108+
AC_ARG_ENABLE([valgrind-]vgtool,
109+
m4_if(m4_defn([en_dflt_valgrind_]vgtool),[off],dnl
110+
[AS_HELP_STRING([--enable-valgrind-]vgtool, [Whether to use ]vgtool[ during the Valgrind tests])],dnl
111+
[AS_HELP_STRING([--disable-valgrind-]vgtool, [Whether to skip ]vgtool[ during the Valgrind tests])]),
112+
[enable_valgrind_]vgtool[=$enableval],
113+
[enable_valgrind_]vgtool[=])
114+
AS_IF([test "$enable_valgrind" = "no"],[
115+
enable_valgrind_]vgtool[=no],
116+
[test "$enable_valgrind_]vgtool[" ]dnl
117+
m4_if(m4_defn([en_dflt_valgrind_]vgtool), [off], [= "yes"], [!= "no"]),[
118+
AC_CACHE_CHECK([for Valgrind tool ]vgtool,
119+
[ax_cv_valgrind_tool_]vgtool,[
120+
ax_cv_valgrind_tool_]vgtool[=no
121+
m4_set_contains([valgrind_exp_tool_set],vgtool,
122+
[m4_define([vgtoolx],[exp-]vgtool)],
123+
[m4_define([vgtoolx],vgtool)])
124+
AS_IF([`$VALGRIND --tool=]vgtoolx[ --help >/dev/null 2>&1`],[
125+
ax_cv_valgrind_tool_]vgtool[=yes
126+
])
127+
])
128+
AS_IF([test "$ax_cv_valgrind_tool_]vgtool[" = "no"],[
129+
AS_IF([test "$enable_valgrind_]vgtool[" = "yes"],[
130+
AC_MSG_ERROR([Valgrind does not support ]vgtool[; reconfigure with --disable-valgrind-]vgtool)
131+
],[
132+
enable_valgrind_]vgtool[=no
133+
])
134+
],[
135+
enable_valgrind_]vgtool[=yes
136+
])
137+
])
138+
AS_IF([test "$enable_valgrind_]vgtool[" = "yes"],[
139+
valgrind_enabled_tools="$valgrind_enabled_tools ]m4_bpatsubst(vgtool,[^exp-])["
140+
])
141+
AC_SUBST([ENABLE_VALGRIND_]vgtool,[$enable_valgrind_]vgtool)
142+
])
143+
AC_SUBST([valgrind_tools],["]m4_join([ ], valgrind_tool_list)["])
144+
AC_SUBST([valgrind_enabled_tools],[$valgrind_enabled_tools])
145+
146+
[VALGRIND_CHECK_RULES='
147+
# Valgrind check
148+
#
149+
# Optional:
150+
# - VALGRIND_SUPPRESSIONS_FILES: Space-separated list of Valgrind suppressions
151+
# files to load. (Default: empty)
152+
# - VALGRIND_FLAGS: General flags to pass to all Valgrind tools.
153+
# (Default: --num-callers=30)
154+
# - VALGRIND_$toolname_FLAGS: Flags to pass to Valgrind $toolname (one of:
155+
# memcheck, helgrind, drd, sgcheck). (Default: various)
156+
157+
# Optional variables
158+
VALGRIND_SUPPRESSIONS ?= $(addprefix --suppressions=,$(VALGRIND_SUPPRESSIONS_FILES))
159+
VALGRIND_FLAGS ?= --num-callers=30
160+
VALGRIND_memcheck_FLAGS ?= --leak-check=full --show-reachable=no
161+
VALGRIND_helgrind_FLAGS ?= --history-level=approx
162+
VALGRIND_drd_FLAGS ?=
163+
VALGRIND_sgcheck_FLAGS ?=
164+
165+
# Internal use
166+
valgrind_log_files = $(addprefix test-suite-,$(addsuffix .log,$(valgrind_tools)))
167+
168+
valgrind_memcheck_flags = --tool=memcheck $(VALGRIND_memcheck_FLAGS)
169+
valgrind_helgrind_flags = --tool=helgrind $(VALGRIND_helgrind_FLAGS)
170+
valgrind_drd_flags = --tool=drd $(VALGRIND_drd_FLAGS)
171+
valgrind_sgcheck_flags = --tool=exp-sgcheck $(VALGRIND_sgcheck_FLAGS)
172+
173+
valgrind_quiet = $(valgrind_quiet_$(V))
174+
valgrind_quiet_ = $(valgrind_quiet_$(AM_DEFAULT_VERBOSITY))
175+
valgrind_quiet_0 = --quiet
176+
valgrind_v_use = $(valgrind_v_use_$(V))
177+
valgrind_v_use_ = $(valgrind_v_use_$(AM_DEFAULT_VERBOSITY))
178+
valgrind_v_use_0 = @echo " USE " $(patsubst check-valgrind-%,%,$''@):;
179+
180+
# Support running with and without libtool.
181+
ifneq ($(LIBTOOL),)
182+
valgrind_lt = $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=execute
183+
else
184+
valgrind_lt =
185+
endif
186+
187+
# Use recursive makes in order to ignore errors during check
188+
check-valgrind:
189+
ifeq ($(VALGRIND_ENABLED),yes)
190+
-$(A''M_V_at)$(foreach tool,$(valgrind_enabled_tools), \
191+
$(MAKE) $(AM_MAKEFLAGS) -k check-valgrind-$(tool); \
192+
)
193+
else
194+
@echo "Need to reconfigure with --enable-valgrind"
195+
endif
196+
197+
# Valgrind running
198+
VALGRIND_TESTS_ENVIRONMENT = \
199+
$(TESTS_ENVIRONMENT) \
200+
env VALGRIND=$(VALGRIND) \
201+
G_SLICE=always-malloc,debug-blocks \
202+
G_DEBUG=fatal-warnings,fatal-criticals,gc-friendly
203+
204+
VALGRIND_LOG_COMPILER = test/test-suite.sh $(VALGRIND_SUPPRESSIONS) $(VALGRIND_FLAGS)
205+
# $(valgrind_lt) \
206+
# $(VALGRIND) $(VALGRIND_SUPPRESSIONS) --error-exitcode=1 $(VALGRIND_FLAGS)
207+
208+
define valgrind_tool_rule =
209+
check-valgrind-$(1):
210+
ifeq ($$(VALGRIND_ENABLED)-$$(ENABLE_VALGRIND_$(1)),yes-yes)
211+
$$(valgrind_v_use)$$(MAKE) check-TESTS \
212+
TESTS_ENVIRONMENT="$$(VALGRIND_TESTS_ENVIRONMENT)" \
213+
LOG_COMPILER="$$(VALGRIND_LOG_COMPILER)" \
214+
LOG_FLAGS="$$(valgrind_$(1)_flags)" \
215+
TEST_SUITE_LOG=test-suite-$(1).log
216+
else ifeq ($$(VALGRIND_ENABLED),yes)
217+
@echo "Need to reconfigure with --enable-valgrind-$(1)"
218+
else
219+
@echo "Need to reconfigure with --enable-valgrind"
220+
endif
221+
endef
222+
223+
$(foreach tool,$(valgrind_tools),$(eval $(call valgrind_tool_rule,$(tool))))
224+
225+
A''M_DISTCHECK_CONFIGURE_FLAGS ?=
226+
A''M_DISTCHECK_CONFIGURE_FLAGS += --disable-valgrind
227+
228+
MOSTLYCLEANFILES ?=
229+
MOSTLYCLEANFILES += $(valgrind_log_files)
230+
231+
.PHONY: check-valgrind $(add-prefix check-valgrind-,$(valgrind_tools))
232+
']
233+
234+
AC_SUBST([VALGRIND_CHECK_RULES])
235+
m4_ifdef([_AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE([VALGRIND_CHECK_RULES])])
236+
])

build/curl.m4

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
dnl Check for CURL Libraries
2+
dnl Sets:
3+
dnl CURL_CFLAGS
4+
dnl CURL_LDADD
5+
dnl CURL_LDFLAGS
6+
dnl CURL_VERSION
7+
dnl CURL_DISPLAY
8+
dnl CURL_FOUND
9+
10+
AC_DEFUN([CHECK_CURL], [
11+
MSC_CHECK_LIB([CURL], [libcurl], [curl/curl.h], [curl], [-DWITH_CURL], [7.15.1])
12+
13+
# Post-processing: TLSv1.2 version check
14+
if test "x${CURL_FOUND}" = "x1" && test -n "${CURL_VERSION}"; then
15+
AC_MSG_CHECKING([if libcurl supports TLSv1.2])
16+
_msc_curl_tlsv2_ver=`echo 7.34.0 | awk -F. '{print (\$ 1 * 1000000) + (\$ 2 * 1000) + \$ 3}'`
17+
_msc_curl_ver=`echo ${CURL_VERSION} | awk -F. '{print (\$ 1 * 1000000) + (\$ 2 * 1000) + \$ 3}'`
18+
if test "${_msc_curl_tlsv2_ver}" -le "${_msc_curl_ver}" 2>/dev/null; then
19+
AC_MSG_RESULT([yes])
20+
CURL_CFLAGS="${CURL_CFLAGS} -DWITH_CURL_SSLVERSION_TLSv1_2"
21+
else
22+
AC_MSG_RESULT([no])
23+
fi
24+
25+
# Check/warn if GnuTLS is used
26+
AC_MSG_CHECKING([if libcurl is linked with gnutls])
27+
_msc_curl_uses_gnutls=`echo ${CURL_LDADD} | grep gnutls | wc -l`
28+
if test "$_msc_curl_uses_gnutls" -ne 0; then
29+
AC_MSG_RESULT([yes])
30+
AC_MSG_NOTICE([NOTE: curl linked with gnutls may be buggy, openssl recommended])
31+
else
32+
AC_MSG_RESULT([no])
33+
fi
34+
fi
35+
36+
]) # AC_DEFUN [CHECK_CURL]

build/libgeoip.m4

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
dnl Check for GeoIP Libraries
2+
dnl Sets:
3+
dnl GEOIP_CFLAGS
4+
dnl GEOIP_LDADD
5+
dnl GEOIP_LDFLAGS
6+
dnl GEOIP_VERSION
7+
dnl GEOIP_DISPLAY
8+
dnl GEOIP_FOUND
9+
10+
AC_DEFUN([PROG_GEOIP], [
11+
MSC_CHECK_LIB([GEOIP], [geoip2 geoip GeoIP], [GeoIPCity.h], [GeoIP], [-DWITH_GEOIP])
12+
]) # AC_DEFUN [PROG_GEOIP]

build/libmaxmind.m4

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
dnl Check for MaxMind Libraries
2+
dnl Sets:
3+
dnl MAXMIND_CFLAGS
4+
dnl MAXMIND_LDADD
5+
dnl MAXMIND_LDFLAGS
6+
dnl MAXMIND_VERSION
7+
dnl MAXMIND_DISPLAY
8+
dnl MAXMIND_FOUND
9+
10+
AC_DEFUN([PROG_MAXMIND], [
11+
MSC_CHECK_LIB([MAXMIND], [libmaxminddb], [maxminddb.h], [maxminddb], [-DWITH_MAXMIND])
12+
]) # AC_DEFUN [PROG_MAXMIND]

build/libxml.m4

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
dnl Check for LIBXML2 Libraries
2+
dnl Sets:
3+
dnl LIBXML2_CFLAGS
4+
dnl LIBXML2_LDADD
5+
dnl LIBXML2_LDFLAGS
6+
dnl LIBXML2_VERSION
7+
dnl LIBXML2_DISPLAY
8+
dnl LIBXML2_FOUND
9+
10+
AC_DEFUN([CHECK_LIBXML2], [
11+
MSC_CHECK_LIB([LIBXML2], [libxml-2.0], [libxml/parser.h], [xml2], [-DWITH_LIBXML2], [2.6.29], [libxml])
12+
]) # AC_DEFUN [CHECK_LIBXML2]

build/lmdb.m4

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
dnl Check for LMDB Libraries
2+
dnl LMDB is disabled by default; only enabled when --with-lmdb is given.
3+
dnl Sets:
4+
dnl LMDB_CFLAGS
5+
dnl LMDB_LDADD
6+
dnl LMDB_LDFLAGS
7+
dnl LMDB_VERSION
8+
dnl LMDB_DISPLAY
9+
dnl LMDB_FOUND
10+
11+
AC_DEFUN([PROG_LMDB], [
12+
13+
# LMDB is opt-in: auto-detect finds it but we only activate when
14+
# --with-lmdb or --with-lmdb=PATH is given explicitly.
15+
MSC_CHECK_LIB([LMDB], [lmdb], [lmdb.h], [lmdb], [-DWITH_LMDB])
16+
17+
# If LMDB was found by auto-detection (no explicit --with-lmdb) treat it
18+
# as disabled since LMDB is opt-in.
19+
_msc_lmdb_with_val="$with_lmdb"
20+
if test "x${_msc_lmdb_with_val}" = "x" && test "x${LMDB_FOUND}" = "x1"; then
21+
LMDB_FOUND=2
22+
LMDB_CFLAGS=""
23+
LMDB_LDADD=""
24+
LMDB_LDFLAGS=""
25+
LMDB_DISPLAY=""
26+
AC_MSG_NOTICE([LMDB is disabled by default. Use --with-lmdb to enable.])
27+
fi
28+
29+
]) # AC_DEFUN [PROG_LMDB]

0 commit comments

Comments
 (0)