Skip to content

Commit 267f8c1

Browse files
committed
crypto/openssl: make vendor imports easier/less error prone
This change adds a custom BSD makefile containing multiple high-level PHONY targets, similar to targets provided by the ports framework. The Makefile does the following: - Reruns Configure with a deterministic set of arguments to ensure that all appropriate features have been enabled/disabled in OpenSSL. - Preens the pkgconfig files to remove duplicate paths in their `CFLAGS` and `includedir` variables. - Rebuilds all ASM files to ensure that the content contained is fresh. - Rebuilds all manpages to ensure that the content contained in the manpages is fresh. Some additional work needs to be done to make the manpage regeneration "operation" reproducible (the date the manpages were generated is embedded in the files). All dynamic configuration previously captured in `include/openssl/configuration.h` and `include/crypto/bn_conf.h` has been moved to `freebsd/include/dynamic_freebsd_configuration.h` and `freebsd/include/crypto/bn_conf.h`, respectively. This helps ensure that future updates don't wipe out FreeBSD customizations to these files, which tune behavior on a per-target architecture basis, e.g., ARM vs x86, 32-bit vs 64-bit, etc. MFC after: 1 month Differential Revision: https://reviews.freebsd.org/D51663
1 parent 439685e commit 267f8c1

File tree

23 files changed

+718
-1952
lines changed

23 files changed

+718
-1952
lines changed

crypto/openssl/BSDmakefile

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
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+
9+
NO_OBJ=
10+
11+
LCRYPTO_SRC= ${SRCTOP}/crypto/openssl
12+
LCRYPTO_DOC= ${LCRYPTO_SRC}/doc
13+
14+
CAT?= /bin/cat
15+
MV?= /bin/mv
16+
PERL?= perl
17+
18+
BN_CONF_H= include/crypto/bn_conf.h
19+
BN_CONF_H_ORIG= ${BN_CONF_H}.orig
20+
CONFIGURATION_H= include/openssl/configuration.h
21+
CONFIGURATION_H_ORIG= ${CONFIGURATION_H}.orig
22+
23+
.PHONY: configure patch all
24+
.ORDER: configure patch all
25+
26+
configure:
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+
46+
all: 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.
76+
patch: 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+
92+
clean: .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>

crypto/openssl/apps/CA.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#!/usr/local/bin/perl
1+
#!/usr/bin/env perl
22
# Copyright 2000-2025 The OpenSSL Project Authors. All Rights Reserved.
33
#
44
# Licensed under the Apache License 2.0 (the "License"). You may not use

crypto/openssl/apps/progs.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* WARNING: do not edit!
33
* Generated by apps/progs.pl
44
*
5-
* Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
5+
* Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved.
66
*
77
* Licensed under the Apache License 2.0 (the "License"). You may not use
88
* this file except in compliance with the License. You can obtain a copy
@@ -89,6 +89,7 @@ FUNCTION functions[] = {
8989
{FT_general, "s_time", s_time_main, s_time_options, NULL, NULL},
9090
#endif
9191
{FT_general, "sess_id", sess_id_main, sess_id_options, NULL, NULL},
92+
{FT_general, "skeyutl", skeyutl_main, skeyutl_options, NULL, NULL},
9293
{FT_general, "smime", smime_main, smime_options, NULL, NULL},
9394
{FT_general, "speed", speed_main, speed_options, NULL, NULL},
9495
{FT_general, "spkac", spkac_main, spkac_options, NULL, NULL},
@@ -225,9 +226,15 @@ FUNCTION functions[] = {
225226
{FT_cipher, "camellia-256-ecb", enc_main, enc_options, NULL},
226227
#endif
227228
{FT_cipher, "base64", enc_main, enc_options, NULL},
228-
#ifdef ZLIB
229+
#ifndef OPENSSL_NO_ZLIB
229230
{FT_cipher, "zlib", enc_main, enc_options, NULL},
230231
#endif
232+
#ifndef OPENSSL_NO_BROTLI
233+
{FT_cipher, "brotli", enc_main, enc_options, NULL},
234+
#endif
235+
#ifndef OPENSSL_NO_ZSTD
236+
{FT_cipher, "zstd", enc_main, enc_options, NULL},
237+
#endif
231238
#ifndef OPENSSL_NO_DES
232239
{FT_cipher, "des", enc_main, enc_options, NULL},
233240
#endif

crypto/openssl/apps/progs.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* WARNING: do not edit!
33
* Generated by apps/progs.pl
44
*
5-
* Copyright 1995-2023 The OpenSSL Project Authors. All Rights Reserved.
5+
* Copyright 1995-2025 The OpenSSL Project Authors. All Rights Reserved.
66
*
77
* Licensed under the Apache License 2.0 (the "License"). You may not use
88
* this file except in compliance with the License. You can obtain a copy
@@ -56,6 +56,7 @@ extern int s_client_main(int argc, char *argv[]);
5656
extern int s_server_main(int argc, char *argv[]);
5757
extern int s_time_main(int argc, char *argv[]);
5858
extern int sess_id_main(int argc, char *argv[]);
59+
extern int skeyutl_main(int argc, char *argv[]);
5960
extern int smime_main(int argc, char *argv[]);
6061
extern int speed_main(int argc, char *argv[]);
6162
extern int spkac_main(int argc, char *argv[]);
@@ -110,6 +111,7 @@ extern const OPTIONS s_client_options[];
110111
extern const OPTIONS s_server_options[];
111112
extern const OPTIONS s_time_options[];
112113
extern const OPTIONS sess_id_options[];
114+
extern const OPTIONS skeyutl_options[];
113115
extern const OPTIONS smime_options[];
114116
extern const OPTIONS speed_options[];
115117
extern const OPTIONS spkac_options[];

0 commit comments

Comments
 (0)