| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | # $NetBSD: builtin.mk,v 1.50 2023/01/12 11:01:41 markd Exp $ | | 1 | # $NetBSD: builtin.mk,v 1.51 2023/02/07 16:34:42 jperkin Exp $ |
2 | | | 2 | |
3 | BUILTIN_PKG:= openssl | | 3 | BUILTIN_PKG:= openssl |
4 | | | 4 | |
5 | BUILTIN_FIND_LIBS:= crypto ssl | | 5 | BUILTIN_FIND_LIBS:= crypto ssl |
6 | BUILTIN_FIND_HEADERS_VAR:= H_OPENSSLCONF H_OPENSSLV | | 6 | BUILTIN_FIND_HEADERS_VAR:= H_OPENSSLCONF H_OPENSSLV |
7 | BUILTIN_FIND_HEADERS.H_OPENSSLCONF= openssl/opensslconf.h | | 7 | BUILTIN_FIND_HEADERS.H_OPENSSLCONF= openssl/opensslconf.h |
8 | BUILTIN_FIND_HEADERS.H_OPENSSLV= openssl/opensslv.h | | 8 | BUILTIN_FIND_HEADERS.H_OPENSSLV= openssl/opensslv.h |
9 | | | 9 | |
10 | .include "../../mk/buildlink3/bsd.builtin.mk" | | 10 | .include "../../mk/buildlink3/bsd.builtin.mk" |
11 | | | 11 | |
12 | ### | | 12 | ### |
13 | ### Determine if there is a built-in implementation of the package and | | 13 | ### Determine if there is a built-in implementation of the package and |
14 | ### set IS_BUILTIN.<pkg> appropriately ("yes" or "no"). | | 14 | ### set IS_BUILTIN.<pkg> appropriately ("yes" or "no"). |
| @@ -16,27 +16,27 @@ BUILTIN_FIND_HEADERS.H_OPENSSLV= openssl | | | @@ -16,27 +16,27 @@ BUILTIN_FIND_HEADERS.H_OPENSSLV= openssl |
16 | .if !defined(IS_BUILTIN.openssl) | | 16 | .if !defined(IS_BUILTIN.openssl) |
17 | IS_BUILTIN.openssl= no | | 17 | IS_BUILTIN.openssl= no |
18 | . if empty(H_OPENSSLV:M__nonexistent__) && empty(H_OPENSSLV:M${LOCALBASE}/*) | | 18 | . if empty(H_OPENSSLV:M__nonexistent__) && empty(H_OPENSSLV:M${LOCALBASE}/*) |
19 | IS_BUILTIN.openssl= yes | | 19 | IS_BUILTIN.openssl= yes |
20 | . endif | | 20 | . endif |
21 | .endif | | 21 | .endif |
22 | MAKEVARS+= IS_BUILTIN.openssl | | 22 | MAKEVARS+= IS_BUILTIN.openssl |
23 | | | 23 | |
24 | ### | | 24 | ### |
25 | ### If there is a built-in implementation, then set BUILTIN_PKG.<pkg> to | | 25 | ### If there is a built-in implementation, then set BUILTIN_PKG.<pkg> to |
26 | ### a package name to represent the built-in package. | | 26 | ### a package name to represent the built-in package. |
27 | ### | | 27 | ### |
28 | .if !defined(BUILTIN_PKG.openssl) && \ | | 28 | .if !defined(BUILTIN_PKG.openssl) && \ |
29 | ${IS_BUILTIN.openssl:M[yY][eE][sS]} && \ | | 29 | ${IS_BUILTIN.openssl:tl} == yes && \ |
30 | empty(H_OPENSSLV:M__nonexistent__) | | 30 | empty(H_OPENSSLV:M__nonexistent__) |
31 | BUILTIN_VERSION.openssl!= \ | | 31 | BUILTIN_VERSION.openssl!= \ |
32 | ${AWK} 'BEGIN { hex="0123456789abcdef"; \ | | 32 | ${AWK} 'BEGIN { hex="0123456789abcdef"; \ |
33 | alpha="abcdefghijklmnopqrstuvwxyz"; \ | | 33 | alpha="abcdefghijklmnopqrstuvwxyz"; \ |
34 | } \ | | 34 | } \ |
35 | /\#[ ]+define/ { sub("\#[ \\t]+define", "\#define", $$0); } \ | | 35 | /\#[ ]+define/ { sub("\#[ \\t]+define", "\#define", $$0); } \ |
36 | /\#define[ ]*OPENSSL_VERSION_STR/ { \ | | 36 | /\#define[ ]*OPENSSL_VERSION_STR/ { \ |
37 | printf "%s\n",substr($$3,2,length($$3)-2); \ | | 37 | printf "%s\n",substr($$3,2,length($$3)-2); \ |
38 | exit 0; \ | | 38 | exit 0; \ |
39 | } \ | | 39 | } \ |
40 | /\#define[ ]*OPENSSL_VERSION_NUMBER/ { \ | | 40 | /\#define[ ]*OPENSSL_VERSION_NUMBER/ { \ |
41 | major = index(hex, substr($$3, 3, 1)) - 1; \ | | 41 | major = index(hex, substr($$3, 3, 1)) - 1; \ |
42 | i = 16 * (index(hex, substr($$3, 4, 1)) - 1); \ | | 42 | i = 16 * (index(hex, substr($$3, 4, 1)) - 1); \ |
| @@ -55,101 +55,101 @@ BUILTIN_VERSION.openssl!= \ | | | @@ -55,101 +55,101 @@ BUILTIN_VERSION.openssl!= \ |
55 | patchlevel = substr(alpha,i,1); \ | | 55 | patchlevel = substr(alpha,i,1); \ |
56 | } \ | | 56 | } \ |
57 | printf "%s%s%s%s\n", \ | | 57 | printf "%s%s%s%s\n", \ |
58 | major, minor, teeny, patchlevel; \ | | 58 | major, minor, teeny, patchlevel; \ |
59 | exit 0; \ | | 59 | exit 0; \ |
60 | } \ | | 60 | } \ |
61 | ' ${H_OPENSSLV} | | 61 | ' ${H_OPENSSLV} |
62 | BUILTIN_PKG.openssl= openssl-${BUILTIN_VERSION.openssl} | | 62 | BUILTIN_PKG.openssl= openssl-${BUILTIN_VERSION.openssl} |
63 | .endif | | 63 | .endif |
64 | MAKEVARS+= BUILTIN_PKG.openssl | | 64 | MAKEVARS+= BUILTIN_PKG.openssl |
65 | MAKEVARS+= BUILTIN_VERSION.openssl | | 65 | MAKEVARS+= BUILTIN_VERSION.openssl |
66 | | | 66 | |
67 | .if !defined(BUILTIN_OPENSSL_HAS_THREADS) && \ | | 67 | .if !defined(BUILTIN_OPENSSL_HAS_THREADS) && \ |
68 | ${IS_BUILTIN.openssl:M[yY][eE][sS]} && \ | | 68 | ${IS_BUILTIN.openssl:tl} == yes && \ |
69 | empty(H_OPENSSLCONF:M__nonexistent__) | | 69 | empty(H_OPENSSLCONF:M__nonexistent__) |
70 | BUILTIN_OPENSSL_HAS_THREADS!= \ | | 70 | BUILTIN_OPENSSL_HAS_THREADS!= \ |
71 | ${AWK} 'BEGIN { ans = "no" } \ | | 71 | ${AWK} 'BEGIN { ans = "no" } \ |
72 | /\#[ ]*define[ ]*OPENSSL_THREADS/ { ans= "yes" } \ | | 72 | /\#[ ]*define[ ]*OPENSSL_THREADS/ { ans= "yes" } \ |
73 | /\#[ ]*define[ ]*THREADS/ { ans = "yes" } \ | | 73 | /\#[ ]*define[ ]*THREADS/ { ans = "yes" } \ |
74 | END { print ans; exit 0 } \ | | 74 | END { print ans; exit 0 } \ |
75 | ' ${H_OPENSSLCONF:Q} | | 75 | ' ${H_OPENSSLCONF:Q} |
76 | .endif | | 76 | .endif |
77 | MAKEVARS+= BUILTIN_OPENSSL_HAS_THREADS | | 77 | MAKEVARS+= BUILTIN_OPENSSL_HAS_THREADS |
78 | | | 78 | |
79 | ### | | 79 | ### |
80 | ### Determine whether we should use the built-in implementation if it | | 80 | ### Determine whether we should use the built-in implementation if it |
81 | ### exists, and set USE_BUILTIN.<pkg> appropriate ("yes" or "no"). | | 81 | ### exists, and set USE_BUILTIN.<pkg> appropriate ("yes" or "no"). |
82 | ### | | 82 | ### |
83 | .if !defined(USE_BUILTIN.openssl) | | 83 | .if !defined(USE_BUILTIN.openssl) |
84 | . if ${PREFER.openssl} == "pkgsrc" | | 84 | . if ${PREFER.openssl} == "pkgsrc" |
85 | USE_BUILTIN.openssl= no | | 85 | USE_BUILTIN.openssl= no |
86 | . else | | 86 | . else |
87 | USE_BUILTIN.openssl= ${IS_BUILTIN.openssl} | | 87 | USE_BUILTIN.openssl= ${IS_BUILTIN.openssl} |
88 | . if defined(BUILTIN_PKG.openssl) && \ | | 88 | . if defined(BUILTIN_PKG.openssl) && \ |
89 | ${IS_BUILTIN.openssl:M[yY][eE][sS]} | | 89 | ${IS_BUILTIN.openssl:tl} == yes |
90 | USE_BUILTIN.openssl= yes | | 90 | USE_BUILTIN.openssl= yes |
91 | ### take care builtin check case, BUILDLINK_API_DEPENDS may not be defined yet. | | 91 | ### take care builtin check case, BUILDLINK_API_DEPENDS may not be defined yet. |
92 | CHECK_BUILTIN.openssl?= no | | 92 | CHECK_BUILTIN.openssl?= no |
93 | . if ${CHECK_BUILTIN.openssl:M[yY][eE][sS]} | | 93 | . if ${CHECK_BUILTIN.openssl:tl} == yes |
94 | BUILDLINK_API_DEPENDS.openssl?= openssl>=1.1.1 | | 94 | BUILDLINK_API_DEPENDS.openssl?= openssl>=1.1.1 |
95 | . endif | | 95 | . endif |
96 | . for dep_ in ${BUILDLINK_API_DEPENDS.openssl} | | 96 | . for dep_ in ${BUILDLINK_API_DEPENDS.openssl} |
97 | . if ${USE_BUILTIN.openssl:M[yY][eE][sS]} | | 97 | . if ${USE_BUILTIN.openssl:tl} == yes |
98 | USE_BUILTIN.openssl!= \ | | 98 | USE_BUILTIN.openssl!= \ |
99 | if ${PKG_ADMIN} pmatch ${dep_:Q} ${BUILTIN_PKG.openssl:Q}; then \ | | 99 | if ${PKG_ADMIN} pmatch ${dep_:Q} ${BUILTIN_PKG.openssl:Q}; then \ |
100 | ${ECHO} yes; \ | | 100 | ${ECHO} yes; \ |
101 | else \ | | 101 | else \ |
102 | ${ECHO} no; \ | | 102 | ${ECHO} no; \ |
103 | fi | | 103 | fi |
104 | . endif | | 104 | . endif |
105 | . endfor | | 105 | . endfor |
106 | . endif | | 106 | . endif |
107 | . if ${IS_BUILTIN.openssl:M[yY][eE][sS]} && \ | | 107 | . if ${IS_BUILTIN.openssl:tl} == yes && \ |
108 | defined(USE_FEATURES.openssl) | | 108 | defined(USE_FEATURES.openssl) |
109 | . if !empty(USE_FEATURES.openssl:Mthreads) && \ | | 109 | . if !empty(USE_FEATURES.openssl:Mthreads) && \ |
110 | !empty(BUILTIN_OPENSSL_HAS_THREADS:M[nN][oO]) | | 110 | !empty(BUILTIN_OPENSSL_HAS_THREADS:M[nN][oO]) |
111 | USE_BUILTIN.openssl= no | | 111 | USE_BUILTIN.openssl= no |
112 | . endif | | 112 | . endif |
113 | . endif | | 113 | . endif |
114 | . endif # PREFER.openssl | | 114 | . endif # PREFER.openssl |
115 | .endif | | 115 | .endif |
116 | MAKEVARS+= USE_BUILTIN.openssl | | 116 | MAKEVARS+= USE_BUILTIN.openssl |
117 | | | 117 | |
118 | ### | | 118 | ### |
119 | ### The section below only applies if we are not including this file | | 119 | ### The section below only applies if we are not including this file |
120 | ### solely to determine whether a built-in implementation exists. | | 120 | ### solely to determine whether a built-in implementation exists. |
121 | ### | | 121 | ### |
122 | CHECK_BUILTIN.openssl?= no | | 122 | CHECK_BUILTIN.openssl?= no |
123 | .if ${CHECK_BUILTIN.openssl:M[nN][oO]} | | 123 | .if ${CHECK_BUILTIN.openssl:tl} == no |
124 | | | 124 | |
125 | . if ${USE_BUILTIN.openssl:M[yY][eE][sS]} | | 125 | . if ${USE_BUILTIN.openssl:tl} == yes |
126 | . if empty(H_OPENSSLV:M__nonexistent__) | | 126 | . if empty(H_OPENSSLV:M__nonexistent__) |
127 | . if !empty(H_OPENSSLV:M/usr/sfw/*) | | 127 | . if !empty(H_OPENSSLV:M/usr/sfw/*) |
128 | BUILDLINK_PREFIX.openssl= /usr/sfw | | 128 | BUILDLINK_PREFIX.openssl= /usr/sfw |
129 | BUILDLINK_PASSTHRU_DIRS+= /usr/sfw | | 129 | BUILDLINK_PASSTHRU_DIRS+= /usr/sfw |
130 | . elif !empty(H_OPENSSLV:M/usr/*) | | 130 | . elif !empty(H_OPENSSLV:M/usr/*) |
131 | BUILDLINK_PREFIX.openssl= /usr | | 131 | BUILDLINK_PREFIX.openssl= /usr |
132 | . elif !empty(H_OPENSSLV:M/boot/system/develop/*) | | 132 | . elif !empty(H_OPENSSLV:M/boot/system/develop/*) |
133 | BUILDLINK_PREFIX.openssl= /boot/system/develop | | 133 | BUILDLINK_PREFIX.openssl= /boot/system/develop |
134 | . elif !empty(H_OPENSSLV:M/boot/common/*) | | 134 | . elif !empty(H_OPENSSLV:M/boot/common/*) |
135 | BUILDLINK_PREFIX.openssl= /boot/common | | 135 | BUILDLINK_PREFIX.openssl= /boot/common |
136 | . endif | | 136 | . endif |
137 | . endif | | 137 | . endif |
138 | . endif | | 138 | . endif |
139 | | | 139 | |
140 | . if defined(PKG_SYSCONFDIR.openssl) | | 140 | . if defined(PKG_SYSCONFDIR.openssl) |
141 | SSLDIR= ${PKG_SYSCONFDIR.openssl} | | 141 | SSLDIR= ${PKG_SYSCONFDIR.openssl} |
142 | . elif ${USE_BUILTIN.openssl:M[yY][eE][sS]} | | 142 | . elif ${USE_BUILTIN.openssl:tl} == yes |
143 | . if ${OPSYS} == "NetBSD" | | 143 | . if ${OPSYS} == "NetBSD" |
144 | SSLDIR= /etc/openssl | | 144 | SSLDIR= /etc/openssl |
145 | . elif ${OPSYS} == "Linux" | | 145 | . elif ${OPSYS} == "Linux" |
146 | . if exists(/etc/pki/tls) | | 146 | . if exists(/etc/pki/tls) |
147 | # Some distributions have moved to /etc/pki/tls, with incomplete | | 147 | # Some distributions have moved to /etc/pki/tls, with incomplete |
148 | # symlinks from /etc/ssl. Prefer the new location if it exists | | 148 | # symlinks from /etc/ssl. Prefer the new location if it exists |
149 | SSLDIR= /etc/pki/tls | | 149 | SSLDIR= /etc/pki/tls |
150 | . else | | 150 | . else |
151 | SSLDIR= /etc/ssl # standard location | | 151 | SSLDIR= /etc/ssl # standard location |
152 | . endif | | 152 | . endif |
153 | . elif ${OPSYS} == "Haiku" | | 153 | . elif ${OPSYS} == "Haiku" |
154 | . if exists(/boot/system/data/ssl) | | 154 | . if exists(/boot/system/data/ssl) |
155 | SSLDIR= /boot/system/data/ssl | | 155 | SSLDIR= /boot/system/data/ssl |
| @@ -168,27 +168,27 @@ SSLCERTS= ${SSLDIR}/certs | | | @@ -168,27 +168,27 @@ SSLCERTS= ${SSLDIR}/certs |
168 | # Continue to define SSLCERTS because it's unclear if that's the | | 168 | # Continue to define SSLCERTS because it's unclear if that's the |
169 | # directory that has one file per cert, or the directory that contains | | 169 | # directory that has one file per cert, or the directory that contains |
170 | # trust anchor config in some fortm. | | 170 | # trust anchor config in some fortm. |
171 | . if exists(${SSLDIR}/certs/ca-bundle.crt) | | 171 | . if exists(${SSLDIR}/certs/ca-bundle.crt) |
172 | SSLCERTBUNDLE= ${SSLDIR}/certs/ca-bundle.crt | | 172 | SSLCERTBUNDLE= ${SSLDIR}/certs/ca-bundle.crt |
173 | . endif | | 173 | . endif |
174 | SSLKEYS= ${SSLDIR}/private | | 174 | SSLKEYS= ${SSLDIR}/private |
175 | | | 175 | |
176 | BUILD_DEFS+= SSLDIR SSLCERTS SSLCERTBUNDLE SSLKEYS | | 176 | BUILD_DEFS+= SSLDIR SSLCERTS SSLCERTBUNDLE SSLKEYS |
177 | | | 177 | |
178 | # create pc files for builtin version; other versions assumed to contain them | | 178 | # create pc files for builtin version; other versions assumed to contain them |
179 | # If we are using the builtin version, check whether it has a *.pc | | 179 | # If we are using the builtin version, check whether it has a *.pc |
180 | # files or not. If the latter, generate fake ones. | | 180 | # files or not. If the latter, generate fake ones. |
181 | . if ${USE_BUILTIN.openssl:M[Yy][Ee][Ss]} | | 181 | . if ${USE_BUILTIN.openssl:tl} == yes |
182 | BUILDLINK_TARGETS+= openssl-fake-pc | | 182 | BUILDLINK_TARGETS+= openssl-fake-pc |
183 | | | 183 | |
184 | . if !defined(HAS_OPENSSL_FAKE_PC) | | 184 | . if !defined(HAS_OPENSSL_FAKE_PC) |
185 | HAS_OPENSSL_FAKE_PC= | | 185 | HAS_OPENSSL_FAKE_PC= |
186 | | | 186 | |
187 | .PHONY: openssl-fake-pc | | 187 | .PHONY: openssl-fake-pc |
188 | openssl-fake-pc: | | 188 | openssl-fake-pc: |
189 | ${RUN} \ | | 189 | ${RUN} \ |
190 | src=${BUILDLINK_PREFIX.openssl}/lib${LIBABISUFFIX}/pkgconfig/libcrypto.pc; \ | | 190 | src=${BUILDLINK_PREFIX.openssl}/lib${LIBABISUFFIX}/pkgconfig/libcrypto.pc; \ |
191 | dst=${BUILDLINK_DIR}/lib/pkgconfig/libcrypto.pc; \ | | 191 | dst=${BUILDLINK_DIR}/lib/pkgconfig/libcrypto.pc; \ |
192 | ${MKDIR} ${BUILDLINK_DIR}/lib/pkgconfig; \ | | 192 | ${MKDIR} ${BUILDLINK_DIR}/lib/pkgconfig; \ |
193 | if ${TEST} -f $${src}; then \ | | 193 | if ${TEST} -f $${src}; then \ |
194 | ${LN} -sf $${src} $${dst}; \ | | 194 | ${LN} -sf $${src} $${dst}; \ |