summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/util')
-rw-r--r--src/lib/libcrypto/util/FreeBSD.sh6
-rw-r--r--src/lib/libcrypto/util/add_cr.pl123
-rw-r--r--src/lib/libcrypto/util/bat.sh134
-rw-r--r--src/lib/libcrypto/util/ck_errf.pl64
-rw-r--r--src/lib/libcrypto/util/clean-depend.pl58
-rw-r--r--src/lib/libcrypto/util/cygwin.sh154
-rw-r--r--src/lib/libcrypto/util/deleof.pl7
-rw-r--r--src/lib/libcrypto/util/dirname.pl18
-rw-r--r--src/lib/libcrypto/util/do_ms.sh19
-rw-r--r--src/lib/libcrypto/util/domd38
-rw-r--r--src/lib/libcrypto/util/err-ins.pl33
-rw-r--r--src/lib/libcrypto/util/extract-names.pl26
-rw-r--r--src/lib/libcrypto/util/files.pl61
-rw-r--r--src/lib/libcrypto/util/fixNT.sh14
-rw-r--r--src/lib/libcrypto/util/install.sh108
-rw-r--r--src/lib/libcrypto/util/mk1mf.pl1231
-rw-r--r--src/lib/libcrypto/util/mkcerts.sh220
-rw-r--r--src/lib/libcrypto/util/mkdef.pl1539
-rw-r--r--src/lib/libcrypto/util/mkdir-p.pl34
-rw-r--r--src/lib/libcrypto/util/mkerr.pl810
-rw-r--r--src/lib/libcrypto/util/mkfiles.pl143
-rw-r--r--src/lib/libcrypto/util/mklink.pl73
-rw-r--r--src/lib/libcrypto/util/mkstack.pl192
-rwxr-xr-xsrc/lib/libcrypto/util/opensslwrap.sh26
-rw-r--r--src/lib/libcrypto/util/perlpath.pl35
-rw-r--r--src/lib/libcrypto/util/pl/BC-32.pl139
-rw-r--r--src/lib/libcrypto/util/pl/Mingw32.pl104
-rw-r--r--src/lib/libcrypto/util/pl/OS2-EMX.pl120
-rw-r--r--src/lib/libcrypto/util/pl/VC-32.pl400
-rw-r--r--src/lib/libcrypto/util/pl/linux.pl104
-rw-r--r--src/lib/libcrypto/util/pl/ultrix.pl38
-rw-r--r--src/lib/libcrypto/util/pl/unix.pl (renamed from src/lib/libcrypto/util/pl/Mingw32f.pl)47
-rw-r--r--src/lib/libcrypto/util/pod2man.pl1184
-rw-r--r--src/lib/libcrypto/util/pod2mantest58
-rw-r--r--src/lib/libcrypto/util/pod2mantest.pod15
-rw-r--r--src/lib/libcrypto/util/point.sh10
-rw-r--r--src/lib/libcrypto/util/selftest.pl201
-rwxr-xr-xsrc/lib/libcrypto/util/shlib_wrap.sh97
-rw-r--r--src/lib/libcrypto/util/sp-diff.pl80
-rw-r--r--src/lib/libcrypto/util/speed.sh39
-rw-r--r--src/lib/libcrypto/util/src-dep.pl147
-rw-r--r--src/lib/libcrypto/util/tab_num.pl17
-rw-r--r--src/lib/libcrypto/util/x86asm.sh42
43 files changed, 7996 insertions, 12 deletions
diff --git a/src/lib/libcrypto/util/FreeBSD.sh b/src/lib/libcrypto/util/FreeBSD.sh
new file mode 100644
index 0000000000..db8edfc6aa
--- /dev/null
+++ b/src/lib/libcrypto/util/FreeBSD.sh
@@ -0,0 +1,6 @@
1#!/bin/sh
2
3perl util/perlpath.pl /usr/bin
4perl util/ssldir.pl /usr/local
5perl util/mk1mf.pl FreeBSD >Makefile.FreeBSD
6perl Configure FreeBSD
diff --git a/src/lib/libcrypto/util/add_cr.pl b/src/lib/libcrypto/util/add_cr.pl
new file mode 100644
index 0000000000..c7b62c11ec
--- /dev/null
+++ b/src/lib/libcrypto/util/add_cr.pl
@@ -0,0 +1,123 @@
1#!/usr/local/bin/perl
2#
3# This adds a copyright message to a souce code file.
4# It also gets the file name correct.
5#
6# perl util/add_cr.pl *.[ch] */*.[ch] */*/*.[ch]
7#
8
9foreach (@ARGV)
10 {
11 &dofile($_);
12 }
13
14sub dofile
15 {
16 local($file)=@_;
17
18 open(IN,"<$file") || die "unable to open $file:$!\n";
19
20 print STDERR "doing $file\n";
21 @in=<IN>;
22
23 return(1) if ($in[0] =~ / NOCW /);
24
25 @out=();
26 open(OUT,">$file.out") || die "unable to open $file.$$:$!\n";
27 push(@out,"/* $file */\n");
28 if (($in[1] !~ /^\/\* Copyright \(C\) [0-9-]+ Eric Young \(eay\@cryptsoft.com\)/))
29 {
30 push(@out,&Copyright);
31 $i=2;
32 @a=grep(/ Copyright \(C\) /,@in);
33 if ($#a >= 0)
34 {
35 while (($i <= $#in) && ($in[$i] ne " */\n"))
36 { $i++; }
37 $i++ if ($in[$i] eq " */\n");
38
39 while (($i <= $#in) && ($in[$i] =~ /^\s*$/))
40 { $i++; }
41
42 push(@out,"\n");
43 for ( ; $i <= $#in; $i++)
44 { push(@out,$in[$i]); }
45 }
46 else
47 { push(@out,@in); }
48 }
49 else
50 {
51 shift(@in);
52 push(@out,@in);
53 }
54 print OUT @out;
55 close(IN);
56 close(OUT);
57 rename("$file","$file.orig") || die "unable to rename $file:$!\n";
58 rename("$file.out",$file) || die "unable to rename $file.out:$!\n";
59 }
60
61
62
63sub Copyright
64 {
65 return <<'EOF';
66/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
67 * All rights reserved.
68 *
69 * This package is an SSL implementation written
70 * by Eric Young (eay@cryptsoft.com).
71 * The implementation was written so as to conform with Netscapes SSL.
72 *
73 * This library is free for commercial and non-commercial use as long as
74 * the following conditions are aheared to. The following conditions
75 * apply to all code found in this distribution, be it the RC4, RSA,
76 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
77 * included with this distribution is covered by the same copyright terms
78 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
79 *
80 * Copyright remains Eric Young's, and as such any Copyright notices in
81 * the code are not to be removed.
82 * If this package is used in a product, Eric Young should be given attribution
83 * as the author of the parts of the library used.
84 * This can be in the form of a textual message at program startup or
85 * in documentation (online or textual) provided with the package.
86 *
87 * Redistribution and use in source and binary forms, with or without
88 * modification, are permitted provided that the following conditions
89 * are met:
90 * 1. Redistributions of source code must retain the copyright
91 * notice, this list of conditions and the following disclaimer.
92 * 2. Redistributions in binary form must reproduce the above copyright
93 * notice, this list of conditions and the following disclaimer in the
94 * documentation and/or other materials provided with the distribution.
95 * 3. All advertising materials mentioning features or use of this software
96 * must display the following acknowledgement:
97 * "This product includes cryptographic software written by
98 * Eric Young (eay@cryptsoft.com)"
99 * The word 'cryptographic' can be left out if the rouines from the library
100 * being used are not cryptographic related :-).
101 * 4. If you include any Windows specific code (or a derivative thereof) from
102 * the apps directory (application code) you must include an acknowledgement:
103 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
104 *
105 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
106 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
107 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
108 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
109 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
110 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
111 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
112 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
113 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
114 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
115 * SUCH DAMAGE.
116 *
117 * The licence and distribution terms for any publically available version or
118 * derivative of this code cannot be changed. i.e. this code cannot simply be
119 * copied and put under another distribution licence
120 * [including the GNU Public Licence.]
121 */
122EOF
123 }
diff --git a/src/lib/libcrypto/util/bat.sh b/src/lib/libcrypto/util/bat.sh
new file mode 100644
index 0000000000..4d9a8287d0
--- /dev/null
+++ b/src/lib/libcrypto/util/bat.sh
@@ -0,0 +1,134 @@
1#!/usr/local/bin/perl
2
3$infile="/home/eay/ssl/SSLeay/MINFO";
4
5open(IN,"<$infile") || die "unable to open $infile:$!\n";
6$_=<IN>;
7for (;;)
8 {
9 chop;
10
11 ($key,$val)=/^([^=]+)=(.*)/;
12 if ($key eq "RELATIVE_DIRECTORY")
13 {
14 if ($lib ne "")
15 {
16 $uc=$lib;
17 $uc =~ s/^lib(.*)\.a/$1/;
18 $uc =~ tr/a-z/A-Z/;
19 $lib_nam{$uc}=$uc;
20 $lib_obj{$uc}.=$libobj." ";
21 }
22 last if ($val eq "FINISHED");
23 $lib="";
24 $libobj="";
25 $dir=$val;
26 }
27
28 if ($key eq "TEST")
29 { $test.=&var_add($dir,$val); }
30
31 if (($key eq "PROGS") || ($key eq "E_OBJ"))
32 { $e_exe.=&var_add($dir,$val); }
33
34 if ($key eq "LIB")
35 {
36 $lib=$val;
37 $lib =~ s/^.*\/([^\/]+)$/$1/;
38 }
39
40 if ($key eq "EXHEADER")
41 { $exheader.=&var_add($dir,$val); }
42
43 if ($key eq "HEADER")
44 { $header.=&var_add($dir,$val); }
45
46 if ($key eq "LIBSRC")
47 { $libsrc.=&var_add($dir,$val); }
48
49 if (!($_=<IN>))
50 { $_="RELATIVE_DIRECTORY=FINISHED\n"; }
51 }
52close(IN);
53
54@a=split(/\s+/,$libsrc);
55foreach (@a)
56 {
57 print "${_}.c\n";
58 }
59
60sub var_add
61 {
62 local($dir,$val)=@_;
63 local(@a,$_,$ret);
64
65 return("") if $no_engine && $dir =~ /\/engine/;
66 return("") if $no_idea && $dir =~ /\/idea/;
67 return("") if $no_rc2 && $dir =~ /\/rc2/;
68 return("") if $no_rc4 && $dir =~ /\/rc4/;
69 return("") if $no_rsa && $dir =~ /\/rsa/;
70 return("") if $no_rsa && $dir =~ /^rsaref/;
71 return("") if $no_dsa && $dir =~ /\/dsa/;
72 return("") if $no_dh && $dir =~ /\/dh/;
73 if ($no_des && $dir =~ /\/des/)
74 {
75 if ($val =~ /read_pwd/)
76 { return("$dir/read_pwd "); }
77 else
78 { return(""); }
79 }
80 return("") if $no_mdc2 && $dir =~ /\/mdc2/;
81 return("") if $no_sock && $dir =~ /\/proxy/;
82 return("") if $no_bf && $dir =~ /\/bf/;
83 return("") if $no_cast && $dir =~ /\/cast/;
84
85 $val =~ s/^\s*(.*)\s*$/$1/;
86 @a=split(/\s+/,$val);
87 grep(s/\.[och]$//,@a);
88
89 @a=grep(!/^e_.*_3d$/,@a) if $no_des;
90 @a=grep(!/^e_.*_d$/,@a) if $no_des;
91 @a=grep(!/^e_.*_i$/,@a) if $no_idea;
92 @a=grep(!/^e_.*_r2$/,@a) if $no_rc2;
93 @a=grep(!/^e_.*_bf$/,@a) if $no_bf;
94 @a=grep(!/^e_.*_c$/,@a) if $no_cast;
95 @a=grep(!/^e_rc4$/,@a) if $no_rc4;
96
97 @a=grep(!/(^s2_)|(^s23_)/,@a) if $no_ssl2;
98 @a=grep(!/(^s3_)|(^s23_)/,@a) if $no_ssl3;
99
100 @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock;
101
102 @a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2;
103 @a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5;
104
105 @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa;
106 @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa;
107 @a=grep(!/(^pem_seal$)/,@a) if $no_rsa;
108
109 @a=grep(!/(m_dss$)|(m_dss1$)/,@a) if $no_dsa;
110 @a=grep(!/(^d2i_s_)|(^i2d_s_)|(_dsap$)/,@a) if $no_dsa;
111
112 @a=grep(!/^n_pkey$/,@a) if $no_rsa || $no_rc4;
113
114 @a=grep(!/_dhp$/,@a) if $no_dh;
115
116 @a=grep(!/(^sha[^1])|(_sha$)|(m_dss$)/,@a) if $no_sha;
117 @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
118 @a=grep(!/_mdc2$/,@a) if $no_mdc2;
119
120 @a=grep(!/^engine$/,@a) if $no_engine;
121 @a=grep(!/(^rsa$)|(^genrsa$)|(^req$)|(^ca$)/,@a) if $no_rsa;
122 @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa;
123 @a=grep(!/^gendsa$/,@a) if $no_sha1;
124 @a=grep(!/(^dh$)|(^gendh$)/,@a) if $no_dh;
125
126 @a=grep(!/(^dh)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
127
128 grep($_="$dir/$_",@a);
129 @a=grep(!/(^|\/)s_/,@a) if $no_sock;
130 @a=grep(!/(^|\/)bio_sock/,@a) if $no_sock;
131 $ret=join(' ',@a)." ";
132 return($ret);
133 }
134
diff --git a/src/lib/libcrypto/util/ck_errf.pl b/src/lib/libcrypto/util/ck_errf.pl
new file mode 100644
index 0000000000..f13af5c50b
--- /dev/null
+++ b/src/lib/libcrypto/util/ck_errf.pl
@@ -0,0 +1,64 @@
1#!/usr/local/bin/perl
2#
3# This is just a quick script to scan for cases where the 'error'
4# function name in a XXXerr() macro is wrong.
5#
6# Run in the top level by going
7# perl util/ck_errf.pl */*.c */*/*.c
8#
9
10my $err_strict = 0;
11my $bad = 0;
12
13foreach $file (@ARGV)
14 {
15 if ($file eq "-strict")
16 {
17 $err_strict = 1;
18 next;
19 }
20 open(IN,"<$file") || die "unable to open $file\n";
21 $func="";
22 while (<IN>)
23 {
24 if (!/;$/ && /^([a-zA-Z].*[\s*])?([A-Za-z_0-9]+)\(.*[),]/)
25 {
26 /^([^()]*(\([^()]*\)[^()]*)*)\(/;
27 $1 =~ /([A-Za-z_0-9]*)$/;
28 $func = $1;
29 $func =~ tr/A-Z/a-z/;
30 }
31 if (/([A-Z0-9]+)err\(([^,]+)/ && ! /ckerr_ignore/)
32 {
33 $errlib=$1;
34 $n=$2;
35
36 if ($func eq "")
37 { print "$file:$.:???:$n\n"; $bad = 1; next; }
38
39 if ($n !~ /([^_]+)_F_(.+)$/)
40 {
41 # print "check -$file:$.:$func:$n\n";
42 next;
43 }
44 $lib=$1;
45 $n=$2;
46
47 if ($lib ne $errlib)
48 { print "$file:$.:$func:$n [${errlib}err]\n"; $bad = 1; next; }
49
50 $n =~ tr/A-Z/a-z/;
51 if (($n ne $func) && ($errlib ne "SYS"))
52 { print "$file:$.:$func:$n\n"; $bad = 1; next; }
53 # print "$func:$1\n";
54 }
55 }
56 close(IN);
57 }
58
59if ($bad && $err_strict)
60 {
61 print STDERR "FATAL: error discrepancy\n";
62 exit 1;
63 }
64
diff --git a/src/lib/libcrypto/util/clean-depend.pl b/src/lib/libcrypto/util/clean-depend.pl
new file mode 100644
index 0000000000..d3525b0ed0
--- /dev/null
+++ b/src/lib/libcrypto/util/clean-depend.pl
@@ -0,0 +1,58 @@
1#!/usr/local/bin/perl -w
2# Clean the dependency list in a makefile of standard includes...
3# Written by Ben Laurie <ben@algroup.co.uk> 19 Jan 1999
4
5use strict;
6
7while(<STDIN>) {
8 print;
9 last if /^# DO NOT DELETE THIS LINE/;
10}
11
12my %files;
13
14my $thisfile="";
15while(<STDIN>) {
16 my ($dummy, $file,$deps)=/^((.*):)? (.*)$/;
17 my $origfile="";
18 $thisfile=$file if defined $file;
19 next if !defined $deps;
20 $origfile=$thisfile;
21 $origfile=~s/\.o$/.c/;
22 my @deps=split ' ',$deps;
23 @deps=grep(!/^\//,@deps);
24 @deps=grep(!/^\\$/,@deps);
25 @deps=grep(!/^$origfile$/,@deps);
26# pull out the kludged kerberos header (if present).
27 @deps=grep(!/^[.\/]+\/krb5.h/,@deps);
28 push @{$files{$thisfile}},@deps;
29}
30
31my $file;
32foreach $file (sort keys %files) {
33 my $len=0;
34 my $dep;
35 my $origfile=$file;
36 $origfile=~s/\.o$/.c/;
37 $file=~s/^\.\///;
38 push @{$files{$file}},$origfile;
39 my $prevdep="";
40
41 # Remove leading ./ before sorting
42 my @deps = map { $_ =~ s/^\.\///; $_ } @{$files{$file}};
43
44 foreach $dep (sort @deps) {
45 $dep=~s/^\.\///;
46 next if $prevdep eq $dep; # to exterminate duplicates...
47 $prevdep = $dep;
48 $len=0 if $len+length($dep)+1 >= 80;
49 if($len == 0) {
50 print "\n$file:";
51 $len=length($file)+1;
52 }
53 print " $dep";
54 $len+=length($dep)+1;
55 }
56}
57
58print "\n";
diff --git a/src/lib/libcrypto/util/cygwin.sh b/src/lib/libcrypto/util/cygwin.sh
new file mode 100644
index 0000000000..cfdb04d2a4
--- /dev/null
+++ b/src/lib/libcrypto/util/cygwin.sh
@@ -0,0 +1,154 @@
1#!/bin/bash
2#
3# This script configures, builds and packs the binary package for
4# the Cygwin net distribution version of OpenSSL
5#
6
7# Uncomment when debugging
8#set -x
9
10CONFIG_OPTIONS="--prefix=/usr shared zlib no-idea no-rc5"
11INSTALL_PREFIX=/tmp/install/INSTALL
12
13VERSION=
14SHLIB_VERSION_NUMBER=
15SUBVERSION=$1
16
17function cleanup()
18{
19 rm -rf ${INSTALL_PREFIX}/etc
20 rm -rf ${INSTALL_PREFIX}/usr
21}
22
23function get_openssl_version()
24{
25 eval `grep '^VERSION=' Makefile`
26 if [ -z "${VERSION}" ]
27 then
28 echo "Error: Couldn't retrieve OpenSSL version from Makefile."
29 echo " Check value of variable VERSION in Makefile."
30 exit 1
31 fi
32 eval `grep '^SHLIB_VERSION_NUMBER=' Makefile`
33 if [ -z "${SHLIB_VERSION_NUMBER}" ]
34 then
35 echo "Error: Couldn't retrieve OpenSSL shared lib version from Makefile."
36 echo " Check value of variable SHLIB_VERSION_NUMBER in Makefile."
37 exit 1
38 fi
39}
40
41function base_install()
42{
43 mkdir -p ${INSTALL_PREFIX}
44 cleanup
45 make install INSTALL_PREFIX="${INSTALL_PREFIX}"
46}
47
48function doc_install()
49{
50 DOC_DIR=${INSTALL_PREFIX}/usr/share/doc/openssl
51
52 mkdir -p ${DOC_DIR}
53 cp CHANGES CHANGES.SSLeay INSTALL LICENSE NEWS README ${DOC_DIR}
54
55 create_cygwin_readme
56}
57
58function certs_install()
59{
60 CERTS_DIR=${INSTALL_PREFIX}/usr/ssl/certs
61
62 mkdir -p ${CERTS_DIR}
63 cp -rp certs/* ${CERTS_DIR}
64}
65
66function create_cygwin_readme()
67{
68 README_DIR=${INSTALL_PREFIX}/usr/share/doc/Cygwin
69 README_FILE=${README_DIR}/openssl-${VERSION}.README
70
71 mkdir -p ${README_DIR}
72 cat > ${README_FILE} <<- EOF
73 The Cygwin version has been built using the following configure:
74
75 ./config ${CONFIG_OPTIONS}
76
77 The IDEA and RC5 algorithms are disabled due to patent and/or
78 licensing issues.
79 EOF
80}
81
82function create_profile_files()
83{
84 PROFILE_DIR=${INSTALL_PREFIX}/etc/profile.d
85
86 mkdir -p $PROFILE_DIR
87 cat > ${PROFILE_DIR}/openssl.sh <<- "EOF"
88 export MANPATH="${MANPATH}:/usr/ssl/man"
89 EOF
90 cat > ${PROFILE_DIR}/openssl.csh <<- "EOF"
91 if ( $?MANPATH ) then
92 setenv MANPATH "${MANPATH}:/usr/ssl/man"
93 else
94 setenv MANPATH ":/usr/ssl/man"
95 endif
96 EOF
97}
98
99if [ -z "${SUBVERSION}" ]
100then
101 echo "Usage: $0 subversion"
102 exit 1
103fi
104
105if [ ! -f config ]
106then
107 echo "You must start this script in the OpenSSL toplevel source dir."
108 exit 1
109fi
110
111./config ${CONFIG_OPTIONS}
112
113get_openssl_version
114
115make depend || exit 1
116
117make || exit 1
118
119base_install
120
121doc_install
122
123certs_install
124
125create_cygwin_readme
126
127create_profile_files
128
129cd ${INSTALL_PREFIX}
130chmod u+w usr/lib/engines/*.so
131strip usr/bin/*.exe usr/bin/*.dll usr/lib/engines/*.so
132chmod u-w usr/lib/engines/*.so
133
134# Runtime package
135tar cjf libopenssl${SHLIB_VERSION_NUMBER//[!0-9]/}-${VERSION}-${SUBVERSION}.tar.bz2 \
136 usr/bin/cyg*dll
137# Base package
138find etc usr/bin/openssl.exe usr/bin/c_rehash usr/lib/engines usr/share/doc \
139 usr/ssl/certs usr/ssl/man/man[157] usr/ssl/misc usr/ssl/openssl.cnf \
140 usr/ssl/private \
141 -empty -o \! -type d |
142tar cjfT openssl-${VERSION}-${SUBVERSION}.tar.bz2 -
143# Development package
144find usr/include usr/lib/*.a usr/lib/pkgconfig usr/ssl/man/man3 \
145 -empty -o \! -type d |
146tar cjfT openssl-devel-${VERSION}-${SUBVERSION}.tar.bz2 -
147
148ls -l openssl-${VERSION}-${SUBVERSION}.tar.bz2
149ls -l openssl-devel-${VERSION}-${SUBVERSION}.tar.bz2
150ls -l libopenssl${SHLIB_VERSION_NUMBER//[!0-9]/}-${VERSION}-${SUBVERSION}.tar.bz2
151
152cleanup
153
154exit 0
diff --git a/src/lib/libcrypto/util/deleof.pl b/src/lib/libcrypto/util/deleof.pl
new file mode 100644
index 0000000000..155acd88ff
--- /dev/null
+++ b/src/lib/libcrypto/util/deleof.pl
@@ -0,0 +1,7 @@
1#!/usr/local/bin/perl
2
3while (<>)
4 {
5 print
6 last if (/^# DO NOT DELETE THIS LINE/);
7 }
diff --git a/src/lib/libcrypto/util/dirname.pl b/src/lib/libcrypto/util/dirname.pl
new file mode 100644
index 0000000000..d7a66d96ac
--- /dev/null
+++ b/src/lib/libcrypto/util/dirname.pl
@@ -0,0 +1,18 @@
1#!/usr/local/bin/perl
2
3if ($#ARGV < 0) {
4 die "dirname.pl: too few arguments\n";
5} elsif ($#ARGV > 0) {
6 die "dirname.pl: too many arguments\n";
7}
8
9my $d = $ARGV[0];
10
11if ($d =~ m|.*/.*|) {
12 $d =~ s|/[^/]*$||;
13} else {
14 $d = ".";
15}
16
17print $d,"\n";
18exit(0);
diff --git a/src/lib/libcrypto/util/do_ms.sh b/src/lib/libcrypto/util/do_ms.sh
new file mode 100644
index 0000000000..515b074cff
--- /dev/null
+++ b/src/lib/libcrypto/util/do_ms.sh
@@ -0,0 +1,19 @@
1#!/bin/sh
2#
3# generate the Microsoft makefiles and .def files
4#
5
6PATH=util:../util:$PATH
7
8# perl util/mk1mf.pl no-sock VC-MSDOS >ms/msdos.mak
9# perl util/mk1mf.pl VC-W31-32 >ms/w31.mak
10perl util/mk1mf.pl dll VC-WIN16 >ms/w31dll.mak
11# perl util/mk1mf.pl VC-WIN32 >ms/nt.mak
12perl util/mk1mf.pl dll VC-WIN32 >ms/ntdll.mak
13perl util/mk1mf.pl Mingw32 >ms/mingw32.mak
14perl util/mk1mf.pl Mingw32-files >ms/mingw32f.mak
15
16perl util/mkdef.pl 16 libeay > ms/libeay16.def
17perl util/mkdef.pl 32 libeay > ms/libeay32.def
18perl util/mkdef.pl 16 ssleay > ms/ssleay16.def
19perl util/mkdef.pl 32 ssleay > ms/ssleay32.def
diff --git a/src/lib/libcrypto/util/domd b/src/lib/libcrypto/util/domd
new file mode 100644
index 0000000000..bab48cb7a2
--- /dev/null
+++ b/src/lib/libcrypto/util/domd
@@ -0,0 +1,38 @@
1#!/bin/sh
2# Do a makedepend, only leave out the standard headers
3# Written by Ben Laurie <ben@algroup.co.uk> 19 Jan 1999
4
5TOP=$1
6shift
7if [ "$1" = "-MD" ]; then
8 shift
9 MAKEDEPEND=$1
10 shift
11fi
12if [ "$MAKEDEPEND" = "" ]; then MAKEDEPEND=makedepend; fi
13
14cp Makefile Makefile.save
15# fake the presence of Kerberos
16touch $TOP/krb5.h
17if expr "$MAKEDEPEND" : '.*gcc$' > /dev/null; then
18 args=""
19 while [ $# -gt 0 ]; do
20 if [ "$1" != "--" ]; then args="$args $1"; fi
21 shift
22 done
23 sed -e '/^# DO NOT DELETE.*/,$d' < Makefile > Makefile.tmp
24 echo '# DO NOT DELETE THIS LINE -- make depend depends on it.' >> Makefile.tmp
25 ${MAKEDEPEND} -Werror -D OPENSSL_DOING_MAKEDEPEND -M $args >> Makefile.tmp || exit 1
26 ${PERL} $TOP/util/clean-depend.pl < Makefile.tmp > Makefile.new
27 RC=$?
28 rm -f Makefile.tmp
29else
30 ${MAKEDEPEND} -D OPENSSL_DOING_MAKEDEPEND $@ && \
31 ${PERL} $TOP/util/clean-depend.pl < Makefile > Makefile.new
32 RC=$?
33fi
34mv Makefile.new Makefile
35# unfake the presence of Kerberos
36rm $TOP/krb5.h
37
38exit $RC
diff --git a/src/lib/libcrypto/util/err-ins.pl b/src/lib/libcrypto/util/err-ins.pl
new file mode 100644
index 0000000000..31b70df8d0
--- /dev/null
+++ b/src/lib/libcrypto/util/err-ins.pl
@@ -0,0 +1,33 @@
1#!/usr/local/bin/perl
2#
3# tack error codes onto the end of a file
4#
5
6open(ERR,$ARGV[0]) || die "unable to open error file '$ARGV[0]':$!\n";
7@err=<ERR>;
8close(ERR);
9
10open(IN,$ARGV[1]) || die "unable to open header file '$ARGV[1]':$!\n";
11
12@out="";
13while (<IN>)
14 {
15 push(@out,$_);
16 last if /BEGIN ERROR CODES/;
17 }
18close(IN);
19
20open(OUT,">$ARGV[1]") || die "unable to open header file '$ARGV[1]':$1\n";
21print OUT @out;
22print OUT @err;
23print OUT <<"EOF";
24
25#ifdef __cplusplus
26}
27#endif
28#endif
29
30EOF
31close(OUT);
32
33
diff --git a/src/lib/libcrypto/util/extract-names.pl b/src/lib/libcrypto/util/extract-names.pl
new file mode 100644
index 0000000000..35bd6ed843
--- /dev/null
+++ b/src/lib/libcrypto/util/extract-names.pl
@@ -0,0 +1,26 @@
1#!/usr/bin/perl
2
3$/ = ""; # Eat a paragraph at once.
4while(<STDIN>) {
5 chop;
6 s/\n/ /gm;
7 if (/^=head1 /) {
8 $name = 0;
9 } elsif ($name) {
10 if (/ - /) {
11 s/ - .*//;
12 s/,\s+/,/g;
13 s/\s+,/,/g;
14 s/^\s+//g;
15 s/\s+$//g;
16 s/\s/_/g;
17 push @words, split ',';
18 }
19 }
20 if (/^=head1 *NAME *$/) {
21 $name = 1;
22 }
23}
24
25print join("\n", @words),"\n";
26
diff --git a/src/lib/libcrypto/util/files.pl b/src/lib/libcrypto/util/files.pl
new file mode 100644
index 0000000000..41f033e3b9
--- /dev/null
+++ b/src/lib/libcrypto/util/files.pl
@@ -0,0 +1,61 @@
1#!/usr/local/bin/perl
2#
3# used to generate the file MINFO for use by util/mk1mf.pl
4# It is basically a list of all variables from the passed makefile
5#
6
7$s="";
8while (<>)
9 {
10 chop;
11 s/#.*//;
12 if (/^(\S+)\s*=\s*(.*)$/)
13 {
14 $o="";
15 ($s,$b)=($1,$2);
16 for (;;)
17 {
18 if ($b =~ /\\$/)
19 {
20 chop($b);
21 $o.=$b." ";
22 $b=<>;
23 chop($b);
24 }
25 else
26 {
27 $o.=$b." ";
28 last;
29 }
30 }
31 $o =~ s/^\s+//;
32 $o =~ s/\s+$//;
33 $o =~ s/\s+/ /g;
34
35 $o =~ s/\$[({]([^)}]+)[)}]/$sym{$1}/g;
36 $sym{$s}=$o;
37 }
38 }
39
40$pwd=`pwd`; chop($pwd);
41
42if ($sym{'TOP'} eq ".")
43 {
44 $n=0;
45 $dir=".";
46 }
47else {
48 $n=split(/\//,$sym{'TOP'});
49 @_=split(/\//,$pwd);
50 $z=$#_-$n+1;
51 foreach $i ($z .. $#_) { $dir.=$_[$i]."/"; }
52 chop($dir);
53 }
54
55print "RELATIVE_DIRECTORY=$dir\n";
56
57foreach (sort keys %sym)
58 {
59 print "$_=$sym{$_}\n";
60 }
61print "RELATIVE_DIRECTORY=\n";
diff --git a/src/lib/libcrypto/util/fixNT.sh b/src/lib/libcrypto/util/fixNT.sh
new file mode 100644
index 0000000000..ab9e766b86
--- /dev/null
+++ b/src/lib/libcrypto/util/fixNT.sh
@@ -0,0 +1,14 @@
1#!/bin/sh
2#
3# clean up the mess that NT makes of my source tree
4#
5
6if [ -f makefile -a ! -f Makefile ]; then
7 /bin/mv makefile Makefile
8fi
9chmod +x Configure util/*
10echo cleaning
11/bin/rm -f `find . -name '*.$$$' -print` 2>/dev/null >/dev/null
12echo 'removing those damn ^M'
13perl -pi -e 's/\015//' `find . -type 'f' -print |grep -v '.obj$' |grep -v '.der$' |grep -v '.gz'`
14make -f Makefile links
diff --git a/src/lib/libcrypto/util/install.sh b/src/lib/libcrypto/util/install.sh
new file mode 100644
index 0000000000..e1d0c982df
--- /dev/null
+++ b/src/lib/libcrypto/util/install.sh
@@ -0,0 +1,108 @@
1#!/bin/sh
2#
3# install - install a program, script, or datafile
4# This comes from X11R5; it is not part of GNU.
5#
6# $XConsortium: install.sh,v 1.2 89/12/18 14:47:22 jim Exp $
7#
8# This script is compatible with the BSD install script, but was written
9# from scratch.
10#
11
12
13# set DOITPROG to echo to test this script
14
15doit="${DOITPROG:-}"
16
17
18# put in absolute paths if you don't have them in your path; or use env. vars.
19
20mvprog="${MVPROG:-mv}"
21cpprog="${CPPROG:-cp}"
22chmodprog="${CHMODPROG:-chmod}"
23chownprog="${CHOWNPROG:-chown}"
24chgrpprog="${CHGRPPROG:-chgrp}"
25stripprog="${STRIPPROG:-strip}"
26rmprog="${RMPROG:-rm}"
27
28instcmd="$mvprog"
29chmodcmd=""
30chowncmd=""
31chgrpcmd=""
32stripcmd=""
33rmcmd="$rmprog -f"
34src=""
35dst=""
36
37while [ x"$1" != x ]; do
38 case $1 in
39 -c) instcmd="$cpprog"
40 shift
41 continue;;
42
43 -m) chmodcmd="$chmodprog $2"
44 shift
45 shift
46 continue;;
47
48 -o) chowncmd="$chownprog $2"
49 shift
50 shift
51 continue;;
52
53 -g) chgrpcmd="$chgrpprog $2"
54 shift
55 shift
56 continue;;
57
58 -s) stripcmd="$stripprog"
59 shift
60 continue;;
61
62 *) if [ x"$src" = x ]
63 then
64 src=$1
65 else
66 dst=$1
67 fi
68 shift
69 continue;;
70 esac
71done
72
73if [ x"$src" = x ]
74then
75 echo "install: no input file specified"
76 exit 1
77fi
78
79if [ x"$dst" = x ]
80then
81 echo "install: no destination specified"
82 exit 1
83fi
84
85
86# if destination is a directory, append the input filename; if your system
87# does not like double slashes in filenames, you may need to add some logic
88
89if [ -d $dst ]
90then
91 dst="$dst"/`basename $src`
92fi
93
94
95# get rid of the old one and mode the new one in
96
97$doit $rmcmd $dst
98$doit $instcmd $src $dst
99
100
101# and set any options; do chmod last to preserve setuid bits
102
103if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; fi
104if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; fi
105if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; fi
106if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; fi
107
108exit 0
diff --git a/src/lib/libcrypto/util/mk1mf.pl b/src/lib/libcrypto/util/mk1mf.pl
new file mode 100644
index 0000000000..72fa089f6b
--- /dev/null
+++ b/src/lib/libcrypto/util/mk1mf.pl
@@ -0,0 +1,1231 @@
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$OPENSSLDIR="/usr/local/ssl";
10$OPTIONS="";
11$ssl_version="";
12$banner="\t\@echo Building OpenSSL";
13
14my $no_static_engine = 1;
15my $engines = "";
16my $otherlibs = "";
17local $zlib_opt = 0; # 0 = no zlib, 1 = static, 2 = dynamic
18local $zlib_lib = "";
19local $perl_asm = 0; # 1 to autobuild asm files from perl scripts
20
21my $ex_l_libs = "";
22
23# Options to import from top level Makefile
24
25my %mf_import = (
26 VERSION => \$ssl_version,
27 OPTIONS => \$OPTIONS,
28 INSTALLTOP => \$INSTALLTOP,
29 OPENSSLDIR => \$OPENSSLDIR,
30 PLATFORM => \$mf_platform,
31 CFLAG => \$mf_cflag,
32 DEPFLAG => \$mf_depflag,
33 CPUID_OBJ => \$mf_cpuid_asm,
34 BN_ASM => \$mf_bn_asm,
35 DES_ENC => \$mf_des_asm,
36 AES_ENC => \$mf_aes_asm,
37 BF_ENC => \$mf_bf_asm,
38 CAST_ENC => \$mf_cast_asm,
39 RC4_ENC => \$mf_rc4_asm,
40 RC5_ENC => \$mf_rc5_asm,
41 MD5_ASM_OBJ => \$mf_md5_asm,
42 SHA1_ASM_OBJ => \$mf_sha_asm,
43 RMD160_ASM_OBJ => \$mf_rmd_asm,
44 WP_ASM_OBJ => \$mf_wp_asm,
45 CMLL_ENC => \$mf_cm_asm,
46 BASEADDR => \$baseaddr,
47 FIPSDIR => \$fipsdir,
48);
49
50
51open(IN,"<Makefile") || die "unable to open Makefile!\n";
52while(<IN>) {
53 my ($mf_opt, $mf_ref);
54 while (($mf_opt, $mf_ref) = each %mf_import) {
55 if (/^$mf_opt\s*=\s*(.*)$/) {
56 $$mf_ref = $1;
57 }
58 }
59}
60close(IN);
61
62$debug = 1 if $mf_platform =~ /^debug-/;
63
64die "Makefile is not the toplevel Makefile!\n" if $ssl_version eq "";
65
66$infile="MINFO";
67
68%ops=(
69 "VC-WIN32", "Microsoft Visual C++ [4-6] - Windows NT or 9X",
70 "VC-WIN64I", "Microsoft C/C++ - Win64/IA-64",
71 "VC-WIN64A", "Microsoft C/C++ - Win64/x64",
72 "VC-CE", "Microsoft eMbedded Visual C++ 3.0 - Windows CE ONLY",
73 "VC-NT", "Microsoft Visual C++ [4-6] - Windows NT ONLY",
74 "Mingw32", "GNU C++ - Windows NT or 9x",
75 "Mingw32-files", "Create files with DOS copy ...",
76 "BC-NT", "Borland C++ 4.5 - Windows NT",
77 "linux-elf","Linux elf",
78 "ultrix-mips","DEC mips ultrix",
79 "FreeBSD","FreeBSD distribution",
80 "OS2-EMX", "EMX GCC OS/2",
81 "netware-clib", "CodeWarrior for NetWare - CLib - with WinSock Sockets",
82 "netware-clib-bsdsock", "CodeWarrior for NetWare - CLib - with BSD Sockets",
83 "netware-libc", "CodeWarrior for NetWare - LibC - with WinSock Sockets",
84 "netware-libc-bsdsock", "CodeWarrior for NetWare - LibC - with BSD Sockets",
85 "default","cc under unix",
86 "auto", "auto detect from top level Makefile"
87 );
88
89$platform="";
90my $xcflags="";
91foreach (@ARGV)
92 {
93 if (!&read_options && !defined($ops{$_}))
94 {
95 print STDERR "unknown option - $_\n";
96 print STDERR "usage: perl mk1mf.pl [options] [system]\n";
97 print STDERR "\nwhere [system] can be one of the following\n";
98 foreach $i (sort keys %ops)
99 { printf STDERR "\t%-10s\t%s\n",$i,$ops{$i}; }
100 print STDERR <<"EOF";
101and [options] can be one of
102 no-md2 no-md4 no-md5 no-sha no-mdc2 - Skip this digest
103 no-ripemd
104 no-rc2 no-rc4 no-rc5 no-idea no-des - Skip this symetric cipher
105 no-bf no-cast no-aes no-camellia no-seed
106 no-rsa no-dsa no-dh - Skip this public key cipher
107 no-ssl2 no-ssl3 - Skip this version of SSL
108 just-ssl - remove all non-ssl keys/digest
109 no-asm - No x86 asm
110 no-krb5 - No KRB5
111 no-srp - No SRP
112 no-ec - No EC
113 no-ecdsa - No ECDSA
114 no-ecdh - No ECDH
115 no-engine - No engine
116 no-hw - No hw
117 nasm - Use NASM for x86 asm
118 nw-nasm - Use NASM x86 asm for NetWare
119 nw-mwasm - Use Metrowerks x86 asm for NetWare
120 gaswin - Use GNU as with Mingw32
121 no-socks - No socket code
122 no-err - No error strings
123 dll/shlib - Build shared libraries (MS)
124 debug - Debug build
125 profile - Profiling build
126 gcc - Use Gcc (unix)
127
128Values that can be set
129TMP=tmpdir OUT=outdir SRC=srcdir BIN=binpath INC=header-outdir CC=C-compiler
130
131-L<ex_lib_path> -l<ex_lib> - extra library flags (unix)
132-<ex_cc_flags> - extra 'cc' flags,
133 added (MS), or replace (unix)
134EOF
135 exit(1);
136 }
137 $platform=$_;
138 }
139foreach (grep(!/^$/, split(/ /, $OPTIONS)))
140 {
141 print STDERR "unknown option - $_\n" if !&read_options;
142 }
143
144$no_static_engine = 0 if (!$shlib);
145
146$no_mdc2=1 if ($no_des);
147
148$no_ssl3=1 if ($no_md5 || $no_sha);
149$no_ssl3=1 if ($no_rsa && $no_dh);
150
151$no_ssl2=1 if ($no_md5);
152$no_ssl2=1 if ($no_rsa);
153
154$out_def="out";
155$inc_def="outinc";
156$tmp_def="tmp";
157
158$perl="perl" unless defined $perl;
159$mkdir="-mkdir" unless defined $mkdir;
160
161($ssl,$crypto)=("ssl","crypto");
162$ranlib="echo ranlib";
163
164$cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc';
165$src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}:'.';
166$bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:'';
167
168# $bin_dir.=$o causes a core dump on my sparc :-(
169
170
171$NT=0;
172
173push(@INC,"util/pl","pl");
174
175if ($platform eq "auto") {
176 $platform = $mf_platform;
177 print STDERR "Imported platform $mf_platform\n";
178}
179
180if (($platform =~ /VC-(.+)/))
181 {
182 $FLAVOR=$1;
183 $NT = 1 if $1 eq "NT";
184 require 'VC-32.pl';
185 }
186elsif ($platform eq "Mingw32")
187 {
188 require 'Mingw32.pl';
189 }
190elsif ($platform eq "Mingw32-files")
191 {
192 require 'Mingw32f.pl';
193 }
194elsif ($platform eq "BC-NT")
195 {
196 $bc=1;
197 require 'BC-32.pl';
198 }
199elsif ($platform eq "FreeBSD")
200 {
201 require 'unix.pl';
202 $cflags='-DTERMIO -D_ANSI_SOURCE -O2 -fomit-frame-pointer';
203 }
204elsif ($platform eq "linux-elf")
205 {
206 require "unix.pl";
207 require "linux.pl";
208 $unix=1;
209 }
210elsif ($platform eq "ultrix-mips")
211 {
212 require "unix.pl";
213 require "ultrix.pl";
214 $unix=1;
215 }
216elsif ($platform eq "OS2-EMX")
217 {
218 $wc=1;
219 require 'OS2-EMX.pl';
220 }
221elsif (($platform eq "netware-clib") || ($platform eq "netware-libc") ||
222 ($platform eq "netware-clib-bsdsock") || ($platform eq "netware-libc-bsdsock"))
223 {
224 $LIBC=1 if $platform eq "netware-libc" || $platform eq "netware-libc-bsdsock";
225 $BSDSOCK=1 if ($platform eq "netware-libc-bsdsock") || ($platform eq "netware-clib-bsdsock");
226 require 'netware.pl';
227 }
228else
229 {
230 require "unix.pl";
231
232 $unix=1;
233 $cflags.=' -DTERMIO';
234 }
235
236$fipsdir =~ s/\//${o}/g;
237
238$out_dir=(defined($VARS{'OUT'}))?$VARS{'OUT'}:$out_def.($debug?".dbg":"");
239$tmp_dir=(defined($VARS{'TMP'}))?$VARS{'TMP'}:$tmp_def.($debug?".dbg":"");
240$inc_dir=(defined($VARS{'INC'}))?$VARS{'INC'}:$inc_def;
241
242$bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq ''));
243
244$cflags= "$xcflags$cflags" if $xcflags ne "";
245
246$cflags.=" -DOPENSSL_NO_IDEA" if $no_idea;
247$cflags.=" -DOPENSSL_NO_AES" if $no_aes;
248$cflags.=" -DOPENSSL_NO_CAMELLIA" if $no_camellia;
249$cflags.=" -DOPENSSL_NO_SEED" if $no_seed;
250$cflags.=" -DOPENSSL_NO_RC2" if $no_rc2;
251$cflags.=" -DOPENSSL_NO_RC4" if $no_rc4;
252$cflags.=" -DOPENSSL_NO_RC5" if $no_rc5;
253$cflags.=" -DOPENSSL_NO_MD2" if $no_md2;
254$cflags.=" -DOPENSSL_NO_MD4" if $no_md4;
255$cflags.=" -DOPENSSL_NO_MD5" if $no_md5;
256$cflags.=" -DOPENSSL_NO_SHA" if $no_sha;
257$cflags.=" -DOPENSSL_NO_SHA1" if $no_sha1;
258$cflags.=" -DOPENSSL_NO_RIPEMD" if $no_ripemd;
259$cflags.=" -DOPENSSL_NO_MDC2" if $no_mdc2;
260$cflags.=" -DOPENSSL_NO_BF" if $no_bf;
261$cflags.=" -DOPENSSL_NO_CAST" if $no_cast;
262$cflags.=" -DOPENSSL_NO_DES" if $no_des;
263$cflags.=" -DOPENSSL_NO_RSA" if $no_rsa;
264$cflags.=" -DOPENSSL_NO_DSA" if $no_dsa;
265$cflags.=" -DOPENSSL_NO_DH" if $no_dh;
266$cflags.=" -DOPENSSL_NO_WHIRLPOOL" if $no_whirlpool;
267$cflags.=" -DOPENSSL_NO_SOCK" if $no_sock;
268$cflags.=" -DOPENSSL_NO_SSL2" if $no_ssl2;
269$cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3;
270$cflags.=" -DOPENSSL_NO_TLSEXT" if $no_tlsext;
271$cflags.=" -DOPENSSL_NO_SRP" if $no_srp;
272$cflags.=" -DOPENSSL_NO_CMS" if $no_cms;
273$cflags.=" -DOPENSSL_NO_ERR" if $no_err;
274$cflags.=" -DOPENSSL_NO_KRB5" if $no_krb5;
275$cflags.=" -DOPENSSL_NO_EC" if $no_ec;
276$cflags.=" -DOPENSSL_NO_ECDSA" if $no_ecdsa;
277$cflags.=" -DOPENSSL_NO_ECDH" if $no_ecdh;
278$cflags.=" -DOPENSSL_NO_GOST" if $no_gost;
279$cflags.=" -DOPENSSL_NO_ENGINE" if $no_engine;
280$cflags.=" -DOPENSSL_NO_HW" if $no_hw;
281$cflags.=" -DOPENSSL_FIPS" if $fips;
282$cflags.=" -DOPENSSL_NO_JPAKE" if $no_jpake;
283$cflags.=" -DOPENSSL_NO_EC2M" if $no_ec2m;
284$cflags.= " -DZLIB" if $zlib_opt;
285$cflags.= " -DZLIB_SHARED" if $zlib_opt == 2;
286
287if ($no_static_engine)
288 {
289 $cflags .= " -DOPENSSL_NO_STATIC_ENGINE";
290 }
291else
292 {
293 $cflags .= " -DOPENSSL_NO_DYNAMIC_ENGINE";
294 }
295
296#$cflags.=" -DRSAref" if $rsaref ne "";
297
298## if ($unix)
299## { $cflags="$c_flags" if ($c_flags ne ""); }
300##else
301 { $cflags="$c_flags$cflags" if ($c_flags ne ""); }
302
303$ex_libs="$l_flags$ex_libs" if ($l_flags ne "");
304
305
306%shlib_ex_cflags=("SSL" => " -DOPENSSL_BUILD_SHLIBSSL",
307 "CRYPTO" => " -DOPENSSL_BUILD_SHLIBCRYPTO");
308
309if ($msdos)
310 {
311 $banner ="\t\@echo Make sure you have run 'perl Configure $platform' in the\n";
312 $banner.="\t\@echo top level directory, if you don't have perl, you will\n";
313 $banner.="\t\@echo need to probably edit crypto/bn/bn.h, check the\n";
314 $banner.="\t\@echo documentation for details.\n";
315 }
316
317# have to do this to allow $(CC) under unix
318$link="$bin_dir$link" if ($link !~ /^\$/);
319
320$INSTALLTOP =~ s|/|$o|g;
321$OPENSSLDIR =~ s|/|$o|g;
322
323#############################################
324# We parse in input file and 'store' info for later printing.
325open(IN,"<$infile") || die "unable to open $infile:$!\n";
326$_=<IN>;
327for (;;)
328 {
329 chop;
330
331 ($key,$val)=/^([^=]+)=(.*)/;
332 if ($key eq "RELATIVE_DIRECTORY")
333 {
334 if ($lib ne "")
335 {
336 $uc=$lib;
337 $uc =~ s/^lib(.*)\.a/$1/;
338 $uc =~ tr/a-z/A-Z/;
339 $lib_nam{$uc}=$uc;
340 $lib_obj{$uc}.=$libobj." ";
341 }
342 last if ($val eq "FINISHED");
343 $lib="";
344 $libobj="";
345 $dir=$val;
346 }
347
348 if ($key eq "KRB5_INCLUDES")
349 { $cflags .= " $val";}
350
351 if ($key eq "ZLIB_INCLUDE")
352 { $cflags .= " $val" if $val ne "";}
353
354 if ($key eq "LIBZLIB")
355 { $zlib_lib = "$val" if $val ne "";}
356
357 if ($key eq "LIBKRB5")
358 { $ex_libs .= " $val" if $val ne "";}
359
360 if ($key eq "TEST")
361 { $test.=&var_add($dir,$val, 0); }
362
363 if (($key eq "PROGS") || ($key eq "E_OBJ"))
364 { $e_exe.=&var_add($dir,$val, 0); }
365
366 if ($key eq "LIB")
367 {
368 $lib=$val;
369 $lib =~ s/^.*\/([^\/]+)$/$1/;
370 }
371 if ($key eq "LIBNAME" && $no_static_engine)
372 {
373 $lib=$val;
374 $lib =~ s/^.*\/([^\/]+)$/$1/;
375 $otherlibs .= " $lib";
376 }
377
378 if ($key eq "EXHEADER")
379 { $exheader.=&var_add($dir,$val, 1); }
380
381 if ($key eq "HEADER")
382 { $header.=&var_add($dir,$val, 1); }
383
384 if ($key eq "LIBOBJ" && ($dir ne "engines" || !$no_static_engine))
385 { $libobj=&var_add($dir,$val, 0); }
386 if ($key eq "LIBNAMES" && $dir eq "engines" && $no_static_engine)
387 { $engines.=$val }
388
389 if (!($_=<IN>))
390 { $_="RELATIVE_DIRECTORY=FINISHED\n"; }
391 }
392close(IN);
393
394if ($shlib)
395 {
396 $extra_install= <<"EOF";
397 \$(CP) \"\$(O_SSL)\" \"\$(INSTALLTOP)${o}bin\"
398 \$(CP) \"\$(O_CRYPTO)\" \"\$(INSTALLTOP)${o}bin\"
399 \$(CP) \"\$(L_SSL)\" \"\$(INSTALLTOP)${o}lib\"
400 \$(CP) \"\$(L_CRYPTO)\" \"\$(INSTALLTOP)${o}lib\"
401EOF
402 if ($no_static_engine)
403 {
404 $extra_install .= <<"EOF"
405 \$(MKDIR) \"\$(INSTALLTOP)${o}lib${o}engines\"
406 \$(CP) \"\$(E_SHLIB)\" \"\$(INSTALLTOP)${o}lib${o}engines\"
407EOF
408 }
409 }
410else
411 {
412 $extra_install= <<"EOF";
413 \$(CP) \"\$(O_SSL)\" \"\$(INSTALLTOP)${o}lib\"
414 \$(CP) \"\$(O_CRYPTO)\" \"\$(INSTALLTOP)${o}lib\"
415EOF
416 $ex_libs .= " $zlib_lib" if $zlib_opt == 1;
417 if ($fips)
418 {
419 $build_targets .= " \$(LIB_D)$o$crypto_compat \$(PREMAIN_DSO_EXE)";
420 $ex_l_libs .= " \$(O_FIPSCANISTER)";
421 }
422 }
423
424$defs= <<"EOF";
425# This makefile has been automatically generated from the OpenSSL distribution.
426# This single makefile will build the complete OpenSSL distribution and
427# by default leave the 'intertesting' output files in .${o}out and the stuff
428# that needs deleting in .${o}tmp.
429# The file was generated by running 'make makefile.one', which
430# does a 'make files', which writes all the environment variables from all
431# the makefiles to the file call MINFO. This file is used by
432# util${o}mk1mf.pl to generate makefile.one.
433# The 'makefile per directory' system suites me when developing this
434# library and also so I can 'distribute' indervidual library sections.
435# The one monster makefile better suits building in non-unix
436# environments.
437
438EOF
439
440$defs .= $preamble if defined $preamble;
441
442$defs.= <<"EOF";
443INSTALLTOP=$INSTALLTOP
444OPENSSLDIR=$OPENSSLDIR
445
446# Set your compiler options
447PLATFORM=$platform
448CC=$bin_dir${cc}
449CFLAG=$cflags
450APP_CFLAG=$app_cflag
451LIB_CFLAG=$lib_cflag
452SHLIB_CFLAG=$shl_cflag
453APP_EX_OBJ=$app_ex_obj
454SHLIB_EX_OBJ=$shlib_ex_obj
455# add extra libraries to this define, for solaris -lsocket -lnsl would
456# be added
457EX_LIBS=$ex_libs
458
459# The OpenSSL directory
460SRC_D=$src_dir
461
462LINK=$link
463LFLAGS=$lflags
464RSC=$rsc
465
466# The output directory for everything intersting
467OUT_D=$out_dir
468# The output directory for all the temporary muck
469TMP_D=$tmp_dir
470# The output directory for the header files
471INC_D=$inc_dir
472INCO_D=$inc_dir${o}openssl
473
474PERL=$perl
475CP=$cp
476RM=$rm
477RANLIB=$ranlib
478MKDIR=$mkdir
479MKLIB=$bin_dir$mklib
480MLFLAGS=$mlflags
481ASM=$bin_dir$asm
482
483# FIPS validated module and support file locations
484
485FIPSDIR=$fipsdir
486BASEADDR=$baseaddr
487FIPSLIB_D=\$(FIPSDIR)${o}lib
488FIPS_PREMAIN_SRC=\$(FIPSLIB_D)${o}fips_premain.c
489O_FIPSCANISTER=\$(FIPSLIB_D)${o}fipscanister.lib
490FIPS_SHA1_EXE=\$(FIPSDIR)${o}bin${o}fips_standalone_sha1${exep}
491E_PREMAIN_DSO=fips_premain_dso
492PREMAIN_DSO_EXE=\$(BIN_D)${o}fips_premain_dso$exep
493FIPSLINK=\$(PERL) \$(FIPSDIR)${o}bin${o}fipslink.pl
494
495######################################################
496# You should not need to touch anything below this point
497######################################################
498
499E_EXE=openssl
500SSL=$ssl
501CRYPTO=$crypto
502
503# BIN_D - Binary output directory
504# TEST_D - Binary test file output directory
505# LIB_D - library output directory
506# ENG_D - dynamic engine output directory
507# Note: if you change these point to different directories then uncomment out
508# the lines around the 'NB' comment below.
509#
510BIN_D=\$(OUT_D)
511TEST_D=\$(OUT_D)
512LIB_D=\$(OUT_D)
513ENG_D=\$(OUT_D)
514
515# INCL_D - local library directory
516# OBJ_D - temp object file directory
517OBJ_D=\$(TMP_D)
518INCL_D=\$(TMP_D)
519
520O_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp
521O_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp
522SO_SSL= $plib\$(SSL)$so_shlibp
523SO_CRYPTO= $plib\$(CRYPTO)$so_shlibp
524L_SSL= \$(LIB_D)$o$plib\$(SSL)$libp
525L_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$libp
526
527L_LIBS= \$(L_SSL) \$(L_CRYPTO) $ex_l_libs
528
529######################################################
530# Don't touch anything below this point
531######################################################
532
533INC=-I\$(INC_D) -I\$(INCL_D)
534APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG)
535LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG)
536SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG)
537LIBS_DEP=\$(O_CRYPTO) \$(O_SSL)
538
539#############################################
540EOF
541
542$rules=<<"EOF";
543all: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INCO_D) headers lib exe $build_targets
544
545banner:
546$banner
547
548\$(TMP_D):
549 \$(MKDIR) \"\$(TMP_D)\"
550# NB: uncomment out these lines if BIN_D, TEST_D and LIB_D are different
551#\$(BIN_D):
552# \$(MKDIR) \$(BIN_D)
553#
554#\$(TEST_D):
555# \$(MKDIR) \$(TEST_D)
556
557\$(LIB_D):
558 \$(MKDIR) \"\$(LIB_D)\"
559
560\$(INCO_D): \$(INC_D)
561 \$(MKDIR) \"\$(INCO_D)\"
562
563\$(INC_D):
564 \$(MKDIR) \"\$(INC_D)\"
565
566headers: \$(HEADER) \$(EXHEADER)
567 @
568
569lib: \$(LIBS_DEP) \$(E_SHLIB)
570
571exe: \$(T_EXE) \$(BIN_D)$o\$(E_EXE)$exep
572
573install: all
574 \$(MKDIR) \"\$(INSTALLTOP)\"
575 \$(MKDIR) \"\$(INSTALLTOP)${o}bin\"
576 \$(MKDIR) \"\$(INSTALLTOP)${o}include\"
577 \$(MKDIR) \"\$(INSTALLTOP)${o}include${o}openssl\"
578 \$(MKDIR) \"\$(INSTALLTOP)${o}lib\"
579 \$(CP) \"\$(INCO_D)${o}*.\[ch\]\" \"\$(INSTALLTOP)${o}include${o}openssl\"
580 \$(CP) \"\$(BIN_D)$o\$(E_EXE)$exep \$(INSTALLTOP)${o}bin\"
581 \$(MKDIR) \"\$(OPENSSLDIR)\"
582 \$(CP) apps${o}openssl.cnf \"\$(OPENSSLDIR)\"
583$extra_install
584
585
586test: \$(T_EXE)
587 cd \$(BIN_D)
588 ..${o}ms${o}test
589
590clean:
591 \$(RM) \$(TMP_D)$o*.*
592
593vclean:
594 \$(RM) \$(TMP_D)$o*.*
595 \$(RM) \$(OUT_D)$o*.*
596
597EOF
598
599my $platform_cpp_symbol = "MK1MF_PLATFORM_$platform";
600$platform_cpp_symbol =~ s/-/_/g;
601if (open(IN,"crypto/buildinf.h"))
602 {
603 # Remove entry for this platform in existing file buildinf.h.
604
605 my $old_buildinf_h = "";
606 while (<IN>)
607 {
608 if (/^\#ifdef $platform_cpp_symbol$/)
609 {
610 while (<IN>) { last if (/^\#endif/); }
611 }
612 else
613 {
614 $old_buildinf_h .= $_;
615 }
616 }
617 close(IN);
618
619 open(OUT,">crypto/buildinf.h") || die "Can't open buildinf.h";
620 print OUT $old_buildinf_h;
621 close(OUT);
622 }
623
624open (OUT,">>crypto/buildinf.h") || die "Can't open buildinf.h";
625printf OUT <<EOF;
626#ifdef $platform_cpp_symbol
627 /* auto-generated/updated by util/mk1mf.pl for crypto/cversion.c */
628 #define CFLAGS "$cc $cflags"
629 #define PLATFORM "$platform"
630EOF
631printf OUT " #define DATE \"%s\"\n", scalar gmtime();
632printf OUT "#endif\n";
633close(OUT);
634
635# Strip of trailing ' '
636foreach (keys %lib_obj) { $lib_obj{$_}=&clean_up_ws($lib_obj{$_}); }
637$test=&clean_up_ws($test);
638$e_exe=&clean_up_ws($e_exe);
639$exheader=&clean_up_ws($exheader);
640$header=&clean_up_ws($header);
641
642# First we strip the exheaders from the headers list
643foreach (split(/\s+/,$exheader)){ $h{$_}=1; }
644foreach (split(/\s+/,$header)) { $h.=$_." " unless $h{$_}; }
645chop($h); $header=$h;
646
647$defs.=&do_defs("HEADER",$header,"\$(INCL_D)","");
648$rules.=&do_copy_rule("\$(INCL_D)",$header,"");
649
650$defs.=&do_defs("EXHEADER",$exheader,"\$(INCO_D)","");
651$rules.=&do_copy_rule("\$(INCO_D)",$exheader,"");
652
653$defs.=&do_defs("T_OBJ",$test,"\$(OBJ_D)",$obj);
654$rules.=&do_compile_rule("\$(OBJ_D)",$test,"\$(APP_CFLAGS)");
655
656$defs.=&do_defs("E_OBJ",$e_exe,"\$(OBJ_D)",$obj);
657$rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)');
658
659# Special case rule for fips_premain_dso
660
661if ($fips)
662 {
663 $rules.=&cc_compile_target("\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj",
664 "\$(FIPS_PREMAIN_SRC)",
665 "-DFINGERPRINT_PREMAIN_DSO_LOAD \$(SHLIB_CFLAGS)", "");
666 $rules.=&do_link_rule("\$(PREMAIN_DSO_EXE)","\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj \$(CRYPTOOBJ) \$(O_FIPSCANISTER)","","\$(EX_LIBS)", 1);
667 }
668
669foreach (values %lib_nam)
670 {
671 $lib_obj=$lib_obj{$_};
672 local($slib)=$shlib;
673
674 if (($_ eq "SSL") && $no_ssl2 && $no_ssl3)
675 {
676 $rules.="\$(O_SSL):\n\n";
677 next;
678 }
679
680 $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj);
681 $lib=($slib)?" \$(SHLIB_CFLAGS)".$shlib_ex_cflags{$_}:" \$(LIB_CFLAGS)";
682 $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib);
683 }
684
685# hack to add version info on MSVC
686if (($platform eq "VC-WIN32") || ($platform eq "VC-WIN64A")
687 || ($platform eq "VC-WIN64I") || ($platform eq "VC-NT")) {
688 $rules.= <<"EOF";
689\$(OBJ_D)\\\$(CRYPTO).res: ms\\version32.rc
690 \$(RSC) /fo"\$(OBJ_D)\\\$(CRYPTO).res" /d CRYPTO ms\\version32.rc
691
692\$(OBJ_D)\\\$(SSL).res: ms\\version32.rc
693 \$(RSC) /fo"\$(OBJ_D)\\\$(SSL).res" /d SSL ms\\version32.rc
694
695EOF
696}
697
698$defs.=&do_defs("T_EXE",$test,"\$(TEST_D)",$exep);
699foreach (split(/\s+/,$test))
700 {
701 $t=&bname($_);
702 $tt="\$(OBJ_D)${o}$t${obj}";
703 $rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)");
704 }
705
706$defs.=&do_defs("E_SHLIB",$engines . $otherlibs,"\$(ENG_D)",$shlibp);
707
708foreach (split(/\s+/,$engines))
709 {
710 $rules.=&do_compile_rule("\$(OBJ_D)","engines${o}e_$_",$lib);
711 $rules.= &do_lib_rule("\$(OBJ_D)${o}e_${_}.obj","\$(ENG_D)$o$_$shlibp","",$shlib,"");
712 }
713
714
715
716$rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)");
717
718if ($fips)
719 {
720 if ($shlib)
721 {
722 $rules.= &do_lib_rule("\$(CRYPTOOBJ) \$(O_FIPSCANISTER)",
723 "\$(O_CRYPTO)", "$crypto",
724 $shlib, "\$(SO_CRYPTO)", "\$(BASEADDR)");
725 }
726 else
727 {
728 $rules.= &do_lib_rule("\$(CRYPTOOBJ)",
729 "\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)", "");
730 $rules.= &do_lib_rule("\$(CRYPTOOBJ) \$(O_FIPSCANISTER)",
731 "\$(LIB_D)$o$crypto_compat",$crypto,$shlib,"\$(SO_CRYPTO)", "");
732 }
733 }
734 else
735 {
736 $rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,
737 "\$(SO_CRYPTO)");
738 }
739
740foreach (split(" ",$otherlibs))
741 {
742 my $uc = $_;
743 $uc =~ tr /a-z/A-Z/;
744 $rules.= &do_lib_rule("\$(${uc}OBJ)","\$(ENG_D)$o$_$shlibp", "", $shlib, "");
745
746 }
747
748$rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)", ($fips && !$shlib) ? 2 : 0);
749
750print $defs;
751
752if ($platform eq "linux-elf") {
753 print <<"EOF";
754# Generate perlasm output files
755%.cpp:
756 (cd \$(\@D)/..; PERL=perl make -f Makefile asm/\$(\@F))
757EOF
758}
759print "###################################################################\n";
760print $rules;
761
762###############################################
763# strip off any trailing .[och] and append the relative directory
764# also remembering to do nothing if we are in one of the dropped
765# directories
766sub var_add
767 {
768 local($dir,$val,$keepext)=@_;
769 local(@a,$_,$ret);
770
771 return("") if $no_engine && $dir =~ /\/engine/;
772 return("") if $no_hw && $dir =~ /\/hw/;
773 return("") if $no_idea && $dir =~ /\/idea/;
774 return("") if $no_aes && $dir =~ /\/aes/;
775 return("") if $no_camellia && $dir =~ /\/camellia/;
776 return("") if $no_seed && $dir =~ /\/seed/;
777 return("") if $no_rc2 && $dir =~ /\/rc2/;
778 return("") if $no_rc4 && $dir =~ /\/rc4/;
779 return("") if $no_rc5 && $dir =~ /\/rc5/;
780 return("") if $no_rsa && $dir =~ /\/rsa/;
781 return("") if $no_rsa && $dir =~ /^rsaref/;
782 return("") if $no_dsa && $dir =~ /\/dsa/;
783 return("") if $no_dh && $dir =~ /\/dh/;
784 return("") if $no_ec && $dir =~ /\/ec/;
785 return("") if $no_gost && $dir =~ /\/ccgost/;
786 return("") if $no_cms && $dir =~ /\/cms/;
787 return("") if $no_jpake && $dir =~ /\/jpake/;
788 if ($no_des && $dir =~ /\/des/)
789 {
790 if ($val =~ /read_pwd/)
791 { return("$dir/read_pwd "); }
792 else
793 { return(""); }
794 }
795 return("") if $no_mdc2 && $dir =~ /\/mdc2/;
796 return("") if $no_sock && $dir =~ /\/proxy/;
797 return("") if $no_bf && $dir =~ /\/bf/;
798 return("") if $no_cast && $dir =~ /\/cast/;
799 return("") if $no_whirlpool && $dir =~ /\/whrlpool/;
800
801 $val =~ s/^\s*(.*)\s*$/$1/;
802 @a=split(/\s+/,$val);
803 grep(s/\.[och]$//,@a) unless $keepext;
804
805 @a=grep(!/^e_.*_3d$/,@a) if $no_des;
806 @a=grep(!/^e_.*_d$/,@a) if $no_des;
807 @a=grep(!/^e_.*_ae$/,@a) if $no_idea;
808 @a=grep(!/^e_.*_i$/,@a) if $no_aes;
809 @a=grep(!/^e_.*_r2$/,@a) if $no_rc2;
810 @a=grep(!/^e_.*_r5$/,@a) if $no_rc5;
811 @a=grep(!/^e_.*_bf$/,@a) if $no_bf;
812 @a=grep(!/^e_.*_c$/,@a) if $no_cast;
813 @a=grep(!/^e_rc4$/,@a) if $no_rc4;
814 @a=grep(!/^e_camellia$/,@a) if $no_camellia;
815 @a=grep(!/^e_seed$/,@a) if $no_seed;
816
817 #@a=grep(!/(^s2_)|(^s23_)/,@a) if $no_ssl2;
818 #@a=grep(!/(^s3_)|(^s23_)/,@a) if $no_ssl3;
819
820 @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock;
821
822 @a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2;
823 @a=grep(!/(^md4)|(_md4$)/,@a) if $no_md4;
824 @a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5;
825 @a=grep(!/(rmd)|(ripemd)/,@a) if $no_ripemd;
826
827 @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa;
828 @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa;
829 @a=grep(!/(^pem_seal$)/,@a) if $no_rsa;
830
831 @a=grep(!/(m_dss$)|(m_dss1$)/,@a) if $no_dsa;
832 @a=grep(!/(^d2i_s_)|(^i2d_s_)|(_dsap$)/,@a) if $no_dsa;
833
834 @a=grep(!/^n_pkey$/,@a) if $no_rsa || $no_rc4;
835
836 @a=grep(!/_dhp$/,@a) if $no_dh;
837
838 @a=grep(!/(^sha[^1])|(_sha$)|(m_dss$)/,@a) if $no_sha;
839 @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
840 @a=grep(!/_mdc2$/,@a) if $no_mdc2;
841
842 @a=grep(!/(srp)/,@a) if $no_srp;
843
844 @a=grep(!/^engine$/,@a) if $no_engine;
845 @a=grep(!/^hw$/,@a) if $no_hw;
846 @a=grep(!/(^rsa$)|(^genrsa$)/,@a) if $no_rsa;
847 @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa;
848 @a=grep(!/^gendsa$/,@a) if $no_sha1;
849 @a=grep(!/(^dh$)|(^gendh$)/,@a) if $no_dh;
850
851 @a=grep(!/(^dh)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
852
853 grep($_="$dir/$_",@a);
854 @a=grep(!/(^|\/)s_/,@a) if $no_sock;
855 @a=grep(!/(^|\/)bio_sock/,@a) if $no_sock;
856 $ret=join(' ',@a)." ";
857 return($ret);
858 }
859
860# change things so that each 'token' is only separated by one space
861sub clean_up_ws
862 {
863 local($w)=@_;
864
865 $w =~ s/^\s*(.*)\s*$/$1/;
866 $w =~ s/\s+/ /g;
867 return($w);
868 }
869
870sub do_defs
871 {
872 local($var,$files,$location,$postfix)=@_;
873 local($_,$ret,$pf);
874 local(*OUT,$tmp,$t);
875
876 $files =~ s/\//$o/g if $o ne '/';
877 $ret="$var=";
878 $n=1;
879 $Vars{$var}.="";
880 foreach (split(/ /,$files))
881 {
882 $orig=$_;
883 $_=&bname($_) unless /^\$/;
884 if ($n++ == 2)
885 {
886 $n=0;
887 $ret.="\\\n\t";
888 }
889 if (($_ =~ /bss_file/) && ($postfix eq ".h"))
890 { $pf=".c"; }
891 else { $pf=$postfix; }
892 if ($_ =~ /BN_ASM/) { $t="$_ "; }
893 elsif ($_ =~ /BNCO_ASM/){ $t="$_ "; }
894 elsif ($_ =~ /AES_ASM/){ $t="$_ "; }
895 elsif ($_ =~ /DES_ENC/) { $t="$_ "; }
896 elsif ($_ =~ /BF_ENC/) { $t="$_ "; }
897 elsif ($_ =~ /CAST_ENC/){ $t="$_ "; }
898 elsif ($_ =~ /RC4_ENC/) { $t="$_ "; }
899 elsif ($_ =~ /RC5_ENC/) { $t="$_ "; }
900 elsif ($_ =~ /MD5_ASM/) { $t="$_ "; }
901 elsif ($_ =~ /SHA1_ASM/){ $t="$_ "; }
902 elsif ($_ =~ /RMD160_ASM/){ $t="$_ "; }
903 elsif ($_ =~ /WHIRLPOOL_ASM/){ $t="$_ "; }
904 elsif ($_ =~ /CPUID_ASM/){ $t="$_ "; }
905 else { $t="$location${o}$_$pf "; }
906
907 $Vars{$var}.="$t ";
908 $ret.=$t;
909 }
910 # hack to add version info on MSVC
911 if ($shlib && (($platform eq "VC-WIN32") || ($platfrom eq "VC-WIN64I") || ($platform eq "VC-WIN64A") || ($platform eq "VC-NT")))
912 {
913 if ($var eq "CRYPTOOBJ")
914 { $ret.="\$(OBJ_D)\\\$(CRYPTO).res "; }
915 elsif ($var eq "SSLOBJ")
916 { $ret.="\$(OBJ_D)\\\$(SSL).res "; }
917 }
918 chomp($ret);
919 $ret.="\n\n";
920 return($ret);
921 }
922
923# return the name with the leading path removed
924sub bname
925 {
926 local($ret)=@_;
927 $ret =~ s/^.*[\\\/]([^\\\/]+)$/$1/;
928 return($ret);
929 }
930
931# return the leading path
932sub dname
933 {
934 my $ret=shift;
935 $ret =~ s/(^.*)[\\\/][^\\\/]+$/$1/;
936 return($ret);
937 }
938
939##############################################################
940# do a rule for each file that says 'compile' to new direcory
941# compile the files in '$files' into $to
942sub do_compile_rule
943 {
944 local($to,$files,$ex)=@_;
945 local($ret,$_,$n,$d,$s);
946
947 $files =~ s/\//$o/g if $o ne '/';
948 foreach (split(/\s+/,$files))
949 {
950 $n=&bname($_);
951 $d=&dname($_);
952 if (-f "${_}.c")
953 {
954 $ret.=&cc_compile_target("$to${o}$n$obj","${_}.c",$ex)
955 }
956 elsif (-f ($s="${d}${o}asm${o}${n}.pl") or
957 ($s=~s/sha256/sha512/ and -f $s) or
958 -f ($s="${d}${o}${n}.pl"))
959 {
960 $ret.=&perlasm_compile_target("$to${o}$n$obj",$s,$n);
961 }
962 elsif (-f ($s="${d}${o}asm${o}${n}.S") or
963 -f ($s="${d}${o}${n}.S"))
964 {
965 $ret.=&Sasm_compile_target("$to${o}$n$obj",$s,$n);
966 }
967 else { die "no rule for $_"; }
968 }
969 return($ret);
970 }
971
972##############################################################
973# do a rule for each file that says 'compile' to new direcory
974sub perlasm_compile_target
975 {
976 my($target,$source,$bname)=@_;
977 my($ret);
978
979 $bname =~ s/(.*)\.[^\.]$/$1/;
980 $ret ="\$(TMP_D)$o$bname.asm: $source\n";
981 $ret.="\t\$(PERL) $source $asmtype \$(CFLAG) >\$\@\n\n";
982 $ret.="$target: \$(TMP_D)$o$bname.asm\n";
983 $ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm\n\n";
984 return($ret);
985 }
986
987sub Sasm_compile_target
988 {
989 my($target,$source,$bname)=@_;
990 my($ret);
991
992 $bname =~ s/(.*)\.[^\.]$/$1/;
993 $ret ="\$(TMP_D)$o$bname.asm: $source\n";
994 $ret.="\t\$(CC) -E \$(CFLAG) $source >\$\@\n\n";
995 $ret.="$target: \$(TMP_D)$o$bname.asm\n";
996 $ret.="\t\$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm\n\n";
997 return($ret);
998 }
999
1000sub cc_compile_target
1001 {
1002 local($target,$source,$ex_flags, $srcd)=@_;
1003 local($ret);
1004
1005 $ex_flags.=" -DMK1MF_BUILD -D$platform_cpp_symbol" if ($source =~ /cversion/);
1006 $target =~ s/\//$o/g if $o ne "/";
1007 $source =~ s/\//$o/g if $o ne "/";
1008 $srcd = "\$(SRC_D)$o" unless defined $srcd;
1009 $ret ="$target: $srcd$source\n\t";
1010 $ret.="\$(CC) ${ofile}$target $ex_flags -c $srcd$source\n\n";
1011 return($ret);
1012 }
1013
1014##############################################################
1015sub do_asm_rule
1016 {
1017 local($target,$src)=@_;
1018 local($ret,@s,@t,$i);
1019
1020 $target =~ s/\//$o/g if $o ne "/";
1021 $src =~ s/\//$o/g if $o ne "/";
1022
1023 @t=split(/\s+/,$target);
1024 @s=split(/\s+/,$src);
1025
1026
1027 for ($i=0; $i<=$#s; $i++)
1028 {
1029 my $objfile = $t[$i];
1030 my $srcfile = $s[$i];
1031
1032 if ($perl_asm == 1)
1033 {
1034 my $plasm = $objfile;
1035 $plasm =~ s/${obj}/.pl/;
1036 $ret.="$srcfile: $plasm\n";
1037 $ret.="\t\$(PERL) $plasm $asmtype \$(CFLAG) >$srcfile\n\n";
1038 }
1039
1040 $ret.="$objfile: $srcfile\n";
1041 $ret.="\t\$(ASM) $afile$objfile \$(SRC_D)$o$srcfile\n\n";
1042 }
1043 return($ret);
1044 }
1045
1046sub do_shlib_rule
1047 {
1048 local($n,$def)=@_;
1049 local($ret,$nn);
1050 local($t);
1051
1052 ($nn=$n) =~ tr/a-z/A-Z/;
1053 $ret.="$n.dll: \$(${nn}OBJ)\n";
1054 if ($vc && $w32)
1055 {
1056 $ret.="\t\$(MKSHLIB) $efile$n.dll $def @<<\n \$(${nn}OBJ_F)\n<<\n";
1057 }
1058 $ret.="\n";
1059 return($ret);
1060 }
1061
1062# do a rule for each file that says 'copy' to new direcory on change
1063sub do_copy_rule
1064 {
1065 local($to,$files,$p)=@_;
1066 local($ret,$_,$n,$pp);
1067
1068 $files =~ s/\//$o/g if $o ne '/';
1069 foreach (split(/\s+/,$files))
1070 {
1071 $n=&bname($_);
1072 if ($n =~ /bss_file/)
1073 { $pp=".c"; }
1074 else { $pp=$p; }
1075 $ret.="$to${o}$n$pp: \$(SRC_D)$o$_$pp\n\t\$(CP) \"\$(SRC_D)$o$_$pp\" \"$to${o}$n$pp\"\n\n";
1076 }
1077 return($ret);
1078 }
1079
1080sub read_options
1081 {
1082 # Many options are handled in a similar way. In particular
1083 # no-xxx sets zero or more scalars to 1.
1084 # Process these using a hash containing the option name and
1085 # reference to the scalars to set.
1086
1087 my %valid_options = (
1088 "no-rc2" => \$no_rc2,
1089 "no-rc4" => \$no_rc4,
1090 "no-rc5" => \$no_rc5,
1091 "no-idea" => \$no_idea,
1092 "no-aes" => \$no_aes,
1093 "no-camellia" => \$no_camellia,
1094 "no-seed" => \$no_seed,
1095 "no-des" => \$no_des,
1096 "no-bf" => \$no_bf,
1097 "no-cast" => \$no_cast,
1098 "no-md2" => \$no_md2,
1099 "no-md4" => \$no_md4,
1100 "no-md5" => \$no_md5,
1101 "no-sha" => \$no_sha,
1102 "no-sha1" => \$no_sha1,
1103 "no-ripemd" => \$no_ripemd,
1104 "no-mdc2" => \$no_mdc2,
1105 "no-whirlpool" => \$no_whirlpool,
1106 "no-patents" =>
1107 [\$no_rc2, \$no_rc4, \$no_rc5, \$no_idea, \$no_rsa],
1108 "no-rsa" => \$no_rsa,
1109 "no-dsa" => \$no_dsa,
1110 "no-dh" => \$no_dh,
1111 "no-hmac" => \$no_hmac,
1112 "no-asm" => \$no_asm,
1113 "nasm" => \$nasm,
1114 "nw-nasm" => \$nw_nasm,
1115 "nw-mwasm" => \$nw_mwasm,
1116 "gaswin" => \$gaswin,
1117 "no-ssl2" => \$no_ssl2,
1118 "no-ssl3" => \$no_ssl3,
1119 "no-tlsext" => \$no_tlsext,
1120 "no-srp" => \$no_srp,
1121 "no-cms" => \$no_cms,
1122 "no-ec2m" => \$no_ec2m,
1123 "no-jpake" => \$no_jpake,
1124 "no-ec_nistp_64_gcc_128" => 0,
1125 "no-err" => \$no_err,
1126 "no-sock" => \$no_sock,
1127 "no-krb5" => \$no_krb5,
1128 "no-ec" => \$no_ec,
1129 "no-ecdsa" => \$no_ecdsa,
1130 "no-ecdh" => \$no_ecdh,
1131 "no-gost" => \$no_gost,
1132 "no-engine" => \$no_engine,
1133 "no-hw" => \$no_hw,
1134 "no-rsax" => 0,
1135 "just-ssl" =>
1136 [\$no_rc2, \$no_idea, \$no_des, \$no_bf, \$no_cast,
1137 \$no_md2, \$no_sha, \$no_mdc2, \$no_dsa, \$no_dh,
1138 \$no_ssl2, \$no_err, \$no_ripemd, \$no_rc5,
1139 \$no_aes, \$no_camellia, \$no_seed, \$no_srp],
1140 "rsaref" => 0,
1141 "gcc" => \$gcc,
1142 "debug" => \$debug,
1143 "profile" => \$profile,
1144 "shlib" => \$shlib,
1145 "dll" => \$shlib,
1146 "shared" => 0,
1147 "no-sctp" => 0,
1148 "no-gmp" => 0,
1149 "no-rfc3779" => 0,
1150 "no-montasm" => 0,
1151 "no-shared" => 0,
1152 "no-store" => 0,
1153 "no-zlib" => 0,
1154 "no-zlib-dynamic" => 0,
1155 "fips" => \$fips
1156 );
1157
1158 if (exists $valid_options{$_})
1159 {
1160 my $r = $valid_options{$_};
1161 if ( ref $r eq "SCALAR")
1162 { $$r = 1;}
1163 elsif ( ref $r eq "ARRAY")
1164 {
1165 my $r2;
1166 foreach $r2 (@$r)
1167 {
1168 $$r2 = 1;
1169 }
1170 }
1171 }
1172 elsif (/^no-comp$/) { $xcflags = "-DOPENSSL_NO_COMP $xcflags"; }
1173 elsif (/^enable-zlib$/) { $zlib_opt = 1 if $zlib_opt == 0 }
1174 elsif (/^enable-zlib-dynamic$/)
1175 {
1176 $zlib_opt = 2;
1177 }
1178 elsif (/^no-static-engine/)
1179 {
1180 $no_static_engine = 1;
1181 }
1182 elsif (/^enable-static-engine/)
1183 {
1184 $no_static_engine = 0;
1185 }
1186 # There are also enable-xxx options which correspond to
1187 # the no-xxx. Since the scalars are enabled by default
1188 # these can be ignored.
1189 elsif (/^enable-/)
1190 {
1191 my $t = $_;
1192 $t =~ s/^enable/no/;
1193 if (exists $valid_options{$t})
1194 {return 1;}
1195 return 0;
1196 }
1197 # experimental-xxx is mostly like enable-xxx, but opensslconf.v
1198 # will still set OPENSSL_NO_xxx unless we set OPENSSL_EXPERIMENTAL_xxx.
1199 # (No need to fail if we don't know the algorithm -- this is for adventurous users only.)
1200 elsif (/^experimental-/)
1201 {
1202 my $algo, $ALGO;
1203 ($algo = $_) =~ s/^experimental-//;
1204 ($ALGO = $algo) =~ tr/[a-z]/[A-Z]/;
1205
1206 $xcflags="-DOPENSSL_EXPERIMENTAL_$ALGO $xcflags";
1207
1208 }
1209 elsif (/^--with-krb5-flavor=(.*)$/)
1210 {
1211 my $krb5_flavor = $1;
1212 if ($krb5_flavor =~ /^force-[Hh]eimdal$/)
1213 {
1214 $xcflags="-DKRB5_HEIMDAL $xcflags";
1215 }
1216 elsif ($krb5_flavor =~ /^MIT/i)
1217 {
1218 $xcflags="-DKRB5_MIT $xcflags";
1219 if ($krb5_flavor =~ /^MIT[._-]*1[._-]*[01]/i)
1220 {
1221 $xcflags="-DKRB5_MIT_OLD11 $xcflags"
1222 }
1223 }
1224 }
1225 elsif (/^([^=]*)=(.*)$/){ $VARS{$1}=$2; }
1226 elsif (/^-[lL].*$/) { $l_flags.="$_ "; }
1227 elsif ((!/^-help/) && (!/^-h/) && (!/^-\?/) && /^-.*$/)
1228 { $c_flags.="$_ "; }
1229 else { return(0); }
1230 return(1);
1231 }
diff --git a/src/lib/libcrypto/util/mkcerts.sh b/src/lib/libcrypto/util/mkcerts.sh
new file mode 100644
index 0000000000..0184fcb70e
--- /dev/null
+++ b/src/lib/libcrypto/util/mkcerts.sh
@@ -0,0 +1,220 @@
1#!/bin/sh
2
3# This script will re-make all the required certs.
4# cd apps
5# sh ../util/mkcerts.sh
6# mv ca-cert.pem pca-cert.pem ../certs
7# cd ..
8# cat certs/*.pem >>apps/server.pem
9# cat certs/*.pem >>apps/server2.pem
10# SSLEAY=`pwd`/apps/ssleay; export SSLEAY
11# sh tools/c_rehash certs
12#
13
14CAbits=1024
15SSLEAY="../apps/openssl"
16CONF="-config ../apps/openssl.cnf"
17
18# create pca request.
19echo creating $CAbits bit PCA cert request
20$SSLEAY req $CONF \
21 -new -md5 -newkey $CAbits \
22 -keyout pca-key.pem \
23 -out pca-req.pem -nodes >/dev/null <<EOF
24AU
25Queensland
26.
27CryptSoft Pty Ltd
28.
29Test PCA (1024 bit)
30
31
32
33EOF
34
35if [ $? != 0 ]; then
36 echo problems generating PCA request
37 exit 1
38fi
39
40#sign it.
41echo
42echo self signing PCA
43$SSLEAY x509 -md5 -days 1461 \
44 -req -signkey pca-key.pem \
45 -CAcreateserial -CAserial pca-cert.srl \
46 -in pca-req.pem -out pca-cert.pem
47
48if [ $? != 0 ]; then
49 echo problems self signing PCA cert
50 exit 1
51fi
52echo
53
54# create ca request.
55echo creating $CAbits bit CA cert request
56$SSLEAY req $CONF \
57 -new -md5 -newkey $CAbits \
58 -keyout ca-key.pem \
59 -out ca-req.pem -nodes >/dev/null <<EOF
60AU
61Queensland
62.
63CryptSoft Pty Ltd
64.
65Test CA (1024 bit)
66
67
68
69EOF
70
71if [ $? != 0 ]; then
72 echo problems generating CA request
73 exit 1
74fi
75
76#sign it.
77echo
78echo signing CA
79$SSLEAY x509 -md5 -days 1461 \
80 -req \
81 -CAcreateserial -CAserial pca-cert.srl \
82 -CA pca-cert.pem -CAkey pca-key.pem \
83 -in ca-req.pem -out ca-cert.pem
84
85if [ $? != 0 ]; then
86 echo problems signing CA cert
87 exit 1
88fi
89echo
90
91# create server request.
92echo creating 512 bit server cert request
93$SSLEAY req $CONF \
94 -new -md5 -newkey 512 \
95 -keyout s512-key.pem \
96 -out s512-req.pem -nodes >/dev/null <<EOF
97AU
98Queensland
99.
100CryptSoft Pty Ltd
101.
102Server test cert (512 bit)
103
104
105
106EOF
107
108if [ $? != 0 ]; then
109 echo problems generating 512 bit server cert request
110 exit 1
111fi
112
113#sign it.
114echo
115echo signing 512 bit server cert
116$SSLEAY x509 -md5 -days 365 \
117 -req \
118 -CAcreateserial -CAserial ca-cert.srl \
119 -CA ca-cert.pem -CAkey ca-key.pem \
120 -in s512-req.pem -out server.pem
121
122if [ $? != 0 ]; then
123 echo problems signing 512 bit server cert
124 exit 1
125fi
126echo
127
128# create 1024 bit server request.
129echo creating 1024 bit server cert request
130$SSLEAY req $CONF \
131 -new -md5 -newkey 1024 \
132 -keyout s1024key.pem \
133 -out s1024req.pem -nodes >/dev/null <<EOF
134AU
135Queensland
136.
137CryptSoft Pty Ltd
138.
139Server test cert (1024 bit)
140
141
142
143EOF
144
145if [ $? != 0 ]; then
146 echo problems generating 1024 bit server cert request
147 exit 1
148fi
149
150#sign it.
151echo
152echo signing 1024 bit server cert
153$SSLEAY x509 -md5 -days 365 \
154 -req \
155 -CAcreateserial -CAserial ca-cert.srl \
156 -CA ca-cert.pem -CAkey ca-key.pem \
157 -in s1024req.pem -out server2.pem
158
159if [ $? != 0 ]; then
160 echo problems signing 1024 bit server cert
161 exit 1
162fi
163echo
164
165# create 512 bit client request.
166echo creating 512 bit client cert request
167$SSLEAY req $CONF \
168 -new -md5 -newkey 512 \
169 -keyout c512-key.pem \
170 -out c512-req.pem -nodes >/dev/null <<EOF
171AU
172Queensland
173.
174CryptSoft Pty Ltd
175.
176Client test cert (512 bit)
177
178
179
180EOF
181
182if [ $? != 0 ]; then
183 echo problems generating 512 bit client cert request
184 exit 1
185fi
186
187#sign it.
188echo
189echo signing 512 bit client cert
190$SSLEAY x509 -md5 -days 365 \
191 -req \
192 -CAcreateserial -CAserial ca-cert.srl \
193 -CA ca-cert.pem -CAkey ca-key.pem \
194 -in c512-req.pem -out client.pem
195
196if [ $? != 0 ]; then
197 echo problems signing 512 bit client cert
198 exit 1
199fi
200
201echo cleanup
202
203cat pca-key.pem >> pca-cert.pem
204cat ca-key.pem >> ca-cert.pem
205cat s512-key.pem >> server.pem
206cat s1024key.pem >> server2.pem
207cat c512-key.pem >> client.pem
208
209for i in pca-cert.pem ca-cert.pem server.pem server2.pem client.pem
210do
211$SSLEAY x509 -issuer -subject -in $i -noout >$$
212cat $$
213/bin/cat $i >>$$
214/bin/mv $$ $i
215done
216
217#/bin/rm -f *key.pem *req.pem *.srl
218
219echo Finished
220
diff --git a/src/lib/libcrypto/util/mkdef.pl b/src/lib/libcrypto/util/mkdef.pl
new file mode 100644
index 0000000000..9a8c7b87d1
--- /dev/null
+++ b/src/lib/libcrypto/util/mkdef.pl
@@ -0,0 +1,1539 @@
1#!/usr/local/bin/perl -w
2#
3# generate a .def file
4#
5# It does this by parsing the header files and looking for the
6# prototyped functions: it then prunes the output.
7#
8# Intermediary files are created, call libeay.num and ssleay.num,...
9# Previously, they had the following format:
10#
11# routine-name nnnn
12#
13# But that isn't enough for a number of reasons, the first on being that
14# this format is (needlessly) very Win32-centric, and even then...
15# One of the biggest problems is that there's no information about what
16# routines should actually be used, which varies with what crypto algorithms
17# are disabled. Also, some operating systems (for example VMS with VAX C)
18# need to keep track of the global variables as well as the functions.
19#
20# So, a remake of this script is done so as to include information on the
21# kind of symbol it is (function or variable) and what algorithms they're
22# part of. This will allow easy translating to .def files or the corresponding
23# file in other operating systems (a .opt file for VMS, possibly with a .mar
24# file).
25#
26# The format now becomes:
27#
28# routine-name nnnn info
29#
30# and the "info" part is actually a colon-separated string of fields with
31# the following meaning:
32#
33# existence:platform:kind:algorithms
34#
35# - "existence" can be "EXIST" or "NOEXIST" depending on if the symbol is
36# found somewhere in the source,
37# - "platforms" is empty if it exists on all platforms, otherwise it contains
38# comma-separated list of the platform, just as they are if the symbol exists
39# for those platforms, or prepended with a "!" if not. This helps resolve
40# symbol name variants for platforms where the names are too long for the
41# compiler or linker, or if the systems is case insensitive and there is a
42# clash, or the symbol is implemented differently (see
43# EXPORT_VAR_AS_FUNCTION). This script assumes renaming of symbols is found
44# in the file crypto/symhacks.h.
45# The semantics for the platforms is that every item is checked against the
46# environment. For the negative items ("!FOO"), if any of them is false
47# (i.e. "FOO" is true) in the environment, the corresponding symbol can't be
48# used. For the positive itms, if all of them are false in the environment,
49# the corresponding symbol can't be used. Any combination of positive and
50# negative items are possible, and of course leave room for some redundancy.
51# - "kind" is "FUNCTION" or "VARIABLE". The meaning of that is obvious.
52# - "algorithms" is a comma-separated list of algorithm names. This helps
53# exclude symbols that are part of an algorithm that some user wants to
54# exclude.
55#
56
57my $debug=0;
58
59my $crypto_num= "util/libeay.num";
60my $ssl_num= "util/ssleay.num";
61my $libname;
62
63my $do_update = 0;
64my $do_rewrite = 1;
65my $do_crypto = 0;
66my $do_ssl = 0;
67my $do_ctest = 0;
68my $do_ctestall = 0;
69my $do_checkexist = 0;
70
71my $VMSVAX=0;
72my $VMSNonVAX=0;
73my $VMS=0;
74my $W32=0;
75my $W16=0;
76my $NT=0;
77my $OS2=0;
78# Set this to make typesafe STACK definitions appear in DEF
79my $safe_stack_def = 0;
80
81my @known_platforms = ( "__FreeBSD__", "PERL5", "NeXT",
82 "EXPORT_VAR_AS_FUNCTION", "ZLIB", "OPENSSL_FIPS" );
83my @known_ossl_platforms = ( "VMS", "WIN16", "WIN32", "WINNT", "OS2" );
84my @known_algorithms = ( "RC2", "RC4", "RC5", "IDEA", "DES", "BF",
85 "CAST", "MD2", "MD4", "MD5", "SHA", "SHA0", "SHA1",
86 "SHA256", "SHA512", "RIPEMD",
87 "MDC2", "WHIRLPOOL", "RSA", "DSA", "DH", "EC", "ECDH", "ECDSA", "EC2M",
88 "HMAC", "AES", "CAMELLIA", "SEED", "GOST",
89 # EC_NISTP_64_GCC_128
90 "EC_NISTP_64_GCC_128",
91 # Envelope "algorithms"
92 "EVP", "X509", "ASN1_TYPEDEFS",
93 # Helper "algorithms"
94 "BIO", "COMP", "BUFFER", "LHASH", "STACK", "ERR",
95 "LOCKING",
96 # External "algorithms"
97 "FP_API", "STDIO", "SOCK", "KRB5", "DGRAM",
98 # Engines
99 "STATIC_ENGINE", "ENGINE", "HW", "GMP",
100 # RFC3779
101 "RFC3779",
102 # TLS
103 "TLSEXT", "PSK", "SRP", "HEARTBEATS",
104 # CMS
105 "CMS",
106 # CryptoAPI Engine
107 "CAPIENG",
108 # SSL v2
109 "SSL2",
110 # JPAKE
111 "JPAKE",
112 # NEXTPROTONEG
113 "NEXTPROTONEG",
114 # Deprecated functions
115 "DEPRECATED",
116 # Hide SSL internals
117 "SSL_INTERN",
118 # SCTP
119 "SCTP");
120
121my $options="";
122open(IN,"<Makefile") || die "unable to open Makefile!\n";
123while(<IN>) {
124 $options=$1 if (/^OPTIONS=(.*)$/);
125}
126close(IN);
127
128# The following ciphers may be excluded (by Configure). This means functions
129# defined with ifndef(NO_XXX) are not included in the .def file, and everything
130# in directory xxx is ignored.
131my $no_rc2; my $no_rc4; my $no_rc5; my $no_idea; my $no_des; my $no_bf;
132my $no_cast; my $no_whirlpool; my $no_camellia; my $no_seed;
133my $no_md2; my $no_md4; my $no_md5; my $no_sha; my $no_ripemd; my $no_mdc2;
134my $no_rsa; my $no_dsa; my $no_dh; my $no_hmac=0; my $no_aes; my $no_krb5;
135my $no_ec; my $no_ecdsa; my $no_ecdh; my $no_engine; my $no_hw;
136my $no_fp_api; my $no_static_engine=1; my $no_gmp; my $no_deprecated;
137my $no_rfc3779; my $no_psk; my $no_tlsext; my $no_cms; my $no_capieng;
138my $no_jpake; my $no_srp; my $no_ssl2; my $no_ec2m; my $no_nistp_gcc;
139my $no_nextprotoneg; my $no_sctp;
140
141my $fips;
142
143my $zlib;
144
145
146foreach (@ARGV, split(/ /, $options))
147 {
148 $debug=1 if $_ eq "debug";
149 $W32=1 if $_ eq "32";
150 $W16=1 if $_ eq "16";
151 if($_ eq "NT") {
152 $W32 = 1;
153 $NT = 1;
154 }
155 if ($_ eq "VMS-VAX") {
156 $VMS=1;
157 $VMSVAX=1;
158 }
159 if ($_ eq "VMS-NonVAX") {
160 $VMS=1;
161 $VMSNonVAX=1;
162 }
163 $VMS=1 if $_ eq "VMS";
164 $OS2=1 if $_ eq "OS2";
165 $fips=1 if /^fips/;
166 if ($_ eq "zlib" || $_ eq "enable-zlib" || $_ eq "zlib-dynamic"
167 || $_ eq "enable-zlib-dynamic") {
168 $zlib = 1;
169 }
170
171 $do_ssl=1 if $_ eq "ssleay";
172 if ($_ eq "ssl") {
173 $do_ssl=1;
174 $libname=$_
175 }
176 $do_crypto=1 if $_ eq "libeay";
177 if ($_ eq "crypto") {
178 $do_crypto=1;
179 $libname=$_;
180 }
181 $no_static_engine=1 if $_ eq "no-static-engine";
182 $no_static_engine=0 if $_ eq "enable-static-engine";
183 $do_update=1 if $_ eq "update";
184 $do_rewrite=1 if $_ eq "rewrite";
185 $do_ctest=1 if $_ eq "ctest";
186 $do_ctestall=1 if $_ eq "ctestall";
187 $do_checkexist=1 if $_ eq "exist";
188 #$safe_stack_def=1 if $_ eq "-DDEBUG_SAFESTACK";
189
190 if (/^no-rc2$/) { $no_rc2=1; }
191 elsif (/^no-rc4$/) { $no_rc4=1; }
192 elsif (/^no-rc5$/) { $no_rc5=1; }
193 elsif (/^no-idea$/) { $no_idea=1; }
194 elsif (/^no-des$/) { $no_des=1; $no_mdc2=1; }
195 elsif (/^no-bf$/) { $no_bf=1; }
196 elsif (/^no-cast$/) { $no_cast=1; }
197 elsif (/^no-whirlpool$/) { $no_whirlpool=1; }
198 elsif (/^no-md2$/) { $no_md2=1; }
199 elsif (/^no-md4$/) { $no_md4=1; }
200 elsif (/^no-md5$/) { $no_md5=1; }
201 elsif (/^no-sha$/) { $no_sha=1; }
202 elsif (/^no-ripemd$/) { $no_ripemd=1; }
203 elsif (/^no-mdc2$/) { $no_mdc2=1; }
204 elsif (/^no-rsa$/) { $no_rsa=1; }
205 elsif (/^no-dsa$/) { $no_dsa=1; }
206 elsif (/^no-dh$/) { $no_dh=1; }
207 elsif (/^no-ec$/) { $no_ec=1; }
208 elsif (/^no-ecdsa$/) { $no_ecdsa=1; }
209 elsif (/^no-ecdh$/) { $no_ecdh=1; }
210 elsif (/^no-hmac$/) { $no_hmac=1; }
211 elsif (/^no-aes$/) { $no_aes=1; }
212 elsif (/^no-camellia$/) { $no_camellia=1; }
213 elsif (/^no-seed$/) { $no_seed=1; }
214 elsif (/^no-evp$/) { $no_evp=1; }
215 elsif (/^no-lhash$/) { $no_lhash=1; }
216 elsif (/^no-stack$/) { $no_stack=1; }
217 elsif (/^no-err$/) { $no_err=1; }
218 elsif (/^no-buffer$/) { $no_buffer=1; }
219 elsif (/^no-bio$/) { $no_bio=1; }
220 #elsif (/^no-locking$/) { $no_locking=1; }
221 elsif (/^no-comp$/) { $no_comp=1; }
222 elsif (/^no-dso$/) { $no_dso=1; }
223 elsif (/^no-krb5$/) { $no_krb5=1; }
224 elsif (/^no-engine$/) { $no_engine=1; }
225 elsif (/^no-hw$/) { $no_hw=1; }
226 elsif (/^no-gmp$/) { $no_gmp=1; }
227 elsif (/^no-rfc3779$/) { $no_rfc3779=1; }
228 elsif (/^no-tlsext$/) { $no_tlsext=1; }
229 elsif (/^no-cms$/) { $no_cms=1; }
230 elsif (/^no-ec2m$/) { $no_ec2m=1; }
231 elsif (/^no-ec_nistp_64_gcc_128$/) { $no_nistp_gcc=1; }
232 elsif (/^no-nextprotoneg$/) { $no_nextprotoneg=1; }
233 elsif (/^no-ssl2$/) { $no_ssl2=1; }
234 elsif (/^no-capieng$/) { $no_capieng=1; }
235 elsif (/^no-jpake$/) { $no_jpake=1; }
236 elsif (/^no-srp$/) { $no_srp=1; }
237 elsif (/^no-sctp$/) { $no_sctp=1; }
238 }
239
240
241if (!$libname) {
242 if ($do_ssl) {
243 $libname="SSLEAY";
244 }
245 if ($do_crypto) {
246 $libname="LIBEAY";
247 }
248}
249
250# If no platform is given, assume WIN32
251if ($W32 + $W16 + $VMS + $OS2 == 0) {
252 $W32 = 1;
253}
254
255# Add extra knowledge
256if ($W16) {
257 $no_fp_api=1;
258}
259
260if (!$do_ssl && !$do_crypto)
261 {
262 print STDERR "usage: $0 ( ssl | crypto ) [ 16 | 32 | NT | OS2 ]\n";
263 exit(1);
264 }
265
266%ssl_list=&load_numbers($ssl_num);
267$max_ssl = $max_num;
268%crypto_list=&load_numbers($crypto_num);
269$max_crypto = $max_num;
270
271my $ssl="ssl/ssl.h";
272$ssl.=" ssl/kssl.h";
273$ssl.=" ssl/tls1.h";
274$ssl.=" ssl/srtp.h";
275
276my $crypto ="crypto/crypto.h";
277$crypto.=" crypto/cryptlib.h";
278$crypto.=" crypto/o_dir.h";
279$crypto.=" crypto/o_str.h";
280$crypto.=" crypto/o_time.h";
281$crypto.=" crypto/des/des.h crypto/des/des_old.h" ; # unless $no_des;
282$crypto.=" crypto/idea/idea.h" ; # unless $no_idea;
283$crypto.=" crypto/rc4/rc4.h" ; # unless $no_rc4;
284$crypto.=" crypto/rc5/rc5.h" ; # unless $no_rc5;
285$crypto.=" crypto/rc2/rc2.h" ; # unless $no_rc2;
286$crypto.=" crypto/bf/blowfish.h" ; # unless $no_bf;
287$crypto.=" crypto/cast/cast.h" ; # unless $no_cast;
288$crypto.=" crypto/whrlpool/whrlpool.h" ;
289$crypto.=" crypto/md2/md2.h" ; # unless $no_md2;
290$crypto.=" crypto/md4/md4.h" ; # unless $no_md4;
291$crypto.=" crypto/md5/md5.h" ; # unless $no_md5;
292$crypto.=" crypto/mdc2/mdc2.h" ; # unless $no_mdc2;
293$crypto.=" crypto/sha/sha.h" ; # unless $no_sha;
294$crypto.=" crypto/ripemd/ripemd.h" ; # unless $no_ripemd;
295$crypto.=" crypto/aes/aes.h" ; # unless $no_aes;
296$crypto.=" crypto/camellia/camellia.h" ; # unless $no_camellia;
297$crypto.=" crypto/seed/seed.h"; # unless $no_seed;
298
299$crypto.=" crypto/bn/bn.h";
300$crypto.=" crypto/rsa/rsa.h" ; # unless $no_rsa;
301$crypto.=" crypto/dsa/dsa.h" ; # unless $no_dsa;
302$crypto.=" crypto/dh/dh.h" ; # unless $no_dh;
303$crypto.=" crypto/ec/ec.h" ; # unless $no_ec;
304$crypto.=" crypto/ecdsa/ecdsa.h" ; # unless $no_ecdsa;
305$crypto.=" crypto/ecdh/ecdh.h" ; # unless $no_ecdh;
306$crypto.=" crypto/hmac/hmac.h" ; # unless $no_hmac;
307$crypto.=" crypto/cmac/cmac.h" ; # unless $no_hmac;
308
309$crypto.=" crypto/engine/engine.h"; # unless $no_engine;
310$crypto.=" crypto/stack/stack.h" ; # unless $no_stack;
311$crypto.=" crypto/buffer/buffer.h" ; # unless $no_buffer;
312$crypto.=" crypto/bio/bio.h" ; # unless $no_bio;
313$crypto.=" crypto/dso/dso.h" ; # unless $no_dso;
314$crypto.=" crypto/lhash/lhash.h" ; # unless $no_lhash;
315$crypto.=" crypto/conf/conf.h";
316$crypto.=" crypto/txt_db/txt_db.h";
317
318$crypto.=" crypto/evp/evp.h" ; # unless $no_evp;
319$crypto.=" crypto/objects/objects.h";
320$crypto.=" crypto/pem/pem.h";
321#$crypto.=" crypto/meth/meth.h";
322$crypto.=" crypto/asn1/asn1.h";
323$crypto.=" crypto/asn1/asn1t.h";
324$crypto.=" crypto/asn1/asn1_mac.h";
325$crypto.=" crypto/err/err.h" ; # unless $no_err;
326$crypto.=" crypto/pkcs7/pkcs7.h";
327$crypto.=" crypto/pkcs12/pkcs12.h";
328$crypto.=" crypto/x509/x509.h";
329$crypto.=" crypto/x509/x509_vfy.h";
330$crypto.=" crypto/x509v3/x509v3.h";
331$crypto.=" crypto/ts/ts.h";
332$crypto.=" crypto/rand/rand.h";
333$crypto.=" crypto/comp/comp.h" ; # unless $no_comp;
334$crypto.=" crypto/ocsp/ocsp.h";
335$crypto.=" crypto/ui/ui.h crypto/ui/ui_compat.h";
336$crypto.=" crypto/krb5/krb5_asn.h";
337#$crypto.=" crypto/store/store.h";
338$crypto.=" crypto/pqueue/pqueue.h";
339$crypto.=" crypto/cms/cms.h";
340$crypto.=" crypto/jpake/jpake.h";
341$crypto.=" crypto/modes/modes.h";
342$crypto.=" crypto/srp/srp.h";
343
344my $symhacks="crypto/symhacks.h";
345
346my @ssl_symbols = &do_defs("SSLEAY", $ssl, $symhacks);
347my @crypto_symbols = &do_defs("LIBEAY", $crypto, $symhacks);
348
349if ($do_update) {
350
351if ($do_ssl == 1) {
352
353 &maybe_add_info("SSLEAY",*ssl_list,@ssl_symbols);
354 if ($do_rewrite == 1) {
355 open(OUT, ">$ssl_num");
356 &rewrite_numbers(*OUT,"SSLEAY",*ssl_list,@ssl_symbols);
357 } else {
358 open(OUT, ">>$ssl_num");
359 }
360 &update_numbers(*OUT,"SSLEAY",*ssl_list,$max_ssl,@ssl_symbols);
361 close OUT;
362}
363
364if($do_crypto == 1) {
365
366 &maybe_add_info("LIBEAY",*crypto_list,@crypto_symbols);
367 if ($do_rewrite == 1) {
368 open(OUT, ">$crypto_num");
369 &rewrite_numbers(*OUT,"LIBEAY",*crypto_list,@crypto_symbols);
370 } else {
371 open(OUT, ">>$crypto_num");
372 }
373 &update_numbers(*OUT,"LIBEAY",*crypto_list,$max_crypto,@crypto_symbols);
374 close OUT;
375}
376
377} elsif ($do_checkexist) {
378 &check_existing(*ssl_list, @ssl_symbols)
379 if $do_ssl == 1;
380 &check_existing(*crypto_list, @crypto_symbols)
381 if $do_crypto == 1;
382} elsif ($do_ctest || $do_ctestall) {
383
384 print <<"EOF";
385
386/* Test file to check all DEF file symbols are present by trying
387 * to link to all of them. This is *not* intended to be run!
388 */
389
390int main()
391{
392EOF
393 &print_test_file(*STDOUT,"SSLEAY",*ssl_list,$do_ctestall,@ssl_symbols)
394 if $do_ssl == 1;
395
396 &print_test_file(*STDOUT,"LIBEAY",*crypto_list,$do_ctestall,@crypto_symbols)
397 if $do_crypto == 1;
398
399 print "}\n";
400
401} else {
402
403 &print_def_file(*STDOUT,$libname,*ssl_list,@ssl_symbols)
404 if $do_ssl == 1;
405
406 &print_def_file(*STDOUT,$libname,*crypto_list,@crypto_symbols)
407 if $do_crypto == 1;
408
409}
410
411
412sub do_defs
413{
414 my($name,$files,$symhacksfile)=@_;
415 my $file;
416 my @ret;
417 my %syms;
418 my %platform; # For anything undefined, we assume ""
419 my %kind; # For anything undefined, we assume "FUNCTION"
420 my %algorithm; # For anything undefined, we assume ""
421 my %variant;
422 my %variant_cnt; # To be able to allocate "name{n}" if "name"
423 # is the same name as the original.
424 my $cpp;
425 my %unknown_algorithms = ();
426
427 foreach $file (split(/\s+/,$symhacksfile." ".$files))
428 {
429 print STDERR "DEBUG: starting on $file:\n" if $debug;
430 open(IN,"<$file") || die "unable to open $file:$!\n";
431 my $line = "", my $def= "";
432 my %tag = (
433 (map { $_ => 0 } @known_platforms),
434 (map { "OPENSSL_SYS_".$_ => 0 } @known_ossl_platforms),
435 (map { "OPENSSL_NO_".$_ => 0 } @known_algorithms),
436 NOPROTO => 0,
437 PERL5 => 0,
438 _WINDLL => 0,
439 CONST_STRICT => 0,
440 TRUE => 1,
441 );
442 my $symhacking = $file eq $symhacksfile;
443 my @current_platforms = ();
444 my @current_algorithms = ();
445
446 # params: symbol, alias, platforms, kind
447 # The reason to put this subroutine in a variable is that
448 # it will otherwise create it's own, unshared, version of
449 # %tag and %variant...
450 my $make_variant = sub
451 {
452 my ($s, $a, $p, $k) = @_;
453 my ($a1, $a2);
454
455 print STDERR "DEBUG: make_variant: Entered with ",$s,", ",$a,", ",(defined($p)?$p:""),", ",(defined($k)?$k:""),"\n" if $debug;
456 if (defined($p))
457 {
458 $a1 = join(",",$p,
459 grep(!/^$/,
460 map { $tag{$_} == 1 ? $_ : "" }
461 @known_platforms));
462 }
463 else
464 {
465 $a1 = join(",",
466 grep(!/^$/,
467 map { $tag{$_} == 1 ? $_ : "" }
468 @known_platforms));
469 }
470 $a2 = join(",",
471 grep(!/^$/,
472 map { $tag{"OPENSSL_SYS_".$_} == 1 ? $_ : "" }
473 @known_ossl_platforms));
474 print STDERR "DEBUG: make_variant: a1 = $a1; a2 = $a2\n" if $debug;
475 if ($a1 eq "") { $a1 = $a2; }
476 elsif ($a1 ne "" && $a2 ne "") { $a1 .= ",".$a2; }
477 if ($a eq $s)
478 {
479 if (!defined($variant_cnt{$s}))
480 {
481 $variant_cnt{$s} = 0;
482 }
483 $variant_cnt{$s}++;
484 $a .= "{$variant_cnt{$s}}";
485 }
486 my $toadd = $a.":".$a1.(defined($k)?":".$k:"");
487 my $togrep = $s.'(\{[0-9]+\})?:'.$a1.(defined($k)?":".$k:"");
488 if (!grep(/^$togrep$/,
489 split(/;/, defined($variant{$s})?$variant{$s}:""))) {
490 if (defined($variant{$s})) { $variant{$s} .= ";"; }
491 $variant{$s} .= $toadd;
492 }
493 print STDERR "DEBUG: make_variant: Exit with variant of ",$s," = ",$variant{$s},"\n" if $debug;
494 };
495
496 print STDERR "DEBUG: parsing ----------\n" if $debug;
497 while(<IN>) {
498 if (/\/\* Error codes for the \w+ functions\. \*\//)
499 {
500 undef @tag;
501 last;
502 }
503 if ($line ne '') {
504 $_ = $line . $_;
505 $line = '';
506 }
507
508 if (/\\$/) {
509 chomp; # remove eol
510 chop; # remove ending backslash
511 $line = $_;
512 next;
513 }
514
515 if(/\/\*/) {
516 if (not /\*\//) { # multiline comment...
517 $line = $_; # ... just accumulate
518 next;
519 } else {
520 s/\/\*.*?\*\///gs;# wipe it
521 }
522 }
523
524 if ($cpp) {
525 $cpp++ if /^#\s*if/;
526 $cpp-- if /^#\s*endif/;
527 next;
528 }
529 $cpp = 1 if /^#.*ifdef.*cplusplus/;
530
531 s/{[^{}]*}//gs; # ignore {} blocks
532 print STDERR "DEBUG: \$def=\"$def\"\n" if $debug && $def ne "";
533 print STDERR "DEBUG: \$_=\"$_\"\n" if $debug;
534 if (/^\#\s*ifndef\s+(.*)/) {
535 push(@tag,"-");
536 push(@tag,$1);
537 $tag{$1}=-1;
538 print STDERR "DEBUG: $file: found tag $1 = -1\n" if $debug;
539 } elsif (/^\#\s*if\s+!defined\(([^\)]+)\)/) {
540 push(@tag,"-");
541 if (/^\#\s*if\s+(!defined\(([^\)]+)\)(\s+\&\&\s+!defined\(([^\)]+)\))*)$/) {
542 my $tmp_1 = $1;
543 my $tmp_;
544 foreach $tmp_ (split '\&\&',$tmp_1) {
545 $tmp_ =~ /!defined\(([^\)]+)\)/;
546 print STDERR "DEBUG: $file: found tag $1 = -1\n" if $debug;
547 push(@tag,$1);
548 $tag{$1}=-1;
549 }
550 } else {
551 print STDERR "Warning: $file: complicated expression: $_" if $debug; # because it is O...
552 print STDERR "DEBUG: $file: found tag $1 = -1\n" if $debug;
553 push(@tag,$1);
554 $tag{$1}=-1;
555 }
556 } elsif (/^\#\s*ifdef\s+(\S*)/) {
557 push(@tag,"-");
558 push(@tag,$1);
559 $tag{$1}=1;
560 print STDERR "DEBUG: $file: found tag $1 = 1\n" if $debug;
561 } elsif (/^\#\s*if\s+defined\(([^\)]+)\)/) {
562 push(@tag,"-");
563 if (/^\#\s*if\s+(defined\(([^\)]+)\)(\s+\|\|\s+defined\(([^\)]+)\))*)$/) {
564 my $tmp_1 = $1;
565 my $tmp_;
566 foreach $tmp_ (split '\|\|',$tmp_1) {
567 $tmp_ =~ /defined\(([^\)]+)\)/;
568 print STDERR "DEBUG: $file: found tag $1 = 1\n" if $debug;
569 push(@tag,$1);
570 $tag{$1}=1;
571 }
572 } else {
573 print STDERR "Warning: $file: complicated expression: $_\n" if $debug; # because it is O...
574 print STDERR "DEBUG: $file: found tag $1 = 1\n" if $debug;
575 push(@tag,$1);
576 $tag{$1}=1;
577 }
578 } elsif (/^\#\s*error\s+(\w+) is disabled\./) {
579 my $tag_i = $#tag;
580 while($tag[$tag_i] ne "-") {
581 if ($tag[$tag_i] eq "OPENSSL_NO_".$1) {
582 $tag{$tag[$tag_i]}=2;
583 print STDERR "DEBUG: $file: chaged tag $1 = 2\n" if $debug;
584 }
585 $tag_i--;
586 }
587 } elsif (/^\#\s*endif/) {
588 my $tag_i = $#tag;
589 while($tag_i > 0 && $tag[$tag_i] ne "-") {
590 my $t=$tag[$tag_i];
591 print STDERR "DEBUG: \$t=\"$t\"\n" if $debug;
592 if ($tag{$t}==2) {
593 $tag{$t}=-1;
594 } else {
595 $tag{$t}=0;
596 }
597 print STDERR "DEBUG: $file: changed tag ",$t," = ",$tag{$t},"\n" if $debug;
598 pop(@tag);
599 if ($t =~ /^OPENSSL_NO_([A-Z0-9_]+)$/) {
600 $t=$1;
601 } else {
602 $t="";
603 }
604 if ($t ne ""
605 && !grep(/^$t$/, @known_algorithms)) {
606 $unknown_algorithms{$t} = 1;
607 #print STDERR "DEBUG: Added as unknown algorithm: $t\n" if $debug;
608 }
609 $tag_i--;
610 }
611 pop(@tag);
612 } elsif (/^\#\s*else/) {
613 my $tag_i = $#tag;
614 while($tag[$tag_i] ne "-") {
615 my $t=$tag[$tag_i];
616 $tag{$t}= -$tag{$t};
617 print STDERR "DEBUG: $file: changed tag ",$t," = ",$tag{$t},"\n" if $debug;
618 $tag_i--;
619 }
620 } elsif (/^\#\s*if\s+1/) {
621 push(@tag,"-");
622 # Dummy tag
623 push(@tag,"TRUE");
624 $tag{"TRUE"}=1;
625 print STDERR "DEBUG: $file: found 1\n" if $debug;
626 } elsif (/^\#\s*if\s+0/) {
627 push(@tag,"-");
628 # Dummy tag
629 push(@tag,"TRUE");
630 $tag{"TRUE"}=-1;
631 print STDERR "DEBUG: $file: found 0\n" if $debug;
632 } elsif (/^\#\s*define\s+(\w+)\s+(\w+)/
633 && $symhacking && $tag{'TRUE'} != -1) {
634 # This is for aliasing. When we find an alias,
635 # we have to invert
636 &$make_variant($1,$2);
637 print STDERR "DEBUG: $file: defined $1 = $2\n" if $debug;
638 }
639 if (/^\#/) {
640 @current_platforms =
641 grep(!/^$/,
642 map { $tag{$_} == 1 ? $_ :
643 $tag{$_} == -1 ? "!".$_ : "" }
644 @known_platforms);
645 push @current_platforms
646 , grep(!/^$/,
647 map { $tag{"OPENSSL_SYS_".$_} == 1 ? $_ :
648 $tag{"OPENSSL_SYS_".$_} == -1 ? "!".$_ : "" }
649 @known_ossl_platforms);
650 @current_algorithms =
651 grep(!/^$/,
652 map { $tag{"OPENSSL_NO_".$_} == -1 ? $_ : "" }
653 @known_algorithms);
654 $def .=
655 "#INFO:"
656 .join(',',@current_platforms).":"
657 .join(',',@current_algorithms).";";
658 next;
659 }
660 if ($tag{'TRUE'} != -1) {
661 if (/^\s*DECLARE_STACK_OF\s*\(\s*(\w*)\s*\)/) {
662 next;
663 } elsif (/^\s*DECLARE_ASN1_ENCODE_FUNCTIONS\s*\(\s*(\w*)\s*,\s*(\w*)\s*,\s*(\w*)\s*\)/) {
664 $def .= "int d2i_$3(void);";
665 $def .= "int i2d_$3(void);";
666 # Variant for platforms that do not
667 # have to access globale variables
668 # in shared libraries through functions
669 $def .=
670 "#INFO:"
671 .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
672 .join(',',@current_algorithms).";";
673 $def .= "OPENSSL_EXTERN int $2_it;";
674 $def .=
675 "#INFO:"
676 .join(',',@current_platforms).":"
677 .join(',',@current_algorithms).";";
678 # Variant for platforms that have to
679 # access globale variables in shared
680 # libraries through functions
681 &$make_variant("$2_it","$2_it",
682 "EXPORT_VAR_AS_FUNCTION",
683 "FUNCTION");
684 next;
685 } elsif (/^\s*DECLARE_ASN1_FUNCTIONS_fname\s*\(\s*(\w*)\s*,\s*(\w*)\s*,\s*(\w*)\s*\)/) {
686 $def .= "int d2i_$3(void);";
687 $def .= "int i2d_$3(void);";
688 $def .= "int $3_free(void);";
689 $def .= "int $3_new(void);";
690 # Variant for platforms that do not
691 # have to access globale variables
692 # in shared libraries through functions
693 $def .=
694 "#INFO:"
695 .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
696 .join(',',@current_algorithms).";";
697 $def .= "OPENSSL_EXTERN int $2_it;";
698 $def .=
699 "#INFO:"
700 .join(',',@current_platforms).":"
701 .join(',',@current_algorithms).";";
702 # Variant for platforms that have to
703 # access globale variables in shared
704 # libraries through functions
705 &$make_variant("$2_it","$2_it",
706 "EXPORT_VAR_AS_FUNCTION",
707 "FUNCTION");
708 next;
709 } elsif (/^\s*DECLARE_ASN1_FUNCTIONS\s*\(\s*(\w*)\s*\)/ ||
710 /^\s*DECLARE_ASN1_FUNCTIONS_const\s*\(\s*(\w*)\s*\)/) {
711 $def .= "int d2i_$1(void);";
712 $def .= "int i2d_$1(void);";
713 $def .= "int $1_free(void);";
714 $def .= "int $1_new(void);";
715 # Variant for platforms that do not
716 # have to access globale variables
717 # in shared libraries through functions
718 $def .=
719 "#INFO:"
720 .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
721 .join(',',@current_algorithms).";";
722 $def .= "OPENSSL_EXTERN int $1_it;";
723 $def .=
724 "#INFO:"
725 .join(',',@current_platforms).":"
726 .join(',',@current_algorithms).";";
727 # Variant for platforms that have to
728 # access globale variables in shared
729 # libraries through functions
730 &$make_variant("$1_it","$1_it",
731 "EXPORT_VAR_AS_FUNCTION",
732 "FUNCTION");
733 next;
734 } elsif (/^\s*DECLARE_ASN1_ENCODE_FUNCTIONS_const\s*\(\s*(\w*)\s*,\s*(\w*)\s*\)/) {
735 $def .= "int d2i_$2(void);";
736 $def .= "int i2d_$2(void);";
737 # Variant for platforms that do not
738 # have to access globale variables
739 # in shared libraries through functions
740 $def .=
741 "#INFO:"
742 .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
743 .join(',',@current_algorithms).";";
744 $def .= "OPENSSL_EXTERN int $2_it;";
745 $def .=
746 "#INFO:"
747 .join(',',@current_platforms).":"
748 .join(',',@current_algorithms).";";
749 # Variant for platforms that have to
750 # access globale variables in shared
751 # libraries through functions
752 &$make_variant("$2_it","$2_it",
753 "EXPORT_VAR_AS_FUNCTION",
754 "FUNCTION");
755 next;
756 } elsif (/^\s*DECLARE_ASN1_ALLOC_FUNCTIONS\s*\(\s*(\w*)\s*\)/) {
757 $def .= "int $1_free(void);";
758 $def .= "int $1_new(void);";
759 next;
760 } elsif (/^\s*DECLARE_ASN1_FUNCTIONS_name\s*\(\s*(\w*)\s*,\s*(\w*)\s*\)/) {
761 $def .= "int d2i_$2(void);";
762 $def .= "int i2d_$2(void);";
763 $def .= "int $2_free(void);";
764 $def .= "int $2_new(void);";
765 # Variant for platforms that do not
766 # have to access globale variables
767 # in shared libraries through functions
768 $def .=
769 "#INFO:"
770 .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
771 .join(',',@current_algorithms).";";
772 $def .= "OPENSSL_EXTERN int $2_it;";
773 $def .=
774 "#INFO:"
775 .join(',',@current_platforms).":"
776 .join(',',@current_algorithms).";";
777 # Variant for platforms that have to
778 # access globale variables in shared
779 # libraries through functions
780 &$make_variant("$2_it","$2_it",
781 "EXPORT_VAR_AS_FUNCTION",
782 "FUNCTION");
783 next;
784 } elsif (/^\s*DECLARE_ASN1_ITEM\s*\(\s*(\w*)\s*\)/) {
785 # Variant for platforms that do not
786 # have to access globale variables
787 # in shared libraries through functions
788 $def .=
789 "#INFO:"
790 .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
791 .join(',',@current_algorithms).";";
792 $def .= "OPENSSL_EXTERN int $1_it;";
793 $def .=
794 "#INFO:"
795 .join(',',@current_platforms).":"
796 .join(',',@current_algorithms).";";
797 # Variant for platforms that have to
798 # access globale variables in shared
799 # libraries through functions
800 &$make_variant("$1_it","$1_it",
801 "EXPORT_VAR_AS_FUNCTION",
802 "FUNCTION");
803 next;
804 } elsif (/^\s*DECLARE_ASN1_NDEF_FUNCTION\s*\(\s*(\w*)\s*\)/) {
805 $def .= "int i2d_$1_NDEF(void);";
806 } elsif (/^\s*DECLARE_ASN1_SET_OF\s*\(\s*(\w*)\s*\)/) {
807 next;
808 } elsif (/^\s*DECLARE_ASN1_PRINT_FUNCTION\s*\(\s*(\w*)\s*\)/) {
809 $def .= "int $1_print_ctx(void);";
810 next;
811 } elsif (/^\s*DECLARE_ASN1_PRINT_FUNCTION_name\s*\(\s*(\w*)\s*,\s*(\w*)\s*\)/) {
812 $def .= "int $2_print_ctx(void);";
813 next;
814 } elsif (/^\s*DECLARE_PKCS12_STACK_OF\s*\(\s*(\w*)\s*\)/) {
815 next;
816 } elsif (/^DECLARE_PEM_rw\s*\(\s*(\w*)\s*,/ ||
817 /^DECLARE_PEM_rw_cb\s*\(\s*(\w*)\s*,/ ||
818 /^DECLARE_PEM_rw_const\s*\(\s*(\w*)\s*,/ ) {
819 # Things not in Win16
820 $def .=
821 "#INFO:"
822 .join(',',"!WIN16",@current_platforms).":"
823 .join(',',@current_algorithms).";";
824 $def .= "int PEM_read_$1(void);";
825 $def .= "int PEM_write_$1(void);";
826 $def .=
827 "#INFO:"
828 .join(',',@current_platforms).":"
829 .join(',',@current_algorithms).";";
830 # Things that are everywhere
831 $def .= "int PEM_read_bio_$1(void);";
832 $def .= "int PEM_write_bio_$1(void);";
833 next;
834 } elsif (/^DECLARE_PEM_write\s*\(\s*(\w*)\s*,/ ||
835 /^DECLARE_PEM_write_cb\s*\(\s*(\w*)\s*,/ ) {
836 # Things not in Win16
837 $def .=
838 "#INFO:"
839 .join(',',"!WIN16",@current_platforms).":"
840 .join(',',@current_algorithms).";";
841 $def .= "int PEM_write_$1(void);";
842 $def .=
843 "#INFO:"
844 .join(',',@current_platforms).":"
845 .join(',',@current_algorithms).";";
846 # Things that are everywhere
847 $def .= "int PEM_write_bio_$1(void);";
848 next;
849 } elsif (/^DECLARE_PEM_read\s*\(\s*(\w*)\s*,/ ||
850 /^DECLARE_PEM_read_cb\s*\(\s*(\w*)\s*,/ ) {
851 # Things not in Win16
852 $def .=
853 "#INFO:"
854 .join(',',"!WIN16",@current_platforms).":"
855 .join(',',@current_algorithms).";";
856 $def .= "int PEM_read_$1(void);";
857 $def .=
858 "#INFO:"
859 .join(',',@current_platforms).":"
860 .join(',',@current_algorithms).";";
861 # Things that are everywhere
862 $def .= "int PEM_read_bio_$1(void);";
863 next;
864 } elsif (/^OPENSSL_DECLARE_GLOBAL\s*\(\s*(\w*)\s*,\s*(\w*)\s*\)/) {
865 # Variant for platforms that do not
866 # have to access globale variables
867 # in shared libraries through functions
868 $def .=
869 "#INFO:"
870 .join(',',"!EXPORT_VAR_AS_FUNCTION",@current_platforms).":"
871 .join(',',@current_algorithms).";";
872 $def .= "OPENSSL_EXTERN int _shadow_$2;";
873 $def .=
874 "#INFO:"
875 .join(',',@current_platforms).":"
876 .join(',',@current_algorithms).";";
877 # Variant for platforms that have to
878 # access globale variables in shared
879 # libraries through functions
880 &$make_variant("_shadow_$2","_shadow_$2",
881 "EXPORT_VAR_AS_FUNCTION",
882 "FUNCTION");
883 } elsif ($tag{'CONST_STRICT'} != 1) {
884 if (/\{|\/\*|\([^\)]*$/) {
885 $line = $_;
886 } else {
887 $def .= $_;
888 }
889 }
890 }
891 }
892 close(IN);
893
894 my $algs;
895 my $plays;
896
897 print STDERR "DEBUG: postprocessing ----------\n" if $debug;
898 foreach (split /;/, $def) {
899 my $s; my $k = "FUNCTION"; my $p; my $a;
900 s/^[\n\s]*//g;
901 s/[\n\s]*$//g;
902 next if(/\#undef/);
903 next if(/typedef\W/);
904 next if(/\#define/);
905
906 # Reduce argument lists to empty ()
907 # fold round brackets recursively: (t(*v)(t),t) -> (t{}{},t) -> {}
908 while(/\(.*\)/s) {
909 s/\([^\(\)]+\)/\{\}/gs;
910 s/\(\s*\*\s*(\w+)\s*\{\}\s*\)/$1/gs; #(*f{}) -> f
911 }
912 # pretend as we didn't use curly braces: {} -> ()
913 s/\{\}/\(\)/gs;
914
915 s/STACK_OF\(\)/void/gs;
916 s/LHASH_OF\(\)/void/gs;
917
918 print STDERR "DEBUG: \$_ = \"$_\"\n" if $debug;
919 if (/^\#INFO:([^:]*):(.*)$/) {
920 $plats = $1;
921 $algs = $2;
922 print STDERR "DEBUG: found info on platforms ($plats) and algorithms ($algs)\n" if $debug;
923 next;
924 } elsif (/^\s*OPENSSL_EXTERN\s.*?(\w+(\{[0-9]+\})?)(\[[0-9]*\])*\s*$/) {
925 $s = $1;
926 $k = "VARIABLE";
927 print STDERR "DEBUG: found external variable $s\n" if $debug;
928 } elsif (/TYPEDEF_\w+_OF/s) {
929 next;
930 } elsif (/(\w+)\s*\(\).*/s) { # first token prior [first] () is
931 $s = $1; # a function name!
932 print STDERR "DEBUG: found function $s\n" if $debug;
933 } elsif (/\(/ and not (/=/)) {
934 print STDERR "File $file: cannot parse: $_;\n";
935 next;
936 } else {
937 next;
938 }
939
940 $syms{$s} = 1;
941 $kind{$s} = $k;
942
943 $p = $plats;
944 $a = $algs;
945 $a .= ",BF" if($s =~ /EVP_bf/);
946 $a .= ",CAST" if($s =~ /EVP_cast/);
947 $a .= ",DES" if($s =~ /EVP_des/);
948 $a .= ",DSA" if($s =~ /EVP_dss/);
949 $a .= ",IDEA" if($s =~ /EVP_idea/);
950 $a .= ",MD2" if($s =~ /EVP_md2/);
951 $a .= ",MD4" if($s =~ /EVP_md4/);
952 $a .= ",MD5" if($s =~ /EVP_md5/);
953 $a .= ",RC2" if($s =~ /EVP_rc2/);
954 $a .= ",RC4" if($s =~ /EVP_rc4/);
955 $a .= ",RC5" if($s =~ /EVP_rc5/);
956 $a .= ",RIPEMD" if($s =~ /EVP_ripemd/);
957 $a .= ",SHA" if($s =~ /EVP_sha/);
958 $a .= ",RSA" if($s =~ /EVP_(Open|Seal)(Final|Init)/);
959 $a .= ",RSA" if($s =~ /PEM_Seal(Final|Init|Update)/);
960 $a .= ",RSA" if($s =~ /RSAPrivateKey/);
961 $a .= ",RSA" if($s =~ /SSLv23?_((client|server)_)?method/);
962
963 $platform{$s} =
964 &reduce_platforms((defined($platform{$s})?$platform{$s}.',':"").$p);
965 $algorithm{$s} .= ','.$a;
966
967 if (defined($variant{$s})) {
968 foreach $v (split /;/,$variant{$s}) {
969 (my $r, my $p, my $k) = split(/:/,$v);
970 my $ip = join ',',map({ /^!(.*)$/ ? $1 : "!".$_ } split /,/, $p);
971 $syms{$r} = 1;
972 if (!defined($k)) { $k = $kind{$s}; }
973 $kind{$r} = $k."(".$s.")";
974 $algorithm{$r} = $algorithm{$s};
975 $platform{$r} = &reduce_platforms($platform{$s}.",".$p.",".$p);
976 $platform{$s} = &reduce_platforms($platform{$s}.','.$ip.','.$ip);
977 print STDERR "DEBUG: \$variant{\"$s\"} = ",$v,"; \$r = $r; \$p = ",$platform{$r},"; \$a = ",$algorithm{$r},"; \$kind = ",$kind{$r},"\n" if $debug;
978 }
979 }
980 print STDERR "DEBUG: \$s = $s; \$p = ",$platform{$s},"; \$a = ",$algorithm{$s},"; \$kind = ",$kind{$s},"\n" if $debug;
981 }
982 }
983
984 # Prune the returned symbols
985
986 delete $syms{"bn_dump1"};
987 $platform{"BIO_s_log"} .= ",!WIN32,!WIN16,!macintosh";
988
989 $platform{"PEM_read_NS_CERT_SEQ"} = "VMS";
990 $platform{"PEM_write_NS_CERT_SEQ"} = "VMS";
991 $platform{"PEM_read_P8_PRIV_KEY_INFO"} = "VMS";
992 $platform{"PEM_write_P8_PRIV_KEY_INFO"} = "VMS";
993 $platform{"EVP_sha384"} = "!VMSVAX";
994 $platform{"EVP_sha512"} = "!VMSVAX";
995 $platform{"SHA384_Init"} = "!VMSVAX";
996 $platform{"SHA384_Transform"} = "!VMSVAX";
997 $platform{"SHA384_Update"} = "!VMSVAX";
998 $platform{"SHA384_Final"} = "!VMSVAX";
999 $platform{"SHA384"} = "!VMSVAX";
1000 $platform{"SHA512_Init"} = "!VMSVAX";
1001 $platform{"SHA512_Transform"} = "!VMSVAX";
1002 $platform{"SHA512_Update"} = "!VMSVAX";
1003 $platform{"SHA512_Final"} = "!VMSVAX";
1004 $platform{"SHA512"} = "!VMSVAX";
1005 $platform{"WHIRLPOOL_Init"} = "!VMSVAX";
1006 $platform{"WHIRLPOOL"} = "!VMSVAX";
1007 $platform{"WHIRLPOOL_BitUpdate"} = "!VMSVAX";
1008 $platform{"EVP_whirlpool"} = "!VMSVAX";
1009 $platform{"WHIRLPOOL_Final"} = "!VMSVAX";
1010 $platform{"WHIRLPOOL_Update"} = "!VMSVAX";
1011
1012
1013 # Info we know about
1014
1015 push @ret, map { $_."\\".&info_string($_,"EXIST",
1016 $platform{$_},
1017 $kind{$_},
1018 $algorithm{$_}) } keys %syms;
1019
1020 if (keys %unknown_algorithms) {
1021 print STDERR "WARNING: mkdef.pl doesn't know the following algorithms:\n";
1022 print STDERR "\t",join("\n\t",keys %unknown_algorithms),"\n";
1023 }
1024 return(@ret);
1025}
1026
1027# Param: string of comma-separated platform-specs.
1028sub reduce_platforms
1029{
1030 my ($platforms) = @_;
1031 my $pl = defined($platforms) ? $platforms : "";
1032 my %p = map { $_ => 0 } split /,/, $pl;
1033 my $ret;
1034
1035 print STDERR "DEBUG: Entered reduce_platforms with \"$platforms\"\n"
1036 if $debug;
1037 # We do this, because if there's code like the following, it really
1038 # means the function exists in all cases and should therefore be
1039 # everywhere. By increasing and decreasing, we may attain 0:
1040 #
1041 # ifndef WIN16
1042 # int foo();
1043 # else
1044 # int _fat foo();
1045 # endif
1046 foreach $platform (split /,/, $pl) {
1047 if ($platform =~ /^!(.*)$/) {
1048 $p{$1}--;
1049 } else {
1050 $p{$platform}++;
1051 }
1052 }
1053 foreach $platform (keys %p) {
1054 if ($p{$platform} == 0) { delete $p{$platform}; }
1055 }
1056
1057 delete $p{""};
1058
1059 $ret = join(',',sort(map { $p{$_} < 0 ? "!".$_ : $_ } keys %p));
1060 print STDERR "DEBUG: Exiting reduce_platforms with \"$ret\"\n"
1061 if $debug;
1062 return $ret;
1063}
1064
1065sub info_string {
1066 (my $symbol, my $exist, my $platforms, my $kind, my $algorithms) = @_;
1067
1068 my %a = defined($algorithms) ?
1069 map { $_ => 1 } split /,/, $algorithms : ();
1070 my $k = defined($kind) ? $kind : "FUNCTION";
1071 my $ret;
1072 my $p = &reduce_platforms($platforms);
1073
1074 delete $a{""};
1075
1076 $ret = $exist;
1077 $ret .= ":".$p;
1078 $ret .= ":".$k;
1079 $ret .= ":".join(',',sort keys %a);
1080 return $ret;
1081}
1082
1083sub maybe_add_info {
1084 (my $name, *nums, my @symbols) = @_;
1085 my $sym;
1086 my $new_info = 0;
1087 my %syms=();
1088
1089 print STDERR "Updating $name info\n";
1090 foreach $sym (@symbols) {
1091 (my $s, my $i) = split /\\/, $sym;
1092 if (defined($nums{$s})) {
1093 $i =~ s/^(.*?:.*?:\w+)(\(\w+\))?/$1/;
1094 (my $n, my $dummy) = split /\\/, $nums{$s};
1095 if (!defined($dummy) || $i ne $dummy) {
1096 $nums{$s} = $n."\\".$i;
1097 $new_info++;
1098 print STDERR "DEBUG: maybe_add_info for $s: \"$dummy\" => \"$i\"\n" if $debug;
1099 }
1100 }
1101 $syms{$s} = 1;
1102 }
1103
1104 my @s=sort { &parse_number($nums{$a},"n") <=> &parse_number($nums{$b},"n") } keys %nums;
1105 foreach $sym (@s) {
1106 (my $n, my $i) = split /\\/, $nums{$sym};
1107 if (!defined($syms{$sym}) && $i !~ /^NOEXIST:/) {
1108 $new_info++;
1109 print STDERR "DEBUG: maybe_add_info for $sym: -> undefined\n" if $debug;
1110 }
1111 }
1112 if ($new_info) {
1113 print STDERR "$new_info old symbols got an info update\n";
1114 if (!$do_rewrite) {
1115 print STDERR "You should do a rewrite to fix this.\n";
1116 }
1117 } else {
1118 print STDERR "No old symbols needed info update\n";
1119 }
1120}
1121
1122# Param: string of comma-separated keywords, each possibly prefixed with a "!"
1123sub is_valid
1124{
1125 my ($keywords_txt,$platforms) = @_;
1126 my (@keywords) = split /,/,$keywords_txt;
1127 my ($falsesum, $truesum) = (0, 1);
1128
1129 # Param: one keyword
1130 sub recognise
1131 {
1132 my ($keyword,$platforms) = @_;
1133
1134 if ($platforms) {
1135 # platforms
1136 if ($keyword eq "VMSVAX" && $VMSVAX) { return 1; }
1137 if ($keyword eq "VMSNonVAX" && $VMSNonVAX) { return 1; }
1138 if ($keyword eq "VMS" && $VMS) { return 1; }
1139 if ($keyword eq "WIN32" && $W32) { return 1; }
1140 if ($keyword eq "WIN16" && $W16) { return 1; }
1141 if ($keyword eq "WINNT" && $NT) { return 1; }
1142 if ($keyword eq "OS2" && $OS2) { return 1; }
1143 # Special platforms:
1144 # EXPORT_VAR_AS_FUNCTION means that global variables
1145 # will be represented as functions. This currently
1146 # only happens on VMS-VAX.
1147 if ($keyword eq "EXPORT_VAR_AS_FUNCTION" && ($VMSVAX || $W32 || $W16)) {
1148 return 1;
1149 }
1150 if ($keyword eq "OPENSSL_FIPS" && $fips) {
1151 return 1;
1152 }
1153 if ($keyword eq "ZLIB" && $zlib) { return 1; }
1154 return 0;
1155 } else {
1156 # algorithms
1157 if ($keyword eq "RC2" && $no_rc2) { return 0; }
1158 if ($keyword eq "RC4" && $no_rc4) { return 0; }
1159 if ($keyword eq "RC5" && $no_rc5) { return 0; }
1160 if ($keyword eq "IDEA" && $no_idea) { return 0; }
1161 if ($keyword eq "DES" && $no_des) { return 0; }
1162 if ($keyword eq "BF" && $no_bf) { return 0; }
1163 if ($keyword eq "CAST" && $no_cast) { return 0; }
1164 if ($keyword eq "MD2" && $no_md2) { return 0; }
1165 if ($keyword eq "MD4" && $no_md4) { return 0; }
1166 if ($keyword eq "MD5" && $no_md5) { return 0; }
1167 if ($keyword eq "SHA" && $no_sha) { return 0; }
1168 if ($keyword eq "RIPEMD" && $no_ripemd) { return 0; }
1169 if ($keyword eq "MDC2" && $no_mdc2) { return 0; }
1170 if ($keyword eq "WHIRLPOOL" && $no_whirlpool) { return 0; }
1171 if ($keyword eq "RSA" && $no_rsa) { return 0; }
1172 if ($keyword eq "DSA" && $no_dsa) { return 0; }
1173 if ($keyword eq "DH" && $no_dh) { return 0; }
1174 if ($keyword eq "EC" && $no_ec) { return 0; }
1175 if ($keyword eq "ECDSA" && $no_ecdsa) { return 0; }
1176 if ($keyword eq "ECDH" && $no_ecdh) { return 0; }
1177 if ($keyword eq "HMAC" && $no_hmac) { return 0; }
1178 if ($keyword eq "AES" && $no_aes) { return 0; }
1179 if ($keyword eq "CAMELLIA" && $no_camellia) { return 0; }
1180 if ($keyword eq "SEED" && $no_seed) { return 0; }
1181 if ($keyword eq "EVP" && $no_evp) { return 0; }
1182 if ($keyword eq "LHASH" && $no_lhash) { return 0; }
1183 if ($keyword eq "STACK" && $no_stack) { return 0; }
1184 if ($keyword eq "ERR" && $no_err) { return 0; }
1185 if ($keyword eq "BUFFER" && $no_buffer) { return 0; }
1186 if ($keyword eq "BIO" && $no_bio) { return 0; }
1187 if ($keyword eq "COMP" && $no_comp) { return 0; }
1188 if ($keyword eq "DSO" && $no_dso) { return 0; }
1189 if ($keyword eq "KRB5" && $no_krb5) { return 0; }
1190 if ($keyword eq "ENGINE" && $no_engine) { return 0; }
1191 if ($keyword eq "HW" && $no_hw) { return 0; }
1192 if ($keyword eq "FP_API" && $no_fp_api) { return 0; }
1193 if ($keyword eq "STATIC_ENGINE" && $no_static_engine) { return 0; }
1194 if ($keyword eq "GMP" && $no_gmp) { return 0; }
1195 if ($keyword eq "RFC3779" && $no_rfc3779) { return 0; }
1196 if ($keyword eq "TLSEXT" && $no_tlsext) { return 0; }
1197 if ($keyword eq "PSK" && $no_psk) { return 0; }
1198 if ($keyword eq "CMS" && $no_cms) { return 0; }
1199 if ($keyword eq "EC2M" && $no_ec2m) { return 0; }
1200 if ($keyword eq "NEXTPROTONEG" && $no_nextprotoneg) { return 0; }
1201 if ($keyword eq "EC_NISTP_64_GCC_128" && $no_nistp_gcc)
1202 { return 0; }
1203 if ($keyword eq "SSL2" && $no_ssl2) { return 0; }
1204 if ($keyword eq "CAPIENG" && $no_capieng) { return 0; }
1205 if ($keyword eq "JPAKE" && $no_jpake) { return 0; }
1206 if ($keyword eq "SRP" && $no_srp) { return 0; }
1207 if ($keyword eq "SCTP" && $no_sctp) { return 0; }
1208 if ($keyword eq "DEPRECATED" && $no_deprecated) { return 0; }
1209
1210 # Nothing recognise as true
1211 return 1;
1212 }
1213 }
1214
1215 foreach $k (@keywords) {
1216 if ($k =~ /^!(.*)$/) {
1217 $falsesum += &recognise($1,$platforms);
1218 } else {
1219 $truesum *= &recognise($k,$platforms);
1220 }
1221 }
1222 print STDERR "DEBUG: [",$#keywords,",",$#keywords < 0,"] is_valid($keywords_txt) => (\!$falsesum) && $truesum = ",(!$falsesum) && $truesum,"\n" if $debug;
1223 return (!$falsesum) && $truesum;
1224}
1225
1226sub print_test_file
1227{
1228 (*OUT,my $name,*nums,my $testall,my @symbols)=@_;
1229 my $n = 1; my @e; my @r;
1230 my $sym; my $prev = ""; my $prefSSLeay;
1231
1232 (@e)=grep(/^SSLeay(\{[0-9]+\})?\\.*?:.*?:.*/,@symbols);
1233 (@r)=grep(/^\w+(\{[0-9]+\})?\\.*?:.*?:.*/ && !/^SSLeay(\{[0-9]+\})?\\.*?:.*?:.*/,@symbols);
1234 @symbols=((sort @e),(sort @r));
1235
1236 foreach $sym (@symbols) {
1237 (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/;
1238 my $v = 0;
1239 $v = 1 if $i=~ /^.*?:.*?:VARIABLE/;
1240 my $p = ($i =~ /^[^:]*:([^:]*):/,$1);
1241 my $a = ($i =~ /^[^:]*:[^:]*:[^:]*:([^:]*)/,$1);
1242 if (!defined($nums{$s})) {
1243 print STDERR "Warning: $s does not have a number assigned\n"
1244 if(!$do_update);
1245 } elsif (is_valid($p,1) && is_valid($a,0)) {
1246 my $s2 = ($s =~ /^(.*?)(\{[0-9]+\})?$/, $1);
1247 if ($prev eq $s2) {
1248 print OUT "\t/* The following has already appeared previously */\n";
1249 print STDERR "Warning: Symbol '",$s2,"' redefined. old=",($nums{$prev} =~ /^(.*?)\\/,$1),", new=",($nums{$s2} =~ /^(.*?)\\/,$1),"\n";
1250 }
1251 $prev = $s2; # To warn about duplicates...
1252
1253 ($nn,$ni)=($nums{$s2} =~ /^(.*?)\\(.*)$/);
1254 if ($v) {
1255 print OUT "\textern int $s2; /* type unknown */ /* $nn $ni */\n";
1256 } else {
1257 print OUT "\textern int $s2(); /* type unknown */ /* $nn $ni */\n";
1258 }
1259 }
1260 }
1261}
1262
1263sub get_version {
1264 local *MF;
1265 my $v = '?';
1266 open MF, 'Makefile' or return $v;
1267 while (<MF>) {
1268 $v = $1, last if /^VERSION=(.*?)\s*$/;
1269 }
1270 close MF;
1271 return $v;
1272}
1273
1274sub print_def_file
1275{
1276 (*OUT,my $name,*nums,my @symbols)=@_;
1277 my $n = 1; my @e; my @r; my @v; my $prev="";
1278 my $liboptions="";
1279 my $libname = $name;
1280 my $http_vendor = 'www.openssl.org/';
1281 my $version = get_version();
1282 my $what = "OpenSSL: implementation of Secure Socket Layer";
1283 my $description = "$what $version, $name - http://$http_vendor";
1284
1285 if ($W32)
1286 { $libname.="32"; }
1287 elsif ($W16)
1288 { $libname.="16"; }
1289 elsif ($OS2)
1290 { # DLL names should not clash on the whole system.
1291 # However, they should not have any particular relationship
1292 # to the name of the static library. Chose descriptive names
1293 # (must be at most 8 chars).
1294 my %translate = (ssl => 'open_ssl', crypto => 'cryptssl');
1295 $libname = $translate{$name} || $name;
1296 $liboptions = <<EOO;
1297INITINSTANCE
1298DATA MULTIPLE NONSHARED
1299EOO
1300 # Vendor field can't contain colon, drat; so we omit http://
1301 $description = "\@#$http_vendor:$version#\@$what; DLL for library $name. Build for EMX -Zmtd";
1302 }
1303
1304 print OUT <<"EOF";
1305;
1306; Definition file for the DLL version of the $name library from OpenSSL
1307;
1308
1309LIBRARY $libname $liboptions
1310
1311EOF
1312
1313 if ($W16) {
1314 print <<"EOF";
1315CODE PRELOAD MOVEABLE
1316DATA PRELOAD MOVEABLE SINGLE
1317
1318EXETYPE WINDOWS
1319
1320HEAPSIZE 4096
1321STACKSIZE 8192
1322
1323EOF
1324 }
1325
1326 print "EXPORTS\n";
1327
1328 (@e)=grep(/^SSLeay(\{[0-9]+\})?\\.*?:.*?:FUNCTION/,@symbols);
1329 (@r)=grep(/^\w+(\{[0-9]+\})?\\.*?:.*?:FUNCTION/ && !/^SSLeay(\{[0-9]+\})?\\.*?:.*?:FUNCTION/,@symbols);
1330 (@v)=grep(/^\w+(\{[0-9]+\})?\\.*?:.*?:VARIABLE/,@symbols);
1331 @symbols=((sort @e),(sort @r), (sort @v));
1332
1333
1334 foreach $sym (@symbols) {
1335 (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/;
1336 my $v = 0;
1337 $v = 1 if $i =~ /^.*?:.*?:VARIABLE/;
1338 if (!defined($nums{$s})) {
1339 printf STDERR "Warning: $s does not have a number assigned\n"
1340 if(!$do_update);
1341 } else {
1342 (my $n, my $dummy) = split /\\/, $nums{$s};
1343 my %pf = ();
1344 my $p = ($i =~ /^[^:]*:([^:]*):/,$1);
1345 my $a = ($i =~ /^[^:]*:[^:]*:[^:]*:([^:]*)/,$1);
1346 if (is_valid($p,1) && is_valid($a,0)) {
1347 my $s2 = ($s =~ /^(.*?)(\{[0-9]+\})?$/, $1);
1348 if ($prev eq $s2) {
1349 print STDERR "Warning: Symbol '",$s2,"' redefined. old=",($nums{$prev} =~ /^(.*?)\\/,$1),", new=",($nums{$s2} =~ /^(.*?)\\/,$1),"\n";
1350 }
1351 $prev = $s2; # To warn about duplicates...
1352 if($v && !$OS2) {
1353 printf OUT " %s%-39s @%-8d DATA\n",($W32)?"":"_",$s2,$n;
1354 } else {
1355 printf OUT " %s%-39s @%d\n",($W32||$OS2)?"":"_",$s2,$n;
1356 }
1357 }
1358 }
1359 }
1360 printf OUT "\n";
1361}
1362
1363sub load_numbers
1364{
1365 my($name)=@_;
1366 my(@a,%ret);
1367
1368 $max_num = 0;
1369 $num_noinfo = 0;
1370 $prev = "";
1371 $prev_cnt = 0;
1372
1373 open(IN,"<$name") || die "unable to open $name:$!\n";
1374 while (<IN>) {
1375 chop;
1376 s/#.*$//;
1377 next if /^\s*$/;
1378 @a=split;
1379 if (defined $ret{$a[0]}) {
1380 # This is actually perfectly OK
1381 #print STDERR "Warning: Symbol '",$a[0],"' redefined. old=",$ret{$a[0]},", new=",$a[1],"\n";
1382 }
1383 if ($max_num > $a[1]) {
1384 print STDERR "Warning: Number decreased from ",$max_num," to ",$a[1],"\n";
1385 }
1386 elsif ($max_num == $a[1]) {
1387 # This is actually perfectly OK
1388 #print STDERR "Warning: Symbol ",$a[0]," has same number as previous ",$prev,": ",$a[1],"\n";
1389 if ($a[0] eq $prev) {
1390 $prev_cnt++;
1391 $a[0] .= "{$prev_cnt}";
1392 }
1393 }
1394 else {
1395 $prev_cnt = 0;
1396 }
1397 if ($#a < 2) {
1398 # Existence will be proven later, in do_defs
1399 $ret{$a[0]}=$a[1];
1400 $num_noinfo++;
1401 } else {
1402 $ret{$a[0]}=$a[1]."\\".$a[2]; # \\ is a special marker
1403 }
1404 $max_num = $a[1] if $a[1] > $max_num;
1405 $prev=$a[0];
1406 }
1407 if ($num_noinfo) {
1408 print STDERR "Warning: $num_noinfo symbols were without info.";
1409 if ($do_rewrite) {
1410 printf STDERR " The rewrite will fix this.\n";
1411 } else {
1412 printf STDERR " You should do a rewrite to fix this.\n";
1413 }
1414 }
1415 close(IN);
1416 return(%ret);
1417}
1418
1419sub parse_number
1420{
1421 (my $str, my $what) = @_;
1422 (my $n, my $i) = split(/\\/,$str);
1423 if ($what eq "n") {
1424 return $n;
1425 } else {
1426 return $i;
1427 }
1428}
1429
1430sub rewrite_numbers
1431{
1432 (*OUT,$name,*nums,@symbols)=@_;
1433 my $thing;
1434
1435 print STDERR "Rewriting $name\n";
1436
1437 my @r = grep(/^\w+(\{[0-9]+\})?\\.*?:.*?:\w+\(\w+\)/,@symbols);
1438 my $r; my %r; my %rsyms;
1439 foreach $r (@r) {
1440 (my $s, my $i) = split /\\/, $r;
1441 my $a = $1 if $i =~ /^.*?:.*?:\w+\((\w+)\)/;
1442 $i =~ s/^(.*?:.*?:\w+)\(\w+\)/$1/;
1443 $r{$a} = $s."\\".$i;
1444 $rsyms{$s} = 1;
1445 }
1446
1447 my %syms = ();
1448 foreach $_ (@symbols) {
1449 (my $n, my $i) = split /\\/;
1450 $syms{$n} = 1;
1451 }
1452
1453 my @s=sort {
1454 &parse_number($nums{$a},"n") <=> &parse_number($nums{$b},"n")
1455 || $a cmp $b
1456 } keys %nums;
1457 foreach $sym (@s) {
1458 (my $n, my $i) = split /\\/, $nums{$sym};
1459 next if defined($i) && $i =~ /^.*?:.*?:\w+\(\w+\)/;
1460 next if defined($rsyms{$sym});
1461 print STDERR "DEBUG: rewrite_numbers for sym = ",$sym,": i = ",$i,", n = ",$n,", rsym{sym} = ",$rsyms{$sym},"syms{sym} = ",$syms{$sym},"\n" if $debug;
1462 $i="NOEXIST::FUNCTION:"
1463 if !defined($i) || $i eq "" || !defined($syms{$sym});
1464 my $s2 = $sym;
1465 $s2 =~ s/\{[0-9]+\}$//;
1466 printf OUT "%s%-39s %d\t%s\n","",$s2,$n,$i;
1467 if (exists $r{$sym}) {
1468 (my $s, $i) = split /\\/,$r{$sym};
1469 my $s2 = $s;
1470 $s2 =~ s/\{[0-9]+\}$//;
1471 printf OUT "%s%-39s %d\t%s\n","",$s2,$n,$i;
1472 }
1473 }
1474}
1475
1476sub update_numbers
1477{
1478 (*OUT,$name,*nums,my $start_num, my @symbols)=@_;
1479 my $new_syms = 0;
1480
1481 print STDERR "Updating $name numbers\n";
1482
1483 my @r = grep(/^\w+(\{[0-9]+\})?\\.*?:.*?:\w+\(\w+\)/,@symbols);
1484 my $r; my %r; my %rsyms;
1485 foreach $r (@r) {
1486 (my $s, my $i) = split /\\/, $r;
1487 my $a = $1 if $i =~ /^.*?:.*?:\w+\((\w+)\)/;
1488 $i =~ s/^(.*?:.*?:\w+)\(\w+\)/$1/;
1489 $r{$a} = $s."\\".$i;
1490 $rsyms{$s} = 1;
1491 }
1492
1493 foreach $sym (@symbols) {
1494 (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/;
1495 next if $i =~ /^.*?:.*?:\w+\(\w+\)/;
1496 next if defined($rsyms{$sym});
1497 die "ERROR: Symbol $sym had no info attached to it."
1498 if $i eq "";
1499 if (!exists $nums{$s}) {
1500 $new_syms++;
1501 my $s2 = $s;
1502 $s2 =~ s/\{[0-9]+\}$//;
1503 printf OUT "%s%-39s %d\t%s\n","",$s2, ++$start_num,$i;
1504 if (exists $r{$s}) {
1505 ($s, $i) = split /\\/,$r{$s};
1506 $s =~ s/\{[0-9]+\}$//;
1507 printf OUT "%s%-39s %d\t%s\n","",$s, $start_num,$i;
1508 }
1509 }
1510 }
1511 if($new_syms) {
1512 print STDERR "$new_syms New symbols added\n";
1513 } else {
1514 print STDERR "No New symbols Added\n";
1515 }
1516}
1517
1518sub check_existing
1519{
1520 (*nums, my @symbols)=@_;
1521 my %existing; my @remaining;
1522 @remaining=();
1523 foreach $sym (@symbols) {
1524 (my $s, my $i) = $sym =~ /^(.*?)\\(.*)$/;
1525 $existing{$s}=1;
1526 }
1527 foreach $sym (keys %nums) {
1528 if (!exists $existing{$sym}) {
1529 push @remaining, $sym;
1530 }
1531 }
1532 if(@remaining) {
1533 print STDERR "The following symbols do not seem to exist:\n";
1534 foreach $sym (@remaining) {
1535 print STDERR "\t",$sym,"\n";
1536 }
1537 }
1538}
1539
diff --git a/src/lib/libcrypto/util/mkdir-p.pl b/src/lib/libcrypto/util/mkdir-p.pl
new file mode 100644
index 0000000000..e73d02b073
--- /dev/null
+++ b/src/lib/libcrypto/util/mkdir-p.pl
@@ -0,0 +1,34 @@
1#!/usr/local/bin/perl
2
3# mkdir-p.pl
4
5# On some systems, the -p option to mkdir (= also create any missing parent
6# directories) is not available.
7
8my $arg;
9
10foreach $arg (@ARGV) {
11 $arg =~ tr|\\|/|;
12 &do_mkdir_p($arg);
13}
14
15
16sub do_mkdir_p {
17 local($dir) = @_;
18
19 $dir =~ s|/*\Z(?!\n)||s;
20
21 if (-d $dir) {
22 return;
23 }
24
25 if ($dir =~ m|[^/]/|s) {
26 local($parent) = $dir;
27 $parent =~ s|[^/]*\Z(?!\n)||s;
28
29 do_mkdir_p($parent);
30 }
31
32 mkdir($dir, 0777) || die "Cannot create directory $dir: $!\n";
33 print "created directory `$dir'\n";
34}
diff --git a/src/lib/libcrypto/util/mkerr.pl b/src/lib/libcrypto/util/mkerr.pl
new file mode 100644
index 0000000000..aec401c773
--- /dev/null
+++ b/src/lib/libcrypto/util/mkerr.pl
@@ -0,0 +1,810 @@
1#!/usr/local/bin/perl -w
2
3my $config = "crypto/err/openssl.ec";
4my $hprefix = "openssl/";
5my $debug = 0;
6my $rebuild = 0;
7my $static = 1;
8my $recurse = 0;
9my $reindex = 0;
10my $dowrite = 0;
11my $staticloader = "";
12
13my $pack_errcode;
14my $load_errcode;
15
16my $errcount;
17
18while (@ARGV) {
19 my $arg = $ARGV[0];
20 if($arg eq "-conf") {
21 shift @ARGV;
22 $config = shift @ARGV;
23 } elsif($arg eq "-hprefix") {
24 shift @ARGV;
25 $hprefix = shift @ARGV;
26 } elsif($arg eq "-debug") {
27 $debug = 1;
28 shift @ARGV;
29 } elsif($arg eq "-rebuild") {
30 $rebuild = 1;
31 shift @ARGV;
32 } elsif($arg eq "-recurse") {
33 $recurse = 1;
34 shift @ARGV;
35 } elsif($arg eq "-reindex") {
36 $reindex = 1;
37 shift @ARGV;
38 } elsif($arg eq "-nostatic") {
39 $static = 0;
40 shift @ARGV;
41 } elsif($arg eq "-staticloader") {
42 $staticloader = "static ";
43 shift @ARGV;
44 } elsif($arg eq "-write") {
45 $dowrite = 1;
46 shift @ARGV;
47 } elsif($arg eq "-help" || $arg eq "-h" || $arg eq "-?" || $arg eq "--help") {
48 print STDERR <<"EOF";
49mkerr.pl [options] ...
50
51Options:
52
53 -conf F Use the config file F instead of the default one:
54 crypto/err/openssl.ec
55
56 -hprefix P Prepend the filenames in generated #include <header>
57 statements with prefix P. Default: 'openssl/' (without
58 the quotes, naturally)
59
60 -debug Turn on debugging verbose output on stderr.
61
62 -rebuild Rebuild all header and C source files, irrespective of the
63 fact if any error or function codes have been added/removed.
64 Default: only update files for libraries which saw change
65 (of course, this requires '-write' as well, or no
66 files will be touched!)
67
68 -recurse scan a preconfigured set of directories / files for error and
69 function codes:
70 (<crypto/*.c>, <crypto/*/*.c>, <ssl/*.c>, <apps/*.c>)
71 When this option is NOT specified, the filelist is taken from
72 the commandline instead. Here, wildcards may be embedded. (Be
73 sure to escape those to prevent the shell from expanding them
74 for you when you wish mkerr.pl to do so instead.)
75 Default: take file list to scan from the command line.
76
77 -reindex Discard the numeric values previously assigned to the error
78 and function codes as extracted from the scanned header files;
79 instead renumber all of them starting from 100. (Note that
80 the numbers assigned through 'R' records in the config file
81 remain intact.)
82 Default: keep previously assigned numbers. (You are warned
83 when collisions are detected.)
84
85 -nostatic Generates a different source code, where these additional
86 functions are generated for each library specified in the
87 config file:
88 void ERR_load_<LIB>_strings(void);
89 void ERR_unload_<LIB>_strings(void);
90 void ERR_<LIB>_error(int f, int r, char *fn, int ln);
91 #define <LIB>err(f,r) ERR_<LIB>_error(f,r,__FILE__,__LINE__)
92 while the code facilitates the use of these in an environment
93 where the error support routines are dynamically loaded at
94 runtime.
95 Default: 'static' code generation.
96
97 -staticloader Prefix generated functions with the 'static' scope modifier.
98 Default: don't write any scope modifier prefix.
99
100 -write Actually (over)write the generated code to the header and C
101 source files as assigned to each library through the config
102 file.
103 Default: don't write.
104
105 -help / -h / -? / --help Show this help text.
106
107 ... Additional arguments are added to the file list to scan,
108 assuming '-recurse' was NOT specified on the command line.
109
110EOF
111 exit 1;
112 } else {
113 last;
114 }
115}
116
117if($recurse) {
118 @source = (<crypto/*.c>, <crypto/*/*.c>, <ssl/*.c>);
119} else {
120 @source = @ARGV;
121}
122
123# Read in the config file
124
125open(IN, "<$config") || die "Can't open config file $config";
126
127# Parse config file
128
129while(<IN>)
130{
131 if(/^L\s+(\S+)\s+(\S+)\s+(\S+)/) {
132 $hinc{$1} = $2;
133 $libinc{$2} = $1;
134 $cskip{$3} = $1;
135 if($3 ne "NONE") {
136 $csrc{$1} = $3;
137 $fmax{$1} = 100;
138 $rmax{$1} = 100;
139 $fassigned{$1} = ":";
140 $rassigned{$1} = ":";
141 $fnew{$1} = 0;
142 $rnew{$1} = 0;
143 }
144 } elsif (/^F\s+(\S+)/) {
145 # Add extra function with $1
146 } elsif (/^R\s+(\S+)\s+(\S+)/) {
147 $rextra{$1} = $2;
148 $rcodes{$1} = $2;
149 }
150}
151
152close IN;
153
154# Scan each header file in turn and make a list of error codes
155# and function names
156
157while (($hdr, $lib) = each %libinc)
158{
159 next if($hdr eq "NONE");
160 print STDERR "Scanning header file $hdr\n" if $debug;
161 my $line = "", $def= "", $linenr = 0, $gotfile = 0;
162 if (open(IN, "<$hdr")) {
163 $gotfile = 1;
164 while(<IN>) {
165 $linenr++;
166 print STDERR "line: $linenr\r" if $debug;
167
168 last if(/BEGIN\s+ERROR\s+CODES/);
169 if ($line ne '') {
170 $_ = $line . $_;
171 $line = '';
172 }
173
174 if (/\\$/) {
175 $line = $_;
176 next;
177 }
178
179 if(/\/\*/) {
180 if (not /\*\//) { # multiline comment...
181 $line = $_; # ... just accumulate
182 next;
183 } else {
184 s/\/\*.*?\*\///gs; # wipe it
185 }
186 }
187
188 if ($cpp) {
189 $cpp++ if /^#\s*if/;
190 $cpp-- if /^#\s*endif/;
191 next;
192 }
193 $cpp = 1 if /^#.*ifdef.*cplusplus/; # skip "C" declaration
194
195 next if (/^\#/); # skip preprocessor directives
196
197 s/{[^{}]*}//gs; # ignore {} blocks
198
199 if (/\{|\/\*/) { # Add a } so editor works...
200 $line = $_;
201 } else {
202 $def .= $_;
203 }
204 }
205 }
206
207 print STDERR " \r" if $debug;
208 $defnr = 0;
209 # Delete any DECLARE_ macros
210 $def =~ s/DECLARE_\w+\([\w,\s]+\)//gs;
211 foreach (split /;/, $def) {
212 $defnr++;
213 print STDERR "def: $defnr\r" if $debug;
214
215 # The goal is to collect function names from function declarations.
216
217 s/^[\n\s]*//g;
218 s/[\n\s]*$//g;
219
220 # Skip over recognized non-function declarations
221 next if(/typedef\W/ or /DECLARE_STACK_OF/ or /TYPEDEF_.*_OF/);
222
223 # Remove STACK_OF(foo)
224 s/STACK_OF\(\w+\)/void/;
225
226 # Reduce argument lists to empty ()
227 # fold round brackets recursively: (t(*v)(t),t) -> (t{}{},t) -> {}
228 while(/\(.*\)/s) {
229 s/\([^\(\)]+\)/\{\}/gs;
230 s/\(\s*\*\s*(\w+)\s*\{\}\s*\)/$1/gs; #(*f{}) -> f
231 }
232 # pretend as we didn't use curly braces: {} -> ()
233 s/\{\}/\(\)/gs;
234
235 if (/(\w+)\s*\(\).*/s) { # first token prior [first] () is
236 my $name = $1; # a function name!
237 $name =~ tr/[a-z]/[A-Z]/;
238 $ftrans{$name} = $1;
239 } elsif (/[\(\)]/ and not (/=/)) {
240 print STDERR "Header $hdr: cannot parse: $_;\n";
241 }
242 }
243
244 print STDERR " \r" if $debug;
245
246 next if $reindex;
247
248 # Scan function and reason codes and store them: keep a note of the
249 # maximum code used.
250
251 if ($gotfile) {
252 while(<IN>) {
253 if(/^\#define\s+(\S+)\s+(\S+)/) {
254 $name = $1;
255 $code = $2;
256 next if $name =~ /^${lib}err/;
257 unless($name =~ /^${lib}_([RF])_(\w+)$/) {
258 print STDERR "Invalid error code $name\n";
259 next;
260 }
261 if($1 eq "R") {
262 $rcodes{$name} = $code;
263 if ($rassigned{$lib} =~ /:$code:/) {
264 print STDERR "!! ERROR: $lib reason code $code assigned twice (collision at $name)\n";
265 ++$errcount;
266 }
267 $rassigned{$lib} .= "$code:";
268 if(!(exists $rextra{$name}) &&
269 ($code > $rmax{$lib}) ) {
270 $rmax{$lib} = $code;
271 }
272 } else {
273 if ($fassigned{$lib} =~ /:$code:/) {
274 print STDERR "!! ERROR: $lib function code $code assigned twice (collision at $name)\n";
275 ++$errcount;
276 }
277 $fassigned{$lib} .= "$code:";
278 if($code > $fmax{$lib}) {
279 $fmax{$lib} = $code;
280 }
281 $fcodes{$name} = $code;
282 }
283 }
284 }
285 }
286
287 if ($debug) {
288 if (defined($fmax{$lib})) {
289 print STDERR "Max function code fmax" . "{" . "$lib" . "} = $fmax{$lib}\n";
290 $fassigned{$lib} =~ m/^:(.*):$/;
291 @fassigned = sort {$a <=> $b} split(":", $1);
292 print STDERR " @fassigned\n";
293 }
294 if (defined($rmax{$lib})) {
295 print STDERR "Max reason code rmax" . "{" . "$lib" . "} = $rmax{$lib}\n";
296 $rassigned{$lib} =~ m/^:(.*):$/;
297 @rassigned = sort {$a <=> $b} split(":", $1);
298 print STDERR " @rassigned\n";
299 }
300 }
301
302 if ($lib eq "SSL") {
303 if ($rmax{$lib} >= 1000) {
304 print STDERR "!! ERROR: SSL error codes 1000+ are reserved for alerts.\n";
305 print STDERR "!! Any new alerts must be added to $config.\n";
306 ++$errcount;
307 print STDERR "\n";
308 }
309 }
310 close IN;
311}
312
313# Scan each C source file and look for function and reason codes
314# This is done by looking for strings that "look like" function or
315# reason codes: basically anything consisting of all upper case and
316# numerics which has _F_ or _R_ in it and which has the name of an
317# error library at the start. This seems to work fine except for the
318# oddly named structure BIO_F_CTX which needs to be ignored.
319# If a code doesn't exist in list compiled from headers then mark it
320# with the value "X" as a place holder to give it a value later.
321# Store all function and reason codes found in %ufcodes and %urcodes
322# so all those unreferenced can be printed out.
323
324
325foreach $file (@source) {
326 # Don't parse the error source file.
327 next if exists $cskip{$file};
328 print STDERR "File loaded: ".$file."\r" if $debug;
329 open(IN, "<$file") || die "Can't open source file $file\n";
330 while(<IN>) {
331 # skip obsoleted source files entirely!
332 last if(/^#error\s+obsolete/);
333
334 if(/(([A-Z0-9]+)_F_([A-Z0-9_]+))/) {
335 next unless exists $csrc{$2};
336 next if($1 eq "BIO_F_BUFFER_CTX");
337 $ufcodes{$1} = 1;
338 if(!exists $fcodes{$1}) {
339 $fcodes{$1} = "X";
340 $fnew{$2}++;
341 }
342 $notrans{$1} = 1 unless exists $ftrans{$3};
343 print STDERR "Function: $1\t= $fcodes{$1} (lib: $2, name: $3)\n" if $debug;
344 }
345 if(/(([A-Z0-9]+)_R_[A-Z0-9_]+)/) {
346 next unless exists $csrc{$2};
347 $urcodes{$1} = 1;
348 if(!exists $rcodes{$1}) {
349 $rcodes{$1} = "X";
350 $rnew{$2}++;
351 }
352 print STDERR "Reason: $1\t= $rcodes{$1} (lib: $2)\n" if $debug;
353 }
354 }
355 close IN;
356}
357print STDERR " \n" if $debug;
358
359# Now process each library in turn.
360
361foreach $lib (keys %csrc)
362{
363 my $hfile = $hinc{$lib};
364 my $cfile = $csrc{$lib};
365 if(!$fnew{$lib} && !$rnew{$lib}) {
366 print STDERR "$lib:\t\tNo new error codes\n";
367 next unless $rebuild;
368 } else {
369 print STDERR "$lib:\t\t$fnew{$lib} New Functions,";
370 print STDERR " $rnew{$lib} New Reasons.\n";
371 next unless $dowrite;
372 }
373
374 # If we get here then we have some new error codes so we
375 # need to rebuild the header file and C file.
376
377 # Make a sorted list of error and reason codes for later use.
378
379 my @function = sort grep(/^${lib}_/,keys %fcodes);
380 my @reasons = sort grep(/^${lib}_/,keys %rcodes);
381
382 # Rewrite the header file
383
384 if (open(IN, "<$hfile")) {
385 # Copy across the old file
386 while(<IN>) {
387 push @out, $_;
388 last if (/BEGIN ERROR CODES/);
389 }
390 close IN;
391 } else {
392 push @out,
393"/* ====================================================================\n",
394" * Copyright (c) 2001-2011 The OpenSSL Project. All rights reserved.\n",
395" *\n",
396" * Redistribution and use in source and binary forms, with or without\n",
397" * modification, are permitted provided that the following conditions\n",
398" * are met:\n",
399" *\n",
400" * 1. Redistributions of source code must retain the above copyright\n",
401" * notice, this list of conditions and the following disclaimer. \n",
402" *\n",
403" * 2. Redistributions in binary form must reproduce the above copyright\n",
404" * notice, this list of conditions and the following disclaimer in\n",
405" * the documentation and/or other materials provided with the\n",
406" * distribution.\n",
407" *\n",
408" * 3. All advertising materials mentioning features or use of this\n",
409" * software must display the following acknowledgment:\n",
410" * \"This product includes software developed by the OpenSSL Project\n",
411" * for use in the OpenSSL Toolkit. (http://www.openssl.org/)\"\n",
412" *\n",
413" * 4. The names \"OpenSSL Toolkit\" and \"OpenSSL Project\" must not be used to\n",
414" * endorse or promote products derived from this software without\n",
415" * prior written permission. For written permission, please contact\n",
416" * openssl-core\@openssl.org.\n",
417" *\n",
418" * 5. Products derived from this software may not be called \"OpenSSL\"\n",
419" * nor may \"OpenSSL\" appear in their names without prior written\n",
420" * permission of the OpenSSL Project.\n",
421" *\n",
422" * 6. Redistributions of any form whatsoever must retain the following\n",
423" * acknowledgment:\n",
424" * \"This product includes software developed by the OpenSSL Project\n",
425" * for use in the OpenSSL Toolkit (http://www.openssl.org/)\"\n",
426" *\n",
427" * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY\n",
428" * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n",
429" * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\n",
430" * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR\n",
431" * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,\n",
432" * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\n",
433" * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n",
434" * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n",
435" * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\n",
436" * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n",
437" * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\n",
438" * OF THE POSSIBILITY OF SUCH DAMAGE.\n",
439" * ====================================================================\n",
440" *\n",
441" * This product includes cryptographic software written by Eric Young\n",
442" * (eay\@cryptsoft.com). This product includes software written by Tim\n",
443" * Hudson (tjh\@cryptsoft.com).\n",
444" *\n",
445" */\n",
446"\n",
447"#ifndef HEADER_${lib}_ERR_H\n",
448"#define HEADER_${lib}_ERR_H\n",
449"\n",
450"#ifdef __cplusplus\n",
451"extern \"C\" {\n",
452"#endif\n",
453"\n",
454"/* BEGIN ERROR CODES */\n";
455 }
456 open (OUT, ">$hfile") || die "Can't Open File $hfile for writing\n";
457
458 print OUT @out;
459 undef @out;
460 print OUT <<"EOF";
461/* The following lines are auto generated by the script mkerr.pl. Any changes
462 * made after this point may be overwritten when the script is next run.
463 */
464EOF
465 if($static) {
466 print OUT <<"EOF";
467${staticloader}void ERR_load_${lib}_strings(void);
468
469EOF
470 } else {
471 print OUT <<"EOF";
472${staticloader}void ERR_load_${lib}_strings(void);
473${staticloader}void ERR_unload_${lib}_strings(void);
474${staticloader}void ERR_${lib}_error(int function, int reason, char *file, int line);
475#define ${lib}err(f,r) ERR_${lib}_error((f),(r),__FILE__,__LINE__)
476
477EOF
478 }
479 print OUT <<"EOF";
480/* Error codes for the $lib functions. */
481
482/* Function codes. */
483EOF
484
485 foreach $i (@function) {
486 $z=6-int(length($i)/8);
487 if($fcodes{$i} eq "X") {
488 $fassigned{$lib} =~ m/^:([^:]*):/;
489 $findcode = $1;
490 if (!defined($findcode)) {
491 $findcode = $fmax{$lib};
492 }
493 while ($fassigned{$lib} =~ m/:$findcode:/) {
494 $findcode++;
495 }
496 $fcodes{$i} = $findcode;
497 $fassigned{$lib} .= "$findcode:";
498 print STDERR "New Function code $i\n" if $debug;
499 }
500 printf OUT "#define $i%s $fcodes{$i}\n","\t" x $z;
501 }
502
503 print OUT "\n/* Reason codes. */\n";
504
505 foreach $i (@reasons) {
506 $z=6-int(length($i)/8);
507 if($rcodes{$i} eq "X") {
508 $rassigned{$lib} =~ m/^:([^:]*):/;
509 $findcode = $1;
510 if (!defined($findcode)) {
511 $findcode = $rmax{$lib};
512 }
513 while ($rassigned{$lib} =~ m/:$findcode:/) {
514 $findcode++;
515 }
516 $rcodes{$i} = $findcode;
517 $rassigned{$lib} .= "$findcode:";
518 print STDERR "New Reason code $i\n" if $debug;
519 }
520 printf OUT "#define $i%s $rcodes{$i}\n","\t" x $z;
521 }
522 print OUT <<"EOF";
523
524#ifdef __cplusplus
525}
526#endif
527#endif
528EOF
529 close OUT;
530
531 # Rewrite the C source file containing the error details.
532
533 # First, read any existing reason string definitions:
534 my %err_reason_strings;
535 if (open(IN,"<$cfile")) {
536 while (<IN>) {
537 if (/\b(${lib}_R_\w*)\b.*\"(.*)\"/) {
538 $err_reason_strings{$1} = $2;
539 }
540 if (/\b${lib}_F_(\w*)\b.*\"(.*)\"/) {
541 if (!exists $ftrans{$1} && ($1 ne $2)) {
542 print STDERR "WARNING: Mismatched function string $2\n";
543 $ftrans{$1} = $2;
544 }
545 }
546 }
547 close(IN);
548 }
549
550
551 my $hincf;
552 if($static) {
553 $hfile =~ /([^\/]+)$/;
554 $hincf = "<${hprefix}$1>";
555 } else {
556 $hincf = "\"$hfile\"";
557 }
558
559 # If static we know the error code at compile time so use it
560 # in error definitions.
561
562 if ($static)
563 {
564 $pack_errcode = "ERR_LIB_${lib}";
565 $load_errcode = "0";
566 }
567 else
568 {
569 $pack_errcode = "0";
570 $load_errcode = "ERR_LIB_${lib}";
571 }
572
573
574 open (OUT,">$cfile") || die "Can't open $cfile for writing";
575
576 print OUT <<"EOF";
577/* $cfile */
578/* ====================================================================
579 * Copyright (c) 1999-2011 The OpenSSL Project. All rights reserved.
580 *
581 * Redistribution and use in source and binary forms, with or without
582 * modification, are permitted provided that the following conditions
583 * are met:
584 *
585 * 1. Redistributions of source code must retain the above copyright
586 * notice, this list of conditions and the following disclaimer.
587 *
588 * 2. Redistributions in binary form must reproduce the above copyright
589 * notice, this list of conditions and the following disclaimer in
590 * the documentation and/or other materials provided with the
591 * distribution.
592 *
593 * 3. All advertising materials mentioning features or use of this
594 * software must display the following acknowledgment:
595 * "This product includes software developed by the OpenSSL Project
596 * for use in the OpenSSL Toolkit. (http://www.OpenSSL.org/)"
597 *
598 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
599 * endorse or promote products derived from this software without
600 * prior written permission. For written permission, please contact
601 * openssl-core\@OpenSSL.org.
602 *
603 * 5. Products derived from this software may not be called "OpenSSL"
604 * nor may "OpenSSL" appear in their names without prior written
605 * permission of the OpenSSL Project.
606 *
607 * 6. Redistributions of any form whatsoever must retain the following
608 * acknowledgment:
609 * "This product includes software developed by the OpenSSL Project
610 * for use in the OpenSSL Toolkit (http://www.OpenSSL.org/)"
611 *
612 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
613 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
614 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
615 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
616 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
617 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
618 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
619 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
620 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
621 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
622 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
623 * OF THE POSSIBILITY OF SUCH DAMAGE.
624 * ====================================================================
625 *
626 * This product includes cryptographic software written by Eric Young
627 * (eay\@cryptsoft.com). This product includes software written by Tim
628 * Hudson (tjh\@cryptsoft.com).
629 *
630 */
631
632/* NOTE: this file was auto generated by the mkerr.pl script: any changes
633 * made to it will be overwritten when the script next updates this file,
634 * only reason strings will be preserved.
635 */
636
637#include <stdio.h>
638#include <openssl/err.h>
639#include $hincf
640
641/* BEGIN ERROR CODES */
642#ifndef OPENSSL_NO_ERR
643
644#define ERR_FUNC(func) ERR_PACK($pack_errcode,func,0)
645#define ERR_REASON(reason) ERR_PACK($pack_errcode,0,reason)
646
647static ERR_STRING_DATA ${lib}_str_functs[]=
648 {
649EOF
650 # Add each function code: if a function name is found then use it.
651 foreach $i (@function) {
652 my $fn;
653 $i =~ /^${lib}_F_(\S+)$/;
654 $fn = $1;
655 if(exists $ftrans{$fn}) {
656 $fn = $ftrans{$fn};
657 }
658# print OUT "{ERR_PACK($pack_errcode,$i,0),\t\"$fn\"},\n";
659 print OUT "{ERR_FUNC($i),\t\"$fn\"},\n";
660 }
661 print OUT <<"EOF";
662{0,NULL}
663 };
664
665static ERR_STRING_DATA ${lib}_str_reasons[]=
666 {
667EOF
668 # Add each reason code.
669 foreach $i (@reasons) {
670 my $rn;
671 my $rstr = "ERR_REASON($i)";
672 my $nspc = 0;
673 if (exists $err_reason_strings{$i}) {
674 $rn = $err_reason_strings{$i};
675 } else {
676 $i =~ /^${lib}_R_(\S+)$/;
677 $rn = $1;
678 $rn =~ tr/_[A-Z]/ [a-z]/;
679 }
680 $nspc = 40 - length($rstr) unless length($rstr) > 40;
681 $nspc = " " x $nspc;
682 print OUT "{${rstr}${nspc},\"$rn\"},\n";
683 }
684if($static) {
685 print OUT <<"EOF";
686{0,NULL}
687 };
688
689#endif
690
691${staticloader}void ERR_load_${lib}_strings(void)
692 {
693#ifndef OPENSSL_NO_ERR
694
695 if (ERR_func_error_string(${lib}_str_functs[0].error) == NULL)
696 {
697 ERR_load_strings($load_errcode,${lib}_str_functs);
698 ERR_load_strings($load_errcode,${lib}_str_reasons);
699 }
700#endif
701 }
702EOF
703} else {
704 print OUT <<"EOF";
705{0,NULL}
706 };
707
708#endif
709
710#ifdef ${lib}_LIB_NAME
711static ERR_STRING_DATA ${lib}_lib_name[]=
712 {
713{0 ,${lib}_LIB_NAME},
714{0,NULL}
715 };
716#endif
717
718
719static int ${lib}_lib_error_code=0;
720static int ${lib}_error_init=1;
721
722${staticloader}void ERR_load_${lib}_strings(void)
723 {
724 if (${lib}_lib_error_code == 0)
725 ${lib}_lib_error_code=ERR_get_next_error_library();
726
727 if (${lib}_error_init)
728 {
729 ${lib}_error_init=0;
730#ifndef OPENSSL_NO_ERR
731 ERR_load_strings(${lib}_lib_error_code,${lib}_str_functs);
732 ERR_load_strings(${lib}_lib_error_code,${lib}_str_reasons);
733#endif
734
735#ifdef ${lib}_LIB_NAME
736 ${lib}_lib_name->error = ERR_PACK(${lib}_lib_error_code,0,0);
737 ERR_load_strings(0,${lib}_lib_name);
738#endif
739 }
740 }
741
742${staticloader}void ERR_unload_${lib}_strings(void)
743 {
744 if (${lib}_error_init == 0)
745 {
746#ifndef OPENSSL_NO_ERR
747 ERR_unload_strings(${lib}_lib_error_code,${lib}_str_functs);
748 ERR_unload_strings(${lib}_lib_error_code,${lib}_str_reasons);
749#endif
750
751#ifdef ${lib}_LIB_NAME
752 ERR_unload_strings(0,${lib}_lib_name);
753#endif
754 ${lib}_error_init=1;
755 }
756 }
757
758${staticloader}void ERR_${lib}_error(int function, int reason, char *file, int line)
759 {
760 if (${lib}_lib_error_code == 0)
761 ${lib}_lib_error_code=ERR_get_next_error_library();
762 ERR_PUT_error(${lib}_lib_error_code,function,reason,file,line);
763 }
764EOF
765
766}
767
768 close OUT;
769 undef %err_reason_strings;
770}
771
772if($debug && %notrans) {
773 print STDERR "The following function codes were not translated:\n";
774 foreach(sort keys %notrans)
775 {
776 print STDERR "$_\n";
777 }
778}
779
780# Make a list of unreferenced function and reason codes
781
782foreach (keys %fcodes) {
783 push (@funref, $_) unless exists $ufcodes{$_};
784}
785
786foreach (keys %rcodes) {
787 push (@runref, $_) unless exists $urcodes{$_};
788}
789
790if($debug && defined(@funref) ) {
791 print STDERR "The following function codes were not referenced:\n";
792 foreach(sort @funref)
793 {
794 print STDERR "$_\n";
795 }
796}
797
798if($debug && defined(@runref) ) {
799 print STDERR "The following reason codes were not referenced:\n";
800 foreach(sort @runref)
801 {
802 print STDERR "$_\n";
803 }
804}
805
806if($errcount) {
807 print STDERR "There were errors, failing...\n\n";
808 exit $errcount;
809}
810
diff --git a/src/lib/libcrypto/util/mkfiles.pl b/src/lib/libcrypto/util/mkfiles.pl
new file mode 100644
index 0000000000..7d9a9d5e5c
--- /dev/null
+++ b/src/lib/libcrypto/util/mkfiles.pl
@@ -0,0 +1,143 @@
1#!/usr/local/bin/perl
2#
3# This is a hacked version of files.pl for systems that can't do a 'make files'.
4# Do a perl util/mkminfo.pl >MINFO to build MINFO
5# Written by Steve Henson 1999.
6
7# List of directories to process
8
9my @dirs = (
10".",
11"crypto",
12"crypto/md2",
13"crypto/md4",
14"crypto/md5",
15"crypto/sha",
16"crypto/mdc2",
17"crypto/hmac",
18"crypto/cmac",
19"crypto/ripemd",
20"crypto/des",
21"crypto/rc2",
22"crypto/rc4",
23"crypto/rc5",
24"crypto/idea",
25"crypto/bf",
26"crypto/cast",
27"crypto/aes",
28"crypto/camellia",
29"crypto/seed",
30"crypto/modes",
31"crypto/bn",
32"crypto/rsa",
33"crypto/dsa",
34"crypto/dso",
35"crypto/dh",
36"crypto/ec",
37"crypto/ecdh",
38"crypto/ecdsa",
39"crypto/buffer",
40"crypto/bio",
41"crypto/stack",
42"crypto/lhash",
43"crypto/rand",
44"crypto/err",
45"crypto/objects",
46"crypto/evp",
47"crypto/asn1",
48"crypto/pem",
49"crypto/x509",
50"crypto/x509v3",
51"crypto/cms",
52"crypto/conf",
53"crypto/jpake",
54"crypto/txt_db",
55"crypto/pkcs7",
56"crypto/pkcs12",
57"crypto/comp",
58"crypto/engine",
59"crypto/ocsp",
60"crypto/ui",
61"crypto/krb5",
62#"crypto/store",
63"crypto/pqueue",
64"crypto/whrlpool",
65"crypto/ts",
66"crypto/srp",
67"ssl",
68"apps",
69"engines",
70"engines/ccgost",
71"test",
72"tools"
73);
74
75%top;
76
77foreach (@dirs) {
78 &files_dir ($_, "Makefile");
79}
80
81exit(0);
82
83sub files_dir
84{
85my ($dir, $makefile) = @_;
86
87my %sym;
88
89open (IN, "$dir/$makefile") || die "Can't open $dir/$makefile";
90
91my $s="";
92
93while (<IN>)
94 {
95 chop;
96 s/#.*//;
97 if (/^(\S+)\s*=\s*(.*)$/)
98 {
99 $o="";
100 ($s,$b)=($1,$2);
101 for (;;)
102 {
103 if ($b =~ /\\$/)
104 {
105 chop($b);
106 $o.=$b." ";
107 $b=<IN>;
108 chop($b);
109 }
110 else
111 {
112 $o.=$b." ";
113 last;
114 }
115 }
116 $o =~ s/^\s+//;
117 $o =~ s/\s+$//;
118 $o =~ s/\s+/ /g;
119
120 $o =~ s/\$[({]([^)}]+)[)}]/$top{$1} or $sym{$1}/ge;
121 $sym{$s}=($top{$s} or $o);
122 }
123 }
124
125print "RELATIVE_DIRECTORY=$dir\n";
126
127foreach (sort keys %sym)
128 {
129 print "$_=$sym{$_}\n";
130 }
131if ($dir eq "." && defined($sym{"BUILDENV"}))
132 {
133 foreach (split(' ',$sym{"BUILDENV"}))
134 {
135 /^(.+)=/;
136 $top{$1}=$sym{$1};
137 }
138 }
139
140print "RELATIVE_DIRECTORY=\n";
141
142close (IN);
143}
diff --git a/src/lib/libcrypto/util/mklink.pl b/src/lib/libcrypto/util/mklink.pl
new file mode 100644
index 0000000000..61db12c68f
--- /dev/null
+++ b/src/lib/libcrypto/util/mklink.pl
@@ -0,0 +1,73 @@
1#!/usr/local/bin/perl
2
3# mklink.pl
4
5# The first command line argument is a non-empty relative path
6# specifying the "from" directory.
7# Each other argument is a file name not containing / and
8# names a file in the current directory.
9#
10# For each of these files, we create in the "from" directory a link
11# of the same name pointing to the local file.
12#
13# We assume that the directory structure is a tree, i.e. that it does
14# not contain symbolic links and that the parent of / is never referenced.
15# Apart from this, this script should be able to handle even the most
16# pathological cases.
17
18use Cwd;
19
20my $from = shift;
21my @files = @ARGV;
22
23my @from_path = split(/[\\\/]/, $from);
24my $pwd = getcwd();
25chomp($pwd);
26my @pwd_path = split(/[\\\/]/, $pwd);
27
28my @to_path = ();
29
30my $dirname;
31foreach $dirname (@from_path) {
32
33 # In this loop, @to_path always is a relative path from
34 # @pwd_path (interpreted is an absolute path) to the original pwd.
35
36 # At the end, @from_path (as a relative path from the original pwd)
37 # designates the same directory as the absolute path @pwd_path,
38 # which means that @to_path then is a path from there to the original pwd.
39
40 next if ($dirname eq "" || $dirname eq ".");
41
42 if ($dirname eq "..") {
43 @to_path = (pop(@pwd_path), @to_path);
44 } else {
45 @to_path = ("..", @to_path);
46 push(@pwd_path, $dirname);
47 }
48}
49
50my $to = join('/', @to_path);
51
52my $file;
53$symlink_exists=eval {symlink("",""); 1};
54if ($^O eq "msys") { $symlink_exists=0 };
55foreach $file (@files) {
56 my $err = "";
57 if ($symlink_exists) {
58 unlink "$from/$file";
59 symlink("$to/$file", "$from/$file") or $err = " [$!]";
60 } else {
61 unlink "$from/$file";
62 open (OLD, "<$file") or die "Can't open $file: $!";
63 open (NEW, ">$from/$file") or die "Can't open $from/$file: $!";
64 binmode(OLD);
65 binmode(NEW);
66 while (<OLD>) {
67 print NEW $_;
68 }
69 close (OLD) or die "Can't close $file: $!";
70 close (NEW) or die "Can't close $from/$file: $!";
71 }
72 print $file . " => $from/$file$err\n";
73}
diff --git a/src/lib/libcrypto/util/mkstack.pl b/src/lib/libcrypto/util/mkstack.pl
new file mode 100644
index 0000000000..f708610a78
--- /dev/null
+++ b/src/lib/libcrypto/util/mkstack.pl
@@ -0,0 +1,192 @@
1#!/usr/local/bin/perl -w
2
3# This is a utility that searches out "DECLARE_STACK_OF()"
4# declarations in .h and .c files, and updates/creates/replaces
5# the corresponding macro declarations in crypto/stack/safestack.h.
6# As it's not generally possible to have macros that generate macros,
7# we need to control this from the "outside", here in this script.
8#
9# Geoff Thorpe, June, 2000 (with massive Perl-hacking
10# help from Steve Robb)
11
12my $safestack = "crypto/stack/safestack";
13
14my $do_write;
15while (@ARGV) {
16 my $arg = $ARGV[0];
17 if($arg eq "-write") {
18 $do_write = 1;
19 }
20 shift @ARGV;
21}
22
23
24@source = (<crypto/*.[ch]>, <crypto/*/*.[ch]>, <ssl/*.[ch]>, <apps/*.[ch]>);
25foreach $file (@source) {
26 next if -l $file;
27
28 # Open the .c/.h file for reading
29 open(IN, "< $file") || die "Can't open $file for reading: $!";
30
31 while(<IN>) {
32 if (/^DECLARE_STACK_OF\(([^)]+)\)/) {
33 push @stacklst, $1;
34 }
35 if (/^DECLARE_SPECIAL_STACK_OF\(([^,\s]+)\s*,\s*([^>\s]+)\)/) {
36 push @sstacklst, [$1, $2];
37 }
38 if (/^DECLARE_ASN1_SET_OF\(([^)]+)\)/) {
39 push @asn1setlst, $1;
40 }
41 if (/^DECLARE_PKCS12_STACK_OF\(([^)]+)\)/) {
42 push @p12stklst, $1;
43 }
44 if (/^DECLARE_LHASH_OF\(([^)]+)\)/) {
45 push @lhashlst, $1;
46 }
47 }
48 close(IN);
49}
50
51
52
53my $old_stackfile = "";
54my $new_stackfile = "";
55my $inside_block = 0;
56my $type_thing;
57
58open(IN, "< $safestack.h") || die "Can't open input file: $!";
59while(<IN>) {
60 $old_stackfile .= $_;
61
62 if (m|^/\* This block of defines is updated by util/mkstack.pl, please do not touch! \*/|) {
63 $inside_block = 1;
64 }
65 if (m|^/\* End of util/mkstack.pl block, you may now edit :-\) \*/|) {
66 $inside_block = 0;
67 } elsif ($inside_block == 0) {
68 $new_stackfile .= $_;
69 }
70 next if($inside_block != 1);
71 $new_stackfile .= "/* This block of defines is updated by util/mkstack.pl, please do not touch! */";
72
73 foreach $type_thing (sort @stacklst) {
74 $new_stackfile .= <<EOF;
75
76#define sk_${type_thing}_new(cmp) SKM_sk_new($type_thing, (cmp))
77#define sk_${type_thing}_new_null() SKM_sk_new_null($type_thing)
78#define sk_${type_thing}_free(st) SKM_sk_free($type_thing, (st))
79#define sk_${type_thing}_num(st) SKM_sk_num($type_thing, (st))
80#define sk_${type_thing}_value(st, i) SKM_sk_value($type_thing, (st), (i))
81#define sk_${type_thing}_set(st, i, val) SKM_sk_set($type_thing, (st), (i), (val))
82#define sk_${type_thing}_zero(st) SKM_sk_zero($type_thing, (st))
83#define sk_${type_thing}_push(st, val) SKM_sk_push($type_thing, (st), (val))
84#define sk_${type_thing}_unshift(st, val) SKM_sk_unshift($type_thing, (st), (val))
85#define sk_${type_thing}_find(st, val) SKM_sk_find($type_thing, (st), (val))
86#define sk_${type_thing}_find_ex(st, val) SKM_sk_find_ex($type_thing, (st), (val))
87#define sk_${type_thing}_delete(st, i) SKM_sk_delete($type_thing, (st), (i))
88#define sk_${type_thing}_delete_ptr(st, ptr) SKM_sk_delete_ptr($type_thing, (st), (ptr))
89#define sk_${type_thing}_insert(st, val, i) SKM_sk_insert($type_thing, (st), (val), (i))
90#define sk_${type_thing}_set_cmp_func(st, cmp) SKM_sk_set_cmp_func($type_thing, (st), (cmp))
91#define sk_${type_thing}_dup(st) SKM_sk_dup($type_thing, st)
92#define sk_${type_thing}_pop_free(st, free_func) SKM_sk_pop_free($type_thing, (st), (free_func))
93#define sk_${type_thing}_shift(st) SKM_sk_shift($type_thing, (st))
94#define sk_${type_thing}_pop(st) SKM_sk_pop($type_thing, (st))
95#define sk_${type_thing}_sort(st) SKM_sk_sort($type_thing, (st))
96#define sk_${type_thing}_is_sorted(st) SKM_sk_is_sorted($type_thing, (st))
97EOF
98 }
99
100 foreach $type_thing (sort @sstacklst) {
101 my $t1 = $type_thing->[0];
102 my $t2 = $type_thing->[1];
103 $new_stackfile .= <<EOF;
104
105#define sk_${t1}_new(cmp) ((STACK_OF($t1) *)sk_new(CHECKED_SK_CMP_FUNC($t2, cmp)))
106#define sk_${t1}_new_null() ((STACK_OF($t1) *)sk_new_null())
107#define sk_${t1}_push(st, val) sk_push(CHECKED_STACK_OF($t1, st), CHECKED_PTR_OF($t2, val))
108#define sk_${t1}_find(st, val) sk_find(CHECKED_STACK_OF($t1, st), CHECKED_PTR_OF($t2, val))
109#define sk_${t1}_value(st, i) (($t1)sk_value(CHECKED_STACK_OF($t1, st), i))
110#define sk_${t1}_num(st) SKM_sk_num($t1, st)
111#define sk_${t1}_pop_free(st, free_func) sk_pop_free(CHECKED_STACK_OF($t1, st), CHECKED_SK_FREE_FUNC2($t1, free_func))
112#define sk_${t1}_insert(st, val, i) sk_insert(CHECKED_STACK_OF($t1, st), CHECKED_PTR_OF($t2, val), i)
113#define sk_${t1}_free(st) SKM_sk_free(${t1}, st)
114#define sk_${t1}_set(st, i, val) sk_set(CHECKED_STACK_OF($t1, st), i, CHECKED_PTR_OF($t2, val))
115#define sk_${t1}_zero(st) SKM_sk_zero($t1, (st))
116#define sk_${t1}_unshift(st, val) sk_unshift(CHECKED_STACK_OF($t1, st), CHECKED_PTR_OF($t2, val))
117#define sk_${t1}_find_ex(st, val) sk_find_ex((_STACK *)CHECKED_CONST_PTR_OF(STACK_OF($t1), st), CHECKED_CONST_PTR_OF($t2, val))
118#define sk_${t1}_delete(st, i) SKM_sk_delete($t1, (st), (i))
119#define sk_${t1}_delete_ptr(st, ptr) ($t1 *)sk_delete_ptr(CHECKED_STACK_OF($t1, st), CHECKED_PTR_OF($t2, ptr))
120#define sk_${t1}_set_cmp_func(st, cmp) \\
121 ((int (*)(const $t2 * const *,const $t2 * const *)) \\
122 sk_set_cmp_func(CHECKED_STACK_OF($t1, st), CHECKED_SK_CMP_FUNC($t2, cmp)))
123#define sk_${t1}_dup(st) SKM_sk_dup($t1, st)
124#define sk_${t1}_shift(st) SKM_sk_shift($t1, (st))
125#define sk_${t1}_pop(st) ($t2 *)sk_pop(CHECKED_STACK_OF($t1, st))
126#define sk_${t1}_sort(st) SKM_sk_sort($t1, (st))
127#define sk_${t1}_is_sorted(st) SKM_sk_is_sorted($t1, (st))
128
129EOF
130 }
131
132 foreach $type_thing (sort @asn1setlst) {
133 $new_stackfile .= <<EOF;
134
135#define d2i_ASN1_SET_OF_${type_thing}(st, pp, length, d2i_func, free_func, ex_tag, ex_class) \\
136 SKM_ASN1_SET_OF_d2i($type_thing, (st), (pp), (length), (d2i_func), (free_func), (ex_tag), (ex_class))
137#define i2d_ASN1_SET_OF_${type_thing}(st, pp, i2d_func, ex_tag, ex_class, is_set) \\
138 SKM_ASN1_SET_OF_i2d($type_thing, (st), (pp), (i2d_func), (ex_tag), (ex_class), (is_set))
139#define ASN1_seq_pack_${type_thing}(st, i2d_func, buf, len) \\
140 SKM_ASN1_seq_pack($type_thing, (st), (i2d_func), (buf), (len))
141#define ASN1_seq_unpack_${type_thing}(buf, len, d2i_func, free_func) \\
142 SKM_ASN1_seq_unpack($type_thing, (buf), (len), (d2i_func), (free_func))
143EOF
144 }
145 foreach $type_thing (sort @p12stklst) {
146 $new_stackfile .= <<EOF;
147
148#define PKCS12_decrypt_d2i_${type_thing}(algor, d2i_func, free_func, pass, passlen, oct, seq) \\
149 SKM_PKCS12_decrypt_d2i($type_thing, (algor), (d2i_func), (free_func), (pass), (passlen), (oct), (seq))
150EOF
151 }
152
153 foreach $type_thing (sort @lhashlst) {
154 my $lc_tt = lc $type_thing;
155 $new_stackfile .= <<EOF;
156
157#define lh_${type_thing}_new() LHM_lh_new(${type_thing},${lc_tt})
158#define lh_${type_thing}_insert(lh,inst) LHM_lh_insert(${type_thing},lh,inst)
159#define lh_${type_thing}_retrieve(lh,inst) LHM_lh_retrieve(${type_thing},lh,inst)
160#define lh_${type_thing}_delete(lh,inst) LHM_lh_delete(${type_thing},lh,inst)
161#define lh_${type_thing}_doall(lh,fn) LHM_lh_doall(${type_thing},lh,fn)
162#define lh_${type_thing}_doall_arg(lh,fn,arg_type,arg) \\
163 LHM_lh_doall_arg(${type_thing},lh,fn,arg_type,arg)
164#define lh_${type_thing}_error(lh) LHM_lh_error(${type_thing},lh)
165#define lh_${type_thing}_num_items(lh) LHM_lh_num_items(${type_thing},lh)
166#define lh_${type_thing}_down_load(lh) LHM_lh_down_load(${type_thing},lh)
167#define lh_${type_thing}_node_stats_bio(lh,out) \\
168 LHM_lh_node_stats_bio(${type_thing},lh,out)
169#define lh_${type_thing}_node_usage_stats_bio(lh,out) \\
170 LHM_lh_node_usage_stats_bio(${type_thing},lh,out)
171#define lh_${type_thing}_stats_bio(lh,out) \\
172 LHM_lh_stats_bio(${type_thing},lh,out)
173#define lh_${type_thing}_free(lh) LHM_lh_free(${type_thing},lh)
174EOF
175 }
176
177 $new_stackfile .= "/* End of util/mkstack.pl block, you may now edit :-) */\n";
178 $inside_block = 2;
179}
180
181
182if ($new_stackfile eq $old_stackfile) {
183 print "No changes to $safestack.h.\n";
184 exit 0; # avoid unnecessary rebuild
185}
186
187if ($do_write) {
188 print "Writing new $safestack.h.\n";
189 open OUT, ">$safestack.h" || die "Can't open output file";
190 print OUT $new_stackfile;
191 close OUT;
192}
diff --git a/src/lib/libcrypto/util/opensslwrap.sh b/src/lib/libcrypto/util/opensslwrap.sh
new file mode 100755
index 0000000000..b27cbb897f
--- /dev/null
+++ b/src/lib/libcrypto/util/opensslwrap.sh
@@ -0,0 +1,26 @@
1#!/bin/sh
2
3HERE="`echo $0 | sed -e 's|[^/]*$||'`"
4OPENSSL="${HERE}../apps/openssl"
5
6if [ -d "${HERE}../engines" -a "x$OPENSSL_ENGINES" = "x" ]; then
7 OPENSSL_ENGINES="${HERE}../engines"; export OPENSSL_ENGINES
8fi
9
10if [ -x "${OPENSSL}.exe" ]; then
11 # The original reason for this script existence is to work around
12 # certain caveats in run-time linker behaviour. On Windows platforms
13 # adjusting $PATH used to be sufficient, but with introduction of
14 # SafeDllSearchMode in XP/2003 the only way to get it right in
15 # *all* possible situations is to copy newly built .DLLs to apps/
16 # and test/, which is now done elsewhere... The $PATH is adjusted
17 # for backward compatibility (and nostagical reasons:-).
18 if [ "$OSTYPE" != msdosdjgpp ]; then
19 PATH="${HERE}..:$PATH"; export PATH
20 fi
21 exec "${OPENSSL}.exe" "$@"
22elif [ -x "${OPENSSL}" -a -x "${HERE}shlib_wrap.sh" ]; then
23 exec "${HERE}shlib_wrap.sh" "${OPENSSL}" "$@"
24else
25 exec "${OPENSSL}" "$@" # hope for the best...
26fi
diff --git a/src/lib/libcrypto/util/perlpath.pl b/src/lib/libcrypto/util/perlpath.pl
new file mode 100644
index 0000000000..a1f236bd98
--- /dev/null
+++ b/src/lib/libcrypto/util/perlpath.pl
@@ -0,0 +1,35 @@
1#!/usr/local/bin/perl
2#
3# modify the '#!/usr/local/bin/perl'
4# line in all scripts that rely on perl.
5#
6
7require "find.pl";
8
9$#ARGV == 0 || print STDERR "usage: perlpath newpath (eg /usr/bin)\n";
10&find(".");
11
12sub wanted
13 {
14 return unless /\.pl$/ || /^[Cc]onfigur/;
15
16 open(IN,"<$_") || die "unable to open $dir/$_:$!\n";
17 @a=<IN>;
18 close(IN);
19
20 if (-d $ARGV[0]) {
21 $a[0]="#!$ARGV[0]/perl\n";
22 }
23 else {
24 $a[0]="#!$ARGV[0]\n";
25 }
26
27 # Playing it safe...
28 $new="$_.new";
29 open(OUT,">$new") || die "unable to open $dir/$new:$!\n";
30 print OUT @a;
31 close(OUT);
32
33 rename($new,$_) || die "unable to rename $dir/$new:$!\n";
34 chmod(0755,$_) || die "unable to chmod $dir/$new:$!\n";
35 }
diff --git a/src/lib/libcrypto/util/pl/BC-32.pl b/src/lib/libcrypto/util/pl/BC-32.pl
new file mode 100644
index 0000000000..b41bb45e82
--- /dev/null
+++ b/src/lib/libcrypto/util/pl/BC-32.pl
@@ -0,0 +1,139 @@
1#!/usr/local/bin/perl
2# Borland C++ builder 3 and 4 -- Janez Jere <jj@void.si>
3#
4
5$ssl= "ssleay32";
6$crypto="libeay32";
7
8$o='\\';
9$cp='copy';
10$rm='del';
11
12# C compiler stuff
13$cc='bcc32';
14$lflags="-ap -Tpe -x -Gn ";
15$mlflags='';
16
17$out_def="out32";
18$tmp_def="tmp32";
19$inc_def="inc32";
20#enable max error messages, disable most common warnings
21$cflags="-DWIN32_LEAN_AND_MEAN -q -w-ccc -w-rch -w-pia -w-aus -w-par -w-inl -c -tWC -tWM -DOPENSSL_SYSNAME_WIN32 -DL_ENDIAN -DDSO_WIN32 -D_stricmp=stricmp -D_strnicmp=strnicmp -D_timeb=timeb -D_ftime=ftime ";
22if ($debug)
23{
24 $cflags.="-Od -y -v -vi- -D_DEBUG";
25 $mlflags.=' ';
26}
27else
28{
29 $cflags.="-O2 -ff -fp";
30}
31
32$obj='.obj';
33$ofile="-o";
34
35# EXE linking stuff
36$link="ilink32";
37$efile="";
38$exep='.exe';
39if ($no_sock)
40 { $ex_libs=""; }
41else { $ex_libs="cw32mt.lib import32.lib crypt32.lib ws2_32.lib"; }
42
43# static library stuff
44$mklib='tlib /P64';
45$ranlib='';
46$plib="";
47$libp=".lib";
48$shlibp=($shlib)?".dll":".lib";
49$lfile='';
50
51$shlib_ex_obj="";
52$app_ex_obj="c0x32.obj";
53
54$asm=(`nasm -v 2>NUL` ge `nasmw -v 2>NUL`?"nasm":"nasmw")." -f obj -d__omf__";
55$asm.=" -g" if $debug;
56$afile='-o';
57
58$bn_mulw_obj='';
59$bn_mulw_src='';
60$des_enc_obj='';
61$des_enc_src='';
62$bf_enc_obj='';
63$bf_enc_src='';
64
65if (!$no_asm)
66 {
67 $bn_mulw_obj='crypto\bn\asm\bn_win32.obj';
68 $bn_mulw_src='crypto\bn\asm\bn_win32.asm';
69 $des_enc_obj='crypto\des\asm\d_win32.obj crypto\des\asm\y_win32.obj';
70 $des_enc_src='crypto\des\asm\d_win32.asm crypto\des\asm\y_win32.asm';
71 $bf_enc_obj='crypto\bf\asm\b_win32.obj';
72 $bf_enc_src='crypto\bf\asm\b_win32.asm';
73 $cast_enc_obj='crypto\cast\asm\c_win32.obj';
74 $cast_enc_src='crypto\cast\asm\c_win32.asm';
75 $rc4_enc_obj='crypto\rc4\asm\r4_win32.obj';
76 $rc4_enc_src='crypto\rc4\asm\r4_win32.asm';
77 $rc5_enc_obj='crypto\rc5\asm\r5_win32.obj';
78 $rc5_enc_src='crypto\rc5\asm\r5_win32.asm';
79 $md5_asm_obj='crypto\md5\asm\m5_win32.obj';
80 $md5_asm_src='crypto\md5\asm\m5_win32.asm';
81 $sha1_asm_obj='crypto\sha\asm\s1_win32.obj';
82 $sha1_asm_src='crypto\sha\asm\s1_win32.asm';
83 $rmd160_asm_obj='crypto\ripemd\asm\rm_win32.obj';
84 $rmd160_asm_src='crypto\ripemd\asm\rm_win32.asm';
85 $cflags.=" -DBN_ASM -DMD5_ASM -DSHA1_ASM -DRMD160_ASM";
86 }
87
88if ($shlib)
89 {
90 $mlflags.=" $lflags /dll";
91# $cflags =~ s| /MD| /MT|;
92 $lib_cflag=" /GD -D_WINDLL -D_DLL";
93 $out_def="out32dll";
94 $tmp_def="tmp32dll";
95 }
96
97sub do_lib_rule
98 {
99 local($objs,$target,$name,$shlib)=@_;
100 local($ret,$Name);
101
102 $taget =~ s/\//$o/g if $o ne '/';
103 ($Name=$name) =~ tr/a-z/A-Z/;
104
105# $target="\$(LIB_D)$o$target";
106 $ret.="$target: $objs\n";
107 if (!$shlib)
108 {
109 $ret.=<<___;
110 -\$(RM) $lfile$target
111 \$(MKLIB) $lfile$target \@&&!
112+\$(**: = &^
113+)
114!
115___
116 }
117 else
118 {
119 local($ex)=($target =~ /O_SSL/)?' $(L_CRYPTO)':'';
120 $ex.=' ws2_32.lib gdi32.lib';
121 $ret.="\t\$(LINK) \$(MLFLAGS) $efile$target /def:ms/${Name}.def @<<\n \$(SHLIB_EX_OBJ) $objs $ex\n<<\n";
122 }
123 $ret.="\n";
124 return($ret);
125 }
126
127sub do_link_rule
128 {
129 local($target,$files,$dep_libs,$libs)=@_;
130 local($ret,$_);
131
132 $file =~ s/\//$o/g if $o ne '/';
133 $n=&bname($targer);
134 $ret.="$target: $files $dep_libs\n";
135 $ret.="\t\$(LINK) \$(LFLAGS) $files \$(APP_EX_OBJ), $target,, $libs\n\n";
136 return($ret);
137 }
138
1391;
diff --git a/src/lib/libcrypto/util/pl/Mingw32.pl b/src/lib/libcrypto/util/pl/Mingw32.pl
new file mode 100644
index 0000000000..fe3fb27a78
--- /dev/null
+++ b/src/lib/libcrypto/util/pl/Mingw32.pl
@@ -0,0 +1,104 @@
1#!/usr/local/bin/perl
2#
3# Mingw32.pl -- Mingw
4#
5
6$o='/';
7$cp='cp';
8$rm='rm -f';
9$mkdir='gmkdir';
10
11$o='\\';
12$cp='copy';
13$rm='del';
14$mkdir='mkdir';
15
16# C compiler stuff
17
18$cc='gcc';
19if ($debug)
20 { $cflags="-DL_ENDIAN -DDSO_WIN32 -g2 -ggdb"; }
21else
22 { $cflags="-DL_ENDIAN -DDSO_WIN32 -fomit-frame-pointer -O3 -mcpu=i486 -Wall"; }
23
24if ($gaswin and !$no_asm)
25 {
26 $bn_asm_obj='$(OBJ_D)\bn-win32.o';
27 $bn_asm_src='crypto/bn/asm/bn-win32.s';
28 $bnco_asm_obj='$(OBJ_D)\co-win32.o';
29 $bnco_asm_src='crypto/bn/asm/co-win32.s';
30 $des_enc_obj='$(OBJ_D)\d-win32.o $(OBJ_D)\y-win32.o';
31 $des_enc_src='crypto/des/asm/d-win32.s crypto/des/asm/y-win32.s';
32 $bf_enc_obj='$(OBJ_D)\b-win32.o';
33 $bf_enc_src='crypto/bf/asm/b-win32.s';
34# $cast_enc_obj='$(OBJ_D)\c-win32.o';
35# $cast_enc_src='crypto/cast/asm/c-win32.s';
36 $rc4_enc_obj='$(OBJ_D)\r4-win32.o';
37 $rc4_enc_src='crypto/rc4/asm/r4-win32.s';
38 $rc5_enc_obj='$(OBJ_D)\r5-win32.o';
39 $rc5_enc_src='crypto/rc5/asm/r5-win32.s';
40 $md5_asm_obj='$(OBJ_D)\m5-win32.o';
41 $md5_asm_src='crypto/md5/asm/m5-win32.s';
42 $rmd160_asm_obj='$(OBJ_D)\rm-win32.o';
43 $rmd160_asm_src='crypto/ripemd/asm/rm-win32.s';
44 $sha1_asm_obj='$(OBJ_D)\s1-win32.o';
45 $sha1_asm_src='crypto/sha/asm/s1-win32.s';
46 $cflags.=" -DBN_ASM -DMD5_ASM -DSHA1_ASM -DOPENSSL_BN_ASM_PART_WORDS";
47 }
48
49
50$obj='.o';
51$ofile='-o ';
52
53# EXE linking stuff
54$link='${CC}';
55$lflags='${CFLAGS}';
56$efile='-o ';
57$exep='';
58$ex_libs="-lws2_32 -lgdi32";
59
60# static library stuff
61$mklib='ar r';
62$mlflags='';
63$ranlib='ranlib';
64$plib='lib';
65$libp=".a";
66$shlibp=".a";
67$lfile='';
68
69$asm='as';
70$afile='-o ';
71#$bn_asm_obj="";
72#$bn_asm_src="";
73#$des_enc_obj="";
74#$des_enc_src="";
75#$bf_enc_obj="";
76#$bf_enc_src="";
77
78sub do_lib_rule
79 {
80 local($obj,$target,$name,$shlib)=@_;
81 local($ret,$_,$Name);
82
83 $target =~ s/\//$o/g if $o ne '/';
84 $target="$target";
85 ($Name=$name) =~ tr/a-z/A-Z/;
86
87 $ret.="$target: \$(${Name}OBJ)\n";
88 $ret.="\tif exist $target \$(RM) $target\n";
89 $ret.="\t\$(MKLIB) $target \$(${Name}OBJ)\n";
90 $ret.="\t\$(RANLIB) $target\n\n";
91 }
92
93sub do_link_rule
94 {
95 local($target,$files,$dep_libs,$libs)=@_;
96 local($ret,$_);
97
98 $file =~ s/\//$o/g if $o ne '/';
99 $n=&bname($target);
100 $ret.="$target: $files $dep_libs\n";
101 $ret.="\t\$(LINK) ${efile}$target \$(LFLAGS) $files $libs\n\n";
102 return($ret);
103 }
1041;
diff --git a/src/lib/libcrypto/util/pl/OS2-EMX.pl b/src/lib/libcrypto/util/pl/OS2-EMX.pl
new file mode 100644
index 0000000000..28cd116907
--- /dev/null
+++ b/src/lib/libcrypto/util/pl/OS2-EMX.pl
@@ -0,0 +1,120 @@
1#!/usr/local/bin/perl
2#
3# OS2-EMX.pl - for EMX GCC on OS/2
4#
5
6$o='/';
7$cp='cp';
8$rm='rm -f';
9
10$preamble = "SHELL=sh\n";
11
12# C compiler stuff
13
14$cc='gcc';
15$cflags="-DL_ENDIAN -O3 -fomit-frame-pointer -m486 -Zmtd -Wall ";
16$cflags.="-Zomf " if $shlib;
17$shl_cflag="-Zdll";
18
19if ($debug) {
20 $cflags.="-g ";
21}
22
23$obj=$shlib ? '.obj' : '.o';
24$ofile='-o ';
25
26# EXE linking stuff
27$link='${CC}';
28$lflags='${CFLAGS} -Zbsd-signals -s';
29$efile='-o ';
30$exep='.exe';
31$ex_libs="-lsocket";
32
33# static library stuff
34$mklib='ar r';
35$mlflags='';
36$ranlib="ar s";
37$plib='';
38$libp=$shlib ? ".lib" : ".a";
39$shlibp=$shlib ? ".dll" : ".a";
40$lfile='';
41
42$asm=$shlib ? 'as -Zomf' : 'as';
43$afile='-o ';
44$bn_asm_obj="";
45$bn_asm_src="";
46$des_enc_obj="";
47$des_enc_src="";
48$bf_enc_obj="";
49$bf_enc_src="";
50
51if (!$no_asm)
52 {
53 $bn_asm_obj="crypto/bn/asm/bn-os2$obj crypto/bn/asm/co-os2$obj";
54 $bn_asm_src="crypto/bn/asm/bn-os2.asm crypto/bn/asm/co-os2.asm";
55 $des_enc_obj="crypto/des/asm/d-os2$obj crypto/des/asm/y-os2$obj";
56 $des_enc_src="crypto/des/asm/d-os2.asm crypto/des/asm/y-os2.asm";
57 $bf_enc_obj="crypto/bf/asm/b-os2$obj";
58 $bf_enc_src="crypto/bf/asm/b-os2.asm";
59 $cast_enc_obj="crypto/cast/asm/c-os2$obj";
60 $cast_enc_src="crypto/cast/asm/c-os2.asm";
61 $rc4_enc_obj="crypto/rc4/asm/r4-os2$obj";
62 $rc4_enc_src="crypto/rc4/asm/r4-os2.asm";
63 $rc5_enc_obj="crypto/rc5/asm/r5-os2$obj";
64 $rc5_enc_src="crypto/rc5/asm/r5-os2.asm";
65 $md5_asm_obj="crypto/md5/asm/m5-os2$obj";
66 $md5_asm_src="crypto/md5/asm/m5-os2.asm";
67 $sha1_asm_obj="crypto/sha/asm/s1-os2$obj";
68 $sha1_asm_src="crypto/sha/asm/s1-os2.asm";
69 $rmd160_asm_obj="crypto/ripemd/asm/rm-os2$obj";
70 $rmd160_asm_src="crypto/ripemd/asm/rm-os2.asm";
71 $cflags.=" -DBN_ASM -DMD5_ASM -DSHA1_ASM -DOPENSSL_BN_ASM_PART_WORDS";
72 }
73
74if ($shlib)
75 {
76 $mlflags.=" $lflags -Zdll";
77 $lib_cflag=" -D_DLL";
78 $out_def="out_dll";
79 $tmp_def="tmp_dll";
80 }
81
82sub do_lib_rule
83 {
84 local($obj,$target,$name,$shlib)=@_;
85 local($ret,$_,$Name);
86
87 $target =~ s/\//$o/g if $o ne '/';
88 $target="$target";
89 ($Name=$name) =~ tr/a-z/A-Z/;
90
91 $ret.="$target: \$(${Name}OBJ)\n";
92 if (!$shlib)
93 {
94 $ret.="\t\$(RM) $target\n";
95 $ret.="\t\$(MKLIB) $target \$(${Name}OBJ)\n";
96 $ret.="\t\$(RANLIB) $target\n\n";
97 }
98 else
99 {
100 local($ex)=($target =~ /O_SSL/)?' $(L_CRYPTO)':'';
101 $ex.=' -lsocket';
102 $ret.="\t\$(LINK) \$(SHLIB_CFLAGS) \$(MLFLAGS) $efile$target \$(SHLIB_EX_OBJ) \$(${Name}OBJ) $ex os2/${Name}.def\n";
103 $ret.="\temximp -o $out_def/$name.a os2/${Name}.def\n";
104 $ret.="\temximp -o $out_def/$name.lib os2/${Name}.def\n\n";
105 }
106 }
107
108sub do_link_rule
109 {
110 local($target,$files,$dep_libs,$libs)=@_;
111 local($ret,$_);
112
113 $file =~ s/\//$o/g if $o ne '/';
114 $n=&bname($target);
115 $ret.="$target: $files $dep_libs\n";
116 $ret.="\t\$(LINK) ${efile}$target \$(CFLAG) \$(LFLAGS) $files $libs\n\n";
117 return($ret);
118 }
119
1201;
diff --git a/src/lib/libcrypto/util/pl/VC-32.pl b/src/lib/libcrypto/util/pl/VC-32.pl
new file mode 100644
index 0000000000..3705fc73b7
--- /dev/null
+++ b/src/lib/libcrypto/util/pl/VC-32.pl
@@ -0,0 +1,400 @@
1#!/usr/local/bin/perl
2# VC-32.pl - unified script for Microsoft Visual C++, covering Win32,
3# Win64 and WinCE [follow $FLAVOR variable to trace the differences].
4#
5
6$ssl= "ssleay32";
7$crypto="libeay32";
8
9if ($fips && !$shlib)
10 {
11 $crypto="libeayfips32";
12 $crypto_compat = "libeaycompat32.lib";
13 }
14else
15 {
16 $crypto="libeay32";
17 }
18
19$o='\\';
20$cp='$(PERL) util/copy.pl';
21$mkdir='$(PERL) util/mkdir-p.pl';
22$rm='del /Q';
23
24$zlib_lib="zlib1.lib";
25
26# Santize -L options for ms link
27$l_flags =~ s/-L("\[^"]+")/\/libpath:$1/g;
28$l_flags =~ s/-L(\S+)/\/libpath:$1/g;
29
30my $ff = "";
31
32# C compiler stuff
33$cc='cl';
34if ($FLAVOR =~ /WIN64/)
35 {
36 # Note that we currently don't have /WX on Win64! There is a lot of
37 # warnings, but only of two types:
38 #
39 # C4344: conversion from '__int64' to 'int/long', possible loss of data
40 # C4267: conversion from 'size_t' to 'int/long', possible loss of data
41 #
42 # Amount of latter type is minimized by aliasing strlen to function of
43 # own desing and limiting its return value to 2GB-1 (see e_os.h). As
44 # per 0.9.8 release remaining warnings were explicitly examined and
45 # considered safe to ignore.
46 #
47 $base_cflags= " $mf_cflag";
48 my $f = $shlib || $fips ?' /MD':' /MT';
49 $lib_cflag='/Zl' if (!$shlib); # remove /DEFAULTLIBs from static lib
50 $opt_cflags=$f.' /Ox';
51 $dbg_cflags=$f.'d /Od -DDEBUG -D_DEBUG';
52 $lflags="/nologo /subsystem:console /opt:ref";
53
54 *::perlasm_compile_target = sub {
55 my ($target,$source,$bname)=@_;
56 my $ret;
57
58 $bname =~ s/(.*)\.[^\.]$/$1/;
59 $ret=<<___;
60\$(TMP_D)$o$bname.asm: $source
61 set ASM=\$(ASM)
62 \$(PERL) $source \$\@
63
64$target: \$(TMP_D)$o$bname.asm
65 \$(ASM) $afile\$\@ \$(TMP_D)$o$bname.asm
66
67___
68 }
69 }
70elsif ($FLAVOR =~ /CE/)
71 {
72 # sanity check
73 die '%OSVERSION% is not defined' if (!defined($ENV{'OSVERSION'}));
74 die '%PLATFORM% is not defined' if (!defined($ENV{'PLATFORM'}));
75 die '%TARGETCPU% is not defined' if (!defined($ENV{'TARGETCPU'}));
76
77 #
78 # Idea behind this is to mimic flags set by eVC++ IDE...
79 #
80 $wcevers = $ENV{'OSVERSION'}; # WCENNN
81 die '%OSVERSION% value is insane' if ($wcevers !~ /^WCE([1-9])([0-9]{2})$/);
82 $wcecdefs = "-D_WIN32_WCE=$1$2 -DUNDER_CE=$1$2"; # -D_WIN32_WCE=NNN
83 $wcelflag = "/subsystem:windowsce,$1.$2"; # ...,N.NN
84
85 $wceplatf = $ENV{'PLATFORM'};
86 $wceplatf =~ tr/a-z0-9 /A-Z0-9_/d;
87 $wcecdefs .= " -DWCE_PLATFORM_$wceplatf";
88
89 $wcetgt = $ENV{'TARGETCPU'}; # just shorter name...
90 SWITCH: for($wcetgt) {
91 /^X86/ && do { $wcecdefs.=" -Dx86 -D_X86_ -D_i386_ -Di_386_";
92 $wcelflag.=" /machine:IX86"; last; };
93 /^ARMV4[IT]/ && do { $wcecdefs.=" -DARM -D_ARM_ -D$wcetgt";
94 $wcecdefs.=" -DTHUMB -D_THUMB_" if($wcetgt=~/T$/);
95 $wcecdefs.=" -QRarch4T -QRinterwork-return";
96 $wcelflag.=" /machine:THUMB"; last; };
97 /^ARM/ && do { $wcecdefs.=" -DARM -D_ARM_ -D$wcetgt";
98 $wcelflag.=" /machine:ARM"; last; };
99 /^MIPSIV/ && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000 -D$wcetgt";
100 $wcecdefs.=" -D_MIPS64 -QMmips4 -QMn32";
101 $wcelflag.=" /machine:MIPSFPU"; last; };
102 /^MIPS16/ && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000 -D$wcetgt";
103 $wcecdefs.=" -DMIPSII -QMmips16";
104 $wcelflag.=" /machine:MIPS16"; last; };
105 /^MIPSII/ && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000 -D$wcetgt";
106 $wcecdefs.=" -QMmips2";
107 $wcelflag.=" /machine:MIPS"; last; };
108 /^R4[0-9]{3}/ && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000";
109 $wcelflag.=" /machine:MIPS"; last; };
110 /^SH[0-9]/ && do { $wcecdefs.=" -D$wcetgt -D_$wcetgt_ -DSHx";
111 $wcecdefs.=" -Qsh4" if ($wcetgt =~ /^SH4/);
112 $wcelflag.=" /machine:$wcetgt"; last; };
113 { $wcecdefs.=" -D$wcetgt -D_$wcetgt_";
114 $wcelflag.=" /machine:$wcetgt"; last; };
115 }
116
117 $cc='$(CC)';
118 $base_cflags=' /W3 /WX /GF /Gy /nologo -DUNICODE -D_UNICODE -DOPENSSL_SYSNAME_WINCE -DWIN32_LEAN_AND_MEAN -DL_ENDIAN -DDSO_WIN32 -DNO_CHMOD -DOPENSSL_SMALL_FOOTPRINT';
119 $base_cflags.=" $wcecdefs";
120 $base_cflags.=' -I$(WCECOMPAT)/include' if (defined($ENV{'WCECOMPAT'}));
121 $base_cflags.=' -I$(PORTSDK_LIBPATH)/../../include' if (defined($ENV{'PORTSDK_LIBPATH'}));
122 $opt_cflags=' /MC /O1i'; # optimize for space, but with intrinsics...
123 $dbg_cflags=' /MC /Od -DDEBUG -D_DEBUG';
124 $lflags="/nologo /opt:ref $wcelflag";
125 }
126else # Win32
127 {
128 $base_cflags= " $mf_cflag";
129 my $f = $shlib || $fips ?' /MD':' /MT';
130 $lib_cflag='/Zl' if (!$shlib); # remove /DEFAULTLIBs from static lib
131 $ff = "/fixed";
132 $opt_cflags=$f.' /Ox /O2 /Ob2';
133 $dbg_cflags=$f.'d /Od -DDEBUG -D_DEBUG';
134 $lflags="/nologo /subsystem:console /opt:ref";
135 }
136$mlflags='';
137
138$out_def ="out32"; $out_def.="dll" if ($shlib);
139 $out_def.='_$(TARGETCPU)' if ($FLAVOR =~ /CE/);
140$tmp_def ="tmp32"; $tmp_def.="dll" if ($shlib);
141 $tmp_def.='_$(TARGETCPU)' if ($FLAVOR =~ /CE/);
142$inc_def="inc32";
143
144if ($debug)
145 {
146 $cflags=$dbg_cflags.$base_cflags;
147 }
148else
149 {
150 $cflags=$opt_cflags.$base_cflags;
151 }
152
153# generate symbols.pdb unconditionally
154$app_cflag.=" /Zi /Fd\$(TMP_D)/app";
155$lib_cflag.=" /Zi /Fd\$(TMP_D)/lib";
156$lflags.=" /debug";
157
158$obj='.obj';
159$asm_suffix='.asm';
160$ofile="/Fo";
161
162# EXE linking stuff
163$link="link";
164$rsc="rc";
165$efile="/out:";
166$exep='.exe';
167if ($no_sock) { $ex_libs=''; }
168elsif ($FLAVOR =~ /CE/) { $ex_libs='winsock.lib'; }
169else { $ex_libs='ws2_32.lib'; }
170
171if ($FLAVOR =~ /CE/)
172 {
173 $ex_libs.=' $(WCECOMPAT)/lib/wcecompatex.lib' if (defined($ENV{'WCECOMPAT'}));
174 $ex_libs.=' $(PORTSDK_LIBPATH)/portlib.lib' if (defined($ENV{'PORTSDK_LIBPATH'}));
175 $ex_libs.=' /nodefaultlib:oldnames.lib coredll.lib corelibc.lib' if ($ENV{'TARGETCPU'} eq "X86");
176 }
177else
178 {
179 $ex_libs.=' gdi32.lib advapi32.lib crypt32.lib user32.lib';
180 $ex_libs.=' bufferoverflowu.lib' if ($FLAVOR =~ /WIN64/ and `cl 2>&1` =~ /14\.00\.4[0-9]{4}\./);
181 # WIN32 UNICODE build gets linked with unicows.lib for
182 # backward compatibility with Win9x.
183 $ex_libs="unicows.lib $ex_libs" if ($FLAVOR =~ /WIN32/ and $cflags =~ /\-DUNICODE/);
184 }
185
186# static library stuff
187$mklib='lib /nologo';
188$ranlib='';
189$plib="";
190$libp=".lib";
191$shlibp=($shlib)?".dll":".lib";
192$lfile='/out:';
193
194$shlib_ex_obj="";
195$app_ex_obj="setargv.obj" if ($FLAVOR !~ /CE/);
196if ($FLAVOR =~ /WIN64A/) {
197 if (`nasm -v 2>NUL` =~ /NASM version ([0-9]+\.[0-9]+)/ && $1 >= 2.0) {
198 $asm='nasm -f win64 -DNEAR -Ox -g';
199 $afile='-o ';
200 } else {
201 $asm='ml64 /c /Cp /Cx /Zi';
202 $afile='/Fo';
203 }
204} elsif ($FLAVOR =~ /WIN64I/) {
205 $asm='ias -d debug';
206 $afile="-o ";
207} elsif ($nasm) {
208 my $ver=`nasm -v 2>NUL`;
209 my $vew=`nasmw -v 2>NUL`;
210 # pick newest version
211 $asm=($ver ge $vew?"nasm":"nasmw")." -f win32";
212 $asmtype="win32n";
213 $afile='-o ';
214} else {
215 $asm='ml /nologo /Cp /coff /c /Cx /Zi';
216 $afile='/Fo';
217 $asmtype="win32";
218}
219
220$bn_asm_obj='';
221$bn_asm_src='';
222$des_enc_obj='';
223$des_enc_src='';
224$bf_enc_obj='';
225$bf_enc_src='';
226
227if (!$no_asm)
228 {
229 win32_import_asm($mf_bn_asm, "bn", \$bn_asm_obj, \$bn_asm_src);
230 win32_import_asm($mf_aes_asm, "aes", \$aes_asm_obj, \$aes_asm_src);
231 win32_import_asm($mf_des_asm, "des", \$des_enc_obj, \$des_enc_src);
232 win32_import_asm($mf_bf_asm, "bf", \$bf_enc_obj, \$bf_enc_src);
233 win32_import_asm($mf_cast_asm, "cast", \$cast_enc_obj, \$cast_enc_src);
234 win32_import_asm($mf_rc4_asm, "rc4", \$rc4_enc_obj, \$rc4_enc_src);
235 win32_import_asm($mf_rc5_asm, "rc5", \$rc5_enc_obj, \$rc5_enc_src);
236 win32_import_asm($mf_md5_asm, "md5", \$md5_asm_obj, \$md5_asm_src);
237 win32_import_asm($mf_sha_asm, "sha", \$sha1_asm_obj, \$sha1_asm_src);
238 win32_import_asm($mf_rmd_asm, "ripemd", \$rmd160_asm_obj, \$rmd160_asm_src);
239 win32_import_asm($mf_wp_asm, "whrlpool", \$whirlpool_asm_obj, \$whirlpool_asm_src);
240 win32_import_asm($mf_cpuid_asm, "", \$cpuid_asm_obj, \$cpuid_asm_src);
241 $perl_asm = 1;
242 }
243
244if ($shlib && $FLAVOR !~ /CE/)
245 {
246 $mlflags.=" $lflags /dll";
247 $lib_cflag.=" -D_WINDLL";
248 #
249 # Engage Applink...
250 #
251 $app_ex_obj.=" \$(OBJ_D)\\applink.obj /implib:\$(TMP_D)\\junk.lib";
252 $cflags.=" -DOPENSSL_USE_APPLINK -I.";
253 # I'm open for better suggestions than overriding $banner...
254 $banner=<<'___';
255 @echo Building OpenSSL
256
257$(OBJ_D)\applink.obj: ms\applink.c
258 $(CC) /Fo$(OBJ_D)\applink.obj $(APP_CFLAGS) -c ms\applink.c
259$(OBJ_D)\uplink.obj: ms\uplink.c ms\applink.c
260 $(CC) /Fo$(OBJ_D)\uplink.obj $(SHLIB_CFLAGS) -c ms\uplink.c
261$(INCO_D)\applink.c: ms\applink.c
262 $(CP) ms\applink.c $(INCO_D)\applink.c
263
264EXHEADER= $(EXHEADER) $(INCO_D)\applink.c
265
266LIBS_DEP=$(LIBS_DEP) $(OBJ_D)\applink.obj
267CRYPTOOBJ=$(OBJ_D)\uplink.obj $(CRYPTOOBJ)
268___
269 $banner.=<<'___' if ($FLAVOR =~ /WIN64/);
270CRYPTOOBJ=ms\uptable.obj $(CRYPTOOBJ)
271___
272 }
273elsif ($shlib && $FLAVOR =~ /CE/)
274 {
275 $mlflags.=" $lflags /dll";
276 $lflags.=' /entry:mainCRTstartup' if(defined($ENV{'PORTSDK_LIBPATH'}));
277 $lib_cflag.=" -D_WINDLL -D_DLL";
278 }
279
280sub do_lib_rule
281 {
282 my($objs,$target,$name,$shlib,$ign,$base_addr) = @_;
283 local($ret);
284
285 $taget =~ s/\//$o/g if $o ne '/';
286 my $base_arg;
287 if ($base_addr ne "")
288 {
289 $base_arg= " /base:$base_addr";
290 }
291 else
292 {
293 $base_arg = "";
294 }
295 if ($name ne "")
296 {
297 $name =~ tr/a-z/A-Z/;
298 $name = "/def:ms/${name}.def";
299 }
300
301# $target="\$(LIB_D)$o$target";
302# $ret.="$target: $objs\n";
303 if (!$shlib)
304 {
305# $ret.="\t\$(RM) \$(O_$Name)\n";
306 $ret.="$target: $objs\n";
307 $ret.="\t\$(MKLIB) $lfile$target @<<\n $objs\n<<\n";
308 }
309 else
310 {
311 local($ex)=($target =~ /O_CRYPTO/)?'':' $(L_CRYPTO)';
312 $ex.=" $zlib_lib" if $zlib_opt == 1 && $target =~ /O_CRYPTO/;
313
314 if ($fips && $target =~ /O_CRYPTO/)
315 {
316 $ret.="$target: $objs \$(PREMAIN_DSO_EXE)";
317 $ret.="\n\tSET FIPS_LINK=\$(LINK)\n";
318 $ret.="\tSET FIPS_CC=\$(CC)\n";
319 $ret.="\tSET FIPS_CC_ARGS=/Fo\$(OBJ_D)${o}fips_premain.obj \$(SHLIB_CFLAGS) -c\n";
320 $ret.="\tSET PREMAIN_DSO_EXE=\$(PREMAIN_DSO_EXE)\n";
321 $ret.="\tSET FIPS_SHA1_EXE=\$(FIPS_SHA1_EXE)\n";
322 $ret.="\tSET FIPS_TARGET=$target\n";
323 $ret.="\tSET FIPSLIB_D=\$(FIPSLIB_D)\n";
324 $ret.="\t\$(FIPSLINK) \$(MLFLAGS) $ff /map $base_arg $efile$target ";
325 $ret.="$name @<<\n \$(SHLIB_EX_OBJ) $objs \$(EX_LIBS) ";
326 $ret.="\$(OBJ_D)${o}fips_premain.obj $ex\n<<\n";
327 }
328 else
329 {
330 $ret.="$target: $objs";
331 $ret.="\n\t\$(LINK) \$(MLFLAGS) $efile$target $name @<<\n \$(SHLIB_EX_OBJ) $objs $ex \$(EX_LIBS)\n<<\n";
332 }
333 $ret.="\tIF EXIST \$@.manifest mt -nologo -manifest \$@.manifest -outputresource:\$@;2\n\n";
334 }
335 $ret.="\n";
336 return($ret);
337 }
338
339sub do_link_rule
340 {
341 my($target,$files,$dep_libs,$libs,$standalone)=@_;
342 local($ret,$_);
343 $file =~ s/\//$o/g if $o ne '/';
344 $n=&bname($targer);
345 $ret.="$target: $files $dep_libs\n";
346 if ($standalone == 1)
347 {
348 $ret.=" \$(LINK) \$(LFLAGS) $efile$target @<<\n\t";
349 $ret.= "\$(EX_LIBS) " if ($files =~ /O_FIPSCANISTER/ && !$fipscanisterbuild);
350 $ret.="$files $libs\n<<\n";
351 }
352 elsif ($standalone == 2)
353 {
354 $ret.="\tSET FIPS_LINK=\$(LINK)\n";
355 $ret.="\tSET FIPS_CC=\$(CC)\n";
356 $ret.="\tSET FIPS_CC_ARGS=/Fo\$(OBJ_D)${o}fips_premain.obj \$(SHLIB_CFLAGS) -c\n";
357 $ret.="\tSET PREMAIN_DSO_EXE=\n";
358 $ret.="\tSET FIPS_TARGET=$target\n";
359 $ret.="\tSET FIPS_SHA1_EXE=\$(FIPS_SHA1_EXE)\n";
360 $ret.="\tSET FIPSLIB_D=\$(FIPSLIB_D)\n";
361 $ret.="\t\$(FIPSLINK) \$(LFLAGS) $ff /map $efile$target @<<\n";
362 $ret.="\t\$(APP_EX_OBJ) $files \$(OBJ_D)${o}fips_premain.obj $libs\n<<\n";
363 }
364 else
365 {
366 $ret.="\t\$(LINK) \$(LFLAGS) $efile$target @<<\n";
367 $ret.="\t\$(APP_EX_OBJ) $files $libs\n<<\n";
368 }
369 $ret.="\tIF EXIST \$@.manifest mt -nologo -manifest \$@.manifest -outputresource:\$@;1\n\n";
370 return($ret);
371 }
372
373sub win32_import_asm
374 {
375 my ($mf_var, $asm_name, $oref, $sref) = @_;
376 my $asm_dir;
377 if ($asm_name eq "")
378 {
379 $asm_dir = "crypto\\";
380 }
381 else
382 {
383 $asm_dir = "crypto\\$asm_name\\asm\\";
384 }
385
386 $$oref = "";
387 $mf_var =~ s/\.o$/.obj/g;
388
389 foreach (split(/ /, $mf_var))
390 {
391 $$oref .= $asm_dir . $_ . " ";
392 }
393 $$oref =~ s/ $//;
394 $$sref = $$oref;
395 $$sref =~ s/\.obj/.asm/g;
396
397 }
398
399
4001;
diff --git a/src/lib/libcrypto/util/pl/linux.pl b/src/lib/libcrypto/util/pl/linux.pl
new file mode 100644
index 0000000000..d24f7b7291
--- /dev/null
+++ b/src/lib/libcrypto/util/pl/linux.pl
@@ -0,0 +1,104 @@
1#!/usr/local/bin/perl
2#
3# linux.pl - the standard unix makefile stuff.
4#
5
6$o='/';
7$cp='/bin/cp';
8$rm='/bin/rm -f';
9
10# C compiler stuff
11
12$cc='gcc';
13if ($debug)
14 { $cflags="-g2 -ggdb -DREF_CHECK -DCRYPTO_MDEBUG"; }
15elsif ($profile)
16 { $cflags="-pg -O3"; }
17else
18 { $cflags="-O3 -fomit-frame-pointer"; }
19
20if (!$no_asm)
21 {
22 $bn_asm_obj='$(OBJ_D)/bn86-elf.o';
23 $bn_asm_src='crypto/bn/asm/bn86unix.cpp';
24 $bnco_asm_obj='$(OBJ_D)/co86-elf.o';
25 $bnco_asm_src='crypto/bn/asm/co86unix.cpp';
26 $des_enc_obj='$(OBJ_D)/dx86-elf.o $(OBJ_D)/yx86-elf.o';
27 $des_enc_src='crypto/des/asm/dx86unix.cpp crypto/des/asm/yx86unix.cpp';
28 $bf_enc_obj='$(OBJ_D)/bx86-elf.o';
29 $bf_enc_src='crypto/bf/asm/bx86unix.cpp';
30 $cast_enc_obj='$(OBJ_D)/cx86-elf.o';
31 $cast_enc_src='crypto/cast/asm/cx86unix.cpp';
32 $rc4_enc_obj='$(OBJ_D)/rx86-elf.o';
33 $rc4_enc_src='crypto/rc4/asm/rx86unix.cpp';
34 $rc5_enc_obj='$(OBJ_D)/r586-elf.o';
35 $rc5_enc_src='crypto/rc5/asm/r586unix.cpp';
36 $md5_asm_obj='$(OBJ_D)/mx86-elf.o';
37 $md5_asm_src='crypto/md5/asm/mx86unix.cpp';
38 $rmd160_asm_obj='$(OBJ_D)/rm86-elf.o';
39 $rmd160_asm_src='crypto/ripemd/asm/rm86unix.cpp';
40 $sha1_asm_obj='$(OBJ_D)/sx86-elf.o';
41 $sha1_asm_src='crypto/sha/asm/sx86unix.cpp';
42 $cflags.=" -DBN_ASM -DMD5_ASM -DSHA1_ASM -DOPENSSL_BN_ASM_PART_WORDS";
43 }
44
45$cflags.=" -DTERMIO -DL_ENDIAN -m486 -Wall";
46
47if ($shlib)
48 {
49 $shl_cflag=" -DPIC -fpic";
50 $shlibp=".so.$ssl_version";
51 $so_shlibp=".so";
52 }
53
54sub do_shlib_rule
55 {
56 local($obj,$target,$name,$shlib,$so_name)=@_;
57 local($ret,$_,$Name);
58
59 $target =~ s/\//$o/g if $o ne '/';
60 ($Name=$name) =~ tr/a-z/A-Z/;
61
62 $ret.="$target: \$(${Name}OBJ)\n";
63 $ret.="\t\$(RM) target\n";
64 $ret.="\tgcc \${CFLAGS} -shared -Wl,-soname,$target -o $target \$(${Name}OBJ)\n";
65 ($t=$target) =~ s/(^.*)\/[^\/]*$/$1/;
66 if ($so_name ne "")
67 {
68 $ret.="\t\$(RM) \$(LIB_D)$o$so_name\n";
69 $ret.="\tln -s $target \$(LIB_D)$o$so_name\n\n";
70 }
71 }
72
73sub do_link_rule
74 {
75 local($target,$files,$dep_libs,$libs)=@_;
76 local($ret,$_);
77
78 $file =~ s/\//$o/g if $o ne '/';
79 $n=&bname($target);
80 $ret.="$target: $files $dep_libs\n";
81 $ret.="\t\$(LINK) ${efile}$target \$(LFLAGS) $files $libs\n\n";
82 return($ret);
83 }
84
85sub do_asm_rule
86 {
87 local($target,$src)=@_;
88 local($ret,@s,@t,$i);
89
90 $target =~ s/\//$o/g if $o ne "/";
91 $src =~ s/\//$o/g if $o ne "/";
92
93 @s=split(/\s+/,$src);
94 @t=split(/\s+/,$target);
95
96 for ($i=0; $i<=$#s; $i++)
97 {
98 $ret.="$t[$i]: $s[$i]\n";
99 $ret.="\tgcc -E -DELF \$(SRC_D)$o$s[$i]|\$(AS) $afile$t[$i]\n\n";
100 }
101 return($ret);
102 }
103
1041;
diff --git a/src/lib/libcrypto/util/pl/ultrix.pl b/src/lib/libcrypto/util/pl/ultrix.pl
new file mode 100644
index 0000000000..ea370c71f9
--- /dev/null
+++ b/src/lib/libcrypto/util/pl/ultrix.pl
@@ -0,0 +1,38 @@
1#!/usr/local/bin/perl
2#
3# linux.pl - the standard unix makefile stuff.
4#
5
6$o='/';
7$cp='/bin/cp';
8$rm='/bin/rm -f';
9
10# C compiler stuff
11
12$cc='cc';
13if ($debug)
14 { $cflags="-g -DREF_CHECK -DCRYPTO_MDEBUG"; }
15else
16 { $cflags="-O2"; }
17
18$cflags.=" -std1 -DL_ENDIAN";
19
20if (!$no_asm)
21 {
22 $bn_asm_obj='$(OBJ_D)/mips1.o';
23 $bn_asm_src='crypto/bn/asm/mips1.s';
24 }
25
26sub do_link_rule
27 {
28 local($target,$files,$dep_libs,$libs)=@_;
29 local($ret,$_);
30
31 $file =~ s/\//$o/g if $o ne '/';
32 $n=&bname($target);
33 $ret.="$target: $files $dep_libs\n";
34 $ret.="\t\$(LINK) ${efile}$target \$(LFLAGS) $files $libs\n\n";
35 return($ret);
36 }
37
381;
diff --git a/src/lib/libcrypto/util/pl/Mingw32f.pl b/src/lib/libcrypto/util/pl/unix.pl
index 44f5673d7a..146611ad99 100644
--- a/src/lib/libcrypto/util/pl/Mingw32f.pl
+++ b/src/lib/libcrypto/util/pl/unix.pl
@@ -1,20 +1,30 @@
1#!/usr/local/bin/perl 1#!/usr/local/bin/perl
2# 2#
3# Mingw32f.pl -- copy files; Mingw32.pl is needed to do the compiling. 3# unix.pl - the standard unix makefile stuff.
4# 4#
5 5
6$o='\\'; 6$o='/';
7$cp='copy'; 7$cp='/bin/cp';
8$rm='del'; 8$rm='/bin/rm -f';
9 9
10# C compiler stuff 10# C compiler stuff
11 11
12$cc='gcc'; 12if ($gcc)
13if ($debug) 13 {
14 { $cflags="-g2 -ggdb -DDSO_WIN32"; } 14 $cc='gcc';
15 if ($debug)
16 { $cflags="-g2 -ggdb"; }
17 else
18 { $cflags="-O3 -fomit-frame-pointer"; }
19 }
15else 20else
16 { $cflags="-O3 -fomit-frame-pointer -DDSO_WIN32"; } 21 {
17 22 $cc='cc';
23 if ($debug)
24 { $cflags="-g"; }
25 else
26 { $cflags="-O"; }
27 }
18$obj='.o'; 28$obj='.o';
19$ofile='-o '; 29$ofile='-o ';
20 30
@@ -23,12 +33,12 @@ $link='${CC}';
23$lflags='${CFLAGS}'; 33$lflags='${CFLAGS}';
24$efile='-o '; 34$efile='-o ';
25$exep=''; 35$exep='';
26$ex_libs="-lwsock32 -lgdi32"; 36$ex_libs="";
27 37
28# static library stuff 38# static library stuff
29$mklib='ar r'; 39$mklib='ar r';
30$mlflags=''; 40$mlflags='';
31$ranlib='ranlib'; 41$ranlib=&which("ranlib") or $ranlib="true";
32$plib='lib'; 42$plib='lib';
33$libp=".a"; 43$libp=".a";
34$shlibp=".a"; 44$shlibp=".a";
@@ -69,5 +79,18 @@ sub do_link_rule
69 $ret.="\t\$(LINK) ${efile}$target \$(LFLAGS) $files $libs\n\n"; 79 $ret.="\t\$(LINK) ${efile}$target \$(LFLAGS) $files $libs\n\n";
70 return($ret); 80 return($ret);
71 } 81 }
721;
73 82
83sub which
84 {
85 my ($name)=@_;
86 my $path;
87 foreach $path (split /:/, $ENV{PATH})
88 {
89 if (-x "$path/$name")
90 {
91 return "$path/$name";
92 }
93 }
94 }
95
961;
diff --git a/src/lib/libcrypto/util/pod2man.pl b/src/lib/libcrypto/util/pod2man.pl
new file mode 100644
index 0000000000..025d914f2e
--- /dev/null
+++ b/src/lib/libcrypto/util/pod2man.pl
@@ -0,0 +1,1184 @@
1: #!/usr/bin/perl-5.005
2 eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
3 if $running_under_some_shell;
4
5$DEF_PM_SECTION = '3pm' || '3';
6
7=head1 NAME
8
9pod2man - translate embedded Perl pod directives into man pages
10
11=head1 SYNOPSIS
12
13B<pod2man>
14[ B<--section=>I<manext> ]
15[ B<--release=>I<relpatch> ]
16[ B<--center=>I<string> ]
17[ B<--date=>I<string> ]
18[ B<--fixed=>I<font> ]
19[ B<--official> ]
20[ B<--lax> ]
21I<inputfile>
22
23=head1 DESCRIPTION
24
25B<pod2man> converts its input file containing embedded pod directives (see
26L<perlpod>) into nroff source suitable for viewing with nroff(1) or
27troff(1) using the man(7) macro set.
28
29Besides the obvious pod conversions, B<pod2man> also takes care of
30func(), func(n), and simple variable references like $foo or @bar so
31you don't have to use code escapes for them; complex expressions like
32C<$fred{'stuff'}> will still need to be escaped, though. Other nagging
33little roffish things that it catches include translating the minus in
34something like foo-bar, making a long dash--like this--into a real em
35dash, fixing up "paired quotes", putting a little space after the
36parens in something like func(), making C++ and PI look right, making
37double underbars have a little tiny space between them, making ALLCAPS
38a teeny bit smaller in troff(1), and escaping backslashes so you don't
39have to.
40
41=head1 OPTIONS
42
43=over 8
44
45=item center
46
47Set the centered header to a specific string. The default is
48"User Contributed Perl Documentation", unless the C<--official> flag is
49given, in which case the default is "Perl Programmers Reference Guide".
50
51=item date
52
53Set the left-hand footer string to this value. By default,
54the modification date of the input file will be used.
55
56=item fixed
57
58The fixed font to use for code refs. Defaults to CW.
59
60=item official
61
62Set the default header to indicate that this page is of
63the standard release in case C<--center> is not given.
64
65=item release
66
67Set the centered footer. By default, this is the current
68perl release.
69
70=item section
71
72Set the section for the C<.TH> macro. The standard conventions on
73sections are to use 1 for user commands, 2 for system calls, 3 for
74functions, 4 for devices, 5 for file formats, 6 for games, 7 for
75miscellaneous information, and 8 for administrator commands. This works
76best if you put your Perl man pages in a separate tree, like
77F</usr/local/perl/man/>. By default, section 1 will be used
78unless the file ends in F<.pm> in which case section 3 will be selected.
79
80=item lax
81
82Don't complain when required sections aren't present.
83
84=back
85
86=head1 Anatomy of a Proper Man Page
87
88For those not sure of the proper layout of a man page, here's
89an example of the skeleton of a proper man page. Head of the
90major headers should be setout as a C<=head1> directive, and
91are historically written in the rather startling ALL UPPER CASE
92format, although this is not mandatory.
93Minor headers may be included using C<=head2>, and are
94typically in mixed case.
95
96=over 10
97
98=item NAME
99
100Mandatory section; should be a comma-separated list of programs or
101functions documented by this podpage, such as:
102
103 foo, bar - programs to do something
104
105=item SYNOPSIS
106
107A short usage summary for programs and functions, which
108may someday be deemed mandatory.
109
110=item DESCRIPTION
111
112Long drawn out discussion of the program. It's a good idea to break this
113up into subsections using the C<=head2> directives, like
114
115 =head2 A Sample Subection
116
117 =head2 Yet Another Sample Subection
118
119=item OPTIONS
120
121Some people make this separate from the description.
122
123=item RETURN VALUE
124
125What the program or function returns if successful.
126
127=item ERRORS
128
129Exceptions, return codes, exit stati, and errno settings.
130
131=item EXAMPLES
132
133Give some example uses of the program.
134
135=item ENVIRONMENT
136
137Envariables this program might care about.
138
139=item FILES
140
141All files used by the program. You should probably use the FE<lt>E<gt>
142for these.
143
144=item SEE ALSO
145
146Other man pages to check out, like man(1), man(7), makewhatis(8), or catman(8).
147
148=item NOTES
149
150Miscellaneous commentary.
151
152=item CAVEATS
153
154Things to take special care with; sometimes called WARNINGS.
155
156=item DIAGNOSTICS
157
158All possible messages the program can print out--and
159what they mean.
160
161=item BUGS
162
163Things that are broken or just don't work quite right.
164
165=item RESTRICTIONS
166
167Bugs you don't plan to fix :-)
168
169=item AUTHOR
170
171Who wrote it (or AUTHORS if multiple).
172
173=item HISTORY
174
175Programs derived from other sources sometimes have this, or
176you might keep a modification log here.
177
178=back
179
180=head1 EXAMPLES
181
182 pod2man program > program.1
183 pod2man some_module.pm > /usr/perl/man/man3/some_module.3
184 pod2man --section=7 note.pod > note.7
185
186=head1 DIAGNOSTICS
187
188The following diagnostics are generated by B<pod2man>. Items
189marked "(W)" are non-fatal, whereas the "(F)" errors will cause
190B<pod2man> to immediately exit with a non-zero status.
191
192=over 4
193
194=item bad option in paragraph %d of %s: ``%s'' should be [%s]<%s>
195
196(W) If you start include an option, you should set it off
197as bold, italic, or code.
198
199=item can't open %s: %s
200
201(F) The input file wasn't available for the given reason.
202
203=item Improper man page - no dash in NAME header in paragraph %d of %s
204
205(W) The NAME header did not have an isolated dash in it. This is
206considered important.
207
208=item Invalid man page - no NAME line in %s
209
210(F) You did not include a NAME header, which is essential.
211
212=item roff font should be 1 or 2 chars, not `%s' (F)
213
214(F) The font specified with the C<--fixed> option was not
215a one- or two-digit roff font.
216
217=item %s is missing required section: %s
218
219(W) Required sections include NAME, DESCRIPTION, and if you're
220using a section starting with a 3, also a SYNOPSIS. Actually,
221not having a NAME is a fatal.
222
223=item Unknown escape: %s in %s
224
225(W) An unknown HTML entity (probably for an 8-bit character) was given via
226a C<EE<lt>E<gt>> directive. Besides amp, lt, gt, and quot, recognized
227entities are Aacute, aacute, Acirc, acirc, AElig, aelig, Agrave, agrave,
228Aring, aring, Atilde, atilde, Auml, auml, Ccedil, ccedil, Eacute, eacute,
229Ecirc, ecirc, Egrave, egrave, ETH, eth, Euml, euml, Iacute, iacute, Icirc,
230icirc, Igrave, igrave, Iuml, iuml, Ntilde, ntilde, Oacute, oacute, Ocirc,
231ocirc, Ograve, ograve, Oslash, oslash, Otilde, otilde, Ouml, ouml, szlig,
232THORN, thorn, Uacute, uacute, Ucirc, ucirc, Ugrave, ugrave, Uuml, uuml,
233Yacute, yacute, and yuml.
234
235=item Unmatched =back
236
237(W) You have a C<=back> without a corresponding C<=over>.
238
239=item Unrecognized pod directive: %s
240
241(W) You specified a pod directive that isn't in the known list of
242C<=head1>, C<=head2>, C<=item>, C<=over>, C<=back>, or C<=cut>.
243
244
245=back
246
247=head1 NOTES
248
249If you would like to print out a lot of man page continuously, you
250probably want to set the C and D registers to set contiguous page
251numbering and even/odd paging, at least on some versions of man(7).
252Settting the F register will get you some additional experimental
253indexing:
254
255 troff -man -rC1 -rD1 -rF1 perl.1 perldata.1 perlsyn.1 ...
256
257The indexing merely outputs messages via C<.tm> for each
258major page, section, subsection, item, and any C<XE<lt>E<gt>>
259directives.
260
261
262=head1 RESTRICTIONS
263
264None at this time.
265
266=head1 BUGS
267
268The =over and =back directives don't really work right. They
269take absolute positions instead of offsets, don't nest well, and
270making people count is suboptimal in any event.
271
272=head1 AUTHORS
273
274Original prototype by Larry Wall, but so massively hacked over by
275Tom Christiansen such that Larry probably doesn't recognize it anymore.
276
277=cut
278
279$/ = "";
280$cutting = 1;
281@Indices = ();
282
283# We try first to get the version number from a local binary, in case we're
284# running an installed version of Perl to produce documentation from an
285# uninstalled newer version's pod files.
286if ($^O ne 'plan9' and $^O ne 'dos' and $^O ne 'os2' and $^O ne 'MSWin32') {
287 my $perl = (-x './perl' && -f './perl' ) ?
288 './perl' :
289 ((-x '../perl' && -f '../perl') ?
290 '../perl' :
291 '');
292 ($version,$patch) = `$perl -e 'print $]'` =~ /^(\d\.\d{3})(\d{2})?/ if $perl;
293}
294# No luck; we'll just go with the running Perl's version
295($version,$patch) = $] =~ /^(.{5})(\d{2})?/ unless $version;
296$DEF_RELEASE = "perl $version";
297$DEF_RELEASE .= ", patch $patch" if $patch;
298
299
300sub makedate {
301 my $secs = shift;
302 my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($secs);
303 my $mname = (qw{Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec})[$mon];
304 $year += 1900;
305 return "$mday/$mname/$year";
306}
307
308use Getopt::Long;
309
310$DEF_SECTION = 1;
311$DEF_CENTER = "User Contributed Perl Documentation";
312$STD_CENTER = "Perl Programmers Reference Guide";
313$DEF_FIXED = 'CW';
314$DEF_LAX = 0;
315
316sub usage {
317 warn "$0: @_\n" if @_;
318 die <<EOF;
319usage: $0 [options] podpage
320Options are:
321 --section=manext (default "$DEF_SECTION")
322 --release=relpatch (default "$DEF_RELEASE")
323 --center=string (default "$DEF_CENTER")
324 --date=string (default "$DEF_DATE")
325 --fixed=font (default "$DEF_FIXED")
326 --official (default NOT)
327 --lax (default NOT)
328EOF
329}
330
331$uok = GetOptions( qw(
332 section=s
333 release=s
334 center=s
335 date=s
336 fixed=s
337 official
338 lax
339 help));
340
341$DEF_DATE = makedate((stat($ARGV[0]))[9] || time());
342
343usage("Usage error!") unless $uok;
344usage() if $opt_help;
345usage("Need one and only one podpage argument") unless @ARGV == 1;
346
347$section = $opt_section || ($ARGV[0] =~ /\.pm$/
348 ? $DEF_PM_SECTION : $DEF_SECTION);
349$RP = $opt_release || $DEF_RELEASE;
350$center = $opt_center || ($opt_official ? $STD_CENTER : $DEF_CENTER);
351$lax = $opt_lax || $DEF_LAX;
352
353$CFont = $opt_fixed || $DEF_FIXED;
354
355if (length($CFont) == 2) {
356 $CFont_embed = "\\f($CFont";
357}
358elsif (length($CFont) == 1) {
359 $CFont_embed = "\\f$CFont";
360}
361else {
362 die "roff font should be 1 or 2 chars, not `$CFont_embed'";
363}
364
365$date = $opt_date || $DEF_DATE;
366
367for (qw{NAME DESCRIPTION}) {
368# for (qw{NAME DESCRIPTION AUTHOR}) {
369 $wanna_see{$_}++;
370}
371$wanna_see{SYNOPSIS}++ if $section =~ /^3/;
372
373
374$name = @ARGV ? $ARGV[0] : "<STDIN>";
375$Filename = $name;
376if ($section =~ /^1/) {
377 require File::Basename;
378 $name = uc File::Basename::basename($name);
379}
380$name =~ s/\.(pod|p[lm])$//i;
381
382# Lose everything up to the first of
383# */lib/*perl* standard or site_perl module
384# */*perl*/lib from -D prefix=/opt/perl
385# */*perl*/ random module hierarchy
386# which works.
387$name =~ s-//+-/-g;
388if ($name =~ s-^.*?/lib/[^/]*perl[^/]*/--i
389 or $name =~ s-^.*?/[^/]*perl[^/]*/lib/--i
390 or $name =~ s-^.*?/[^/]*perl[^/]*/--i) {
391 # Lose ^site(_perl)?/.
392 $name =~ s-^site(_perl)?/--;
393 # Lose ^arch/. (XXX should we use Config? Just for archname?)
394 $name =~ s~^(.*-$^O|$^O-.*)/~~o;
395 # Lose ^version/.
396 $name =~ s-^\d+\.\d+/--;
397}
398
399# Translate Getopt/Long to Getopt::Long, etc.
400$name =~ s(/)(::)g;
401
402if ($name ne 'something') {
403 FCHECK: {
404 open(F, "< $ARGV[0]") || die "can't open $ARGV[0]: $!";
405 while (<F>) {
406 next unless /^=\b/;
407 if (/^=head1\s+NAME\s*$/) { # an /m would forgive mistakes
408 $_ = <F>;
409 unless (/\s*-+\s+/) {
410 $oops++;
411 warn "$0: Improper man page - no dash in NAME header in paragraph $. of $ARGV[0]\n"
412 } else {
413 my @n = split /\s+-+\s+/;
414 if (@n != 2) {
415 $oops++;
416 warn "$0: Improper man page - malformed NAME header in paragraph $. of $ARGV[0]\n"
417 }
418 else {
419 $n[0] =~ s/\n/ /g;
420 $n[1] =~ s/\n/ /g;
421 %namedesc = @n;
422 }
423 }
424 last FCHECK;
425 }
426 next if /^=cut\b/; # DB_File and Net::Ping have =cut before NAME
427 next if /^=pod\b/; # It is OK to have =pod before NAME
428 next if /^=(for|begin|end)\s+comment\b/; # It is OK to have =for =begin or =end comment before NAME
429 die "$0: Invalid man page - 1st pod line is not NAME in $ARGV[0]\n" unless $lax;
430 }
431 die "$0: Invalid man page - no documentation in $ARGV[0]\n" unless $lax;
432 }
433 close F;
434}
435
436print <<"END";
437.rn '' }`
438''' \$RCSfile\$\$Revision\$\$Date\$
439'''
440''' \$Log\$
441'''
442.de Sh
443.br
444.if t .Sp
445.ne 5
446.PP
447\\fB\\\\\$1\\fR
448.PP
449..
450.de Sp
451.if t .sp .5v
452.if n .sp
453..
454.de Ip
455.br
456.ie \\\\n(.\$>=3 .ne \\\\\$3
457.el .ne 3
458.IP "\\\\\$1" \\\\\$2
459..
460.de Vb
461.ft $CFont
462.nf
463.ne \\\\\$1
464..
465.de Ve
466.ft R
467
468.fi
469..
470'''
471'''
472''' Set up \\*(-- to give an unbreakable dash;
473''' string Tr holds user defined translation string.
474''' Bell System Logo is used as a dummy character.
475'''
476.tr \\(*W-|\\(bv\\*(Tr
477.ie n \\{\\
478.ds -- \\(*W-
479.ds PI pi
480.if (\\n(.H=4u)&(1m=24u) .ds -- \\(*W\\h'-12u'\\(*W\\h'-12u'-\\" diablo 10 pitch
481.if (\\n(.H=4u)&(1m=20u) .ds -- \\(*W\\h'-12u'\\(*W\\h'-8u'-\\" diablo 12 pitch
482.ds L" ""
483.ds R" ""
484''' \\*(M", \\*(S", \\*(N" and \\*(T" are the equivalent of
485''' \\*(L" and \\*(R", except that they are used on ".xx" lines,
486''' such as .IP and .SH, which do another additional levels of
487''' double-quote interpretation
488.ds M" """
489.ds S" """
490.ds N" """""
491.ds T" """""
492.ds L' '
493.ds R' '
494.ds M' '
495.ds S' '
496.ds N' '
497.ds T' '
498'br\\}
499.el\\{\\
500.ds -- \\(em\\|
501.tr \\*(Tr
502.ds L" ``
503.ds R" ''
504.ds M" ``
505.ds S" ''
506.ds N" ``
507.ds T" ''
508.ds L' `
509.ds R' '
510.ds M' `
511.ds S' '
512.ds N' `
513.ds T' '
514.ds PI \\(*p
515'br\\}
516END
517
518print <<'END';
519.\" If the F register is turned on, we'll generate
520.\" index entries out stderr for the following things:
521.\" TH Title
522.\" SH Header
523.\" Sh Subsection
524.\" Ip Item
525.\" X<> Xref (embedded
526.\" Of course, you have to process the output yourself
527.\" in some meaninful fashion.
528.if \nF \{
529.de IX
530.tm Index:\\$1\t\\n%\t"\\$2"
531..
532.nr % 0
533.rr F
534.\}
535END
536
537print <<"END";
538.TH $name $section "$RP" "$date" "$center"
539.UC
540END
541
542push(@Indices, qq{.IX Title "$name $section"});
543
544while (($name, $desc) = each %namedesc) {
545 for ($name, $desc) { s/^\s+//; s/\s+$//; }
546 push(@Indices, qq(.IX Name "$name - $desc"\n));
547}
548
549print <<'END';
550.if n .hy 0
551.if n .na
552.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
553.de CQ \" put $1 in typewriter font
554END
555print ".ft $CFont\n";
556print <<'END';
557'if n "\c
558'if t \\&\\$1\c
559'if n \\&\\$1\c
560'if n \&"
561\\&\\$2 \\$3 \\$4 \\$5 \\$6 \\$7
562'.ft R
563..
564.\" @(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2
565. \" AM - accent mark definitions
566.bd B 3
567. \" fudge factors for nroff and troff
568.if n \{\
569. ds #H 0
570. ds #V .8m
571. ds #F .3m
572. ds #[ \f1
573. ds #] \fP
574.\}
575.if t \{\
576. ds #H ((1u-(\\\\n(.fu%2u))*.13m)
577. ds #V .6m
578. ds #F 0
579. ds #[ \&
580. ds #] \&
581.\}
582. \" simple accents for nroff and troff
583.if n \{\
584. ds ' \&
585. ds ` \&
586. ds ^ \&
587. ds , \&
588. ds ~ ~
589. ds ? ?
590. ds ! !
591. ds /
592. ds q
593.\}
594.if t \{\
595. ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
596. ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
597. ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
598. ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
599. ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
600. ds ? \s-2c\h'-\w'c'u*7/10'\u\h'\*(#H'\zi\d\s+2\h'\w'c'u*8/10'
601. ds ! \s-2\(or\s+2\h'-\w'\(or'u'\v'-.8m'.\v'.8m'
602. ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
603. ds q o\h'-\w'o'u*8/10'\s-4\v'.4m'\z\(*i\v'-.4m'\s+4\h'\w'o'u*8/10'
604.\}
605. \" troff and (daisy-wheel) nroff accents
606.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
607.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
608.ds v \\k:\h'-(\\n(.wu*9/10-\*(#H)'\v'-\*(#V'\*(#[\s-4v\s0\v'\*(#V'\h'|\\n:u'\*(#]
609.ds _ \\k:\h'-(\\n(.wu*9/10-\*(#H+(\*(#F*2/3))'\v'-.4m'\z\(hy\v'.4m'\h'|\\n:u'
610.ds . \\k:\h'-(\\n(.wu*8/10)'\v'\*(#V*4/10'\z.\v'-\*(#V*4/10'\h'|\\n:u'
611.ds 3 \*(#[\v'.2m'\s-2\&3\s0\v'-.2m'\*(#]
612.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
613.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
614.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
615.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
616.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
617.ds ae a\h'-(\w'a'u*4/10)'e
618.ds Ae A\h'-(\w'A'u*4/10)'E
619.ds oe o\h'-(\w'o'u*4/10)'e
620.ds Oe O\h'-(\w'O'u*4/10)'E
621. \" corrections for vroff
622.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
623.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
624. \" for low resolution devices (crt and lpr)
625.if \n(.H>23 .if \n(.V>19 \
626\{\
627. ds : e
628. ds 8 ss
629. ds v \h'-1'\o'\(aa\(ga'
630. ds _ \h'-1'^
631. ds . \h'-1'.
632. ds 3 3
633. ds o a
634. ds d- d\h'-1'\(ga
635. ds D- D\h'-1'\(hy
636. ds th \o'bp'
637. ds Th \o'LP'
638. ds ae ae
639. ds Ae AE
640. ds oe oe
641. ds Oe OE
642.\}
643.rm #[ #] #H #V #F C
644END
645
646$indent = 0;
647
648$begun = "";
649
650# Unrolling [^A-Z>]|[A-Z](?!<) gives: // MRE pp 165.
651my $nonest = '(?:[^A-Z>]*(?:[A-Z](?!<)[^A-Z>]*)*)';
652
653while (<>) {
654 if ($cutting) {
655 next unless /^=/;
656 $cutting = 0;
657 }
658 if ($begun) {
659 if (/^=end\s+$begun/) {
660 $begun = "";
661 }
662 elsif ($begun =~ /^(roff|man)$/) {
663 print STDOUT $_;
664 }
665 next;
666 }
667 chomp;
668
669 # Translate verbatim paragraph
670
671 if (/^\s/) {
672 @lines = split(/\n/);
673 for (@lines) {
674 1 while s
675 {^( [^\t]* ) \t ( \t* ) }
676 { $1 . ' ' x (8 - (length($1)%8) + 8 * (length($2))) }ex;
677 s/\\/\\e/g;
678 s/\A/\\&/s;
679 }
680 $lines = @lines;
681 makespace() unless $verbatim++;
682 print ".Vb $lines\n";
683 print join("\n", @lines), "\n";
684 print ".Ve\n";
685 $needspace = 0;
686 next;
687 }
688
689 $verbatim = 0;
690
691 if (/^=for\s+(\S+)\s*/s) {
692 if ($1 eq "man" or $1 eq "roff") {
693 print STDOUT $',"\n\n";
694 } else {
695 # ignore unknown for
696 }
697 next;
698 }
699 elsif (/^=begin\s+(\S+)\s*/s) {
700 $begun = $1;
701 if ($1 eq "man" or $1 eq "roff") {
702 print STDOUT $'."\n\n";
703 }
704 next;
705 }
706
707 # check for things that'll hosed our noremap scheme; affects $_
708 init_noremap();
709
710 if (!/^=item/) {
711
712 # trofficate backslashes; must do it before what happens below
713 s/\\/noremap('\\e')/ge;
714
715 # protect leading periods and quotes against *roff
716 # mistaking them for directives
717 s/^(?:[A-Z]<)?[.']/\\&$&/gm;
718
719 # first hide the escapes in case we need to
720 # intuit something and get it wrong due to fmting
721
722 1 while s/([A-Z]<$nonest>)/noremap($1)/ge;
723
724 # func() is a reference to a perl function
725 s{
726 \b
727 (
728 [:\w]+ \(\)
729 )
730 } {I<$1>}gx;
731
732 # func(n) is a reference to a perl function or a man page
733 s{
734 ([:\w]+)
735 (
736 \( [^\051]+ \)
737 )
738 } {I<$1>\\|$2}gx;
739
740 # convert simple variable references
741 s/(\s+)([\$\@%][\w:]+)(?!\()/${1}C<$2>/g;
742
743 if (m{ (
744 [\-\w]+
745 \(
746 [^\051]*?
747 [\@\$,]
748 [^\051]*?
749 \)
750 )
751 }x && $` !~ /([LCI]<[^<>]*|-)$/ && !/^=\w/)
752 {
753 warn "$0: bad option in paragraph $. of $ARGV: ``$1'' should be [LCI]<$1>\n";
754 $oops++;
755 }
756
757 while (/(-[a-zA-Z])\b/g && $` !~ /[\w\-]$/) {
758 warn "$0: bad option in paragraph $. of $ARGV: ``$1'' should be [CB]<$1>\n";
759 $oops++;
760 }
761
762 # put it back so we get the <> processed again;
763 clear_noremap(0); # 0 means leave the E's
764
765 } else {
766 # trofficate backslashes
767 s/\\/noremap('\\e')/ge;
768
769 }
770
771 # need to hide E<> first; they're processed in clear_noremap
772 s/(E<[^<>]+>)/noremap($1)/ge;
773
774
775 $maxnest = 10;
776 while ($maxnest-- && /[A-Z]</) {
777
778 # can't do C font here
779 s/([BI])<($nonest)>/font($1) . $2 . font('R')/eg;
780
781 # files and filelike refs in italics
782 s/F<($nonest)>/I<$1>/g;
783
784 # no break -- usually we want C<> for this
785 s/S<($nonest)>/nobreak($1)/eg;
786
787 # LREF: a la HREF L<show this text|man/section>
788 s:L<([^|>]+)\|[^>]+>:$1:g;
789
790 # LREF: a manpage(3f)
791 s:L<([a-zA-Z][^\s\/]+)(\([^\)]+\))?>:the I<$1>$2 manpage:g;
792
793 # LREF: an =item on another manpage
794 s{
795 L<
796 ([^/]+)
797 /
798 (
799 [:\w]+
800 (\(\))?
801 )
802 >
803 } {the C<$2> entry in the I<$1> manpage}gx;
804
805 # LREF: an =item on this manpage
806 s{
807 ((?:
808 L<
809 /
810 (
811 [:\w]+
812 (\(\))?
813 )
814 >
815 (,?\s+(and\s+)?)?
816 )+)
817 } { internal_lrefs($1) }gex;
818
819 # LREF: a =head2 (head1?), maybe on a manpage, maybe right here
820 # the "func" can disambiguate
821 s{
822 L<
823 (?:
824 ([a-zA-Z]\S+?) /
825 )?
826 "?(.*?)"?
827 >
828 }{
829 do {
830 $1 # if no $1, assume it means on this page.
831 ? "the section on I<$2> in the I<$1> manpage"
832 : "the section on I<$2>"
833 }
834 }gesx; # s in case it goes over multiple lines, so . matches \n
835
836 s/Z<>/\\&/g;
837
838 # comes last because not subject to reprocessing
839 s/C<($nonest)>/noremap("${CFont_embed}${1}\\fR")/eg;
840 }
841
842 if (s/^=//) {
843 $needspace = 0; # Assume this.
844
845 s/\n/ /g;
846
847 ($Cmd, $_) = split(' ', $_, 2);
848
849 $dotlevel = 1;
850 if ($Cmd eq 'head1') {
851 $dotlevel = 1;
852 }
853 elsif ($Cmd eq 'head2') {
854 $dotlevel = 1;
855 }
856 elsif ($Cmd eq 'item') {
857 $dotlevel = 2;
858 }
859
860 if (defined $_) {
861 &escapes($dotlevel);
862 s/"/""/g;
863 }
864
865 clear_noremap(1);
866
867 if ($Cmd eq 'cut') {
868 $cutting = 1;
869 }
870 elsif ($Cmd eq 'head1') {
871 s/\s+$//;
872 delete $wanna_see{$_} if exists $wanna_see{$_};
873 print qq{.SH "$_"\n};
874 push(@Indices, qq{.IX Header "$_"\n});
875 }
876 elsif ($Cmd eq 'head2') {
877 print qq{.Sh "$_"\n};
878 push(@Indices, qq{.IX Subsection "$_"\n});
879 }
880 elsif ($Cmd eq 'over') {
881 push(@indent,$indent);
882 $indent += ($_ + 0) || 5;
883 }
884 elsif ($Cmd eq 'back') {
885 $indent = pop(@indent);
886 warn "$0: Unmatched =back in paragraph $. of $ARGV\n" unless defined $indent;
887 $needspace = 1;
888 }
889 elsif ($Cmd eq 'item') {
890 s/^\*( |$)/\\(bu$1/g;
891 # if you know how to get ":s please do
892 s/\\\*\(L"([^"]+?)\\\*\(R"/'$1'/g;
893 s/\\\*\(L"([^"]+?)""/'$1'/g;
894 s/[^"]""([^"]+?)""[^"]/'$1'/g;
895 # here do something about the $" in perlvar?
896 print STDOUT qq{.Ip "$_" $indent\n};
897 push(@Indices, qq{.IX Item "$_"\n});
898 }
899 elsif ($Cmd eq 'pod') {
900 # this is just a comment
901 }
902 else {
903 warn "$0: Unrecognized pod directive in paragraph $. of $ARGV: $Cmd\n";
904 }
905 }
906 else {
907 if ($needspace) {
908 &makespace;
909 }
910 &escapes(0);
911 clear_noremap(1);
912 print $_, "\n";
913 $needspace = 1;
914 }
915}
916
917print <<"END";
918
919.rn }` ''
920END
921
922if (%wanna_see && !$lax) {
923 @missing = keys %wanna_see;
924 warn "$0: $Filename is missing required section"
925 . (@missing > 1 && "s")
926 . ": @missing\n";
927 $oops++;
928}
929
930foreach (@Indices) { print "$_\n"; }
931
932exit;
933#exit ($oops != 0);
934
935#########################################################################
936
937sub nobreak {
938 my $string = shift;
939 $string =~ s/ /\\ /g;
940 $string;
941}
942
943sub escapes {
944 my $indot = shift;
945
946 s/X<(.*?)>/mkindex($1)/ge;
947
948 # translate the minus in foo-bar into foo\-bar for roff
949 s/([^0-9a-z-])-([^-])/$1\\-$2/g;
950
951 # make -- into the string version \*(-- (defined above)
952 s/\b--\b/\\*(--/g;
953 s/"--([^"])/"\\*(--$1/g; # should be a better way
954 s/([^"])--"/$1\\*(--"/g;
955
956 # fix up quotes; this is somewhat tricky
957 my $dotmacroL = 'L';
958 my $dotmacroR = 'R';
959 if ( $indot == 1 ) {
960 $dotmacroL = 'M';
961 $dotmacroR = 'S';
962 }
963 elsif ( $indot >= 2 ) {
964 $dotmacroL = 'N';
965 $dotmacroR = 'T';
966 }
967 if (!/""/) {
968 s/(^|\s)(['"])/noremap("$1\\*($dotmacroL$2")/ge;
969 s/(['"])($|[\-\s,;\\!?.])/noremap("\\*($dotmacroR$1$2")/ge;
970 }
971
972 #s/(?!")(?:.)--(?!")(?:.)/\\*(--/g;
973 #s/(?:(?!")(?:.)--(?:"))|(?:(?:")--(?!")(?:.))/\\*(--/g;
974
975
976 # make sure that func() keeps a bit a space tween the parens
977 ### s/\b\(\)/\\|()/g;
978 ### s/\b\(\)/(\\|)/g;
979
980 # make C++ into \*C+, which is a squinched version (defined above)
981 s/\bC\+\+/\\*(C+/g;
982
983 # make double underbars have a little tiny space between them
984 s/__/_\\|_/g;
985
986 # PI goes to \*(PI (defined above)
987 s/\bPI\b/noremap('\\*(PI')/ge;
988
989 # make all caps a teeny bit smaller, but don't muck with embedded code literals
990 my $hidCFont = font('C');
991 if ($Cmd !~ /^head1/) { # SH already makes smaller
992 # /g isn't enough; 1 while or we'll be off
993
994# 1 while s{
995# (?!$hidCFont)(..|^.|^)
996# \b
997# (
998# [A-Z][\/A-Z+:\-\d_$.]+
999# )
1000# (s?)
1001# \b
1002# } {$1\\s-1$2\\s0}gmox;
1003
1004 1 while s{
1005 (?!$hidCFont)(..|^.|^)
1006 (
1007 \b[A-Z]{2,}[\/A-Z+:\-\d_\$]*\b
1008 )
1009 } {
1010 $1 . noremap( '\\s-1' . $2 . '\\s0' )
1011 }egmox;
1012
1013 }
1014}
1015
1016# make troff just be normal, but make small nroff get quoted
1017# decided to just put the quotes in the text; sigh;
1018sub ccvt {
1019 local($_,$prev) = @_;
1020 noremap(qq{.CQ "$_" \n\\&});
1021}
1022
1023sub makespace {
1024 if ($indent) {
1025 print ".Sp\n";
1026 }
1027 else {
1028 print ".PP\n";
1029 }
1030}
1031
1032sub mkindex {
1033 my ($entry) = @_;
1034 my @entries = split m:\s*/\s*:, $entry;
1035 push @Indices, ".IX Xref " . join ' ', map {qq("$_")} @entries;
1036 return '';
1037}
1038
1039sub font {
1040 local($font) = shift;
1041 return '\\f' . noremap($font);
1042}
1043
1044sub noremap {
1045 local($thing_to_hide) = shift;
1046 $thing_to_hide =~ tr/\000-\177/\200-\377/;
1047 return $thing_to_hide;
1048}
1049
1050sub init_noremap {
1051 # escape high bit characters in input stream
1052 s/([\200-\377])/"E<".ord($1).">"/ge;
1053}
1054
1055sub clear_noremap {
1056 my $ready_to_print = $_[0];
1057
1058 tr/\200-\377/\000-\177/;
1059
1060 # trofficate backslashes
1061 # s/(?!\\e)(?:..|^.|^)\\/\\e/g;
1062
1063 # now for the E<>s, which have been hidden until now
1064 # otherwise the interative \w<> processing would have
1065 # been hosed by the E<gt>
1066 s {
1067 E<
1068 (
1069 ( \d + )
1070 | ( [A-Za-z]+ )
1071 )
1072 >
1073 } {
1074 do {
1075 defined $2
1076 ? chr($2)
1077 :
1078 exists $HTML_Escapes{$3}
1079 ? do { $HTML_Escapes{$3} }
1080 : do {
1081 warn "$0: Unknown escape in paragraph $. of $ARGV: ``$&''\n";
1082 "E<$1>";
1083 }
1084 }
1085 }egx if $ready_to_print;
1086}
1087
1088sub internal_lrefs {
1089 local($_) = shift;
1090 local $trailing_and = s/and\s+$// ? "and " : "";
1091
1092 s{L</([^>]+)>}{$1}g;
1093 my(@items) = split( /(?:,?\s+(?:and\s+)?)/ );
1094 my $retstr = "the ";
1095 my $i;
1096 for ($i = 0; $i <= $#items; $i++) {
1097 $retstr .= "C<$items[$i]>";
1098 $retstr .= ", " if @items > 2 && $i != $#items;
1099 $retstr .= " and " if $i+2 == @items;
1100 }
1101
1102 $retstr .= " entr" . ( @items > 1 ? "ies" : "y" )
1103 . " elsewhere in this document";
1104 # terminal space to avoid words running together (pattern used
1105 # strips terminal spaces)
1106 $retstr .= " " if length $trailing_and;
1107 $retstr .= $trailing_and;
1108
1109 return $retstr;
1110
1111}
1112
1113BEGIN {
1114%HTML_Escapes = (
1115 'amp' => '&', # ampersand
1116 'lt' => '<', # left chevron, less-than
1117 'gt' => '>', # right chevron, greater-than
1118 'quot' => '"', # double quote
1119
1120 "Aacute" => "A\\*'", # capital A, acute accent
1121 "aacute" => "a\\*'", # small a, acute accent
1122 "Acirc" => "A\\*^", # capital A, circumflex accent
1123 "acirc" => "a\\*^", # small a, circumflex accent
1124 "AElig" => '\*(AE', # capital AE diphthong (ligature)
1125 "aelig" => '\*(ae', # small ae diphthong (ligature)
1126 "Agrave" => "A\\*`", # capital A, grave accent
1127 "agrave" => "A\\*`", # small a, grave accent
1128 "Aring" => 'A\\*o', # capital A, ring
1129 "aring" => 'a\\*o', # small a, ring
1130 "Atilde" => 'A\\*~', # capital A, tilde
1131 "atilde" => 'a\\*~', # small a, tilde
1132 "Auml" => 'A\\*:', # capital A, dieresis or umlaut mark
1133 "auml" => 'a\\*:', # small a, dieresis or umlaut mark
1134 "Ccedil" => 'C\\*,', # capital C, cedilla
1135 "ccedil" => 'c\\*,', # small c, cedilla
1136 "Eacute" => "E\\*'", # capital E, acute accent
1137 "eacute" => "e\\*'", # small e, acute accent
1138 "Ecirc" => "E\\*^", # capital E, circumflex accent
1139 "ecirc" => "e\\*^", # small e, circumflex accent
1140 "Egrave" => "E\\*`", # capital E, grave accent
1141 "egrave" => "e\\*`", # small e, grave accent
1142 "ETH" => '\\*(D-', # capital Eth, Icelandic
1143 "eth" => '\\*(d-', # small eth, Icelandic
1144 "Euml" => "E\\*:", # capital E, dieresis or umlaut mark
1145 "euml" => "e\\*:", # small e, dieresis or umlaut mark
1146 "Iacute" => "I\\*'", # capital I, acute accent
1147 "iacute" => "i\\*'", # small i, acute accent
1148 "Icirc" => "I\\*^", # capital I, circumflex accent
1149 "icirc" => "i\\*^", # small i, circumflex accent
1150 "Igrave" => "I\\*`", # capital I, grave accent
1151 "igrave" => "i\\*`", # small i, grave accent
1152 "Iuml" => "I\\*:", # capital I, dieresis or umlaut mark
1153 "iuml" => "i\\*:", # small i, dieresis or umlaut mark
1154 "Ntilde" => 'N\*~', # capital N, tilde
1155 "ntilde" => 'n\*~', # small n, tilde
1156 "Oacute" => "O\\*'", # capital O, acute accent
1157 "oacute" => "o\\*'", # small o, acute accent
1158 "Ocirc" => "O\\*^", # capital O, circumflex accent
1159 "ocirc" => "o\\*^", # small o, circumflex accent
1160 "Ograve" => "O\\*`", # capital O, grave accent
1161 "ograve" => "o\\*`", # small o, grave accent
1162 "Oslash" => "O\\*/", # capital O, slash
1163 "oslash" => "o\\*/", # small o, slash
1164 "Otilde" => "O\\*~", # capital O, tilde
1165 "otilde" => "o\\*~", # small o, tilde
1166 "Ouml" => "O\\*:", # capital O, dieresis or umlaut mark
1167 "ouml" => "o\\*:", # small o, dieresis or umlaut mark
1168 "szlig" => '\*8', # small sharp s, German (sz ligature)
1169 "THORN" => '\\*(Th', # capital THORN, Icelandic
1170 "thorn" => '\\*(th',, # small thorn, Icelandic
1171 "Uacute" => "U\\*'", # capital U, acute accent
1172 "uacute" => "u\\*'", # small u, acute accent
1173 "Ucirc" => "U\\*^", # capital U, circumflex accent
1174 "ucirc" => "u\\*^", # small u, circumflex accent
1175 "Ugrave" => "U\\*`", # capital U, grave accent
1176 "ugrave" => "u\\*`", # small u, grave accent
1177 "Uuml" => "U\\*:", # capital U, dieresis or umlaut mark
1178 "uuml" => "u\\*:", # small u, dieresis or umlaut mark
1179 "Yacute" => "Y\\*'", # capital Y, acute accent
1180 "yacute" => "y\\*'", # small y, acute accent
1181 "yuml" => "y\\*:", # small y, dieresis or umlaut mark
1182);
1183}
1184
diff --git a/src/lib/libcrypto/util/pod2mantest b/src/lib/libcrypto/util/pod2mantest
new file mode 100644
index 0000000000..384e683df4
--- /dev/null
+++ b/src/lib/libcrypto/util/pod2mantest
@@ -0,0 +1,58 @@
1#!/bin/sh
2
3# This script is used by test/Makefile to check whether a sane 'pod2man'
4# is installed.
5# ('make install' should not try to run 'pod2man' if it does not exist or if
6# it is a broken 'pod2man' version that is known to cause trouble. if we find
7# the system 'pod2man' to be broken, we use our own copy instead)
8#
9# In any case, output an appropriate command line for running (or not
10# running) pod2man.
11
12
13IFS=:
14if test "$OSTYPE" = "msdosdjgpp"; then IFS=";"; fi
15
16try_without_dir=true
17# First we try "pod2man", then "$dir/pod2man" for each item in $PATH.
18for dir in dummy${IFS}$PATH; do
19 if [ "$try_without_dir" = true ]; then
20 # first iteration
21 pod2man=pod2man
22 try_without_dir=false
23 else
24 # second and later iterations
25 pod2man="$dir/pod2man"
26 if [ ! -f "$pod2man" ]; then # '-x' is not available on Ultrix
27 pod2man=''
28 fi
29 fi
30
31 if [ ! "$pod2man" = '' ]; then
32 failure=none
33
34 if "$pod2man" --section=1 --center=OpenSSL --release=dev pod2mantest.pod | fgrep OpenSSL >/dev/null; then
35 :
36 else
37 failure=BasicTest
38 fi
39
40 if [ "$failure" = none ]; then
41 if "$pod2man" --section=1 --center=OpenSSL --release=dev pod2mantest.pod | grep '^MARKER - ' >/dev/null; then
42 failure=MultilineTest
43 fi
44 fi
45
46
47 if [ "$failure" = none ]; then
48 echo "$pod2man"
49 exit 0
50 fi
51
52 echo "$pod2man does not work properly ('$failure' failed). Looking for another pod2man ..." >&2
53 fi
54done
55
56echo "No working pod2man found. Consider installing a new version." >&2
57echo "As a workaround, we'll use a bundled old copy of pod2man.pl." >&2
58echo "$1 ../../util/pod2man.pl"
diff --git a/src/lib/libcrypto/util/pod2mantest.pod b/src/lib/libcrypto/util/pod2mantest.pod
new file mode 100644
index 0000000000..5d2539a17f
--- /dev/null
+++ b/src/lib/libcrypto/util/pod2mantest.pod
@@ -0,0 +1,15 @@
1=pod
2
3=head1 NAME
4
5foo, bar,
6MARKER - test of multiline name section
7
8=head1 DESCRIPTION
9
10This is a test .pod file to see if we have a buggy pod2man or not.
11If we have a buggy implementation, we will get a line matching the
12regular expression "^ +MARKER - test of multiline name section *$"
13at the end of the resulting document.
14
15=cut
diff --git a/src/lib/libcrypto/util/point.sh b/src/lib/libcrypto/util/point.sh
new file mode 100644
index 0000000000..da39899cb1
--- /dev/null
+++ b/src/lib/libcrypto/util/point.sh
@@ -0,0 +1,10 @@
1#!/bin/sh
2
3rm -f "$2"
4if test "$OSTYPE" = msdosdjgpp || test "x$PLATFORM" = xmingw ; then
5 cp "$1" "$2"
6else
7 ln -s "$1" "$2"
8fi
9echo "$2 => $1"
10
diff --git a/src/lib/libcrypto/util/selftest.pl b/src/lib/libcrypto/util/selftest.pl
new file mode 100644
index 0000000000..7b32e9f4ff
--- /dev/null
+++ b/src/lib/libcrypto/util/selftest.pl
@@ -0,0 +1,201 @@
1#!/usr/local/bin/perl -w
2#
3# Run the test suite and generate a report
4#
5
6if (! -f "Configure") {
7 print "Please run perl util/selftest.pl in the OpenSSL directory.\n";
8 exit 1;
9}
10
11my $report="testlog";
12my $os="??";
13my $version="??";
14my $platform0="??";
15my $platform="??";
16my $options="??";
17my $last="??";
18my $ok=0;
19my $cc="cc";
20my $cversion="??";
21my $sep="-----------------------------------------------------------------------------\n";
22my $not_our_fault="\nPlease ask your system administrator/vendor for more information.\n[Problems with your operating system setup should not be reported\nto the OpenSSL project.]\n";
23
24open(OUT,">$report") or die;
25
26print OUT "OpenSSL self-test report:\n\n";
27
28$uname=`uname -a`;
29$uname="??\n" if $uname eq "";
30
31$c=`sh config -t`;
32foreach $_ (split("\n",$c)) {
33 $os=$1 if (/Operating system: (.*)$/);
34 $platform0=$1 if (/Configuring for (.*)$/);
35}
36
37system "sh config" if (! -f "Makefile");
38
39if (open(IN,"<Makefile")) {
40 while (<IN>) {
41 $version=$1 if (/^VERSION=(.*)$/);
42 $platform=$1 if (/^PLATFORM=(.*)$/);
43 $options=$1 if (/^OPTIONS=(.*)$/);
44 $cc=$1 if (/^CC= *(.*)$/);
45 }
46 close(IN);
47} else {
48 print OUT "Error running config!\n";
49}
50
51$cversion=`$cc -v 2>&1`;
52$cversion=`$cc -V 2>&1` if $cversion =~ "[Uu]sage";
53$cversion=`$cc -V |head -1` if $cversion =~ "Error";
54$cversion=`$cc --version` if $cversion eq "";
55$cversion =~ s/Reading specs.*\n//;
56$cversion =~ s/usage.*\n//;
57chomp $cversion;
58
59if (open(IN,"<CHANGES")) {
60 while(<IN>) {
61 if (/\*\) (.{0,55})/ && !/applies to/) {
62 $last=$1;
63 last;
64 }
65 }
66 close(IN);
67}
68
69print OUT "OpenSSL version: $version\n";
70print OUT "Last change: $last...\n";
71print OUT "Options: $options\n" if $options ne "";
72print OUT "OS (uname): $uname";
73print OUT "OS (config): $os\n";
74print OUT "Target (default): $platform0\n";
75print OUT "Target: $platform\n";
76print OUT "Compiler: $cversion\n";
77print OUT "\n";
78
79print "Checking compiler...\n";
80if (open(TEST,">cctest.c")) {
81 print TEST "#include <stdio.h>\n#include <stdlib.h>\n#include <errno.h>\nmain(){printf(\"Hello world\\n\");}\n";
82 close(TEST);
83 system("$cc -o cctest cctest.c");
84 if (`./cctest` !~ /Hello world/) {
85 print OUT "Compiler doesn't work.\n";
86 print OUT $not_our_fault;
87 goto err;
88 }
89 system("ar r cctest.a /dev/null");
90 if (not -f "cctest.a") {
91 print OUT "Check your archive tool (ar).\n";
92 print OUT $not_our_fault;
93 goto err;
94 }
95} else {
96 print OUT "Can't create cctest.c\n";
97}
98if (open(TEST,">cctest.c")) {
99 print TEST "#include <stdio.h>\n#include <stdlib.h>\n#include <openssl/opensslv.h>\nmain(){printf(OPENSSL_VERSION_TEXT);}\n";
100 close(TEST);
101 system("$cc -o cctest -Iinclude cctest.c");
102 $cctest = `./cctest`;
103 if ($cctest !~ /OpenSSL $version/) {
104 if ($cctest =~ /OpenSSL/) {
105 print OUT "#include uses headers from different OpenSSL version!\n";
106 } else {
107 print OUT "Can't compile test program!\n";
108 }
109 print OUT $not_our_fault;
110 goto err;
111 }
112} else {
113 print OUT "Can't create cctest.c\n";
114}
115
116print "Running make...\n";
117if (system("make 2>&1 | tee make.log") > 255) {
118
119 print OUT "make failed!\n";
120 if (open(IN,"<make.log")) {
121 print OUT $sep;
122 while (<IN>) {
123 print OUT;
124 }
125 close(IN);
126 print OUT $sep;
127 } else {
128 print OUT "make.log not found!\n";
129 }
130 goto err;
131}
132
133# Not sure why this is here. The tests themselves can detect if their
134# particular feature isn't included, and should therefore skip themselves.
135# To skip *all* tests just because one algorithm isn't included is like
136# shooting mosquito with an elephant gun...
137# -- Richard Levitte, inspired by problem report 1089
138#
139#$_=$options;
140#s/no-asm//;
141#s/no-shared//;
142#s/no-krb5//;
143#if (/no-/)
144#{
145# print OUT "Test skipped.\n";
146# goto err;
147#}
148
149print "Running make test...\n";
150if (system("make test 2>&1 | tee maketest.log") > 255)
151 {
152 print OUT "make test failed!\n";
153} else {
154 $ok=1;
155}
156
157if ($ok and open(IN,"<maketest.log")) {
158 while (<IN>) {
159 $ok=2 if /^platform: $platform/;
160 }
161 close(IN);
162}
163
164if ($ok != 2) {
165 print OUT "Failure!\n";
166 if (open(IN,"<make.log")) {
167 print OUT $sep;
168 while (<IN>) {
169 print OUT;
170 }
171 close(IN);
172 print OUT $sep;
173 } else {
174 print OUT "make.log not found!\n";
175 }
176 if (open(IN,"<maketest.log")) {
177 while (<IN>) {
178 print OUT;
179 }
180 close(IN);
181 print OUT $sep;
182 } else {
183 print OUT "maketest.log not found!\n";
184 }
185} else {
186 print OUT "Test passed.\n";
187}
188err:
189close(OUT);
190
191print "\n";
192open(IN,"<$report") or die;
193while (<IN>) {
194 if (/$sep/) {
195 print "[...]\n";
196 last;
197 }
198 print;
199}
200print "\nTest report in file $report\n";
201
diff --git a/src/lib/libcrypto/util/shlib_wrap.sh b/src/lib/libcrypto/util/shlib_wrap.sh
new file mode 100755
index 0000000000..8775cb5411
--- /dev/null
+++ b/src/lib/libcrypto/util/shlib_wrap.sh
@@ -0,0 +1,97 @@
1#!/bin/sh
2
3[ $# -ne 0 ] || set -x # debug mode without arguments:-)
4
5THERE="`echo $0 | sed -e 's|[^/]*$||' 2>/dev/null`.."
6[ -d "${THERE}" ] || exec "$@" # should never happen...
7
8# Alternative to this is to parse ${THERE}/Makefile...
9LIBCRYPTOSO="${THERE}/libcrypto.so"
10if [ -f "$LIBCRYPTOSO" ]; then
11 while [ -h "$LIBCRYPTOSO" ]; do
12 LIBCRYPTOSO="${THERE}/`ls -l "$LIBCRYPTOSO" | sed -e 's|.*\-> ||'`"
13 done
14 SOSUFFIX=`echo ${LIBCRYPTOSO} | sed -e 's|.*\.so||' 2>/dev/null`
15 LIBSSLSO="${THERE}/libssl.so${SOSUFFIX}"
16fi
17
18SYSNAME=`(uname -s) 2>/dev/null`;
19case "$SYSNAME" in
20SunOS|IRIX*)
21 # SunOS and IRIX run-time linkers evaluate alternative
22 # variables depending on target ABI...
23 rld_var=LD_LIBRARY_PATH
24 case "`(/usr/bin/file "$LIBCRYPTOSO") 2>/dev/null`" in
25 *ELF\ 64*SPARC*|*ELF\ 64*AMD64*)
26 [ -n "$LD_LIBRARY_PATH_64" ] && rld_var=LD_LIBRARY_PATH_64
27 LD_PRELOAD_64="$LIBCRYPTOSO $LIBSSLSO"; export LD_PRELOAD_64
28 preload_var=LD_PRELOAD_64
29 ;;
30 # Why are newly built .so's preloaded anyway? Because run-time
31 # .so lookup path embedded into application takes precedence
32 # over LD_LIBRARY_PATH and as result application ends up linking
33 # to previously installed .so's. On IRIX instead of preloading
34 # newly built .so's we trick run-time linker to fail to find
35 # the installed .so by setting _RLD_ROOT variable.
36 *ELF\ 32*MIPS*)
37 #_RLD_LIST="$LIBCRYPTOSO:$LIBSSLSO:DEFAULT"; export _RLD_LIST
38 _RLD_ROOT=/no/such/dir; export _RLD_ROOT
39 eval $rld_var=\"/usr/lib'${'$rld_var':+:$'$rld_var'}'\"
40 preload_var=_RLD_LIST
41 ;;
42 *ELF\ N32*MIPS*)
43 [ -n "$LD_LIBRARYN32_PATH" ] && rld_var=LD_LIBRARYN32_PATH
44 #_RLDN32_LIST="$LIBCRYPTOSO:$LIBSSLSO:DEFAULT"; export _RLDN32_LIST
45 _RLDN32_ROOT=/no/such/dir; export _RLDN32_ROOT
46 eval $rld_var=\"/usr/lib32'${'$rld_var':+:$'$rld_var'}'\"
47 preload_var=_RLDN32_LIST
48 ;;
49 *ELF\ 64*MIPS*)
50 [ -n "$LD_LIBRARY64_PATH" ] && rld_var=LD_LIBRARY64_PATH
51 #_RLD64_LIST="$LIBCRYPTOSO:$LIBSSLSO:DEFAULT"; export _RLD64_LIST
52 _RLD64_ROOT=/no/such/dir; export _RLD64_ROOT
53 eval $rld_var=\"/usr/lib64'${'$rld_var':+:$'$rld_var'}'\"
54 preload_var=_RLD64_LIST
55 ;;
56 esac
57 eval $rld_var=\"${THERE}'${'$rld_var':+:$'$rld_var'}'\"; export $rld_var
58 unset rld_var
59 ;;
60*) LD_LIBRARY_PATH="${THERE}:$LD_LIBRARY_PATH" # Linux, ELF HP-UX
61 DYLD_LIBRARY_PATH="${THERE}:$DYLD_LIBRARY_PATH" # MacOS X
62 SHLIB_PATH="${THERE}:$SHLIB_PATH" # legacy HP-UX
63 LIBPATH="${THERE}:$LIBPATH" # AIX, OS/2
64 export LD_LIBRARY_PATH DYLD_LIBRARY_PATH SHLIB_PATH LIBPATH
65 # Even though $PATH is adjusted [for Windows sake], it doesn't
66 # necessarily does the trick. Trouble is that with introduction
67 # of SafeDllSearchMode in XP/2003 it's more appropriate to copy
68 # .DLLs in vicinity of executable, which is done elsewhere...
69 if [ "$OSTYPE" != msdosdjgpp ]; then
70 PATH="${THERE}:$PATH"; export PATH
71 fi
72 ;;
73esac
74
75if [ -f "$LIBCRYPTOSO" -a -z "$preload_var" ]; then
76 # Following three lines are major excuse for isolating them into
77 # this wrapper script. Original reason for setting LD_PRELOAD
78 # was to make it possible to pass 'make test' when user linked
79 # with -rpath pointing to previous version installation. Wrapping
80 # it into a script makes it possible to do so on multi-ABI
81 # platforms.
82 case "$SYSNAME" in
83 *BSD|QNX) LD_PRELOAD="$LIBCRYPTOSO:$LIBSSLSO" ;; # *BSD, QNX
84 *) LD_PRELOAD="$LIBCRYPTOSO $LIBSSLSO" ;; # SunOS, Linux, ELF HP-UX
85 esac
86 _RLD_LIST="$LIBCRYPTOSO:$LIBSSLSO:DEFAULT" # Tru64, o32 IRIX
87 DYLD_INSERT_LIBRARIES="$LIBCRYPTOSO:$LIBSSLSO" # MacOS X
88 export LD_PRELOAD _RLD_LIST DYLD_INSERT_LIBRARIES
89fi
90
91cmd="$1${EXE_EXT}"
92shift
93if [ $# -eq 0 ]; then
94 exec "$cmd" # old sh, such as Tru64 4.x, fails to expand empty "$@"
95else
96 exec "$cmd" "$@"
97fi
diff --git a/src/lib/libcrypto/util/sp-diff.pl b/src/lib/libcrypto/util/sp-diff.pl
new file mode 100644
index 0000000000..9d6c60387f
--- /dev/null
+++ b/src/lib/libcrypto/util/sp-diff.pl
@@ -0,0 +1,80 @@
1#!/usr/local/bin/perl
2#
3# This file takes as input, the files that have been output from
4# ssleay speed.
5# It prints a table of the relative differences with %100 being 'no difference'
6#
7
8($#ARGV == 1) || die "$0 speedout1 speedout2\n";
9
10%one=&loadfile($ARGV[0]);
11%two=&loadfile($ARGV[1]);
12
13$line=0;
14foreach $a ("md2","md4","md5","sha","sha1","rc4","des cfb","des cbc","des ede3",
15 "idea cfb","idea cbc","rc2 cfb","rc2 cbc","blowfish cbc","cast cbc")
16 {
17 if (defined($one{$a,8}) && defined($two{$a,8}))
18 {
19 print "type 8 byte% 64 byte% 256 byte% 1024 byte% 8192 byte%\n"
20 unless $line;
21 $line++;
22 printf "%-12s ",$a;
23 foreach $b (8,64,256,1024,8192)
24 {
25 $r=$two{$a,$b}/$one{$a,$b}*100;
26 printf "%12.2f",$r;
27 }
28 print "\n";
29 }
30 }
31
32foreach $a (
33 "rsa 512","rsa 1024","rsa 2048","rsa 4096",
34 "dsa 512","dsa 1024","dsa 2048",
35 )
36 {
37 if (defined($one{$a,1}) && defined($two{$a,1}))
38 {
39 $r1=($one{$a,1}/$two{$a,1})*100;
40 $r2=($one{$a,2}/$two{$a,2})*100;
41 printf "$a bits %% %6.2f %% %6.2f\n",$r1,$r2;
42 }
43 }
44
45sub loadfile
46 {
47 local($file)=@_;
48 local($_,%ret);
49
50 open(IN,"<$file") || die "unable to open '$file' for input\n";
51 $header=1;
52 while (<IN>)
53 {
54 $header=0 if /^[dr]sa/;
55 if (/^type/) { $header=0; next; }
56 next if $header;
57 chop;
58 @a=split;
59 if ($a[0] =~ /^[dr]sa$/)
60 {
61 ($n,$t1,$t2)=($_ =~ /^([dr]sa\s+\d+)\s+bits\s+([.\d]+)s\s+([.\d]+)/);
62 $ret{$n,1}=$t1;
63 $ret{$n,2}=$t2;
64 }
65 else
66 {
67 $n=join(' ',grep(/[^k]$/,@a));
68 @k=grep(s/k$//,@a);
69
70 $ret{$n, 8}=$k[0];
71 $ret{$n, 64}=$k[1];
72 $ret{$n, 256}=$k[2];
73 $ret{$n,1024}=$k[3];
74 $ret{$n,8192}=$k[4];
75 }
76 }
77 close(IN);
78 return(%ret);
79 }
80
diff --git a/src/lib/libcrypto/util/speed.sh b/src/lib/libcrypto/util/speed.sh
new file mode 100644
index 0000000000..f489706197
--- /dev/null
+++ b/src/lib/libcrypto/util/speed.sh
@@ -0,0 +1,39 @@
1#!/bin/sh
2
3#
4# This is a ugly script use, in conjuction with editing the 'b'
5# configuration in the $(TOP)/Configure script which will
6# output when finished a file called speed.log which is the
7# timings of SSLeay with various options turned on or off.
8#
9# from the $(TOP) directory
10# Edit Configure, modifying things to do with the b/bl-4c-2c etc
11# configurations.
12#
13
14make clean
15perl Configure b
16make
17apps/ssleay version -v -b -f >speed.1
18apps/ssleay speed >speed.1l
19
20perl Configure bl-4c-2c
21/bin/rm -f crypto/rc4/*.o crypto/bn/bn*.o crypto/md2/md2_dgst.o
22make
23apps/ssleay speed rc4 rsa md2 >speed.2l
24
25perl Configure bl-4c-ri
26/bin/rm -f crypto/rc4/rc4*.o
27make
28apps/ssleay speed rc4 >speed.3l
29
30perl Configure b2-is-ri-dp
31/bin/rm -f crypto/idea/i_*.o crypto/rc4/*.o crypto/des/ecb_enc.o crypto/bn/bn*.o
32apps/ssleay speed rsa rc4 idea des >speed.4l
33
34cat speed.1 >speed.log
35cat speed.1l >>speed.log
36perl util/sp-diff.pl speed.1l speed.2l >>speed.log
37perl util/sp-diff.pl speed.1l speed.3l >>speed.log
38perl util/sp-diff.pl speed.1l speed.4l >>speed.log
39
diff --git a/src/lib/libcrypto/util/src-dep.pl b/src/lib/libcrypto/util/src-dep.pl
new file mode 100644
index 0000000000..ad997e4746
--- /dev/null
+++ b/src/lib/libcrypto/util/src-dep.pl
@@ -0,0 +1,147 @@
1#!/usr/local/bin/perl
2
3# we make up an array of
4# $file{function_name}=filename;
5# $unres{filename}="func1 func2 ...."
6$debug=1;
7#$nm_func="parse_linux";
8$nm_func="parse_solaris";
9
10foreach (@ARGV)
11 {
12 &$nm_func($_);
13 }
14
15foreach $file (sort keys %unres)
16 {
17 @a=split(/\s+/,$unres{$file});
18 %ff=();
19 foreach $func (@a)
20 {
21 $f=$file{$func};
22 $ff{$f}=1 if $f ne "";
23 }
24
25 foreach $a (keys %ff)
26 { $we_need{$file}.="$a "; }
27 }
28
29foreach $file (sort keys %we_need)
30 {
31# print " $file $we_need{$file}\n";
32 foreach $bit (split(/\s+/,$we_need{$file}))
33 { push(@final,&walk($bit)); }
34
35 foreach (@final) { $fin{$_}=1; }
36 @final="";
37 foreach (sort keys %fin)
38 { push(@final,$_); }
39
40 print "$file: @final\n";
41 }
42
43sub walk
44 {
45 local($f)=@_;
46 local(@a,%seen,@ret,$r);
47
48 @ret="";
49 $f =~ s/^\s+//;
50 $f =~ s/\s+$//;
51 return "" if ($f =~ "^\s*$");
52
53 return(split(/\s/,$done{$f})) if defined ($done{$f});
54
55 return if $in{$f} > 0;
56 $in{$f}++;
57 push(@ret,$f);
58 foreach $r (split(/\s+/,$we_need{$f}))
59 {
60 push(@ret,&walk($r));
61 }
62 $in{$f}--;
63 $done{$f}=join(" ",@ret);
64 return(@ret);
65 }
66
67sub parse_linux
68 {
69 local($name)=@_;
70
71 open(IN,"nm $name|") || die "unable to run 'nn $name':$!\n";
72 while (<IN>)
73 {
74 chop;
75 next if /^\s*$/;
76 if (/^[^[](.*):$/)
77 {
78 $file=$1;
79 $file="$1.c" if /\[(.*).o\]/;
80 print STDERR "$file\n";
81 $we_need{$file}=" ";
82 next;
83 }
84
85 @a=split(/\s*\|\s*/);
86 next unless $#a == 7;
87 next unless $a[4] eq "GLOB";
88 if ($a[6] eq "UNDEF")
89 {
90 $unres{$file}.=$a[7]." ";
91 }
92 else
93 {
94 if ($file{$a[7]} ne "")
95 {
96 print STDERR "duplicate definition of $a[7],\n$file{$a[7]} and $file \n";
97 }
98 else
99 {
100 $file{$a[7]}=$file;
101 }
102 }
103 }
104 close(IN);
105 }
106
107sub parse_solaris
108 {
109 local($name)=@_;
110
111 open(IN,"nm $name|") || die "unable to run 'nn $name':$!\n";
112 while (<IN>)
113 {
114 chop;
115 next if /^\s*$/;
116 if (/^(\S+):$/)
117 {
118 $file=$1;
119 #$file="$1.c" if $file =~ /^(.*).o$/;
120 print STDERR "$file\n";
121 $we_need{$file}=" ";
122 next;
123 }
124 @a=split(/\s*\|\s*/);
125 next unless $#a == 7;
126 next unless $a[4] eq "GLOB";
127 if ($a[6] eq "UNDEF")
128 {
129 $unres{$file}.=$a[7]." ";
130 print STDERR "$file needs $a[7]\n" if $debug;
131 }
132 else
133 {
134 if ($file{$a[7]} ne "")
135 {
136 print STDERR "duplicate definition of $a[7],\n$file{$a[7]} and $file \n";
137 }
138 else
139 {
140 $file{$a[7]}=$file;
141 print STDERR "$file has $a[7]\n" if $debug;
142 }
143 }
144 }
145 close(IN);
146 }
147
diff --git a/src/lib/libcrypto/util/tab_num.pl b/src/lib/libcrypto/util/tab_num.pl
new file mode 100644
index 0000000000..a81ed0edc2
--- /dev/null
+++ b/src/lib/libcrypto/util/tab_num.pl
@@ -0,0 +1,17 @@
1#!/usr/local/bin/perl
2
3$num=1;
4$width=40;
5
6while (<>)
7 {
8 chop;
9
10 $i=length($_);
11
12 $n=$width-$i;
13 $i=int(($n+7)/8);
14 print $_.("\t" x $i).$num."\n";
15 $num++;
16 }
17
diff --git a/src/lib/libcrypto/util/x86asm.sh b/src/lib/libcrypto/util/x86asm.sh
new file mode 100644
index 0000000000..d2090a9849
--- /dev/null
+++ b/src/lib/libcrypto/util/x86asm.sh
@@ -0,0 +1,42 @@
1#!/bin/sh
2
3echo Generating x86 assember
4echo Bignum
5(cd crypto/bn/asm; perl x86.pl cpp > bn86unix.cpp)
6(cd crypto/bn/asm; perl x86.pl win32 > bn-win32.asm)
7
8echo DES
9(cd crypto/des/asm; perl des-586.pl cpp > dx86unix.cpp)
10(cd crypto/des/asm; perl des-586.pl win32 > d-win32.asm)
11
12echo "crypt(3)"
13(cd crypto/des/asm; perl crypt586.pl cpp > yx86unix.cpp)
14(cd crypto/des/asm; perl crypt586.pl win32 > y-win32.asm)
15
16echo Blowfish
17(cd crypto/bf/asm; perl bf-586.pl cpp > bx86unix.cpp)
18(cd crypto/bf/asm; perl bf-586.pl win32 > b-win32.asm)
19
20echo CAST5
21(cd crypto/cast/asm; perl cast-586.pl cpp > cx86unix.cpp)
22(cd crypto/cast/asm; perl cast-586.pl win32 > c-win32.asm)
23
24echo RC4
25(cd crypto/rc4/asm; perl rc4-586.pl cpp > rx86unix.cpp)
26(cd crypto/rc4/asm; perl rc4-586.pl win32 > r4-win32.asm)
27
28echo MD5
29(cd crypto/md5/asm; perl md5-586.pl cpp > mx86unix.cpp)
30(cd crypto/md5/asm; perl md5-586.pl win32 > m5-win32.asm)
31
32echo SHA1
33(cd crypto/sha/asm; perl sha1-586.pl cpp > sx86unix.cpp)
34(cd crypto/sha/asm; perl sha1-586.pl win32 > s1-win32.asm)
35
36echo RIPEMD160
37(cd crypto/ripemd/asm; perl rmd-586.pl cpp > rm86unix.cpp)
38(cd crypto/ripemd/asm; perl rmd-586.pl win32 > rm-win32.asm)
39
40echo RC5/32
41(cd crypto/rc5/asm; perl rc5-586.pl cpp > r586unix.cpp)
42(cd crypto/rc5/asm; perl rc5-586.pl win32 > r5-win32.asm)