forked from cathugger/mkp224o
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
398 lines (356 loc) · 9.85 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
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
AC_INIT(mkp224o)
# sanity check
AC_CONFIG_SRCDIR([main.c])
# C compiler
oldcflags="$CFLAGS"
AC_PROG_CC
# determine version
ver=""
if test -r "$srcdir/version.txt"
then
ver=`cat "$srcdir/version.txt"`
elif test -d "$srcdir/.git"
then
if git --version >/dev/null 2>&1
then
# try matching exact tag
ver=`git -C "$srcdir" describe --tags --exact-match 2>/dev/null`
if test -z "$ver"
then
# otherwise obtain full commit ID
ver=`git -C "$srcdir" rev-parse HEAD 2>/dev/null`
if test -n "$ver"
then
ver=git-$ver
fi
fi
if test -n "$ver"
then
if ! git -C "$srcdir" diff --exit-code >/dev/null 2>&1
then
# add at the end to mark modified version
ver="$ver"'*'
fi
fi
fi
fi
if test -z "$ver"
then
ver=unknown
fi
# NOTE: this script intentionally doesn't check for small details like posix functions and hard dependencies (libsodium) so you may get errors at compilation
if test x"$oldcflags" != x"$CFLAGS"
then
oldcflags="-O3"
CFLAGS="-march=native"
AC_MSG_CHECKING([whether CC supports -march=native])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_RESULT([yes])]
[oldcflags="$oldcflags -march=native"],
[AC_MSG_RESULT([no])]
)
CFLAGS="-fomit-frame-pointer"
AC_MSG_CHECKING([whether CC supports -fomit-frame-pointer])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_RESULT([yes])]
[oldcflags="$oldcflags -fomit-frame-pointer"],
[AC_MSG_RESULT([no])]
)
CFLAGS="$oldcflags"
fi
pie=""
oldcflags="$CFLAGS"
CFLAGS="-fPIE -Werror"
AC_MSG_CHECKING([whether CC supports -fPIE])
AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_RESULT([yes])]
[pie="-fPIE"],
[AC_MSG_RESULT([no])]
)
CFLAGS="$oldcflags"
MYDEFS=""
MAINLIB=""
ed25519impl=""
AC_ARG_ENABLE([ref10],
[AS_HELP_STRING([--enable-ref10],
[use SUPERCOP ref10 ed25519 implementation @<:@default=no@:>@])],
[
AS_IF([test x"$ed25519impl" != x"" -a "$ed25519impl" != "ref10"],
[AC_MSG_ERROR(only one ed25519 implementation can be defined)])
ed25519impl="ref10"
],
[]
)
AC_ARG_ENABLE([amd64-51-30k],
[AS_HELP_STRING([--enable-amd64-51-30k],
[use SUPERCOP amd64-51-30k ed25519 implementation @<:@default=no@:>@])],
[
AS_IF([test x"$ed25519impl" != x"" -a "$ed25519impl" != "amd64_51_30k"],
[AC_MSG_ERROR(only one ed25519 implementation can be defined)])
ed25519impl="amd64_51_30k"
],
[]
)
AC_ARG_ENABLE([amd64-64-24k],
[AS_HELP_STRING([--enable-amd64-64-24k],
[use SUPERCOP amd64-64-24k ed25519 implementation @<:@default=no@:>@])],
[
AS_IF([test x"$ed25519impl" != x"" -a "$ed25519impl" != "amd64_64_24k"],
[AC_MSG_ERROR(only one ed25519 implementation can be defined)])
ed25519impl="amd64_64_24k"
],
[]
)
AC_ARG_ENABLE([donna],
[AS_HELP_STRING([--enable-donna],
[use ed25519-donna implementation @<:@default=yes@:>@])],
[
AS_IF([test x"$ed25519impl" != x"" -a "$ed25519impl" != "donna"],
[AC_MSG_ERROR(only one ed25519 implementation can be defined)])
ed25519impl="donna"
],
[]
)
AC_ARG_ENABLE([donna-sse2],
[AS_HELP_STRING([--enable-donna-sse2],
[use ed25519-donna SSE2 implementation @<:@default=no@:>@])],
[
AS_IF([test x"$ed25519impl" != x"" -a "$ed25519impl" != "donna-sse2"],
[AC_MSG_ERROR(only one ed25519 implementation can be defined)])
ed25519impl="donna-sse2"
],
[]
)
# default
AS_IF([test x"$ed25519impl" = x""],[ed25519impl="donna"])
if test "$ed25519impl" = "donna-sse2"
then
ed25519impl="donna"
MYDEFS="$MYDEFS -DED25519_SSE2"
CFLAGS="$CFLAGS -msse2"
fi
AC_ARG_ENABLE([intfilter],
[AS_HELP_STRING([--enable-intfilter@<:@=(32|64|128|native)@:>@],
[use integers of specific size @<:@default=64@:>@ for filtering. faster but limits filter length to: 6 for 32-bit, 12 for 64-bit, 24 for 128-bit @<:@default=no@:>@])],
[], [enable_intfilter=no]
)
AC_ARG_ENABLE([intfilter32],
[AS_HELP_STRING([--enable-intfilter32], [deprecated. use --enable-intfilter=32 instead])],
[enable_intfilter=32]
[AC_MSG_WARN([--enable-intfilter32 option is deprecated. use --enable-intfilter=32 instead])],
[]
)
case "$enable_intfilter" in
32)
intfiltertype="u32"
;;
64|yes)
intfiltertype="u64"
;;
128)
intfiltertype="unsigned __int128"
;;
native)
intfiltertype="size_t"
;;
no|"")
intfiltertype=""
;;
*)
AC_MSG_WARN([unrecognised intfilter type: $enable_intfilter])
intfiltertype=""
;;
esac
if test -n "$intfiltertype"
then
MYDEFS="$MYDEFS -DINTFILTER -DIFT='$intfiltertype'"
fi
AC_ARG_ENABLE([batchnum],
[AS_HELP_STRING([--enable-batchnum=number],
[number of elements to batch when using -B @<:@default=2048@:>@])],
[], []
)
if test -n "$enable_batchnum" -a x"$enable_batchnum" != x"no"
then
MYDEFS="$MYDEFS -DBATCHNUM=$enable_batchnum"
fi
cstd=""
c99=""
oldcflags="$CFLAGS"
CFLAGS="-std=c99"
AC_MSG_CHECKING([whether CC supports -std=c99])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_RESULT([yes])]
[c99="yes"]
[cstd="-std=c99"],
[AC_MSG_RESULT([no])]
)
CFLAGS="$cstd -Wall"
AC_MSG_CHECKING([whether CC supports -Wall])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_RESULT([yes])]
[cstd="$cstd -Wall"],
[AC_MSG_RESULT([no])]
)
CFLAGS="$cstd -Wextra"
AC_MSG_CHECKING([whether CC supports -Wextra])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_RESULT([yes])]
[cstd="$cstd -Wextra"],
[AC_MSG_RESULT([no])]
)
# (negative) detection on clang fails without -Werror
CFLAGS="$cstd -Wno-maybe-uninitialized -Werror"
AC_MSG_CHECKING([whether CC supports -Wno-maybe-uninitialized])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_RESULT([yes])]
[cstd="$cstd -Wno-maybe-uninitialized"],
[AC_MSG_RESULT([no])]
)
if test x"$c99" = x"yes" -a x"$ed25519impl" != x"donna" -a x"$enable_intfilter" != x"128"
then
CFLAGS="$cstd -pedantic"
AC_MSG_CHECKING([whether CC supports -pedantic])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_RESULT([yes])]
[cstd="$cstd -pedantic"],
[AC_MSG_RESULT([no])]
)
fi
CFLAGS="$cstd -Wno-format -Wno-pedantic-ms-format -Werror"
AC_MSG_CHECKING([whether CC supports and needs -Wno-format -Wno-pedantic-ms-format])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#ifndef _WIN32
#error wants windows
#endif]], [])],
[AC_MSG_RESULT([yes])]
[cstd="$cstd -Wno-format -Wno-pedantic-ms-format"],
[AC_MSG_RESULT([no])]
)
if test x"$ed25519impl" = x"donna"
then
CFLAGS="$cstd -Wno-unused-function -Werror"
AC_MSG_CHECKING([whether CC supports -Wno-unused-function])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_RESULT([yes])]
[cstd="$cstd -Wno-unused-function"],
[AC_MSG_RESULT([no])]
)
fi
if test x"$ed25519impl" = x"amd64_64_24k"
then
CFLAGS="$cstd -Wno-unused-const-variable -Werror"
AC_MSG_CHECKING([whether CC supports -Wno-unused-const-variable])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_RESULT([yes])]
[cstd="$cstd -Wno-unused-const-variable"],
[AC_MSG_RESULT([no])]
)
fi
CFLAGS="$cstd -Wmissing-prototypes -Werror"
AC_MSG_CHECKING([whether CC supports -Wmissing-prototypes])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_RESULT([yes])]
[cstd="$cstd -Wmissing-prototypes"],
[AC_MSG_RESULT([no])]
)
# XXX AC_LANG_PROGRAM produces unsuitable prototype so this check must be last one
CFLAGS="$cstd -Wstrict-prototypes -Werror"
AC_MSG_CHECKING([whether CC supports -Wstrict-prototypes])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int main(void) { return 0; }]])],
[AC_MSG_RESULT([yes])]
[cstd="$cstd -Wstrict-prototypes"],
[AC_MSG_RESULT([no])]
)
CFLAGS="$oldcflags"
AC_ARG_ENABLE([binfilterlen],
[AS_HELP_STRING([--enable-binfilterlen=VAL],
[set binary string filter length (if you don't use intfilter) @<:@default=32@:>@])],
[], [enable_binfilterlen=no]
)
if test x"$enable_binfilterlen" != x"yes" -a x"$enable_binfilterlen" != x"no"
then
MYDEFS="$MYDEFS -DBINFILTERLEN=$enable_binfilterlen"
fi
AC_ARG_ENABLE([binsearch],
[AS_HELP_STRING([--enable-binsearch],
[enable binary search algoritm; MUCH faster if there are a lot of filters @<:@default=no@:>@])],
[], [enable_binsearch=no]
)
if test x"$enable_binsearch" = x"yes"
then
MYDEFS="$MYDEFS -DBINSEARCH"
fi
AC_ARG_ENABLE([besort],
[AS_HELP_STRING([--enable-besort],
[force intfilter binsearch case to use big endian sorting and not omit masks from filters; useful if your filters aren't of same length @<:@default=no@:>@])],
[], [enable_besort=no]
)
if test x"$enable_besort" = x"yes"
then
MYDEFS="$MYDEFS -DBESORT"
fi
AC_ARG_ENABLE([statistics],
[AS_HELP_STRING([--enable-statistics],
[collect statistics @<:@default=yes@:>@])],
[], [enable_statistics=yes]
)
if test x"$enable_statistics" = x"yes"
then
MYDEFS="$MYDEFS -DSTATISTICS"
fi
AC_ARG_WITH([pcre2],[AS_HELP_STRING([--with-pcre2],[pcre2-config executable @<:@default=pcre2-config@:>@])],[],[with_pcre2="pcre2-config"])
AC_ARG_ENABLE([regex],[AS_HELP_STRING([--enable-regex],[whether to enable regex engine. currently possible values are "pcre2" and "yes" which defaults to "pcre2" @<:@default=no@:>@])],[],[enable_regex=no])
case "$enable_regex" in
no|"")
;;
yes|pcre2)
AC_MSG_CHECKING([pcre2])
V=""
if test "$with_pcre2" != "yes"
then
V=`"$with_pcre2" --version 2>/dev/null`
fi
if test -n "$V"
then
AC_MSG_RESULT([$V])
MYDEFS="$MYDEFS -DPCRE2FILTER"
CF=`"$with_pcre2" --cflags`
if test -n "$CF"
then
CFLAGS="$CFLAGS $CF"
fi
LF=`"$with_pcre2" --libs8`
if test -n "$LF"
then
MAINLIB="$MAINLIB $LF"
fi
else
AC_MSG_RESULT([not found])
AC_MSG_ERROR(pcre2-config cannot be executed)
fi
;;
*)
AC_MSG_WARN([unrecognised regex engine type: $enable_regex])
;;
esac
AC_MSG_CHECKING([whether ARGON2ID13 is supported by libsodium])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM(
[[#include <sodium/crypto_pwhash.h>]],
[[int alg = crypto_pwhash_ALG_ARGON2ID13;(void) alg;]]
)],
[AC_MSG_RESULT([yes])]
[MYDEFS="$MYDEFS -DPASSPHRASE"],
[AC_MSG_RESULT([no])]
)
# recreate dir tree, because otherwise gcc will fuck up
(cd "$srcdir" && find ed25519 -type d) | xargs mkdir -p
AC_SUBST(CSTD,["$cstd"])
AC_SUBST(ED25519IMPL,["$ed25519impl"])
AC_SUBST(MYDEFS,["$MYDEFS"])
AC_SUBST(MAINLIB,["$MAINLIB"])
AC_SUBST(PIE,["$pie"])
AC_SUBST(SRCDIR,["$srcdir"])
AC_SUBST(VERSION,["$ver"])
AC_CONFIG_FILES([GNUmakefile])
AC_OUTPUT