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',
74 'aesni-sha256-x86_64' => 'crypto/aes',
77 # If I were feeling more clever, these could probably be extracted
79 sub platform_perlasm_compile_target
81 local($target, $source, $bname) = @_;
85 if ($target eq "\$(OBJ_D)/$p.o")
88 \$(TMP_D)/$p.s: $perl1{$p}/asm/$p.pl
89 \$(PERL) $perl1{$p}/asm/$p.pl \$(PERLASM_SCHEME) > \$@
93 if ($target eq '$(OBJ_D)/x86_64cpuid.o')
96 $(TMP_D)/x86_64cpuid.s: crypto/x86_64cpuid.pl
97 $(PERL) crypto/x86_64cpuid.pl $(PERLASM_SCHEME) > $@
100 elsif ($target eq '$(OBJ_D)/sha256-x86_64.o')
103 $(TMP_D)/sha256-x86_64.s: crypto/sha/asm/sha512-x86_64.pl
104 $(PERL) crypto/sha/asm/sha512-x86_64.pl $(PERLASM_SCHEME) $@
107 elsif ($target eq '$(OBJ_D)/sha512-x86_64.o')
110 $(TMP_D)/sha512-x86_64.s: crypto/sha/asm/sha512-x86_64.pl
111 $(PERL) crypto/sha/asm/sha512-x86_64.pl $(PERLASM_SCHEME) $@
114 elsif ($target eq '$(OBJ_D)/sha512-x86_64.o')
117 $(TMP_D)/sha512-x86_64.s: crypto/sha/asm/sha512-x86_64.pl
118 $(PERL) crypto/sha/asm/sha512-x86_64.pl $(PERLASM_SCHEME) $@
125 sub special_compile_target
129 if ($target eq 'crypto/bn/x86_64-gcc')
132 \$(TMP_D)/x86_64-gcc.o: crypto/bn/asm/x86_64-gcc.c
133 \$(CC) \$(CFLAGS) -c -o \$@ crypto/bn/asm/x86_64-gcc.c
141 local($obj,$target,$name,$shlib)=@_;
142 local($ret,$_,$Name);
144 $target =~ s/\//$o/g if $o ne '/';
146 ($Name=$name) =~ tr/a-z/A-Z/;
148 $ret.="$target: \$(${Name}OBJ)\n";
149 $ret.="\t\$(RM) $target\n";
150 $ret.="\t\$(MKLIB) $target \$(${Name}OBJ)\n";
151 $ret.="\t\$(RANLIB) $target\n\n";
156 local($target,$files,$dep_libs,$libs)=@_;
159 $file =~ s/\//$o/g if $o ne '/';
161 $ret.="$target: $files $dep_libs\n";
162 $ret.="\t\$(LINK) ${efile}$target \$(LFLAGS) $files $libs\n\n";
170 foreach $path (split /:/, $ENV{PATH})
172 if (-x "$path/$name")
174 return "$path/$name";
181 my ($str, $tests) = @_;
183 foreach my $t (keys %$tests)
185 $str =~ s/(\.\/)?\$\($t\)/\$(TEST_D)\/$tests->{$t}/g;
193 my ($str, $fakes) = @_;
195 my @t = split(/\s+/, $str);
199 $str .= ' ' if $str ne '';
200 if (exists($fakes->{$t}))
202 $str .= $fakes->{$t};
205 if ($t =~ /^[^\/]+$/)
207 $str .= '$(TEST_D)/' . $t;
222 # Compatible with -j...
223 $str =~ s/^(\s+@?)/$1cd \$(TEST_D) && /;
226 # Compatible with not -j.
227 my @t = split("\n", $str);
237 $t =~ s/^@/\@cd \$(TEST_D) && /;
239 elsif ($t !~ /^\s*#/)
241 $t = 'cd $(TEST_D) && ' . $t;
252 my ($sed, $src, @targets) = @_;
255 foreach my $t (@targets)
257 # Copy first so we get file modes...
258 $s .= "\$(TEST_D)/$t: \$(SRC_D)/$src/$t\n\tcp \$(SRC_D)/$src/$t \$(TEST_D)/$t\n";
259 $s .= "\tsed -e 's/\\.\\.\\/apps/..\\/\$(OUT_D)/' -e 's/\\.\\.\\/util/..\\/\$(TEST_D)/' < \$(SRC_D)/$src/$t > \$(TEST_D)/$t\n" if $sed;
269 open(M, $makefile) || die "Can't open $makefile: $!";
275 while (my $line = <M>)
278 while ($line =~ /^(.*)\\$/)
283 if ($line =~ /^alltests:(.*)$/)
285 my @t = split(/\s+/, $1);
289 $alltests{$t} = undef;
293 if (($line =~ /^(?<t>\S+):(?<d>.*)$/ && exists $targets{$1})
294 || $line =~ /^(?<t>test_(ss|gen) .*):(?<d>.*)/)
298 # If there are multiple targets stupid FreeBSD make runs the
299 # rules once for each dependency that matches one of the
300 # targets. Running the same rule twice concurrently causes
301 # breakage, so replace with a fake target.
305 my @targets = split /\s+/, $t;
307 foreach my $f (@targets)
313 $deps{$t} =~ s/#.*$//;
319 $targets{$t} .= "$line\n";
324 if ($line =~ /^(\S+TEST)=\s*(\S+)$/)
331 delete $alltests{test_jpake} if $no_jpake;
332 delete $targets{test_ige} if $no_ige;
333 delete $alltests{test_md2} if $no_md2;
334 delete $alltests{test_rc5} if $no_rc5;
337 foreach my $t (keys %tests)
339 $tests .= "$t = $tests{$t}\n";
343 foreach my $t (keys %targets)
348 $d =~ s/\.\.\/apps/\$(BIN_D)/g;
349 $d =~ s/\.\.\/util/\$(TEST_D)/g;
350 $d = fixtests($d, \%tests);
351 $d = fixdeps($d, \%fakes);
353 my $r = $targets{$t};
354 $r =~ s/\.\.\/apps/..\/\$(BIN_D)/g;
355 $r =~ s/\.\.\/util/..\/\$(TEST_D)/g;
356 $r =~ s/\.\.\/(\S+)/\$(SRC_D)\/$1/g;
361 $t =~ s/\s+/ \$(TEST_D)\//g;
363 $each .= "$t: test_scripts $d\n\t\@echo '$t test started'\n$r\t\@echo '$t test done'\n\n";
366 # FIXME: Might be a clever way to figure out what needs copying
367 my @copies = ( 'bctest',
401 my $copies = copy_scripts(1, 'test', @copies);
402 $copies .= copy_scripts(0, 'test', ('smcont.txt'));
404 my @utils = ( 'shlib_wrap.sh',
407 $copies .= copy_scripts(1, 'util', @utils);
409 my @apps = ( 'CA.sh',
413 $copies .= copy_scripts(1, 'apps', @apps);
415 $copies .= copy_scripts(1, 'crypto/evp', ('evptests.txt'));
417 $scripts = "test_scripts: \$(TEST_D)/CA.sh \$(TEST_D)/opensslwrap.sh \$(TEST_D)/openssl.cnf \$(TEST_D)/shlib_wrap.sh ocsp smime\n";
418 $scripts .= "\nocsp:\n\tcp -R test/ocsp-tests \$(TEST_D)\n";
419 $scripts .= "\smime:\n\tcp -R test/smime-certs \$(TEST_D)\n";
422 foreach my $t (keys %alltests)
424 if (exists($fakes{$t}))
426 $all .= " $fakes{$t}";
434 return "$scripts\n$copies\n$tests\n$all\n\n$each";