3 AC_CONFIG_SRCDIR([main.c])
8 # NOTE: this script intentionally doesn't check for small details like posix functions and hard dependencies (libsodium) so you may get errors at compilation
10 if test "x$oldcflags" != "x$CFLAGS"
13 CFLAGS="-march=native"
14 AC_MSG_CHECKING([whether CC supports -march=native])
15 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
16 [AC_MSG_RESULT([yes])]
17 [oldcflags="$oldcflags -march=native"],
20 CFLAGS="-fomit-frame-pointer"
21 AC_MSG_CHECKING([whether CC supports -fomit-frame-pointer])
22 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
23 [AC_MSG_RESULT([yes])]
24 [oldcflags="$oldcflags -fomit-frame-pointer"],
33 CFLAGS="-nopie -Werror"
34 AC_MSG_CHECKING([whether CC supports -nopie])
35 AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
36 [AC_MSG_RESULT([yes])]
42 if test "x$nopie" = "x"
45 CFLAGS="-no-pie -Werror"
46 AC_MSG_CHECKING([whether CC supports -no-pie])
47 AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
48 [AC_MSG_RESULT([yes])]
59 AC_ARG_ENABLE([ref10],
60 [AS_HELP_STRING([--enable-ref10],
61 [use SUPERCOP ref10 ed25519 implementation @<:@default=no@:>@])],
63 AS_IF([test "x$ed25519impl" != "x" -a "$ed25519impl" != "ref10"],
64 [AC_ERROR([only one ed25519 implementation can be defined])])
70 AC_ARG_ENABLE([amd64-51-30k],
71 [AS_HELP_STRING([--enable-amd64-51-30k],
72 [use SUPERCOP amd64-51-30k ed25519 implementation @<:@default=no@:>@])],
74 AS_IF([test "x$ed25519impl" != "x" -a "$ed25519impl" != "amd64_51_30k"],
75 [AC_ERROR([only one ed25519 implementation can be defined])])
76 ed25519impl="amd64_51_30k"
81 AC_ARG_ENABLE([amd64-64-24k],
82 [AS_HELP_STRING([--enable-amd64-64-24k],
83 [use SUPERCOP amd64-64-24k ed25519 implementation @<:@default=no@:>@])],
85 AS_IF([test "x$ed25519impl" != "x" -a "$ed25519impl" != "amd64_64_24k"],
86 [AC_ERROR([only one ed25519 implementation can be defined])])
87 ed25519impl="amd64_64_24k"
92 AC_ARG_ENABLE([donna],
93 [AS_HELP_STRING([--enable-donna],
94 [use ed25519-donna implementation @<:@default=yes@:>@])],
96 AS_IF([test "x$ed25519impl" != "x" -a "$ed25519impl" != "donna"],
97 [AC_ERROR([only one ed25519 implementation can be defined])])
103 AC_ARG_ENABLE([donna-sse2],
104 [AS_HELP_STRING([--enable-donna-sse2],
105 [use ed25519-donna SSE2 implementation @<:@default=no@:>@])],
107 AS_IF([test "x$ed25519impl" != "x" -a "$ed25519impl" != "donna-sse2"],
108 [AC_ERROR([only one ed25519 implementation can be defined])])
109 ed25519impl="donna-sse2"
115 AS_IF([test "x$ed25519impl" == "x"],[ed25519impl="donna"])
117 if test "$ed25519impl" = "donna-sse2"
120 MYDEFS="$MYDEFS -DED25519_SSE2"
121 CFLAGS="$CFLAGS -msse2"
126 AC_ARG_ENABLE([intfilter],
127 [AS_HELP_STRING([--enable-intfilter@<:@=(32|64|128|native)@:>@],
128 [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@:>@])],
129 [], [enable_intfilter=no]
131 AC_ARG_ENABLE([intfilter32],
132 [AS_HELP_STRING([--enable-intfilter32], [deprecated. use --enable-intfilter=32 instead])],
133 [enable_intfilter=32]
134 [AC_MSG_WARN([--enable-intfilter32 option is deprecated. use --enable-intfilter=32 instead])],
137 case "$enable_intfilter" in
145 intfiltertype="unsigned __int128"
148 intfiltertype="size_t"
154 AC_MSG_WARN([unrecognised intfilter type: $enable_intfilter])
159 if test -n "$intfiltertype"
161 MYDEFS="$MYDEFS -DINTFILTER -DIFT='$intfiltertype'"
164 AC_ARG_ENABLE([batchnum],
165 [AS_HELP_STRING([--enable-batchnum=number],
166 [number of elements to batch when using -B @<:@default=2048@:>@])],
169 if test -n "$enable_batchnum" -a x"$enable_batchnum" != x"no"
171 MYDEFS="$MYDEFS -DBATCHNUM=$enable_batchnum"
179 AC_MSG_CHECKING([whether CC supports -std=c99])
180 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
181 [AC_MSG_RESULT([yes])]
184 [AC_MSG_RESULT([no])]
188 AC_MSG_CHECKING([whether CC supports -Wall])
189 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
190 [AC_MSG_RESULT([yes])]
191 [cstd="$cstd -Wall"],
192 [AC_MSG_RESULT([no])]
195 CFLAGS="$cstd -Wextra"
196 AC_MSG_CHECKING([whether CC supports -Wextra])
197 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
198 [AC_MSG_RESULT([yes])]
199 [cstd="$cstd -Wextra"],
200 [AC_MSG_RESULT([no])]
203 # (negative) detection on clang fails without -Werror
204 CFLAGS="$cstd -Wno-maybe-uninitialized -Werror"
205 AC_MSG_CHECKING([whether CC supports -Wno-maybe-uninitialized])
206 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
207 [AC_MSG_RESULT([yes])]
208 [cstd="$cstd -Wno-maybe-uninitialized"],
209 [AC_MSG_RESULT([no])]
212 if test "x$c99" = "xyes" -a "x$ed25519impl" != "xdonna" -a "x$enable_intfilter" != "x128"
214 CFLAGS="$cstd -pedantic"
215 AC_MSG_CHECKING([whether CC supports -pedantic])
216 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
217 [AC_MSG_RESULT([yes])]
218 [cstd="$cstd -pedantic"],
219 [AC_MSG_RESULT([no])]
223 CFLAGS="$cstd -Wno-format -Wno-pedantic-ms-format -Werror"
224 AC_MSG_CHECKING([whether CC supports and needs -Wno-format -Wno-pedantic-ms-format])
225 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#ifndef _WIN32
228 [AC_MSG_RESULT([yes])]
229 [cstd="$cstd -Wno-format -Wno-pedantic-ms-format"],
230 [AC_MSG_RESULT([no])]
233 if test "x$ed25519impl" = "xdonna"
235 CFLAGS="$cstd -Wno-unused-function -Werror"
236 AC_MSG_CHECKING([whether CC supports -Wno-unused-function])
237 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
238 [AC_MSG_RESULT([yes])]
239 [cstd="$cstd -Wno-unused-function"],
240 [AC_MSG_RESULT([no])]
244 CFLAGS="$cstd -Wmissing-prototypes -Werror"
245 AC_MSG_CHECKING([whether CC supports -Wmissing-prototypes])
246 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
247 [AC_MSG_RESULT([yes])]
248 [cstd="$cstd -Wmissing-prototypes"],
249 [AC_MSG_RESULT([no])]
252 # XXX AC_LANG_PROGRAM produces unsuitable prototype so this check must be last one
253 CFLAGS="$cstd -Wstrict-prototypes -Werror"
254 AC_MSG_CHECKING([whether CC supports -Wstrict-prototypes])
255 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int main(void) { return 0; }]])],
256 [AC_MSG_RESULT([yes])]
257 [cstd="$cstd -Wstrict-prototypes"],
258 [AC_MSG_RESULT([no])]
263 AC_ARG_ENABLE([binfilterlen],
264 [AS_HELP_STRING([--enable-binfilterlen=VAL],
265 [set binary string filter length (if you don't use intfilter) @<:@default=32@:>@])],
266 [], [enable_binfilterlen=no]
268 if test "x$enable_binfilterlen" != "xyes" -a "x$enable_binfilterlen" != "xno"
270 MYDEFS="$MYDEFS -DBINFILTERLEN=$enable_binfilterlen"
273 AC_ARG_ENABLE([binsearch],
274 [AS_HELP_STRING([--enable-binsearch],
275 [enable binary search algoritm; MUCH faster if there are a lot of filters @<:@default=no@:>@])],
276 [], [enable_binsearch=no]
278 if test "x$enable_binsearch" = "xyes"
280 MYDEFS="$MYDEFS -DBINSEARCH"
283 AC_ARG_ENABLE([besort],
284 [AS_HELP_STRING([--enable-besort],
285 [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@:>@])],
286 [], [enable_besort=no]
288 if test "x$enable_besort" = "xyes"
290 MYDEFS="$MYDEFS -DBESORT"
293 AC_ARG_ENABLE([statistics],
294 [AS_HELP_STRING([--enable-statistics],
295 [collect statistics @<:@default=yes@:>@])],
296 [], [enable_statistics=yes]
298 if test "x$enable_statistics" = "xyes"
300 MYDEFS="$MYDEFS -DSTATISTICS"
303 AC_ARG_WITH([pcre2],[AC_HELP_STRING([--with-pcre2],[pcre2-config executable @<:@default=pcre2-config@:>@])],[],[with_pcre2="pcre2-config"])
305 AC_ARG_ENABLE([regex],[AC_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])
306 case "$enable_regex" in
310 AC_MSG_CHECKING([pcre2])
312 if test "$with_pcre2" != "yes"
314 V=`"$with_pcre2" --version 2>/dev/null`
319 MYDEFS="$MYDEFS -DPCRE2FILTER"
320 CF=`"$with_pcre2" --cflags`
325 LF=`"$with_pcre2" --libs8`
328 MAINLIB="$MAINLIB $LF"
331 AC_MSG_RESULT([not found])
332 AC_ERROR([pcre2-config cannot be executed])
336 AC_MSG_WARN([unrecognised regex engine type: $enable_regex])
341 AC_MSG_CHECKING([whether ARGON2ID13 is supported by libsodium])
344 [[#include <sodium/crypto_pwhash.h>]],
345 [[int alg = crypto_pwhash_ALG_ARGON2ID13;(void) alg;]]
347 [AC_MSG_RESULT([yes])]
348 [MYDEFS="$MYDEFS -DPASSPHRASE"],
349 [AC_MSG_RESULT([no])]
353 # recreate dir tree, because otherwise gcc will fuck up
354 (cd "$srcdir" && find ed25519 -type d) | xargs mkdir -p
356 AC_SUBST(CSTD,["$cstd"])
357 AC_SUBST(ED25519IMPL,["$ed25519impl"])
358 AC_SUBST(MYDEFS,["$MYDEFS"])
359 AC_SUBST(MAINLIB,["$MAINLIB"])
360 AC_SUBST(NOPIE,["$nopie"])
361 AC_SUBST(SRCDIR,["$srcdir"])
362 AC_OUTPUT(GNUmakefile)