(linenum→info "unix/slp.c:2238")

openssl/0.9.8g/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: $OPTIONS="";
   10: $ssl_version="";
   11: $banner="\t\@echo Building OpenSSL";
   12: 
   13: my $no_static_engine = 0;
   14: my $engines = "";
   15: local $zlib_opt = 0;    # 0 = no zlib, 1 = static, 2 = dynamic
   16: local $zlib_lib = "";
   17: 
   18: 
   19: open(IN,"<Makefile") || die "unable to open Makefile!\n";
   20: while(<IN>) {
   21:     $ssl_version=$1 if (/^VERSION=(.*)$/);
   22:     $OPTIONS=$1 if (/^OPTIONS=(.*)$/);
   23:     $INSTALLTOP=$1 if (/^INSTALLTOP=(.*$)/);
   24: }
   25: close(IN);
   26: 
   27: die "Makefile is not the toplevel Makefile!\n" if $ssl_version eq "";
   28: 
   29: $infile="MINFO";
   30: 
   31: %ops=(
   32:         "VC-WIN32",   "Microsoft Visual C++ [4-6] - Windows NT or 9X",
   33:         "VC-WIN64I",  "Microsoft C/C++ - Win64/IA-64",
   34:         "VC-WIN64A",  "Microsoft C/C++ - Win64/x64",
   35:         "VC-CE",   "Microsoft eMbedded Visual C++ 3.0 - Windows CE ONLY",
   36:         "VC-NT",   "Microsoft Visual C++ [4-6] - Windows NT ONLY",
   37:         "Mingw32", "GNU C++ - Windows NT or 9x",
   38:         "Mingw32-files", "Create files with DOS copy ...",
   39:         "BC-NT",   "Borland C++ 4.5 - Windows NT",
   40:         "linux-elf","Linux elf",
   41:         "ultrix-mips","DEC mips ultrix",
   42:         "FreeBSD","FreeBSD distribution",
   43:         "OS2-EMX", "EMX GCC OS/2",
   44:         "netware-clib", "CodeWarrior for NetWare - CLib - with WinSock Sockets",
   45:         "netware-libc", "CodeWarrior for NetWare - LibC - with WinSock Sockets",
   46:         "netware-libc-bsdsock", "CodeWarrior for NetWare - LibC - with BSD Sockets",
   47:         "default","cc under unix",
   48:         );
   49: 
   50: $platform="";
   51: my $xcflags="";
   52: foreach (@ARGV)
   53:         {
   54:         if (!&read_options && !defined($ops{$_}))
   55:                 {
   56:                 print STDERR "unknown option - $_\n";
   57:                 print STDERR "usage: perl mk1mf.pl [options] [system]\n";
   58:                 print STDERR "\nwhere [system] can be one of the following\n";
   59:                 foreach $i (sort keys %ops)
   60:                 { printf STDERR "\t%-10s\t%s\n",$i,$ops{$i}; }
   61:                 print STDERR <<"EOF";
   62: and [options] can be one of
   63:         no-md2 no-md4 no-md5 no-sha no-mdc2    - Skip this digest
   64:         no-ripemd
   65:         no-rc2 no-rc4 no-rc5 no-idea no-des     - Skip this symetric cipher
   66:         no-bf no-cast no-aes no-camellia no-seed
   67:         no-rsa no-dsa no-dh                    - Skip this public key cipher
   68:         no-ssl2 no-ssl3                                - Skip this version of SSL
   69:         just-ssl                               - remove all non-ssl keys/digest
   70:         no-asm                                         - No x86 asm
   71:         no-krb5                                        - No KRB5
   72:         no-ec                                  - No EC
   73:         no-ecdsa                               - No ECDSA
   74:         no-ecdh                                        - No ECDH
   75:         no-engine                              - No engine
   76:         no-hw                                  - No hw
   77:         nasm                                   - Use NASM for x86 asm
   78:         nw-nasm                                        - Use NASM x86 asm for NetWare
   79:         nw-mwasm                                       - Use Metrowerks x86 asm for NetWare
   80:         gaswin                                 - Use GNU as with Mingw32
   81:         no-socks                               - No socket code
   82:         no-err                                 - No error strings
   83:         dll/shlib                              - Build shared libraries (MS)
   84:         debug                                  - Debug build
   85:         profile                                 - Profiling build
   86:         gcc                                    - Use Gcc (unix)
   87: 
   88: Values that can be set
   89: TMP=tmpdir OUT=outdir SRC=srcdir BIN=binpath INC=header-outdir CC=C-compiler
   90: 
   91: -L<ex_lib_path> -l<ex_lib>                      - extra library flags (unix)
   92: -<ex_cc_flags>                                  - extra 'cc' flags,
   93:                                                   added (MS), or replace (unix)
   94: EOF
   95:                 exit(1);
   96:                 }
   97:         $platform=$_;
   98:         }
   99: foreach (grep(!/^$/, split(/ /, $OPTIONS)))
  100:         {
  101:         print STDERR "unknown option - $_\n" if !&read_options;
  102:         }
  103: 
  104: $no_static_engine = 0 if (!$shlib);
  105: 
  106: $no_mdc2=1 if ($no_des);
  107: 
  108: $no_ssl3=1 if ($no_md5 || $no_sha);
  109: $no_ssl3=1 if ($no_rsa && $no_dh);
  110: 
  111: $no_ssl2=1 if ($no_md5);
  112: $no_ssl2=1 if ($no_rsa);
  113: 
  114: $out_def="out";
  115: $inc_def="outinc";
  116: $tmp_def="tmp";
  117: 
  118: $perl="perl" unless defined $perl;
  119: $mkdir="-mkdir" unless defined $mkdir;
  120: 
  121: ($ssl,$crypto)=("ssl","crypto");
  122: $ranlib="echo ranlib";
  123: 
  124: $cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc';
  125: $src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}:'.';
  126: $bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:'';
  127: 
  128: # $bin_dir.=$o causes a core dump on my sparc :-(
  129: 
  130: 
  131: $NT=0;
  132: 
  133: push(@INC,"util/pl","pl");
  134: if (($platform =~ /VC-(.+)/))
  135:         {
  136:         $FLAVOR=$1;
  137:         $NT = 1 if $1 eq "NT";
  138:         require 'VC-32.pl';
  139:         }
  140: elsif ($platform eq "Mingw32")
  141:         {
  142:         require 'Mingw32.pl';
  143:         }
  144: elsif ($platform eq "Mingw32-files")
  145:         {
  146:         require 'Mingw32f.pl';
  147:         }
  148: elsif ($platform eq "BC-NT")
  149:         {
  150:         $bc=1;
  151:         require 'BC-32.pl';
  152:         }
  153: elsif ($platform eq "FreeBSD")
  154:         {
  155:         require 'unix.pl';
  156:         $cflags='-DTERMIO -D_ANSI_SOURCE -O2 -fomit-frame-pointer';
  157:         }
  158: elsif ($platform eq "linux-elf")
  159:         {
  160:         require "unix.pl";
  161:         require "linux.pl";
  162:         $unix=1;
  163:         }
  164: elsif ($platform eq "ultrix-mips")
  165:         {
  166:         require "unix.pl";
  167:         require "ultrix.pl";
  168:         $unix=1;
  169:         }
  170: elsif ($platform eq "OS2-EMX")
  171:         {
  172:         $wc=1;
  173:         require 'OS2-EMX.pl';
  174:         }
  175: elsif (($platform eq "netware-clib") || ($platform eq "netware-libc") ||
  176:        ($platform eq "netware-libc-bsdsock"))
  177:         {
  178:         $LIBC=1 if $platform eq "netware-libc" || $platform eq "netware-libc-bsdsock";
  179:         $BSDSOCK=1 if $platform eq "netware-libc-bsdsock";
  180:         require 'netware.pl';
  181:         }
  182: else
  183:         {
  184:         require "unix.pl";
  185: 
  186:         $unix=1;
  187:         $cflags.=' -DTERMIO';
  188:         }
  189: 
  190: $out_dir=(defined($VARS{'OUT'}))?$VARS{'OUT'}:$out_def.($debug?".dbg":"");
  191: $tmp_dir=(defined($VARS{'TMP'}))?$VARS{'TMP'}:$tmp_def.($debug?".dbg":"");
  192: $inc_dir=(defined($VARS{'INC'}))?$VARS{'INC'}:$inc_def;
  193: 
  194: $bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq ''));
  195: 
  196: $cflags= "$xcflags$cflags" if $xcflags ne "";
  197: 
  198: $cflags.=" -DOPENSSL_NO_IDEA" if $no_idea;
  199: $cflags.=" -DOPENSSL_NO_AES"  if $no_aes;
  200: $cflags.=" -DOPENSSL_NO_CAMELLIA"  if $no_camellia;
  201: $cflags.=" -DOPENSSL_NO_SEED" if $no_seed;
  202: $cflags.=" -DOPENSSL_NO_RC2"  if $no_rc2;
  203: $cflags.=" -DOPENSSL_NO_RC4"  if $no_rc4;
  204: $cflags.=" -DOPENSSL_NO_RC5"  if $no_rc5;
  205: $cflags.=" -DOPENSSL_NO_MD2"  if $no_md2;
  206: $cflags.=" -DOPENSSL_NO_MD4"  if $no_md4;
  207: $cflags.=" -DOPENSSL_NO_MD5"  if $no_md5;
  208: $cflags.=" -DOPENSSL_NO_SHA"  if $no_sha;
  209: $cflags.=" -DOPENSSL_NO_SHA1" if $no_sha1;
  210: $cflags.=" -DOPENSSL_NO_RIPEMD" if $no_ripemd;
  211: $cflags.=" -DOPENSSL_NO_MDC2" if $no_mdc2;
  212: $cflags.=" -DOPENSSL_NO_BF"  if $no_bf;
  213: $cflags.=" -DOPENSSL_NO_CAST" if $no_cast;
  214: $cflags.=" -DOPENSSL_NO_DES"  if $no_des;
  215: $cflags.=" -DOPENSSL_NO_RSA"  if $no_rsa;
  216: $cflags.=" -DOPENSSL_NO_DSA"  if $no_dsa;
  217: $cflags.=" -DOPENSSL_NO_DH"   if $no_dh;
  218: $cflags.=" -DOPENSSL_NO_SOCK" if $no_sock;
  219: $cflags.=" -DOPENSSL_NO_SSL2" if $no_ssl2;
  220: $cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3;
  221: $cflags.=" -DOPENSSL_NO_TLSEXT" if $no_tlsext;
  222: $cflags.=" -DOPENSSL_NO_ERR"  if $no_err;
  223: $cflags.=" -DOPENSSL_NO_KRB5" if $no_krb5;
  224: $cflags.=" -DOPENSSL_NO_EC"   if $no_ec;
  225: $cflags.=" -DOPENSSL_NO_ECDSA" if $no_ecdsa;
  226: $cflags.=" -DOPENSSL_NO_ECDH" if $no_ecdh;
  227: $cflags.=" -DOPENSSL_NO_ENGINE"   if $no_engine;
  228: $cflags.=" -DOPENSSL_NO_HW"   if $no_hw;
  229: 
  230: $cflags.= " -DZLIB" if $zlib_opt;
  231: $cflags.= " -DZLIB_SHARED" if $zlib_opt == 2;
  232: 
  233: if ($no_static_engine)
  234:         {
  235:         $cflags .= " -DOPENSSL_NO_STATIC_ENGINE";
  236:         }
  237: else
  238:         {
  239:         $cflags .= " -DOPENSSL_NO_DYNAMIC_ENGINE";
  240:         }
  241: 
  242: #$cflags.=" -DRSAref"  if $rsaref ne "";
  243: 
  244: ## if ($unix)
  245: ##      { $cflags="$c_flags" if ($c_flags ne ""); }
  246: ##else
  247:         { $cflags="$c_flags$cflags" if ($c_flags ne ""); }
  248: 
  249: $ex_libs="$l_flags$ex_libs" if ($l_flags ne "");
  250: 
  251: 
  252: %shlib_ex_cflags=("SSL" => " -DOPENSSL_BUILD_SHLIBSSL",
  253:                   "CRYPTO" => " -DOPENSSL_BUILD_SHLIBCRYPTO");
  254: 
  255: if ($msdos)
  256:         {
  257:         $banner ="\t\@echo Make sure you have run 'perl Configure $platform' in the\n";
  258:         $banner.="\t\@echo top level directory, if you don't have perl, you will\n";
  259:         $banner.="\t\@echo need to probably edit crypto/bn/bn.h, check the\n";
  260:         $banner.="\t\@echo documentation for details.\n";
  261:         }
  262: 
  263: # have to do this to allow $(CC) under unix
  264: $link="$bin_dir$link" if ($link !~ /^\$/);
  265: 
  266: $INSTALLTOP =~ s|/|$o|g;
  267: 
  268: #############################################
  269: # We parse in input file and 'store' info for later printing.
  270: open(IN,"<$infile") || die "unable to open $infile:$!\n";
  271: $_=<IN>;
  272: for (;;)
  273:         {
  274:         chop;
  275: 
  276:         ($key,$val)=/^([^=]+)=(.*)/;
  277:         if ($key eq "RELATIVE_DIRECTORY")
  278:                 {
  279:                 if ($lib ne "")
  280:                         {
  281:                         $uc=$lib;
  282:                         $uc =~ s/^lib(.*)\.a/$1/;
  283:                         $uc =~ tr/a-z/A-Z/;
  284:                         $lib_nam{$uc}=$uc;
  285:                         $lib_obj{$uc}.=$libobj." ";
  286:                         }
  287:                 last if ($val eq "FINISHED");
  288:                 $lib="";
  289:                 $libobj="";
  290:                 $dir=$val;
  291:                 }
  292: 
  293:         if ($key eq "KRB5_INCLUDES")
  294:                 { $cflags .= " $val";}
  295: 
  296:         if ($key eq "ZLIB_INCLUDE")
  297:                 { $cflags .= " $val" if $val ne "";}
  298: 
  299:         if ($key eq "LIBZLIB")
  300:                 { $zlib_lib = "$val" if $val ne "";}
  301: 
  302:         if ($key eq "LIBKRB5")
  303:                 { $ex_libs .= " $val" if $val ne "";}
  304: 
  305:         if ($key eq "TEST")
  306:                 { $test.=&var_add($dir,$val, 0); }
  307: 
  308:         if (($key eq "PROGS") || ($key eq "E_OBJ"))
  309:                 { $e_exe.=&var_add($dir,$val, 0); }
  310: 
  311:         if ($key eq "LIB")
  312:                 {
  313:                 $lib=$val;
  314:                 $lib =~ s/^.*\/([^\/]+)$/$1/;
  315:                 }
  316: 
  317:         if ($key eq "EXHEADER")
  318:                 { $exheader.=&var_add($dir,$val, 1); }
  319: 
  320:         if ($key eq "HEADER")
  321:                 { $header.=&var_add($dir,$val, 1); }
  322: 
  323:         if ($key eq "LIBOBJ" && ($dir ne "engines" || !$no_static_engine))
  324:                 { $libobj=&var_add($dir,$val, 0); }
  325:         if ($key eq "LIBNAMES" && $dir eq "engines" && $no_static_engine)
  326:                 { $engines.=$val }
  327: 
  328:         if (!($_=<IN>))
  329:                 { $_="RELATIVE_DIRECTORY=FINISHED\n"; }
  330:         }
  331: close(IN);
  332: 
  333: if ($shlib)
  334:         {
  335:         $extra_install= <<"EOF";
  336:         \$(CP) \$(O_SSL) \$(INSTALLTOP)${o}bin
  337:         \$(CP) \$(O_CRYPTO) \$(INSTALLTOP)${o}bin
  338:         \$(CP) \$(L_SSL) \$(INSTALLTOP)${o}lib
  339:         \$(CP) \$(L_CRYPTO) \$(INSTALLTOP)${o}lib
  340: EOF
  341:         if ($no_static_engine)
  342:                 {
  343:                 $extra_install .= <<"EOF"
  344:         \$(MKDIR) \$(INSTALLTOP)${o}lib${o}engines
  345:         \$(CP) \$(E_SHLIB) \$(INSTALLTOP)${o}lib${o}engines
  346: EOF
  347:                 }
  348:         }
  349: else
  350:         {
  351:         $extra_install= <<"EOF";
  352:         \$(CP) \$(O_SSL) \$(INSTALLTOP)${o}lib
  353:         \$(CP) \$(O_CRYPTO) \$(INSTALLTOP)${o}lib
  354: EOF
  355:         $ex_libs .= " $zlib_lib" if $zlib_opt == 1;
  356:         }
  357: 
  358: $defs= <<"EOF";
  359: # This makefile has been automatically generated from the OpenSSL distribution.
  360: # This single makefile will build the complete OpenSSL distribution and
  361: # by default leave the 'intertesting' output files in .${o}out and the stuff
  362: # that needs deleting in .${o}tmp.
  363: # The file was generated by running 'make makefile.one', which
  364: # does a 'make files', which writes all the environment variables from all
  365: # the makefiles to the file call MINFO.  This file is used by
  366: # util${o}mk1mf.pl to generate makefile.one.
  367: # The 'makefile per directory' system suites me when developing this
  368: # library and also so I can 'distribute' indervidual library sections.
  369: # The one monster makefile better suits building in non-unix
  370: # environments.
  371: 
  372: EOF
  373: 
  374: $defs .= $preamble if defined $preamble;
  375: 
  376: $defs.= <<"EOF";
  377: INSTALLTOP=$INSTALLTOP
  378: 
  379: # Set your compiler options
  380: PLATFORM=$platform
  381: CC=$bin_dir${cc}
  382: CFLAG=$cflags
  383: APP_CFLAG=$app_cflag
  384: LIB_CFLAG=$lib_cflag
  385: SHLIB_CFLAG=$shl_cflag
  386: APP_EX_OBJ=$app_ex_obj
  387: SHLIB_EX_OBJ=$shlib_ex_obj
  388: # add extra libraries to this define, for solaris -lsocket -lnsl would
  389: # be added
  390: EX_LIBS=$ex_libs
  391: 
  392: # The OpenSSL directory
  393: SRC_D=$src_dir
  394: 
  395: LINK=$link
  396: LFLAGS=$lflags
  397: RSC=$rsc
  398: 
  399: AES_ASM_OBJ=$aes_asm_obj
  400: AES_ASM_SRC=$aes_asm_src
  401: BN_ASM_OBJ=$bn_asm_obj
  402: BN_ASM_SRC=$bn_asm_src
  403: BNCO_ASM_OBJ=$bnco_asm_obj
  404: BNCO_ASM_SRC=$bnco_asm_src
  405: DES_ENC_OBJ=$des_enc_obj
  406: DES_ENC_SRC=$des_enc_src
  407: BF_ENC_OBJ=$bf_enc_obj
  408: BF_ENC_SRC=$bf_enc_src
  409: CAST_ENC_OBJ=$cast_enc_obj
  410: CAST_ENC_SRC=$cast_enc_src
  411: RC4_ENC_OBJ=$rc4_enc_obj
  412: RC4_ENC_SRC=$rc4_enc_src
  413: RC5_ENC_OBJ=$rc5_enc_obj
  414: RC5_ENC_SRC=$rc5_enc_src
  415: MD5_ASM_OBJ=$md5_asm_obj
  416: MD5_ASM_SRC=$md5_asm_src
  417: SHA1_ASM_OBJ=$sha1_asm_obj
  418: SHA1_ASM_SRC=$sha1_asm_src
  419: RMD160_ASM_OBJ=$rmd160_asm_obj
  420: RMD160_ASM_SRC=$rmd160_asm_src
  421: CPUID_ASM_OBJ=$cpuid_asm_obj
  422: CPUID_ASM_SRC=$cpuid_asm_src
  423: 
  424: # The output directory for everything intersting
  425: OUT_D=$out_dir
  426: # The output directory for all the temporary muck
  427: TMP_D=$tmp_dir
  428: # The output directory for the header files
  429: INC_D=$inc_dir
  430: INCO_D=$inc_dir${o}openssl
  431: 
  432: PERL=$perl
  433: CP=$cp
  434: RM=$rm
  435: RANLIB=$ranlib
  436: MKDIR=$mkdir
  437: MKLIB=$bin_dir$mklib
  438: MLFLAGS=$mlflags
  439: ASM=$bin_dir$asm
  440: 
  441: ######################################################
  442: # You should not need to touch anything below this point
  443: ######################################################
  444: 
  445: E_EXE=openssl
  446: SSL=$ssl
  447: CRYPTO=$crypto
  448: 
  449: # BIN_D  - Binary output directory
  450: # TEST_D - Binary test file output directory
  451: # LIB_D  - library output directory
  452: # ENG_D  - dynamic engine output directory
  453: # Note: if you change these point to different directories then uncomment out
  454: # the lines around the 'NB' comment below.
  455: # 
  456: BIN_D=\$(OUT_D)
  457: TEST_D=\$(OUT_D)
  458: LIB_D=\$(OUT_D)
  459: ENG_D=\$(OUT_D)
  460: 
  461: # INCL_D - local library directory
  462: # OBJ_D  - temp object file directory
  463: OBJ_D=\$(TMP_D)
  464: INCL_D=\$(TMP_D)
  465: 
  466: O_SSL=     \$(LIB_D)$o$plib\$(SSL)$shlibp
  467: O_CRYPTO=  \$(LIB_D)$o$plib\$(CRYPTO)$shlibp
  468: SO_SSL=    $plib\$(SSL)$so_shlibp
  469: SO_CRYPTO= $plib\$(CRYPTO)$so_shlibp
  470: L_SSL=     \$(LIB_D)$o$plib\$(SSL)$libp
  471: L_CRYPTO=  \$(LIB_D)$o$plib\$(CRYPTO)$libp
  472: 
  473: L_LIBS= \$(L_SSL) \$(L_CRYPTO)
  474: 
  475: ######################################################
  476: # Don't touch anything below this point
  477: ######################################################
  478: 
  479: INC=-I\$(INC_D) -I\$(INCL_D)
  480: APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG)
  481: LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG)
  482: SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG)
  483: LIBS_DEP=\$(O_CRYPTO) \$(O_SSL)
  484: 
  485: #############################################
  486: EOF
  487: 
  488: $rules=<<"EOF";
  489: all: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INCO_D) headers lib exe
  490: 
  491: banner:
  492: $banner
  493: 
  494: \$(TMP_D):
  495:         \$(MKDIR) \$(TMP_D)
  496: # NB: uncomment out these lines if BIN_D, TEST_D and LIB_D are different
  497: #\$(BIN_D):
  498: #       \$(MKDIR) \$(BIN_D)
  499: #
  500: #\$(TEST_D):
  501: #       \$(MKDIR) \$(TEST_D)
  502: 
  503: \$(LIB_D):
  504:         \$(MKDIR) \$(LIB_D)
  505: 
  506: \$(INCO_D): \$(INC_D)
  507:         \$(MKDIR) \$(INCO_D)
  508: 
  509: \$(INC_D):
  510:         \$(MKDIR) \$(INC_D)
  511: 
  512: headers: \$(HEADER) \$(EXHEADER)
  513:         @
  514: 
  515: lib: \$(LIBS_DEP) \$(E_SHLIB)
  516: 
  517: exe: \$(T_EXE) \$(BIN_D)$o\$(E_EXE)$exep
  518: 
  519: install: all
  520:         \$(MKDIR) \$(INSTALLTOP)
  521:         \$(MKDIR) \$(INSTALLTOP)${o}bin
  522:         \$(MKDIR) \$(INSTALLTOP)${o}include
  523:         \$(MKDIR) \$(INSTALLTOP)${o}include${o}openssl
  524:         \$(MKDIR) \$(INSTALLTOP)${o}lib
  525:         \$(CP) \$(INCO_D)${o}*.\[ch\] \$(INSTALLTOP)${o}include${o}openssl
  526:         \$(CP) \$(BIN_D)$o\$(E_EXE)$exep \$(INSTALLTOP)${o}bin
  527:         \$(CP) apps${o}openssl.cnf \$(INSTALLTOP)
  528: $extra_install
  529: 
  530: 
  531: test: \$(T_EXE)
  532:         cd \$(BIN_D)
  533:         ..${o}ms${o}test
  534: 
  535: clean:
  536:         \$(RM) \$(TMP_D)$o*.*
  537: 
  538: vclean:
  539:         \$(RM) \$(TMP_D)$o*.*
  540:         \$(RM) \$(OUT_D)$o*.*
  541: 
  542: EOF
  543:     
  544: my $platform_cpp_symbol = "MK1MF_PLATFORM_$platform";
  545: $platform_cpp_symbol =~ s/-/_/g;
  546: if (open(IN,"crypto/buildinf.h"))
  547:         {
  548:         # Remove entry for this platform in existing file buildinf.h.
  549: 
  550:         my $old_buildinf_h = "";
  551:         while (<IN>)
  552:                 {
  553:                 if (/^\#ifdef $platform_cpp_symbol$/)
  554:                         {
  555:                         while (<IN>) { last if (/^\#endif/); }
  556:                         }
  557:                 else
  558:                         {
  559:                         $old_buildinf_h .= $_;
  560:                         }
  561:                 }
  562:         close(IN);
  563: 
  564:         open(OUT,">crypto/buildinf.h") || die "Can't open buildinf.h";
  565:         print OUT $old_buildinf_h;
  566:         close(OUT);
  567:         }
  568: 
  569: open (OUT,">>crypto/buildinf.h") || die "Can't open buildinf.h";
  570: printf OUT <<EOF;
  571: #ifdef $platform_cpp_symbol
  572:   /* auto-generated/updated by util/mk1mf.pl for crypto/cversion.c */
  573:   #define CFLAGS "$cc $cflags"
  574:   #define PLATFORM "$platform"
  575: EOF
  576: printf OUT "  #define DATE \"%s\"\n", scalar gmtime();
  577: printf OUT "#endif\n";
  578: close(OUT);
  579: 
  580: # Strip of trailing ' '
  581: foreach (keys %lib_obj) { $lib_obj{$_}=&clean_up_ws($lib_obj{$_}); }
  582: $test=&clean_up_ws($test);
  583: $e_exe=&clean_up_ws($e_exe);
  584: $exheader=&clean_up_ws($exheader);
  585: $header=&clean_up_ws($header);
  586: 
  587: # First we strip the exheaders from the headers list
  588: foreach (split(/\s+/,$exheader)){ $h{$_}=1; }
  589: foreach (split(/\s+/,$header))  { $h.=$_." " unless $h{$_}; }
  590: chop($h); $header=$h;
  591: 
  592: $defs.=&do_defs("HEADER",$header,"\$(INCL_D)","");
  593: $rules.=&do_copy_rule("\$(INCL_D)",$header,"");
  594: 
  595: $defs.=&do_defs("EXHEADER",$exheader,"\$(INCO_D)","");
  596: $rules.=&do_copy_rule("\$(INCO_D)",$exheader,"");
  597: 
  598: $defs.=&do_defs("T_OBJ",$test,"\$(OBJ_D)",$obj);
  599: $rules.=&do_compile_rule("\$(OBJ_D)",$test,"\$(APP_CFLAGS)");
  600: 
  601: $defs.=&do_defs("E_OBJ",$e_exe,"\$(OBJ_D)",$obj);
  602: $rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)');
  603: 
  604: foreach (values %lib_nam)
  605:         {
  606:         $lib_obj=$lib_obj{$_};
  607:         local($slib)=$shlib;
  608: 
  609:         if (($_ eq "SSL") && $no_ssl2 && $no_ssl3)
  610:                 {
  611:                 $rules.="\$(O_SSL):\n\n"; 
  612:                 next;
  613:                 }
  614:         if (($aes_asm_obj ne "") && ($_ eq "CRYPTO"))
  615:                 {
  616:                 $lib_obj =~ s/\s(\S*\/aes_core\S*)/ \$(AES_ASM_OBJ)/;
  617:                 $lib_obj =~ s/\s\S*\/aes_cbc\S*//;
  618:                 $rules.=&do_asm_rule($aes_asm_obj,$aes_asm_src);
  619:                 }
  620:         if (($bn_asm_obj ne "") && ($_ eq "CRYPTO"))
  621:                 {
  622:                 $lib_obj =~ s/\s\S*\/bn_asm\S*/ \$(BN_ASM_OBJ)/;
  623:                 $rules.=&do_asm_rule($bn_asm_obj,$bn_asm_src);
  624:                 }
  625:         if (($bnco_asm_obj ne "") && ($_ eq "CRYPTO"))
  626:                 {
  627:                 $lib_obj .= "\$(BNCO_ASM_OBJ)";
  628:                 $rules.=&do_asm_rule($bnco_asm_obj,$bnco_asm_src);
  629:                 }
  630:         if (($des_enc_obj ne "") && ($_ eq "CRYPTO"))
  631:                 {
  632:                 $lib_obj =~ s/\s\S*des_enc\S*/ \$(DES_ENC_OBJ)/;
  633:                 $lib_obj =~ s/\s\S*\/fcrypt_b\S*\s*/ /;
  634:                 $rules.=&do_asm_rule($des_enc_obj,$des_enc_src);
  635:                 }
  636:         if (($bf_enc_obj ne "") && ($_ eq "CRYPTO"))
  637:                 {
  638:                 $lib_obj =~ s/\s\S*\/bf_enc\S*/ \$(BF_ENC_OBJ)/;
  639:                 $rules.=&do_asm_rule($bf_enc_obj,$bf_enc_src);
  640:                 }
  641:         if (($cast_enc_obj ne "") && ($_ eq "CRYPTO"))
  642:                 {
  643:                 $lib_obj =~ s/(\s\S*\/c_enc\S*)/ \$(CAST_ENC_OBJ)/;
  644:                 $rules.=&do_asm_rule($cast_enc_obj,$cast_enc_src);
  645:                 }
  646:         if (($rc4_enc_obj ne "") && ($_ eq "CRYPTO"))
  647:                 {
  648:                 $lib_obj =~ s/\s\S*\/rc4_enc\S*/ \$(RC4_ENC_OBJ)/;
  649:                 $rules.=&do_asm_rule($rc4_enc_obj,$rc4_enc_src);
  650:                 }
  651:         if (($rc5_enc_obj ne "") && ($_ eq "CRYPTO"))
  652:                 {
  653:                 $lib_obj =~ s/\s\S*\/rc5_enc\S*/ \$(RC5_ENC_OBJ)/;
  654:                 $rules.=&do_asm_rule($rc5_enc_obj,$rc5_enc_src);
  655:                 }
  656:         if (($md5_asm_obj ne "") && ($_ eq "CRYPTO"))
  657:                 {
  658:                 $lib_obj =~ s/\s(\S*\/md5_dgst\S*)/ $1 \$(MD5_ASM_OBJ)/;
  659:                 $rules.=&do_asm_rule($md5_asm_obj,$md5_asm_src);
  660:                 }
  661:         if (($sha1_asm_obj ne "") && ($_ eq "CRYPTO"))
  662:                 {
  663:                 $lib_obj =~ s/\s(\S*\/sha1dgst\S*)/ $1 \$(SHA1_ASM_OBJ)/;
  664:                 $rules.=&do_asm_rule($sha1_asm_obj,$sha1_asm_src);
  665:                 }
  666:         if (($rmd160_asm_obj ne "") && ($_ eq "CRYPTO"))
  667:                 {
  668:                 $lib_obj =~ s/\s(\S*\/rmd_dgst\S*)/ $1 \$(RMD160_ASM_OBJ)/;
  669:                 $rules.=&do_asm_rule($rmd160_asm_obj,$rmd160_asm_src);
  670:                 }
  671:         if (($cpuid_asm_obj ne "") && ($_ eq "CRYPTO"))
  672:                 {
  673:                 $lib_obj =~ s/\s(\S*\/cversion\S*)/ $1 \$(CPUID_ASM_OBJ)/;
  674:                 $rules.=&do_asm_rule($cpuid_asm_obj,$cpuid_asm_src);
  675:                 }
  676:         $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj);
  677:         $lib=($slib)?" \$(SHLIB_CFLAGS)".$shlib_ex_cflags{$_}:" \$(LIB_CFLAGS)";
  678:         $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib);
  679:         }
  680: 
  681: # hack to add version info on MSVC
  682: if (($platform eq "VC-WIN32") || ($platform eq "VC-NT")) {
  683:     $rules.= <<"EOF";
  684: \$(OBJ_D)\\\$(CRYPTO).res: ms\\version32.rc
  685:         \$(RSC) /fo"\$(OBJ_D)\\\$(CRYPTO).res" /d CRYPTO ms\\version32.rc
  686: 
  687: \$(OBJ_D)\\\$(SSL).res: ms\\version32.rc
  688:         \$(RSC) /fo"\$(OBJ_D)\\\$(SSL).res" /d SSL ms\\version32.rc
  689: 
  690: EOF
  691: }
  692: 
  693: $defs.=&do_defs("T_EXE",$test,"\$(TEST_D)",$exep);
  694: foreach (split(/\s+/,$test))
  695:         {
  696:         $t=&bname($_);
  697:         $tt="\$(OBJ_D)${o}$t${obj}";
  698:         $rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)");
  699:         }
  700: 
  701: $defs.=&do_defs("E_SHLIB",$engines,"\$(ENG_D)",$shlibp);
  702: 
  703: foreach (split(/\s+/,$engines))
  704:         {
  705:         $rules.=&do_compile_rule("\$(OBJ_D)","engines${o}e_$_",$lib);
  706:         $rules.= &do_lib_rule("\$(OBJ_D)${o}e_${_}.obj","\$(ENG_D)$o$_$shlibp","",$shlib,"");
  707:         }
  708: 
  709: 
  710: 
  711: $rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)");
  712: $rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)");
  713: 
  714: $rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)");
  715: 
  716: print $defs;
  717: 
  718: if ($platform eq "linux-elf") {
  719:     print <<"EOF";
  720: # Generate perlasm output files
  721: %.cpp:
  722:         (cd \$(\@D)/..; PERL=perl make -f Makefile asm/\$(\@F))
  723: EOF
  724: }
  725: print "###################################################################\n";
  726: print $rules;
  727: 
  728: ###############################################
  729: # strip off any trailing .[och] and append the relative directory
  730: # also remembering to do nothing if we are in one of the dropped
  731: # directories
  732: sub var_add
  733:         {
  734:         local($dir,$val,$keepext)=@_;
  735:         local(@a,$_,$ret);
  736: 
  737:         return("") if $no_engine && $dir =~ /\/engine/;
  738:         return("") if $no_hw   && $dir =~ /\/hw/;
  739:         return("") if $no_idea && $dir =~ /\/idea/;
  740:         return("") if $no_aes  && $dir =~ /\/aes/;
  741:         return("") if $no_camellia  && $dir =~ /\/camellia/;
  742:         return("") if $no_seed && $dir =~ /\/seed/;
  743:         return("") if $no_rc2  && $dir =~ /\/rc2/;
  744:         return("") if $no_rc4  && $dir =~ /\/rc4/;
  745:         return("") if $no_rc5  && $dir =~ /\/rc5/;
  746:         return("") if $no_rsa  && $dir =~ /\/rsa/;
  747:         return("") if $no_rsa  && $dir =~ /^rsaref/;
  748:         return("") if $no_dsa  && $dir =~ /\/dsa/;
  749:         return("") if $no_dh   && $dir =~ /\/dh/;
  750:         return("") if $no_ec   && $dir =~ /\/ec/;
  751:         if ($no_des && $dir =~ /\/des/)
  752:                 {
  753:                 if ($val =~ /read_pwd/)
  754:                         { return("$dir/read_pwd "); }
  755:                 else
  756:                         { return(""); }
  757:                 }
  758:         return("") if $no_mdc2 && $dir =~ /\/mdc2/;
  759:         return("") if $no_sock && $dir =~ /\/proxy/;
  760:         return("") if $no_bf   && $dir =~ /\/bf/;
  761:         return("") if $no_cast && $dir =~ /\/cast/;
  762: 
  763:         $val =~ s/^\s*(.*)\s*$/$1/;
  764:         @a=split(/\s+/,$val);
  765:         grep(s/\.[och]$//,@a) unless $keepext;
  766: 
  767:         @a=grep(!/^e_.*_3d$/,@a) if $no_des;
  768:         @a=grep(!/^e_.*_d$/,@a) if $no_des;
  769:         @a=grep(!/^e_.*_ae$/,@a) if $no_idea;
  770:         @a=grep(!/^e_.*_i$/,@a) if $no_aes;
  771:         @a=grep(!/^e_.*_r2$/,@a) if $no_rc2;
  772:         @a=grep(!/^e_.*_r5$/,@a) if $no_rc5;
  773:         @a=grep(!/^e_.*_bf$/,@a) if $no_bf;
  774:         @a=grep(!/^e_.*_c$/,@a) if $no_cast;
  775:         @a=grep(!/^e_rc4$/,@a) if $no_rc4;
  776:         @a=grep(!/^e_camellia$/,@a) if $no_camellia;
  777:         @a=grep(!/^e_seed$/,@a) if $no_seed;
  778: 
  779:         @a=grep(!/(^s2_)|(^s23_)/,@a) if $no_ssl2;
  780:         @a=grep(!/(^s3_)|(^s23_)/,@a) if $no_ssl3;
  781: 
  782:         @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock;
  783: 
  784: