]>
Commit | Line | Data |
---|---|---|
d02b48c6 RE |
1 | #!/usr/local/bin/perl |
2 | # A bit of an evil hack but it post processes the file ../MINFO which | |
3 | # is generated by `make files` in the top directory. | |
4 | # This script outputs one mega makefile that has no shell stuff or any | |
5 | # funny stuff | |
6 | # | |
7 | ||
559b52ac | 8 | $INSTALLTOP="/usr/local/ssl"; |
b8bb15fb | 9 | $OPENSSLDIR="/usr/local/ssl"; |
31ff97b2 UM |
10 | $OPTIONS=""; |
11 | $ssl_version=""; | |
eff5f612 | 12 | $banner="\t\@echo Building OpenSSL"; |
d02b48c6 | 13 | |
f858d222 | 14 | my $no_static_engine = 1; |
fbf002bb | 15 | my $engines = ""; |
223c59ea | 16 | my $otherlibs = ""; |
ad2695b1 DSH |
17 | local $zlib_opt = 0; # 0 = no zlib, 1 = static, 2 = dynamic |
18 | local $zlib_lib = ""; | |
73980531 DSH |
19 | local $perl_asm = 0; # 1 to autobuild asm files from perl scripts |
20 | ||
06b433ac DSH |
21 | local $fips_canister_path = ""; |
22 | my $fips_premain_dso_exe_path = ""; | |
23 | my $fips_premain_c_path = ""; | |
24 | my $fips_sha1_exe_path = ""; | |
25 | ||
26 | local $fipscanisterbuild = 0; | |
27 | ||
d989e4f8 DSH |
28 | my $fipscanisteronly = 0; |
29 | ||
06b433ac DSH |
30 | my $fipslibdir = ""; |
31 | my $baseaddr = ""; | |
32 | ||
33 | my $ex_l_libs = ""; | |
34 | ||
d989e4f8 DSH |
35 | my $build_targets = "lib exe"; |
36 | my $libs_dep = "\$(O_CRYPTO) \$(O_SSL)"; | |
37 | ||
73980531 DSH |
38 | # Options to import from top level Makefile |
39 | ||
40 | my %mf_import = ( | |
41 | VERSION => \$ssl_version, | |
42 | OPTIONS => \$OPTIONS, | |
43 | INSTALLTOP => \$INSTALLTOP, | |
44 | OPENSSLDIR => \$OPENSSLDIR, | |
45 | PLATFORM => \$mf_platform, | |
46 | CFLAG => \$mf_cflag, | |
47 | DEPFLAG => \$mf_depflag, | |
48 | CPUID_OBJ => \$mf_cpuid_asm, | |
49 | BN_ASM => \$mf_bn_asm, | |
50 | DES_ENC => \$mf_des_asm, | |
51 | AES_ENC => \$mf_aes_asm, | |
52 | BF_ENC => \$mf_bf_asm, | |
53 | CAST_ENC => \$mf_cast_asm, | |
54 | RC4_ENC => \$mf_rc4_asm, | |
55 | RC5_ENC => \$mf_rc5_asm, | |
56 | MD5_ASM_OBJ => \$mf_md5_asm, | |
57 | SHA1_ASM_OBJ => \$mf_sha_asm, | |
58 | RMD160_ASM_OBJ => \$mf_rmd_asm, | |
59 | WP_ASM_OBJ => \$mf_wp_asm, | |
dc527a62 DSH |
60 | CMLL_ENC => \$mf_cm_asm, |
61 | MODES_ASM_OBJ => \$mf_modes_asm | |
73980531 | 62 | ); |
fbf002bb | 63 | |
f68854b4 | 64 | open(IN,"<Makefile") || die "unable to open Makefile!\n"; |
31ff97b2 | 65 | while(<IN>) { |
73980531 DSH |
66 | my ($mf_opt, $mf_ref); |
67 | while (($mf_opt, $mf_ref) = each %mf_import) { | |
68 | if (/^$mf_opt\s*=\s*(.*)$/) { | |
69 | $$mf_ref = $1; | |
70 | } | |
71 | } | |
31ff97b2 | 72 | } |
ce457a54 | 73 | close(IN); |
31ff97b2 | 74 | |
71b7858b DSH |
75 | $debug = 1 if $mf_platform =~ /^debug-/; |
76 | ||
a7a90b2f | 77 | die "Makefile is not the toplevel Makefile!\n" if $ssl_version eq ""; |
58964a49 | 78 | |
d02b48c6 RE |
79 | $infile="MINFO"; |
80 | ||
81 | %ops=( | |
06c68491 | 82 | "VC-WIN32", "Microsoft Visual C++ [4-6] - Windows NT or 9X", |
1875e6db AP |
83 | "VC-WIN64I", "Microsoft C/C++ - Win64/IA-64", |
84 | "VC-WIN64A", "Microsoft C/C++ - Win64/x64", | |
0bf23d9b | 85 | "VC-CE", "Microsoft eMbedded Visual C++ 3.0 - Windows CE ONLY", |
06c68491 | 86 | "VC-NT", "Microsoft Visual C++ [4-6] - Windows NT ONLY", |
31a674d8 | 87 | "Mingw32", "GNU C++ - Windows NT or 9x", |
12d7d32f | 88 | "Mingw32-files", "Create files with DOS copy ...", |
31a674d8 | 89 | "BC-NT", "Borland C++ 4.5 - Windows NT", |
58964a49 | 90 | "linux-elf","Linux elf", |
dfeab068 | 91 | "ultrix-mips","DEC mips ultrix", |
d02b48c6 | 92 | "FreeBSD","FreeBSD distribution", |
dc01b6b1 | 93 | "OS2-EMX", "EMX GCC OS/2", |
b764ab95 | 94 | "netware-clib", "CodeWarrior for NetWare - CLib - with WinSock Sockets", |
eef0c1f3 | 95 | "netware-clib-bsdsock", "CodeWarrior for NetWare - CLib - with BSD Sockets", |
b764ab95 RL |
96 | "netware-libc", "CodeWarrior for NetWare - LibC - with WinSock Sockets", |
97 | "netware-libc-bsdsock", "CodeWarrior for NetWare - LibC - with BSD Sockets", | |
d02b48c6 | 98 | "default","cc under unix", |
73980531 | 99 | "auto", "auto detect from top level Makefile" |
d02b48c6 RE |
100 | ); |
101 | ||
dfeab068 | 102 | $platform=""; |
6bc8e6b8 | 103 | my $xcflags=""; |
d02b48c6 RE |
104 | foreach (@ARGV) |
105 | { | |
31ff97b2 | 106 | if (!&read_options && !defined($ops{$_})) |
d02b48c6 | 107 | { |
31ff97b2 | 108 | print STDERR "unknown option - $_\n"; |
748365ee | 109 | print STDERR "usage: perl mk1mf.pl [options] [system]\n"; |
31ff97b2 UM |
110 | print STDERR "\nwhere [system] can be one of the following\n"; |
111 | foreach $i (sort keys %ops) | |
112 | { printf STDERR "\t%-10s\t%s\n",$i,$ops{$i}; } | |
113 | print STDERR <<"EOF"; | |
d02b48c6 | 114 | and [options] can be one of |
3009458e RL |
115 | no-md2 no-md4 no-md5 no-sha no-mdc2 - Skip this digest |
116 | no-ripemd | |
77dd9c18 | 117 | no-rc2 no-rc4 no-rc5 no-idea no-des - Skip this symetric cipher |
96afc1cf | 118 | no-bf no-cast no-aes no-camellia no-seed |
d02b48c6 RE |
119 | no-rsa no-dsa no-dh - Skip this public key cipher |
120 | no-ssl2 no-ssl3 - Skip this version of SSL | |
121 | just-ssl - remove all non-ssl keys/digest | |
122 | no-asm - No x86 asm | |
97f56446 | 123 | no-krb5 - No KRB5 |
edc032b5 | 124 | no-srp - No SRP |
01682a8b RL |
125 | no-ec - No EC |
126 | no-ecdsa - No ECDSA | |
0b13e9f0 RL |
127 | no-ecdh - No ECDH |
128 | no-engine - No engine | |
5cd48abf | 129 | no-hw - No hw |
bbdb5438 | 130 | nasm - Use NASM for x86 asm |
4d8743f4 | 131 | nw-nasm - Use NASM x86 asm for NetWare |
eef0c1f3 | 132 | nw-mwasm - Use Metrowerks x86 asm for NetWare |
2da0c119 | 133 | gaswin - Use GNU as with Mingw32 |
d02b48c6 RE |
134 | no-socks - No socket code |
135 | no-err - No error strings | |
136 | dll/shlib - Build shared libraries (MS) | |
137 | debug - Debug build | |
d55a3cf1 | 138 | profile - Profiling build |
d02b48c6 | 139 | gcc - Use Gcc (unix) |
d02b48c6 RE |
140 | |
141 | Values that can be set | |
58964a49 | 142 | TMP=tmpdir OUT=outdir SRC=srcdir BIN=binpath INC=header-outdir CC=C-compiler |
d02b48c6 RE |
143 | |
144 | -L<ex_lib_path> -l<ex_lib> - extra library flags (unix) | |
145 | -<ex_cc_flags> - extra 'cc' flags, | |
146 | added (MS), or replace (unix) | |
147 | EOF | |
31ff97b2 | 148 | exit(1); |
d02b48c6 | 149 | } |
31ff97b2 UM |
150 | $platform=$_; |
151 | } | |
7f2113a2 | 152 | foreach (grep(!/^$/, split(/ /, $OPTIONS))) |
31ff97b2 UM |
153 | { |
154 | print STDERR "unknown option - $_\n" if !&read_options; | |
d02b48c6 RE |
155 | } |
156 | ||
fbf002bb DSH |
157 | $no_static_engine = 0 if (!$shlib); |
158 | ||
d02b48c6 RE |
159 | $no_mdc2=1 if ($no_des); |
160 | ||
8cf65228 | 161 | $no_ssl3=1 if ($no_md5 || $no_sha); |
d02b48c6 RE |
162 | $no_ssl3=1 if ($no_rsa && $no_dh); |
163 | ||
6f9079fd | 164 | $no_ssl2=1 if ($no_md5); |
d02b48c6 RE |
165 | $no_ssl2=1 if ($no_rsa); |
166 | ||
58964a49 RE |
167 | $out_def="out"; |
168 | $inc_def="outinc"; | |
169 | $tmp_def="tmp"; | |
170 | ||
2e9f1bf0 DSH |
171 | $perl="perl" unless defined $perl; |
172 | $mkdir="-mkdir" unless defined $mkdir; | |
d02b48c6 RE |
173 | |
174 | ($ssl,$crypto)=("ssl","crypto"); | |
d02b48c6 RE |
175 | $ranlib="echo ranlib"; |
176 | ||
58964a49 RE |
177 | $cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc'; |
178 | $src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}:'.'; | |
179 | $bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:''; | |
180 | ||
181 | # $bin_dir.=$o causes a core dump on my sparc :-( | |
182 | ||
6bc8e6b8 | 183 | |
06c68491 DSH |
184 | $NT=0; |
185 | ||
d02b48c6 | 186 | push(@INC,"util/pl","pl"); |
73980531 DSH |
187 | |
188 | if ($platform eq "auto") { | |
189 | $platform = $mf_platform; | |
190 | print STDERR "Imported platform $mf_platform\n"; | |
191 | } | |
192 | ||
1875e6db | 193 | if (($platform =~ /VC-(.+)/)) |
d02b48c6 | 194 | { |
1875e6db AP |
195 | $FLAVOR=$1; |
196 | $NT = 1 if $1 eq "NT"; | |
d02b48c6 RE |
197 | require 'VC-32.pl'; |
198 | } | |
31a674d8 UM |
199 | elsif ($platform eq "Mingw32") |
200 | { | |
201 | require 'Mingw32.pl'; | |
202 | } | |
12d7d32f UM |
203 | elsif ($platform eq "Mingw32-files") |
204 | { | |
205 | require 'Mingw32f.pl'; | |
206 | } | |
dfeab068 | 207 | elsif ($platform eq "BC-NT") |
d02b48c6 RE |
208 | { |
209 | $bc=1; | |
210 | require 'BC-32.pl'; | |
211 | } | |
dfeab068 | 212 | elsif ($platform eq "FreeBSD") |
d02b48c6 RE |
213 | { |
214 | require 'unix.pl'; | |
215 | $cflags='-DTERMIO -D_ANSI_SOURCE -O2 -fomit-frame-pointer'; | |
216 | } | |
dfeab068 | 217 | elsif ($platform eq "linux-elf") |
58964a49 RE |
218 | { |
219 | require "unix.pl"; | |
220 | require "linux.pl"; | |
221 | $unix=1; | |
222 | } | |
dfeab068 RE |
223 | elsif ($platform eq "ultrix-mips") |
224 | { | |
225 | require "unix.pl"; | |
226 | require "ultrix.pl"; | |
227 | $unix=1; | |
228 | } | |
dc01b6b1 RL |
229 | elsif ($platform eq "OS2-EMX") |
230 | { | |
231 | $wc=1; | |
232 | require 'OS2-EMX.pl'; | |
233 | } | |
b764ab95 | 234 | elsif (($platform eq "netware-clib") || ($platform eq "netware-libc") || |
eef0c1f3 | 235 | ($platform eq "netware-clib-bsdsock") || ($platform eq "netware-libc-bsdsock")) |
4d8743f4 | 236 | { |
b764ab95 | 237 | $LIBC=1 if $platform eq "netware-libc" || $platform eq "netware-libc-bsdsock"; |
eef0c1f3 | 238 | $BSDSOCK=1 if ($platform eq "netware-libc-bsdsock") || ($platform eq "netware-clib-bsdsock"); |
4d8743f4 RL |
239 | require 'netware.pl'; |
240 | } | |
d02b48c6 RE |
241 | else |
242 | { | |
243 | require "unix.pl"; | |
244 | ||
245 | $unix=1; | |
246 | $cflags.=' -DTERMIO'; | |
247 | } | |
248 | ||
58964a49 RE |
249 | $out_dir=(defined($VARS{'OUT'}))?$VARS{'OUT'}:$out_def.($debug?".dbg":""); |
250 | $tmp_dir=(defined($VARS{'TMP'}))?$VARS{'TMP'}:$tmp_def.($debug?".dbg":""); | |
251 | $inc_dir=(defined($VARS{'INC'}))?$VARS{'INC'}:$inc_def; | |
252 | ||
d02b48c6 RE |
253 | $bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq '')); |
254 | ||
6bc8e6b8 DSH |
255 | $cflags= "$xcflags$cflags" if $xcflags ne ""; |
256 | ||
cf1b7d96 | 257 | $cflags.=" -DOPENSSL_NO_IDEA" if $no_idea; |
77dd9c18 | 258 | $cflags.=" -DOPENSSL_NO_AES" if $no_aes; |
f3dea9a5 | 259 | $cflags.=" -DOPENSSL_NO_CAMELLIA" if $no_camellia; |
96afc1cf | 260 | $cflags.=" -DOPENSSL_NO_SEED" if $no_seed; |
cf1b7d96 RL |
261 | $cflags.=" -DOPENSSL_NO_RC2" if $no_rc2; |
262 | $cflags.=" -DOPENSSL_NO_RC4" if $no_rc4; | |
263 | $cflags.=" -DOPENSSL_NO_RC5" if $no_rc5; | |
264 | $cflags.=" -DOPENSSL_NO_MD2" if $no_md2; | |
265 | $cflags.=" -DOPENSSL_NO_MD4" if $no_md4; | |
266 | $cflags.=" -DOPENSSL_NO_MD5" if $no_md5; | |
267 | $cflags.=" -DOPENSSL_NO_SHA" if $no_sha; | |
268 | $cflags.=" -DOPENSSL_NO_SHA1" if $no_sha1; | |
7e38616d | 269 | $cflags.=" -DOPENSSL_NO_RIPEMD" if $no_ripemd; |
cf1b7d96 RL |
270 | $cflags.=" -DOPENSSL_NO_MDC2" if $no_mdc2; |
271 | $cflags.=" -DOPENSSL_NO_BF" if $no_bf; | |
272 | $cflags.=" -DOPENSSL_NO_CAST" if $no_cast; | |
273 | $cflags.=" -DOPENSSL_NO_DES" if $no_des; | |
274 | $cflags.=" -DOPENSSL_NO_RSA" if $no_rsa; | |
275 | $cflags.=" -DOPENSSL_NO_DSA" if $no_dsa; | |
276 | $cflags.=" -DOPENSSL_NO_DH" if $no_dh; | |
ec645d90 | 277 | $cflags.=" -DOPENSSL_NO_WHIRLPOOL" if $no_whirlpool; |
cf1b7d96 RL |
278 | $cflags.=" -DOPENSSL_NO_SOCK" if $no_sock; |
279 | $cflags.=" -DOPENSSL_NO_SSL2" if $no_ssl2; | |
280 | $cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3; | |
525de5d3 | 281 | $cflags.=" -DOPENSSL_NO_TLSEXT" if $no_tlsext; |
edc032b5 | 282 | $cflags.=" -DOPENSSL_NO_SRP" if $no_srp; |
88db4e6b | 283 | $cflags.=" -DOPENSSL_NO_CMS" if $no_cms; |
cf1b7d96 | 284 | $cflags.=" -DOPENSSL_NO_ERR" if $no_err; |
01682a8b RL |
285 | $cflags.=" -DOPENSSL_NO_KRB5" if $no_krb5; |
286 | $cflags.=" -DOPENSSL_NO_EC" if $no_ec; | |
287 | $cflags.=" -DOPENSSL_NO_ECDSA" if $no_ecdsa; | |
0b13e9f0 | 288 | $cflags.=" -DOPENSSL_NO_ECDH" if $no_ecdh; |
4ed7b78b | 289 | $cflags.=" -DOPENSSL_NO_GOST" if $no_gost; |
0b13e9f0 | 290 | $cflags.=" -DOPENSSL_NO_ENGINE" if $no_engine; |
5cd48abf | 291 | $cflags.=" -DOPENSSL_NO_HW" if $no_hw; |
06b433ac | 292 | $cflags.=" -DOPENSSL_FIPS" if $fips; |
79bd20fd | 293 | $cflags.=" -DOPENSSL_NO_JPAKE" if $no_jpake; |
36246be9 | 294 | $cflags.=" -DOPENSSL_NO_EC2M" if $no_ec2m; |
ad2695b1 DSH |
295 | $cflags.= " -DZLIB" if $zlib_opt; |
296 | $cflags.= " -DZLIB_SHARED" if $zlib_opt == 2; | |
297 | ||
fbf002bb DSH |
298 | if ($no_static_engine) |
299 | { | |
300 | $cflags .= " -DOPENSSL_NO_STATIC_ENGINE"; | |
301 | } | |
302 | else | |
303 | { | |
304 | $cflags .= " -DOPENSSL_NO_DYNAMIC_ENGINE"; | |
305 | } | |
306 | ||
ccb9643f | 307 | #$cflags.=" -DRSAref" if $rsaref ne ""; |
d02b48c6 | 308 | |
d55a3cf1 UM |
309 | ## if ($unix) |
310 | ## { $cflags="$c_flags" if ($c_flags ne ""); } | |
311 | ##else | |
312 | { $cflags="$c_flags$cflags" if ($c_flags ne ""); } | |
d02b48c6 RE |
313 | |
314 | $ex_libs="$l_flags$ex_libs" if ($l_flags ne ""); | |
315 | ||
ad2695b1 | 316 | |
f09628e4 RL |
317 | %shlib_ex_cflags=("SSL" => " -DOPENSSL_BUILD_SHLIBSSL", |
318 | "CRYPTO" => " -DOPENSSL_BUILD_SHLIBCRYPTO"); | |
319 | ||
d02b48c6 RE |
320 | if ($msdos) |
321 | { | |
dfeab068 | 322 | $banner ="\t\@echo Make sure you have run 'perl Configure $platform' in the\n"; |
d02b48c6 RE |
323 | $banner.="\t\@echo top level directory, if you don't have perl, you will\n"; |
324 | $banner.="\t\@echo need to probably edit crypto/bn/bn.h, check the\n"; | |
325 | $banner.="\t\@echo documentation for details.\n"; | |
326 | } | |
327 | ||
328 | # have to do this to allow $(CC) under unix | |
329 | $link="$bin_dir$link" if ($link !~ /^\$/); | |
330 | ||
331 | $INSTALLTOP =~ s|/|$o|g; | |
b8bb15fb | 332 | $OPENSSLDIR =~ s|/|$o|g; |
d02b48c6 | 333 | |
2dc08d5f DSH |
334 | ############################################# |
335 | # We parse in input file and 'store' info for later printing. | |
336 | open(IN,"<$infile") || die "unable to open $infile:$!\n"; | |
337 | $_=<IN>; | |
338 | for (;;) | |
339 | { | |
340 | chop; | |
341 | ||
342 | ($key,$val)=/^([^=]+)=(.*)/; | |
343 | if ($key eq "RELATIVE_DIRECTORY") | |
344 | { | |
345 | if ($lib ne "") | |
346 | { | |
06b433ac DSH |
347 | if ($fips && $dir =~ /^fips/) |
348 | { | |
349 | $uc = "FIPS"; | |
350 | } | |
351 | else | |
352 | { | |
353 | $uc=$lib; | |
354 | $uc =~ s/^lib(.*)\.a/$1/; | |
355 | $uc =~ tr/a-z/A-Z/; | |
356 | } | |
357 | if (($uc ne "FIPS") || $fipscanisterbuild) | |
358 | { | |
359 | $lib_nam{$uc}=$uc; | |
360 | $lib_obj{$uc}.=$libobj." "; | |
361 | } | |
2dc08d5f DSH |
362 | } |
363 | last if ($val eq "FINISHED"); | |
364 | $lib=""; | |
365 | $libobj=""; | |
366 | $dir=$val; | |
367 | } | |
368 | ||
369 | if ($key eq "KRB5_INCLUDES") | |
370 | { $cflags .= " $val";} | |
371 | ||
ad2695b1 | 372 | if ($key eq "ZLIB_INCLUDE") |
1291dfde | 373 | { $cflags .= " $val" if $val ne "";} |
ad2695b1 DSH |
374 | |
375 | if ($key eq "LIBZLIB") | |
376 | { $zlib_lib = "$val" if $val ne "";} | |
377 | ||
2dc08d5f | 378 | if ($key eq "LIBKRB5") |
ad2695b1 | 379 | { $ex_libs .= " $val" if $val ne "";} |
2dc08d5f | 380 | |
d989e4f8 | 381 | if ($key eq "TEST" && (!$fipscanisteronly || $dir =~ /^fips/ )) |
c51f2d42 | 382 | { $test.=&var_add($dir,$val, 0); } |
2dc08d5f DSH |
383 | |
384 | if (($key eq "PROGS") || ($key eq "E_OBJ")) | |
c51f2d42 | 385 | { $e_exe.=&var_add($dir,$val, 0); } |
2dc08d5f DSH |
386 | |
387 | if ($key eq "LIB") | |
388 | { | |
389 | $lib=$val; | |
390 | $lib =~ s/^.*\/([^\/]+)$/$1/; | |
391 | } | |
223c59ea DSH |
392 | if ($key eq "LIBNAME" && $no_static_engine) |
393 | { | |
394 | $lib=$val; | |
395 | $lib =~ s/^.*\/([^\/]+)$/$1/; | |
396 | $otherlibs .= " $lib"; | |
397 | } | |
2dc08d5f DSH |
398 | |
399 | if ($key eq "EXHEADER") | |
c51f2d42 | 400 | { $exheader.=&var_add($dir,$val, 1); } |
2dc08d5f DSH |
401 | |
402 | if ($key eq "HEADER") | |
c51f2d42 | 403 | { $header.=&var_add($dir,$val, 1); } |
2dc08d5f | 404 | |
fbf002bb | 405 | if ($key eq "LIBOBJ" && ($dir ne "engines" || !$no_static_engine)) |
c51f2d42 | 406 | { $libobj=&var_add($dir,$val, 0); } |
fbf002bb DSH |
407 | if ($key eq "LIBNAMES" && $dir eq "engines" && $no_static_engine) |
408 | { $engines.=$val } | |
2dc08d5f | 409 | |
06b433ac DSH |
410 | if ($key eq "FIPS_EX_OBJ") |
411 | { | |
412 | $fips_ex_obj=&var_add("crypto",$val,0); | |
413 | } | |
414 | ||
415 | if ($key eq "FIPSLIBDIR") | |
416 | { | |
417 | $fipslibdir=$val; | |
418 | $fipslibdir =~ s/\/$//; | |
419 | $fipslibdir =~ s/\//$o/g; | |
420 | } | |
421 | ||
422 | if ($key eq "BASEADDR") | |
423 | { $baseaddr=$val;} | |
424 | ||
2dc08d5f DSH |
425 | if (!($_=<IN>)) |
426 | { $_="RELATIVE_DIRECTORY=FINISHED\n"; } | |
427 | } | |
428 | close(IN); | |
429 | ||
06b433ac DSH |
430 | if ($fips) |
431 | { | |
432 | ||
433 | foreach (split " ", $fips_ex_obj) | |
434 | { | |
435 | $fips_exclude_obj{$1} = 1 if (/\/([^\/]*)$/); | |
436 | } | |
437 | foreach (split " ", | |
dc527a62 DSH |
438 | "$mf_cpuid_asm $mf_aes_asm $mf_sha_asm $mf_bn_asm " . |
439 | "$mf_des_asm $mf_modes_asm") | |
06b433ac DSH |
440 | { |
441 | s/\.o//; | |
442 | $fips_exclude_obj{$_} = 1; | |
443 | } | |
444 | my @ltmp = split " ", $lib_obj{"CRYPTO"}; | |
445 | ||
446 | ||
447 | $lib_obj{"CRYPTO"} = ""; | |
448 | ||
449 | foreach(@ltmp) | |
450 | { | |
451 | if (/\/([^\/]*)$/ && exists $fips_exclude_obj{$1}) | |
452 | { | |
453 | if ($fipscanisterbuild) | |
454 | { | |
455 | $lib_obj{"FIPS"} .= "$_ "; | |
456 | } | |
457 | } | |
d989e4f8 | 458 | elsif (!$fipscanisteronly) |
06b433ac DSH |
459 | { |
460 | $lib_obj{"CRYPTO"} .= "$_ "; | |
461 | } | |
462 | } | |
463 | ||
464 | } | |
465 | ||
466 | if ($fipscanisterbuild) | |
467 | { | |
468 | $fips_canister_path = "\$(LIB_D)${o}fipscanister.lib" if $fips_canister_path eq ""; | |
469 | $fips_premain_c_path = "\$(LIB_D)${o}fips_premain.c"; | |
470 | } | |
471 | else | |
472 | { | |
473 | if ($fips_canister_path eq "") | |
474 | { | |
475 | $fips_canister_path = "\$(FIPSLIB_D)${o}fipscanister.lib"; | |
476 | } | |
477 | ||
478 | if ($fips_premain_c_path eq "") | |
479 | { | |
480 | $fips_premain_c_path = "\$(FIPSLIB_D)${o}fips_premain.c"; | |
481 | } | |
482 | } | |
483 | ||
484 | if ($fips) | |
485 | { | |
486 | if ($fips_sha1_exe_path eq "") | |
487 | { | |
488 | $fips_sha1_exe_path = | |
489 | "\$(BIN_D)${o}fips_standalone_sha1$exep"; | |
490 | } | |
491 | } | |
492 | else | |
493 | { | |
494 | $fips_sha1_exe_path = ""; | |
495 | } | |
496 | ||
497 | if ($fips_premain_dso_exe_path eq "") | |
498 | { | |
499 | $fips_premain_dso_exe_path = "\$(BIN_D)${o}fips_premain_dso$exep"; | |
500 | } | |
501 | ||
502 | # $ex_build_targets .= "\$(BIN_D)${o}\$(E_PREMAIN_DSO)$exep" if ($fips); | |
503 | ||
504 | if ($fips) | |
505 | { | |
506 | if (!$shlib) | |
507 | { | |
d989e4f8 | 508 | $build_targets .= " \$(LIB_D)$o$crypto_compat \$(PREMAIN_DSO_EXE)"; |
06b433ac DSH |
509 | $ex_l_libs .= " \$(O_FIPSCANISTER)"; |
510 | $ex_libs_dep .= " \$(O_FIPSCANISTER)" if $fipscanisterbuild; | |
511 | } | |
512 | if ($fipscanisterbuild) | |
513 | { | |
514 | $fipslibdir = "\$(LIB_D)"; | |
515 | } | |
516 | else | |
517 | { | |
518 | if ($fipslibdir eq "") | |
519 | { | |
520 | open (IN, "util/fipslib_path.txt") || fipslib_error(); | |
521 | $fipslibdir = <IN>; | |
522 | chomp $fipslibdir; | |
523 | close IN; | |
524 | } | |
525 | fips_check_files($fipslibdir, | |
526 | "fipscanister.lib", "fipscanister.lib.sha1", | |
527 | "fips_premain.c", "fips_premain.c.sha1"); | |
528 | } | |
529 | } | |
530 | ||
d989e4f8 DSH |
531 | if ($fipscanisteronly) |
532 | { | |
533 | $build_targets = "\$(O_FIPSCANISTER) \$(T_EXE)"; | |
534 | $libs_dep = ""; | |
535 | } | |
536 | ||
537 | ||
2e9f1bf0 DSH |
538 | if ($shlib) |
539 | { | |
540 | $extra_install= <<"EOF"; | |
96fc37f1 DSH |
541 | \$(CP) \"\$(O_SSL)\" \"\$(INSTALLTOP)${o}bin\" |
542 | \$(CP) \"\$(O_CRYPTO)\" \"\$(INSTALLTOP)${o}bin\" | |
543 | \$(CP) \"\$(L_SSL)\" \"\$(INSTALLTOP)${o}lib\" | |
544 | \$(CP) \"\$(L_CRYPTO)\" \"\$(INSTALLTOP)${o}lib\" | |
2e9f1bf0 DSH |
545 | EOF |
546 | if ($no_static_engine) | |
547 | { | |
548 | $extra_install .= <<"EOF" | |
96fc37f1 DSH |
549 | \$(MKDIR) \"\$(INSTALLTOP)${o}lib${o}engines\" |
550 | \$(CP) \"\$(E_SHLIB)\" \"\$(INSTALLTOP)${o}lib${o}engines\" | |
2e9f1bf0 DSH |
551 | EOF |
552 | } | |
553 | } | |
554 | else | |
555 | { | |
556 | $extra_install= <<"EOF"; | |
96fc37f1 DSH |
557 | \$(CP) \"\$(O_SSL)\" \"\$(INSTALLTOP)${o}lib\" |
558 | \$(CP) \"\$(O_CRYPTO)\" \"\$(INSTALLTOP)${o}lib\" | |
2e9f1bf0 | 559 | EOF |
ad2695b1 | 560 | $ex_libs .= " $zlib_lib" if $zlib_opt == 1; |
2e9f1bf0 DSH |
561 | } |
562 | ||
d02b48c6 | 563 | $defs= <<"EOF"; |
e527ba09 DSH |
564 | # This makefile has been automatically generated from the OpenSSL distribution. |
565 | # This single makefile will build the complete OpenSSL distribution and | |
d02b48c6 RE |
566 | # by default leave the 'intertesting' output files in .${o}out and the stuff |
567 | # that needs deleting in .${o}tmp. | |
568 | # The file was generated by running 'make makefile.one', which | |
569 | # does a 'make files', which writes all the environment variables from all | |
570 | # the makefiles to the file call MINFO. This file is used by | |
571 | # util${o}mk1mf.pl to generate makefile.one. | |
572 | # The 'makefile per directory' system suites me when developing this | |
573 | # library and also so I can 'distribute' indervidual library sections. | |
574 | # The one monster makefile better suits building in non-unix | |
575 | # environments. | |
576 | ||
7a1f92fd RL |
577 | EOF |
578 | ||
0b352c58 RL |
579 | $defs .= $preamble if defined $preamble; |
580 | ||
7a1f92fd | 581 | $defs.= <<"EOF"; |
d02b48c6 | 582 | INSTALLTOP=$INSTALLTOP |
b8bb15fb | 583 | OPENSSLDIR=$OPENSSLDIR |
d02b48c6 RE |
584 | |
585 | # Set your compiler options | |
dfeab068 | 586 | PLATFORM=$platform |
d02b48c6 RE |
587 | CC=$bin_dir${cc} |
588 | CFLAG=$cflags | |
589 | APP_CFLAG=$app_cflag | |
590 | LIB_CFLAG=$lib_cflag | |
58964a49 | 591 | SHLIB_CFLAG=$shl_cflag |
d02b48c6 RE |
592 | APP_EX_OBJ=$app_ex_obj |
593 | SHLIB_EX_OBJ=$shlib_ex_obj | |
594 | # add extra libraries to this define, for solaris -lsocket -lnsl would | |
595 | # be added | |
596 | EX_LIBS=$ex_libs | |
597 | ||
e527ba09 | 598 | # The OpenSSL directory |
d02b48c6 RE |
599 | SRC_D=$src_dir |
600 | ||
601 | LINK=$link | |
602 | LFLAGS=$lflags | |
fc6a6a10 | 603 | RSC=$rsc |
06b433ac | 604 | FIPSLINK=\$(PERL) util${o}fipslink.pl |
d02b48c6 | 605 | |
d02b48c6 RE |
606 | # The output directory for everything intersting |
607 | OUT_D=$out_dir | |
608 | # The output directory for all the temporary muck | |
609 | TMP_D=$tmp_dir | |
58964a49 RE |
610 | # The output directory for the header files |
611 | INC_D=$inc_dir | |
ec577822 | 612 | INCO_D=$inc_dir${o}openssl |
d02b48c6 | 613 | |
2e9f1bf0 | 614 | PERL=$perl |
d02b48c6 RE |
615 | CP=$cp |
616 | RM=$rm | |
617 | RANLIB=$ranlib | |
12d7d32f | 618 | MKDIR=$mkdir |
d02b48c6 RE |
619 | MKLIB=$bin_dir$mklib |
620 | MLFLAGS=$mlflags | |
621 | ASM=$bin_dir$asm | |
622 | ||
06b433ac DSH |
623 | # FIPS validated module and support file locations |
624 | ||
625 | E_PREMAIN_DSO=fips_premain_dso | |
626 | ||
627 | FIPSLIB_D=$fipslibdir | |
628 | BASEADDR=$baseaddr | |
629 | FIPS_PREMAIN_SRC=$fips_premain_c_path | |
630 | O_FIPSCANISTER=$fips_canister_path | |
631 | FIPS_SHA1_EXE=$fips_sha1_exe_path | |
632 | PREMAIN_DSO_EXE=$fips_premain_dso_exe_path | |
633 | ||
d02b48c6 RE |
634 | ###################################################### |
635 | # You should not need to touch anything below this point | |
636 | ###################################################### | |
637 | ||
e527ba09 | 638 | E_EXE=openssl |
d02b48c6 RE |
639 | SSL=$ssl |
640 | CRYPTO=$crypto | |
d02b48c6 RE |
641 | |
642 | # BIN_D - Binary output directory | |
643 | # TEST_D - Binary test file output directory | |
644 | # LIB_D - library output directory | |
fbf002bb | 645 | # ENG_D - dynamic engine output directory |
e2e044fa DSH |
646 | # Note: if you change these point to different directories then uncomment out |
647 | # the lines around the 'NB' comment below. | |
648 | # | |
d02b48c6 RE |
649 | BIN_D=\$(OUT_D) |
650 | TEST_D=\$(OUT_D) | |
651 | LIB_D=\$(OUT_D) | |
fbf002bb | 652 | ENG_D=\$(OUT_D) |
d02b48c6 RE |
653 | |
654 | # INCL_D - local library directory | |
655 | # OBJ_D - temp object file directory | |
656 | OBJ_D=\$(TMP_D) | |
657 | INCL_D=\$(TMP_D) | |
658 | ||
659 | O_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp | |
660 | O_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp | |
58964a49 RE |
661 | SO_SSL= $plib\$(SSL)$so_shlibp |
662 | SO_CRYPTO= $plib\$(CRYPTO)$so_shlibp | |
31a674d8 UM |
663 | L_SSL= \$(LIB_D)$o$plib\$(SSL)$libp |
664 | L_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$libp | |
d02b48c6 | 665 | |
06b433ac | 666 | L_LIBS= \$(L_SSL) \$(L_CRYPTO) $ex_l_libs |
d02b48c6 RE |
667 | |
668 | ###################################################### | |
669 | # Don't touch anything below this point | |
670 | ###################################################### | |
671 | ||
58964a49 | 672 | INC=-I\$(INC_D) -I\$(INCL_D) |
d02b48c6 RE |
673 | APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG) |
674 | LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) | |
58964a49 | 675 | SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG) |
d989e4f8 | 676 | LIBS_DEP=$libs_dep |
d02b48c6 RE |
677 | |
678 | ############################################# | |
679 | EOF | |
680 | ||
681 | $rules=<<"EOF"; | |
d989e4f8 | 682 | all: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INCO_D) headers \$(FIPS_SHA1_EXE) $build_targets |
d02b48c6 RE |
683 | |
684 | banner: | |
685 | $banner | |
686 | ||
d02b48c6 | 687 | \$(TMP_D): |
96fc37f1 | 688 | \$(MKDIR) \"\$(TMP_D)\" |
e2e044fa DSH |
689 | # NB: uncomment out these lines if BIN_D, TEST_D and LIB_D are different |
690 | #\$(BIN_D): | |
691 | # \$(MKDIR) \$(BIN_D) | |
692 | # | |
693 | #\$(TEST_D): | |
694 | # \$(MKDIR) \$(TEST_D) | |
58964a49 RE |
695 | |
696 | \$(LIB_D): | |
96fc37f1 | 697 | \$(MKDIR) \"\$(LIB_D)\" |
58964a49 | 698 | |
ec577822 | 699 | \$(INCO_D): \$(INC_D) |
96fc37f1 | 700 | \$(MKDIR) \"\$(INCO_D)\" |
ec577822 | 701 | |
58964a49 | 702 | \$(INC_D): |
96fc37f1 | 703 | \$(MKDIR) \"\$(INC_D)\" |
58964a49 | 704 | |
d02b48c6 | 705 | headers: \$(HEADER) \$(EXHEADER) |
b222eb64 | 706 | @ |
d02b48c6 | 707 | |
fbf002bb | 708 | lib: \$(LIBS_DEP) \$(E_SHLIB) |
d02b48c6 RE |
709 | |
710 | exe: \$(T_EXE) \$(BIN_D)$o\$(E_EXE)$exep | |
711 | ||
2e9f1bf0 | 712 | install: all |
96fc37f1 DSH |
713 | \$(MKDIR) \"\$(INSTALLTOP)\" |
714 | \$(MKDIR) \"\$(INSTALLTOP)${o}bin\" | |
715 | \$(MKDIR) \"\$(INSTALLTOP)${o}include\" | |
716 | \$(MKDIR) \"\$(INSTALLTOP)${o}include${o}openssl\" | |
717 | \$(MKDIR) \"\$(INSTALLTOP)${o}lib\" | |
76d761cc | 718 | \$(CP) \"\$(INCO_D)${o}*.\[ch\]\" \"\$(INSTALLTOP)${o}include${o}openssl\" |
96fc37f1 DSH |
719 | \$(CP) \"\$(BIN_D)$o\$(E_EXE)$exep \$(INSTALLTOP)${o}bin\" |
720 | \$(MKDIR) \"\$(OPENSSLDIR)\" | |
721 | \$(CP) apps${o}openssl.cnf \"\$(OPENSSLDIR)\" | |
2e9f1bf0 DSH |
722 | $extra_install |
723 | ||
724 | ||
725 | test: \$(T_EXE) | |
726 | cd \$(BIN_D) | |
727 | ..${o}ms${o}test | |
d02b48c6 RE |
728 | |
729 | clean: | |
730 | \$(RM) \$(TMP_D)$o*.* | |
731 | ||
732 | vclean: | |
733 | \$(RM) \$(TMP_D)$o*.* | |
734 | \$(RM) \$(OUT_D)$o*.* | |
735 | ||
736 | EOF | |
2e0fc875 BM |
737 | |
738 | my $platform_cpp_symbol = "MK1MF_PLATFORM_$platform"; | |
e9185df4 | 739 | $platform_cpp_symbol =~ s/-/_/g; |
57119943 | 740 | if (open(IN,"crypto/buildinf.h")) |
2e0fc875 | 741 | { |
57119943 | 742 | # Remove entry for this platform in existing file buildinf.h. |
2e0fc875 | 743 | |
57119943 | 744 | my $old_buildinf_h = ""; |
2e0fc875 BM |
745 | while (<IN>) |
746 | { | |
747 | if (/^\#ifdef $platform_cpp_symbol$/) | |
748 | { | |
749 | while (<IN>) { last if (/^\#endif/); } | |
750 | } | |
751 | else | |
752 | { | |
57119943 | 753 | $old_buildinf_h .= $_; |
2e0fc875 BM |
754 | } |
755 | } | |
7fbd8db1 | 756 | close(IN); |
2e0fc875 | 757 | |
57119943 BM |
758 | open(OUT,">crypto/buildinf.h") || die "Can't open buildinf.h"; |
759 | print OUT $old_buildinf_h; | |
7fbd8db1 | 760 | close(OUT); |
2e0fc875 BM |
761 | } |
762 | ||
57119943 | 763 | open (OUT,">>crypto/buildinf.h") || die "Can't open buildinf.h"; |
2e0fc875 BM |
764 | printf OUT <<EOF; |
765 | #ifdef $platform_cpp_symbol | |
57119943 | 766 | /* auto-generated/updated by util/mk1mf.pl for crypto/cversion.c */ |
2e0fc875 BM |
767 | #define CFLAGS "$cc $cflags" |
768 | #define PLATFORM "$platform" | |
769 | EOF | |
770 | printf OUT " #define DATE \"%s\"\n", scalar gmtime(); | |
771 | printf OUT "#endif\n"; | |
772 | close(OUT); | |
d02b48c6 | 773 | |
d02b48c6 RE |
774 | # Strip of trailing ' ' |
775 | foreach (keys %lib_obj) { $lib_obj{$_}=&clean_up_ws($lib_obj{$_}); } | |
776 | $test=&clean_up_ws($test); | |
777 | $e_exe=&clean_up_ws($e_exe); | |
778 | $exheader=&clean_up_ws($exheader); | |
779 | $header=&clean_up_ws($header); | |
780 | ||
781 | # First we strip the exheaders from the headers list | |
782 | foreach (split(/\s+/,$exheader)){ $h{$_}=1; } | |
783 | foreach (split(/\s+/,$header)) { $h.=$_." " unless $h{$_}; } | |
784 | chop($h); $header=$h; | |
785 | ||
c51f2d42 DSH |
786 | $defs.=&do_defs("HEADER",$header,"\$(INCL_D)",""); |
787 | $rules.=&do_copy_rule("\$(INCL_D)",$header,""); | |
d02b48c6 | 788 | |
c51f2d42 DSH |
789 | $defs.=&do_defs("EXHEADER",$exheader,"\$(INCO_D)",""); |
790 | $rules.=&do_copy_rule("\$(INCO_D)",$exheader,""); | |
d02b48c6 RE |
791 | |
792 | $defs.=&do_defs("T_OBJ",$test,"\$(OBJ_D)",$obj); | |
793 | $rules.=&do_compile_rule("\$(OBJ_D)",$test,"\$(APP_CFLAGS)"); | |
794 | ||
795 | $defs.=&do_defs("E_OBJ",$e_exe,"\$(OBJ_D)",$obj); | |
796 | $rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)'); | |
797 | ||
06b433ac DSH |
798 | # Special case rules for fips_start and fips_end fips_premain_dso |
799 | ||
800 | if ($fips) | |
801 | { | |
802 | if ($fipscanisterbuild) | |
803 | { | |
804 | $rules.=&cc_compile_target("\$(OBJ_D)${o}fips_start$obj", | |
805 | "fips${o}fips_canister.c", | |
806 | "-DFIPS_START \$(SHLIB_CFLAGS)"); | |
807 | $rules.=&cc_compile_target("\$(OBJ_D)${o}fips_end$obj", | |
808 | "fips${o}fips_canister.c", "\$(SHLIB_CFLAGS)"); | |
809 | } | |
810 | $rules.=&cc_compile_target("\$(OBJ_D)${o}fips_standalone_sha1$obj", | |
811 | "fips${o}sha${o}fips_standalone_sha1.c", | |
812 | "\$(SHLIB_CFLAGS)"); | |
813 | $rules.=&cc_compile_target("\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj", | |
814 | "fips${o}fips_premain.c", | |
815 | "-DFINGERPRINT_PREMAIN_DSO_LOAD \$(SHLIB_CFLAGS)"); | |
816 | } | |
817 | ||
d02b48c6 RE |
818 | foreach (values %lib_nam) |
819 | { | |
820 | $lib_obj=$lib_obj{$_}; | |
58964a49 RE |
821 | local($slib)=$shlib; |
822 | ||
d02b48c6 RE |
823 | if (($_ eq "SSL") && $no_ssl2 && $no_ssl3) |
824 | { | |
825 | $rules.="\$(O_SSL):\n\n"; | |
826 | next; | |
827 | } | |
828 | ||
d02b48c6 | 829 | $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj); |
f09628e4 | 830 | $lib=($slib)?" \$(SHLIB_CFLAGS)".$shlib_ex_cflags{$_}:" \$(LIB_CFLAGS)"; |
58964a49 | 831 | $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib); |
d02b48c6 RE |
832 | } |
833 | ||
fc6a6a10 | 834 | # hack to add version info on MSVC |
1d42dbaf | 835 | if (($platform eq "VC-WIN32") || ($platform eq "VC-WIN64A") |
23129dec | 836 | || ($platform eq "VC-WIN64I") || ($platform eq "VC-NT")) { |
fc6a6a10 DSH |
837 | $rules.= <<"EOF"; |
838 | \$(OBJ_D)\\\$(CRYPTO).res: ms\\version32.rc | |
839 | \$(RSC) /fo"\$(OBJ_D)\\\$(CRYPTO).res" /d CRYPTO ms\\version32.rc | |
840 | ||
841 | \$(OBJ_D)\\\$(SSL).res: ms\\version32.rc | |
842 | \$(RSC) /fo"\$(OBJ_D)\\\$(SSL).res" /d SSL ms\\version32.rc | |
843 | ||
844 | EOF | |
845 | } | |
846 | ||
d02b48c6 | 847 | $defs.=&do_defs("T_EXE",$test,"\$(TEST_D)",$exep); |
06b433ac DSH |
848 | foreach (split(/\s+/,$test)) |
849 | { | |
850 | my $t_libs; | |
851 | $t=&bname($_); | |
852 | my $ltype; | |
853 | # Check to see if test program is FIPS | |
854 | if ($fips && /fips/) | |
855 | { | |
856 | # If fips perform static link to | |
857 | # $(O_FIPSCANISTER) | |
858 | $t_libs = "\$(O_FIPSCANISTER)"; | |
859 | $ltype = 2; | |
860 | } | |
861 | else | |
862 | { | |
863 | $t_libs = "\$(L_LIBS)"; | |
864 | $ltype = 0; | |
865 | } | |
866 | ||
867 | $tt="\$(OBJ_D)${o}$t${obj}"; | |
868 | $rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","$t_libs \$(EX_LIBS)", $ltype); | |
869 | } | |
d02b48c6 | 870 | |
223c59ea | 871 | $defs.=&do_defs("E_SHLIB",$engines . $otherlibs,"\$(ENG_D)",$shlibp); |
fbf002bb DSH |
872 | |
873 | foreach (split(/\s+/,$engines)) | |
874 | { | |
875 | $rules.=&do_compile_rule("\$(OBJ_D)","engines${o}e_$_",$lib); | |
876 | $rules.= &do_lib_rule("\$(OBJ_D)${o}e_${_}.obj","\$(ENG_D)$o$_$shlibp","",$shlib,""); | |
877 | } | |
878 | ||
879 | ||
880 | ||
58964a49 | 881 | $rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)"); |
06b433ac | 882 | #$rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)"); |
d02b48c6 | 883 | |
ef3026a3 | 884 | foreach (split(" ",$otherlibs)) |
223c59ea DSH |
885 | { |
886 | my $uc = $_; | |
887 | $uc =~ tr /a-z/A-Z/; | |
888 | $rules.= &do_lib_rule("\$(${uc}OBJ)","\$(ENG_D)$o$_$shlibp", "", $shlib, ""); | |
889 | ||
890 | } | |
891 | ||
06b433ac DSH |
892 | if ($fips) |
893 | { | |
894 | if ($shlib) | |
895 | { | |
896 | $rules.= &do_lib_rule("\$(CRYPTOOBJ) \$(O_FIPSCANISTER)", | |
897 | "\$(O_CRYPTO)", "$crypto", | |
898 | $shlib, "\$(SO_CRYPTO)", "\$(BASEADDR)"); | |
899 | } | |
900 | else | |
901 | { | |
902 | $rules.= &do_lib_rule("\$(CRYPTOOBJ)", | |
903 | "\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)", ""); | |
904 | $rules.= &do_lib_rule("\$(CRYPTOOBJ) \$(FIPSOBJ)", | |
905 | "\$(LIB_D)$o$crypto_compat",$crypto,$shlib,"\$(SO_CRYPTO)", ""); | |
906 | } | |
907 | } | |
908 | else | |
909 | { | |
910 | $rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib, | |
911 | "\$(SO_CRYPTO)"); | |
912 | } | |
913 | ||
914 | if ($fips) | |
915 | { | |
916 | if ($fipscanisterbuild) | |
917 | { | |
918 | $rules.= &do_rlink_rule("\$(O_FIPSCANISTER)", | |
919 | "\$(OBJ_D)${o}fips_start$obj", | |
920 | "\$(FIPSOBJ)", | |
921 | "\$(OBJ_D)${o}fips_end$obj", | |
922 | "\$(FIPS_SHA1_EXE)", ""); | |
923 | # FIXME | |
924 | $rules.=&do_link_rule("\$(FIPS_SHA1_EXE)", | |
925 | "\$(OBJ_D)${o}fips_standalone_sha1$obj \$(OBJ_D)${o}sha1dgst$obj $sha1_asm_obj", | |
926 | "","\$(EX_LIBS)", 1); | |
927 | } | |
928 | else | |
929 | { | |
930 | $rules.=&do_link_rule("\$(FIPS_SHA1_EXE)", | |
931 | "\$(OBJ_D)${o}fips_standalone_sha1$obj \$(O_FIPSCANISTER)", | |
932 | "","", 1); | |
933 | ||
934 | } | |
935 | $rules.=&do_link_rule("\$(PREMAIN_DSO_EXE)","\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj \$(CRYPTOOBJ) \$(O_FIPSCANISTER)","","\$(EX_LIBS)", 1); | |
936 | ||
937 | } | |
938 | ||
939 | $rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)", ($fips && !$shlib) ? 2 : 0); | |
d02b48c6 RE |
940 | |
941 | print $defs; | |
eb206eb8 UM |
942 | |
943 | if ($platform eq "linux-elf") { | |
944 | print <<"EOF"; | |
945 | # Generate perlasm output files | |
946 | %.cpp: | |
cd202fe2 | 947 | (cd \$(\@D)/..; PERL=perl make -f Makefile asm/\$(\@F)) |
eb206eb8 UM |
948 | EOF |
949 | } | |
d02b48c6 RE |
950 | print "###################################################################\n"; |
951 | print $rules; | |
952 | ||
953 | ############################################### | |
954 | # strip off any trailing .[och] and append the relative directory | |
955 | # also remembering to do nothing if we are in one of the dropped | |
956 | # directories | |
957 | sub var_add | |
958 | { | |
c51f2d42 | 959 | local($dir,$val,$keepext)=@_; |
d02b48c6 RE |
960 | local(@a,$_,$ret); |
961 | ||
0b13e9f0 | 962 | return("") if $no_engine && $dir =~ /\/engine/; |
5cd48abf | 963 | return("") if $no_hw && $dir =~ /\/hw/; |
d02b48c6 | 964 | return("") if $no_idea && $dir =~ /\/idea/; |
77dd9c18 | 965 | return("") if $no_aes && $dir =~ /\/aes/; |
f3dea9a5 | 966 | return("") if $no_camellia && $dir =~ /\/camellia/; |
96afc1cf | 967 | return("") if $no_seed && $dir =~ /\/seed/; |
d02b48c6 RE |
968 | return("") if $no_rc2 && $dir =~ /\/rc2/; |
969 | return("") if $no_rc4 && $dir =~ /\/rc4/; | |
58964a49 | 970 | return("") if $no_rc5 && $dir =~ /\/rc5/; |
d02b48c6 RE |
971 | return("") if $no_rsa && $dir =~ /\/rsa/; |
972 | return("") if $no_rsa && $dir =~ /^rsaref/; | |
973 | return("") if $no_dsa && $dir =~ /\/dsa/; | |
974 | return("") if $no_dh && $dir =~ /\/dh/; | |
e8e0e371 | 975 | return("") if $no_ec && $dir =~ /\/ec/; |
4ed7b78b | 976 | return("") if $no_gost && $dir =~ /\/ccgost/; |
68190507 | 977 | return("") if $no_cms && $dir =~ /\/cms/; |
79bd20fd | 978 | return("") if $no_jpake && $dir =~ /\/jpake/; |
06b433ac | 979 | return("") if !$fips && $dir =~ /^fips/; |
d02b48c6 RE |
980 | if ($no_des && $dir =~ /\/des/) |
981 | { | |
982 | if ($val =~ /read_pwd/) | |
983 | { return("$dir/read_pwd "); } | |
984 | else | |
985 | { return(""); } | |
986 | } | |
987 | return("") if $no_mdc2 && $dir =~ /\/mdc2/; | |
988 | return("") if $no_sock && $dir =~ /\/proxy/; | |
989 | return("") if $no_bf && $dir =~ /\/bf/; | |
58964a49 | 990 | return("") if $no_cast && $dir =~ /\/cast/; |
ec645d90 | 991 | return("") if $no_whirlpool && $dir =~ /\/whrlpool/; |
d02b48c6 RE |
992 | |
993 | $val =~ s/^\s*(.*)\s*$/$1/; | |
994 | @a=split(/\s+/,$val); | |
c51f2d42 | 995 | grep(s/\.[och]$//,@a) unless $keepext; |
d02b48c6 RE |
996 | |
997 | @a=grep(!/^e_.*_3d$/,@a) if $no_des; | |
998 | @a=grep(!/^e_.*_d$/,@a) if $no_des; | |
77dd9c18 RL |
999 | @a=grep(!/^e_.*_ae$/,@a) if $no_idea; |
1000 | @a=grep(!/^e_.*_i$/,@a) if $no_aes; | |
d02b48c6 | 1001 | @a=grep(!/^e_.*_r2$/,@a) if $no_rc2; |
58964a49 | 1002 | @a=grep(!/^e_.*_r5$/,@a) if $no_rc5; |
d02b48c6 | 1003 | @a=grep(!/^e_.*_bf$/,@a) if $no_bf; |
58964a49 | 1004 | @a=grep(!/^e_.*_c$/,@a) if $no_cast; |
d02b48c6 | 1005 | @a=grep(!/^e_rc4$/,@a) if $no_rc4; |
f3dea9a5 | 1006 | @a=grep(!/^e_camellia$/,@a) if $no_camellia; |
96afc1cf | 1007 | @a=grep(!/^e_seed$/,@a) if $no_seed; |
d02b48c6 | 1008 | |
06ddf8eb DSH |
1009 | #@a=grep(!/(^s2_)|(^s23_)/,@a) if $no_ssl2; |
1010 | #@a=grep(!/(^s3_)|(^s23_)/,@a) if $no_ssl3; | |
d02b48c6 RE |
1011 | |
1012 | @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock; | |
1013 | ||
1014 | @a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2; | |
3009458e | 1015 | @a=grep(!/(^md4)|(_md4$)/,@a) if $no_md4; |
d02b48c6 | 1016 | @a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5; |
7e38616d | 1017 | @a=grep(!/(rmd)|(ripemd)/,@a) if $no_ripemd; |
d02b48c6 RE |
1018 | |
1019 | @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa; | |
1020 | @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa; | |
1021 | @a=grep(!/(^pem_seal$)/,@a) if $no_rsa; | |
1022 | ||
1023 | @a=grep(!/(m_dss$)|(m_dss1$)/,@a) if $no_dsa; | |
1024 | @a=grep(!/(^d2i_s_)|(^i2d_s_)|(_dsap$)/,@a) if $no_dsa; | |
1025 | ||
1026 | @a=grep(!/^n_pkey$/,@a) if $no_rsa || $no_rc4; | |
1027 | ||
1028 | @a=grep(!/_dhp$/,@a) if $no_dh; | |
1029 | ||
1030 | @a=grep(!/(^sha[^1])|(_sha$)|(m_dss$)/,@a) if $no_sha; | |
1031 | @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1; | |
1032 | @a=grep(!/_mdc2$/,@a) if $no_mdc2; | |
1033 | ||
edc032b5 BL |
1034 | @a=grep(!/(srp)/,@a) if $no_srp; |
1035 | ||
0b13e9f0 | 1036 | @a=grep(!/^engine$/,@a) if $no_engine; |
5cd48abf | 1037 | @a=grep(!/^hw$/,@a) if $no_hw; |
13e91dd3 | 1038 | @a=grep(!/(^rsa$)|(^genrsa$)/,@a) if $no_rsa; |
d02b48c6 RE |
1039 | @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa; |
1040 | @a=grep(!/^gendsa$/,@a) if $no_sha1; | |
1041 | @a=grep(!/(^dh$)|(^gendh$)/,@a) if $no_dh; | |
1042 | ||
1043 | @a=grep(!/(^dh)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1; | |
1044 | ||
1045 | grep($_="$dir/$_",@a); | |
1046 | @a=grep(!/(^|\/)s_/,@a) if $no_sock; | |
1047 | @a=grep(!/(^|\/)bio_sock/,@a) if $no_sock; | |
1048 | $ret=join(' ',@a)." "; | |
1049 | return($ret); | |
1050 | } | |
1051 | ||
1052 | # change things so that each 'token' is only separated by one space | |
1053 | sub clean_up_ws | |
1054 | { | |
1055 | local($w)=@_; | |
1056 | ||
1057 | $w =~ s/^\s*(.*)\s*$/$1/; | |
1058 | $w =~ s/\s+/ /g; | |
1059 | return($w); | |
1060 | } | |
1061 | ||
1062 | sub do_defs | |
1063 | { | |
1064 | local($var,$files,$location,$postfix)=@_; | |
58964a49 | 1065 | local($_,$ret,$pf); |
d02b48c6 RE |
1066 | local(*OUT,$tmp,$t); |
1067 | ||
1068 | $files =~ s/\//$o/g if $o ne '/'; | |
1069 | $ret="$var="; | |
1070 | $n=1; | |
1071 | $Vars{$var}.=""; | |
1072 | foreach (split(/ /,$files)) | |
1073 | { | |
58964a49 | 1074 | $orig=$_; |
d02b48c6 RE |
1075 | $_=&bname($_) unless /^\$/; |
1076 | if ($n++ == 2) | |
1077 | { | |
1078 | $n=0; | |
1079 | $ret.="\\\n\t"; | |
1080 | } | |
58964a49 RE |
1081 | if (($_ =~ /bss_file/) && ($postfix eq ".h")) |
1082 | { $pf=".c"; } | |
1083 | else { $pf=$postfix; } | |
dfeab068 | 1084 | if ($_ =~ /BN_ASM/) { $t="$_ "; } |
b222eb64 | 1085 | elsif ($_ =~ /BNCO_ASM/){ $t="$_ "; } |
4664eb52 | 1086 | elsif ($_ =~ /AES_ASM/){ $t="$_ "; } |
58964a49 RE |
1087 | elsif ($_ =~ /DES_ENC/) { $t="$_ "; } |
1088 | elsif ($_ =~ /BF_ENC/) { $t="$_ "; } | |
1089 | elsif ($_ =~ /CAST_ENC/){ $t="$_ "; } | |
1090 | elsif ($_ =~ /RC4_ENC/) { $t="$_ "; } | |
1091 | elsif ($_ =~ /RC5_ENC/) { $t="$_ "; } | |
1092 | elsif ($_ =~ /MD5_ASM/) { $t="$_ "; } | |
1093 | elsif ($_ =~ /SHA1_ASM/){ $t="$_ "; } | |
1094 | elsif ($_ =~ /RMD160_ASM/){ $t="$_ "; } | |
7c510d6f | 1095 | elsif ($_ =~ /WHIRLPOOL_ASM/){ $t="$_ "; } |
a4c886e4 | 1096 | elsif ($_ =~ /CPUID_ASM/){ $t="$_ "; } |
58964a49 | 1097 | else { $t="$location${o}$_$pf "; } |
d02b48c6 RE |
1098 | |
1099 | $Vars{$var}.="$t "; | |
1100 | $ret.=$t; | |
1101 | } | |
fc6a6a10 | 1102 | # hack to add version info on MSVC |
1d42dbaf | 1103 | if ($shlib && (($platform eq "VC-WIN32") || ($platfrom eq "VC-WIN64I") || ($platform eq "VC-WIN64A") || ($platform eq "VC-NT"))) |
fc6a6a10 DSH |
1104 | { |
1105 | if ($var eq "CRYPTOOBJ") | |
1106 | { $ret.="\$(OBJ_D)\\\$(CRYPTO).res "; } | |
1107 | elsif ($var eq "SSLOBJ") | |
1108 | { $ret.="\$(OBJ_D)\\\$(SSL).res "; } | |
1109 | } | |
fbf002bb | 1110 | chomp($ret); |
d02b48c6 RE |
1111 | $ret.="\n\n"; |
1112 | return($ret); | |
1113 | } | |
1114 | ||
1115 | # return the name with the leading path removed | |
1116 | sub bname | |
1117 | { | |
1118 | local($ret)=@_; | |
1119 | $ret =~ s/^.*[\\\/]([^\\\/]+)$/$1/; | |
1120 | return($ret); | |
1121 | } | |
1122 | ||
4287ade5 AP |
1123 | # return the leading path |
1124 | sub dname | |
1125 | { | |
1126 | my $ret=shift; | |
1127 | $ret =~ s/(^.*)[\\\/][^\\\/]+$/$1/; | |
1128 | return($ret); | |
1129 | } | |
d02b48c6 RE |
1130 | |
1131 | ############################################################## | |
1132 | # do a rule for each file that says 'compile' to new direcory | |
1133 | # compile the files in '$files' into $to | |
1134 | sub do_compile_rule | |
1135 | { | |
1136 | local($to,$files,$ex)=@_; | |
4287ade5 AP |
1137 | local($ret,$_,$n,$d,$s); |
1138 | ||
d02b48c6 RE |
1139 | $files =~ s/\//$o/g if $o ne '/'; |
1140 | foreach (split(/\s+/,$files)) | |
1141 | { | |
1142 | $n=&bname($_); | |
4287ade5 AP |
1143 | $d=&dname($_); |
1144 | if (-f "${_}.c") | |
1145 | { | |
1146 | $ret.=&cc_compile_target("$to${o}$n$obj","${_}.c",$ex) | |
1147 | } | |
1148 | elsif (-f ($s="${d}${o}asm${o}${n}.pl") or | |
f63e4be3 | 1149 | ($s=~s/sha256/sha512/ and -f $s) or |
4287ade5 AP |
1150 | -f ($s="${d}${o}${n}.pl")) |
1151 | { | |
1152 | $ret.=&perlasm_compile_target("$to${o}$n$obj",$s,$n); | |
1153 | } | |
1154 | elsif (-f ($s="${d}${o}asm${o}${n}.S") or | |
1155 | -f ($s="${d}${o}${n}.S")) | |
1156 | { | |
1157 | $ret.=&Sasm_compile_target("$to${o}$n$obj",$s,$n); | |
1158 | } | |
1159 | else { die "no rule for $_"; } | |
d02b48c6 RE |
1160 | } |
1161 | return($ret); | |
1162 | } | |
1163 | ||
1164 | ############################################################## | |
1165 | # do a rule for each file that says 'compile' to new direcory | |
4287ade5 AP |
1166 | sub perlasm_compile_target |
1167 | { | |
1168 | my($target,$source,$bname)=@_; | |
1169 | my($ret); | |
4287ade5 AP |
1170 | $bname =~ s/(.*)\.[^\.]$/$1/; |
1171 | $ret ="\$(TMP_D)$o$bname.asm: $source\n"; | |
548b4763 DSH |
1172 | $ret.="\t\$(PERL) $source $asmtype \$(CFLAG) >\$\@\n"; |
1173 | if ($cflags =~ /-DOPENSSL_FIPSSYMS/) | |
1174 | { | |
1175 | $ret .= "\t\$(PERL) util\\fipsas.pl . \$@ norunasm \$(CFLAG)\n"; | |
1176 | } | |
1177 | $ret .= "\n"; | |
4287ade5 AP |
1178 | $ret.="$target: \$(TMP_D)$o$bname.asm\n"; |
1179 | $ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm\n\n"; | |
1180 | return($ret); | |
1181 | } | |
1182 | ||
1183 | sub Sasm_compile_target | |
1184 | { | |
1185 | my($target,$source,$bname)=@_; | |
1186 | my($ret); | |
1187 | ||
1188 | $bname =~ s/(.*)\.[^\.]$/$1/; | |
1189 | $ret ="\$(TMP_D)$o$bname.asm: $source\n"; | |
1190 | $ret.="\t\$(CC) -E \$(CFLAG) $source >\$\@\n\n"; | |
1191 | $ret.="$target: \$(TMP_D)$o$bname.asm\n"; | |
1192 | $ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm\n\n"; | |
1193 | return($ret); | |
1194 | } | |
1195 | ||
d02b48c6 RE |
1196 | sub cc_compile_target |
1197 | { | |
1198 | local($target,$source,$ex_flags)=@_; | |
1199 | local($ret); | |
1200 | ||
2e0fc875 | 1201 | $ex_flags.=" -DMK1MF_BUILD -D$platform_cpp_symbol" if ($source =~ /cversion/); |
d02b48c6 RE |
1202 | $target =~ s/\//$o/g if $o ne "/"; |
1203 | $source =~ s/\//$o/g if $o ne "/"; | |
1204 | $ret ="$target: \$(SRC_D)$o$source\n\t"; | |
1205 | $ret.="\$(CC) ${ofile}$target $ex_flags -c \$(SRC_D)$o$source\n\n"; | |
1206 | return($ret); | |
1207 | } | |
1208 | ||
1209 | ############################################################## | |
1210 | sub do_asm_rule | |
1211 | { | |
1212 | local($target,$src)=@_; | |
1213 | local($ret,@s,@t,$i); | |
1214 | ||
1215 | $target =~ s/\//$o/g if $o ne "/"; | |
1216 | $src =~ s/\//$o/g if $o ne "/"; | |
1217 | ||
d02b48c6 | 1218 | @t=split(/\s+/,$target); |
73980531 DSH |
1219 | @s=split(/\s+/,$src); |
1220 | ||
d02b48c6 RE |
1221 | |
1222 | for ($i=0; $i<=$#s; $i++) | |
1223 | { | |
73980531 DSH |
1224 | my $objfile = $t[$i]; |
1225 | my $srcfile = $s[$i]; | |
1226 | ||
1227 | if ($perl_asm == 1) | |
1228 | { | |
1229 | my $plasm = $objfile; | |
1230 | $plasm =~ s/${obj}/.pl/; | |
1231 | $ret.="$srcfile: $plasm\n"; | |
1232 | $ret.="\t\$(PERL) $plasm $asmtype \$(CFLAG) >$srcfile\n\n"; | |
1233 | } | |
1234 | ||
1235 | $ret.="$objfile: $srcfile\n"; | |
1236 | $ret.="\t\$(ASM) $afile$objfile \$(SRC_D)$o$srcfile\n\n"; | |
d02b48c6 RE |
1237 | } |
1238 | return($ret); | |
1239 | } | |
1240 | ||
1241 | sub do_shlib_rule | |
1242 | { | |
1243 | local($n,$def)=@_; | |
1244 | local($ret,$nn); | |
1245 | local($t); | |
1246 | ||
1247 | ($nn=$n) =~ tr/a-z/A-Z/; | |
1248 | $ret.="$n.dll: \$(${nn}OBJ)\n"; | |
1249 | if ($vc && $w32) | |
1250 | { | |
1251 | $ret.="\t\$(MKSHLIB) $efile$n.dll $def @<<\n \$(${nn}OBJ_F)\n<<\n"; | |
1252 | } | |
1253 | $ret.="\n"; | |
1254 | return($ret); | |
1255 | } | |
1256 | ||
dfeab068 RE |
1257 | # do a rule for each file that says 'copy' to new direcory on change |
1258 | sub do_copy_rule | |
1259 | { | |
1260 | local($to,$files,$p)=@_; | |
1261 | local($ret,$_,$n,$pp); | |
1262 | ||
1263 | $files =~ s/\//$o/g if $o ne '/'; | |
1264 | foreach (split(/\s+/,$files)) | |
1265 | { | |
1266 | $n=&bname($_); | |
1267 | if ($n =~ /bss_file/) | |
1268 | { $pp=".c"; } | |
1269 | else { $pp=$p; } | |
96fc37f1 | 1270 | $ret.="$to${o}$n$pp: \$(SRC_D)$o$_$pp\n\t\$(CP) \"\$(SRC_D)$o$_$pp\" \"$to${o}$n$pp\"\n\n"; |
dfeab068 RE |
1271 | } |
1272 | return($ret); | |
1273 | } | |
31ff97b2 UM |
1274 | |
1275 | sub read_options | |
1276 | { | |
00b8abee DSH |
1277 | # Many options are handled in a similar way. In particular |
1278 | # no-xxx sets zero or more scalars to 1. | |
1279 | # Process these using a hash containing the option name and | |
1280 | # reference to the scalars to set. | |
1281 | ||
1282 | my %valid_options = ( | |
1283 | "no-rc2" => \$no_rc2, | |
1284 | "no-rc4" => \$no_rc4, | |
1285 | "no-rc5" => \$no_rc5, | |
1286 | "no-idea" => \$no_idea, | |
1287 | "no-aes" => \$no_aes, | |
f3dea9a5 | 1288 | "no-camellia" => \$no_camellia, |
96afc1cf | 1289 | "no-seed" => \$no_seed, |
00b8abee DSH |
1290 | "no-des" => \$no_des, |
1291 | "no-bf" => \$no_bf, | |
1292 | "no-cast" => \$no_cast, | |
1293 | "no-md2" => \$no_md2, | |
1294 | "no-md4" => \$no_md4, | |
1295 | "no-md5" => \$no_md5, | |
1296 | "no-sha" => \$no_sha, | |
1297 | "no-sha1" => \$no_sha1, | |
1298 | "no-ripemd" => \$no_ripemd, | |
1299 | "no-mdc2" => \$no_mdc2, | |
ec645d90 | 1300 | "no-whirlpool" => \$no_whirlpool, |
00b8abee DSH |
1301 | "no-patents" => |
1302 | [\$no_rc2, \$no_rc4, \$no_rc5, \$no_idea, \$no_rsa], | |
1303 | "no-rsa" => \$no_rsa, | |
1304 | "no-dsa" => \$no_dsa, | |
1305 | "no-dh" => \$no_dh, | |
1306 | "no-hmac" => \$no_hmac, | |
00b8abee DSH |
1307 | "no-asm" => \$no_asm, |
1308 | "nasm" => \$nasm, | |
1309 | "nw-nasm" => \$nw_nasm, | |
1310 | "nw-mwasm" => \$nw_mwasm, | |
1311 | "gaswin" => \$gaswin, | |
1312 | "no-ssl2" => \$no_ssl2, | |
1313 | "no-ssl3" => \$no_ssl3, | |
525de5d3 | 1314 | "no-tlsext" => \$no_tlsext, |
edc032b5 | 1315 | "no-srp" => \$no_srp, |
88db4e6b | 1316 | "no-cms" => \$no_cms, |
79bd20fd | 1317 | "no-jpake" => \$no_jpake, |
36246be9 | 1318 | "no-ec2m" => \$no_ec2m, |
00b8abee DSH |
1319 | "no-err" => \$no_err, |
1320 | "no-sock" => \$no_sock, | |
1321 | "no-krb5" => \$no_krb5, | |
1322 | "no-ec" => \$no_ec, | |
1323 | "no-ecdsa" => \$no_ecdsa, | |
1324 | "no-ecdh" => \$no_ecdh, | |
4ed7b78b | 1325 | "no-gost" => \$no_gost, |
00b8abee DSH |
1326 | "no-engine" => \$no_engine, |
1327 | "no-hw" => \$no_hw, | |
1328 | "just-ssl" => | |
1329 | [\$no_rc2, \$no_idea, \$no_des, \$no_bf, \$no_cast, | |
1330 | \$no_md2, \$no_sha, \$no_mdc2, \$no_dsa, \$no_dh, | |
1331 | \$no_ssl2, \$no_err, \$no_ripemd, \$no_rc5, | |
edc032b5 | 1332 | \$no_aes, \$no_camellia, \$no_seed, \$no_srp], |
00b8abee DSH |
1333 | "rsaref" => 0, |
1334 | "gcc" => \$gcc, | |
1335 | "debug" => \$debug, | |
1336 | "profile" => \$profile, | |
1337 | "shlib" => \$shlib, | |
bf2336f4 | 1338 | "dll" => \$shlib, |
00b8abee DSH |
1339 | "shared" => 0, |
1340 | "no-gmp" => 0, | |
d137b56a | 1341 | "no-rfc3779" => 0, |
64ddafc6 | 1342 | "no-montasm" => 0, |
00b8abee | 1343 | "no-shared" => 0, |
d6e460d4 | 1344 | "no-store" => 0, |
00b8abee DSH |
1345 | "no-zlib" => 0, |
1346 | "no-zlib-dynamic" => 0, | |
06b433ac DSH |
1347 | "fips" => \$fips, |
1348 | "fipscanisterbuild" => [\$fips, \$fipscanisterbuild], | |
d989e4f8 | 1349 | "fipscanisteronly" => [\$fips, \$fipscanisterbuild, \$fipscanisteronly], |
00b8abee DSH |
1350 | ); |
1351 | ||
1352 | if (exists $valid_options{$_}) | |
1353 | { | |
1354 | my $r = $valid_options{$_}; | |
1355 | if ( ref $r eq "SCALAR") | |
1356 | { $$r = 1;} | |
1357 | elsif ( ref $r eq "ARRAY") | |
1358 | { | |
1359 | my $r2; | |
1360 | foreach $r2 (@$r) | |
1361 | { | |
1362 | $$r2 = 1; | |
1363 | } | |
1364 | } | |
1365 | } | |
231b98a5 | 1366 | elsif (/^no-comp$/) { $xcflags = "-DOPENSSL_NO_COMP $xcflags"; } |
ad2695b1 | 1367 | elsif (/^enable-zlib$/) { $zlib_opt = 1 if $zlib_opt == 0 } |
6bc8e6b8 DSH |
1368 | elsif (/^enable-zlib-dynamic$/) |
1369 | { | |
ad2695b1 | 1370 | $zlib_opt = 2; |
6bc8e6b8 | 1371 | } |
fbf002bb DSH |
1372 | elsif (/^no-static-engine/) |
1373 | { | |
1374 | $no_static_engine = 1; | |
1375 | } | |
1376 | elsif (/^enable-static-engine/) | |
1377 | { | |
1378 | $no_static_engine = 0; | |
1379 | } | |
00b8abee DSH |
1380 | # There are also enable-xxx options which correspond to |
1381 | # the no-xxx. Since the scalars are enabled by default | |
1382 | # these can be ignored. | |
1383 | elsif (/^enable-/) | |
1384 | { | |
1385 | my $t = $_; | |
1386 | $t =~ s/^enable/no/; | |
1387 | if (exists $valid_options{$t}) | |
1388 | {return 1;} | |
1389 | return 0; | |
48114ec9 BM |
1390 | } |
1391 | # experimental-xxx is mostly like enable-xxx, but opensslconf.v | |
1392 | # will still set OPENSSL_NO_xxx unless we set OPENSSL_EXPERIMENTAL_xxx. | |
1393 | # (No need to fail if we don't know the algorithm -- this is for adventurous users only.) | |
1394 | elsif (/^experimental-/) | |
1395 | { | |
1396 | my $algo, $ALGO; | |
1397 | ($algo = $_) =~ s/^experimental-//; | |
1398 | ($ALGO = $algo) =~ tr/[a-z]/[A-Z]/; | |
1399 | ||
1400 | $xcflags="-DOPENSSL_EXPERIMENTAL_$ALGO $xcflags"; | |
1401 | ||
00b8abee | 1402 | } |
6bc8e6b8 DSH |
1403 | elsif (/^--with-krb5-flavor=(.*)$/) |
1404 | { | |
1405 | my $krb5_flavor = $1; | |
1406 | if ($krb5_flavor =~ /^force-[Hh]eimdal$/) | |
1407 | { | |
1408 | $xcflags="-DKRB5_HEIMDAL $xcflags"; | |
1409 | } | |
1410 | elsif ($krb5_flavor =~ /^MIT/i) | |
1411 | { | |
1412 | $xcflags="-DKRB5_MIT $xcflags"; | |
1413 | if ($krb5_flavor =~ /^MIT[._-]*1[._-]*[01]/i) | |
1414 | { | |
1415 | $xcflags="-DKRB5_MIT_OLD11 $xcflags" | |
1416 | } | |
1417 | } | |
1418 | } | |
31ff97b2 UM |
1419 | elsif (/^([^=]*)=(.*)$/){ $VARS{$1}=$2; } |
1420 | elsif (/^-[lL].*$/) { $l_flags.="$_ "; } | |
1421 | elsif ((!/^-help/) && (!/^-h/) && (!/^-\?/) && /^-.*$/) | |
1422 | { $c_flags.="$_ "; } | |
ad2cb8b4 BM |
1423 | else { return(0); } |
1424 | return(1); | |
31ff97b2 | 1425 | } |
06b433ac DSH |
1426 | |
1427 | sub fipslib_error | |
1428 | { | |
1429 | print STDERR "***FIPS module directory sanity check failed***\n"; | |
1430 | print STDERR "FIPS module build failed, or was deleted\n"; | |
1431 | print STDERR "Please rebuild FIPS module.\n"; | |
1432 | exit 1; | |
1433 | } | |
1434 | ||
1435 | sub fips_check_files | |
1436 | { | |
1437 | my $dir = shift @_; | |
1438 | my $ret = 1; | |
1439 | if (!-d $dir) | |
1440 | { | |
1441 | print STDERR "FIPS module directory $dir does not exist\n"; | |
1442 | fipslib_error(); | |
1443 | } | |
1444 | foreach (@_) | |
1445 | { | |
1446 | if (!-f "$dir${o}$_") | |
1447 | { | |
1448 | print STDERR "FIPS module file $_ does not exist!\n"; | |
1449 | $ret = 0; | |
1450 | } | |
1451 | } | |
1452 | fipslib_error() if ($ret == 0); | |
1453 | } |