1#	$NetBSD: Makefile,v 1.28 2023/05/17 19:09:41 christos Exp $
2
3# RCSid:
4#	Id: Makefile,v 1.33 1998/11/11 11:53:53 sjg Exp
5#
6#	@(#) Copyright (c) 1994 Simon J. Gerraty
7#
8#	This file is provided in the hope that it will
9#	be of use.  There is absolutely NO WARRANTY.
10#	Permission to copy, redistribute or otherwise
11#	use this file is hereby granted provided that
12#	the above copyright notice and this notice are
13#	left intact.
14#
15#	Please send copies of changes and bug-fixes to:
16#	sjg@quick.com.au
17#
18
19LIB=	crypto
20USE_FORT?= yes	# cryptographic software
21USE_SHLIBDIR=	yes
22USE_FIPS=	no
23#DBG=-g
24
25.include <bsd.own.mk>
26.include <bsd.shlib.mk>
27
28COPTS+= -Wno-error=cast-qual -Wno-error=discarded-qualifiers
29COPTS+= -Wno-error=missing-field-initializers -Wno-error=char-subscripts
30CWARNFLAGS.clang+=	-Wno-empty-body -Wno-unused-value -Wno-parentheses -Wno-implicit-int-float-conversion
31# XXX: This warning seems to trigger incorrectly
32CWARNFLAGS.clang+=	-Wno-atomic-alignment
33
34LINTFLAGS+=	-X 161	# constant in conditional context
35LINTFLAGS+=	-X 129	# expression has null effect
36LINTFLAGS+=	-X 117	# bitwise '>>' on signed value possibly nonportable
37LINTFLAGS+=	-X 231	# argument '%s' unused in function '%s'
38LINTFLAGS+=	-X 220	# fallthrough on case statement
39LINTFLAGS+=	-X 118	# semantics of '%s' change in ANSI C; use explicit cast
40
41CPPFLAGS+= -Dlib${LIB} -I. -I${OPENSSLSRC}/crypto -I${OPENSSLSRC}
42CPPFLAGS+= -I${OPENSSLSRC}/include -I${OPENSSLSRC}/crypto/include
43CPPFLAGS+= -I${OPENSSLSRC}/crypto/asn1 -I${OPENSSLSRC}/crypto/evp
44CPPFLAGS+= -I${OPENSSLSRC}/crypto/modes
45CPPFLAGS+= -I${OPENSSLSRC}/../include
46
47
48
49CRYPTODIST=	${NETBSDSRCDIR}/crypto
50OPENSSLINC=	${OPENSSLSRC}/include/openssl
51
52.include "${NETBSDSRCDIR}/crypto/Makefile.openssl"
53.PATH: ${OPENSSLSRC} ${OPENSSLINC}
54.PATH: ${OPENSSLSRC}/../include/openssl
55
56.include "srcs.inc"
57.include "${.CURDIR}/../libdefault/srcs.inc"
58CPPFLAGS+= -I${.CURDIR}/../libdefault
59CPPFLAGS+= -I${OPENSSLSRC}/providers/common/include
60CPPFLAGS+= -I${OPENSSLSRC}/providers/implementations/include
61.PATH: ${.CURDIR}/../libdefault
62.include "${.CURDIR}/../libcommon/srcs.inc"
63.PATH: ${.CURDIR}/../libcommon
64
65AFLAGS+=-DELF
66LIBDPLIBS+= crypt ${NETBSDSRCDIR}/lib/libcrypt
67
68OS_VERSION!= ${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh
69
70# XXX CFLAGS: While it would be nice to know which compiler flags
71# XXX the library was built with, we don't want pathname information
72# XXX for the host toolchain embedded in the image.
73${SRCS}: buildinf.h
74buildinf.h: Makefile
75	@echo "#ifndef MK1MF_BUILD" >buildinf.h
76	@echo "#define compiler_flags \"`${CC} -v 2>&1 | grep 'gcc version'`\"" >>buildinf.h
77	@echo "#define PLATFORM \"NetBSD-${MACHINE_ARCH}\"" >>buildinf.h
78	@echo "#define DATE \"NetBSD ${OS_VERSION}\"" >>buildinf.h
79	@echo "#endif" >>buildinf.h
80
81CLEANFILES+= buildinf.h
82
83# This list is built from the contents of the include/openssl
84# directory in the OpenSSL source distribution.
85INCS+= \
86aes.h \
87asn1.h \
88asn1_mac.h \
89asn1err.h \
90asn1t.h \
91async.h \
92asyncerr.h \
93bio.h \
94bioerr.h \
95blowfish.h \
96bn.h \
97bnerr.h \
98buffer.h \
99buffererr.h \
100camellia.h \
101cast.h \
102cmac.h \
103cmp.h \
104cmp_util.h \
105cmperr.h \
106cms.h \
107cmserr.h \
108comp.h \
109comperr.h \
110conf.h \
111conf_api.h \
112conferr.h \
113configuration.h \
114conftypes.h \
115core.h \
116core_dispatch.h \
117core_names.h \
118core_object.h \
119crmf.h \
120crmferr.h \
121crypto.h \
122cryptoerr.h \
123cryptoerr_legacy.h \
124ct.h \
125cterr.h \
126decoder.h \
127decodererr.h \
128des.h \
129dh.h \
130dherr.h \
131dsa.h \
132dsaerr.h \
133dtls1.h \
134e_os2.h \
135ebcdic.h \
136ec.h \
137ecdh.h \
138ecdsa.h \
139ecerr.h \
140encoder.h \
141encodererr.h \
142engine.h \
143engineerr.h \
144err.h \
145ess.h \
146esserr.h \
147evp.h \
148evperr.h \
149fips_names.h \
150fipskey.h \
151hmac.h \
152http.h \
153httperr.h \
154kdf.h \
155kdferr.h \
156lhash.h \
157macros.h \
158md2.h \
159md4.h \
160md5.h \
161modes.h \
162obj_mac.h \
163objects.h \
164objectserr.h \
165ocsp.h \
166ocsperr.h \
167opensslconf.h \
168opensslv.h \
169ossl_typ.h \
170param_build.h \
171params.h \
172pem.h \
173pem2.h \
174pemerr.h \
175pkcs12.h \
176pkcs12err.h \
177pkcs7.h \
178pkcs7err.h \
179prov_ssl.h \
180proverr.h \
181provider.h \
182rand.h \
183randerr.h \
184rc2.h \
185rc4.h \
186ripemd.h \
187rsa.h \
188rsaerr.h \
189safestack.h \
190seed.h \
191self_test.h \
192sha.h \
193srp.h \
194srtp.h \
195ssl.h \
196ssl2.h \
197ssl3.h \
198sslerr.h \
199sslerr_legacy.h \
200stack.h \
201store.h \
202storeerr.h \
203symhacks.h \
204tls1.h \
205trace.h \
206ts.h \
207tserr.h \
208txt_db.h \
209types.h \
210ui.h \
211uierr.h \
212whrlpool.h \
213x509.h \
214x509_vfy.h \
215x509err.h \
216x509v3.h \
217x509v3err.h
218
219# IDEA - patented, but we install the header anyways
220INCS+=	idea.h
221
222# RC5 - patented, but we install the header anyways
223INCS+=	rc5.h
224
225# MDC2 - patented, but we install the header anyways
226INCS+=	mdc2.h
227
228.if (${USE_FIPS} != "no")
229# FIPS
230# This part is always included, because OpenSSL does not protect
231# The FIPS include files
232.PATH: ${OPENSSLSRC}/fips ${OPENSSLSRC}/fips/rand
233INCS+=	fips.h fips_rand.h
234.endif
235
236.if (${USE_FIPS} != "no")
237CPPFLAGS+=-DOPENSSL_FIPS
238.PATH: ${OPENSSLSRC}/fips/aes
239SRCS+=fips_aes_core.c fips_aes_selftest.c
240.PATH: ${OPENSSLSRC}/fips/des
241SRCS+=fips_des_enc.c fips_des_selftest.c fips_set_key.c
242# asm/fips-dx86-elf.s
243.PATH: ${OPENSSLSRC}/fips/dh
244SRCS+=fips_dh_check.c fips_dh_gen.c fips_dh_key.c
245.PATH: ${OPENSSLSRC}/fips/dsa
246SRCS+=fips_dsa_ossl.c fips_dsa_gen.c fips_dsa_selftest.c
247#.PATH: ${OPENSSLSRC}/fips/rand
248SRCS+=fips_rand.c
249.PATH: ${OPENSSLSRC}/fips/rsa
250SRCS+=fips_rsa_eay.c fips_rsa_gen.c fips_rsa_selftest.c
251SRCS+=fips_sha1dgst.c fips_sha1_selftest.c
252# asm/sx86-elf.s
253.PATH: ${OPENSSLSRC}/fips/sha1
254#.PATH: ${OPENSSLSRC}/fips
255SRCS+=fips.c fips_err_wrapper.c
256
257SRCS+=rc5_skey.c i_skey.c mdc2dgst.c
258.endif
259
260COPTS.eng_padlock.c = -Wno-stack-protector
261
262INCSDIR=/usr/include/openssl
263
264LDFLAGS+=-Wl,--version-script=${.CURDIR}/crypto.map
265
266PKGCONFIG=libcrypto
267.include "${.CURDIR}/../../pkgconfig.mk"
268
269# too much of a pain to generate opensslv.h / configuration.h / fipskey.h
270GENH = \
271asn1.h \
272asn1t.h \
273bio.h \
274cmp.h \
275cms.h \
276conf.h \
277crmf.h \
278crypto.h \
279ct.h \
280err.h \
281ess.h \
282lhash.h \
283ocsp.h \
284pkcs12.h \
285pkcs7.h \
286safestack.h \
287srp.h \
288ssl.h \
289ui.h \
290x509.h \
291x509_vfy.h \
292x509v3.h
293
294.for i in ${GENH}
295$i: $i.in
296	${_MKTARGET_CREATE}
297	${.CURDIR}/gen ${.ALLSRC} > ${.TARGET}
298.endfor
299
300.include <bsd.lib.mk>
301
302