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