explicit void declaration, remove unused arg. thanks ccomp
[mkp224o.git] / configure.ac
blob475b0c163c57187b5b35bcda7862c4a48e97e5f1
1 AC_INIT(mkp224o)
2 # sanity check
3 AC_CONFIG_SRCDIR([main.c])
4 # C compiler
5 oldcflags="$CFLAGS"
6 AC_PROG_CC
8 if test "x$oldcflags" != "x$CFLAGS"
9 then
10         oldcflags="-O3"
11         CFLAGS="-march=native"
12         AC_MSG_CHECKING([whether CC supports -march=native])
13         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
14                 [AC_MSG_RESULT([yes])]
15                 [oldcflags="$oldcflags -march=native"],
16                 [AC_MSG_RESULT([no])]
17         )
18         CFLAGS="-fomit-frame-pointer"
19         AC_MSG_CHECKING([whether CC supports -fomit-frame-pointer])
20         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
21                 [AC_MSG_RESULT([yes])]
22                 [oldcflags="$oldcflags -fomit-frame-pointer"],
23                 [AC_MSG_RESULT([no])]
24         )
25         CFLAGS="$oldcflags"
28 nopie=""
30 oldcflags="$CFLAGS"
31 CFLAGS="-nopie"
32 AC_MSG_CHECKING([whether CC supports -nopie])
33 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
34     [AC_MSG_RESULT([yes])]
35     [nopie="-nopie"],
36     [AC_MSG_RESULT([no])]
38 CFLAGS="$oldcflags"
40 if test "x$nopie" = "x"
41 then
42         oldcflags="$CFLAGS"
43         CFLAGS="-no-pie"
44         AC_MSG_CHECKING([whether CC supports -no-pie])
45         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
46                 [AC_MSG_RESULT([yes])]
47                 [nopie="-no-pie"],
48                 [AC_MSG_RESULT([no])]
49         )
50         CFLAGS="$oldcflags"
53 MYDEFS=""
55 ed25519impl=""
56 AC_ARG_ENABLE([ref10],
57         [AS_HELP_STRING([--enable-ref10],
58                 [use SUPERCOP ref10 ed25519 implementation @<:@default=yes@:>@])],
59         [
60                 AS_IF([test "x$ed25519impl" != "x" -a "$ed25519impl" != "ref10"],
61                         [AC_ERROR([only one ed25519 implementation can be defined])])
62                 ed25519impl="ref10"
63         ],
64         []
67 AC_ARG_ENABLE([amd64-51-30k],
68         [AS_HELP_STRING([--enable-amd64-51-30k],
69                 [use SUPERCOP amd64-51-30k ed25519 implementation @<:@default=no@:>@])],
70         [
71                 AS_IF([test "x$ed25519impl" != "x" -a "$ed25519impl" != "amd64_51_30k"],
72                         [AC_ERROR([only one ed25519 implementation can be defined])])
73                 ed25519impl="amd64_51_30k"
74         ],
75         []
78 AC_ARG_ENABLE([amd64-64-24k],
79         [AS_HELP_STRING([--enable-amd64-64-24k],
80                 [use SUPERCOP amd64-64-24k ed25519 implementation @<:@default=no@:>@])],
81         [
82                 AS_IF([test "x$ed25519impl" != "x" -a "$ed25519impl" != "amd64_64_24k"],
83                         [AC_ERROR([only one ed25519 implementation can be defined])])
84                 ed25519impl="amd64_64_24k"
85         ],
86         []
89 AC_ARG_ENABLE([donna],
90         [AS_HELP_STRING([--enable-donna],
91                 [use ed25519-donna implementation @<:@default=no@:>@])],
92         [
93                 AS_IF([test "x$ed25519impl" != "x" -a "$ed25519impl" != "donna"],
94                         [AC_ERROR([only one ed25519 implementation can be defined])])
95                 ed25519impl="donna"
96         ],
97         []
100 AC_ARG_ENABLE([donna-sse2],
101         [AS_HELP_STRING([--enable-donna-sse2],
102                 [use ed25519-donna SSE2 implementation @<:@default=no@:>@])],
103         [
104                 AS_IF([test "x$ed25519impl" != "x" -a "$ed25519impl" != "donna-sse2"],
105                         [AC_ERROR([only one ed25519 implementation can be defined])])
106                 ed25519impl="donna-sse2"
107         ],
108         []
111 AS_IF([test "x$ed25519impl" == "x"],[ed25519impl=ref10])
113 if test "$ed25519impl" = "donna-sse2"
114 then
115         ed25519impl="donna"
116         MYDEFS="$MYDEFS -DED25519_SSE2"
117         CFLAGS="$CFLAGS -msse2"
120 AC_ARG_ENABLE([intfilter],
121         [AS_HELP_STRING([--enable-intfilter@<:@=(32|64|128|native)@:>@],
122                 [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@:>@])],
123         [], [enable_intfilter=no]
125 AC_ARG_ENABLE([intfilter32],
126         [AS_HELP_STRING([--enable-intfilter32], [deprecated. use --enable-intfilter=32 instead])],
127         [enable_intfilter=32]
128         [AC_MSG_WARN([--enable-intfilter32 option is deprecated. use --enable-intfilter=32 instead])],
129         []
131 case "$enable_intfilter" in
133         intfiltertype="u32"
134         ;;
135 64|yes)
136         intfiltertype="u64"
137         ;;
138 128)
139         intfiltertype="unsigned __int128"
140         ;;
141 native)
142         intfiltertype="size_t"
143         ;;
145         intfiltertype=""
146         ;;
148         AC_MSG_WARN([unrecognised intfilter type: $enable_intfilter])
149         intfiltertype=""
150         ;;
151 esac
153 if test -n "$intfiltertype"
154 then
155         MYDEFS="$MYDEFS -DINTFILTER -DIFT='$intfiltertype'"
158 cstd=""
159 c99=""
160 oldcflags="$CFLAGS"
161 CFLAGS="-std=c99"
162 AC_MSG_CHECKING([whether CC supports -std=c99])
163 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
164     [AC_MSG_RESULT([yes])]
165     [c99="yes"]
166     [cstd="-std=c99"],
167     [AC_MSG_RESULT([no])]
169 CFLAGS="$cstd -Wall"
170 AC_MSG_CHECKING([whether CC supports -Wall])
171 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
172     [AC_MSG_RESULT([yes])]
173     [cstd="$cstd -Wall"],
174     [AC_MSG_RESULT([no])]
176 if test "x$c99" = "xyes" -a "x$ed25519impl" != "xdonna" -a "x$enable_intfilter" != "x128"
177 then
178         CFLAGS="$cstd -Wpedantic"
179         AC_MSG_CHECKING([whether CC supports -Wpedantic])
180         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
181                 [AC_MSG_RESULT([yes])]
182                 [cstd="$cstd -Wpedantic"],
183                 [AC_MSG_RESULT([no])]
184         )
186 if test "x$ed25519impl" = "xdonna"
187 then
188         CFLAGS="$cstd -Wno-unused-function"
189         AC_MSG_CHECKING([whether CC supports -Wno-unused-function])
190         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
191                 [AC_MSG_RESULT([yes])]
192                 [cstd="$cstd -Wno-unused-function"],
193                 [AC_MSG_RESULT([no])]
194         )
196 CFLAGS="$oldcflags"
198 AC_ARG_ENABLE([binfilterlen],
199         [AS_HELP_STRING([--enable-binfilterlen=VAL],
200                 [set binary string filter length (if you don't use intfilter) @<:@default=32@:>@])],
201         [], [enable_binfilterlen=no]
203 if test "x$enable_binfilterlen" != "xyes" -a "x$enable_binfilterlen" != "xno"
204 then
205         MYDEFS="$MYDEFS -DBINFILTERLEN=$enable_binfilterlen"
208 AC_ARG_ENABLE([binsearch],
209         [AS_HELP_STRING([--enable-binsearch],
210                 [enable binary search algoritm; MUCH faster if there are a lot of filters @<:@default=no@:>@])],
211         [], [enable_binsearch=no]
213 if test "x$enable_binsearch" = "xyes"
214 then
215         MYDEFS="$MYDEFS -DBINSEARCH"
218 AC_ARG_ENABLE([besort],
219         [AS_HELP_STRING([--enable-besort],
220                 [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@:>@])],
221         [], [enable_besort=no]
223 if test "x$enable_besort" = "xyes"
224 then
225         MYDEFS="$MYDEFS -DBESORT"
228 AC_ARG_ENABLE([statistics],
229         [AS_HELP_STRING([--enable-statistics],
230                 [collect statistics @<:@default=yes@:>@])],
231         [], [enable_statistics=yes]
233 if test "x$enable_statistics" = "xyes"
234 then
235         MYDEFS="$MYDEFS -DSTATISTICS"
238 AC_SUBST(CSTD,["$cstd"])
239 AC_SUBST(ED25519IMPL,["$ed25519impl"])
240 AC_SUBST(MYDEFS,["$MYDEFS"])
241 AC_SUBST(NOPIE,["$nopie"])
242 AC_OUTPUT(Makefile)