]>
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"; |
31ff97b2 UM |
9 | $OPTIONS=""; |
10 | $ssl_version=""; | |
d02b48c6 | 11 | |
31ff97b2 UM |
12 | open(IN,"<Makefile.ssl") || die "unable to open Makefile.ssl!\n"; |
13 | while(<IN>) { | |
14 | $ssl_version=$1 if (/^VERSION=(.*)$/); | |
f76a8084 | 15 | $OPTIONS=$1 if (/^OPTIONS=(.*)$/); |
31ff97b2 UM |
16 | $INSTALLTOP=$1 if (/^INSTALLTOP=(.*$)/); |
17 | } | |
ce457a54 | 18 | close(IN); |
31ff97b2 UM |
19 | |
20 | die "Makefile.ssl is not the toplevel Makefile!\n" if $ssl_version eq ""; | |
58964a49 | 21 | |
d02b48c6 RE |
22 | $infile="MINFO"; |
23 | ||
24 | %ops=( | |
06c68491 DSH |
25 | "VC-WIN32", "Microsoft Visual C++ [4-6] - Windows NT or 9X", |
26 | "VC-NT", "Microsoft Visual C++ [4-6] - Windows NT ONLY", | |
d02b48c6 RE |
27 | "VC-W31-16", "Microsoft Visual C++ 1.52 - Windows 3.1 - 286", |
28 | "VC-WIN16", "Alias for VC-W31-32", | |
29 | "VC-W31-32", "Microsoft Visual C++ 1.52 - Windows 3.1 - 386+", | |
30 | "VC-MSDOS","Microsoft Visual C++ 1.52 - MSDOS", | |
31a674d8 | 31 | "Mingw32", "GNU C++ - Windows NT or 9x", |
12d7d32f | 32 | "Mingw32-files", "Create files with DOS copy ...", |
31a674d8 | 33 | "BC-NT", "Borland C++ 4.5 - Windows NT", |
d02b48c6 RE |
34 | "BC-W31", "Borland C++ 4.5 - Windows 3.1 - PROBABLY NOT WORKING", |
35 | "BC-MSDOS","Borland C++ 4.5 - MSDOS", | |
58964a49 | 36 | "linux-elf","Linux elf", |
dfeab068 | 37 | "ultrix-mips","DEC mips ultrix", |
d02b48c6 RE |
38 | "FreeBSD","FreeBSD distribution", |
39 | "default","cc under unix", | |
40 | ); | |
41 | ||
dfeab068 | 42 | $platform=""; |
d02b48c6 RE |
43 | foreach (@ARGV) |
44 | { | |
31ff97b2 | 45 | if (!&read_options && !defined($ops{$_})) |
d02b48c6 | 46 | { |
31ff97b2 | 47 | print STDERR "unknown option - $_\n"; |
748365ee | 48 | print STDERR "usage: perl mk1mf.pl [options] [system]\n"; |
31ff97b2 UM |
49 | print STDERR "\nwhere [system] can be one of the following\n"; |
50 | foreach $i (sort keys %ops) | |
51 | { printf STDERR "\t%-10s\t%s\n",$i,$ops{$i}; } | |
52 | print STDERR <<"EOF"; | |
d02b48c6 | 53 | and [options] can be one of |
8cf65228 | 54 | no-md2 no-md5 no-sha no-mdc2 no-ripemd - Skip this digest |
58964a49 RE |
55 | no-rc2 no-rc4 no-idea no-des no-bf no-cast - Skip this symetric cipher |
56 | no-rc5 | |
d02b48c6 RE |
57 | no-rsa no-dsa no-dh - Skip this public key cipher |
58 | no-ssl2 no-ssl3 - Skip this version of SSL | |
59 | just-ssl - remove all non-ssl keys/digest | |
60 | no-asm - No x86 asm | |
bbdb5438 | 61 | nasm - Use NASM for x86 asm |
2da0c119 | 62 | gaswin - Use GNU as with Mingw32 |
d02b48c6 RE |
63 | no-socks - No socket code |
64 | no-err - No error strings | |
65 | dll/shlib - Build shared libraries (MS) | |
66 | debug - Debug build | |
67 | gcc - Use Gcc (unix) | |
68 | rsaref - Build to require RSAref | |
69 | ||
70 | Values that can be set | |
58964a49 | 71 | TMP=tmpdir OUT=outdir SRC=srcdir BIN=binpath INC=header-outdir CC=C-compiler |
d02b48c6 RE |
72 | |
73 | -L<ex_lib_path> -l<ex_lib> - extra library flags (unix) | |
74 | -<ex_cc_flags> - extra 'cc' flags, | |
75 | added (MS), or replace (unix) | |
76 | EOF | |
31ff97b2 | 77 | exit(1); |
d02b48c6 | 78 | } |
31ff97b2 UM |
79 | $platform=$_; |
80 | } | |
81 | foreach (split / /, $OPTIONS) | |
82 | { | |
83 | print STDERR "unknown option - $_\n" if !&read_options; | |
d02b48c6 RE |
84 | } |
85 | ||
86 | $no_mdc2=1 if ($no_des); | |
87 | ||
8cf65228 | 88 | $no_ssl3=1 if ($no_md5 || $no_sha); |
d02b48c6 RE |
89 | $no_ssl3=1 if ($no_rsa && $no_dh); |
90 | ||
91 | $no_ssl2=1 if ($no_md5 || $no_rsa); | |
92 | $no_ssl2=1 if ($no_rsa); | |
93 | ||
58964a49 RE |
94 | $out_def="out"; |
95 | $inc_def="outinc"; | |
96 | $tmp_def="tmp"; | |
97 | ||
12d7d32f | 98 | $mkdir="mkdir"; |
d02b48c6 RE |
99 | |
100 | ($ssl,$crypto)=("ssl","crypto"); | |
101 | $RSAglue="RSAglue"; | |
102 | $ranlib="echo ranlib"; | |
103 | ||
58964a49 RE |
104 | $cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc'; |
105 | $src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}:'.'; | |
106 | $bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:''; | |
107 | ||
108 | # $bin_dir.=$o causes a core dump on my sparc :-( | |
109 | ||
06c68491 DSH |
110 | $NT=0; |
111 | ||
d02b48c6 | 112 | push(@INC,"util/pl","pl"); |
dfeab068 | 113 | if ($platform eq "VC-MSDOS") |
d02b48c6 RE |
114 | { |
115 | $asmbits=16; | |
116 | $msdos=1; | |
117 | require 'VC-16.pl'; | |
118 | } | |
dfeab068 | 119 | elsif ($platform eq "VC-W31-16") |
d02b48c6 RE |
120 | { |
121 | $asmbits=16; | |
122 | $msdos=1; $win16=1; | |
123 | require 'VC-16.pl'; | |
124 | } | |
dfeab068 | 125 | elsif (($platform eq "VC-W31-32") || ($platform eq "VC-WIN16")) |
d02b48c6 RE |
126 | { |
127 | $asmbits=32; | |
128 | $msdos=1; $win16=1; | |
129 | require 'VC-16.pl'; | |
130 | } | |
dfeab068 | 131 | elsif (($platform eq "VC-WIN32") || ($platform eq "VC-NT")) |
d02b48c6 | 132 | { |
06c68491 | 133 | $NT = 1 if $platform eq "VC-NT"; |
d02b48c6 RE |
134 | require 'VC-32.pl'; |
135 | } | |
31a674d8 UM |
136 | elsif ($platform eq "Mingw32") |
137 | { | |
138 | require 'Mingw32.pl'; | |
139 | } | |
12d7d32f UM |
140 | elsif ($platform eq "Mingw32-files") |
141 | { | |
142 | require 'Mingw32f.pl'; | |
143 | } | |
dfeab068 | 144 | elsif ($platform eq "BC-NT") |
d02b48c6 RE |
145 | { |
146 | $bc=1; | |
147 | require 'BC-32.pl'; | |
148 | } | |
dfeab068 | 149 | elsif ($platform eq "BC-W31") |
d02b48c6 RE |
150 | { |
151 | $bc=1; | |
152 | $msdos=1; $w16=1; | |
153 | require 'BC-16.pl'; | |
154 | } | |
dfeab068 | 155 | elsif ($platform eq "BC-Q16") |
d02b48c6 RE |
156 | { |
157 | $msdos=1; $w16=1; $shlib=0; $qw=1; | |
158 | require 'BC-16.pl'; | |
159 | } | |
dfeab068 | 160 | elsif ($platform eq "BC-MSDOS") |
d02b48c6 RE |
161 | { |
162 | $asmbits=16; | |
163 | $msdos=1; | |
164 | require 'BC-16.pl'; | |
165 | } | |
dfeab068 | 166 | elsif ($platform eq "FreeBSD") |
d02b48c6 RE |
167 | { |
168 | require 'unix.pl'; | |
169 | $cflags='-DTERMIO -D_ANSI_SOURCE -O2 -fomit-frame-pointer'; | |
170 | } | |
dfeab068 | 171 | elsif ($platform eq "linux-elf") |
58964a49 RE |
172 | { |
173 | require "unix.pl"; | |
174 | require "linux.pl"; | |
175 | $unix=1; | |
176 | } | |
dfeab068 RE |
177 | elsif ($platform eq "ultrix-mips") |
178 | { | |
179 | require "unix.pl"; | |
180 | require "ultrix.pl"; | |
181 | $unix=1; | |
182 | } | |
d02b48c6 RE |
183 | else |
184 | { | |
185 | require "unix.pl"; | |
186 | ||
187 | $unix=1; | |
188 | $cflags.=' -DTERMIO'; | |
189 | } | |
190 | ||
58964a49 RE |
191 | $out_dir=(defined($VARS{'OUT'}))?$VARS{'OUT'}:$out_def.($debug?".dbg":""); |
192 | $tmp_dir=(defined($VARS{'TMP'}))?$VARS{'TMP'}:$tmp_def.($debug?".dbg":""); | |
193 | $inc_dir=(defined($VARS{'INC'}))?$VARS{'INC'}:$inc_def; | |
194 | ||
d02b48c6 RE |
195 | $bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq '')); |
196 | ||
197 | $cflags.=" -DNO_IDEA" if $no_idea; | |
198 | $cflags.=" -DNO_RC2" if $no_rc2; | |
199 | $cflags.=" -DNO_RC4" if $no_rc4; | |
58964a49 | 200 | $cflags.=" -DNO_RC5" if $no_rc5; |
d02b48c6 RE |
201 | $cflags.=" -DNO_MD2" if $no_md2; |
202 | $cflags.=" -DNO_MD5" if $no_md5; | |
203 | $cflags.=" -DNO_SHA" if $no_sha; | |
204 | $cflags.=" -DNO_SHA1" if $no_sha1; | |
b5929507 | 205 | $cflags.=" -DNO_RIPEMD" if $no_rmd160; |
d02b48c6 | 206 | $cflags.=" -DNO_MDC2" if $no_mdc2; |
b5929507 | 207 | $cflags.=" -DNO_BF" if $no_bf; |
58964a49 | 208 | $cflags.=" -DNO_CAST" if $no_cast; |
d02b48c6 RE |
209 | $cflags.=" -DNO_DES" if $no_des; |
210 | $cflags.=" -DNO_RSA" if $no_rsa; | |
211 | $cflags.=" -DNO_DSA" if $no_dsa; | |
212 | $cflags.=" -DNO_DH" if $no_dh; | |
213 | $cflags.=" -DNO_SOCK" if $no_sock; | |
214 | $cflags.=" -DNO_SSL2" if $no_ssl2; | |
215 | $cflags.=" -DNO_SSL3" if $no_ssl3; | |
216 | $cflags.=" -DNO_ERR" if $no_err; | |
217 | $cflags.=" -DRSAref" if $rsaref ne ""; | |
218 | ||
219 | if ($unix) | |
220 | { $cflags="$c_flags" if ($c_flags ne ""); } | |
221 | else { $cflags="$c_flags$cflags" if ($c_flags ne ""); } | |
222 | ||
223 | $ex_libs="$l_flags$ex_libs" if ($l_flags ne ""); | |
224 | ||
d02b48c6 RE |
225 | if ($msdos) |
226 | { | |
dfeab068 | 227 | $banner ="\t\@echo Make sure you have run 'perl Configure $platform' in the\n"; |
d02b48c6 RE |
228 | $banner.="\t\@echo top level directory, if you don't have perl, you will\n"; |
229 | $banner.="\t\@echo need to probably edit crypto/bn/bn.h, check the\n"; | |
230 | $banner.="\t\@echo documentation for details.\n"; | |
231 | } | |
232 | ||
233 | # have to do this to allow $(CC) under unix | |
234 | $link="$bin_dir$link" if ($link !~ /^\$/); | |
235 | ||
236 | $INSTALLTOP =~ s|/|$o|g; | |
237 | ||
238 | $defs= <<"EOF"; | |
e527ba09 DSH |
239 | # This makefile has been automatically generated from the OpenSSL distribution. |
240 | # This single makefile will build the complete OpenSSL distribution and | |
d02b48c6 RE |
241 | # by default leave the 'intertesting' output files in .${o}out and the stuff |
242 | # that needs deleting in .${o}tmp. | |
243 | # The file was generated by running 'make makefile.one', which | |
244 | # does a 'make files', which writes all the environment variables from all | |
245 | # the makefiles to the file call MINFO. This file is used by | |
246 | # util${o}mk1mf.pl to generate makefile.one. | |
247 | # The 'makefile per directory' system suites me when developing this | |
248 | # library and also so I can 'distribute' indervidual library sections. | |
249 | # The one monster makefile better suits building in non-unix | |
250 | # environments. | |
251 | ||
252 | INSTALLTOP=$INSTALLTOP | |
253 | ||
254 | # Set your compiler options | |
dfeab068 | 255 | PLATFORM=$platform |
d02b48c6 RE |
256 | CC=$bin_dir${cc} |
257 | CFLAG=$cflags | |
258 | APP_CFLAG=$app_cflag | |
259 | LIB_CFLAG=$lib_cflag | |
58964a49 | 260 | SHLIB_CFLAG=$shl_cflag |
d02b48c6 RE |
261 | APP_EX_OBJ=$app_ex_obj |
262 | SHLIB_EX_OBJ=$shlib_ex_obj | |
263 | # add extra libraries to this define, for solaris -lsocket -lnsl would | |
264 | # be added | |
265 | EX_LIBS=$ex_libs | |
266 | ||
e527ba09 | 267 | # The OpenSSL directory |
d02b48c6 RE |
268 | SRC_D=$src_dir |
269 | ||
270 | LINK=$link | |
271 | LFLAGS=$lflags | |
272 | ||
dfeab068 RE |
273 | BN_ASM_OBJ=$bn_asm_obj |
274 | BN_ASM_SRC=$bn_asm_src | |
d02b48c6 RE |
275 | DES_ENC_OBJ=$des_enc_obj |
276 | DES_ENC_SRC=$des_enc_src | |
d02b48c6 RE |
277 | BF_ENC_OBJ=$bf_enc_obj |
278 | BF_ENC_SRC=$bf_enc_src | |
58964a49 RE |
279 | CAST_ENC_OBJ=$cast_enc_obj |
280 | CAST_ENC_SRC=$cast_enc_src | |
281 | RC4_ENC_OBJ=$rc4_enc_obj | |
282 | RC4_ENC_SRC=$rc4_enc_src | |
283 | RC5_ENC_OBJ=$rc5_enc_obj | |
284 | RC5_ENC_SRC=$rc5_enc_src | |
285 | MD5_ASM_OBJ=$md5_asm_obj | |
286 | MD5_ASM_SRC=$md5_asm_src | |
287 | SHA1_ASM_OBJ=$sha1_asm_obj | |
288 | SHA1_ASM_SRC=$sha1_asm_src | |
289 | RMD160_ASM_OBJ=$rmd160_asm_obj | |
290 | RMD160_ASM_SRC=$rmd160_asm_src | |
d02b48c6 RE |
291 | |
292 | # The output directory for everything intersting | |
293 | OUT_D=$out_dir | |
294 | # The output directory for all the temporary muck | |
295 | TMP_D=$tmp_dir | |
58964a49 RE |
296 | # The output directory for the header files |
297 | INC_D=$inc_dir | |
ec577822 | 298 | INCO_D=$inc_dir${o}openssl |
d02b48c6 RE |
299 | |
300 | CP=$cp | |
301 | RM=$rm | |
302 | RANLIB=$ranlib | |
12d7d32f | 303 | MKDIR=$mkdir |
d02b48c6 RE |
304 | MKLIB=$bin_dir$mklib |
305 | MLFLAGS=$mlflags | |
306 | ASM=$bin_dir$asm | |
307 | ||
308 | ###################################################### | |
309 | # You should not need to touch anything below this point | |
310 | ###################################################### | |
311 | ||
e527ba09 | 312 | E_EXE=openssl |
d02b48c6 RE |
313 | SSL=$ssl |
314 | CRYPTO=$crypto | |
315 | RSAGLUE=$RSAglue | |
316 | ||
317 | # BIN_D - Binary output directory | |
318 | # TEST_D - Binary test file output directory | |
319 | # LIB_D - library output directory | |
e2e044fa DSH |
320 | # Note: if you change these point to different directories then uncomment out |
321 | # the lines around the 'NB' comment below. | |
322 | # | |
d02b48c6 RE |
323 | BIN_D=\$(OUT_D) |
324 | TEST_D=\$(OUT_D) | |
325 | LIB_D=\$(OUT_D) | |
d02b48c6 RE |
326 | |
327 | # INCL_D - local library directory | |
328 | # OBJ_D - temp object file directory | |
329 | OBJ_D=\$(TMP_D) | |
330 | INCL_D=\$(TMP_D) | |
331 | ||
332 | O_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp | |
333 | O_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp | |
334 | O_RSAGLUE= \$(LIB_D)$o$plib\$(RSAGLUE)$libp | |
58964a49 RE |
335 | SO_SSL= $plib\$(SSL)$so_shlibp |
336 | SO_CRYPTO= $plib\$(CRYPTO)$so_shlibp | |
31a674d8 UM |
337 | L_SSL= \$(LIB_D)$o$plib\$(SSL)$libp |
338 | L_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$libp | |
d02b48c6 RE |
339 | |
340 | L_LIBS= \$(L_SSL) \$(L_CRYPTO) | |
341 | #L_LIBS= \$(O_SSL) \$(O_RSAGLUE) -lrsaref \$(O_CRYPTO) | |
342 | ||
343 | ###################################################### | |
344 | # Don't touch anything below this point | |
345 | ###################################################### | |
346 | ||
58964a49 | 347 | INC=-I\$(INC_D) -I\$(INCL_D) |
d02b48c6 RE |
348 | APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG) |
349 | LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) | |
58964a49 | 350 | SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG) |
d02b48c6 RE |
351 | LIBS_DEP=\$(O_CRYPTO) \$(O_RSAGLUE) \$(O_SSL) |
352 | ||
353 | ############################################# | |
354 | EOF | |
355 | ||
356 | $rules=<<"EOF"; | |
ec577822 | 357 | all: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INCO_D) headers lib exe |
d02b48c6 RE |
358 | |
359 | banner: | |
360 | $banner | |
361 | ||
d02b48c6 RE |
362 | \$(TMP_D): |
363 | \$(MKDIR) \$(TMP_D) | |
e2e044fa DSH |
364 | # NB: uncomment out these lines if BIN_D, TEST_D and LIB_D are different |
365 | #\$(BIN_D): | |
366 | # \$(MKDIR) \$(BIN_D) | |
367 | # | |
368 | #\$(TEST_D): | |
369 | # \$(MKDIR) \$(TEST_D) | |
58964a49 RE |
370 | |
371 | \$(LIB_D): | |
372 | \$(MKDIR) \$(LIB_D) | |
373 | ||
ec577822 | 374 | \$(INCO_D): \$(INC_D) |
31a674d8 | 375 | \$(MKDIR) \$(INCO_D) |
ec577822 | 376 | |
58964a49 RE |
377 | \$(INC_D): |
378 | \$(MKDIR) \$(INC_D) | |
379 | ||
d02b48c6 RE |
380 | headers: \$(HEADER) \$(EXHEADER) |
381 | ||
382 | lib: \$(LIBS_DEP) | |
383 | ||
384 | exe: \$(T_EXE) \$(BIN_D)$o\$(E_EXE)$exep | |
385 | ||
386 | install: | |
387 | \$(MKDIR) \$(INSTALLTOP) | |
388 | \$(MKDIR) \$(INSTALLTOP)${o}bin | |
389 | \$(MKDIR) \$(INSTALLTOP)${o}include | |
ec577822 | 390 | \$(MKDIR) \$(INSTALLTOP)${o}include${o}openssl |
d02b48c6 | 391 | \$(MKDIR) \$(INSTALLTOP)${o}lib |
ec577822 | 392 | \$(CP) \$(INCO_D)${o}*.\[ch\] \$(INSTALLTOP)${o}include${o}openssl |
d02b48c6 | 393 | \$(CP) \$(BIN_D)$o\$(E_EXE)$exep \$(INSTALLTOP)${o}bin |
58964a49 RE |
394 | \$(CP) \$(O_SSL) \$(INSTALLTOP)${o}lib |
395 | \$(CP) \$(O_CRYPTO) \$(INSTALLTOP)${o}lib | |
d02b48c6 RE |
396 | |
397 | clean: | |
398 | \$(RM) \$(TMP_D)$o*.* | |
399 | ||
400 | vclean: | |
401 | \$(RM) \$(TMP_D)$o*.* | |
402 | \$(RM) \$(OUT_D)$o*.* | |
403 | ||
404 | EOF | |
2e0fc875 BM |
405 | |
406 | my $platform_cpp_symbol = "MK1MF_PLATFORM_$platform"; | |
e9185df4 | 407 | $platform_cpp_symbol =~ s/-/_/g; |
57119943 | 408 | if (open(IN,"crypto/buildinf.h")) |
2e0fc875 | 409 | { |
57119943 | 410 | # Remove entry for this platform in existing file buildinf.h. |
2e0fc875 | 411 | |
57119943 | 412 | my $old_buildinf_h = ""; |
2e0fc875 BM |
413 | while (<IN>) |
414 | { | |
415 | if (/^\#ifdef $platform_cpp_symbol$/) | |
416 | { | |
417 | while (<IN>) { last if (/^\#endif/); } | |
418 | } | |
419 | else | |
420 | { | |
57119943 | 421 | $old_buildinf_h .= $_; |
2e0fc875 BM |
422 | } |
423 | } | |
7fbd8db1 | 424 | close(IN); |
2e0fc875 | 425 | |
57119943 BM |
426 | open(OUT,">crypto/buildinf.h") || die "Can't open buildinf.h"; |
427 | print OUT $old_buildinf_h; | |
7fbd8db1 | 428 | close(OUT); |
2e0fc875 BM |
429 | } |
430 | ||
57119943 | 431 | open (OUT,">>crypto/buildinf.h") || die "Can't open buildinf.h"; |
2e0fc875 BM |
432 | printf OUT <<EOF; |
433 | #ifdef $platform_cpp_symbol | |
57119943 | 434 | /* auto-generated/updated by util/mk1mf.pl for crypto/cversion.c */ |
2e0fc875 BM |
435 | #define CFLAGS "$cc $cflags" |
436 | #define PLATFORM "$platform" | |
437 | EOF | |
438 | printf OUT " #define DATE \"%s\"\n", scalar gmtime(); | |
439 | printf OUT "#endif\n"; | |
440 | close(OUT); | |
d02b48c6 RE |
441 | |
442 | ############################################# | |
443 | # We parse in input file and 'store' info for later printing. | |
444 | open(IN,"<$infile") || die "unable to open $infile:$!\n"; | |
445 | $_=<IN>; | |
446 | for (;;) | |
447 | { | |
448 | chop; | |
449 | ||
450 | ($key,$val)=/^([^=]+)=(.*)/; | |
451 | if ($key eq "RELATIVE_DIRECTORY") | |
452 | { | |
453 | if ($lib ne "") | |
454 | { | |
455 | $uc=$lib; | |
456 | $uc =~ s/^lib(.*)\.a/$1/; | |
457 | $uc =~ tr/a-z/A-Z/; | |
458 | $lib_nam{$uc}=$uc; | |
459 | $lib_obj{$uc}.=$libobj." "; | |
460 | } | |
461 | last if ($val eq "FINISHED"); | |
462 | $lib=""; | |
463 | $libobj=""; | |
464 | $dir=$val; | |
465 | } | |
466 | ||
467 | if ($key eq "TEST") | |
468 | { $test.=&var_add($dir,$val); } | |
469 | ||
470 | if (($key eq "PROGS") || ($key eq "E_OBJ")) | |
471 | { $e_exe.=&var_add($dir,$val); } | |
472 | ||
473 | if ($key eq "LIB") | |
474 | { | |
475 | $lib=$val; | |
476 | $lib =~ s/^.*\/([^\/]+)$/$1/; | |
477 | } | |
478 | ||
479 | if ($key eq "EXHEADER") | |
480 | { $exheader.=&var_add($dir,$val); } | |
481 | ||
482 | if ($key eq "HEADER") | |
483 | { $header.=&var_add($dir,$val); } | |
484 | ||
485 | if ($key eq "LIBOBJ") | |
486 | { $libobj=&var_add($dir,$val); } | |
487 | ||
488 | if (!($_=<IN>)) | |
489 | { $_="RELATIVE_DIRECTORY=FINISHED\n"; } | |
490 | } | |
491 | close(IN); | |
492 | ||
493 | # Strip of trailing ' ' | |
494 | foreach (keys %lib_obj) { $lib_obj{$_}=&clean_up_ws($lib_obj{$_}); } | |
495 | $test=&clean_up_ws($test); | |
496 | $e_exe=&clean_up_ws($e_exe); | |
497 | $exheader=&clean_up_ws($exheader); | |
498 | $header=&clean_up_ws($header); | |
499 | ||
500 | # First we strip the exheaders from the headers list | |
501 | foreach (split(/\s+/,$exheader)){ $h{$_}=1; } | |
502 | foreach (split(/\s+/,$header)) { $h.=$_." " unless $h{$_}; } | |
503 | chop($h); $header=$h; | |
504 | ||
505 | $defs.=&do_defs("HEADER",$header,"\$(INCL_D)",".h"); | |
506 | $rules.=&do_copy_rule("\$(INCL_D)",$header,".h"); | |
507 | ||
ec577822 BM |
508 | $defs.=&do_defs("EXHEADER",$exheader,"\$(INCO_D)",".h"); |
509 | $rules.=&do_copy_rule("\$(INCO_D)",$exheader,".h"); | |
d02b48c6 RE |
510 | |
511 | $defs.=&do_defs("T_OBJ",$test,"\$(OBJ_D)",$obj); | |
512 | $rules.=&do_compile_rule("\$(OBJ_D)",$test,"\$(APP_CFLAGS)"); | |
513 | ||
514 | $defs.=&do_defs("E_OBJ",$e_exe,"\$(OBJ_D)",$obj); | |
515 | $rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)'); | |
516 | ||
517 | foreach (values %lib_nam) | |
518 | { | |
519 | $lib_obj=$lib_obj{$_}; | |
58964a49 RE |
520 | local($slib)=$shlib; |
521 | ||
522 | $slib=0 if ($_ eq "RSAGLUE"); | |
d02b48c6 RE |
523 | |
524 | if (($_ eq "SSL") && $no_ssl2 && $no_ssl3) | |
525 | { | |
526 | $rules.="\$(O_SSL):\n\n"; | |
527 | next; | |
528 | } | |
529 | ||
530 | if (($_ eq "RSAGLUE") && $no_rsa) | |
531 | { | |
532 | $rules.="\$(O_RSAGLUE):\n\n"; | |
533 | next; | |
534 | } | |
535 | ||
dfeab068 | 536 | if (($bn_asm_obj ne "") && ($_ eq "CRYPTO")) |
d02b48c6 | 537 | { |
dfeab068 RE |
538 | $lib_obj =~ s/\s\S*\/bn_asm\S*/ \$(BN_ASM_OBJ)/; |
539 | $rules.=&do_asm_rule($bn_asm_obj,$bn_asm_src); | |
d02b48c6 RE |
540 | } |
541 | if (($des_enc_obj ne "") && ($_ eq "CRYPTO")) | |
542 | { | |
58964a49 RE |
543 | $lib_obj =~ s/\s\S*des_enc\S*/ \$(DES_ENC_OBJ)/; |
544 | $lib_obj =~ s/\s\S*\/fcrypt_b\S*\s*/ /; | |
d02b48c6 RE |
545 | $rules.=&do_asm_rule($des_enc_obj,$des_enc_src); |
546 | } | |
547 | if (($bf_enc_obj ne "") && ($_ eq "CRYPTO")) | |
548 | { | |
58964a49 | 549 | $lib_obj =~ s/\s\S*\/bf_enc\S*/ \$(BF_ENC_OBJ)/; |
d02b48c6 RE |
550 | $rules.=&do_asm_rule($bf_enc_obj,$bf_enc_src); |
551 | } | |
58964a49 RE |
552 | if (($cast_enc_obj ne "") && ($_ eq "CRYPTO")) |
553 | { | |
554 | $lib_obj =~ s/(\s\S*\/c_enc\S*)/ \$(CAST_ENC_OBJ)/; | |
555 | $rules.=&do_asm_rule($cast_enc_obj,$cast_enc_src); | |
556 | } | |
557 | if (($rc4_enc_obj ne "") && ($_ eq "CRYPTO")) | |
558 | { | |
559 | $lib_obj =~ s/\s\S*\/rc4_enc\S*/ \$(RC4_ENC_OBJ)/; | |
560 | $rules.=&do_asm_rule($rc4_enc_obj,$rc4_enc_src); | |
561 | } | |
562 | if (($rc5_enc_obj ne "") && ($_ eq "CRYPTO")) | |
563 | { | |
564 | $lib_obj =~ s/\s\S*\/rc5_enc\S*/ \$(RC5_ENC_OBJ)/; | |
565 | $rules.=&do_asm_rule($rc5_enc_obj,$rc5_enc_src); | |
566 | } | |
567 | if (($md5_asm_obj ne "") && ($_ eq "CRYPTO")) | |
568 | { | |
569 | $lib_obj =~ s/\s(\S*\/md5_dgst\S*)/ $1 \$(MD5_ASM_OBJ)/; | |
570 | $rules.=&do_asm_rule($md5_asm_obj,$md5_asm_src); | |
571 | } | |
572 | if (($sha1_asm_obj ne "") && ($_ eq "CRYPTO")) | |
573 | { | |
574 | $lib_obj =~ s/\s(\S*\/sha1dgst\S*)/ $1 \$(SHA1_ASM_OBJ)/; | |
575 | $rules.=&do_asm_rule($sha1_asm_obj,$sha1_asm_src); | |
576 | } | |
577 | if (($rmd160_asm_obj ne "") && ($_ eq "CRYPTO")) | |
578 | { | |
579 | $lib_obj =~ s/\s(\S*\/rmd_dgst\S*)/ $1 \$(RMD160_ASM_OBJ)/; | |
580 | $rules.=&do_asm_rule($rmd160_asm_obj,$rmd160_asm_src); | |
581 | } | |
d02b48c6 | 582 | $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj); |
58964a49 RE |
583 | $lib=($slib)?" \$(SHLIB_CFLAGS)":" \$(LIB_CFLAGS)"; |
584 | $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib); | |
d02b48c6 RE |
585 | } |
586 | ||
587 | $defs.=&do_defs("T_EXE",$test,"\$(TEST_D)",$exep); | |
588 | foreach (split(/\s+/,$test)) | |
589 | { | |
590 | $t=&bname($_); | |
591 | $tt="\$(OBJ_D)${o}$t${obj}"; | |
592 | $rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)"); | |
593 | } | |
594 | ||
58964a49 RE |
595 | $rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)"); |
596 | $rules.= &do_lib_rule("\$(RSAGLUEOBJ)","\$(O_RSAGLUE)",$RSAglue,0,"") | |
d02b48c6 | 597 | unless $no_rsa; |
58964a49 | 598 | $rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)"); |
d02b48c6 RE |
599 | |
600 | $rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)"); | |
601 | ||
602 | print $defs; | |
603 | print "###################################################################\n"; | |
604 | print $rules; | |
605 | ||
606 | ############################################### | |
607 | # strip off any trailing .[och] and append the relative directory | |
608 | # also remembering to do nothing if we are in one of the dropped | |
609 | # directories | |
610 | sub var_add | |
611 | { | |
612 | local($dir,$val)=@_; | |
613 | local(@a,$_,$ret); | |
614 | ||
615 | return("") if $no_idea && $dir =~ /\/idea/; | |
616 | return("") if $no_rc2 && $dir =~ /\/rc2/; | |
617 | return("") if $no_rc4 && $dir =~ /\/rc4/; | |
58964a49 | 618 | return("") if $no_rc5 && $dir =~ /\/rc5/; |
d02b48c6 RE |
619 | return("") if $no_rsa && $dir =~ /\/rsa/; |
620 | return("") if $no_rsa && $dir =~ /^rsaref/; | |
621 | return("") if $no_dsa && $dir =~ /\/dsa/; | |
622 | return("") if $no_dh && $dir =~ /\/dh/; | |
623 | if ($no_des && $dir =~ /\/des/) | |
624 | { | |
625 | if ($val =~ /read_pwd/) | |
626 | { return("$dir/read_pwd "); } | |
627 | else | |
628 | { return(""); } | |
629 | } | |
630 | return("") if $no_mdc2 && $dir =~ /\/mdc2/; | |
631 | return("") if $no_sock && $dir =~ /\/proxy/; | |
632 | return("") if $no_bf && $dir =~ /\/bf/; | |
58964a49 | 633 | return("") if $no_cast && $dir =~ /\/cast/; |
d02b48c6 RE |
634 | |
635 | $val =~ s/^\s*(.*)\s*$/$1/; | |
636 | @a=split(/\s+/,$val); | |
637 | grep(s/\.[och]$//,@a); | |
638 | ||
639 | @a=grep(!/^e_.*_3d$/,@a) if $no_des; | |
640 | @a=grep(!/^e_.*_d$/,@a) if $no_des; | |
641 | @a=grep(!/^e_.*_i$/,@a) if $no_idea; | |
642 | @a=grep(!/^e_.*_r2$/,@a) if $no_rc2; | |
58964a49 | 643 | @a=grep(!/^e_.*_r5$/,@a) if $no_rc5; |
d02b48c6 | 644 | @a=grep(!/^e_.*_bf$/,@a) if $no_bf; |
58964a49 | 645 | @a=grep(!/^e_.*_c$/,@a) if $no_cast; |
d02b48c6 RE |
646 | @a=grep(!/^e_rc4$/,@a) if $no_rc4; |
647 | ||
648 | @a=grep(!/(^s2_)|(^s23_)/,@a) if $no_ssl2; | |
649 | @a=grep(!/(^s3_)|(^s23_)/,@a) if $no_ssl3; | |
650 | ||
651 | @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock; | |
652 | ||
653 | @a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2; | |
654 | @a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5; | |
dfeab068 | 655 | @a=grep(!/(rmd)|(ripemd)/,@a) if $no_rmd160; |
d02b48c6 RE |
656 | |
657 | @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa; | |
658 | @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa; | |
659 | @a=grep(!/(^pem_seal$)/,@a) if $no_rsa; | |
660 | ||
661 | @a=grep(!/(m_dss$)|(m_dss1$)/,@a) if $no_dsa; | |
662 | @a=grep(!/(^d2i_s_)|(^i2d_s_)|(_dsap$)/,@a) if $no_dsa; | |
663 | ||
664 | @a=grep(!/^n_pkey$/,@a) if $no_rsa || $no_rc4; | |
665 | ||
666 | @a=grep(!/_dhp$/,@a) if $no_dh; | |
667 | ||
668 | @a=grep(!/(^sha[^1])|(_sha$)|(m_dss$)/,@a) if $no_sha; | |
669 | @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1; | |
670 | @a=grep(!/_mdc2$/,@a) if $no_mdc2; | |
671 | ||
13e91dd3 | 672 | @a=grep(!/(^rsa$)|(^genrsa$)/,@a) if $no_rsa; |
d02b48c6 RE |
673 | @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa; |
674 | @a=grep(!/^gendsa$/,@a) if $no_sha1; | |
675 | @a=grep(!/(^dh$)|(^gendh$)/,@a) if $no_dh; | |
676 | ||
677 | @a=grep(!/(^dh)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1; | |
678 | ||
679 | grep($_="$dir/$_",@a); | |
680 | @a=grep(!/(^|\/)s_/,@a) if $no_sock; | |
681 | @a=grep(!/(^|\/)bio_sock/,@a) if $no_sock; | |
682 | $ret=join(' ',@a)." "; | |
683 | return($ret); | |
684 | } | |
685 | ||
686 | # change things so that each 'token' is only separated by one space | |
687 | sub clean_up_ws | |
688 | { | |
689 | local($w)=@_; | |
690 | ||
691 | $w =~ s/^\s*(.*)\s*$/$1/; | |
692 | $w =~ s/\s+/ /g; | |
693 | return($w); | |
694 | } | |
695 | ||
696 | sub do_defs | |
697 | { | |
698 | local($var,$files,$location,$postfix)=@_; | |
58964a49 | 699 | local($_,$ret,$pf); |
d02b48c6 RE |
700 | local(*OUT,$tmp,$t); |
701 | ||
702 | $files =~ s/\//$o/g if $o ne '/'; | |
703 | $ret="$var="; | |
704 | $n=1; | |
705 | $Vars{$var}.=""; | |
706 | foreach (split(/ /,$files)) | |
707 | { | |
58964a49 | 708 | $orig=$_; |
d02b48c6 RE |
709 | $_=&bname($_) unless /^\$/; |
710 | if ($n++ == 2) | |
711 | { | |
712 | $n=0; | |
713 | $ret.="\\\n\t"; | |
714 | } | |
58964a49 RE |
715 | if (($_ =~ /bss_file/) && ($postfix eq ".h")) |
716 | { $pf=".c"; } | |
717 | else { $pf=$postfix; } | |
dfeab068 | 718 | if ($_ =~ /BN_ASM/) { $t="$_ "; } |
58964a49 RE |
719 | elsif ($_ =~ /DES_ENC/) { $t="$_ "; } |
720 | elsif ($_ =~ /BF_ENC/) { $t="$_ "; } | |
721 | elsif ($_ =~ /CAST_ENC/){ $t="$_ "; } | |
722 | elsif ($_ =~ /RC4_ENC/) { $t="$_ "; } | |
723 | elsif ($_ =~ /RC5_ENC/) { $t="$_ "; } | |
724 | elsif ($_ =~ /MD5_ASM/) { $t="$_ "; } | |
725 | elsif ($_ =~ /SHA1_ASM/){ $t="$_ "; } | |
726 | elsif ($_ =~ /RMD160_ASM/){ $t="$_ "; } | |
727 | else { $t="$location${o}$_$pf "; } | |
d02b48c6 RE |
728 | |
729 | $Vars{$var}.="$t "; | |
730 | $ret.=$t; | |
731 | } | |
732 | chop($ret); | |
733 | $ret.="\n\n"; | |
734 | return($ret); | |
735 | } | |
736 | ||
737 | # return the name with the leading path removed | |
738 | sub bname | |
739 | { | |
740 | local($ret)=@_; | |
741 | $ret =~ s/^.*[\\\/]([^\\\/]+)$/$1/; | |
742 | return($ret); | |
743 | } | |
744 | ||
d02b48c6 RE |
745 | |
746 | ############################################################## | |
747 | # do a rule for each file that says 'compile' to new direcory | |
748 | # compile the files in '$files' into $to | |
749 | sub do_compile_rule | |
750 | { | |
751 | local($to,$files,$ex)=@_; | |
752 | local($ret,$_,$n); | |
753 | ||
754 | $files =~ s/\//$o/g if $o ne '/'; | |
755 | foreach (split(/\s+/,$files)) | |
756 | { | |
757 | $n=&bname($_); | |
758 | $ret.=&cc_compile_target("$to${o}$n$obj","${_}.c",$ex) | |
759 | } | |
760 | return($ret); | |
761 | } | |
762 | ||
763 | ############################################################## | |
764 | # do a rule for each file that says 'compile' to new direcory | |
765 | sub cc_compile_target | |
766 | { | |
767 | local($target,$source,$ex_flags)=@_; | |
768 | local($ret); | |
769 | ||
2e0fc875 | 770 | $ex_flags.=" -DMK1MF_BUILD -D$platform_cpp_symbol" if ($source =~ /cversion/); |
d02b48c6 RE |
771 | $target =~ s/\//$o/g if $o ne "/"; |
772 | $source =~ s/\//$o/g if $o ne "/"; | |
773 | $ret ="$target: \$(SRC_D)$o$source\n\t"; | |
774 | $ret.="\$(CC) ${ofile}$target $ex_flags -c \$(SRC_D)$o$source\n\n"; | |
775 | return($ret); | |
776 | } | |
777 | ||
778 | ############################################################## | |
779 | sub do_asm_rule | |
780 | { | |
781 | local($target,$src)=@_; | |
782 | local($ret,@s,@t,$i); | |
783 | ||
784 | $target =~ s/\//$o/g if $o ne "/"; | |
785 | $src =~ s/\//$o/g if $o ne "/"; | |
786 | ||
787 | @s=split(/\s+/,$src); | |
788 | @t=split(/\s+/,$target); | |
789 | ||
790 | for ($i=0; $i<=$#s; $i++) | |
791 | { | |
792 | $ret.="$t[$i]: $s[$i]\n"; | |
793 | $ret.="\t\$(ASM) $afile$t[$i] \$(SRC_D)$o$s[$i]\n\n"; | |
794 | } | |
795 | return($ret); | |
796 | } | |
797 | ||
798 | sub do_shlib_rule | |
799 | { | |
800 | local($n,$def)=@_; | |
801 | local($ret,$nn); | |
802 | local($t); | |
803 | ||
804 | ($nn=$n) =~ tr/a-z/A-Z/; | |
805 | $ret.="$n.dll: \$(${nn}OBJ)\n"; | |
806 | if ($vc && $w32) | |
807 | { | |
808 | $ret.="\t\$(MKSHLIB) $efile$n.dll $def @<<\n \$(${nn}OBJ_F)\n<<\n"; | |
809 | } | |
810 | $ret.="\n"; | |
811 | return($ret); | |
812 | } | |
813 | ||
dfeab068 RE |
814 | # do a rule for each file that says 'copy' to new direcory on change |
815 | sub do_copy_rule | |
816 | { | |
817 | local($to,$files,$p)=@_; | |
818 | local($ret,$_,$n,$pp); | |
819 | ||
820 | $files =~ s/\//$o/g if $o ne '/'; | |
821 | foreach (split(/\s+/,$files)) | |
822 | { | |
823 | $n=&bname($_); | |
824 | if ($n =~ /bss_file/) | |
825 | { $pp=".c"; } | |
826 | else { $pp=$p; } | |
827 | $ret.="$to${o}$n$pp: \$(SRC_D)$o$_$pp\n\t\$(CP) \$(SRC_D)$o$_$pp $to${o}$n$pp\n\n"; | |
828 | } | |
829 | return($ret); | |
830 | } | |
31ff97b2 UM |
831 | |
832 | sub read_options | |
833 | { | |
834 | if (/^no-rc2$/) { $no_rc2=1; } | |
835 | elsif (/^no-rc4$/) { $no_rc4=1; } | |
836 | elsif (/^no-rc5$/) { $no_rc5=1; } | |
837 | elsif (/^no-idea$/) { $no_idea=1; } | |
838 | elsif (/^no-des$/) { $no_des=1; } | |
839 | elsif (/^no-bf$/) { $no_bf=1; } | |
840 | elsif (/^no-cast$/) { $no_cast=1; } | |
841 | elsif (/^no-md2$/) { $no_md2=1; } | |
842 | elsif (/^no-md5$/) { $no_md5=1; } | |
843 | elsif (/^no-sha$/) { $no_sha=1; } | |
844 | elsif (/^no-sha1$/) { $no_sha1=1; } | |
845 | elsif (/^no-ripemd$/) { $no_ripemd=1; } | |
846 | elsif (/^no-mdc2$/) { $no_mdc2=1; } | |
847 | elsif (/^no-patents$/) { $no_rc2=$no_rc4=$no_rc5=$no_idea=$no_rsa=1; } | |
848 | elsif (/^no-rsa$/) { $no_rsa=1; } | |
849 | elsif (/^no-dsa$/) { $no_dsa=1; } | |
850 | elsif (/^no-dh$/) { $no_dh=1; } | |
851 | elsif (/^no-hmac$/) { $no_hmac=1; } | |
852 | elsif (/^no-asm$/) { $no_asm=1; } | |
bbdb5438 | 853 | elsif (/^nasm$/) { $nasm=1; } |
2da0c119 | 854 | elsif (/^gaswin$/) { $gaswin=1; } |
31ff97b2 UM |
855 | elsif (/^no-ssl2$/) { $no_ssl2=1; } |
856 | elsif (/^no-ssl3$/) { $no_ssl3=1; } | |
857 | elsif (/^no-err$/) { $no_err=1; } | |
858 | elsif (/^no-sock$/) { $no_sock=1; } | |
859 | ||
860 | elsif (/^just-ssl$/) { $no_rc2=$no_idea=$no_des=$no_bf=$no_cast=1; | |
861 | $no_md2=$no_sha=$no_mdc2=$no_dsa=$no_dh=1; | |
862 | $no_ssl2=$no_err=$no_rmd160=$no_rc5=1; } | |
863 | ||
864 | elsif (/^rsaref$/) { $rsaref=1; } | |
865 | elsif (/^gcc$/) { $gcc=1; } | |
866 | elsif (/^debug$/) { $debug=1; } | |
867 | elsif (/^shlib$/) { $shlib=1; } | |
868 | elsif (/^dll$/) { $shlib=1; } | |
869 | elsif (/^([^=]*)=(.*)$/){ $VARS{$1}=$2; } | |
870 | elsif (/^-[lL].*$/) { $l_flags.="$_ "; } | |
871 | elsif ((!/^-help/) && (!/^-h/) && (!/^-\?/) && /^-.*$/) | |
872 | { $c_flags.="$_ "; } | |
ad2cb8b4 BM |
873 | else { return(0); } |
874 | return(1); | |
31ff97b2 | 875 | } |