1#	$NetBSD: Makefile,v 1.11 2025/11/24 16:28:51 nia Exp $
2
3.include <bsd.own.mk>
4
5TESTSDIR=	${TESTSBASE}/sys/crypto/aes
6
7TESTS_C=	t_aes
8
9AFLAGS+=	-D_LOCORE
10
11.PATH:	${NETBSDSRCDIR}/sys/crypto/aes
12CPPFLAGS+=	-I${NETBSDSRCDIR}/sys
13
14SRCS.t_aes+=	t_aes.c
15
16SRCS.t_aes+=	aes_bear.c
17SRCS.t_aes+=	aes_ct.c
18SRCS.t_aes+=	aes_ct_dec.c
19SRCS.t_aes+=	aes_ct_enc.c
20
21SRCS.t_aes+=	aes_bear64.c
22SRCS.t_aes+=	aes_ct64.c
23SRCS.t_aes+=	aes_ct64_dec.c
24SRCS.t_aes+=	aes_ct64_enc.c
25
26SRCS.t_aes+=	aes_keysched.c
27SRCS.t_aes+=	aes_selftest.c
28
29.if !empty(MACHINE_ARCH:Mearmv7*) || !empty(MACHINE_ARCH:Maarch64*)
30
31.PATH:	${NETBSDSRCDIR}/sys/crypto/aes/arch/arm
32CPPFLAGS+=	-I${NETBSDSRCDIR}/sys/crypto/aes/arch/arm
33
34.if !empty(MACHINE_ARCH:Maarch64*)	# XXX no AESE/AESD in 32-bit mode yet
35SRCS.t_aes+=	aes_armv8.c
36SRCS.t_aes+=	aes_armv8_64.S
37.endif
38
39CLANG_NO_NONPORTABLE_VECTOR_INITIALIZATION= ${${ACTIVE_CC} == "clang":? -Wno-nonportable-vector-initialization :}
40
41SRCS.t_aes+=	aes_neon.c
42COPTS.aes_neon.c+=${CLANG_NO_NONPORTABLE_VECTOR_INITIALIZATION}
43SRCS.t_aes+=	aes_neon_impl.c
44SRCS.t_aes+=	aes_neon_subr.c
45COPTS.aes_neon_subr.c+=${CLANG_NO_NONPORTABLE_VECTOR_INITIALIZATION}
46.if !empty(MACHINE_ARCH:Mearmv7*)
47SRCS.t_aes+=	aes_neon_32.S
48.endif
49
50.if !empty(MACHINE_ARCH:Mearmv7*) && empty(MACHINE_ARCH:Mearmv7hf*)
51COPTS.aes_neon.c+=	-mfloat-abi=softfp -mfpu=neon
52COPTS.aes_neon_subr.c+=	-mfloat-abi=softfp -mfpu=neon
53AOPTS.aes_neon_32.S+=	-D__SOFTFP__
54.endif
55
56.endif				# earmv7/aarch64
57
58.if ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64"
59
60.PATH:	${NETBSDSRCDIR}/sys/crypto/aes/arch/x86
61CPPFLAGS+=	-I${NETBSDSRCDIR}/sys/crypto/aes/arch/x86
62
63.if ${MACHINE_ARCH} == "x86_64"		# XXX no AES-NI in 32-bit mode yet
64SRCS.t_aes+=	aes_ni.c
65SRCS.t_aes+=	aes_ni_64.S
66.endif
67
68SRCS.t_aes+=	aes_sse2_4x32.c
69SRCS.t_aes+=	aes_sse2_4x32_dec.c
70SRCS.t_aes+=	aes_sse2_4x32_enc.c
71SRCS.t_aes+=	aes_sse2_4x32_impl.c
72SRCS.t_aes+=	aes_sse2_4x32_subr.c
73COPTS.aes_sse2_4x32.c+=		-msse -msse2
74COPTS.aes_sse2_4x32_dec.c+=	-msse -msse2
75COPTS.aes_sse2_4x32_enc.c+=	-msse -msse2
76COPTS.aes_sse2_4x32_subr.c+=	-msse -msse2
77
78SRCS.t_aes+=	aes_ssse3.c
79SRCS.t_aes+=	aes_ssse3_impl.c
80SRCS.t_aes+=	aes_ssse3_subr.c
81COPTS.aes_ssse3.c+=		-msse -msse2 -msse3 -mssse3
82COPTS.aes_ssse3_subr.c+=	-msse -msse2 -msse3 -mssse3
83
84SRCS.t_aes+=	aes_via.c
85
86.endif				# x86
87
88WARNS=		5
89
90# Many of these are probably GCC bugs, see
91#   https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110878
92COPTS.aes_armv8.c+=	${CC_WNO_STRINGOP_OVERREAD} ${CC_WNO_STRINGOP_OVERFLOW}
93COPTS.aes_bear.c+=	${CC_WNO_STRINGOP_OVERFLOW} ${CC_WNO_ARRAY_BOUNDS}
94COPTS.aes_bear64.c+=	${CC_WNO_STRINGOP_OVERFLOW} ${CC_WNO_ARRAY_BOUNDS} \
95			${CC_WNO_STRINGOP_OVERREAD}
96COPTS.aes_neon_subr.c+=	${CC_WNO_ARRAY_BOUNDS}
97
98COPTS.aes_ni.c+=	${CC_WNO_STRINGOP_OVERREAD} ${CC_WNO_STRINGOP_OVERFLOW}
99COPTS.aes_sse2_4x32_subr.c+=	${CC_WNO_ARRAY_BOUNDS}
100COPTS.aes_ssse3_subr.c+=${CC_WNO_ARRAY_BOUNDS}
101COPTS.aes_via.c+=	${CC_WNO_ARRAY_BOUNDS}
102
103.include <bsd.test.mk>
104