summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/util/mk1mf.pl
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/util/mk1mf.pl')
-rw-r--r--src/lib/libcrypto/util/mk1mf.pl432
1 files changed, 273 insertions, 159 deletions
diff --git a/src/lib/libcrypto/util/mk1mf.pl b/src/lib/libcrypto/util/mk1mf.pl
index 149a0f4f80..8b6b2e668a 100644
--- a/src/lib/libcrypto/util/mk1mf.pl
+++ b/src/lib/libcrypto/util/mk1mf.pl
@@ -1,4 +1,4 @@
1#!/usr/bin/perl 1#!/usr/local/bin/perl
2# A bit of an evil hack but it post processes the file ../MINFO which 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. 3# is generated by `make files` in the top directory.
4# This script outputs one mega makefile that has no shell stuff or any 4# This script outputs one mega makefile that has no shell stuff or any
@@ -6,88 +6,71 @@
6# 6#
7 7
8$INSTALLTOP="/usr/local/ssl"; 8$INSTALLTOP="/usr/local/ssl";
9$OPTIONS="";
10$ssl_version="";
11$banner="\t\@echo Building OpenSSL";
12
13open(IN,"<Makefile.ssl") || die "unable to open Makefile.ssl!\n";
14while(<IN>) {
15 $ssl_version=$1 if (/^VERSION=(.*)$/);
16 $OPTIONS=$1 if (/^OPTIONS=(.*)$/);
17 $INSTALLTOP=$1 if (/^INSTALLTOP=(.*$)/);
18}
19close(IN);
9 20
10$ssl_version="0.8.2"; 21die "Makefile.ssl is not the toplevel Makefile!\n" if $ssl_version eq "";
11 22
12$infile="MINFO"; 23$infile="MINFO";
13 24
14%ops=( 25%ops=(
15 "VC-WIN32", "Microsoft Visual C++ 4.[01] - Windows NT [34].x", 26 "VC-WIN32", "Microsoft Visual C++ [4-6] - Windows NT or 9X",
27 "VC-NT", "Microsoft Visual C++ [4-6] - Windows NT ONLY",
16 "VC-W31-16", "Microsoft Visual C++ 1.52 - Windows 3.1 - 286", 28 "VC-W31-16", "Microsoft Visual C++ 1.52 - Windows 3.1 - 286",
17 "VC-WIN16", "Alias for VC-W31-32", 29 "VC-WIN16", "Alias for VC-W31-32",
18 "VC-W31-32", "Microsoft Visual C++ 1.52 - Windows 3.1 - 386+", 30 "VC-W31-32", "Microsoft Visual C++ 1.52 - Windows 3.1 - 386+",
19 "VC-MSDOS","Microsoft Visual C++ 1.52 - MSDOS", 31 "VC-MSDOS","Microsoft Visual C++ 1.52 - MSDOS",
20 "BC-NT", "Borland C++ 4.5 - Windows NT - PROBABLY NOT WORKING", 32 "Mingw32", "GNU C++ - Windows NT or 9x",
33 "Mingw32-files", "Create files with DOS copy ...",
34 "BC-NT", "Borland C++ 4.5 - Windows NT",
21 "BC-W31", "Borland C++ 4.5 - Windows 3.1 - PROBABLY NOT WORKING", 35 "BC-W31", "Borland C++ 4.5 - Windows 3.1 - PROBABLY NOT WORKING",
22 "BC-MSDOS","Borland C++ 4.5 - MSDOS", 36 "BC-MSDOS","Borland C++ 4.5 - MSDOS",
23 "linux-elf","Linux elf", 37 "linux-elf","Linux elf",
38 "ultrix-mips","DEC mips ultrix",
24 "FreeBSD","FreeBSD distribution", 39 "FreeBSD","FreeBSD distribution",
40 "OS2-EMX", "EMX GCC OS/2",
25 "default","cc under unix", 41 "default","cc under unix",
26 ); 42 );
27 43
28$type=""; 44$platform="";
29foreach (@ARGV) 45foreach (@ARGV)
30 { 46 {
31 if (/^no-rc2$/) { $no_rc2=1; } 47 if (!&read_options && !defined($ops{$_}))
32 elsif (/^no-rc4$/) { $no_rc4=1; }
33 elsif (/^no-rc5$/) { $no_rc5=1; }
34 elsif (/^no-idea$/) { $no_idea=1; }
35 elsif (/^no-des$/) { $no_des=1; }
36 elsif (/^no-bf$/) { $no_bf=1; }
37 elsif (/^no-cast$/) { $no_cast=1; }
38 elsif (/^no-md2$/) { $no_md2=1; }
39 elsif (/^no-md5$/) { $no_md5=1; }
40 elsif (/^no-sha$/) { $no_sha=1; }
41 elsif (/^no-sha1$/) { $no_sha1=1; }
42 elsif (/^no-rmd160$/) { $no_rmd160=1; }
43 elsif (/^no-mdc2$/) { $no_mdc2=1; }
44 elsif (/^no-patents$/) { $no_rc2=$no_rc4=$no_rc5=$no_idea=$no_rsa=1; }
45 elsif (/^no-rsa$/) { $no_rsa=1; }
46 elsif (/^no-dsa$/) { $no_dsa=1; }
47 elsif (/^no-dh$/) { $no_dh=1; }
48 elsif (/^no-asm$/) { $no_asm=1; }
49 elsif (/^no-ssl2$/) { $no_ssl2=1; }
50 elsif (/^no-ssl3$/) { $no_ssl3=1; }
51 elsif (/^no-err$/) { $no_err=1; }
52 elsif (/^no-sock$/) { $no_sock=1; }
53
54 elsif (/^just-ssl$/) { $no_rc2=$no_idea=$no_des=$no_bf=$no_cast=1;
55 $no_md2=$no_sha=$no_mdc2=$no_dsa=$no_dh=1;
56 $no_ssl2=$no_err=1; }
57
58 elsif (/^rsaref$/) { $rsaref=1; }
59 elsif (/^gcc$/) { $gcc=1; }
60 elsif (/^debug$/) { $debug=1; }
61 elsif (/^shlib$/) { $shlib=1; }
62 elsif (/^dll$/) { $shlib=1; }
63 elsif (/^([^=]*)=(.*)$/){ $VARS{$1}=$2; }
64 elsif (/^-[lL].*$/) { $l_flags.="$_ "; }
65 elsif ((!/^-help/) && (!/^-h/) && (!/^-\?/) && /^-.*$/)
66 { $c_flags.="$_ "; }
67 else
68 { 48 {
69 if (!defined($ops{$_})) 49 print STDERR "unknown option - $_\n";
70 { 50 print STDERR "usage: perl mk1mf.pl [options] [system]\n";
71 print STDERR "unknown option - $_\n"; 51 print STDERR "\nwhere [system] can be one of the following\n";
72 print STDERR "usage: perl mk1mf.pl [system] [options]\n"; 52 foreach $i (sort keys %ops)
73 print STDERR "\nwhere [system] can be one of the following\n"; 53 { printf STDERR "\t%-10s\t%s\n",$i,$ops{$i}; }
74 foreach $i (sort keys %ops) 54 print STDERR <<"EOF";
75 { printf STDERR "\t%-10s\t%s\n",$i,$ops{$i}; }
76 print STDERR <<"EOF";
77and [options] can be one of 55and [options] can be one of
78 no-md2 no-md5 no-sha no-sha1 no-mdc2 no-rmd160 - Skip this digest 56 no-md2 no-md4 no-md5 no-sha no-mdc2 - Skip this digest
79 no-rc2 no-rc4 no-idea no-des no-bf no-cast - Skip this symetric cipher 57 no-ripemd
80 no-rc5 58 no-rc2 no-rc4 no-rc5 no-idea no-des - Skip this symetric cipher
59 no-bf no-cast no-aes
81 no-rsa no-dsa no-dh - Skip this public key cipher 60 no-rsa no-dsa no-dh - Skip this public key cipher
82 no-ssl2 no-ssl3 - Skip this version of SSL 61 no-ssl2 no-ssl3 - Skip this version of SSL
83 just-ssl - remove all non-ssl keys/digest 62 just-ssl - remove all non-ssl keys/digest
84 no-asm - No x86 asm 63 no-asm - No x86 asm
64 no-krb5 - No KRB5
65 no-ec - No EC
66 nasm - Use NASM for x86 asm
67 gaswin - Use GNU as with Mingw32
85 no-socks - No socket code 68 no-socks - No socket code
86 no-err - No error strings 69 no-err - No error strings
87 dll/shlib - Build shared libraries (MS) 70 dll/shlib - Build shared libraries (MS)
88 debug - Debug build 71 debug - Debug build
72 profile - Profiling build
89 gcc - Use Gcc (unix) 73 gcc - Use Gcc (unix)
90 rsaref - Build to require RSAref
91 74
92Values that can be set 75Values that can be set
93TMP=tmpdir OUT=outdir SRC=srcdir BIN=binpath INC=header-outdir CC=C-compiler 76TMP=tmpdir OUT=outdir SRC=srcdir BIN=binpath INC=header-outdir CC=C-compiler
@@ -96,27 +79,30 @@ TMP=tmpdir OUT=outdir SRC=srcdir BIN=binpath INC=header-outdir CC=C-compiler
96-<ex_cc_flags> - extra 'cc' flags, 79-<ex_cc_flags> - extra 'cc' flags,
97 added (MS), or replace (unix) 80 added (MS), or replace (unix)
98EOF 81EOF
99 exit(1); 82 exit(1);
100 }
101 $type=$_;
102 } 83 }
84 $platform=$_;
85 }
86foreach (grep(!/^$/, split(/ /, $OPTIONS)))
87 {
88 print STDERR "unknown option - $_\n" if !&read_options;
103 } 89 }
104 90
105$no_mdc2=1 if ($no_des); 91$no_mdc2=1 if ($no_des);
106 92
107$no_ssl3=1 if ($no_md5 || $no_sha1); 93$no_ssl3=1 if ($no_md5 || $no_sha);
108$no_ssl3=1 if ($no_rsa && $no_dh); 94$no_ssl3=1 if ($no_rsa && $no_dh);
109 95
110$no_ssl2=1 if ($no_md5 || $no_rsa); 96$no_ssl2=1 if ($no_md5);
111$no_ssl2=1 if ($no_rsa); 97$no_ssl2=1 if ($no_rsa);
112 98
113$out_def="out"; 99$out_def="out";
114$inc_def="outinc"; 100$inc_def="outinc";
115$tmp_def="tmp"; 101$tmp_def="tmp";
116 102
103$mkdir="mkdir";
117 104
118($ssl,$crypto)=("ssl","crypto"); 105($ssl,$crypto)=("ssl","crypto");
119$RSAglue="RSAglue";
120$ranlib="echo ranlib"; 106$ranlib="echo ranlib";
121 107
122$cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc'; 108$cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc';
@@ -125,62 +111,84 @@ $bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:'';
125 111
126# $bin_dir.=$o causes a core dump on my sparc :-( 112# $bin_dir.=$o causes a core dump on my sparc :-(
127 113
114$NT=0;
115
128push(@INC,"util/pl","pl"); 116push(@INC,"util/pl","pl");
129if ($type eq "VC-MSDOS") 117if ($platform eq "VC-MSDOS")
130 { 118 {
131 $asmbits=16; 119 $asmbits=16;
132 $msdos=1; 120 $msdos=1;
133 require 'VC-16.pl'; 121 require 'VC-16.pl';
134 } 122 }
135elsif ($type eq "VC-W31-16") 123elsif ($platform eq "VC-W31-16")
136 { 124 {
137 $asmbits=16; 125 $asmbits=16;
138 $msdos=1; $win16=1; 126 $msdos=1; $win16=1;
139 require 'VC-16.pl'; 127 require 'VC-16.pl';
140 } 128 }
141elsif (($type eq "VC-W31-32") || ($type eq "VC-WIN16")) 129elsif (($platform eq "VC-W31-32") || ($platform eq "VC-WIN16"))
142 { 130 {
143 $asmbits=32; 131 $asmbits=32;
144 $msdos=1; $win16=1; 132 $msdos=1; $win16=1;
145 require 'VC-16.pl'; 133 require 'VC-16.pl';
146 } 134 }
147elsif (($type eq "VC-WIN32") || ($type eq "VC-NT")) 135elsif (($platform eq "VC-WIN32") || ($platform eq "VC-NT"))
148 { 136 {
137 $NT = 1 if $platform eq "VC-NT";
149 require 'VC-32.pl'; 138 require 'VC-32.pl';
150 } 139 }
151elsif ($type eq "BC-NT") 140elsif ($platform eq "Mingw32")
141 {
142 require 'Mingw32.pl';
143 }
144elsif ($platform eq "Mingw32-files")
145 {
146 require 'Mingw32f.pl';
147 }
148elsif ($platform eq "BC-NT")
152 { 149 {
153 $bc=1; 150 $bc=1;
154 require 'BC-32.pl'; 151 require 'BC-32.pl';
155 } 152 }
156elsif ($type eq "BC-W31") 153elsif ($platform eq "BC-W31")
157 { 154 {
158 $bc=1; 155 $bc=1;
159 $msdos=1; $w16=1; 156 $msdos=1; $w16=1;
160 require 'BC-16.pl'; 157 require 'BC-16.pl';
161 } 158 }
162elsif ($type eq "BC-Q16") 159elsif ($platform eq "BC-Q16")
163 { 160 {
164 $msdos=1; $w16=1; $shlib=0; $qw=1; 161 $msdos=1; $w16=1; $shlib=0; $qw=1;
165 require 'BC-16.pl'; 162 require 'BC-16.pl';
166 } 163 }
167elsif ($type eq "BC-MSDOS") 164elsif ($platform eq "BC-MSDOS")
168 { 165 {
169 $asmbits=16; 166 $asmbits=16;
170 $msdos=1; 167 $msdos=1;
171 require 'BC-16.pl'; 168 require 'BC-16.pl';
172 } 169 }
173elsif ($type eq "FreeBSD") 170elsif ($platform eq "FreeBSD")
174 { 171 {
175 require 'unix.pl'; 172 require 'unix.pl';
176 $cflags='-DTERMIO -D_ANSI_SOURCE -O2 -fomit-frame-pointer'; 173 $cflags='-DTERMIO -D_ANSI_SOURCE -O2 -fomit-frame-pointer';
177 } 174 }
178elsif ($type eq "linux-elf") 175elsif ($platform eq "linux-elf")
179 { 176 {
180 require "unix.pl"; 177 require "unix.pl";
181 require "linux.pl"; 178 require "linux.pl";
182 $unix=1; 179 $unix=1;
183 } 180 }
181elsif ($platform eq "ultrix-mips")
182 {
183 require "unix.pl";
184 require "ultrix.pl";
185 $unix=1;
186 }
187elsif ($platform eq "OS2-EMX")
188 {
189 $wc=1;
190 require 'OS2-EMX.pl';
191 }
184else 192else
185 { 193 {
186 require "unix.pl"; 194 require "unix.pl";
@@ -195,42 +203,45 @@ $inc_dir=(defined($VARS{'INC'}))?$VARS{'INC'}:$inc_def;
195 203
196$bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq '')); 204$bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq ''));
197 205
198$cflags.=" -DNO_IDEA" if $no_idea; 206$cflags.=" -DOPENSSL_NO_IDEA" if $no_idea;
199$cflags.=" -DNO_RC2" if $no_rc2; 207$cflags.=" -DOPENSSL_NO_AES" if $no_aes;
200$cflags.=" -DNO_RC4" if $no_rc4; 208$cflags.=" -DOPENSSL_NO_RC2" if $no_rc2;
201$cflags.=" -DNO_RC5" if $no_rc5; 209$cflags.=" -DOPENSSL_NO_RC4" if $no_rc4;
202$cflags.=" -DNO_MD2" if $no_md2; 210$cflags.=" -DOPENSSL_NO_RC5" if $no_rc5;
203$cflags.=" -DNO_MD5" if $no_md5; 211$cflags.=" -DOPENSSL_NO_MD2" if $no_md2;
204$cflags.=" -DNO_SHA" if $no_sha; 212$cflags.=" -DOPENSSL_NO_MD4" if $no_md4;
205$cflags.=" -DNO_SHA1" if $no_sha1; 213$cflags.=" -DOPENSSL_NO_MD5" if $no_md5;
206$cflags.=" -DNO_RMD160" if $no_rmd160; 214$cflags.=" -DOPENSSL_NO_SHA" if $no_sha;
207$cflags.=" -DNO_MDC2" if $no_mdc2; 215$cflags.=" -DOPENSSL_NO_SHA1" if $no_sha1;
208$cflags.=" -DNO_BLOWFISH" if $no_bf; 216$cflags.=" -DOPENSSL_NO_RIPEMD" if $no_rmd160;
209$cflags.=" -DNO_CAST" if $no_cast; 217$cflags.=" -DOPENSSL_NO_MDC2" if $no_mdc2;
210$cflags.=" -DNO_DES" if $no_des; 218$cflags.=" -DOPENSSL_NO_BF" if $no_bf;
211$cflags.=" -DNO_RSA" if $no_rsa; 219$cflags.=" -DOPENSSL_NO_CAST" if $no_cast;
212$cflags.=" -DNO_DSA" if $no_dsa; 220$cflags.=" -DOPENSSL_NO_DES" if $no_des;
213$cflags.=" -DNO_DH" if $no_dh; 221$cflags.=" -DOPENSSL_NO_RSA" if $no_rsa;
214$cflags.=" -DNO_SOCK" if $no_sock; 222$cflags.=" -DOPENSSL_NO_DSA" if $no_dsa;
215$cflags.=" -DNO_SSL2" if $no_ssl2; 223$cflags.=" -DOPENSSL_NO_DH" if $no_dh;
216$cflags.=" -DNO_SSL3" if $no_ssl3; 224$cflags.=" -DOPENSSL_NO_SOCK" if $no_sock;
217$cflags.=" -DNO_ERR" if $no_err; 225$cflags.=" -DOPENSSL_NO_SSL2" if $no_ssl2;
218$cflags.=" -DRSAref" if $rsaref ne ""; 226$cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3;
219 227$cflags.=" -DOPENSSL_NO_ERR" if $no_err;
220if ($unix) 228$cflags.=" -DOPENSSL_NO_KRB5" if $no_krb5;
221 { $cflags="$c_flags" if ($c_flags ne ""); } 229$cflags.=" -DOPENSSL_NO_EC" if $no_ec;
222else { $cflags="$c_flags$cflags" if ($c_flags ne ""); } 230#$cflags.=" -DRSAref" if $rsaref ne "";
231
232## if ($unix)
233## { $cflags="$c_flags" if ($c_flags ne ""); }
234##else
235 { $cflags="$c_flags$cflags" if ($c_flags ne ""); }
223 236
224$ex_libs="$l_flags$ex_libs" if ($l_flags ne ""); 237$ex_libs="$l_flags$ex_libs" if ($l_flags ne "");
225 238
226if ($ranlib ne "") 239%shlib_ex_cflags=("SSL" => " -DOPENSSL_BUILD_SHLIBSSL",
227 { 240 "CRYPTO" => " -DOPENSSL_BUILD_SHLIBCRYPTO");
228 $ranlib="\$(SRC_D)$o$ranlib";
229 }
230 241
231if ($msdos) 242if ($msdos)
232 { 243 {
233 $banner ="\t\@echo Make sure you have run 'perl Configure $type' in the\n"; 244 $banner ="\t\@echo Make sure you have run 'perl Configure $platform' in the\n";
234 $banner.="\t\@echo top level directory, if you don't have perl, you will\n"; 245 $banner.="\t\@echo top level directory, if you don't have perl, you will\n";
235 $banner.="\t\@echo need to probably edit crypto/bn/bn.h, check the\n"; 246 $banner.="\t\@echo need to probably edit crypto/bn/bn.h, check the\n";
236 $banner.="\t\@echo documentation for details.\n"; 247 $banner.="\t\@echo documentation for details.\n";
@@ -242,8 +253,8 @@ $link="$bin_dir$link" if ($link !~ /^\$/);
242$INSTALLTOP =~ s|/|$o|g; 253$INSTALLTOP =~ s|/|$o|g;
243 254
244$defs= <<"EOF"; 255$defs= <<"EOF";
245# This makefile has been automatically generated from the SSLeay distribution. 256# This makefile has been automatically generated from the OpenSSL distribution.
246# This single makefile will build the complete SSLeay distribution and 257# This single makefile will build the complete OpenSSL distribution and
247# by default leave the 'intertesting' output files in .${o}out and the stuff 258# by default leave the 'intertesting' output files in .${o}out and the stuff
248# that needs deleting in .${o}tmp. 259# that needs deleting in .${o}tmp.
249# The file was generated by running 'make makefile.one', which 260# The file was generated by running 'make makefile.one', which
@@ -258,6 +269,7 @@ $defs= <<"EOF";
258INSTALLTOP=$INSTALLTOP 269INSTALLTOP=$INSTALLTOP
259 270
260# Set your compiler options 271# Set your compiler options
272PLATFORM=$platform
261CC=$bin_dir${cc} 273CC=$bin_dir${cc}
262CFLAG=$cflags 274CFLAG=$cflags
263APP_CFLAG=$app_cflag 275APP_CFLAG=$app_cflag
@@ -269,18 +281,18 @@ SHLIB_EX_OBJ=$shlib_ex_obj
269# be added 281# be added
270EX_LIBS=$ex_libs 282EX_LIBS=$ex_libs
271 283
272# The SSLeay directory 284# The OpenSSL directory
273SRC_D=$src_dir 285SRC_D=$src_dir
274 286
275LINK=$link 287LINK=$link
276LFLAGS=$lflags 288LFLAGS=$lflags
277 289
278BN_MULW_OBJ=$bn_mulw_obj 290BN_ASM_OBJ=$bn_asm_obj
279BN_MULW_SRC=$bn_mulw_src 291BN_ASM_SRC=$bn_asm_src
292BNCO_ASM_OBJ=$bnco_asm_obj
293BNCO_ASM_SRC=$bnco_asm_src
280DES_ENC_OBJ=$des_enc_obj 294DES_ENC_OBJ=$des_enc_obj
281DES_ENC_SRC=$des_enc_src 295DES_ENC_SRC=$des_enc_src
282DES_CRYPT_OBJ=$des_crypt_obj
283DES_CRYPT_SRC=$des_crypt_src
284BF_ENC_OBJ=$bf_enc_obj 296BF_ENC_OBJ=$bf_enc_obj
285BF_ENC_SRC=$bf_enc_src 297BF_ENC_SRC=$bf_enc_src
286CAST_ENC_OBJ=$cast_enc_obj 298CAST_ENC_OBJ=$cast_enc_obj
@@ -302,11 +314,12 @@ OUT_D=$out_dir
302TMP_D=$tmp_dir 314TMP_D=$tmp_dir
303# The output directory for the header files 315# The output directory for the header files
304INC_D=$inc_dir 316INC_D=$inc_dir
317INCO_D=$inc_dir${o}openssl
305 318
306CP=$cp 319CP=$cp
307RM=$rm 320RM=$rm
308RANLIB=$ranlib 321RANLIB=$ranlib
309MKDIR=mkdir 322MKDIR=$mkdir
310MKLIB=$bin_dir$mklib 323MKLIB=$bin_dir$mklib
311MLFLAGS=$mlflags 324MLFLAGS=$mlflags
312ASM=$bin_dir$asm 325ASM=$bin_dir$asm
@@ -315,14 +328,16 @@ ASM=$bin_dir$asm
315# You should not need to touch anything below this point 328# You should not need to touch anything below this point
316###################################################### 329######################################################
317 330
318E_EXE=ssleay 331E_EXE=openssl
319SSL=$ssl 332SSL=$ssl
320CRYPTO=$crypto 333CRYPTO=$crypto
321RSAGLUE=$RSAglue
322 334
323# BIN_D - Binary output directory 335# BIN_D - Binary output directory
324# TEST_D - Binary test file output directory 336# TEST_D - Binary test file output directory
325# LIB_D - library output directory 337# LIB_D - library output directory
338# Note: if you change these point to different directories then uncomment out
339# the lines around the 'NB' comment below.
340#
326BIN_D=\$(OUT_D) 341BIN_D=\$(OUT_D)
327TEST_D=\$(OUT_D) 342TEST_D=\$(OUT_D)
328LIB_D=\$(OUT_D) 343LIB_D=\$(OUT_D)
@@ -334,14 +349,12 @@ INCL_D=\$(TMP_D)
334 349
335O_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp 350O_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp
336O_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp 351O_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp
337O_RSAGLUE= \$(LIB_D)$o$plib\$(RSAGLUE)$libp
338SO_SSL= $plib\$(SSL)$so_shlibp 352SO_SSL= $plib\$(SSL)$so_shlibp
339SO_CRYPTO= $plib\$(CRYPTO)$so_shlibp 353SO_CRYPTO= $plib\$(CRYPTO)$so_shlibp
340L_SSL= \$(LIB_D)$o\$(SSL)$libp 354L_SSL= \$(LIB_D)$o$plib\$(SSL)$libp
341L_CRYPTO= \$(LIB_D)$o\$(CRYPTO)$libp 355L_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$libp
342 356
343L_LIBS= \$(L_SSL) \$(L_CRYPTO) 357L_LIBS= \$(L_SSL) \$(L_CRYPTO)
344#L_LIBS= \$(O_SSL) \$(O_RSAGLUE) -lrsaref \$(O_CRYPTO)
345 358
346###################################################### 359######################################################
347# Don't touch anything below this point 360# Don't touch anything below this point
@@ -351,33 +364,37 @@ INC=-I\$(INC_D) -I\$(INCL_D)
351APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG) 364APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG)
352LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) 365LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG)
353SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG) 366SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG)
354LIBS_DEP=\$(O_CRYPTO) \$(O_RSAGLUE) \$(O_SSL) 367LIBS_DEP=\$(O_CRYPTO) \$(O_SSL)
355 368
356############################################# 369#############################################
357EOF 370EOF
358 371
359$rules=<<"EOF"; 372$rules=<<"EOF";
360all: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INC_D) headers lib exe 373all: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INCO_D) headers lib exe
361 374
362banner: 375banner:
363$banner 376$banner
364 377
365\$(TMP_D): 378\$(TMP_D):
366 \$(MKDIR) \$(TMP_D) 379 \$(MKDIR) \$(TMP_D)
367 380# NB: uncomment out these lines if BIN_D, TEST_D and LIB_D are different
368\$(BIN_D): 381#\$(BIN_D):
369 \$(MKDIR) \$(BIN_D) 382# \$(MKDIR) \$(BIN_D)
370 383#
371\$(TEST_D): 384#\$(TEST_D):
372 \$(MKDIR) \$(TEST_D) 385# \$(MKDIR) \$(TEST_D)
373 386
374\$(LIB_D): 387\$(LIB_D):
375 \$(MKDIR) \$(LIB_D) 388 \$(MKDIR) \$(LIB_D)
376 389
390\$(INCO_D): \$(INC_D)
391 \$(MKDIR) \$(INCO_D)
392
377\$(INC_D): 393\$(INC_D):
378 \$(MKDIR) \$(INC_D) 394 \$(MKDIR) \$(INC_D)
379 395
380headers: \$(HEADER) \$(EXHEADER) 396headers: \$(HEADER) \$(EXHEADER)
397 @
381 398
382lib: \$(LIBS_DEP) 399lib: \$(LIBS_DEP)
383 400
@@ -387,8 +404,9 @@ install:
387 \$(MKDIR) \$(INSTALLTOP) 404 \$(MKDIR) \$(INSTALLTOP)
388 \$(MKDIR) \$(INSTALLTOP)${o}bin 405 \$(MKDIR) \$(INSTALLTOP)${o}bin
389 \$(MKDIR) \$(INSTALLTOP)${o}include 406 \$(MKDIR) \$(INSTALLTOP)${o}include
407 \$(MKDIR) \$(INSTALLTOP)${o}include${o}openssl
390 \$(MKDIR) \$(INSTALLTOP)${o}lib 408 \$(MKDIR) \$(INSTALLTOP)${o}lib
391 \$(CP) \$(INC_D)${o}*.\[ch\] \$(INSTALLTOP)${o}include 409 \$(CP) \$(INCO_D)${o}*.\[ch\] \$(INSTALLTOP)${o}include${o}openssl
392 \$(CP) \$(BIN_D)$o\$(E_EXE)$exep \$(INSTALLTOP)${o}bin 410 \$(CP) \$(BIN_D)$o\$(E_EXE)$exep \$(INSTALLTOP)${o}bin
393 \$(CP) \$(O_SSL) \$(INSTALLTOP)${o}lib 411 \$(CP) \$(O_SSL) \$(INSTALLTOP)${o}lib
394 \$(CP) \$(O_CRYPTO) \$(INSTALLTOP)${o}lib 412 \$(CP) \$(O_CRYPTO) \$(INSTALLTOP)${o}lib
@@ -401,6 +419,42 @@ vclean:
401 \$(RM) \$(OUT_D)$o*.* 419 \$(RM) \$(OUT_D)$o*.*
402 420
403EOF 421EOF
422
423my $platform_cpp_symbol = "MK1MF_PLATFORM_$platform";
424$platform_cpp_symbol =~ s/-/_/g;
425if (open(IN,"crypto/buildinf.h"))
426 {
427 # Remove entry for this platform in existing file buildinf.h.
428
429 my $old_buildinf_h = "";
430 while (<IN>)
431 {
432 if (/^\#ifdef $platform_cpp_symbol$/)
433 {
434 while (<IN>) { last if (/^\#endif/); }
435 }
436 else
437 {
438 $old_buildinf_h .= $_;
439 }
440 }
441 close(IN);
442
443 open(OUT,">crypto/buildinf.h") || die "Can't open buildinf.h";
444 print OUT $old_buildinf_h;
445 close(OUT);
446 }
447
448open (OUT,">>crypto/buildinf.h") || die "Can't open buildinf.h";
449printf OUT <<EOF;
450#ifdef $platform_cpp_symbol
451 /* auto-generated/updated by util/mk1mf.pl for crypto/cversion.c */
452 #define CFLAGS "$cc $cflags"
453 #define PLATFORM "$platform"
454EOF
455printf OUT " #define DATE \"%s\"\n", scalar gmtime();
456printf OUT "#endif\n";
457close(OUT);
404 458
405############################################# 459#############################################
406# We parse in input file and 'store' info for later printing. 460# We parse in input file and 'store' info for later printing.
@@ -468,8 +522,8 @@ chop($h); $header=$h;
468$defs.=&do_defs("HEADER",$header,"\$(INCL_D)",".h"); 522$defs.=&do_defs("HEADER",$header,"\$(INCL_D)",".h");
469$rules.=&do_copy_rule("\$(INCL_D)",$header,".h"); 523$rules.=&do_copy_rule("\$(INCL_D)",$header,".h");
470 524
471$defs.=&do_defs("EXHEADER",$exheader,"\$(INC_D)",".h"); 525$defs.=&do_defs("EXHEADER",$exheader,"\$(INCO_D)",".h");
472$rules.=&do_copy_rule("\$(INC_D)",$exheader,".h"); 526$rules.=&do_copy_rule("\$(INCO_D)",$exheader,".h");
473 527
474$defs.=&do_defs("T_OBJ",$test,"\$(OBJ_D)",$obj); 528$defs.=&do_defs("T_OBJ",$test,"\$(OBJ_D)",$obj);
475$rules.=&do_compile_rule("\$(OBJ_D)",$test,"\$(APP_CFLAGS)"); 529$rules.=&do_compile_rule("\$(OBJ_D)",$test,"\$(APP_CFLAGS)");
@@ -482,24 +536,21 @@ foreach (values %lib_nam)
482 $lib_obj=$lib_obj{$_}; 536 $lib_obj=$lib_obj{$_};
483 local($slib)=$shlib; 537 local($slib)=$shlib;
484 538
485 $slib=0 if ($_ eq "RSAGLUE");
486
487 if (($_ eq "SSL") && $no_ssl2 && $no_ssl3) 539 if (($_ eq "SSL") && $no_ssl2 && $no_ssl3)
488 { 540 {
489 $rules.="\$(O_SSL):\n\n"; 541 $rules.="\$(O_SSL):\n\n";
490 next; 542 next;
491 } 543 }
492 544
493 if (($_ eq "RSAGLUE") && $no_rsa) 545 if (($bn_asm_obj ne "") && ($_ eq "CRYPTO"))
494 { 546 {
495 $rules.="\$(O_RSAGLUE):\n\n"; 547 $lib_obj =~ s/\s\S*\/bn_asm\S*/ \$(BN_ASM_OBJ)/;
496 next; 548 $rules.=&do_asm_rule($bn_asm_obj,$bn_asm_src);
497 } 549 }
498 550 if (($bnco_asm_obj ne "") && ($_ eq "CRYPTO"))
499 if (($bn_mulw_obj ne "") && ($_ eq "CRYPTO"))
500 { 551 {
501 $lib_obj =~ s/\s\S*\/bn_mulw\S*/ \$(BN_MULW_OBJ)/; 552 $lib_obj .= "\$(BNCO_ASM_OBJ)";
502 $rules.=&do_asm_rule($bn_mulw_obj,$bn_mulw_src); 553 $rules.=&do_asm_rule($bnco_asm_obj,$bnco_asm_src);
503 } 554 }
504 if (($des_enc_obj ne "") && ($_ eq "CRYPTO")) 555 if (($des_enc_obj ne "") && ($_ eq "CRYPTO"))
505 { 556 {
@@ -543,7 +594,7 @@ foreach (values %lib_nam)
543 $rules.=&do_asm_rule($rmd160_asm_obj,$rmd160_asm_src); 594 $rules.=&do_asm_rule($rmd160_asm_obj,$rmd160_asm_src);
544 } 595 }
545 $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj); 596 $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj);
546 $lib=($slib)?" \$(SHLIB_CFLAGS)":" \$(LIB_CFLAGS)"; 597 $lib=($slib)?" \$(SHLIB_CFLAGS)".$shlib_ex_cflags{$_}:" \$(LIB_CFLAGS)";
547 $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib); 598 $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib);
548 } 599 }
549 600
@@ -556,13 +607,19 @@ foreach (split(/\s+/,$test))
556 } 607 }
557 608
558$rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)"); 609$rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)");
559$rules.= &do_lib_rule("\$(RSAGLUEOBJ)","\$(O_RSAGLUE)",$RSAglue,0,"")
560 unless $no_rsa;
561$rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)"); 610$rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)");
562 611
563$rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)"); 612$rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)");
564 613
565print $defs; 614print $defs;
615
616if ($platform eq "linux-elf") {
617 print <<"EOF";
618# Generate perlasm output files
619%.cpp:
620 (cd \$(\@D)/..; PERL=perl make -f Makefile.ssl asm/\$(\@F))
621EOF
622}
566print "###################################################################\n"; 623print "###################################################################\n";
567print $rules; 624print $rules;
568 625
@@ -576,6 +633,7 @@ sub var_add
576 local(@a,$_,$ret); 633 local(@a,$_,$ret);
577 634
578 return("") if $no_idea && $dir =~ /\/idea/; 635 return("") if $no_idea && $dir =~ /\/idea/;
636 return("") if $no_aes && $dir =~ /\/aes/;
579 return("") if $no_rc2 && $dir =~ /\/rc2/; 637 return("") if $no_rc2 && $dir =~ /\/rc2/;
580 return("") if $no_rc4 && $dir =~ /\/rc4/; 638 return("") if $no_rc4 && $dir =~ /\/rc4/;
581 return("") if $no_rc5 && $dir =~ /\/rc5/; 639 return("") if $no_rc5 && $dir =~ /\/rc5/;
@@ -601,7 +659,8 @@ sub var_add
601 659
602 @a=grep(!/^e_.*_3d$/,@a) if $no_des; 660 @a=grep(!/^e_.*_3d$/,@a) if $no_des;
603 @a=grep(!/^e_.*_d$/,@a) if $no_des; 661 @a=grep(!/^e_.*_d$/,@a) if $no_des;
604 @a=grep(!/^e_.*_i$/,@a) if $no_idea; 662 @a=grep(!/^e_.*_ae$/,@a) if $no_idea;
663 @a=grep(!/^e_.*_i$/,@a) if $no_aes;
605 @a=grep(!/^e_.*_r2$/,@a) if $no_rc2; 664 @a=grep(!/^e_.*_r2$/,@a) if $no_rc2;
606 @a=grep(!/^e_.*_r5$/,@a) if $no_rc5; 665 @a=grep(!/^e_.*_r5$/,@a) if $no_rc5;
607 @a=grep(!/^e_.*_bf$/,@a) if $no_bf; 666 @a=grep(!/^e_.*_bf$/,@a) if $no_bf;
@@ -614,7 +673,9 @@ sub var_add
614 @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock; 673 @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock;
615 674
616 @a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2; 675 @a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2;
676 @a=grep(!/(^md4)|(_md4$)/,@a) if $no_md4;
617 @a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5; 677 @a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5;
678 @a=grep(!/(rmd)|(ripemd)/,@a) if $no_rmd160;
618 679
619 @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa; 680 @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa;
620 @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa; 681 @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa;
@@ -631,7 +692,7 @@ sub var_add
631 @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1; 692 @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
632 @a=grep(!/_mdc2$/,@a) if $no_mdc2; 693 @a=grep(!/_mdc2$/,@a) if $no_mdc2;
633 694
634 @a=grep(!/(^rsa$)|(^genrsa$)|(^req$)|(^ca$)/,@a) if $no_rsa; 695 @a=grep(!/(^rsa$)|(^genrsa$)/,@a) if $no_rsa;
635 @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa; 696 @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa;
636 @a=grep(!/^gendsa$/,@a) if $no_sha1; 697 @a=grep(!/^gendsa$/,@a) if $no_sha1;
637 @a=grep(!/(^dh$)|(^gendh$)/,@a) if $no_dh; 698 @a=grep(!/(^dh$)|(^gendh$)/,@a) if $no_dh;
@@ -677,7 +738,8 @@ sub do_defs
677 if (($_ =~ /bss_file/) && ($postfix eq ".h")) 738 if (($_ =~ /bss_file/) && ($postfix eq ".h"))
678 { $pf=".c"; } 739 { $pf=".c"; }
679 else { $pf=$postfix; } 740 else { $pf=$postfix; }
680 if ($_ =~ /BN_MULW/) { $t="$_ "; } 741 if ($_ =~ /BN_ASM/) { $t="$_ "; }
742 elsif ($_ =~ /BNCO_ASM/){ $t="$_ "; }
681 elsif ($_ =~ /DES_ENC/) { $t="$_ "; } 743 elsif ($_ =~ /DES_ENC/) { $t="$_ "; }
682 elsif ($_ =~ /BF_ENC/) { $t="$_ "; } 744 elsif ($_ =~ /BF_ENC/) { $t="$_ "; }
683 elsif ($_ =~ /CAST_ENC/){ $t="$_ "; } 745 elsif ($_ =~ /CAST_ENC/){ $t="$_ "; }
@@ -704,23 +766,6 @@ sub bname
704 return($ret); 766 return($ret);
705 } 767 }
706 768
707# do a rule for each file that says 'copy' to new direcory on change
708sub do_copy_rule
709 {
710 local($to,$files,$p)=@_;
711 local($ret,$_,$n,$pp);
712
713 $files =~ s/\//$o/g if $o ne '/';
714 foreach (split(/\s+/,$files))
715 {
716 $n=&bname($_);
717 if ($n =~ /bss_file/)
718 { $pp=".c"; }
719 else { $pp=$p; }
720 $ret.="$to${o}$n$pp: \$(SRC_D)$o$_$pp\n\t\$(CP) \$(SRC_D)$o$_$pp $to${o}$n$pp\n\n";
721 }
722 return($ret);
723 }
724 769
725############################################################## 770##############################################################
726# do a rule for each file that says 'compile' to new direcory 771# do a rule for each file that says 'compile' to new direcory
@@ -746,8 +791,7 @@ sub cc_compile_target
746 local($target,$source,$ex_flags)=@_; 791 local($target,$source,$ex_flags)=@_;
747 local($ret); 792 local($ret);
748 793
749 # EAY EAY 794 $ex_flags.=" -DMK1MF_BUILD -D$platform_cpp_symbol" if ($source =~ /cversion/);
750 $ex_flags.=' -DCFLAGS="\"$(CC) $(CFLAG)\""' if ($source =~ /cversion/);
751 $target =~ s/\//$o/g if $o ne "/"; 795 $target =~ s/\//$o/g if $o ne "/";
752 $source =~ s/\//$o/g if $o ne "/"; 796 $source =~ s/\//$o/g if $o ne "/";
753 $ret ="$target: \$(SRC_D)$o$source\n\t"; 797 $ret ="$target: \$(SRC_D)$o$source\n\t";
@@ -791,3 +835,73 @@ sub do_shlib_rule
791 return($ret); 835 return($ret);
792 } 836 }
793 837
838# do a rule for each file that says 'copy' to new direcory on change
839sub do_copy_rule
840 {
841 local($to,$files,$p)=@_;
842 local($ret,$_,$n,$pp);
843
844 $files =~ s/\//$o/g if $o ne '/';
845 foreach (split(/\s+/,$files))
846 {
847 $n=&bname($_);
848 if ($n =~ /bss_file/)
849 { $pp=".c"; }
850 else { $pp=$p; }
851 $ret.="$to${o}$n$pp: \$(SRC_D)$o$_$pp\n\t\$(CP) \$(SRC_D)$o$_$pp $to${o}$n$pp\n\n";
852 }
853 return($ret);
854 }
855
856sub read_options
857 {
858 if (/^no-rc2$/) { $no_rc2=1; }
859 elsif (/^no-rc4$/) { $no_rc4=1; }
860 elsif (/^no-rc5$/) { $no_rc5=1; }
861 elsif (/^no-idea$/) { $no_idea=1; }
862 elsif (/^no-aes$/) { $no_aes=1; }
863 elsif (/^no-des$/) { $no_des=1; }
864 elsif (/^no-bf$/) { $no_bf=1; }
865 elsif (/^no-cast$/) { $no_cast=1; }
866 elsif (/^no-md2$/) { $no_md2=1; }
867 elsif (/^no-md4$/) { $no_md4=1; }
868 elsif (/^no-md5$/) { $no_md5=1; }
869 elsif (/^no-sha$/) { $no_sha=1; }
870 elsif (/^no-sha1$/) { $no_sha1=1; }
871 elsif (/^no-ripemd$/) { $no_ripemd=1; }
872 elsif (/^no-mdc2$/) { $no_mdc2=1; }
873 elsif (/^no-patents$/) { $no_rc2=$no_rc4=$no_rc5=$no_idea=$no_rsa=1; }
874 elsif (/^no-rsa$/) { $no_rsa=1; }
875 elsif (/^no-dsa$/) { $no_dsa=1; }
876 elsif (/^no-dh$/) { $no_dh=1; }
877 elsif (/^no-hmac$/) { $no_hmac=1; }
878 elsif (/^no-aes$/) { $no_aes=1; }
879 elsif (/^no-asm$/) { $no_asm=1; }
880 elsif (/^nasm$/) { $nasm=1; }
881 elsif (/^gaswin$/) { $gaswin=1; }
882 elsif (/^no-ssl2$/) { $no_ssl2=1; }
883 elsif (/^no-ssl3$/) { $no_ssl3=1; }
884 elsif (/^no-err$/) { $no_err=1; }
885 elsif (/^no-sock$/) { $no_sock=1; }
886 elsif (/^no-krb5$/) { $no_krb5=1; }
887 elsif (/^no-ec$/) { $no_ec=1; }
888
889 elsif (/^just-ssl$/) { $no_rc2=$no_idea=$no_des=$no_bf=$no_cast=1;
890 $no_md2=$no_sha=$no_mdc2=$no_dsa=$no_dh=1;
891 $no_ssl2=$no_err=$no_rmd160=$no_rc5=1;
892 $no_aes=1; }
893
894 elsif (/^rsaref$/) { }
895 elsif (/^gcc$/) { $gcc=1; }
896 elsif (/^debug$/) { $debug=1; }
897 elsif (/^profile$/) { $profile=1; }
898 elsif (/^shlib$/) { $shlib=1; }
899 elsif (/^dll$/) { $shlib=1; }
900 elsif (/^shared$/) { } # We just need to ignore it for now...
901 elsif (/^([^=]*)=(.*)$/){ $VARS{$1}=$2; }
902 elsif (/^-[lL].*$/) { $l_flags.="$_ "; }
903 elsif ((!/^-help/) && (!/^-h/) && (!/^-\?/) && /^-.*$/)
904 { $c_flags.="$_ "; }
905 else { return(0); }
906 return(1);
907 }