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