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.pl1165
1 files changed, 1165 insertions, 0 deletions
diff --git a/src/lib/libcrypto/util/mk1mf.pl b/src/lib/libcrypto/util/mk1mf.pl
new file mode 100644
index 0000000000..05a6086164
--- /dev/null
+++ b/src/lib/libcrypto/util/mk1mf.pl
@@ -0,0 +1,1165 @@
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$OPTIONS="";
10$ssl_version="";
11$banner="\t\@echo Building OpenSSL";
12
13local $zlib_opt = 0; # 0 = no zlib, 1 = static, 2 = dynamic
14local $zlib_lib = "";
15
16my $fips_canister_path = "";
17my $fips_premain_dso_exe_path = "";
18my $fips_premain_c_path = "";
19my $fips_sha1_exe_path = "";
20
21my $fipslibdir = "";
22my $baseaddr = "";
23
24my $ex_l_libs = "";
25
26
27open(IN,"<Makefile") || die "unable to open Makefile!\n";
28while(<IN>) {
29 $ssl_version=$1 if (/^VERSION=(.*)$/);
30 $OPTIONS=$1 if (/^OPTIONS=(.*)$/);
31 $INSTALLTOP=$1 if (/^INSTALLTOP=(.*$)/);
32}
33close(IN);
34
35die "Makefile is not the toplevel Makefile!\n" if $ssl_version eq "";
36
37$infile="MINFO";
38
39%ops=(
40 "VC-WIN32", "Microsoft Visual C++ [4-6] - Windows NT or 9X",
41 "VC-WIN32-GMAKE", "Microsoft Visual C++ [4-6] - Windows NT or 9X, GNU make",
42 "VC-CE", "Microsoft eMbedded Visual C++ 3.0 - Windows CE ONLY",
43 "VC-NT", "Microsoft Visual C++ [4-6] - Windows NT ONLY",
44 "VC-W31-16", "Microsoft Visual C++ 1.52 - Windows 3.1 - 286",
45 "VC-WIN16", "Alias for VC-W31-32",
46 "VC-W31-32", "Microsoft Visual C++ 1.52 - Windows 3.1 - 386+",
47 "VC-MSDOS","Microsoft Visual C++ 1.52 - MSDOS",
48 "Mingw32", "GNU C++ - Windows NT or 9x",
49 "Mingw32-files", "Create files with DOS copy ...",
50 "BC-NT", "Borland C++ 4.5 - Windows NT",
51 "BC-W31", "Borland C++ 4.5 - Windows 3.1 - PROBABLY NOT WORKING",
52 "BC-MSDOS","Borland C++ 4.5 - MSDOS",
53 "linux-elf","Linux elf",
54 "ultrix-mips","DEC mips ultrix",
55 "FreeBSD","FreeBSD distribution",
56 "OS2-EMX", "EMX GCC OS/2",
57 "default","cc under unix",
58 );
59
60$platform="";
61my $xcflags="";
62foreach (@ARGV)
63 {
64 if (!&read_options && !defined($ops{$_}))
65 {
66 print STDERR "unknown option - $_\n";
67 print STDERR "usage: perl mk1mf.pl [options] [system]\n";
68 print STDERR "\nwhere [system] can be one of the following\n";
69 foreach $i (sort keys %ops)
70 { printf STDERR "\t%-10s\t%s\n",$i,$ops{$i}; }
71 print STDERR <<"EOF";
72and [options] can be one of
73 no-md2 no-md4 no-md5 no-sha no-mdc2 - Skip this digest
74 no-ripemd
75 no-rc2 no-rc4 no-rc5 no-idea no-des - Skip this symetric cipher
76 no-bf no-cast no-aes
77 no-rsa no-dsa no-dh - Skip this public key cipher
78 no-ssl2 no-ssl3 - Skip this version of SSL
79 just-ssl - remove all non-ssl keys/digest
80 no-asm - No x86 asm
81 no-krb5 - No KRB5
82 no-ec - No EC
83 no-engine - No engine
84 no-hw - No hw
85 nasm - Use NASM for x86 asm
86 gaswin - Use GNU as with Mingw32
87 no-socks - No socket code
88 no-err - No error strings
89 dll/shlib - Build shared libraries (MS)
90 debug - Debug build
91 profile - Profiling build
92 gcc - Use Gcc (unix)
93
94Values that can be set
95TMP=tmpdir OUT=outdir SRC=srcdir BIN=binpath INC=header-outdir CC=C-compiler
96
97-L<ex_lib_path> -l<ex_lib> - extra library flags (unix)
98-<ex_cc_flags> - extra 'cc' flags,
99 added (MS), or replace (unix)
100EOF
101 exit(1);
102 }
103 $platform=$_;
104 }
105foreach (grep(!/^$/, split(/ /, $OPTIONS)))
106 {
107 print STDERR "unknown option - $_\n" if !&read_options;
108 }
109
110$no_mdc2=1 if ($no_des);
111
112$no_ssl3=1 if ($no_md5 || $no_sha);
113$no_ssl3=1 if ($no_rsa && $no_dh);
114
115$no_ssl2=1 if ($no_md5);
116$no_ssl2=1 if ($no_rsa);
117
118$out_def="out";
119$inc_def="outinc";
120$tmp_def="tmp";
121
122$mkdir="-mkdir";
123$mkcanister="ld -r -o";
124
125$ex_build_targets = "";
126
127($ssl,$crypto)=("ssl","crypto");
128$cryptocompat = "";
129$ranlib="echo ranlib";
130
131$cc=(defined($VARS{'CC'}))?$VARS{'CC'}:'cc';
132$src_dir=(defined($VARS{'SRC'}))?$VARS{'SRC'}:'.';
133$bin_dir=(defined($VARS{'BIN'}))?$VARS{'BIN'}:'';
134
135# $bin_dir.=$o causes a core dump on my sparc :-(
136
137$NT=0;
138
139push(@INC,"util/pl","pl");
140if ($platform eq "VC-MSDOS")
141 {
142 $asmbits=16;
143 $msdos=1;
144 require 'VC-16.pl';
145 }
146elsif ($platform eq "VC-W31-16")
147 {
148 $asmbits=16;
149 $msdos=1; $win16=1;
150 require 'VC-16.pl';
151 }
152elsif (($platform eq "VC-W31-32") || ($platform eq "VC-WIN16"))
153 {
154 $asmbits=32;
155 $msdos=1; $win16=1;
156 require 'VC-16.pl';
157 }
158elsif (($platform eq "VC-WIN32") || ($platform eq "VC-NT"))
159 {
160 $NT = 1 if $platform eq "VC-NT";
161 require 'VC-32.pl';
162 }
163elsif ($platform eq "VC-WIN32-GMAKE")
164 {
165 require 'VC-32-GMAKE.pl';
166 }
167elsif ($platform eq "VC-CE")
168 {
169 require 'VC-CE.pl';
170 }
171elsif ($platform eq "Mingw32")
172 {
173 require 'Mingw32.pl';
174 }
175elsif ($platform eq "Mingw32-files")
176 {
177 require 'Mingw32f.pl';
178 }
179elsif ($platform eq "BC-NT")
180 {
181 $bc=1;
182 require 'BC-32.pl';
183 }
184elsif ($platform eq "BC-W31")
185 {
186 $bc=1;
187 $msdos=1; $w16=1;
188 require 'BC-16.pl';
189 }
190elsif ($platform eq "BC-Q16")
191 {
192 $msdos=1; $w16=1; $shlib=0; $qw=1;
193 require 'BC-16.pl';
194 }
195elsif ($platform eq "BC-MSDOS")
196 {
197 $asmbits=16;
198 $msdos=1;
199 require 'BC-16.pl';
200 }
201elsif ($platform eq "FreeBSD")
202 {
203 require 'unix.pl';
204 $cflags='-DTERMIO -D_ANSI_SOURCE -O2 -fomit-frame-pointer';
205 }
206elsif ($platform eq "linux-elf")
207 {
208 require "unix.pl";
209 require "linux.pl";
210 $unix=1;
211 }
212elsif ($platform eq "ultrix-mips")
213 {
214 require "unix.pl";
215 require "ultrix.pl";
216 $unix=1;
217 }
218elsif ($platform eq "OS2-EMX")
219 {
220 $wc=1;
221 require 'OS2-EMX.pl';
222 }
223else
224 {
225 require "unix.pl";
226
227 $unix=1;
228 $cflags.=' -DTERMIO';
229 }
230
231$out_dir=(defined($VARS{'OUT'}))?$VARS{'OUT'}:$out_def.($debug?".dbg":"");
232$tmp_dir=(defined($VARS{'TMP'}))?$VARS{'TMP'}:$tmp_def.($debug?".dbg":"");
233$inc_dir=(defined($VARS{'INC'}))?$VARS{'INC'}:$inc_def;
234
235$bin_dir=$bin_dir.$o unless ((substr($bin_dir,-1,1) eq $o) || ($bin_dir eq ''));
236
237$cflags= "$xcflags$cflags" if $xcflags ne "";
238
239$cflags.=" -DOPENSSL_NO_IDEA" if $no_idea;
240$cflags.=" -DOPENSSL_NO_AES" if $no_aes;
241$cflags.=" -DOPENSSL_NO_RC2" if $no_rc2;
242$cflags.=" -DOPENSSL_NO_RC4" if $no_rc4;
243$cflags.=" -DOPENSSL_NO_RC5" if $no_rc5;
244$cflags.=" -DOPENSSL_NO_MD2" if $no_md2;
245$cflags.=" -DOPENSSL_NO_MD4" if $no_md4;
246$cflags.=" -DOPENSSL_NO_MD5" if $no_md5;
247$cflags.=" -DOPENSSL_NO_SHA" if $no_sha;
248$cflags.=" -DOPENSSL_NO_SHA1" if $no_sha1;
249$cflags.=" -DOPENSSL_NO_RIPEMD" if $no_ripemd;
250$cflags.=" -DOPENSSL_NO_MDC2" if $no_mdc2;
251$cflags.=" -DOPENSSL_NO_BF" if $no_bf;
252$cflags.=" -DOPENSSL_NO_CAST" if $no_cast;
253$cflags.=" -DOPENSSL_NO_DES" if $no_des;
254$cflags.=" -DOPENSSL_NO_RSA" if $no_rsa;
255$cflags.=" -DOPENSSL_NO_DSA" if $no_dsa;
256$cflags.=" -DOPENSSL_NO_DH" if $no_dh;
257$cflags.=" -DOPENSSL_NO_SOCK" if $no_sock;
258$cflags.=" -DOPENSSL_NO_SSL2" if $no_ssl2;
259$cflags.=" -DOPENSSL_NO_SSL3" if $no_ssl3;
260$cflags.=" -DOPENSSL_NO_ERR" if $no_err;
261$cflags.=" -DOPENSSL_NO_KRB5" if $no_krb5;
262$cflags.=" -DOPENSSL_NO_EC" if $no_ec;
263$cflags.=" -DOPENSSL_NO_ENGINE" if $no_engine;
264$cflags.=" -DOPENSSL_NO_HW" if $no_hw;
265$cflags.=" -DOPENSSL_FIPS" if $fips;
266#$cflags.=" -DRSAref" if $rsaref ne "";
267
268$cflags.= " -DZLIB" if $zlib_opt;
269$cflags.= " -DZLIB_SHARED" if $zlib_opt == 2;
270
271## if ($unix)
272## { $cflags="$c_flags" if ($c_flags ne ""); }
273##else
274 { $cflags="$c_flags$cflags" if ($c_flags ne ""); }
275
276$ex_libs="$l_flags$ex_libs" if ($l_flags ne "");
277
278
279%shlib_ex_cflags=("SSL" => " -DOPENSSL_BUILD_SHLIBSSL",
280 "CRYPTO" => " -DOPENSSL_BUILD_SHLIBCRYPTO");
281
282if ($msdos)
283 {
284 $banner ="\t\@echo Make sure you have run 'perl Configure $platform' in the\n";
285 $banner.="\t\@echo top level directory, if you don't have perl, you will\n";
286 $banner.="\t\@echo need to probably edit crypto/bn/bn.h, check the\n";
287 $banner.="\t\@echo documentation for details.\n";
288 }
289
290# have to do this to allow $(CC) under unix
291$link="$bin_dir$link" if ($link !~ /^\$/);
292
293$INSTALLTOP =~ s|/|$o|g;
294
295#############################################
296# We parse in input file and 'store' info for later printing.
297open(IN,"<$infile") || die "unable to open $infile:$!\n";
298$_=<IN>;
299for (;;)
300 {
301 chop;
302
303 ($key,$val)=/^([^=]+)=(.*)/;
304 if ($key eq "RELATIVE_DIRECTORY")
305 {
306 if ($lib ne "")
307 {
308 if ($fips && $dir =~ /^fips/)
309 {
310 $uc = "FIPS";
311 }
312 else
313 {
314 $uc=$lib;
315 $uc =~ s/^lib(.*)\.a/$1/;
316 $uc =~ tr/a-z/A-Z/;
317 }
318 if (($uc ne "FIPS") || $fips_canister_build)
319 {
320 $lib_nam{$uc}=$uc;
321 $lib_obj{$uc}.=$libobj." ";
322 }
323 }
324 last if ($val eq "FINISHED");
325 $lib="";
326 $libobj="";
327 $dir=$val;
328 }
329
330 if ($key eq "KRB5_INCLUDES")
331 { $cflags .= " $val";}
332
333 if ($key eq "ZLIB_INCLUDE")
334 { $cflags .= " $val" if $val ne "";}
335
336 if ($key eq "LIBZLIB")
337 { $zlib_lib = "$val" if $val ne "";}
338
339 if ($key eq "LIBKRB5")
340 { $ex_libs .= " $val" if $val ne "";}
341
342 if ($key eq "TEST")
343 { $test.=&var_add($dir,$val); }
344
345 if (($key eq "PROGS") || ($key eq "E_OBJ"))
346 { $e_exe.=&var_add($dir,$val); }
347
348 if ($key eq "LIB")
349 {
350 $lib=$val;
351 $lib =~ s/^.*\/([^\/]+)$/$1/;
352 }
353
354 if ($key eq "EXHEADER")
355 { $exheader.=&var_add($dir,$val); }
356
357 if ($key eq "HEADER")
358 { $header.=&var_add($dir,$val); }
359
360 if ($key eq "LIBOBJ")
361 { $libobj=&var_add($dir,$val); }
362
363 if ($key eq "FIPSLIBDIR")
364 { $fipslibdir=$val;}
365
366 if ($key eq "BASEADDR")
367 { $baseaddr=$val;}
368
369 if (!($_=<IN>))
370 { $_="RELATIVE_DIRECTORY=FINISHED\n"; }
371 }
372close(IN);
373
374if ($fips_canister_path eq "")
375 {
376 $fips_canister_path = "\$(FIPSLIB_D)${o}fipscanister.o";
377 }
378
379if ($fips_premain_c_path eq "")
380 {
381 $fips_premain_c_path = "\$(FIPSLIB_D)${o}fips_premain.c";
382 }
383
384if ($fips)
385 {
386 if ($fips_sha1_exe_path eq "")
387 {
388 $fips_sha1_exe_path =
389 "\$(BIN_D)${o}fips_standalone_sha1$exep";
390 }
391 }
392 else
393 {
394 $fips_sha1_exe_path = "";
395 }
396
397if ($fips_premain_dso_exe_path eq "")
398 {
399 $fips_premain_dso_exe_path = "\$(BIN_D)${o}fips_premain_dso$exep";
400 }
401
402# $ex_build_targets .= "\$(BIN_D)${o}\$(E_PREMAIN_DSO)$exep" if ($fips);
403
404if ($fips)
405 {
406 if (!$shlib)
407 {
408 $ex_build_targets .= " \$(LIB_D)$o$crypto_compat \$(PREMAIN_DSO_EXE)";
409 $ex_l_libs .= " \$(O_FIPSCANISTER)";
410 }
411 if ($fipslibdir eq "")
412 {
413 open (IN, "util/fipslib_path.txt") || fipslib_error();
414 $fipslibdir = <IN>;
415 chomp $fipslibdir;
416 close IN;
417 }
418 fips_check_files($fipslibdir,
419 "fipscanister.o", "fipscanister.o.sha1",
420 "fips_premain.c", "fips_premain.c.sha1");
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
442if ($platform eq "VC-CE")
443 {
444 $defs.= <<"EOF";
445!INCLUDE <\$(WCECOMPAT)/wcedefs.mak>
446
447EOF
448 $ex_libs .= " $zlib_lib" if $zlib_opt == 1;
449 }
450
451$defs.= <<"EOF";
452INSTALLTOP=$INSTALLTOP
453
454# Set your compiler options
455PLATFORM=$platform
456CC=$bin_dir${cc}
457CFLAG=$cflags
458APP_CFLAG=$app_cflag
459LIB_CFLAG=$lib_cflag
460SHLIB_CFLAG=$shl_cflag
461APP_EX_OBJ=$app_ex_obj
462SHLIB_EX_OBJ=$shlib_ex_obj
463# add extra libraries to this define, for solaris -lsocket -lnsl would
464# be added
465EX_LIBS=$ex_libs
466
467# The OpenSSL directory
468SRC_D=$src_dir
469
470LINK=$link
471PERL=perl
472FIPSLINK=\$(PERL) util${o}fipslink.pl
473LFLAGS=$lflags
474
475BN_ASM_OBJ=$bn_asm_obj
476BN_ASM_SRC=$bn_asm_src
477BNCO_ASM_OBJ=$bnco_asm_obj
478BNCO_ASM_SRC=$bnco_asm_src
479DES_ENC_OBJ=$des_enc_obj
480DES_ENC_SRC=$des_enc_src
481BF_ENC_OBJ=$bf_enc_obj
482BF_ENC_SRC=$bf_enc_src
483CAST_ENC_OBJ=$cast_enc_obj
484CAST_ENC_SRC=$cast_enc_src
485RC4_ENC_OBJ=$rc4_enc_obj
486RC4_ENC_SRC=$rc4_enc_src
487RC5_ENC_OBJ=$rc5_enc_obj
488RC5_ENC_SRC=$rc5_enc_src
489MD5_ASM_OBJ=$md5_asm_obj
490MD5_ASM_SRC=$md5_asm_src
491SHA1_ASM_OBJ=$sha1_asm_obj
492SHA1_ASM_SRC=$sha1_asm_src
493RMD160_ASM_OBJ=$rmd160_asm_obj
494RMD160_ASM_SRC=$rmd160_asm_src
495
496# The output directory for everything intersting
497OUT_D=$out_dir
498# The output directory for all the temporary muck
499TMP_D=$tmp_dir
500# The output directory for the header files
501INC_D=$inc_dir
502INCO_D=$inc_dir${o}openssl
503
504# Directory containing FIPS module
505
506
507CP=$cp
508RM=$rm
509RANLIB=$ranlib
510MKDIR=$mkdir
511MKLIB=$bin_dir$mklib
512MLFLAGS=$mlflags
513ASM=$bin_dir$asm
514MKCANISTER=$mkcanister
515
516# FIPS validated module and support file locations
517
518E_PREMAIN_DSO=fips_premain_dso
519
520FIPSLIB_D=$fipslibdir
521BASEADDR=$baseaddr
522FIPS_PREMAIN_SRC=$fips_premain_c_path
523O_FIPSCANISTER=$fips_canister_path
524FIPS_SHA1_EXE=$fips_sha1_exe_path
525PREMAIN_DSO_EXE=$fips_premain_dso_exe_path
526
527######################################################
528# You should not need to touch anything below this point
529######################################################
530
531E_EXE=openssl
532SSL=$ssl
533CRYPTO=$crypto
534
535# BIN_D - Binary output directory
536# TEST_D - Binary test file output directory
537# LIB_D - library output directory
538# Note: if you change these point to different directories then uncomment out
539# the lines around the 'NB' comment below.
540#
541BIN_D=\$(OUT_D)
542TEST_D=\$(OUT_D)
543LIB_D=\$(OUT_D)
544
545# INCL_D - local library directory
546# OBJ_D - temp object file directory
547OBJ_D=\$(TMP_D)
548INCL_D=\$(TMP_D)
549
550O_SSL= \$(LIB_D)$o$plib\$(SSL)$shlibp
551O_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$shlibp
552SO_SSL= $plib\$(SSL)$so_shlibp
553SO_CRYPTO= $plib\$(CRYPTO)$so_shlibp
554L_SSL= \$(LIB_D)$o$plib\$(SSL)$libp
555L_CRYPTO= \$(LIB_D)$o$plib\$(CRYPTO)$libp
556
557L_LIBS= \$(L_SSL) \$(L_CRYPTO) $ex_l_libs
558
559######################################################
560# Don't touch anything below this point
561######################################################
562
563INC=-I\$(INC_D) -I\$(INCL_D)
564APP_CFLAGS=\$(INC) \$(CFLAG) \$(APP_CFLAG)
565LIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG)
566SHLIB_CFLAGS=\$(INC) \$(CFLAG) \$(LIB_CFLAG) \$(SHLIB_CFLAG)
567LIBS_DEP=\$(O_CRYPTO) \$(O_SSL) $ex_libs_dep
568
569#############################################
570EOF
571
572$rules=<<"EOF";
573all: banner \$(TMP_D) \$(BIN_D) \$(TEST_D) \$(LIB_D) \$(INCO_D) headers \$(FIPS_SHA1_EXE) lib exe $ex_build_targets
574
575banner:
576$banner
577
578\$(TMP_D):
579 \$(MKDIR) \$(TMP_D)
580# NB: uncomment out these lines if BIN_D, TEST_D and LIB_D are different
581#\$(BIN_D):
582# \$(MKDIR) \$(BIN_D)
583#
584#\$(TEST_D):
585# \$(MKDIR) \$(TEST_D)
586
587\$(LIB_D):
588 \$(MKDIR) \$(LIB_D)
589
590\$(INCO_D): \$(INC_D)
591 \$(MKDIR) \$(INCO_D)
592
593\$(INC_D):
594 \$(MKDIR) \$(INC_D)
595
596headers: \$(HEADER) \$(EXHEADER)
597 @
598
599lib: \$(LIBS_DEP)
600
601exe: \$(T_EXE) \$(BIN_D)$o\$(E_EXE)$exep
602
603install:
604 \$(MKDIR) \$(INSTALLTOP)
605 \$(MKDIR) \$(INSTALLTOP)${o}bin
606 \$(MKDIR) \$(INSTALLTOP)${o}include
607 \$(MKDIR) \$(INSTALLTOP)${o}include${o}openssl
608 \$(MKDIR) \$(INSTALLTOP)${o}lib
609 \$(CP) \$(INCO_D)${o}*.\[ch\] \$(INSTALLTOP)${o}include${o}openssl
610 \$(CP) \$(BIN_D)$o\$(E_EXE)$exep \$(INSTALLTOP)${o}bin
611 \$(CP) \$(O_SSL) \$(INSTALLTOP)${o}lib
612 \$(CP) \$(O_CRYPTO) \$(INSTALLTOP)${o}lib
613
614clean:
615 \$(RM) \$(TMP_D)$o*.*
616
617vclean:
618 \$(RM) \$(TMP_D)$o*.*
619 \$(RM) \$(OUT_D)$o*.*
620
621EOF
622
623my $platform_cpp_symbol = "MK1MF_PLATFORM_$platform";
624$platform_cpp_symbol =~ s/-/_/g;
625if (open(IN,"crypto/buildinf.h"))
626 {
627 # Remove entry for this platform in existing file buildinf.h.
628
629 my $old_buildinf_h = "";
630 while (<IN>)
631 {
632 if (/^\#ifdef $platform_cpp_symbol$/)
633 {
634 while (<IN>) { last if (/^\#endif/); }
635 }
636 else
637 {
638 $old_buildinf_h .= $_;
639 }
640 }
641 close(IN);
642
643 open(OUT,">crypto/buildinf.h") || die "Can't open buildinf.h";
644 print OUT $old_buildinf_h;
645 close(OUT);
646 }
647
648open (OUT,">>crypto/buildinf.h") || die "Can't open buildinf.h";
649printf OUT <<EOF;
650#ifdef $platform_cpp_symbol
651 /* auto-generated/updated by util/mk1mf.pl for crypto/cversion.c */
652 #define CFLAGS "$cc $cflags"
653 #define PLATFORM "$platform"
654EOF
655printf OUT " #define DATE \"%s\"\n", scalar gmtime();
656printf OUT "#endif\n";
657close(OUT);
658
659# Strip of trailing ' '
660foreach (keys %lib_obj) { $lib_obj{$_}=&clean_up_ws($lib_obj{$_}); }
661$test=&clean_up_ws($test);
662$e_exe=&clean_up_ws($e_exe);
663$exheader=&clean_up_ws($exheader);
664$header=&clean_up_ws($header);
665
666# First we strip the exheaders from the headers list
667foreach (split(/\s+/,$exheader)){ $h{$_}=1; }
668foreach (split(/\s+/,$header)) { $h.=$_." " unless $h{$_}; }
669chop($h); $header=$h;
670
671$defs.=&do_defs("HEADER",$header,"\$(INCL_D)",".h");
672$rules.=&do_copy_rule("\$(INCL_D)",$header,".h");
673
674$defs.=&do_defs("EXHEADER",$exheader,"\$(INCO_D)",".h");
675$rules.=&do_copy_rule("\$(INCO_D)",$exheader,".h");
676
677$defs.=&do_defs("T_OBJ",$test,"\$(OBJ_D)",$obj);
678$rules.=&do_compile_rule("\$(OBJ_D)",$test,"\$(APP_CFLAGS)");
679
680$defs.=&do_defs("E_OBJ",$e_exe,"\$(OBJ_D)",$obj);
681$rules.=&do_compile_rule("\$(OBJ_D)",$e_exe,'-DMONOLITH $(APP_CFLAGS)');
682
683# Special case rules for fips_start and fips_end fips_premain_dso
684
685if ($fips)
686 {
687 if ($fips_canister_build)
688 {
689 $rules.=&cc_compile_target("\$(OBJ_D)${o}fips_start$obj",
690 "fips-1.0${o}fips_canister.c",
691 "-DFIPS_START \$(SHLIB_CFLAGS)");
692 $rules.=&cc_compile_target("\$(OBJ_D)${o}fips_end$obj",
693 "fips-1.0${o}fips_canister.c", "\$(SHLIB_CFLAGS)");
694 }
695 $rules.=&cc_compile_target("\$(OBJ_D)${o}fips_standalone_sha1$obj",
696 "fips-1.0${o}sha${o}fips_standalone_sha1.c",
697 "\$(SHLIB_CFLAGS)");
698 $rules.=&cc_compile_target("\$(OBJ_D)${o}fips_sha1dgst$obj",
699 "fips-1.0${o}sha${o}fips_sha1dgst.c",
700 "\$(SHLIB_CFLAGS)") unless $fips_canister_build;
701 $rules.=&cc_compile_target("\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj",
702 "fips-1.0${o}fips_premain.c",
703 "-DFINGERPRINT_PREMAIN_DSO_LOAD \$(SHLIB_CFLAGS)");
704 }
705
706foreach (values %lib_nam)
707 {
708 $lib_obj=$lib_obj{$_};
709 local($slib)=$shlib;
710
711 if (($_ eq "SSL") && $no_ssl2 && $no_ssl3)
712 {
713 $rules.="\$(O_SSL):\n\n";
714 next;
715 }
716
717 if (($bn_asm_obj ne "") && ($_ eq "CRYPTO"))
718 {
719 $lib_obj =~ s/\s\S*\/bn_asm\S*/ \$(BN_ASM_OBJ)/;
720 $rules.=&do_asm_rule($bn_asm_obj,$bn_asm_src);
721 }
722 if (($bnco_asm_obj ne "") && ($_ eq "CRYPTO"))
723 {
724 $lib_obj .= "\$(BNCO_ASM_OBJ)";
725 $rules.=&do_asm_rule($bnco_asm_obj,$bnco_asm_src);
726 }
727 if (($des_enc_obj ne "") && ($_ eq "CRYPTO"))
728 {
729 $lib_obj =~ s/\s\S*des_enc\S*/ \$(DES_ENC_OBJ)/;
730 $lib_obj =~ s/\s\S*\/fcrypt_b\S*\s*/ /;
731 $rules.=&do_asm_rule($des_enc_obj,$des_enc_src);
732 }
733 if (($bf_enc_obj ne "") && ($_ eq "CRYPTO"))
734 {
735 $lib_obj =~ s/\s\S*\/bf_enc\S*/ \$(BF_ENC_OBJ)/;
736 $rules.=&do_asm_rule($bf_enc_obj,$bf_enc_src);
737 }
738 if (($cast_enc_obj ne "") && ($_ eq "CRYPTO"))
739 {
740 $lib_obj =~ s/(\s\S*\/c_enc\S*)/ \$(CAST_ENC_OBJ)/;
741 $rules.=&do_asm_rule($cast_enc_obj,$cast_enc_src);
742 }
743 if (($rc4_enc_obj ne "") && ($_ eq "CRYPTO"))
744 {
745 $lib_obj =~ s/\s\S*\/rc4_enc\S*/ \$(RC4_ENC_OBJ)/;
746 $rules.=&do_asm_rule($rc4_enc_obj,$rc4_enc_src);
747 }
748 if (($rc5_enc_obj ne "") && ($_ eq "CRYPTO"))
749 {
750 $lib_obj =~ s/\s\S*\/rc5_enc\S*/ \$(RC5_ENC_OBJ)/;
751 $rules.=&do_asm_rule($rc5_enc_obj,$rc5_enc_src);
752 }
753 if (($md5_asm_obj ne "") && ($_ eq "CRYPTO"))
754 {
755 $lib_obj =~ s/\s(\S*\/md5_dgst\S*)/ $1 \$(MD5_ASM_OBJ)/;
756 $rules.=&do_asm_rule($md5_asm_obj,$md5_asm_src);
757 }
758 if (($sha1_asm_obj ne "") && ($_ eq "CRYPTO"))
759 {
760 $lib_obj =~ s/\s(\S*\/sha1dgst\S*)/ $1 \$(SHA1_ASM_OBJ)/;
761 $rules.=&do_asm_rule($sha1_asm_obj,$sha1_asm_src);
762 }
763 if (($rmd160_asm_obj ne "") && ($_ eq "CRYPTO"))
764 {
765 $lib_obj =~ s/\s(\S*\/rmd_dgst\S*)/ $1 \$(RMD160_ASM_OBJ)/;
766 $rules.=&do_asm_rule($rmd160_asm_obj,$rmd160_asm_src);
767 }
768 $defs.=&do_defs(${_}."OBJ",$lib_obj,"\$(OBJ_D)",$obj);
769 $lib=($slib)?" \$(SHLIB_CFLAGS)".$shlib_ex_cflags{$_}:" \$(LIB_CFLAGS)";
770 $rules.=&do_compile_rule("\$(OBJ_D)",$lib_obj{$_},$lib);
771 }
772
773$defs.=&do_defs("T_EXE",$test,"\$(TEST_D)",$exep);
774foreach (split(/\s+/,$test))
775 {
776 $t=&bname($_);
777 $tt="\$(OBJ_D)${o}$t${obj}";
778 $rules.=&do_link_rule("\$(TEST_D)$o$t$exep",$tt,"\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)");
779 }
780
781$rules.= &do_lib_rule("\$(SSLOBJ)","\$(O_SSL)",$ssl,$shlib,"\$(SO_SSL)");
782
783
784if ($fips)
785 {
786 if ($shlib)
787 {
788 $rules.= &do_lib_rule("\$(CRYPTOOBJ) \$(O_FIPSCANISTER)",
789 "\$(O_CRYPTO)",
790 "$crypto",
791 $shlib, "\$(SO_CRYPTO)", "\$(BASEADDR)");
792 }
793 else
794 {
795 $rules.= &do_lib_rule("\$(CRYPTOOBJ)",
796 "\$(O_CRYPTO)",$crypto,$shlib,"\$(SO_CRYPTO)", "");
797 $rules.= &do_lib_rule("\$(CRYPTOOBJ) \$(O_FIPSCANISTER)",
798 "\$(LIB_D)$o$crypto_compat",$crypto,$shlib,"\$(SO_CRYPTO)", "");
799 }
800 }
801 else
802 {
803 $rules.= &do_lib_rule("\$(CRYPTOOBJ)","\$(O_CRYPTO)",$crypto,$shlib,
804 "\$(SO_CRYPTO)");
805 }
806
807
808if ($fips)
809 {
810 $rules.= &do_rlink_rule("\$(O_FIPSCANISTER)", "\$(OBJ_D)${o}fips_start$obj \$(FIPSOBJ) \$(OBJ_D)${o}fips_end$obj", "\$(FIPSLIB_D)${o}fips_standalone_sha1$exep", "") if $fips_canister_build;
811 $rules.=&do_link_rule("\$(PREMAIN_DSO_EXE)","\$(OBJ_D)${o}\$(E_PREMAIN_DSO)$obj \$(CRYPTOOBJ) \$(O_FIPSCANISTER)","","\$(EX_LIBS)", 1);
812
813 $rules.=&do_link_rule("\$(FIPS_SHA1_EXE)","\$(OBJ_D)${o}fips_standalone_sha1$obj \$(OBJ_D)${o}fips_sha1dgst$obj","","", 1);
814 }
815
816 $rules.=&do_link_rule("\$(BIN_D)$o\$(E_EXE)$exep","\$(E_OBJ)","\$(LIBS_DEP)","\$(L_LIBS) \$(EX_LIBS)",0);
817
818print $defs;
819
820if ($platform eq "linux-elf") {
821 print <<"EOF";
822# Generate perlasm output files
823%.cpp:
824 (cd \$(\@D)/..; PERL=perl make -f Makefile asm/\$(\@F))
825EOF
826}
827print "###################################################################\n";
828print $rules;
829
830###############################################
831# strip off any trailing .[och] and append the relative directory
832# also remembering to do nothing if we are in one of the dropped
833# directories
834sub var_add
835 {
836 local($dir,$val)=@_;
837 local(@a,$_,$ret);
838
839 return("") if $no_engine && $dir =~ /\/engine/;
840 return("") if $no_hw && $dir =~ /\/hw/;
841 return("") if $no_idea && $dir =~ /\/idea/;
842 return("") if $no_aes && $dir =~ /\/aes/;
843 return("") if $no_rc2 && $dir =~ /\/rc2/;
844 return("") if $no_rc4 && $dir =~ /\/rc4/;
845 return("") if $no_rc5 && $dir =~ /\/rc5/;
846 return("") if $no_rsa && $dir =~ /\/rsa/;
847 return("") if $no_rsa && $dir =~ /^rsaref/;
848 return("") if $no_dsa && $dir =~ /\/dsa/;
849 return("") if $no_dh && $dir =~ /\/dh/;
850 return("") if $no_ec && $dir =~ /\/ec/;
851 if ($no_des && $dir =~ /\/des/)
852 {
853 if ($val =~ /read_pwd/)
854 { return("$dir/read_pwd "); }
855 else
856 { return(""); }
857 }
858 return("") if $no_mdc2 && $dir =~ /\/mdc2/;
859 return("") if $no_sock && $dir =~ /\/proxy/;
860 return("") if $no_bf && $dir =~ /\/bf/;
861 return("") if $no_cast && $dir =~ /\/cast/;
862
863 $val =~ s/^\s*(.*)\s*$/$1/;
864 @a=split(/\s+/,$val);
865 grep(s/\.[och]$//,@a);
866
867 @a=grep(!/^e_.*_3d$/,@a) if $no_des;
868 @a=grep(!/^e_.*_d$/,@a) if $no_des;
869 @a=grep(!/^e_.*_ae$/,@a) if $no_idea;
870 @a=grep(!/^e_.*_i$/,@a) if $no_aes;
871 @a=grep(!/^e_.*_r2$/,@a) if $no_rc2;
872 @a=grep(!/^e_.*_r5$/,@a) if $no_rc5;
873 @a=grep(!/^e_.*_bf$/,@a) if $no_bf;
874 @a=grep(!/^e_.*_c$/,@a) if $no_cast;
875 @a=grep(!/^e_rc4$/,@a) if $no_rc4;
876
877 @a=grep(!/(^s2_)|(^s23_)/,@a) if $no_ssl2;
878 @a=grep(!/(^s3_)|(^s23_)/,@a) if $no_ssl3;
879
880 @a=grep(!/(_sock$)|(_acpt$)|(_conn$)|(^pxy_)/,@a) if $no_sock;
881
882 @a=grep(!/(^md2)|(_md2$)/,@a) if $no_md2;
883 @a=grep(!/(^md4)|(_md4$)/,@a) if $no_md4;
884 @a=grep(!/(^md5)|(_md5$)/,@a) if $no_md5;
885 @a=grep(!/(rmd)|(ripemd)/,@a) if $no_ripemd;
886
887 @a=grep(!/(^d2i_r_)|(^i2d_r_)/,@a) if $no_rsa;
888 @a=grep(!/(^p_open$)|(^p_seal$)/,@a) if $no_rsa;
889 @a=grep(!/(^pem_seal$)/,@a) if $no_rsa;
890
891 @a=grep(!/(m_dss$)|(m_dss1$)/,@a) if $no_dsa;
892 @a=grep(!/(^d2i_s_)|(^i2d_s_)|(_dsap$)/,@a) if $no_dsa;
893
894 @a=grep(!/^n_pkey$/,@a) if $no_rsa || $no_rc4;
895
896 @a=grep(!/_dhp$/,@a) if $no_dh;
897
898 @a=grep(!/(^sha[^1])|(_sha$)|(m_dss$)/,@a) if $no_sha;
899 @a=grep(!/(^sha1)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
900 @a=grep(!/_mdc2$/,@a) if $no_mdc2;
901
902 @a=grep(!/^engine$/,@a) if $no_engine;
903 @a=grep(!/^hw$/,@a) if $no_hw;
904 @a=grep(!/(^rsa$)|(^genrsa$)/,@a) if $no_rsa;
905 @a=grep(!/(^dsa$)|(^gendsa$)|(^dsaparam$)/,@a) if $no_dsa;
906 @a=grep(!/^gendsa$/,@a) if $no_sha1;
907 @a=grep(!/(^dh$)|(^gendh$)/,@a) if $no_dh;
908
909 @a=grep(!/(^dh)|(_sha1$)|(m_dss1$)/,@a) if $no_sha1;
910
911 grep($_="$dir/$_",@a);
912 @a=grep(!/(^|\/)s_/,@a) if $no_sock;
913 @a=grep(!/(^|\/)bio_sock/,@a) if $no_sock;
914 $ret=join(' ',@a)." ";
915 return($ret);
916 }
917
918# change things so that each 'token' is only separated by one space
919sub clean_up_ws
920 {
921 local($w)=@_;
922
923 $w =~ s/^\s*(.*)\s*$/$1/;
924 $w =~ s/\s+/ /g;
925 return($w);
926 }
927
928sub do_defs
929 {
930 local($var,$files,$location,$postfix)=@_;
931 local($_,$ret,$pf);
932 local(*OUT,$tmp,$t);
933
934 $files =~ s/\//$o/g if $o ne '/';
935 $ret="$var=";
936 $n=1;
937 $Vars{$var}.="";
938 foreach (split(/ /,$files))
939 {
940 $orig=$_;
941 $_=&bname($_) unless /^\$/;
942 if ($n++ == 2)
943 {
944 $n=0;
945 $ret.="\\\n\t";
946 }
947 if (($_ =~ /bss_file/) && ($postfix eq ".h"))
948 { $pf=".c"; }
949 else { $pf=$postfix; }
950 if ($_ =~ /BN_ASM/) { $t="$_ "; }
951 elsif ($_ =~ /BNCO_ASM/){ $t="$_ "; }
952 elsif ($_ =~ /DES_ENC/) { $t="$_ "; }
953 elsif ($_ =~ /BF_ENC/) { $t="$_ "; }
954 elsif ($_ =~ /CAST_ENC/){ $t="$_ "; }
955 elsif ($_ =~ /RC4_ENC/) { $t="$_ "; }
956 elsif ($_ =~ /RC5_ENC/) { $t="$_ "; }
957 elsif ($_ =~ /MD5_ASM/) { $t="$_ "; }
958 elsif ($_ =~ /SHA1_ASM/){ $t="$_ "; }
959 elsif ($_ =~ /RMD160_ASM/){ $t="$_ "; }
960 else { $t="$location${o}$_$pf "; }
961
962 $Vars{$var}.="$t ";
963 $ret.=$t;
964 }
965 chop($ret);
966 $ret.="\n\n";
967 return($ret);
968 }
969
970# return the name with the leading path removed
971sub bname
972 {
973 local($ret)=@_;
974 $ret =~ s/^.*[\\\/]([^\\\/]+)$/$1/;
975 return($ret);
976 }
977
978
979##############################################################
980# do a rule for each file that says 'compile' to new direcory
981# compile the files in '$files' into $to
982sub do_compile_rule
983 {
984 local($to,$files,$ex)=@_;
985 local($ret,$_,$n);
986
987 $files =~ s/\//$o/g if $o ne '/';
988 foreach (split(/\s+/,$files))
989 {
990 $n=&bname($_);
991 $ret.=&cc_compile_target("$to${o}$n$obj","${_}.c",$ex)
992 }
993 return($ret);
994 }
995
996##############################################################
997# do a rule for each file that says 'compile' to new direcory
998sub cc_compile_target
999 {
1000 local($target,$source,$ex_flags)=@_;
1001 local($ret);
1002
1003 $ex_flags.=" -DMK1MF_BUILD -D$platform_cpp_symbol" if ($source =~ /cversion/);
1004 $target =~ s/\//$o/g if $o ne "/";
1005 $source =~ s/\//$o/g if $o ne "/";
1006 $ret ="$target: \$(SRC_D)$o$source\n\t";
1007 $ret.="\$(CC) ${ofile}$target $ex_flags -c \$(SRC_D)$o$source\n\n";
1008 return($ret);
1009 }
1010
1011##############################################################
1012sub do_asm_rule
1013 {
1014 local($target,$src)=@_;
1015 local($ret,@s,@t,$i);
1016
1017 $target =~ s/\//$o/g if $o ne "/";
1018 $src =~ s/\//$o/g if $o ne "/";
1019
1020 @s=split(/\s+/,$src);
1021 @t=split(/\s+/,$target);
1022
1023 for ($i=0; $i<=$#s; $i++)
1024 {
1025 $ret.="$t[$i]: $s[$i]\n";
1026 $ret.="\t\$(ASM) $afile$t[$i] \$(SRC_D)$o$s[$i]\n\n";
1027 }
1028 return($ret);
1029 }
1030
1031sub do_shlib_rule
1032 {
1033 local($n,$def)=@_;
1034 local($ret,$nn);
1035 local($t);
1036
1037 ($nn=$n) =~ tr/a-z/A-Z/;
1038 $ret.="$n.dll: \$(${nn}OBJ)\n";
1039 if ($vc && $w32)
1040 {
1041 $ret.="\t\$(MKSHLIB) $efile$n.dll $def @<<\n \$(${nn}OBJ_F)\n<<\n";
1042 }
1043 $ret.="\n";
1044 return($ret);
1045 }
1046
1047# do a rule for each file that says 'copy' to new direcory on change
1048sub do_copy_rule
1049 {
1050 local($to,$files,$p)=@_;
1051 local($ret,$_,$n,$pp);
1052
1053 $files =~ s/\//$o/g if $o ne '/';
1054 foreach (split(/\s+/,$files))
1055 {
1056 $n=&bname($_);
1057 if ($n =~ /bss_file/)
1058 { $pp=".c"; }
1059 else { $pp=$p; }
1060 $ret.="$to${o}$n$pp: \$(SRC_D)$o$_$pp\n\t\$(CP) \$(SRC_D)$o$_$pp $to${o}$n$pp\n\n";
1061 }
1062 return($ret);
1063 }
1064
1065sub read_options
1066 {
1067 if (/^no-rc2$/) { $no_rc2=1; }
1068 elsif (/^no-rc4$/) { $no_rc4=1; }
1069 elsif (/^no-rc5$/) { $no_rc5=1; }
1070 elsif (/^no-idea$/) { $no_idea=1; }
1071 elsif (/^no-aes$/) { $no_aes=1; }
1072 elsif (/^no-des$/) { $no_des=1; }
1073 elsif (/^no-bf$/) { $no_bf=1; }
1074 elsif (/^no-cast$/) { $no_cast=1; }
1075 elsif (/^no-md2$/) { $no_md2=1; }
1076 elsif (/^no-md4$/) { $no_md4=1; }
1077 elsif (/^no-md5$/) { $no_md5=1; }
1078 elsif (/^no-sha$/) { $no_sha=1; }
1079 elsif (/^no-sha1$/) { $no_sha1=1; }
1080 elsif (/^no-ripemd$/) { $no_ripemd=1; }
1081 elsif (/^no-mdc2$/) { $no_mdc2=1; }
1082 elsif (/^no-patents$/) { $no_rc2=$no_rc4=$no_rc5=$no_idea=$no_rsa=1; }
1083 elsif (/^no-rsa$/) { $no_rsa=1; }
1084 elsif (/^no-dsa$/) { $no_dsa=1; }
1085 elsif (/^no-dh$/) { $no_dh=1; }
1086 elsif (/^no-hmac$/) { $no_hmac=1; }
1087 elsif (/^no-aes$/) { $no_aes=1; }
1088 elsif (/^no-asm$/) { $no_asm=1; }
1089 elsif (/^nasm$/) { $nasm=1; }
1090 elsif (/^gaswin$/) { $gaswin=1; }
1091 elsif (/^no-ssl2$/) { $no_ssl2=1; }
1092 elsif (/^no-ssl3$/) { $no_ssl3=1; }
1093 elsif (/^no-err$/) { $no_err=1; }
1094 elsif (/^no-sock$/) { $no_sock=1; }
1095 elsif (/^no-krb5$/) { $no_krb5=1; }
1096 elsif (/^no-ec$/) { $no_ec=1; }
1097 elsif (/^no-engine$/) { $no_engine=1; }
1098 elsif (/^no-hw$/) { $no_hw=1; }
1099
1100 elsif (/^just-ssl$/) { $no_rc2=$no_idea=$no_des=$no_bf=$no_cast=1;
1101 $no_md2=$no_sha=$no_mdc2=$no_dsa=$no_dh=1;
1102 $no_ssl2=$no_err=$no_ripemd=$no_rc5=1;
1103 $no_aes=1; }
1104
1105 elsif (/^rsaref$/) { }
1106 elsif (/^fips$/) { $fips=1; }
1107 elsif (/^gcc$/) { $gcc=1; }
1108 elsif (/^debug$/) { $debug=1; }
1109 elsif (/^profile$/) { $profile=1; }
1110 elsif (/^shlib$/) { $shlib=1; }
1111 elsif (/^dll$/) { $shlib=1; }
1112 elsif (/^shared$/) { } # We just need to ignore it for now...
1113 elsif (/^zlib$/) { $zlib_opt = 1 if $zlib_opt == 0 }
1114 elsif (/^zlib-dynamic$/){ $zlib_opt = 2; }
1115 elsif (/^--with-krb5-flavor=(.*)$/)
1116 {
1117 my $krb5_flavor = $1;
1118 if ($krb5_flavor =~ /^force-[Hh]eimdal$/)
1119 {
1120 $xcflags="-DKRB5_HEIMDAL $xcflags";
1121 }
1122 elsif ($krb5_flavor =~ /^MIT/i)
1123 {
1124 $xcflags="-DKRB5_MIT $xcflags";
1125 if ($krb5_flavor =~ /^MIT[._-]*1[._-]*[01]/i)
1126 {
1127 $xcflags="-DKRB5_MIT_OLD11 $xcflags"
1128 }
1129 }
1130 }
1131 elsif (/^([^=]*)=(.*)$/){ $VARS{$1}=$2; }
1132 elsif (/^-[lL].*$/) { $l_flags.="$_ "; }
1133 elsif ((!/^-help/) && (!/^-h/) && (!/^-\?/) && /^-.*$/)
1134 { $c_flags.="$_ "; }
1135 else { return(0); }
1136 return(1);
1137 }
1138
1139sub fipslib_error
1140 {
1141 print STDERR "***FIPS module directory sanity check failed***\n";
1142 print STDERR "FIPS module build failed, or was deleted\n";
1143 print STDERR "Please rebuild FIPS module.\n";
1144 exit 1;
1145 }
1146
1147sub fips_check_files
1148 {
1149 my $dir = shift @_;
1150 my $ret = 1;
1151 if (!-d $dir)
1152 {
1153 print STDERR "FIPS module directory $dir does not exist\n";
1154 fipslib_error();
1155 }
1156 foreach (@_)
1157 {
1158 if (!-f "$dir${o}$_")
1159 {
1160 print STDERR "FIPS module file $_ does not exist!\n";
1161 $ret = 0;
1162 }
1163 }
1164 fipslib_error() if ($ret == 0);
1165 }