3 # unix.pl - the standard unix makefile stuff.
16 { $cflags="-g2 -ggdb"; }
18 { $cflags="-O3 -fomit-frame-pointer"; }
39 # static library stuff
42 $ranlib=&which("ranlib") or $ranlib="true";
58 'md5-x86_64' => 'crypto/md5',
59 'x86_64-mont' => 'crypto/bn',
60 'x86_64-mont5' => 'crypto/bn',
61 'x86_64-gf2m' => 'crypto/bn',
62 'modexp512-x86_64' => 'crypto/bn',
63 'aes-x86_64' => 'crypto/aes',
64 'vpaes-x86_64' => 'crypto/aes',
65 'bsaes-x86_64' => 'crypto/aes',
66 'aesni-x86_64' => 'crypto/aes',
67 'aesni-sha1-x86_64' => 'crypto/aes',
68 'sha1-x86_64' => 'crypto/sha',
69 'e_padlock-x86_64' => 'engines',
70 'rc4-x86_64' => 'crypto/rc4',
71 'rc4-md5-x86_64' => 'crypto/rc4',
72 'ghash-x86_64' => 'crypto/modes',
73 'aesni-gcm-x86_64' => 'crypto/modes',
76 # If I were feeling more clever, these could probably be extracted
78 sub platform_perlasm_compile_target
80 local($target, $source, $bname) = @_;
84 if ($target eq "\$(OBJ_D)/$p.o")
87 \$(TMP_D)/$p.s: $perl1{$p}/asm/$p.pl
88 \$(PERL) $perl1{$p}/asm/$p.pl \$(PERLASM_SCHEME) > \$@
92 if ($target eq '$(OBJ_D)/x86_64cpuid.o')
95 $(TMP_D)/x86_64cpuid.s: crypto/x86_64cpuid.pl
96 $(PERL) crypto/x86_64cpuid.pl $(PERLASM_SCHEME) > $@
99 elsif ($target eq '$(OBJ_D)/sha256-x86_64.o')
102 $(TMP_D)/sha256-x86_64.s: crypto/sha/asm/sha512-x86_64.pl
103 $(PERL) crypto/sha/asm/sha512-x86_64.pl $(PERLASM_SCHEME) $@
106 elsif ($target eq '$(OBJ_D)/sha512-x86_64.o')
109 $(TMP_D)/sha512-x86_64.s: crypto/sha/asm/sha512-x86_64.pl
110 $(PERL) crypto/sha/asm/sha512-x86_64.pl $(PERLASM_SCHEME) $@
113 elsif ($target eq '$(OBJ_D)/sha512-x86_64.o')
116 $(TMP_D)/sha512-x86_64.s: crypto/sha/asm/sha512-x86_64.pl
117 $(PERL) crypto/sha/asm/sha512-x86_64.pl $(PERLASM_SCHEME) $@
124 sub special_compile_target
128 if ($target eq 'crypto/bn/x86_64-gcc')
131 \$(TMP_D)/x86_64-gcc.o: crypto/bn/asm/x86_64-gcc.c
132 \$(CC) \$(CFLAGS) -c -o \$@ crypto/bn/asm/x86_64-gcc.c
140 local($obj,$target,$name,$shlib)=@_;
141 local($ret,$_,$Name);
143 $target =~ s/\//$o/g if $o ne '/';
145 ($Name=$name) =~ tr/a-z/A-Z/;
147 $ret.="$target: \$(${Name}OBJ)\n";
148 $ret.="\t\$(RM) $target\n";
149 $ret.="\t\$(MKLIB) $target \$(${Name}OBJ)\n";
150 $ret.="\t\$(RANLIB) $target\n\n";
155 local($target,$files,$dep_libs,$libs)=@_;
158 $file =~ s/\//$o/g if $o ne '/';
160 $ret.="$target: $files $dep_libs\n";
161 $ret.="\t\$(LINK) ${efile}$target \$(LFLAGS) $files $libs\n\n";
169 foreach $path (split /:/, $ENV{PATH})
171 if (-x "$path/$name")
173 return "$path/$name";
180 my ($str, $tests) = @_;
182 foreach my $t (keys %$tests)
184 $str =~ s/(\.\/)?\$\($t\)/\$(TEST_D)\/$tests->{$t}/g;
194 my @t = split(/\s+/, $str);
198 $str .= ' ' if $str ne '';
199 if ($t =~ /^[^\/]+$/)
201 $str .= '$(TEST_D)/' . $t;
216 # Compatible with -j...
217 $str =~ s/^(\s+@?)/$1cd \$(TEST_D) && /;
220 # Compatible with not -j.
221 my @t = split("\n", $str);
231 $t =~ s/^@/\@cd \$(TEST_D) && /;
233 elsif ($t !~ /^\s*#/)
235 $t = 'cd $(TEST_D) && ' . $t;
246 my ($sed, $src, @targets) = @_;
249 foreach my $t (@targets)
251 # Copy first so we get file modes...
252 $s .= "\$(TEST_D)/$t: \$(SRC_D)/$src/$t\n\tcp \$(SRC_D)/$src/$t \$(TEST_D)/$t\n";
253 $s .= "\tsed -e 's/\\.\\.\\/apps/..\\/\$(OUT_D)/' -e 's/\\.\\.\\/util/..\\/\$(TEST_D)/' < \$(SRC_D)/$src/$t > \$(TEST_D)/$t\n" if $sed;
263 open(M, $makefile) || die "Can't open $makefile: $!";
268 while (my $line = <M>)
271 while ($line =~ /^(.*)\\$/)
276 if ($line =~ /^alltests:(.*)$/)
278 my @t = split(/\s+/, $1);
282 $alltests{$t} = undef;
286 if (($line =~ /^(?<t>\S+):(?<d>.*)$/ && exists $targets{$1})
287 || $line =~ /^(?<t>test_(ss|gen) .*):(?<d>.*)/)
291 $deps{$t} =~ s/#.*$//;
297 $targets{$t} .= "$line\n";
302 if ($line =~ /^(\S+TEST)=\s*(\S+)$/)
309 delete $alltests{test_jpake} if $no_jpake;
310 delete $targets{test_ige} if $no_ige;
311 delete $alltests{test_md2} if $no_md2;
312 delete $alltests{test_rc5} if $no_rc5;
315 foreach my $t (keys %tests)
317 $tests .= "$t = $tests{$t}\n";
321 foreach my $t (keys %targets)
326 $d =~ s/\.\.\/apps/\$(BIN_D)/g;
327 $d =~ s/\.\.\/util/\$(TEST_D)/g;
328 $d = fixtests($d, \%tests);
331 my $r = $targets{$t};
332 $r =~ s/\.\.\/apps/..\/\$(BIN_D)/g;
333 $r =~ s/\.\.\/util/..\/\$(TEST_D)/g;
334 $r =~ s/\.\.\/(\S+)/\$(SRC_D)\/$1/g;
339 $t =~ s/\s+/ \$(TEST_D)\//g;
341 $each .= "$t: test_scripts $d\n\t\@echo '$t test started'\n$r\t\@echo '$t test done'\n\n";
344 # FIXME: Might be a clever way to figure out what needs copying
345 my @copies = ( 'bctest',
376 my $copies = copy_scripts(1, 'test', @copies);
377 $copies .= copy_scripts(0, 'test', ('smcont.txt'));
379 my @utils = ( 'shlib_wrap.sh',
382 $copies .= copy_scripts(1, 'util', @utils);
384 my @apps = ( 'CA.sh',
387 $copies .= copy_scripts(1, 'apps', @apps);
389 $copies .= copy_scripts(1, 'crypto/evp', ('evptests.txt'));
391 $scripts = "test_scripts: \$(TEST_D)/CA.sh \$(TEST_D)/opensslwrap.sh \$(TEST_D)/openssl.cnf \$(TEST_D)/shlib_wrap.sh ocsp smime\n";
392 $scripts .= "\nocsp:\n\tcp -R test/ocsp-tests \$(TEST_D)\n";
393 $scripts .= "\smime:\n\tcp -R test/smime-certs \$(TEST_D)\n";
395 my $all = 'test: ' . join(' ', keys %alltests);
397 return "$scripts\n$copies\n$tests\n$all\n\n$each";