Modify configure script to generate some files that Win32 needs and new
[openssl.git] / util / mkdef.pl
index a62e3ee..e1f2ca9 100755 (executable)
@@ -15,7 +15,10 @@ foreach (@ARGV)
        $NT=1 if $_ eq "32";
        $NT=0 if $_ eq "16";
        $do_ssl=1 if $_ eq "ssleay";
        $NT=1 if $_ eq "32";
        $NT=0 if $_ eq "16";
        $do_ssl=1 if $_ eq "ssleay";
+       $do_ssl=1 if $_ eq "ssl";
        $do_crypto=1 if $_ eq "libeay";
        $do_crypto=1 if $_ eq "libeay";
+       $do_crypto=1 if $_ eq "crypto";
+       $do_update=1 if $_ eq "update";
        }
 
 if (!$do_ssl && !$do_crypto)
        }
 
 if (!$do_ssl && !$do_crypto)
@@ -25,7 +28,9 @@ if (!$do_ssl && !$do_crypto)
        }
 
 %ssl_list=&load_numbers($ssl_num);
        }
 
 %ssl_list=&load_numbers($ssl_num);
+$max_ssl = $max_num;
 %crypto_list=&load_numbers($crypto_num);
 %crypto_list=&load_numbers($crypto_num);
+$max_crypto = $max_num;
 
 $ssl="ssl/ssl.h";
 
 
 $ssl="ssl/ssl.h";
 
@@ -74,11 +79,33 @@ $crypto.=" crypto/tmdiff.h";
 $match{'NOPROTO'}=1;
 $match2{'PERL5'}=1;
 
 $match{'NOPROTO'}=1;
 $match2{'PERL5'}=1;
 
-&print_def_file(*STDOUT,"SSLEAY",*ssl_list,&do_defs("SSLEAY",$ssl))
-       if $do_ssl == 1;
+@ssl_func = &do_defs("SSLEAY", $ssl);
+@crypto_func = &do_defs("LIBEAY", $crypto);
+
+if ($do_update) {
+
+if ($do_ssl == 1) {
+       open(OUT, ">>$ssl_num");
+       &update_numbers(*OUT,"SSLEAY",*ssl_list,$max_ssl, @ssl_func);
+       close OUT;
+}
+
+if($do_crypto == 1) {
+       open(OUT, ">>$crypto_num");
+       &update_numbers(*OUT,"LIBEAY",*crypto_list,$max_crypto, @crypto_func);
+       close OUT;
+}
+
+} else {
+
+       &print_def_file(*STDOUT,"SSLEAY",*ssl_list,@ssl_func)
+               if $do_ssl == 1;
+
+       &print_def_file(*STDOUT,"LIBEAY",*crypto_list,@crypto_func)
+               if $do_crypto == 1;
+
+}
 
 
-&print_def_file(*STDOUT,"LIBEAY",*crypto_list,&do_defs("LIBEAY",$crypto))
-       if $do_crypto == 1;
 
 sub do_defs
        {
 
 sub do_defs
        {
@@ -98,7 +125,7 @@ sub do_defs
                while (($i=index($a,"/*")) >= 0)
                        {
                        $j=index($a,"*/");
                while (($i=index($a,"/*")) >= 0)
                        {
                        $j=index($a,"*/");
-                       break unless ($j >= 0);
+                       last unless ($j >= 0);
                        $a=substr($a,0,$i).substr($a,$j+2);
                #       print "$i $j\n";
                        }
                        $a=substr($a,0,$i).substr($a,$j+2);
                #       print "$i $j\n";
                        }
@@ -231,12 +258,12 @@ sub print_def_file
 
        print OUT <<"EOF";
 ;
 
        print OUT <<"EOF";
 ;
-; Definition file for the DDL version of the $name library from SSLeay
+; Definition file for the DLL version of the $name library from OpenSSL
 ;
 
 LIBRARY         $name
 
 ;
 
 LIBRARY         $name
 
-DESCRIPTION     'SSLeay $name - eay\@cryptsoft.com'
+DESCRIPTION     'OpenSSL $name - http://www.openssl.org/'
 
 EOF
 
 
 EOF
 
@@ -265,12 +292,13 @@ EOF
                {
                if (!defined($nums{$func}))
                        {
                {
                if (!defined($nums{$func}))
                        {
-                       printf STDERR "$func does not have a number assigned\n";
+                       printf STDERR "$func does not have a number assigned\n"
+                                       if(!$do_update);
                        }
                else
                        {
                        $n=$nums{$func};
                        }
                else
                        {
                        $n=$nums{$func};
-                       printf OUT "    %s%-35s@%d\n",($NT)?"":"_",$func,$n;
+                       printf OUT "    %s%-40s@%d\n",($NT)?"":"_",$func,$n;
                        }
                }
        printf OUT "\n";
                        }
                }
        printf OUT "\n";
@@ -281,6 +309,8 @@ sub load_numbers
        local($name)=@_;
        local($j,@a,%ret);
 
        local($name)=@_;
        local($j,@a,%ret);
 
+       $max_num = 0;
+
        open(IN,"<$name") || die "unable to open $name:$!\n";
        while (<IN>)
                {
        open(IN,"<$name") || die "unable to open $name:$!\n";
        while (<IN>)
                {
@@ -289,7 +319,28 @@ sub load_numbers
                next if /^\s*$/;
                @a=split;
                $ret{$a[0]}=$a[1];
                next if /^\s*$/;
                @a=split;
                $ret{$a[0]}=$a[1];
+               $max_num = $a[1] if $a[1] > $max_num;
                }
        close(IN);
        return(%ret);
        }
                }
        close(IN);
        return(%ret);
        }
+
+sub update_numbers
+       {
+       local(*OUT,$name,*nums,$start_num, @functions)=@_;
+       my $new_funcs = 0;
+       print STDERR "Updating $name\n";
+       foreach $func (@functions)
+               {
+               if (!defined($nums{$func}))
+                       {
+                       $new_funcs++;
+                       printf OUT "%s%-40s%d\n","",$func, ++$start_num;
+                       }
+               }
+       if($new_funcs) {
+               print STDERR "$new_funcs New Functions added\n";
+       } else {
+               print STDERR "No New Functions Added\n";
+       }
+       }