cleanup right side reseed
[mkp224o.git] / configure.ac
blob55a5b1b2954cb454624afd2ad14b9da094c35228
1 AC_INIT(mkp224o)
2 # sanity check
3 AC_CONFIG_SRCDIR([main.c])
4 # C compiler
5 oldcflags="$CFLAGS"
6 AC_PROG_CC
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"
11 then
12         oldcflags="-O3"
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"],
18                 [AC_MSG_RESULT([no])]
19         )
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"],
25                 [AC_MSG_RESULT([no])]
26         )
27         CFLAGS="$oldcflags"
30 nopie=""
32 oldcflags="$CFLAGS"
33 CFLAGS="-nopie"
34 AC_MSG_CHECKING([whether CC supports -nopie])
35 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
36     [AC_MSG_RESULT([yes])]
37     [nopie="-nopie"],
38     [AC_MSG_RESULT([no])]
40 CFLAGS="$oldcflags"
42 if test "x$nopie" = "x"
43 then
44         oldcflags="$CFLAGS"
45         CFLAGS="-no-pie"
46         AC_MSG_CHECKING([whether CC supports -no-pie])
47         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
48                 [AC_MSG_RESULT([yes])]
49                 [nopie="-no-pie"],
50                 [AC_MSG_RESULT([no])]
51         )
52         CFLAGS="$oldcflags"
55 MYDEFS=""
56 MAINLIB=""
58 ed25519impl=""
59 AC_ARG_ENABLE([ref10],
60         [AS_HELP_STRING([--enable-ref10],
61                 [use SUPERCOP ref10 ed25519 implementation @<:@default=yes@:>@])],
62         [
63                 AS_IF([test "x$ed25519impl" != "x" -a "$ed25519impl" != "ref10"],
64                         [AC_ERROR([only one ed25519 implementation can be defined])])
65                 ed25519impl="ref10"
66         ],
67         []
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@:>@])],
73         [
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"
77         ],
78         []
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@:>@])],
84         [
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"
88         ],
89         []
92 AC_ARG_ENABLE([donna],
93         [AS_HELP_STRING([--enable-donna],
94                 [use ed25519-donna implementation @<:@default=no@:>@])],
95         [
96                 AS_IF([test "x$ed25519impl" != "x" -a "$ed25519impl" != "donna"],
97                         [AC_ERROR([only one ed25519 implementation can be defined])])
98                 ed25519impl="donna"
99         ],
100         []
103 AC_ARG_ENABLE([donna-sse2],
104         [AS_HELP_STRING([--enable-donna-sse2],
105                 [use ed25519-donna SSE2 implementation @<:@default=no@:>@])],
106         [
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"
110         ],
111         []
114 AS_IF([test "x$ed25519impl" == "x"],[ed25519impl=ref10])
116 if test "$ed25519impl" = "donna-sse2"
117 then
118         ed25519impl="donna"
119         MYDEFS="$MYDEFS -DED25519_SSE2"
120         CFLAGS="$CFLAGS -msse2"
123 AC_ARG_ENABLE([intfilter],
124         [AS_HELP_STRING([--enable-intfilter@<:@=(32|64|128|native)@:>@],
125                 [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@:>@])],
126         [], [enable_intfilter=no]
128 AC_ARG_ENABLE([intfilter32],
129         [AS_HELP_STRING([--enable-intfilter32], [deprecated. use --enable-intfilter=32 instead])],
130         [enable_intfilter=32]
131         [AC_MSG_WARN([--enable-intfilter32 option is deprecated. use --enable-intfilter=32 instead])],
132         []
134 case "$enable_intfilter" in
136         intfiltertype="u32"
137         ;;
138 64|yes)
139         intfiltertype="u64"
140         ;;
141 128)
142         intfiltertype="unsigned __int128"
143         ;;
144 native)
145         intfiltertype="size_t"
146         ;;
147 no|"")
148         intfiltertype=""
149         ;;
151         AC_MSG_WARN([unrecognised intfilter type: $enable_intfilter])
152         intfiltertype=""
153         ;;
154 esac
156 if test -n "$intfiltertype"
157 then
158         MYDEFS="$MYDEFS -DINTFILTER -DIFT='$intfiltertype'"
161 AC_ARG_ENABLE([batchnum],
162         [AS_HELP_STRING([--enable-batchnum=number],
163                 [number of elements to batch when using -B @<:@default=2048@:>@])],
164         [], []
166 if test -n "$enable_batchnum" -a x"$enable_batchnum" != x"no"
167 then
168         MYDEFS="$MYDEFS -DBATCHNUM=$enable_batchnum"
171 cstd=""
172 c99=""
173 oldcflags="$CFLAGS"
174 CFLAGS="-std=c99"
175 AC_MSG_CHECKING([whether CC supports -std=c99])
176 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
177     [AC_MSG_RESULT([yes])]
178     [c99="yes"]
179     [cstd="-std=c99"],
180     [AC_MSG_RESULT([no])]
182 CFLAGS="$cstd -Wall"
183 AC_MSG_CHECKING([whether CC supports -Wall])
184 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
185     [AC_MSG_RESULT([yes])]
186     [cstd="$cstd -Wall"],
187     [AC_MSG_RESULT([no])]
189 CFLAGS="$cstd -Wno-maybe-uninitialized"
190 AC_MSG_CHECKING([whether CC supports -Wno-maybe-uninitialized])
191 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
192     [AC_MSG_RESULT([yes])]
193     [cstd="$cstd -Wno-maybe-uninitialized"],
194     [AC_MSG_RESULT([no])]
196 if test "x$c99" = "xyes" -a "x$ed25519impl" != "xdonna" -a "x$enable_intfilter" != "x128"
197 then
198         CFLAGS="$cstd -pedantic"
199         AC_MSG_CHECKING([whether CC supports -pedantic])
200         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
201                 [AC_MSG_RESULT([yes])]
202                 [cstd="$cstd -pedantic"],
203                 [AC_MSG_RESULT([no])]
204         )
206 if test "x$ed25519impl" = "xdonna"
207 then
208         CFLAGS="$cstd -Wno-unused-function"
209         AC_MSG_CHECKING([whether CC supports -Wno-unused-function])
210         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
211                 [AC_MSG_RESULT([yes])]
212                 [cstd="$cstd -Wno-unused-function"],
213                 [AC_MSG_RESULT([no])]
214         )
216 CFLAGS="$oldcflags"
218 AC_ARG_ENABLE([binfilterlen],
219         [AS_HELP_STRING([--enable-binfilterlen=VAL],
220                 [set binary string filter length (if you don't use intfilter) @<:@default=32@:>@])],
221         [], [enable_binfilterlen=no]
223 if test "x$enable_binfilterlen" != "xyes" -a "x$enable_binfilterlen" != "xno"
224 then
225         MYDEFS="$MYDEFS -DBINFILTERLEN=$enable_binfilterlen"
228 AC_ARG_ENABLE([binsearch],
229         [AS_HELP_STRING([--enable-binsearch],
230                 [enable binary search algoritm; MUCH faster if there are a lot of filters @<:@default=no@:>@])],
231         [], [enable_binsearch=no]
233 if test "x$enable_binsearch" = "xyes"
234 then
235         MYDEFS="$MYDEFS -DBINSEARCH"
238 AC_ARG_ENABLE([besort],
239         [AS_HELP_STRING([--enable-besort],
240                 [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@:>@])],
241         [], [enable_besort=no]
243 if test "x$enable_besort" = "xyes"
244 then
245         MYDEFS="$MYDEFS -DBESORT"
248 AC_ARG_ENABLE([statistics],
249         [AS_HELP_STRING([--enable-statistics],
250                 [collect statistics @<:@default=yes@:>@])],
251         [], [enable_statistics=yes]
253 if test "x$enable_statistics" = "xyes"
254 then
255         MYDEFS="$MYDEFS -DSTATISTICS"
258 AC_ARG_WITH([pcre2],[AC_HELP_STRING([--with-pcre2],[pcre2-config executable @<:@default=pcre2-config@:>@])],[],[with_pcre2="pcre2-config"])
260 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])
261 case "$enable_regex" in
262 no|"")
263         ;;
264 yes|pcre2)
265         AC_MSG_CHECKING([pcre2])
266         V=""
267         if test "$with_pcre2" != "yes"
268         then
269                 V=`"$with_pcre2" --version 2>/dev/null`
270         fi
271         if test -n "$V"
272         then
273                 AC_MSG_RESULT([$V])
274                 MYDEFS="$MYDEFS -DPCRE2FILTER"
275                 CF=`"$with_pcre2" --cflags`
276                 if test -n "$CF"
277                 then
278                         CFLAGS="$CFLAGS $CF"
279                 fi
280                 LF=`"$with_pcre2" --libs8`
281                 if test -n "$LF"
282                 then
283                         MAINLIB="$MAINLIB $LF"
284                 fi
285         else
286                 AC_MSG_RESULT([not found])
287                 AC_ERROR([pcre2-config cannot be executed])
288         fi
289         ;;
291         AC_MSG_WARN([unrecognised regex engine type: $enable_regex])
292         ;;
293 esac
295 AC_SUBST(CSTD,["$cstd"])
296 AC_SUBST(ED25519IMPL,["$ed25519impl"])
297 AC_SUBST(MYDEFS,["$MYDEFS"])
298 AC_SUBST(MAINLIB,["$MAINLIB"])
299 AC_SUBST(NOPIE,["$nopie"])
300 AC_OUTPUT(Makefile)