"make depend"
[openssl.git] / util / mkdef.pl
index e1f2ca99a10571bb911b830e5a0a4c8fd3c59c43..4a94dc4dbdd25380da44df07b375a8611058a7dc 100755 (executable)
@@ -9,11 +9,18 @@
 $crypto_num="util/libeay.num";
 $ssl_num=   "util/ssleay.num";
 
-$NT=1;
+$W32=1;
+$NT=0;
+# Set this to make typesafe STACK definitions appear in DEF
+$safe_stack_def = 1;
 foreach (@ARGV)
        {
-       $NT=1 if $_ eq "32";
-       $NT=0 if $_ eq "16";
+       $W32=1 if $_ eq "32";
+       $W32=0 if $_ eq "16";
+       if($_ eq "NT") {
+               $W32 = 1;
+               $NT = 1;
+       }
        $do_ssl=1 if $_ eq "ssleay";
        $do_ssl=1 if $_ eq "ssl";
        $do_crypto=1 if $_ eq "libeay";
@@ -68,6 +75,7 @@ $crypto.=" crypto/asn1/asn1.h";
 $crypto.=" crypto/asn1/asn1_mac.h";
 $crypto.=" crypto/err/err.h";
 $crypto.=" crypto/pkcs7/pkcs7.h";
+$crypto.=" crypto/pkcs12/pkcs12.h";
 $crypto.=" crypto/x509/x509.h";
 $crypto.=" crypto/x509/x509_vfy.h";
 $crypto.=" crypto/x509v3/x509v3.h";
@@ -167,22 +175,48 @@ sub do_defs
                                $tag{$t}= -$tag{$t};
                                next;
                                }
-#printf STDERR "$_\n%2d %2d %2d %2d %2d $NT\n",
+#printf STDERR "$_\n%2d %2d %2d %2d %2d $W32\n",
 #$tag{'NOPROTO'},$tag{'FreeBSD'},$tag{'WIN16'},$tag{'PERL5'},$tag{'NO_FP_API'};
 
                        $t=undef;
                        if (/^extern .*;$/)
                                { $t=&do_extern($name,$_); }
-                       elsif ( ($tag{'NOPROTO'} == 1) &&
+                       elsif ($safe_stack_def &&
+                               /^\s*DECLARE_STACK_OF\s*\(\s*(\w*)\s*\)/)
+                               {
+                               push(@ret,"sk_${1}_new");
+                               push(@ret,"sk_${1}_new_null");
+                               push(@ret,"sk_${1}_free");
+                               push(@ret,"sk_${1}_num");
+                               push(@ret,"sk_${1}_value");
+                               push(@ret,"sk_${1}_set");
+                               push(@ret,"sk_${1}_zero");
+                               push(@ret,"sk_${1}_push");
+                               push(@ret,"sk_${1}_pop");
+                               push(@ret,"sk_${1}_find");
+                               push(@ret,"sk_${1}_delete");
+                               push(@ret,"sk_${1}_delete_ptr");
+                               push(@ret,"sk_${1}_set_cmp_func");
+                               push(@ret,"sk_${1}_dup");
+                               push(@ret,"sk_${1}_pop_free");
+                               push(@ret,"sk_${1}_shift");
+                               }
+                       elsif ($safe_stack_def &&
+                               /^\s*DECLARE_ASN1_SET_OF\s*\(\s*(\w*)\s*\)/)
+                               {
+                               push(@ret,"d2i_ASN1_SET_OF_${1}");
+                               push(@ret,"i2d_ASN1_SET_OF_${1}");
+                               }
+                       elsif (($tag{'NOPROTO'} == 1) &&
                                ($tag{'FreeBSD'} != 1) &&
-                               (($NT && ($tag{'WIN16'} != 1)) ||
-                                (!$NT && ($tag{'WIN16'} != -1))) &&
+                               (($W32 && ($tag{'WIN16'} != 1)) ||
+                                (!$W32 && ($tag{'WIN16'} != -1))) &&
                                ($tag{'PERL5'} != 1) &&
 #                              ($tag{'_WINDLL'} != -1) &&
-                               ((!$NT && $tag{'_WINDLL'} != -1) ||
-                                ($NT && $tag{'_WINDLL'} != 1)) &&
-                               ((($tag{'NO_FP_API'} != 1) && $NT) ||
-                                (($tag{'NO_FP_API'} != -1) && !$NT)))
+                               ((!$W32 && $tag{'_WINDLL'} != -1) ||
+                                ($W32 && $tag{'_WINDLL'} != 1)) &&
+                               ((($tag{'NO_FP_API'} != 1) && $W32) ||
+                                (($tag{'NO_FP_API'} != -1) && !$W32)))
                                { $t=&do_line($name,$_); }
                        else
                                { $t=undef; }
@@ -216,24 +250,31 @@ sub do_line
                { return($1); }
        elsif (/(SSL_get_info_callback)/)
                { return($1); }
-       elsif ((!$NT) && /(ERR_load_CRYPTO_strings)/)
+       elsif ((!$W32) && /(ERR_load_CRYPTO_strings)/)
                { return("ERR_load_CRYPTOlib_strings"); }
-       elsif (!$NT && /BIO_s_file/)
+       elsif (!$W32 && /BIO_s_file/)
+               { return(undef); }
+       elsif (!$W32 && /BIO_new_file/)
+               { return(undef); }
+       elsif (!$W32 && /BIO_new_fp/)
                { return(undef); }
-       elsif (!$NT && /BIO_new_file/)
+       elsif ($W32 && /BIO_s_file_internal/)
                { return(undef); }
-       elsif (!$NT && /BIO_new_fp/)
+       elsif ($W32 && /BIO_new_file_internal/)
                { return(undef); }
-       elsif ($NT && /BIO_s_file_internal/)
+       elsif ($W32 && /BIO_new_fp_internal/)
                { return(undef); }
-       elsif ($NT && /BIO_new_file_internal/)
+        elsif (/SSL_add_dir_cert_subjects_to_stack/)
                { return(undef); }
-       elsif ($NT && /BIO_new_fp_internal/)
+       elsif (!$NT && /BIO_s_log/)
                { return(undef); }
        else
                {
                /\s\**(\S+)\s*\(/;
-               return($1);
+               $_ = $1;
+               tr/()*//d;
+#print STDERR "$1 : $_\n";
+               return($_);
                }
        }
 
@@ -251,7 +292,7 @@ sub print_def_file
        local(*OUT,$name,*nums,@functions)=@_;
        local($n)=1;
 
-       if ($NT)
+       if ($W32)
                { $name.="32"; }
        else
                { $name.="16"; }
@@ -267,7 +308,7 @@ DESCRIPTION     'OpenSSL $name - http://www.openssl.org/'
 
 EOF
 
-       if (!$NT)
+       if (!$W32)
                {
                print <<"EOF";
 CODE            PRELOAD MOVEABLE
@@ -298,7 +339,7 @@ EOF
                else
                        {
                        $n=$nums{$func};
-                       printf OUT "    %s%-40s@%d\n",($NT)?"":"_",$func,$n;
+                       printf OUT "    %s%-40s@%d\n",($W32)?"":"_",$func,$n;
                        }
                }
        printf OUT "\n";