-
Notifications
You must be signed in to change notification settings - Fork 85
/
configure.ac
281 lines (255 loc) · 9.93 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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
AC_INIT([re-flex],[5.0.1],[https://github.com/Genivia/RE-flex/issues],[reflex])
AM_INIT_AUTOMAKE([foreign subdir-objects])
AC_CONFIG_HEADERS([config.h])
AC_COPYRIGHT([Copyright (C) 2016-2024 Robert van Engelen, Genivia Inc.])
AC_TYPE_SIZE_T
AC_TYPE_OFF_T
AC_TYPE_UINT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
# if CXXFLAGS is undefined, set it to our preferred default flags
: ${CXXFLAGS="-Wall -Wextra -Wunused -O2"}
AC_LANG([C++])
AC_PROG_CXX
AM_PROG_AR
AC_PROG_RANLIB
AC_PROG_INSTALL
AC_CHECK_HEADERS([sys/time.h])
# removed to avoid MaxOS libtool issues, alas...
# LT_INIT
AC_PROG_YACC
AC_SUBST(YACC)
AC_CANONICAL_HOST
PLATFORM=${host}
AC_SUBST(PLATFORM)
################################################################################
# Use SIMD CPU extensions and manage cross compilation
################################################################################
# --disable-sse2 fallback option if cross compilation fails to disable SSE2 CPU extensions
AC_ARG_ENABLE(sse2,
[AS_HELP_STRING([--disable-sse2],
[disable SSE2 CPU extensions])],
[with_no_sse2="yes"],
[with_no_sse2="no"])
# --disable-avx2 fallback option if cross compilation fails to disable AVX2/AVX512BW CPU extensions
AC_ARG_ENABLE(avx2,
[AS_HELP_STRING([--disable-avx2],
[disable AVX2/AVX512BW CPU extensions])],
[with_no_avx2="yes"],
[with_no_avx2="no"])
# --disable-neon fallback option if cross compilation fails to disable NEON/AArch64 CPU extensions
AC_ARG_ENABLE(neon,
[AS_HELP_STRING([--disable-neon],
[disable NEON CPU extensions])],
[with_no_neon="yes"],
[with_no_neon="no"])
# SIMD_FLAGS applies to all source code
SIMD_FLAGS=
# SIMD_AVX2_FLAGS applies to lib/matcher_avx2.cpp which is selected based on a runtime AVX2 check
SIMD_AVX2_FLAGS=
# SIMD_AVX512BW_FLAGS applies to lib/matcher_avx512bw.cpp which is selected based on a runtime AVX512BW check
SIMD_AVX512BW_FLAGS=
if test "x$cross_compiling" = "xyes"; then
# cross compiling to a host CPU: check support for SIMD CPU extension compile flags
case $host_cpu in
i[[3456]]86*|x86_64*|amd64*)
# enable SSE2/AVX2/AVX512BW extensions
if ! test "x$with_no_sse2" = "xyes"; then
AC_MSG_CHECKING([whether ${CXX} supports SSE2 intrinsics])
save_CXXFLAGS=$CXXFLAGS
CXXFLAGS="-msse2"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <emmintrin.h>]], [[__m128i n = _mm_set1_epi8(42);]])],
[msse2_ok=yes],
[msse2_ok=no])
CXXFLAGS=$save_CXXFLAGS
AC_MSG_RESULT($msse2_ok)
if test "x$msse2_ok" = "xyes"; then
SIMD_FLAGS="-msse2 -DHAVE_SSE2"
if ! test "x$with_no_avx2" = "xyes"; then
AC_MSG_CHECKING([whether ${CXX} supports AVX2/AVX512BW intrinsics])
save_CXXFLAGS=$CXXFLAGS
CXXFLAGS="-mavx512bw"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <immintrin.h>]], [[__m512i n = _mm512_set1_epi8(42); (void)_mm512_cmpeq_epi8_mask(n, n);]])],
[mavx_ok=yes],
[mavx_ok=no])
if test "x$mavx_ok" = "xyes"; then
SIMD_FLAGS="-msse2 -DHAVE_AVX512BW"
SIMD_AVX2_FLAGS="-mavx2"
SIMD_AVX512BW_FLAGS="-mavx512bw"
else
CXXFLAGS="-mavx2"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <immintrin.h>]], [[__m256i n = _mm256_set1_epi8(42); (void)_mm256_movemask_epi8(_mm256_and_si256(n, n));]])],
[mavx_ok=yes],
[mavx_ok=no])
if test "x$mavx_ok" = "xyes"; then
SIMD_FLAGS="-msse2 -DHAVE_AVX2"
SIMD_AVX2_FLAGS="-mavx2"
fi
fi
CXXFLAGS=$save_CXXFLAGS
AC_MSG_RESULT($mavx_ok)
fi
fi
fi
;;
armv5*|armv6*)
;;
arm*)
# enable arm >= 7 neon extensions with option -mfpu=neon
if ! test "x$with_no_neon" = "xyes"; then
AC_MSG_CHECKING([whether ${CXX} supports ARM NEON/AArch64 intrinsics])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <arm_neon.h>]], [[uint64x2_t n; uint64_t m = vgetq_lane_u64(n, 0);]])],
[mneon_ok=yes],
[mneon_ok=no])
if test "x$mneon_ok" = "xyes"; then
SIMD_FLAGS="-DHAVE_NEON"
else
save_CXXFLAGS=$CXXFLAGS
CXXFLAGS="-mfpu=neon"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <arm_neon.h>]], [[uint64x2_t n; uint64_t m = vgetq_lane_u64(n, 0);]])],
[mneon_ok=yes],
[mneon_ok=no])
if test "x$mneon_ok" = "xyes"; then
SIMD_FLAGS="-mfpu=neon -DHAVE_NEON"
else
# this is iffy,,,
CXXFLAGS="-march=native -mfpu=neon"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <arm_neon.h>]], [[uint64x2_t n; uint64_t m = vgetq_lane_u64(n, 0);]])],
[mneon_ok=yes],
[mneon_ok=no])
if test "x$mneon_ok" = "xyes"; then
SIMD_FLAGS="-march=native -mfpu=neon -DHAVE_NEON"
fi
fi
CXXFLAGS=$save_CXXFLAGS
fi
AC_MSG_RESULT($mneon_ok)
fi
;;
aarch64*)
# enable AArch64 neon extensions
if ! test "x$with_no_neon" = "xyes"; then
SIMD_FLAGS="-DHAVE_NEON"
fi
;;
esac
else
if ! test "x$with_no_sse2" = "xyes"; then
AC_MSG_CHECKING([whether ${CXX} supports SSE2 intrinsics])
save_CXXFLAGS=$CXXFLAGS
CXXFLAGS="-msse2"
AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <emmintrin.h>]],[[__m128i n = _mm_set1_epi8(42);]])],
[msse2_ok=yes],
[msse2_ok=no])
CXXFLAGS=$save_CXXFLAGS
AC_MSG_RESULT($msse2_ok)
if test "x$msse2_ok" = "xyes"; then
SIMD_FLAGS="-msse2 -DHAVE_SSE2"
AC_MSG_CHECKING(for --disable-avx)
if ! test "x$with_no_avx2" = "xyes"; then
AC_MSG_RESULT(no)
AC_MSG_CHECKING([whether ${CXX} supports AVX2/AVX512BW intrinsics])
save_CXXFLAGS=$CXXFLAGS
CXXFLAGS="-mavx512bw"
AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <immintrin.h>]],[[__m512i n = _mm512_set1_epi8(42); (void)_mm512_cmpeq_epi8_mask(n, n);]])],
[mavx_ok=yes],
[mavx_ok=no])
if test "x$mavx_ok" = "xyes"; then
SIMD_FLAGS="-msse2 -DHAVE_AVX512BW"
SIMD_AVX2_FLAGS="-mavx2"
SIMD_AVX512BW_FLAGS="-mavx512bw"
else
CXXFLAGS="-mavx2"
AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <immintrin.h>]],[[__m256i n = _mm256_set1_epi8(42); (void)_mm256_movemask_epi8(_mm256_and_si256(n, n));]])],
[mavx_ok=yes],
[mavx_ok=no])
if test "x$mavx_ok" = "xyes"; then
SIMD_FLAGS="-msse2 -DHAVE_AVX2"
SIMD_AVX2_FLAGS="-mavx2"
fi
fi
CXXFLAGS=$save_CXXFLAGS
AC_MSG_RESULT($mavx_ok)
else
AC_MSG_RESULT(yes)
fi
fi
fi
if test -z "$SIMD_FLAGS"; then
if ! test "x$with_no_neon" = "xyes"; then
AC_MSG_CHECKING([whether ${CXX} supports NEON/AArch64 intrinsics])
AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <arm_neon.h>]],[[uint64x2_t n; uint64_t m = vgetq_lane_u64(n, 0);]])],
[mneon_ok=yes],
[mneon_ok=no])
if test "x$mneon_ok" = "xyes"; then
SIMD_FLAGS="-DHAVE_NEON"
else
save_CXXFLAGS=$CXXFLAGS
CXXFLAGS="-mfpu=neon"
AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <arm_neon.h>]],[[uint64x2_t n; uint64_t m = vgetq_lane_u64(n, 0);]])],
[mneon_ok=yes],
[mneon_ok=no])
if test "x$mneon_ok" = "xyes"; then
SIMD_FLAGS="-mfpu=neon -DHAVE_NEON"
else
CXXFLAGS="-march=native -mfpu=neon"
AC_RUN_IFELSE([AC_LANG_PROGRAM([[#include <arm_neon.h>]],[[uint64x2_t n; uint64_t m = vgetq_lane_u64(n, 0);]])],
[mneon_ok=yes],
[mneon_ok=no])
if test "x$mneon_ok" = "xyes"; then
SIMD_FLAGS="-march=native -mfpu=neon -DHAVE_NEON"
fi
fi
CXXFLAGS=$save_CXXFLAGS
fi
AC_MSG_RESULT($mneon_ok)
fi
fi
fi
AC_SUBST(SIMD_FLAGS)
AC_SUBST(SIMD_AVX2_FLAGS)
AC_SUBST(SIMD_AVX512BW_FLAGS)
################################################################################
# Build the examples when requested, requires Bison
################################################################################
AC_ARG_ENABLE(examples,
[AS_HELP_STRING([--enable-examples],
[build examples @<:@default=no@:>@])],
[enable_examples=yes],
[enable_examples=no])
AM_CONDITIONAL([ENABLE_EXAMPLES],[test "x$enable_examples" = "xyes"])
AC_SUBST(ENABLE_EXAMPLES)
if test "x$enable_examples" = "xyes"; then
EXAMPLESDIR="examples"
else
EXAMPLESDIR=
fi
AC_SUBST(EXAMPLESDIR)
################################################################################
# Check for Doxygen to update manual, not a required dependency, manual included
################################################################################
AC_PATH_PROG(DOXYGEN,doxygen,NO_DOXYGEN)
if test "$DOXYGEN" = NO_DOXYGEN; then
AC_MSG_CHECKING([for Doxygen.app])
IFS=:
if test -d "/Applications/Doxygen.app"; then
DOXYGEN="/Applications/Doxygen.app/Contents/Resources/doxygen"
ac_cv_path_DOXYGEN="/Applications/Doxygen.app/Contents/Resources/doxygen"
fi
IFS=$as_save_IFS
if test "x$DOXYGEN" = "xNO_DOXYGEN"; then
AC_MSG_RESULT([not found])
else
AC_MSG_RESULT($DOXYGEN)
fi
fi
if test "x$DOXYGEN" = "xNO_DOXYGEN"; then
AC_MSG_NOTICE([Couldn't find Doxygen -- documentation updates cannot be built without Doxygen])
else
AC_CONFIG_FILES([doc/Doxyfile])
fi
DOXYGEN_OUTPUT_DIRECTORY="doc/html"
AC_SUBST(DOXYGEN_OUTPUT_DIRECTORY)
AC_CONFIG_FILES([Makefile lib/Makefile src/Makefile tests/Makefile examples/Makefile reflex.pc reflexmin.pc])
AC_OUTPUT