-
Notifications
You must be signed in to change notification settings - Fork 80
/
configure.ac
341 lines (309 loc) · 9.81 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.69)
AC_INIT([libisal_crypto],
[2.25.0],
[https://github.com/intel/isa-l_crypto/issues],
[isa-l_crypto])
AC_CONFIG_SRCDIR([])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([
foreign
1.11
-Wall
-Wno-portability
silent-rules
tar-pax
no-dist-gzip
dist-xz
subdir-objects
])
AM_PROG_AS
AC_CANONICAL_HOST
CPU=""
AS_CASE([$host_cpu],
[x86_64], [CPU="x86_64"],
[amd64], [CPU="x86_64"],
[i?86], [CPU="x86_32"],
[aarch64], [CPU="aarch64"],
[arm64], [CPU="aarch64"],
)
AM_CONDITIONAL([CPU_X86_64], [test "$CPU" = "x86_64"])
AM_CONDITIONAL([CPU_X86_32], [test "$CPU" = "x86_32"])
AM_CONDITIONAL([CPU_AARCH64], [test "$CPU" = "aarch64"])
AM_CONDITIONAL([CPU_UNDEFINED], [test "x$CPU" = "x"])
AM_CONDITIONAL([SAFE_PARAM], [test x"$SAFE_PARAM" = x"yes"])
if test "$CPU" = "x86_64"; then
is_x86=yes
else
if test "$CPU" = "x86_32"; then
is_x86=yes
else
is_x86=no
fi
fi
# Check for programs
AC_PROG_CC_STDC
AC_USE_SYSTEM_EXTENSIONS
AM_SILENT_RULES([yes])
LT_INIT
AC_PREFIX_DEFAULT([/usr])
AC_PROG_SED
AC_PROG_MKDIR_P
# Options
AC_ARG_ENABLE([debug],
AS_HELP_STRING([--enable-debug], [enable debug messages @<:@default=disabled@:>@]),
[], [enable_debug=no])
AS_IF([test "x$enable_debug" = "xyes"], [
AC_DEFINE(ENABLE_DEBUG, [1], [Debug messages.])
])
AC_ARG_ENABLE([fips-mode],
AS_HELP_STRING([--enable-fips-mode], [enable FIPS mode @<:@default=disabled@:>@]),
[enable_fips_mode=yes], [enable_fips_mode=no])
AS_IF([test "x$enable_fips_mode" = "xyes"], [
AC_DEFINE(FIPS_MODE, [1], [FIPS mode.])
])
AC_ARG_ENABLE([safe-data],
AS_HELP_STRING([--disable-safe-data], [clear sensitive data @<:@default=enabled@:>@]),
[safe_data=no], [safe_data=yes])
AS_IF([test "x$safe_data" = "xyes"], [
AC_DEFINE(SAFE_DATA, [1], [Clear sensitive data.])
])
AC_ARG_ENABLE([safe-param],
AS_HELP_STRING([--disable-safe-param], [enable parameter checking @<:@default=enabled@:>@]),
[safe_param=no], [safe_param=yes])
AS_IF([test "x$safe_param" = "xyes"], [
AC_DEFINE(SAFE_PARAM, [1], [Enable parameter checking.])
])
if test x"$CPU" = x"aarch64"; then
AC_ARG_ENABLE([sve2],
AS_HELP_STRING([--disable-sve2], [disable usage of SVE2]),
, enable_sve2=yes)
if test "$enable_sve2" = "yes"; then
AC_MSG_CHECKING([whether compiler supports sve2])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
[asm(".arch armv8.2-a+sve2");])],
[cc_support_sve2=yes],
[cc_support_sve2=no])
if test x"$cc_support_sve2" = xyes ; then
AC_MSG_RESULT([yes])
else
AC_MSG_RESULT([no])
AC_MSG_ERROR([upgrade your compiler to support SVE2, or run \"./configure --disable-sve2\"])
fi
else
AC_DEFINE(NO_SVE2, 1, [Define to 1 if the compiler does not supports SVE2.])
fi
fi
# If this build is for x86, look for nasm
if test x"$is_x86" = x"yes"; then
AC_MSG_CHECKING([whether Intel CET is enabled])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
#ifndef __CET__
# error CET is not enabled
#endif]])],[AC_MSG_RESULT([yes])
intel_cet_enabled=yes],[AC_MSG_RESULT([no])
intel_cet_enabled=no])
AS_IF([test "x$intel_cet_enabled" = "xyes"], [
AC_DEFINE(INTEL_CET_ENABLED, [1], [Intel CET enabled.])
])
# check if LD -z options are supported
LDFLAGS="\
-Wl,-z,noexecstack \
-Wl,-z,relro \
-Wl,-z,now \
"
AC_MSG_CHECKING([if $LD supports $LDFLAGS])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
int main(int argc, char **argv)
{
return 0;
}]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
LDFLAGS=""]
)
# Pick NASM assembler
if test x"$AS" = x""; then
# Check for nasm and nasm features
nasm_feature_level=0
AC_CHECK_PROG(HAVE_NASM, nasm, yes, no)
if test "$HAVE_NASM" = "yes"; then
nasm_feature_level=1
else
AC_MSG_RESULT([no nasm])
fi
if test x"$nasm_feature_level" = x"1"; then
AC_MSG_CHECKING([for modern nasm])
AC_LANG_CONFTEST([AC_LANG_SOURCE([[pblendvb xmm2, xmm1;]])])
sed -i -e '/pblendvb/!d' conftest.c
if nasm -f elf64 conftest.c 2> /dev/null; then
AC_MSG_RESULT([yes])
nasm_feature_level=4
else
AC_MSG_RESULT([no])
fi
fi
if test x"$nasm_feature_level" = x"4"; then
AC_MSG_CHECKING([for optional nasm AVX512 support])
AC_LANG_CONFTEST([AC_LANG_SOURCE([[vinserti32x8 zmm0, ymm1, 1;]])])
sed -i -e '/vinsert/!d' conftest.c
if nasm -f elf64 conftest.c 2> /dev/null; then
AC_MSG_RESULT([yes])
nasm_feature_level=6
else
AC_MSG_RESULT([no])
fi
fi
if test x"$nasm_feature_level" = x"6"; then
AC_MSG_CHECKING([for additional nasm AVX512 support])
AC_LANG_CONFTEST([AC_LANG_SOURCE([[vpcompressb zmm0 {k1}, zmm1;]])])
sed -i -e '/vpcompressb/!d' conftest.c
if nasm -f elf64 conftest.c 2> /dev/null; then
AC_MSG_RESULT([yes])
nasm_feature_level=10
else
AC_MSG_RESULT([no])
fi
fi
AS=nasm
as_feature_level=$nasm_feature_level
else
# Check for $AS supported features
as_feature_level=0
AC_CHECK_PROG(HAVE_AS, $AS, yes, no)
if test "$HAVE_AS" = "yes"; then
as_feature_level=1
else
AC_MSG_ERROR([no $AS])
fi
if test x"$as_feature_level" = x"1"; then
AC_MSG_CHECKING([for modern $AS])
AC_LANG_CONFTEST([AC_LANG_SOURCE([[pblendvb xmm2, xmm1;]])])
sed -i -e '/pblendvb/!d' conftest.c
if $AS -f elf64 conftest.c 2> /dev/null; then
AC_MSG_RESULT([yes])
as_feature_level=4
else
AC_MSG_RESULT([no])
fi
fi
if test x"$as_feature_level" = x"4"; then
AC_MSG_CHECKING([for optional as AVX512 support])
AC_LANG_CONFTEST([AC_LANG_SOURCE([[vinserti32x8 zmm0, ymm1, 1;]])])
sed -i -e '/vinsert/!d' conftest.c
if $AS -f elf64 conftest.c 2> /dev/null; then
AC_MSG_RESULT([yes])
as_feature_level=6
else
AC_MSG_RESULT([no])
fi
fi
if test x"$as_feature_level" = x"6"; then
AC_MSG_CHECKING([for additional as AVX512 support])
AC_LANG_CONFTEST([AC_LANG_SOURCE([[vpcompressb zmm0, k1, zmm1;]])])
sed -i -e '/vpcompressb/!d' conftest.c
if $AS -f elf64 conftest.c 2> /dev/null; then
AC_MSG_RESULT([yes])
as_feature_level=10
else
AC_MSG_RESULT([no])
fi
fi
AC_MSG_CHECKING([for optional nasm SHA-NI support])
AC_LANG_CONFTEST([AC_LANG_SOURCE([[sha256rnds2 xmm2,xmm1,xmm0;]])])
sed -i -e '/sha256rnds2/!d' conftest.c
if $AS -f elf64 conftest.c 2> /dev/null; then
AC_MSG_RESULT([yes])
as_knows_shani=yes
else
AC_MSG_RESULT([no])
fi
fi
if test $as_feature_level -lt 10 ; then
AC_MSG_ERROR([No modern nasm found as required. Nasm should be v2.14.01 or later.])
fi
if test x"$as_knows_shani" = x"yes"; then
AC_DEFINE(HAVE_AS_KNOWS_SHANI, [1], [Assembler can do SHANI.])
have_as_knows_shani=yes
else
AC_MSG_RESULT([Assembler does not understand SHANI opcodes. Consider upgrading for best performance.])
fi
case $host_os in
*linux*) arch=linux asm_args="-f elf64";;
*darwin*) arch=darwin asm_args="-f macho64 --prefix=_ ";;
*netbsd*) arch=netbsd asm_args="-f elf64";;
*mingw*) arch=mingw asm_args="-f win64";;
*) arch=unknown asm_args="-f elf64";;
esac
AC_DEFINE_UNQUOTED(AS_FEATURE_LEVEL, [$as_feature_level], [Assembler feature level.])
if test $as_feature_level -ge 6 ; then
AC_DEFINE(HAVE_AS_KNOWS_AVX512, [1], [Assembler can do AVX512.])
have_as_knows_avx512=yes
else
AC_MSG_RESULT([Assembler does not understand AVX512 opcodes. Consider upgrading for best performance.])
fi
AM_CONDITIONAL(SAFE_DATA, test x"$SAFE_DATA" = x"yes")
AM_CONDITIONAL(FIPS_MODE, test x"$FIPS_MODE" = x"yes")
AM_CONDITIONAL(USE_NASM, test x"$AS" = x"nasm")
AM_CONDITIONAL(WITH_AVX512, test x"$have_as_knows_avx512" = x"yes")
AM_CONDITIONAL(WITH_SHANI, test x"$have_as_knows_shani" = x"yes")
AC_SUBST([asm_args])
AM_CONDITIONAL(DARWIN, test x"$arch" = x"darwin")
AC_MSG_RESULT([Using $AS args target "$arch" "$asm_args"])
else
# Disable below conditionals if not x86
AM_CONDITIONAL(SAFE_DATA, test "x" = "y")
AM_CONDITIONAL(FIPS_MODE, test "x" = "y")
AM_CONDITIONAL(USE_NASM, test "x" = "y")
AM_CONDITIONAL(WITH_AVX512, test "x" = "y")
AM_CONDITIONAL(WITH_SHANI, test "x" = "y")
AM_CONDITIONAL(DARWIN, test "x" = "y")
fi
# Check for header files
AC_CHECK_HEADERS([limits.h stdint.h stdlib.h string.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_SIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINT8_T
# Checks for library functions.
AC_FUNC_MALLOC # Used only in tests
AC_CHECK_FUNCS([memmove memset])
my_CFLAGS="\
-Wall \
-fPIC \
-Wchar-subscripts \
-Wformat-security \
-Wnested-externs \
-Wpointer-arith \
-Wshadow \
-Wstrict-prototypes \
-Wtype-limits \
-fstack-protector \
-D_FORTIFY_SOURCE=2 \
-DNO_COMPAT_ISAL_CRYPTO_API_2_24
"
AC_SUBST([my_CFLAGS])
AC_CONFIG_FILES([\
Makefile\
libisal_crypto.pc
])
AC_OUTPUT
AC_MSG_RESULT([
$PACKAGE $VERSION
=====
prefix: ${prefix}
sysconfdir: ${sysconfdir}
libdir: ${libdir}
includedir: ${includedir}
compiler: ${CC}
cflags: ${CFLAGS}
ldflags: ${LDFLAGS}
debug: ${enable_debug}
safe_data: ${safe_data}
safe_param: ${safe_param}
FIPS mode: ${enable_fips_mode}
])