Ignore zero length constructed segments.
[openssl.git] / util / mk1mf.pl
index 13c8222bceb35f331db29dfc2aaead3d51f9458f..a0ec39e5f06a35b29cd16822425f9cfc9bce20de 100755 (executable)
@@ -12,6 +12,8 @@ $banner="\t\@echo Building OpenSSL";
 
 my $no_static_engine = 1;
 my $engines = "";
+local $zlib_opt = 0;   # 0 = no zlib, 1 = static, 2 = dynamic
+local $zlib_lib = "";
 
 
 open(IN,"<Makefile") || die "unable to open Makefile!\n";
@@ -113,7 +115,8 @@ $out_def="out";
 $inc_def="outinc";
 $tmp_def="tmp";
 
-$mkdir="-mkdir";
+$perl="perl" unless defined $perl;
+$mkdir="-mkdir" unless defined $mkdir;
 
 ($ssl,$crypto)=("ssl","crypto");
 $ranlib="echo ranlib";
@@ -210,6 +213,7 @@ $cflags.=" -DOPENSSL_NO_DES"  if $no_des;
 $cflags.=" -DOPENSSL_NO_RSA"  if $no_rsa;
 $cflags.=" -DOPENSSL_NO_DSA"  if $no_dsa;
 $cflags.=" -DOPENSSL_NO_DH"   if $no_dh;
+$cflags.=" -DOPENSSL_NO_WHIRLPOOL"   if $no_whirlpool;
 $cflags.=" -DOPENSSL_NO_SOCK" if $no_sock;
 $cflags.=" -DOPENSSL_NO_SSL2" if $no_ssl2;
 $cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3;
@@ -221,6 +225,9 @@ $cflags.=" -DOPENSSL_NO_ECDH" if $no_ecdh;
 $cflags.=" -DOPENSSL_NO_ENGINE"   if $no_engine;
 $cflags.=" -DOPENSSL_NO_HW"   if $no_hw;
 
+$cflags.= " -DZLIB" if $zlib_opt;
+$cflags.= " -DZLIB_SHARED" if $zlib_opt == 2;
+
 if ($no_static_engine)
        {
        $cflags .= " -DOPENSSL_NO_STATIC_ENGINE";
@@ -239,6 +246,7 @@ else
 
 $ex_libs="$l_flags$ex_libs" if ($l_flags ne "");
 
+
 %shlib_ex_cflags=("SSL" => " -DOPENSSL_BUILD_SHLIBSSL",
                  "CRYPTO" => " -DOPENSSL_BUILD_SHLIBCRYPTO");
 
@@ -283,8 +291,14 @@ for (;;)
        if ($key eq "KRB5_INCLUDES")
                { $cflags .= " $val";}
 
+       if ($key eq "ZLIB_INCLUDE")
+               { $cflags .= " $val" if $val ne "";}
+
+       if ($key eq "LIBZLIB")
+               { $zlib_lib = "$val" if $val ne "";}
+
        if ($key eq "LIBKRB5")
-               { $ex_libs .= " $val";}
+               { $ex_libs .= " $val" if $val ne "";}
 
        if ($key eq "TEST")
                { $test.=&var_add($dir,$val, 0); }
@@ -314,6 +328,31 @@ for (;;)
        }
 close(IN);
 
+if ($shlib)
+       {
+       $extra_install= <<"EOF";
+       \$(CP) \$(O_SSL) \$(INSTALLTOP)${o}bin
+       \$(CP) \$(O_CRYPTO) \$(INSTALLTOP)${o}bin
+       \$(CP) \$(L_SSL) \$(INSTALLTOP)${o}lib
+       \$(CP) \$(L_CRYPTO) \$(INSTALLTOP)${o}lib
+EOF
+       if ($no_static_engine)
+               {
+               $extra_install .= <<"EOF"
+       \$(MKDIR) \$(INSTALLTOP)${o}lib${o}engines
+       \$(CP) \$(E_SHLIB) \$(INSTALLTOP)${o}lib${o}engines
+EOF
+               }
+       }
+else
+       {
+       $extra_install= <<"EOF";
+       \$(CP) \$(O_SSL) \$(INSTALLTOP)${o}lib
+       \$(CP) \$(O_CRYPTO) \$(INSTALLTOP)${o}lib
+EOF
+       $ex_libs .= " $zlib_lib" if $zlib_opt == 1;
+       }
+
 $defs= <<"EOF";
 # This makefile has been automatically generated from the OpenSSL distribution.
 # This single makefile will build the complete OpenSSL distribution and
@@ -375,6 +414,10 @@ SHA1_ASM_OBJ=$sha1_asm_obj
 SHA1_ASM_SRC=$sha1_asm_src
 RMD160_ASM_OBJ=$rmd160_asm_obj
 RMD160_ASM_SRC=$rmd160_asm_src
+WHIRLPOOL_ASM_OBJ=$whirlpool_asm_obj
+WHIRLPOOL_ASM_SRC=$whirlpool_asm_src
+CPUID_ASM_OBJ=$cpuid_asm_obj
+CPUID_ASM_SRC=$cpuid_asm_src
 
 # The output directory for everything intersting
 OUT_D=$out_dir
@@ -384,6 +427,7 @@ TMP_D=$tmp_dir
 INC_D=$inc_dir
 INCO_D=$inc_dir${o}openssl
 
+PERL=$perl
 CP=$cp
 RM=$rm
 RANLIB=$ranlib
@@ -470,7 +514,7 @@ lib: \$(LIBS_DEP) \$(E_SHLIB)
 
 exe: \$(T_EXE) \$(BIN_D)$o\$(E_EXE)$exep
 
-install:
+install: all
        \$(MKDIR) \$(INSTALLTOP)
        \$(MKDIR) \$(INSTALLTOP)${o}bin
        \$(MKDIR) \$(INSTALLTOP)${o}include
@@ -478,8 +522,13 @@ install:
        \$(MKDIR) \$(INSTALLTOP)${o}lib
        \$(CP) \$(INCO_D)${o}*.\[ch\] \$(INSTALLTOP)${o}include${o}openssl
        \$(CP) \$(BIN_D)$o\$(E_EXE)$exep \$(INSTALLTOP)${o}bin
-       \$(CP) \$(O_SSL) \$(INSTALLTOP)${o}lib
-       \$(CP) \$(O_CRYPTO) \$(INSTALLTOP)${o}lib
+       \$(CP) apps${o}openssl.cnf \$(INSTALLTOP)
+$extra_install
+
+
+test: \$(T_EXE)
+       cd \$(BIN_D)
+       ..${o}ms${o}test
 
 clean:
        \$(RM) \$(TMP_D)$o*.*
@@ -612,6 +661,16 @@ foreach (values %lib_nam)
                $lib_obj =~ s/\s(\S*\/rmd_dgst\S*)/ $1 \$(RMD160_ASM_OBJ)/;
                $rules.=&do_asm_rule($rmd160_asm_obj,$rmd160_asm_src);
                }
+       if (($whirlpool_asm_obj ne "") && ($_ eq "CRYPTO"))
+               {
+               $lib_obj =~ s/\s(\S*\/wp_dgst\S*)/ $1 \$(WHIRLPOOL_ASM_OBJ)/;
+               $rules.=&do_asm_rule($whirlpool_asm_obj,$whirlpool_asm_src);
+               }
+       if (($cpuid_asm_obj ne "") && ($_ eq "CRYPTO"))
+               {
+               $lib_obj =~ s/\s(\S*\/cversion\S*)/ $1 \$(CPUID_ASM_OBJ)/;
+               $rules.=&do_asm_rule($cpuid_asm_obj,$cpuid_asm_src);
+               }
        $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj);
        $lib=($slib)?" \$(SHLIB_CFLAGS)".$shlib_ex_cflags{$_}:" \$(LIB_CFLAGS)";
        $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib);
@@ -696,6 +755,7 @@ sub var_add
        return("") if $no_sock && $dir =~ /\/proxy/;
        return("") if $no_bf   && $dir =~ /\/bf/;
        return("") if $no_cast && $dir =~ /\/cast/;
+       return("") if $no_whirlpool && $dir =~ /\/whrlpool/;
 
        $val =~ s/^\s*(.*)\s*$/$1/;
        @a=split(/\s+/,$val);
@@ -794,13 +854,15 @@ sub do_defs
                elsif ($_ =~ /MD5_ASM/) { $t="$_ "; }
                elsif ($_ =~ /SHA1_ASM/){ $t="$_ "; }
                elsif ($_ =~ /RMD160_ASM/){ $t="$_ "; }
+               elsif ($_ =~ /WHIRLPOOL_ASM/){ $t="$_ "; }
+               elsif ($_ =~ /CPUID_ASM/){ $t="$_ "; }
                else    { $t="$location${o}$_$pf "; }
 
                $Vars{$var}.="$t ";
                $ret.=$t;
                }
        # hack to add version info on MSVC
-       if ($shlib && ($platform eq "VC-WIN32") || ($platform eq "VC-NT"))
+       if ($shlib && (($platform eq "VC-WIN32") || ($platform eq "VC-NT")))
                {
                if ($var eq "CRYPTOOBJ")
                        { $ret.="\$(OBJ_D)\\\$(CRYPTO).res "; }
@@ -930,6 +992,7 @@ sub read_options
                "no-sha1" => \$no_sha1,
                "no-ripemd" => \$no_ripemd,
                "no-mdc2" => \$no_mdc2,
+               "no-whirlpool" => \$no_whirlpool,
                "no-patents" => 
                        [\$no_rc2, \$no_rc4, \$no_rc5, \$no_idea, \$no_rsa],
                "no-rsa" => \$no_rsa,
@@ -985,10 +1048,10 @@ sub read_options
                        }
                }
        elsif (/^no-comp$/) { $xcflags = "-DOPENSSL_NO_COMP $xcflags"; }
-       elsif (/^enable-zlib$/) { $xcflags = "-DZLIB $xcflags"; }
+       elsif (/^enable-zlib$/) { $zlib_opt = 1 if $zlib_opt == 0 }
        elsif (/^enable-zlib-dynamic$/)
                {
-               $xcflags = "-DZLIB_SHARED -DZLIB $xcflags";
+               $zlib_opt = 2;
                }
        elsif (/^no-static-engine/)
                {