This commit was manufactured by cvs2svn to create branch
[openssl.git] / util / mk1mf.pl
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
8 $INSTALLTOP="/usr/local/ssl";
9 $OPENSSLDIR="/usr/local/ssl";
10 $OPTIONS="";
11 $ssl_version="";
12 $banner="\t\@echo Building OpenSSL";
13
14 my $no_static_engine = 1;
15 my $engines = "";
16 local $zlib_opt = 0;    # 0 = no zlib, 1 = static, 2 = dynamic
17 local $zlib_lib = "";
18 local $perl_asm = 0;    # 1 to autobuild asm files from perl scripts
19
20 # Options to import from top level Makefile
21
22 my %mf_import = (
23         VERSION        => \$ssl_version,
24         OPTIONS        => \$OPTIONS,
25         INSTALLTOP     => \$INSTALLTOP,
26         OPENSSLDIR     => \$OPENSSLDIR,
27         PLATFORM       => \$mf_platform,
28         CFLAG          => \$mf_cflag,
29         DEPFLAG        => \$mf_depflag,
30         CPUID_OBJ      => \$mf_cpuid_asm,
31         BN_ASM         => \$mf_bn_asm,
32         DES_ENC        => \$mf_des_asm,
33         AES_ENC        => \$mf_aes_asm,
34         BF_ENC         => \$mf_bf_asm,
35         CAST_ENC       => \$mf_cast_asm,
36         RC4_ENC        => \$mf_rc4_asm,
37         RC5_ENC        => \$mf_rc5_asm,
38         MD5_ASM_OBJ    => \$mf_md5_asm,
39         SHA1_ASM_OBJ   => \$mf_sha_asm,
40         RMD160_ASM_OBJ => \$mf_rmd_asm,
41         WP_ASM_OBJ     => \$mf_wp_asm,
42         CMLL_ENC       => \$mf_cm_asm
43 );
44
45
46 open(IN,"<Makefile") || die "unable to open Makefile!\n";
47 while(<IN>) {
48     my ($mf_opt, $mf_ref);
49     while (($mf_opt, $mf_ref) = each %mf_import) {
50         if (/^$mf_opt\s*=\s*(.*)$/) {
51            $$mf_ref = $1;
52         }
53     }
54 }
55 close(IN);
56
57 die "Makefile is not the toplevel Makefile!\n" if $ssl_version eq "";
58
59 $infile="MINFO";
60
61 %ops=(
62         "VC-WIN32",   "Microsoft Visual C++ [4-6] - Windows NT or 9X",
63         "VC-WIN64I",  "Microsoft C/C++ - Win64/IA-64",
64         "VC-WIN64A",  "Microsoft C/C++ - Win64/x64",
65         "VC-CE",   "Microsoft eMbedded Visual C++ 3.0 - Windows CE ONLY",
66         "VC-NT",   "Microsoft Visual C++ [4-6] - Windows NT ONLY",
67         "Mingw32", "GNU C++ - Windows NT or 9x",
68         "Mingw32-files", "Create files with DOS copy ...",
69         "BC-NT",   "Borland C++ 4.5 - Windows NT",
70         "linux-elf","Linux elf",
71         "ultrix-mips","DEC mips ultrix",
72         "FreeBSD","FreeBSD distribution",
73         "OS2-EMX", "EMX GCC OS/2",
74         "netware-clib", "CodeWarrior for NetWare - CLib - with WinSock Sockets",
75         "netware-clib-bsdsock", "CodeWarrior for NetWare - CLib - with BSD Sockets",
76         "netware-libc", "CodeWarrior for NetWare - LibC - with WinSock Sockets",
77         "netware-libc-bsdsock", "CodeWarrior for NetWare - LibC - with BSD Sockets",
78         "default","cc under unix",
79         "auto", "auto detect from top level Makefile"
80         );
81
82 $platform="";
83 my $xcflags="";
84 foreach (@ARGV)
85         {
86         if (!&read_options && !defined($ops{$_}))
87                 {
88                 print STDERR "unknown option - $_\n";
89                 print STDERR "usage: perl mk1mf.pl [options] [system]\n";
90                 print STDERR "\nwhere [system] can be one of the following\n";
91                 foreach $i (sort keys %ops)
92                 { printf STDERR "\t%-10s\t%s\n",$i,$ops{$i}; }
93                 print STDERR <<"EOF";
94 and [options] can be one of
95         no-md2 no-md4 no-md5 no-sha no-mdc2     - Skip this digest
96         no-ripemd
97         no-rc2 no-rc4 no-rc5 no-idea no-des     - Skip this symetric cipher
98         no-bf no-cast no-aes no-camellia no-seed
99         no-rsa no-dsa no-dh                     - Skip this public key cipher
100         no-ssl2 no-ssl3                         - Skip this version of SSL
101         just-ssl                                - remove all non-ssl keys/digest
102         no-asm                                  - No x86 asm
103         no-krb5                                 - No KRB5
104         no-ec                                   - No EC
105         no-ecdsa                                - No ECDSA
106         no-ecdh                                 - No ECDH
107         no-engine                               - No engine
108         no-hw                                   - No hw
109         nasm                                    - Use NASM for x86 asm
110         nw-nasm                                 - Use NASM x86 asm for NetWare
111         nw-mwasm                                - Use Metrowerks x86 asm for NetWare
112         gaswin                                  - Use GNU as with Mingw32
113         no-socks                                - No socket code
114         no-err                                  - No error strings
115         dll/shlib                               - Build shared libraries (MS)
116         debug                                   - Debug build
117         profile                                 - Profiling build
118         gcc                                     - Use Gcc (unix)
119
120 Values that can be set
121 TMP=tmpdir OUT=outdir SRC=srcdir BIN=binpath INC=header-outdir CC=C-compiler
122
123 -L<ex_lib_path> -l<ex_lib>                      - extra library flags (unix)
124 -<ex_cc_flags>                                  - extra 'cc' flags,
125                                                   added (MS), or replace (unix)
126 EOF
127                 exit(1);
128                 }
129         $platform=$_;
130         }
131 foreach (grep(!/^$/, split(/ /, $OPTIONS)))
132         {
133         print STDERR "unknown option - $_\n" if !&read_options;
134         }
135
136 $no_static_engine = 0 if (!$shlib);
137
138 $no_mdc2=1 if ($no_des);
139
140 $no_ssl3=1 if ($no_md5 || $no_sha);
141 $no_ssl3=1 if ($no_rsa && $no_dh);
142
143 $no_ssl2=1 if ($no_md5);
144 $no_ssl2=1 if ($no_rsa);
145
146 $out_def="out";
147 $inc_def="outinc";
148 $tmp_def="tmp";
149
150 $perl="perl" unless defined $perl;
151 $mkdir="-mkdir" unless defined $mkdir;
152
153 ($ssl,$crypto)=("ssl","crypto");
154 $ranlib="echo ranlib";
155
156 $cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc';
157 $src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}:'.';
158 $bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:'';
159
160 # $bin_dir.=$o causes a core dump on my sparc :-(
161
162
163 $NT=0;
164
165 push(@INC,"util/pl","pl");
166
167 if ($platform eq "auto") {
168         $platform = $mf_platform;
169         print STDERR "Imported platform $mf_platform\n";
170 }
171
172 if (($platform =~ /VC-(.+)/))
173         {
174         $FLAVOR=$1;
175         $NT = 1 if $1 eq "NT";
176         require 'VC-32.pl';
177         }
178 elsif ($platform eq "Mingw32")
179         {
180         require 'Mingw32.pl';
181         }
182 elsif ($platform eq "Mingw32-files")
183         {
184         require 'Mingw32f.pl';
185         }
186 elsif ($platform eq "BC-NT")
187         {
188         $bc=1;
189         require 'BC-32.pl';
190         }
191 elsif ($platform eq "FreeBSD")
192         {
193         require 'unix.pl';
194         $cflags='-DTERMIO -D_ANSI_SOURCE -O2 -fomit-frame-pointer';
195         }
196 elsif ($platform eq "linux-elf")
197         {
198         require "unix.pl";
199         require "linux.pl";
200         $unix=1;
201         }
202 elsif ($platform eq "ultrix-mips")
203         {
204         require "unix.pl";
205         require "ultrix.pl";
206         $unix=1;
207         }
208 elsif ($platform eq "OS2-EMX")
209         {
210         $wc=1;
211         require 'OS2-EMX.pl';
212         }
213 elsif (($platform eq "netware-clib") || ($platform eq "netware-libc") ||
214        ($platform eq "netware-clib-bsdsock") || ($platform eq "netware-libc-bsdsock"))
215         {
216         $LIBC=1 if $platform eq "netware-libc" || $platform eq "netware-libc-bsdsock";
217         $BSDSOCK=1 if ($platform eq "netware-libc-bsdsock") || ($platform eq "netware-clib-bsdsock");
218         require 'netware.pl';
219         }
220 else
221         {
222         require "unix.pl";
223
224         $unix=1;
225         $cflags.=' -DTERMIO';
226         }
227
228 $out_dir=(defined($VARS{'OUT'}))?$VARS{'OUT'}:$out_def.($debug?".dbg":"");
229 $tmp_dir=(defined($VARS{'TMP'}))?$VARS{'TMP'}:$tmp_def.($debug?".dbg":"");
230 $inc_dir=(defined($VARS{'INC'}))?$VARS{'INC'}:$inc_def;
231
232 $bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq ''));
233
234 $cflags= "$xcflags$cflags" if $xcflags ne "";
235
236 $cflags.=" -DOPENSSL_NO_IDEA" if $no_idea;
237 $cflags.=" -DOPENSSL_NO_AES"  if $no_aes;
238 $cflags.=" -DOPENSSL_NO_CAMELLIA"  if $no_camellia;
239 $cflags.=" -DOPENSSL_NO_SEED" if $no_seed;
240 $cflags.=" -DOPENSSL_NO_RC2"  if $no_rc2;
241 $cflags.=" -DOPENSSL_NO_RC4"  if $no_rc4;
242 $cflags.=" -DOPENSSL_NO_RC5"  if $no_rc5;
243 $cflags.=" -DOPENSSL_NO_MD2"  if $no_md2;
244 $cflags.=" -DOPENSSL_NO_MD4"  if $no_md4;
245 $cflags.=" -DOPENSSL_NO_MD5"  if $no_md5;
246 $cflags.=" -DOPENSSL_NO_SHA"  if $no_sha;
247 $cflags.=" -DOPENSSL_NO_SHA1" if $no_sha1;
248 $cflags.=" -DOPENSSL_NO_RIPEMD" if $no_ripemd;
249 $cflags.=" -DOPENSSL_NO_MDC2" if $no_mdc2;
250 $cflags.=" -DOPENSSL_NO_BF"  if $no_bf;
251 $cflags.=" -DOPENSSL_NO_CAST" if $no_cast;
252 $cflags.=" -DOPENSSL_NO_DES"  if $no_des;
253 $cflags.=" -DOPENSSL_NO_RSA"  if $no_rsa;
254 $cflags.=" -DOPENSSL_NO_DSA"  if $no_dsa;
255 $cflags.=" -DOPENSSL_NO_DH"   if $no_dh;
256 $cflags.=" -DOPENSSL_NO_WHIRLPOOL"   if $no_whirlpool;
257 $cflags.=" -DOPENSSL_NO_SOCK" if $no_sock;
258 $cflags.=" -DOPENSSL_NO_SSL2" if $no_ssl2;
259 $cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3;
260 $cflags.=" -DOPENSSL_NO_TLSEXT" if $no_tlsext;
261 $cflags.=" -DOPENSSL_NO_CMS" if $no_cms;
262 $cflags.=" -DOPENSSL_NO_ERR"  if $no_err;
263 $cflags.=" -DOPENSSL_NO_KRB5" if $no_krb5;
264 $cflags.=" -DOPENSSL_NO_EC"   if $no_ec;
265 $cflags.=" -DOPENSSL_NO_ECDSA" if $no_ecdsa;
266 $cflags.=" -DOPENSSL_NO_ECDH" if $no_ecdh;
267 $cflags.=" -DOPENSSL_NO_ENGINE"   if $no_engine;
268 $cflags.=" -DOPENSSL_NO_HW"   if $no_hw;
269 $cflags.=" -DOPENSSL_NO_JPAKE"    if $no_jpake;
270 $cflags.= " -DZLIB" if $zlib_opt;
271 $cflags.= " -DZLIB_SHARED" if $zlib_opt == 2;
272
273 if ($no_static_engine)
274         {
275         $cflags .= " -DOPENSSL_NO_STATIC_ENGINE";
276         }
277 else
278         {
279         $cflags .= " -DOPENSSL_NO_DYNAMIC_ENGINE";
280         }
281
282 #$cflags.=" -DRSAref"  if $rsaref ne "";
283
284 ## if ($unix)
285 ##      { $cflags="$c_flags" if ($c_flags ne ""); }
286 ##else
287         { $cflags="$c_flags$cflags" if ($c_flags ne ""); }
288
289 $ex_libs="$l_flags$ex_libs" if ($l_flags ne "");
290
291
292 %shlib_ex_cflags=("SSL" => " -DOPENSSL_BUILD_SHLIBSSL",
293                   "CRYPTO" => " -DOPENSSL_BUILD_SHLIBCRYPTO");
294
295 if ($msdos)
296         {
297         $banner ="\t\@echo Make sure you have run 'perl Configure $platform' in the\n";
298         $banner.="\t\@echo top level directory, if you don't have perl, you will\n";
299         $banner.="\t\@echo need to probably edit crypto/bn/bn.h, check the\n";
300         $banner.="\t\@echo documentation for details.\n";
301         }
302
303 # have to do this to allow $(CC) under unix
304 $link="$bin_dir$link" if ($link !~ /^\$/);
305
306 $INSTALLTOP =~ s|/|$o|g;
307 $OPENSSLDIR =~ s|/|$o|g;
308
309 #############################################
310 # We parse in input file and 'store' info for later printing.
311 open(IN,"<$infile") || die "unable to open $infile:$!\n";
312 $_=<IN>;
313 for (;;)
314         {
315         chop;
316
317         ($key,$val)=/^([^=]+)=(.*)/;
318         if ($key eq "RELATIVE_DIRECTORY")
319                 {
320                 if ($lib ne "")
321                         {
322                         $uc=$lib;
323                         $uc =~ s/^lib(.*)\.a/$1/;
324                         $uc =~ tr/a-z/A-Z/;
325                         $lib_nam{$uc}=$uc;
326                         $lib_obj{$uc}.=$libobj." ";
327                         }
328                 last if ($val eq "FINISHED");
329                 $lib="";
330                 $libobj="";
331                 $dir=$val;
332                 }
333
334         if ($key eq "KRB5_INCLUDES")
335                 { $cflags .= " $val";}
336
337         if ($key eq "ZLIB_INCLUDE")
338                 { $cflags .= " $val" if $val ne "";}
339
340         if ($key eq "LIBZLIB")
341                 { $zlib_lib = "$val" if $val ne "";}
342
343         if ($key eq "LIBKRB5")
344                 { $ex_libs .= " $val" if $val ne "";}
345
346         if ($key eq "TEST")
347                 { $test.=&var_add($dir,$val, 0); }
348
349         if (($key eq "PROGS") || ($key eq "E_OBJ"))
350                 { $e_exe.=&var_add($dir,$val, 0); }
351
352         if ($key eq "LIB")
353                 {
354                 $lib=$val;
355                 $lib =~ s/^.*\/([^\/]+)$/$1/;
356                 }
357
358         if ($key eq "EXHEADER")
359                 { $exheader.=&var_add($dir,$val, 1); }
360
361         if ($key eq "HEADER")
362                 { $header.=&var_add($dir,$val, 1); }
363
364         if ($key eq "LIBOBJ" && ($dir ne "engines" || !$no_static_engine))
365                 { $libobj=&var_add($dir,$val, 0); }
366         if ($key eq "LIBNAMES" && $dir eq "engines" && $no_static_engine)
367                 { $engines.=$val }
368
369         if (!($_=<IN>))
370                 { $_="RELATIVE_DIRECTORY=FINISHED\n"; }
371         }
372 close(IN);
373
374 if ($shlib)
375         {
376         $extra_install= <<"EOF";
377         \$(CP) \"\$(O_SSL)\" \"\$(INSTALLTOP)${o}bin\"
378         \$(CP) \"\$(O_CRYPTO)\" \"\$(INSTALLTOP)${o}bin\"
379         \$(CP) \"\$(L_SSL)\" \"\$(INSTALLTOP)${o}lib\"
380         \$(CP) \"\$(L_CRYPTO)\" \"\$(INSTALLTOP)${o}lib\"
381 EOF
382         if ($no_static_engine)
383                 {
384                 $extra_install .= <<"EOF"
385         \$(MKDIR) \"\$(INSTALLTOP)${o}lib${o}engines\"
386         \$(CP) \"\$(E_SHLIB)\" \"\$(INSTALLTOP)${o}lib${o}engines\"
387 EOF
388                 }
389         }
390 else
391         {
392         $extra_install= <<"EOF";
393         \$(CP) \"\$(O_SSL)\" \"\$(INSTALLTOP)${o}lib\"
394         \$(CP) \"\$(O_CRYPTO)\" \"\$(INSTALLTOP)${o}lib\"
395 EOF
396         $ex_libs .= " $zlib_lib" if $zlib_opt == 1;
397         }
398
399 $defs= <<"EOF";
400 # This makefile has been automatically generated from the OpenSSL distribution.
401 # This single makefile will build the complete OpenSSL distribution and
402 # by default leave the 'intertesting' output files in .${o}out and the stuff
403 # that needs deleting in .${o}tmp.
404 # The file was generated by running 'make makefile.one', which
405 # does a 'make files', which writes all the environment variables from all
406 # the makefiles to the file call MINFO.  This file is used by
407 # util${o}mk1mf.pl to generate makefile.one.
408 # The 'makefile per directory' system suites me when developing this
409 # library and also so I can 'distribute' indervidual library sections.
410 # The one monster makefile better suits building in non-unix
411 # environments.
412
413 EOF
414
415 $defs .= $preamble if defined $preamble;
416
417 $defs.= <<"EOF";
418 INSTALLTOP=$INSTALLTOP
419 OPENSSLDIR=$OPENSSLDIR
420
421 # Set your compiler options
422 PLATFORM=$platform
423 CC=$bin_dir${cc}
424 CFLAG=$cflags
425 APP_CFLAG=$app_cflag
426 LIB_CFLAG=$lib_cflag
427 SHLIB_CFLAG=$shl_cflag
428 APP_EX_OBJ=$app_ex_obj
429 SHLIB_EX_OBJ=$shlib_ex_obj
430 # add extra libraries to this define, for solaris -lsocket -lnsl would
431 # be added
432 EX_LIBS=$ex_libs
433
434 # The OpenSSL directory
435 SRC_D=$src_dir
436
437 LINK=$link
438 LFLAGS=$lflags
439 RSC=$rsc
440
441 # The output directory for everything intersting
442 OUT_D=$out_dir
443 # The output directory for all the temporary muck
444 TMP_D=$tmp_dir
445 # The output directory for the header files
446 INC_D=$inc_dir
447 INCO_D=$inc_dir${o}openssl
448
449 PERL=$perl
450 CP=$cp
451 RM=$rm
452 RANLIB=$ranlib
453 MKDIR=$mkdir
454 MKLIB=$bin_dir$mklib
455 MLFLAGS=$mlflags
456 ASM=$bin_dir$asm
457
458 ######################################################
459 # You should not need to touch anything below this point
460 ######################################################
461
462 E_EXE=openssl
463 SSL=$ssl
464 CRYPTO=$crypto
465
466 # BIN_D  - Binary output directory
467 # TEST_D - Binary test file output directory
468 # LIB_D  - library output directory
469 # ENG_D  - dynamic engine output directory
470 # Note: if you change these point to different directories then uncomment out
471 # the lines around the 'NB' comment below.
472
473 BIN_D=\$(OUT_D)
474 TEST_D=\$(OUT_D)
475 LIB_D=\$(OUT_D)
476 ENG_D=\$(OUT_D)
477
478 # INCL_D - local library directory
479 # OBJ_D  - temp object file directory
480 OBJ_D=\$(TMP_D)
481 INCL_D=\$(TMP_D)
482
483 O_SSL=     \$(LIB_D)$o$plib\$(SSL)$shlibp
484 O_CRYPTO=  \$(LIB_D)$o$plib\$(CRYPTO)$shlibp
485 SO_SSL=    $plib\$(SSL)$so_shlibp
486 SO_CRYPTO= $plib\$(CRYPTO)$so_shlibp
487 L_SSL=     \$(LIB_D)$o$plib\$(SSL)$libp
488 L_CRYPTO=  \$(LIB_D)$o$plib\$(CRYPTO)$libp
489
490 L_LIBS= \$(L_SSL) \$(L_CRYPTO)
491
492 ######################################################
493 # Don't touch anything below this point
494 ######################################################
495
496 INC=-I\$(INC_D) -I\$(INCL_D)
497 APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG)
498 LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG)
499 SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG)
500 LIBS_DEP=\$(O_CRYPTO) \$(O_SSL)
501
502 #############################################
503 EOF
504
505 $rules=<<"EOF";
506 all: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INCO_D) headers lib exe
507
508 banner:
509 $banner
510
511 \$(TMP_D):
512         \$(MKDIR) \"\$(TMP_D)\"
513 # NB: uncomment out these lines if BIN_D, TEST_D and LIB_D are different
514 #\$(BIN_D):
515 #       \$(MKDIR) \$(BIN_D)
516 #
517 #\$(TEST_D):
518 #       \$(MKDIR) \$(TEST_D)
519
520 \$(LIB_D):
521         \$(MKDIR) \"\$(LIB_D)\"
522
523 \$(INCO_D): \$(INC_D)
524         \$(MKDIR) \"\$(INCO_D)\"
525
526 \$(INC_D):
527         \$(MKDIR) \"\$(INC_D)\"
528
529 headers: \$(HEADER) \$(EXHEADER)
530         @
531
532 lib: \$(LIBS_DEP) \$(E_SHLIB)
533
534 exe: \$(T_EXE) \$(BIN_D)$o\$(E_EXE)$exep
535
536 install: all
537         \$(MKDIR) \"\$(INSTALLTOP)\"
538         \$(MKDIR) \"\$(INSTALLTOP)${o}bin\"
539         \$(MKDIR) \"\$(INSTALLTOP)${o}include\"
540         \$(MKDIR) \"\$(INSTALLTOP)${o}include${o}openssl\"
541         \$(MKDIR) \"\$(INSTALLTOP)${o}lib\"
542         \$(CP) \"\$(INCO_D)${o}*.\[ch\]\" \"\$(INSTALLTOP)${o}include${o}openssl\"
543         \$(CP) \"\$(BIN_D)$o\$(E_EXE)$exep \$(INSTALLTOP)${o}bin\"
544         \$(MKDIR) \"\$(OPENSSLDIR)\"
545         \$(CP) apps${o}openssl.cnf \"\$(OPENSSLDIR)\"
546 $extra_install
547
548
549 test: \$(T_EXE)
550         cd \$(BIN_D)
551         ..${o}ms${o}test
552
553 clean:
554         \$(RM) \$(TMP_D)$o*.*
555
556 vclean:
557         \$(RM) \$(TMP_D)$o*.*
558         \$(RM) \$(OUT_D)$o*.*
559
560 EOF
561     
562 my $platform_cpp_symbol = "MK1MF_PLATFORM_$platform";
563 $platform_cpp_symbol =~ s/-/_/g;
564 if (open(IN,"crypto/buildinf.h"))
565         {
566         # Remove entry for this platform in existing file buildinf.h.
567
568         my $old_buildinf_h = "";
569         while (<IN>)
570                 {
571                 if (/^\#ifdef $platform_cpp_symbol$/)
572                         {
573                         while (<IN>) { last if (/^\#endif/); }
574                         }
575                 else
576                         {
577                         $old_buildinf_h .= $_;
578                         }
579                 }
580         close(IN);
581
582         open(OUT,">crypto/buildinf.h") || die "Can't open buildinf.h";
583         print OUT $old_buildinf_h;
584         close(OUT);
585         }
586
587 open (OUT,">>crypto/buildinf.h") || die "Can't open buildinf.h";
588 printf OUT <<EOF;
589 #ifdef $platform_cpp_symbol
590   /* auto-generated/updated by util/mk1mf.pl for crypto/cversion.c */
591   #define CFLAGS "$cc $cflags"
592   #define PLATFORM "$platform"
593 EOF
594 printf OUT "  #define DATE \"%s\"\n", scalar gmtime();
595 printf OUT "#endif\n";
596 close(OUT);
597
598 # Strip of trailing ' '
599 foreach (keys %lib_obj) { $lib_obj{$_}=&clean_up_ws($lib_obj{$_}); }
600 $test=&clean_up_ws($test);
601 $e_exe=&clean_up_ws($e_exe);
602 $exheader=&clean_up_ws($exheader);
603 $header=&clean_up_ws($header);
604
605 # First we strip the exheaders from the headers list
606 foreach (split(/\s+/,$exheader)){ $h{$_}=1; }
607 foreach (split(/\s+/,$header))  { $h.=$_." " unless $h{$_}; }
608 chop($h); $header=$h;
609
610 $defs.=&do_defs("HEADER",$header,"\$(INCL_D)","");
611 $rules.=&do_copy_rule("\$(INCL_D)",$header,"");
612
613 $defs.=&do_defs("EXHEADER",$exheader,"\$(INCO_D)","");
614 $rules.=&do_copy_rule("\$(INCO_D)",$exheader,"");
615
616 $defs.=&do_defs("T_OBJ",$test,"\$(OBJ_D)",$obj);
617 $rules.=&do_compile_rule("\$(OBJ_D)",$test,"\$(APP_CFLAGS)");
618
619 $defs.=&do_defs("E_OBJ",$e_exe,"\$(OBJ_D)",$obj);
620 $rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)');
621
622 foreach (values %lib_nam)
623         {
624         $lib_obj=$lib_obj{$_};
625         local($slib)=$shlib;
626
627         if (($_ eq "SSL") && $no_ssl2 && $no_ssl3)
628                 {
629                 $rules.="\$(O_SSL):\n\n"; 
630                 next;
631                 }
632
633         $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj);
634         $lib=($slib)?" \$(SHLIB_CFLAGS)".$shlib_ex_cflags{$_}:" \$(LIB_CFLAGS)";
635         $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib);
636         }
637
638 # hack to add version info on MSVC
639 if (($platform eq "VC-WIN32") || ($platform eq "VC-NT")) {
640     $rules.= <<"EOF";
641 \$(OBJ_D)\\\$(CRYPTO).res: ms\\version32.rc
642         \$(RSC) /fo"\$(OBJ_D)\\\$(CRYPTO).res" /d CRYPTO ms\\version32.rc
643
644 \$(OBJ_D)\\\$(SSL).res: ms\\version32.rc
645         \$(RSC) /fo"\$(OBJ_D)\\\$(SSL).res" /d SSL ms\\version32.rc
646
647 EOF
648 }
649
650 $defs.=&do_defs("T_EXE",$test,"\$(TEST_D)",$exep);
651 foreach (split(/\s+/,$test))
652         {
653         $t=&bname($_);
654         $tt="\$(OBJ_D)${o}$t${obj}";
655         $rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)");
656         }
657
658 $defs.=&do_defs("E_SHLIB",$engines,"\$(ENG_D)",$shlibp);
659
660 foreach (split(/\s+/,$engines))
661         {
662         $rules.=&do_compile_rule("\$(OBJ_D)","engines${o}e_$_",$lib);
663         $rules.= &do_lib_rule("\$(OBJ_D)${o}e_${_}.obj","\$(ENG_D)$o$_$shlibp","",$shlib,"");
664         }
665
666
667
668 $rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)");
669 $rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)");
670
671 $rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)");
672
673 print $defs;
674
675 if ($platform eq "linux-elf") {
676     print <<"EOF";
677 # Generate perlasm output files
678 %.cpp:
679         (cd \$(\@D)/..; PERL=perl make -f Makefile asm/\$(\@F))
680 EOF
681 }
682 print "###################################################################\n";
683 print $rules;
684
685 ###############################################
686 # strip off any trailing .[och] and append the relative directory
687 # also remembering to do nothing if we are in one of the dropped
688 # directories
689 sub var_add
690         {
691         local($dir,$val,$keepext)=@_;
692         local(@a,$_,$ret);
693
694         return("") if $no_engine && $dir =~ /\/engine/;
695         return("") if $no_hw   && $dir =~ /\/hw/;
696         return("") if $no_idea && $dir =~ /\/idea/;
697         return("") if $no_aes  && $dir =~ /\/aes/;
698         return("") if $no_camellia  && $dir =~ /\/camellia/;
699         return("") if $no_seed && $dir =~ /\/seed/;
700         return("") if $no_rc2  && $dir =~ /\/rc2/;
701         return("") if $no_rc4  && $dir =~ /\/rc4/;
702         return("") if $no_rc5  && $dir =~ /\/rc5/;
703         return("") if $no_rsa  && $dir =~ /\/rsa/;
704         return("") if $no_rsa  && $dir =~ /^rsaref/;
705         return("") if $no_dsa  && $dir =~ /\/dsa/;
706         return("") if $no_dh   && $dir =~ /\/dh/;
707         return("") if $no_ec   && $dir =~ /\/ec/;
708         return("") if $no_cms  && $dir =~ /\/cms/;
709         return("") if $no_jpake  && $dir =~ /\/jpake/;
710         if ($no_des && $dir =~ /\/des/)
711                 {
712                 if ($val =~ /read_pwd/)
713                         { return("$dir/read_pwd "); }
714                 else
715                         { return(""); }
716                 }
717         return("") if $no_mdc2 && $dir =~ /\/mdc2/;
718         return("") if $no_sock && $dir =~ /\/proxy/;
719         return("") if $no_bf   && $dir =~ /\/bf/;
720         return("") if $no_cast && $dir =~ /\/cast/;
721         return("") if $no_whirlpool && $dir =~ /\/whrlpool/;
722
723         $val =~ s/^\s*(.*)\s*$/$1/;
724         @a=split(/\s+/,$val);
725         grep(s/\.[och]$//,@a) unless $keepext;
726
727         @a=grep(!/^e_.*_3d$/,@a) if $no_des;
728         @a=grep(!/^e_.*_d$/,@a) if $no_des;
729         @a=grep(!/^e_.*_ae$/,@a) if $no_idea;
730         @a=grep(!/^e_.*_i$/,@a) if $no_aes;
731         @a=grep(!/^e_.*_r2$/,@a) if $no_rc2;
732         @a=grep(!/^e_.*_r5$/,@a) if $no_rc5;
733         @a=grep(!/^e_.*_bf$/,@a) if $no_bf;
734         @a=grep(!/^e_.*_c$/,@a) if $no_cast;
735         @a=grep(!/^e_rc4$/,@a) if $no_rc4;
736         @a=grep(!/^e_camellia$/,@a) if $no_camellia;
737         @a=grep(!/^e_seed$/,@a) if $no_seed;
738
739         @a=grep(!/(^s2_)|(^s23_)/,@a) if $no_ssl2;
740         @a=grep(!/(^s3_)|(^s23_)/,@a) if $no_ssl3;
741
742         @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock;
743
744         @a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2;
745         @a=grep(!/(^md4)|(_md4$)/,@a) if $no_md4;
746         @a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5;
747         @a=grep(!/(rmd)|(ripemd)/,@a) if $no_ripemd;
748
749         @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa;
750         @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa;
751         @a=grep(!/(^pem_seal$)/,@a) if $no_rsa;
752
753         @a=grep(!/(m_dss$)|(m_dss1$)/,@a) if $no_dsa;
754         @a=grep(!/(^d2i_s_)|(^i2d_s_)|(_dsap$)/,@a) if $no_dsa;
755
756         @a=grep(!/^n_pkey$/,@a) if $no_rsa || $no_rc4;
757
758         @a=grep(!/_dhp$/,@a) if $no_dh;
759
760         @a=grep(!/(^sha[^1])|(_sha$)|(m_dss$)/,@a) if $no_sha;
761         @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
762         @a=grep(!/_mdc2$/,@a) if $no_mdc2;
763
764         @a=grep(!/^engine$/,@a) if $no_engine;
765         @a=grep(!/^hw$/,@a) if $no_hw;
766         @a=grep(!/(^rsa$)|(^genrsa$)/,@a) if $no_rsa;
767         @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa;
768         @a=grep(!/^gendsa$/,@a) if $no_sha1;
769         @a=grep(!/(^dh$)|(^gendh$)/,@a) if $no_dh;
770
771         @a=grep(!/(^dh)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
772
773         grep($_="$dir/$_",@a);
774         @a=grep(!/(^|\/)s_/,@a) if $no_sock;
775         @a=grep(!/(^|\/)bio_sock/,@a) if $no_sock;
776         $ret=join(' ',@a)." ";
777         return($ret);
778         }
779
780 # change things so that each 'token' is only separated by one space
781 sub clean_up_ws
782         {
783         local($w)=@_;
784
785         $w =~ s/^\s*(.*)\s*$/$1/;
786         $w =~ s/\s+/ /g;
787         return($w);
788         }
789
790 sub do_defs
791         {
792         local($var,$files,$location,$postfix)=@_;
793         local($_,$ret,$pf);
794         local(*OUT,$tmp,$t);
795
796         $files =~ s/\//$o/g if $o ne '/';
797         $ret="$var="; 
798         $n=1;
799         $Vars{$var}.="";
800         foreach (split(/ /,$files))
801                 {
802                 $orig=$_;
803                 $_=&bname($_) unless /^\$/;
804                 if ($n++ == 2)
805                         {
806                         $n=0;
807                         $ret.="\\\n\t";
808                         }
809                 if (($_ =~ /bss_file/) && ($postfix eq ".h"))
810                         { $pf=".c"; }
811                 else    { $pf=$postfix; }
812                 if ($_ =~ /BN_ASM/)     { $t="$_ "; }
813                 elsif ($_ =~ /BNCO_ASM/){ $t="$_ "; }
814                 elsif ($_ =~ /AES_ASM/){ $t="$_ "; }
815                 elsif ($_ =~ /DES_ENC/) { $t="$_ "; }
816                 elsif ($_ =~ /BF_ENC/)  { $t="$_ "; }
817                 elsif ($_ =~ /CAST_ENC/){ $t="$_ "; }
818                 elsif ($_ =~ /RC4_ENC/) { $t="$_ "; }
819                 elsif ($_ =~ /RC5_ENC/) { $t="$_ "; }
820                 elsif ($_ =~ /MD5_ASM/) { $t="$_ "; }
821                 elsif ($_ =~ /SHA1_ASM/){ $t="$_ "; }
822                 elsif ($_ =~ /RMD160_ASM/){ $t="$_ "; }
823                 elsif ($_ =~ /WHIRLPOOL_ASM/){ $t="$_ "; }
824                 elsif ($_ =~ /CPUID_ASM/){ $t="$_ "; }
825                 else    { $t="$location${o}$_$pf "; }
826
827                 $Vars{$var}.="$t ";
828                 $ret.=$t;
829                 }
830         # hack to add version info on MSVC
831         if ($shlib && (($platform eq "VC-WIN32") || ($platform eq "VC-NT")))
832                 {
833                 if ($var eq "CRYPTOOBJ")
834                         { $ret.="\$(OBJ_D)\\\$(CRYPTO).res "; }
835                 elsif ($var eq "SSLOBJ")
836                         { $ret.="\$(OBJ_D)\\\$(SSL).res "; }
837                 }
838         chomp($ret);
839         $ret.="\n\n";
840         return($ret);
841         }
842
843 # return the name with the leading path removed
844 sub bname
845         {
846         local($ret)=@_;
847         $ret =~ s/^.*[\\\/]([^\\\/]+)$/$1/;
848         return($ret);
849         }
850
851 # return the leading path
852 sub dname
853         {
854         my $ret=shift;
855         $ret =~ s/(^.*)[\\\/][^\\\/]+$/$1/;
856         return($ret);
857         }
858
859 ##############################################################
860 # do a rule for each file that says 'compile' to new direcory
861 # compile the files in '$files' into $to
862 sub do_compile_rule
863         {
864         local($to,$files,$ex)=@_;
865         local($ret,$_,$n,$d,$s);
866
867         $files =~ s/\//$o/g if $o ne '/';
868         foreach (split(/\s+/,$files))
869                 {
870                 $n=&bname($_);
871                 $d=&dname($_);
872                 if (-f "${_}.c")
873                         {
874                         $ret.=&cc_compile_target("$to${o}$n$obj","${_}.c",$ex)
875                         }
876                 elsif (-f ($s="${d}${o}asm${o}${n}.pl") or
877                        ($s=~s/sha256/sha512/ and -f $s) or
878                        -f ($s="${d}${o}${n}.pl"))
879                         {
880                         $ret.=&perlasm_compile_target("$to${o}$n$obj",$s,$n);
881                         }
882                 elsif (-f ($s="${d}${o}asm${o}${n}.S") or
883                        -f ($s="${d}${o}${n}.S"))
884                         {
885                         $ret.=&Sasm_compile_target("$to${o}$n$obj",$s,$n);
886                         }
887                 else    { die "no rule for $_"; }
888                 }
889         return($ret);
890         }
891
892 ##############################################################
893 # do a rule for each file that says 'compile' to new direcory
894 sub perlasm_compile_target
895         {
896         my($target,$source,$bname)=@_;
897         my($ret);
898
899         $bname =~ s/(.*)\.[^\.]$/$1/;
900         $ret ="\$(TMP_D)$o$bname.asm: $source\n";
901         $ret.="\t\$(PERL) $source $asmtype \$(CFLAG) >\$\@\n\n";
902         $ret.="$target: \$(TMP_D)$o$bname.asm\n";
903         $ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm\n\n";
904         return($ret);
905         }
906
907 sub Sasm_compile_target
908         {
909         my($target,$source,$bname)=@_;
910         my($ret);
911
912         $bname =~ s/(.*)\.[^\.]$/$1/;
913         $ret ="\$(TMP_D)$o$bname.asm: $source\n";
914         $ret.="\t\$(CC) -E \$(CFLAG) $source >\$\@\n\n";
915         $ret.="$target: \$(TMP_D)$o$bname.asm\n";
916         $ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm\n\n";
917         return($ret);
918         }
919
920 sub cc_compile_target
921         {
922         local($target,$source,$ex_flags)=@_;
923         local($ret);
924         
925         $ex_flags.=" -DMK1MF_BUILD -D$platform_cpp_symbol" if ($source =~ /cversion/);
926         $target =~ s/\//$o/g if $o ne "/";
927         $source =~ s/\//$o/g if $o ne "/";
928         $ret ="$target: \$(SRC_D)$o$source\n\t";
929         $ret.="\$(CC) ${ofile}$target $ex_flags -c \$(SRC_D)$o$source\n\n";
930         return($ret);
931         }
932
933 ##############################################################
934 sub do_asm_rule
935         {
936         local($target,$src)=@_;
937         local($ret,@s,@t,$i);
938
939         $target =~ s/\//$o/g if $o ne "/";
940         $src =~ s/\//$o/g if $o ne "/";
941
942         @t=split(/\s+/,$target);
943         @s=split(/\s+/,$src);
944
945
946         for ($i=0; $i<=$#s; $i++)
947                 {
948                 my $objfile = $t[$i];
949                 my $srcfile = $s[$i];
950
951                 if ($perl_asm == 1)
952                         {
953                         my $plasm = $objfile;
954                         $plasm =~ s/${obj}/.pl/;
955                         $ret.="$srcfile: $plasm\n";
956                         $ret.="\t\$(PERL) $plasm $asmtype \$(CFLAG) >$srcfile\n\n";
957                         }
958
959                 $ret.="$objfile: $srcfile\n";
960                 $ret.="\t\$(ASM) $afile$objfile \$(SRC_D)$o$srcfile\n\n";
961                 }
962         return($ret);
963         }
964
965 sub do_shlib_rule
966         {
967         local($n,$def)=@_;
968         local($ret,$nn);
969         local($t);
970
971         ($nn=$n) =~ tr/a-z/A-Z/;
972         $ret.="$n.dll: \$(${nn}OBJ)\n";
973         if ($vc && $w32)
974                 {
975                 $ret.="\t\$(MKSHLIB) $efile$n.dll $def @<<\n  \$(${nn}OBJ_F)\n<<\n";
976                 }
977         $ret.="\n";
978         return($ret);
979         }
980
981 # do a rule for each file that says 'copy' to new direcory on change
982 sub do_copy_rule
983         {
984         local($to,$files,$p)=@_;
985         local($ret,$_,$n,$pp);
986         
987         $files =~ s/\//$o/g if $o ne '/';
988         foreach (split(/\s+/,$files))
989                 {
990                 $n=&bname($_);
991                 if ($n =~ /bss_file/)
992                         { $pp=".c"; }
993                 else    { $pp=$p; }
994                 $ret.="$to${o}$n$pp: \$(SRC_D)$o$_$pp\n\t\$(CP) \"\$(SRC_D)$o$_$pp\" \"$to${o}$n$pp\"\n\n";
995                 }
996         return($ret);
997         }
998
999 sub read_options
1000         {
1001         # Many options are handled in a similar way. In particular
1002         # no-xxx sets zero or more scalars to 1.
1003         # Process these using a hash containing the option name and
1004         # reference to the scalars to set.
1005
1006         my %valid_options = (
1007                 "no-rc2" => \$no_rc2,
1008                 "no-rc4" => \$no_rc4,
1009                 "no-rc5" => \$no_rc5,
1010                 "no-idea" => \$no_idea,
1011                 "no-aes" => \$no_aes,
1012                 "no-camellia" => \$no_camellia,
1013                 "no-seed" => \$no_seed,
1014                 "no-des" => \$no_des,
1015                 "no-bf" => \$no_bf,
1016                 "no-cast" => \$no_cast,
1017                 "no-md2" => \$no_md2,
1018                 "no-md4" => \$no_md4,
1019                 "no-md5" => \$no_md5,
1020                 "no-sha" => \$no_sha,
1021                 "no-sha1" => \$no_sha1,
1022                 "no-ripemd" => \$no_ripemd,
1023                 "no-mdc2" => \$no_mdc2,
1024                 "no-whirlpool" => \$no_whirlpool,
1025                 "no-patents" => 
1026                         [\$no_rc2, \$no_rc4, \$no_rc5, \$no_idea, \$no_rsa],
1027                 "no-rsa" => \$no_rsa,
1028                 "no-dsa" => \$no_dsa,
1029                 "no-dh" => \$no_dh,
1030                 "no-hmac" => \$no_hmac,
1031                 "no-asm" => \$no_asm,
1032                 "nasm" => \$nasm,
1033                 "nw-nasm" => \$nw_nasm,
1034                 "nw-mwasm" => \$nw_mwasm,
1035                 "gaswin" => \$gaswin,
1036                 "no-ssl2" => \$no_ssl2,
1037                 "no-ssl3" => \$no_ssl3,
1038                 "no-tlsext" => \$no_tlsext,
1039                 "no-cms" => \$no_cms,
1040                 "no-jpake" => \$no_jpake,
1041                 "no-err" => \$no_err,
1042                 "no-sock" => \$no_sock,
1043                 "no-krb5" => \$no_krb5,
1044                 "no-ec" => \$no_ec,
1045                 "no-ecdsa" => \$no_ecdsa,
1046                 "no-ecdh" => \$no_ecdh,
1047                 "no-engine" => \$no_engine,
1048                 "no-hw" => \$no_hw,
1049                 "just-ssl" =>
1050                         [\$no_rc2, \$no_idea, \$no_des, \$no_bf, \$no_cast,
1051                           \$no_md2, \$no_sha, \$no_mdc2, \$no_dsa, \$no_dh,
1052                           \$no_ssl2, \$no_err, \$no_ripemd, \$no_rc5,
1053                           \$no_aes, \$no_camellia, \$no_seed],
1054                 "rsaref" => 0,
1055                 "gcc" => \$gcc,
1056                 "debug" => \$debug,
1057                 "profile" => \$profile,
1058                 "shlib" => \$shlib,
1059                 "dll" => \$shlib,
1060                 "shared" => 0,
1061                 "no-gmp" => 0,
1062                 "no-rfc3779" => 0,
1063                 "no-montasm" => 0,
1064                 "no-shared" => 0,
1065                 "no-zlib" => 0,
1066                 "no-zlib-dynamic" => 0,
1067                 );
1068
1069         if (exists $valid_options{$_})
1070                 {
1071                 my $r = $valid_options{$_};
1072                 if ( ref $r eq "SCALAR")
1073                         { $$r = 1;}
1074                 elsif ( ref $r eq "ARRAY")
1075                         {
1076                         my $r2;
1077                         foreach $r2 (@$r)
1078                                 {
1079                                 $$r2 = 1;
1080                                 }
1081                         }
1082                 }
1083         elsif (/^no-comp$/) { $xcflags = "-DOPENSSL_NO_COMP $xcflags"; }
1084         elsif (/^enable-zlib$/) { $zlib_opt = 1 if $zlib_opt == 0 }
1085         elsif (/^enable-zlib-dynamic$/)
1086                 {
1087                 $zlib_opt = 2;
1088                 }
1089         elsif (/^no-static-engine/)
1090                 {
1091                 $no_static_engine = 1;
1092                 }
1093         elsif (/^enable-static-engine/)
1094                 {
1095                 $no_static_engine = 0;
1096                 }
1097         # There are also enable-xxx options which correspond to
1098         # the no-xxx. Since the scalars are enabled by default
1099         # these can be ignored.
1100         elsif (/^enable-/)
1101                 {
1102                 my $t = $_;
1103                 $t =~ s/^enable/no/;
1104                 if (exists $valid_options{$t})
1105                         {return 1;}
1106                 return 0;
1107                 }
1108         # experimental-xxx is mostly like enable-xxx, but opensslconf.v
1109         # will still set OPENSSL_NO_xxx unless we set OPENSSL_EXPERIMENTAL_xxx.
1110         # (No need to fail if we don't know the algorithm -- this is for adventurous users only.)
1111         elsif (/^experimental-/)
1112                 {
1113                 my $algo, $ALGO;
1114                 ($algo = $_) =~ s/^experimental-//;
1115                 ($ALGO = $algo) =~ tr/[a-z]/[A-Z]/;
1116
1117                 $xcflags="-DOPENSSL_EXPERIMENTAL_$ALGO $xcflags";
1118                 
1119                 }
1120         elsif (/^--with-krb5-flavor=(.*)$/)
1121                 {
1122                 my $krb5_flavor = $1;
1123                 if ($krb5_flavor =~ /^force-[Hh]eimdal$/)
1124                         {
1125                         $xcflags="-DKRB5_HEIMDAL $xcflags";
1126                         }
1127                 elsif ($krb5_flavor =~ /^MIT/i)
1128                         {
1129                         $xcflags="-DKRB5_MIT $xcflags";
1130                         if ($krb5_flavor =~ /^MIT[._-]*1[._-]*[01]/i)
1131                                 {
1132                                 $xcflags="-DKRB5_MIT_OLD11 $xcflags"
1133                                 }
1134                         }
1135                 }
1136         elsif (/^([^=]*)=(.*)$/){ $VARS{$1}=$2; }
1137         elsif (/^-[lL].*$/)     { $l_flags.="$_ "; }
1138         elsif ((!/^-help/) && (!/^-h/) && (!/^-\?/) && /^-.*$/)
1139                 { $c_flags.="$_ "; }
1140         else { return(0); }
1141         return(1);
1142         }