more autism
[mkp224o.git] / configure.ac
blobf5260a2cdace91e989347d58fc53d3e50371769f
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 cstd=""
121 c99=""
122 oldcflags="$CFLAGS"
123 CFLAGS="-std=c99"
124 AC_MSG_CHECKING([whether CC supports -std=c99])
125 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
126     [AC_MSG_RESULT([yes])]
127     [c99="yes"]
128     [cstd="-std=c99"],
129     [AC_MSG_RESULT([no])]
131 CFLAGS="$cstd -Wall"
132 AC_MSG_CHECKING([whether CC supports -Wall])
133 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
134     [AC_MSG_RESULT([yes])]
135     [cstd="$cstd -Wall"],
136     [AC_MSG_RESULT([no])]
138 if test "x$c99" = "xyes" -a "x$ed25519impl" != "xdonna"
139 then
140         CFLAGS="$cstd -Wpedantic"
141         AC_MSG_CHECKING([whether CC supports -Wpedantic])
142         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
143                 [AC_MSG_RESULT([yes])]
144                 [cstd="$cstd -Wpedantic"],
145                 [AC_MSG_RESULT([no])]
146         )
148 if test "x$ed25519impl" = "xdonna"
149 then
150         CFLAGS="$cstd -Wno-unused-function"
151         AC_MSG_CHECKING([whether CC supports -Wno-unused-function])
152         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
153                 [AC_MSG_RESULT([yes])]
154                 [cstd="$cstd -Wno-unused-function"],
155                 [AC_MSG_RESULT([no])]
156         )
158 CFLAGS="$oldcflags"
161 AC_ARG_ENABLE([intfilter],
162         [AS_HELP_STRING([--enable-intfilter],
163                 [use 64-bit integers for filtering. faster but limits filter length to 12 @<:@default=no@:>@])],
164         [], [enable_intfilter=no]
166 AC_ARG_ENABLE([intfilter32],
167         [AS_HELP_STRING([--enable-intfilter32],
168                 [use 32-bit integers for filtering. even faster on 32-bit machines but limits filter length to 6 @<:@default=no@:>@])],
169         [], [enable_intfilter32=no]
171 if test "x$enable_intfilter32" = "xyes"
172 then
173         if test "x$enable_intfilter" = "xyes"
174         then
175                 AC_MSG_WARN([both intfilter and intfilter32 specified; using intfilter32])
176         fi
177         MYDEFS="$MYDEFS -DINTFILTER -DIFT=u32"
178 else
179         if test "x$enable_intfilter" = "xyes"
180         then
181                 MYDEFS="$MYDEFS -DINTFILTER"
182         fi
185 AC_ARG_ENABLE([binfilterlen],
186         [AS_HELP_STRING([--enable-binfilterlen=VAL],
187                 [set binary string filter length (if you don't use intfilter) @<:@default=32@:>@])],
188         [], [enable_binfilterlen=no]
190 if test "x$enable_binfilterlen" != "xyes" -a "x$enable_binfilterlen" != "xno"
191 then
192         MYDEFS="$MYDEFS -DBINFILTERLEN=$enable_binfilterlen"
195 AC_ARG_ENABLE([binsearch],
196         [AS_HELP_STRING([--enable-binsearch],
197                 [enable binary search algoritm; MUCH faster if there are a lot of filters @<:@default=no@:>@])],
198         [], [enable_binsearch=no]
200 if test "x$enable_binsearch" = "xyes"
201 then
202         MYDEFS="$MYDEFS -DBINSEARCH"
205 AC_ARG_ENABLE([statistics],
206         [AS_HELP_STRING([--enable-statistics],
207                 [collect statistics @<:@default=yes@:>@])],
208         [], [enable_statistics=yes]
210 if test "x$enable_statistics" = "xyes"
211 then
212         MYDEFS="$MYDEFS -DSTATISTICS"
215 AC_SUBST(CSTD,["$cstd"])
216 AC_SUBST(ED25519IMPL,["$ed25519impl"])
217 AC_SUBST(MYDEFS,["$MYDEFS"])
218 AC_SUBST(NOPIE,["$nopie"])
219 AC_OUTPUT(Makefile)