ed25519-donna: batchpack maybe
[mkp224o.git] / configure.ac
blobd9970687a5838fe708a0ff3b1fb3ae3a1f7df4ee
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 cstd=""
162 c99=""
163 oldcflags="$CFLAGS"
164 CFLAGS="-std=c99"
165 AC_MSG_CHECKING([whether CC supports -std=c99])
166 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
167     [AC_MSG_RESULT([yes])]
168     [c99="yes"]
169     [cstd="-std=c99"],
170     [AC_MSG_RESULT([no])]
172 CFLAGS="$cstd -Wall"
173 AC_MSG_CHECKING([whether CC supports -Wall])
174 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
175     [AC_MSG_RESULT([yes])]
176     [cstd="$cstd -Wall"],
177     [AC_MSG_RESULT([no])]
179 CFLAGS="$cstd -Wno-maybe-uninitialized"
180 AC_MSG_CHECKING([whether CC supports -Wno-maybe-uninitialized])
181 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
182     [AC_MSG_RESULT([yes])]
183     [cstd="$cstd -Wno-maybe-uninitialized"],
184     [AC_MSG_RESULT([no])]
186 if test "x$c99" = "xyes" -a "x$ed25519impl" != "xdonna" -a "x$enable_intfilter" != "x128"
187 then
188         CFLAGS="$cstd -pedantic"
189         AC_MSG_CHECKING([whether CC supports -pedantic])
190         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
191                 [AC_MSG_RESULT([yes])]
192                 [cstd="$cstd -pedantic"],
193                 [AC_MSG_RESULT([no])]
194         )
196 if test "x$ed25519impl" = "xdonna"
197 then
198         CFLAGS="$cstd -Wno-unused-function"
199         AC_MSG_CHECKING([whether CC supports -Wno-unused-function])
200         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
201                 [AC_MSG_RESULT([yes])]
202                 [cstd="$cstd -Wno-unused-function"],
203                 [AC_MSG_RESULT([no])]
204         )
206 CFLAGS="$oldcflags"
208 AC_ARG_ENABLE([binfilterlen],
209         [AS_HELP_STRING([--enable-binfilterlen=VAL],
210                 [set binary string filter length (if you don't use intfilter) @<:@default=32@:>@])],
211         [], [enable_binfilterlen=no]
213 if test "x$enable_binfilterlen" != "xyes" -a "x$enable_binfilterlen" != "xno"
214 then
215         MYDEFS="$MYDEFS -DBINFILTERLEN=$enable_binfilterlen"
218 AC_ARG_ENABLE([binsearch],
219         [AS_HELP_STRING([--enable-binsearch],
220                 [enable binary search algoritm; MUCH faster if there are a lot of filters @<:@default=no@:>@])],
221         [], [enable_binsearch=no]
223 if test "x$enable_binsearch" = "xyes"
224 then
225         MYDEFS="$MYDEFS -DBINSEARCH"
228 AC_ARG_ENABLE([besort],
229         [AS_HELP_STRING([--enable-besort],
230                 [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@:>@])],
231         [], [enable_besort=no]
233 if test "x$enable_besort" = "xyes"
234 then
235         MYDEFS="$MYDEFS -DBESORT"
238 AC_ARG_ENABLE([statistics],
239         [AS_HELP_STRING([--enable-statistics],
240                 [collect statistics @<:@default=yes@:>@])],
241         [], [enable_statistics=yes]
243 if test "x$enable_statistics" = "xyes"
244 then
245         MYDEFS="$MYDEFS -DSTATISTICS"
248 AC_ARG_WITH([pcre2],[AC_HELP_STRING([--with-pcre2],[pcre2-config executable @<:@default=pcre2-config@:>@])],[],[with_pcre2="pcre2-config"])
250 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])
251 case "$enable_regex" in
252 no|"")
253         ;;
254 yes|pcre2)
255         AC_MSG_CHECKING([pcre2])
256         V=""
257         if test "$with_pcre2" != "yes"
258         then
259                 V=`"$with_pcre2" --version 2>/dev/null`
260         fi
261         if test -n "$V"
262         then
263                 AC_MSG_RESULT([$V])
264                 MYDEFS="$MYDEFS -DPCRE2FILTER"
265                 CF=`"$with_pcre2" --cflags`
266                 if test -n "$CF"
267                 then
268                         CFLAGS="$CFLAGS $CF"
269                 fi
270                 LF=`"$with_pcre2" --libs8`
271                 if test -n "$LF"
272                 then
273                         MAINLIB="$MAINLIB $LF"
274                 fi
275         else
276                 AC_MSG_RESULT([not found])
277                 AC_ERROR([pcre2-config cannot be executed])
278         fi
279         ;;
281         AC_MSG_WARN([unrecognised regex engine type: $enable_regex])
282         ;;
283 esac
285 AC_SUBST(CSTD,["$cstd"])
286 AC_SUBST(ED25519IMPL,["$ed25519impl"])
287 AC_SUBST(MYDEFS,["$MYDEFS"])
288 AC_SUBST(MAINLIB,["$MAINLIB"])
289 AC_SUBST(NOPIE,["$nopie"])
290 AC_OUTPUT(Makefile)