xref: /freebsd/crypto/openssl/BSDmakefile (revision 267f8c1f4b09431b335d5f48d84586047471f978)
1# This BSD makefile helps provide a deterministic means of doing a "clean"
2# vendor import of OpenSSL.
3#
4# Recommended use:
5#
6#   % make clean
7#   % make all
8
9NO_OBJ=
10
11LCRYPTO_SRC=	${SRCTOP}/crypto/openssl
12LCRYPTO_DOC=	${LCRYPTO_SRC}/doc
13
14CAT?=		/bin/cat
15MV?=		/bin/mv
16PERL?=		perl
17
18BN_CONF_H=		include/crypto/bn_conf.h
19BN_CONF_H_ORIG=		${BN_CONF_H}.orig
20CONFIGURATION_H=	include/openssl/configuration.h
21CONFIGURATION_H_ORIG=	${CONFIGURATION_H}.orig
22
23.PHONY: configure patch all
24.ORDER: configure patch all
25
26configure:
27	@cd ${.CURDIR} && \
28	    ${PERL} ./Configure \
29	    disable-aria \
30	    disable-egd \
31	    disable-idea \
32	    disable-mdc2 \
33	    disable-sm2 \
34	    disable-sm3 \
35	    disable-sm4 \
36	    enable-ec_nistp_64_gcc_128 \
37	    enable-ktls \
38	    enable-sctp \
39	    --openssldir=etc \
40	    --prefix=/usr
41	@cd ${.CURDIR} && gmake configdata.pm
42	@cd ${LCRYPTO_SRC} && ${PERL} \
43	    ${LCRYPTO_SRC}/freebsd/dump_version_from_configdata.pl > \
44	    ${SRCTOP}/secure/lib/libcrypto/Makefile.version
45
46all: patch
47	# Passing `-j ${.MAKE.JOBS}` doesn't work here for some reason.
48	@cd ${.CURDIR} && gmake build_all_generated
49
50	# Clean the pkgconfig files:
51	# 1. Fix --prefix (not sure why configure --prefix isn't honored properly).
52	# 2. Remove duplicate path in CFLAGS.
53	# 3. Remove duplicate path in includedir(s).
54	@find . -name \*.pc -print -exec sed -i '' -E \
55	    -e 's,^prefix=.+,prefix=/usr,' \
56	    -e 's,[[:space:]]+(\-I)?\$\{prefix\}/\./include[[:space:]]*,,g' \
57	    {} +
58
59	@cd ${SRCTOP}/secure/lib/libcrypto && \
60	    ${MAKE} cleanasm && \
61	    ${MAKE} buildasm
62
63	@rsync -a --delete \
64	    --exclude 'Makefile*' --exclude '*.1' \
65	    ${LCRYPTO_DOC}/man/ \
66	    ${SRCTOP}/secure/lib/libcrypto/man
67
68	@rsync -a --delete \
69	    --exclude 'Makefile*' --exclude '*.[357]' \
70	    ${LCRYPTO_DOC}/man/man1/ \
71	    ${SRCTOP}/secure/usr.bin/openssl/man
72
73
74# This doesn't use standard patching since the generated files can vary
75# depending on the host architecture.
76patch: configure
77	# Spam arch-specific overrides to config files.
78
79	@cd ${.CURDIR} && gmake ${BN_CONF_H} && \
80	${MV} ${BN_CONF_H} ${BN_CONF_H_ORIG} && \
81	${CAT} ${BN_CONF_H}.orig \
82	    ${LCRYPTO_SRC}/freebsd/${BN_CONF_H} >> \
83	    ${BN_CONF_H}
84
85	@cd ${.CURDIR} && \
86	 ${MV} ${CONFIGURATION_H} ${CONFIGURATION_H_ORIG} && \
87	 ${CAT} ${CONFIGURATION_H_ORIG} \
88	    ${LCRYPTO_SRC}/freebsd/${CONFIGURATION_H} >> \
89	    ${CONFIGURATION_H}
90
91
92clean: .PHONY
93	@cd ${.CURDIR} && rm -f ${BN_CONF_H_ORIG} ${CONFIGURATION_H_ORIG}
94
95	@cd ${SRCTOP}/secure/lib/libcrypto && ${MAKE} cleanasm
96
97	-@cd ${.CURDIR} && gmake ${.TARGET}
98
99.include <sys.mk>
100