1#	$NetBSD: Makefile,v 1.26 2023/05/08 19:14:28 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
28# XXX: There's a bit of work to do before we can enable warnings.
29WARNS=0
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
48CRYPTODIST=	${NETBSDSRCDIR}/crypto
49OPENSSLINC=	${OPENSSLSRC}/include/openssl
50
51.include "${NETBSDSRCDIR}/crypto/Makefile.openssl"
52.PATH: ${OPENSSLSRC} ${OPENSSLINC}
53.PATH: ${OPENSSLSRC}/../include/openssl
54
55.include "srcs.inc"
56.include "${.CURDIR}/../libdefault/srcs.inc"
57CPPFLAGS+= -I${.CURDIR}/../libdefault
58.PATH: ${.CURDIR}/../libdefault
59.include "${.CURDIR}/../libcommon/srcs.inc"
60.PATH: ${.CURDIR}/../libcommon
61
62AFLAGS+=-DELF
63LIBDPLIBS+= crypt ${NETBSDSRCDIR}/lib/libcrypt
64
65OS_VERSION!= ${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh
66
67# XXX CFLAGS: While it would be nice to know which compiler flags
68# XXX the library was built with, we don't want pathname information
69# XXX for the host toolchain embedded in the image.
70${SRCS}: buildinf.h
71buildinf.h: Makefile
72	@echo "#ifndef MK1MF_BUILD" >buildinf.h
73	@echo "#define compiler_flags \"`${CC} -v 2>&1 | grep 'gcc version'`\"" >>buildinf.h
74	@echo "#define PLATFORM \"NetBSD-${MACHINE_ARCH}\"" >>buildinf.h
75	@echo "#define DATE \"NetBSD ${OS_VERSION}\"" >>buildinf.h
76	@echo "#endif" >>buildinf.h
77
78CLEANFILES+= buildinf.h
79
80# This list is built from the contents of the include/openssl
81# directory in the OpenSSL source distribution.
82INCS+= \
83aes.h \
84asn1.h \
85asn1_mac.h \
86asn1err.h \
87asn1t.h \
88async.h \
89asyncerr.h \
90bio.h \
91bioerr.h \
92blowfish.h \
93bn.h \
94bnerr.h \
95buffer.h \
96buffererr.h \
97camellia.h \
98cast.h \
99cmac.h \
100cmp.h \
101cmp_util.h \
102cmperr.h \
103cms.h \
104cmserr.h \
105comp.h \
106comperr.h \
107conf.h \
108conf_api.h \
109conferr.h \
110configuration.h \
111conftypes.h \
112core.h \
113core_dispatch.h \
114core_names.h \
115core_object.h \
116crmf.h \
117crmferr.h \
118crypto.h \
119cryptoerr.h \
120cryptoerr_legacy.h \
121ct.h \
122cterr.h \
123decoder.h \
124decodererr.h \
125des.h \
126dh.h \
127dherr.h \
128dsa.h \
129dsaerr.h \
130dtls1.h \
131e_os2.h \
132ebcdic.h \
133ec.h \
134ecdh.h \
135ecdsa.h \
136ecerr.h \
137encoder.h \
138encodererr.h \
139engine.h \
140engineerr.h \
141err.h \
142ess.h \
143esserr.h \
144evp.h \
145evperr.h \
146fips_names.h \
147fipskey.h \
148hmac.h \
149http.h \
150httperr.h \
151kdf.h \
152kdferr.h \
153lhash.h \
154macros.h \
155md2.h \
156md4.h \
157md5.h \
158modes.h \
159obj_mac.h \
160objects.h \
161objectserr.h \
162ocsp.h \
163ocsperr.h \
164opensslconf.h \
165opensslv.h \
166ossl_typ.h \
167param_build.h \
168params.h \
169pem.h \
170pem2.h \
171pemerr.h \
172pkcs12.h \
173pkcs12err.h \
174pkcs7.h \
175pkcs7err.h \
176prov_ssl.h \
177proverr.h \
178provider.h \
179rand.h \
180randerr.h \
181rc2.h \
182rc4.h \
183ripemd.h \
184rsa.h \
185rsaerr.h \
186safestack.h \
187seed.h \
188self_test.h \
189sha.h \
190srp.h \
191srtp.h \
192ssl.h \
193ssl2.h \
194ssl3.h \
195sslerr.h \
196sslerr_legacy.h \
197stack.h \
198store.h \
199storeerr.h \
200symhacks.h \
201tls1.h \
202trace.h \
203ts.h \
204tserr.h \
205txt_db.h \
206types.h \
207ui.h \
208uierr.h \
209whrlpool.h \
210x509.h \
211x509_vfy.h \
212x509err.h \
213x509v3.h \
214x509v3err.h
215
216# IDEA - patented, but we install the header anyways
217INCS+=	idea.h
218
219# RC5 - patented, but we install the header anyways
220INCS+=	rc5.h
221
222# MDC2 - patented, but we install the header anyways
223INCS+=	mdc2.h
224
225.if (${USE_FIPS} != "no")
226# FIPS
227# This part is always included, because OpenSSL does not protect
228# The FIPS include files
229.PATH: ${OPENSSLSRC}/fips ${OPENSSLSRC}/fips/rand
230INCS+=	fips.h fips_rand.h
231.endif
232
233.if (${USE_FIPS} != "no")
234CPPFLAGS+=-DOPENSSL_FIPS
235.PATH: ${OPENSSLSRC}/fips/aes
236SRCS+=fips_aes_core.c fips_aes_selftest.c
237.PATH: ${OPENSSLSRC}/fips/des
238SRCS+=fips_des_enc.c fips_des_selftest.c fips_set_key.c
239# asm/fips-dx86-elf.s
240.PATH: ${OPENSSLSRC}/fips/dh
241SRCS+=fips_dh_check.c fips_dh_gen.c fips_dh_key.c
242.PATH: ${OPENSSLSRC}/fips/dsa
243SRCS+=fips_dsa_ossl.c fips_dsa_gen.c fips_dsa_selftest.c
244#.PATH: ${OPENSSLSRC}/fips/rand
245SRCS+=fips_rand.c
246.PATH: ${OPENSSLSRC}/fips/rsa
247SRCS+=fips_rsa_eay.c fips_rsa_gen.c fips_rsa_selftest.c
248SRCS+=fips_sha1dgst.c fips_sha1_selftest.c
249# asm/sx86-elf.s
250.PATH: ${OPENSSLSRC}/fips/sha1
251#.PATH: ${OPENSSLSRC}/fips
252SRCS+=fips.c fips_err_wrapper.c
253
254SRCS+=rc5_skey.c i_skey.c mdc2dgst.c
255.endif
256
257COPTS.eng_padlock.c = -Wno-stack-protector
258
259INCSDIR=/usr/include/openssl
260
261LDFLAGS+=-Wl,--version-script=${.CURDIR}/crypto.map
262
263PKGCONFIG=libcrypto
264.include "${.CURDIR}/../../pkgconfig.mk"
265
266# too much of a pain to generate opensslv.h / configuration.h / fipskey.h
267GENH = \
268asn1.h \
269asn1t.h \
270bio.h \
271cmp.h \
272cms.h \
273conf.h \
274crmf.h \
275crypto.h \
276ct.h \
277err.h \
278ess.h \
279lhash.h \
280ocsp.h \
281pkcs12.h \
282pkcs7.h \
283safestack.h \
284srp.h \
285ssl.h \
286ui.h \
287x509.h \
288x509_vfy.h \
289x509v3.h
290
291.for i in ${GENH}
292$i: $i.in
293	${_MKTARGET_CREATE}
294	${.CURDIR}/gen ${.ALLSRC} > ${.TARGET}
295.endfor
296
297.include <bsd.lib.mk>
298
299