3 # unix.pl - the standard unix makefile stuff.
16 { $cflags="-g2 -ggdb"; }
18 { $cflags="-O3 -fomit-frame-pointer"; }
38 # static library stuff
41 $ranlib=&which("ranlib") or $ranlib="true";
57 'md5-x86_64' => 'crypto/md5',
58 'x86_64-mont' => 'crypto/bn',
59 'x86_64-mont5' => 'crypto/bn',
60 'x86_64-gf2m' => 'crypto/bn',
61 'modexp512-x86_64' => 'crypto/bn',
62 'aes-x86_64' => 'crypto/aes',
63 'vpaes-x86_64' => 'crypto/aes',
64 'bsaes-x86_64' => 'crypto/aes',
65 'aesni-x86_64' => 'crypto/aes',
66 'aesni-sha1-x86_64' => 'crypto/aes',
67 'sha1-x86_64' => 'crypto/sha',
68 'e_padlock-x86_64' => 'engines',
69 'rc4-x86_64' => 'crypto/rc4',
70 'rc4-md5-x86_64' => 'crypto/rc4',
71 'ghash-x86_64' => 'crypto/modes',
74 # If I were feeling more clever, these could probably be extracted
76 sub platform_perlasm_compile_target
78 local($target, $source, $bname) = @_;
82 if ($target eq "\$(OBJ_D)/$p.o")
85 \$(TMP_D)/$p.s: $perl1{$p}/asm/$p.pl
86 \$(PERL) $perl1{$p}/asm/$p.pl \$(PERLASM_SCHEME) > \$@
90 if ($target eq '$(OBJ_D)/x86_64cpuid.o')
93 $(TMP_D)/x86_64cpuid.s: crypto/x86_64cpuid.pl
94 $(PERL) crypto/x86_64cpuid.pl $(PERLASM_SCHEME) > $@
97 elsif ($target eq '$(OBJ_D)/sha256-x86_64.o')
100 $(TMP_D)/sha256-x86_64.s: crypto/sha/asm/sha512-x86_64.pl
101 $(PERL) crypto/sha/asm/sha512-x86_64.pl $(PERLASM_SCHEME) $@
104 elsif ($target eq '$(OBJ_D)/sha512-x86_64.o')
107 $(TMP_D)/sha512-x86_64.s: crypto/sha/asm/sha512-x86_64.pl
108 $(PERL) crypto/sha/asm/sha512-x86_64.pl $(PERLASM_SCHEME) $@
111 elsif ($target eq '$(OBJ_D)/sha512-x86_64.o')
114 $(TMP_D)/sha512-x86_64.s: crypto/sha/asm/sha512-x86_64.pl
115 $(PERL) crypto/sha/asm/sha512-x86_64.pl $(PERLASM_SCHEME) $@
122 sub special_compile_target
126 if ($target eq 'crypto/bn/x86_64-gcc')
129 \$(TMP_D)/x86_64-gcc.o: crypto/bn/asm/x86_64-gcc.c
130 \$(CC) \$(CFLAGS) -c -o \$@ crypto/bn/asm/x86_64-gcc.c
138 local($obj,$target,$name,$shlib)=@_;
139 local($ret,$_,$Name);
141 $target =~ s/\//$o/g if $o ne '/';
143 ($Name=$name) =~ tr/a-z/A-Z/;
145 $ret.="$target: \$(${Name}OBJ)\n";
146 $ret.="\t\$(RM) $target\n";
147 $ret.="\t\$(MKLIB) $target \$(${Name}OBJ)\n";
148 $ret.="\t\$(RANLIB) $target\n\n";
153 local($target,$files,$dep_libs,$libs)=@_;
156 $file =~ s/\//$o/g if $o ne '/';
158 $ret.="$target: $files $dep_libs\n";
159 $ret.="\t\$(LINK) ${efile}$target \$(LFLAGS) $files $libs\n\n";
167 foreach $path (split /:/, $ENV{PATH})
169 if (-x "$path/$name")
171 return "$path/$name";
178 my ($str, $tests) = @_;
180 foreach my $t (keys %$tests)
182 $str =~ s/(\.\/)?\$\($t\)/\$(TEST_D)\/$tests->{$t}/g;
192 my @t = split(/\s+/, $str);
196 $str .= ' ' if $str ne '';
197 if ($t =~ /^[^\/]+$/)
199 $str .= '$(TEST_D)/' . $t;
216 my @t = split("\n", $str);
223 $t =~ s/^@/\@cd \$(TEST_D) && /;
227 $t = 'cd $(TEST_D) && ' . $t;
238 open(M, $makefile) || die "Can't open $makefile: $!";
242 while (my $line = <M>)
245 while ($line =~ /^(.*)\\$/)
250 if ($line =~ /^alltests:(.*)$/)
252 my @t = split(/\s+/, $1);
259 if (($line =~ /^(\S+):(.*)$/ && exists $targets{$1})
260 || $line =~ /^(test_ss .*):(.*)/)
264 $deps{$t} =~ s/#.*$//;
270 $targets{$t} .= "$line\n";
275 if ($line =~ /^(\S+TEST)=\s*(\S+)$/)
282 delete $targets{test_jpake} if $no_jpake;
283 delete $targets{test_ige} if $no_ige;
284 delete $targets{test_md2} if $no_md2;
285 delete $targets{test_rc5} if $no_rc5;
288 foreach my $t (keys %tests)
290 $tests .= "$t = $tests{$t}\n";
295 foreach my $t (keys %targets)
299 if ($t =~ /^test_ss/)
301 $t =~ s/\s+/ \$(TEST_D)\//g;
310 $d =~ s/\.\.\/apps/\$(BIN_D)/g;
311 $d = fixtests($d, \%tests);
314 my $r = $targets{$t};
315 $r =~ s/\.\.\/apps/\$(BIN_D)/g;
316 $r =~ s/\.\.\/(\S+)/\$(SRC_D)\/$1/g;
319 $each .= "$t: \$(TEST_D) $d\n\tcd \$(TEST_D)\n$r\n";
322 # FIXME: Might be a clever way to figure out what needs copying
323 my $copies = do_copy_rule('$(TEST_D)', 'test/bctest test/evptests.txt test/testgen test/cms-test.pl', '');
325 return "$copies\n$tests\n$all\n\n$each";