-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
configure.ac
248 lines (199 loc) · 7.81 KB
/
configure.ac
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
AC_PREREQ([2.69])
AC_CONFIG_MACRO_DIR([m4])
include([ax_cxx_compile_stdcxx.m4])
include([acx_pthread.m4])
include([ax_check_define.m4])
AC_INIT([jpcre2], [10.32.01], [https://github.com/jpcre2/jpcre2/issues])
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_SRCDIR([src/jpcre2.hpp])
AC_PROG_CXX
AC_LANG([C++])
AM_INIT_AUTOMAKE
AC_TYPE_INT64_T
# Checks for programs.
AC_PROG_INSTALL
LT_INIT([shared])
# Checks for typedefs, structures, and compiler characteristics.
AC_CHECK_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_SIZE_T
AC_TYPE_UINT32_T
AC_CHECK_HEADER([pcre2.h],[],[AC_MSG_ERROR([Could not find pcre2.h header])],
[#define PCRE2_CODE_UNIT_WIDTH 0
#include <pcre2.h>
])
AC_CHECK_HEADERS([string vector map cstdio climits cstdlib],[],[AC_MSG_ERROR([Required header/s not found])])
# Checks for library functions.
AC_CHECK_FUNCS([free],[],[AC_MSG_ERROR([The function free() could not be found])])
# Check for macros
AX_CHECK_DEFINE([climits],[CHAR_BIT],[],[AC_MSG_ERROR([The macro CHAR_BIT does not exist in header climits])])
# handle --disable-silent-rules (enabled by default)
AC_ARG_ENABLE(silent-rules,
AS_HELP_STRING([--disable-silent-rules],
[Disable silent rules and run in verbose mode]),
, enable_silent_rules=unset)
AC_SUBST(enable_silent_rules)
# Handle --enable-test (disabled by default)
AC_ARG_ENABLE(test,
AS_HELP_STRING([--enable-test],
[enable test]),
, enable_test=unset)
AC_SUBST(enable_test)
# Handle --enable-test (disabled by default)
AC_ARG_ENABLE(thread-check,
AS_HELP_STRING([--enable-thread-check],
[enable thread check]),
, enable_thread_check=unset)
AC_SUBST(enable_thread_check)
# Handle --enable-cpp11 (disabled by default)
AC_ARG_ENABLE(cpp11,
AS_HELP_STRING([--enable-cpp11],
[enable compiling with cpp11]),
, enable_cpp11=unset)
AC_SUBST(enable_cpp11)
# Handle --enable-cpp17 (disabled by default)
AC_ARG_ENABLE(cpp17,
AS_HELP_STRING([--enable-cpp17],
[enable compiling with cpp17]),
, enable_cpp17=unset)
AC_SUBST(enable_cpp17)
AC_ARG_ENABLE(coverage,
AS_HELP_STRING([--enable-coverage],
[use Gcov and lcov to test the test suite]),
, enable_coverage=unset)
AC_SUBST(enable_coverage)
AC_ARG_ENABLE(valgrind,
AS_HELP_STRING([--enable-valgrind],
[use valgrind to test the test suite]),
, enable_valgrind=unset)
AC_SUBST(enable_valgrind)
# Set the default value for cpp11
if test "x$enable_cpp11" = "xunset"
then
enable_cpp11=no
fi
# Set the default value for cpp17
if test "x$enable_cpp17" = "xunset"
then
enable_cpp17=no
fi
# Set the default value silent-rules
if test "x$enable_silent_rules" = "xunset"
then
enable_silent_rules=yes
fi
# Set the default value for test
if test "x$enable_test" = "xunset"
then
enable_test=no
fi
# Set default value for enable_thread_check
if test "x$enable_thread_check" = "xunset"
then
enable_thread_check=no
fi
if test "x$enable_coverage" = "xunset"
then
enable_coverage=no
fi
if test "x$enable_valgrind" = "xunset"
then
enable_valgrind=no
fi
# Here is where JPCRE2-specific defines are handled
if test "$enable_coverage" = "yes"; then
AC_ARG_VAR([LCOV],[the ltp lcov program])
AC_PATH_PROG([LCOV],[lcov],[false])
if test "x$LCOV" = "xfalse"; then
AC_MSG_ERROR([lcov not found])
fi
AC_ARG_VAR([GENHTML],[the ltp genhtml program])
AC_PATH_PROG([GENHTML],[genhtml],[false])
if test "x$GENHTML" = "xfalse"; then
AC_MSG_ERROR([genhtml not found])
fi
enable_test=yes
CXXFLAGS="-O0 -ggdb3 -fprofile-arcs -ftest-coverage"
if test "$enable_thread_check" = yes; then
AC_MSG_ERROR([coverage report option is not supported with thread check])
fi
fi
if test "$enable_thread_check" = "yes"; then
AC_DEFINE([SUPPORT_THREAD_CHECK], [], [
Define to any value to enable thread check])
AC_CHECK_HEADERS([pthread.h],[],[AC_MSG_ERROR([Unable to find pthread.h header])])
AC_CHECK_LIB([pthread], [pthread_exit], [], [AC_MSG_ERROR([Could not find pthread library])])
LIBS="-pthread $LIBS" # be compatible with older compilers
AC_ARG_VAR([VALGRIND],[the valgrind program])
AC_PATH_PROG([VALGRIND],[valgrind],[false])
if test "x$VALGRIND" = "xfalse"; then
AC_MSG_ERROR([The program valgrind not installed])
fi
if test "$enable_coverage" = yes; then
AC_MSG_ERROR([thread check option is not supported with coverage report])
fi
CXXFLAGS="$CXXFLAGS"
fi
if test "$enable_valgrind" = "yes"; then
AC_ARG_VAR([VALGRIND],[the valgrind program])
AC_PATH_PROG([VALGRIND],[valgrind],[false])
if test "x$VALGRIND" = "xfalse"; then
AC_MSG_ERROR([valgrind not found])
fi
enable_test=yes
fi
if test "$enable_silent_rules" = "yes"; then
AM_SILENT_RULES([yes])
AC_DEFINE([SUPPORT_SILENT_RULES], [], [
Define to any value to enable prettified make output])
fi
if test "$enable_test" = "yes"; then
AC_DEFINE([SUPPORT_TEST], [], [
Define to any value to enable the test suite])
AC_CHECK_LIB([pcre2-8], [pcre2_code_free_8], [], [AC_MSG_ERROR([Could not find pcre2-8 library])])
AC_CHECK_LIB([pcre2-16], [pcre2_code_free_16], [], [AC_MSG_ERROR([Could not find pcre2-16 library])])
AC_CHECK_LIB([pcre2-32], [pcre2_code_free_32], [], [AC_MSG_ERROR([Could not find pcre2-32 library])])
AC_CHECK_HEADERS([iostream cassert cstring],[],[AC_MSG_ERROR([Required header/s missing for test programs])])
fi
if test "$enable_cpp11" = "yes"; then
AC_DEFINE([SUPPORT_CPP11], [], [
Define to any value to enable C++ 11])
#check for c++11 support and add flags
AX_CXX_COMPILE_STDCXX([11], [noext], [mandatory])
AC_CHECK_HEADER([utility],[],[AC_MSG_ERROR([C++11 is being used but utility header not found])])
AC_CHECK_HEADER([functional],[],[AC_MSG_ERROR([C++11 is being used but functional header not found. Either update your compiler or define JPCRE2_USE_FUNCTION_POINTER_CALLBACK before including jpcre2.hpp in your program if applicable and update configure script to ignore this error.])])
if test "$enable_thread_check" = 'yes'; then
AC_CHECK_HEADERS([thread mutex],[],[AC_MSG_ERROR([Unable to find thread/mutex header])])
AC_CHECK_HEADERS([ctime],[],[AC_MSG_ERROR([Unable to find ctime header])])
fi
fi
if test "$enable_cpp17" = "yes"; then
AC_DEFINE([SUPPORT_CPP17], [], [
Define to any value to enable C++ 17])
#check for c++17 support and add flags
AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory])
fi
# Conditional compilation
AM_CONDITIONAL(WITH_TEST_SUIT, test "x$enable_valgrind" = "xyes" || test "x$enable_coverage" = "xyes" || test "x$enable_test" = "xyes")
AM_CONDITIONAL(WITH_COVERAGE, test "x$enable_coverage" = "xyes")
AM_CONDITIONAL(WITH_THREAD_TEST, test "x$enable_thread_check" = "xyes")
AM_CONDITIONAL(WITH_VALGRIND, test "x$enable_valgrind" = "xyes")
AM_CONDITIONAL(WITH_CPP11, test "x$enable_cpp11" = "xyes")
AC_OUTPUT(Makefile src/Makefile)
cat <<EOF
configuration summary:
Install prefix .................... : ${prefix}
C++ compiler ...................... : ${CXX}
Linker ............................ : ${LD}
C++ preprocessor flags ............ : ${CPPFLAGS}
C++ compiler flags ................ : ${CXXFLAGS}
Linker flags ...................... : ${LDFLAGS}
Extra libraries ................... : ${LIBS}
Build tests ....................... : ${enable_test}
Build with C++ 11 ................. : ${enable_cpp11}
Build with C++ 17 ................. : ${enable_cpp17}
Valgrind memory leak test ......... : ${enable_valgrind}
Multi-thread test ................. : ${enable_thread_check}
Coverage report ................... : ${enable_coverage}
Enable Silent Rules ............... : ${enable_silent_rules}
EOF