Fix installation on VC-WIN32 with nmake
[oweals/openssl.git] / util / mk1mf.pl
index 324871f629da77fd1e8a2d1cbcccc8ea2c197634..6b31496ed1e694ff2bba7044dace14dc99a095fc 100755 (executable)
@@ -52,6 +52,7 @@ my %mf_import = (
         ENGINES_ASM_OBJ=> \$mf_engines_asm,
        BASEADDR       => \$baseaddr,
        FIPSDIR        => \$fipsdir,
+       EC_ASM         => \$mf_ec_asm,
 );
 
 open(IN,"<Makefile") || die "unable to open Makefile!\n";
@@ -276,6 +277,7 @@ $cflags.=" -DOPENSSL_NO_SOCK" if $no_sock;
 $cflags.=" -DOPENSSL_NO_SSL2" if $no_ssl2;
 $cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3;
 $cflags.=" -DOPENSSL_NO_TLSEXT" if $no_tlsext;
+$cflags.=" -DOPENSSL_NO_TLS1" if $no_tls1;
 $cflags.=" -DOPENSSL_NO_SRP" if $no_srp;
 $cflags.=" -DOPENSSL_NO_CMS" if $no_cms;
 $cflags.=" -DOPENSSL_NO_ERR"  if $no_err;
@@ -289,8 +291,10 @@ $cflags.=" -DOPENSSL_NO_HW"   if $no_hw;
 $cflags.=" -DOPENSSL_FIPS"    if $fips;
 $cflags.=" -DOPENSSL_NO_JPAKE"    if $no_jpake;
 $cflags.=" -DOPENSSL_NO_EC2M"    if $no_ec2m;
-$cflags.= " -DZLIB" if $zlib_opt;
-$cflags.= " -DZLIB_SHARED" if $zlib_opt == 2;
+$cflags.=" -DOPENSSL_NO_WEAK_SSL_CIPHERS"   if $no_weak_ssl;
+$cflags.=" -DZLIB" if $zlib_opt;
+$cflags.=" -DZLIB_SHARED" if $zlib_opt == 2;
+$cflags.=" -DOPENSSL_NO_COMP" if $no_comp;
 
 if ($no_static_engine)
        {
@@ -339,7 +343,7 @@ open(IN,"<$infile") || die "unable to open $infile:$!\n";
 $_=<IN>;
 for (;;)
        {
-       chop;
+       s/\s*$//; # was chop, didn't work in mixture of perls for Windows...
 
        ($key,$val)=/^([^=]+)=(.*)/;
        if ($key eq "RELATIVE_DIRECTORY")
@@ -404,10 +408,13 @@ for (;;)
        }
 close(IN);
 
-# Remove opensslconf.h so it doesn't get updated if we configure a
-# different branch.
-$exheader =~ s/[^ ]+\/opensslconf.h//;
-$header =~ s/[^ ]+\/opensslconf.h//;
+if ($orig_platform eq 'copy')
+       {
+       # Remove opensslconf.h so it doesn't get updated if we configure a
+       # different branch.
+       $exheader =~ s/[^ ]+\/opensslconf.h//;
+       $header =~ s/[^ ]+\/opensslconf.h//;
+       }
 
 if ($shlib)
        {
@@ -421,7 +428,7 @@ EOF
                {
                $extra_install .= <<"EOF"
        \$(MKDIR) \"\$(INSTALLTOP)${o}lib${o}engines\"
-       \$(CP) \"\$(E_SHLIB)\" \"\$(INSTALLTOP)${o}lib${o}engines\"
+       \$(CP) \$(E_SHLIB) \"\$(INSTALLTOP)${o}lib${o}engines\"
 EOF
                }
        }
@@ -443,7 +450,7 @@ $defs= <<"EOF";
 # N.B. You MUST use -j on FreeBSD.
 # This makefile has been automatically generated from the OpenSSL distribution.
 # This single makefile will build the complete OpenSSL distribution and
-# by default leave the 'intertesting' output files in .${o}out and the stuff
+# by default leave the 'interesting' output files in .${o}out and the stuff
 # that needs deleting in .${o}tmp.
 # The file was generated by running 'make makefile.one', which
 # does a 'make files', which writes all the environment variables from all
@@ -478,7 +485,7 @@ EX_LIBS=$ex_libs
 # The OpenSSL directory
 SRC_D=$src_dir
 
-LINK=$link
+LINK_CMD=$link
 LFLAGS=$lflags
 RSC=$rsc
 
@@ -601,7 +608,7 @@ install: all
        \$(MKDIR) \"\$(INSTALLTOP)${o}include${o}openssl\"
        \$(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) \"\$(BIN_D)$o\$(E_EXE)$exep\" \"\$(INSTALLTOP)${o}bin\"
        \$(MKDIR) \"\$(OPENSSLDIR)\"
        \$(CP) apps${o}openssl.cnf \"\$(OPENSSLDIR)\"
 $extra_install
@@ -661,7 +668,7 @@ open (OUT,">>crypto/buildinf.h") || die "Can't open buildinf.h";
 printf OUT <<EOF;
 #ifdef $platform_cpp_symbol
   /* auto-generated/updated by util/mk1mf.pl for crypto/cversion.c */
-  #define CFLAGS "$cc $cflags"
+  #define CFLAGS "compiler: $cc $cflags"
   #define PLATFORM "$platform"
 EOF
 printf OUT "  #define DATE \"%s\"\n", scalar gmtime();
@@ -686,8 +693,8 @@ $rules.=&do_copy_rule("\$(INCL_D)",$header,"");
 $defs.=&do_defs("EXHEADER",$exheader,"\$(INCO_D)","");
 $rules.=&do_copy_rule("\$(INCO_D)",$exheader,"");
 
-$defs.=&do_defs("T_OBJ",$test,"\$(OBJ_D)",$obj);
-$rules.=&do_compile_rule("\$(OBJ_D)",$test,"\$(APP_CFLAGS)");
+$defs.=&do_defs("T_OBJ","$test test${o}ssltestlib","\$(OBJ_D)",$obj);
+$rules.=&do_compile_rule("\$(OBJ_D)","$test test${o}ssltestlib","\$(APP_CFLAGS)");
 
 $defs.=&do_defs("E_OBJ",$e_exe,"\$(OBJ_D)",$obj);
 $rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)');
@@ -727,6 +734,7 @@ if ($orig_platform eq 'copy') {
        $lib_obj{CRYPTO} .= fix_asm($mf_engines_asm, 'engines');
        $lib_obj{CRYPTO} .= fix_asm($mf_rc4_asm, 'crypto/rc4');
        $lib_obj{CRYPTO} .= fix_asm($mf_modes_asm, 'crypto/modes');
+       $lib_obj{CRYPTO} .= fix_asm($mf_ec_asm, 'crypto/ec');
 }
 
 foreach (values %lib_nam)
@@ -734,12 +742,6 @@ foreach (values %lib_nam)
        $lib_obj=$lib_obj{$_};
        local($slib)=$shlib;
 
-       if (($_ eq "SSL") && $no_ssl2 && $no_ssl3)
-               {
-               $rules.="\$(O_SSL):\n\n"; 
-               next;
-               }
-
        $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);
@@ -763,6 +765,7 @@ foreach (split(/\s+/,$test))
        {
        $t=&bname($_);
        $tt="\$(OBJ_D)${o}$t${obj}";
+       $tt.=" \$(OBJ_D)${o}ssltestlib${obj}" if $t eq "dtlstest";
        $rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)");
        }
 
@@ -850,6 +853,7 @@ sub var_add
        return("") if $no_gost   && $dir =~ /\/ccgost/;
        return("") if $no_cms  && $dir =~ /\/cms/;
        return("") if $no_jpake  && $dir =~ /\/jpake/;
+       return("") if $no_comp && $dir =~ /\/comp/;
        if ($no_des && $dir =~ /\/des/)
                {
                if ($val =~ /read_pwd/)
@@ -1155,12 +1159,17 @@ sub do_copy_rule
        return($ret);
        }
 
+# Options picked up from the OPTIONS line in the top level Makefile
+# generated by Configure.
+
 sub read_options
        {
        # Many options are handled in a similar way. In particular
        # no-xxx sets zero or more scalars to 1.
-       # Process these using a hash containing the option name and
-       # reference to the scalars to set.
+       # Process these using the %valid_options hash containing the option
+       # name and reference to the scalars to set. In some cases the option
+       # needs no special handling and can be ignored: this is done by
+       # setting the value to 0.
 
        my %valid_options = (
                "no-rc2" => \$no_rc2,
@@ -1193,13 +1202,18 @@ sub read_options
                "nw-mwasm" => \$nw_mwasm,
                "gaswin" => \$gaswin,
                "no-ssl2" => \$no_ssl2,
+               "no-ssl2-method" => 0,
                "no-ssl3" => \$no_ssl3,
+               "no-ssl3-method" => 0,
                "no-tlsext" => \$no_tlsext,
+               "no-tls1" => \$no_tls1,
+               "no-dtls1" => 0,
                "no-srp" => \$no_srp,
                "no-cms" => \$no_cms,
                "no-jpake" => \$no_jpake,
                "no-ec2m" => \$no_ec2m,
                "no-ec_nistp_64_gcc_128" => 0,
+               "no-weak-ssl-ciphers" => \$no_weak_ssl,
                "no-err" => \$no_err,
                "no-sock" => \$no_sock,
                "no-krb5" => \$no_krb5,
@@ -1223,6 +1237,7 @@ sub read_options
                "dll" => \$shlib,
                "shared" => 0,
                "no-sctp" => 0,
+               "no-srtp" => 0,
                "no-gmp" => 0,
                "no-rfc3779" => 0,
                "no-montasm" => 0,
@@ -1231,9 +1246,10 @@ sub read_options
                "no-zlib" => 0,
                "no-zlib-dynamic" => 0,
                "no-ssl-trace" => 0,
-               "no-dane" => 0,
+               "no-unit-test" => 0,
                "no-libunbound" => 0,
                "no-multiblock" => 0,
+               "no-comp" => \$no_comp,
                "fips" => \$fips
                );
 
@@ -1251,7 +1267,6 @@ sub read_options
                                }
                        }
                }
-       elsif (/^no-comp$/) { $xcflags = "-DOPENSSL_NO_COMP $xcflags"; }
        elsif (/^enable-zlib$/) { $zlib_opt = 1 if $zlib_opt == 0 }
        elsif (/^enable-zlib-dynamic$/)
                {