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