]>
Commit | Line | Data |
---|---|---|
d02b48c6 RE |
1 | #!/usr/local/bin/perl |
2 | # | |
3 | # unix.pl - the standard unix makefile stuff. | |
4 | # | |
5 | ||
6 | $o='/'; | |
7 | $cp='/bin/cp'; | |
8 | $rm='/bin/rm -f'; | |
9 | ||
10 | # C compiler stuff | |
11 | ||
12 | if ($gcc) | |
13 | { | |
14 | $cc='gcc'; | |
15 | if ($debug) | |
16 | { $cflags="-g2 -ggdb"; } | |
17 | else | |
18 | { $cflags="-O3 -fomit-frame-pointer"; } | |
19 | } | |
20 | else | |
21 | { | |
22 | $cc='cc'; | |
23 | if ($debug) | |
24 | { $cflags="-g"; } | |
25 | else | |
26 | { $cflags="-O"; } | |
27 | } | |
28 | $obj='.o'; | |
045b2809 | 29 | $asm_suffix='.s'; |
d02b48c6 RE |
30 | $ofile='-o '; |
31 | ||
32 | # EXE linking stuff | |
33 | $link='${CC}'; | |
897dfd4e | 34 | $lflags='${CFLAG}'; |
d02b48c6 RE |
35 | $efile='-o '; |
36 | $exep=''; | |
37 | $ex_libs=""; | |
38 | ||
39 | # static library stuff | |
40 | $mklib='ar r'; | |
41 | $mlflags=''; | |
99aab161 | 42 | $ranlib=&which("ranlib") or $ranlib="true"; |
d02b48c6 RE |
43 | $plib='lib'; |
44 | $libp=".a"; | |
45 | $shlibp=".a"; | |
46 | $lfile=''; | |
47 | ||
48 | $asm='as'; | |
49 | $afile='-o '; | |
dfeab068 RE |
50 | $bn_asm_obj=""; |
51 | $bn_asm_src=""; | |
d02b48c6 RE |
52 | $des_enc_obj=""; |
53 | $des_enc_src=""; | |
54 | $bf_enc_obj=""; | |
55 | $bf_enc_src=""; | |
56 | ||
656829b7 BL |
57 | %perl1 = ( |
58 | 'md5-x86_64' => 'crypto/md5', | |
59 | 'x86_64-mont' => 'crypto/bn', | |
60 | 'x86_64-mont5' => 'crypto/bn', | |
61 | 'x86_64-gf2m' => 'crypto/bn', | |
656829b7 BL |
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', | |
6d84daa5 BL |
72 | 'aesni-gcm-x86_64' => 'crypto/modes', |
73 | 'aesni-sha256-x86_64' => 'crypto/aes', | |
82fe001b BL |
74 | 'rsaz-x86_64' => 'crypto/bn', |
75 | 'rsaz-avx2' => 'crypto/bn', | |
99fb2212 BL |
76 | 'aesni-mb-x86_64' => 'crypto/aes', |
77 | 'sha1-mb-x86_64' => 'crypto/sha', | |
78 | 'sha256-mb-x86_64' => 'crypto/sha', | |
71614df4 | 79 | 'ecp_nistz256-x86_64' => 'crypto/ec', |
32bb5c39 MB |
80 | 'wp-x86_64' => 'crypto/whrlpool', |
81 | 'cmll-x86_64' => 'crypto/camellia', | |
656829b7 BL |
82 | ); |
83 | ||
84 | # If I were feeling more clever, these could probably be extracted | |
85 | # from makefiles. | |
86 | sub platform_perlasm_compile_target | |
87 | { | |
88 | local($target, $source, $bname) = @_; | |
89 | ||
90 | for $p (keys %perl1) | |
91 | { | |
c051cbc8 BL |
92 | # FIXME: export CC so rsaz-avx2 can test for it, since BSD make does |
93 | # not export variables, unlike GNU make. But this also requires fixing | |
94 | # the .s.o rule to use CC! | |
656829b7 BL |
95 | if ($target eq "\$(OBJ_D)/$p.o") |
96 | { | |
97 | return << "EOF"; | |
98 | \$(TMP_D)/$p.s: $perl1{$p}/asm/$p.pl | |
99 | \$(PERL) $perl1{$p}/asm/$p.pl \$(PERLASM_SCHEME) > \$@ | |
100 | EOF | |
101 | } | |
102 | } | |
103 | if ($target eq '$(OBJ_D)/x86_64cpuid.o') | |
104 | { | |
105 | return << 'EOF'; | |
106 | $(TMP_D)/x86_64cpuid.s: crypto/x86_64cpuid.pl | |
107 | $(PERL) crypto/x86_64cpuid.pl $(PERLASM_SCHEME) > $@ | |
108 | EOF | |
109 | } | |
110 | elsif ($target eq '$(OBJ_D)/sha256-x86_64.o') | |
111 | { | |
112 | return << 'EOF'; | |
113 | $(TMP_D)/sha256-x86_64.s: crypto/sha/asm/sha512-x86_64.pl | |
114 | $(PERL) crypto/sha/asm/sha512-x86_64.pl $(PERLASM_SCHEME) $@ | |
115 | EOF | |
116 | } | |
117 | elsif ($target eq '$(OBJ_D)/sha512-x86_64.o') | |
118 | { | |
119 | return << 'EOF'; | |
120 | $(TMP_D)/sha512-x86_64.s: crypto/sha/asm/sha512-x86_64.pl | |
121 | $(PERL) crypto/sha/asm/sha512-x86_64.pl $(PERLASM_SCHEME) $@ | |
122 | EOF | |
123 | } | |
124 | elsif ($target eq '$(OBJ_D)/sha512-x86_64.o') | |
125 | { | |
126 | return << 'EOF'; | |
127 | $(TMP_D)/sha512-x86_64.s: crypto/sha/asm/sha512-x86_64.pl | |
128 | $(PERL) crypto/sha/asm/sha512-x86_64.pl $(PERLASM_SCHEME) $@ | |
129 | EOF | |
130 | } | |
131 | ||
132 | die $target; | |
133 | } | |
134 | ||
135 | sub special_compile_target | |
136 | { | |
137 | local($target) = @_; | |
138 | ||
139 | if ($target eq 'crypto/bn/x86_64-gcc') | |
140 | { | |
141 | return << "EOF"; | |
142 | \$(TMP_D)/x86_64-gcc.o: crypto/bn/asm/x86_64-gcc.c | |
63116812 | 143 | \$(CC) \$(LIB_CFLAGS) -c -o \$@ crypto/bn/asm/x86_64-gcc.c |
656829b7 BL |
144 | EOF |
145 | } | |
146 | return undef; | |
147 | } | |
148 | ||
d02b48c6 RE |
149 | sub do_lib_rule |
150 | { | |
151 | local($obj,$target,$name,$shlib)=@_; | |
152 | local($ret,$_,$Name); | |
153 | ||
154 | $target =~ s/\//$o/g if $o ne '/'; | |
dfeab068 | 155 | $target="$target"; |
d02b48c6 RE |
156 | ($Name=$name) =~ tr/a-z/A-Z/; |
157 | ||
158 | $ret.="$target: \$(${Name}OBJ)\n"; | |
159 | $ret.="\t\$(RM) $target\n"; | |
160 | $ret.="\t\$(MKLIB) $target \$(${Name}OBJ)\n"; | |
161 | $ret.="\t\$(RANLIB) $target\n\n"; | |
162 | } | |
163 | ||
164 | sub do_link_rule | |
165 | { | |
166 | local($target,$files,$dep_libs,$libs)=@_; | |
167 | local($ret,$_); | |
3b4d86bf | 168 | |
d02b48c6 RE |
169 | $file =~ s/\//$o/g if $o ne '/'; |
170 | $n=&bname($target); | |
171 | $ret.="$target: $files $dep_libs\n"; | |
d44bb1c3 | 172 | $ret.="\t\$(LINK_CMD) ${efile}$target \$(LFLAGS) $files $libs\n\n"; |
d02b48c6 RE |
173 | return($ret); |
174 | } | |
175 | ||
99aab161 UM |
176 | sub which |
177 | { | |
178 | my ($name)=@_; | |
179 | my $path; | |
180 | foreach $path (split /:/, $ENV{PATH}) | |
181 | { | |
182 | if (-x "$path/$name") | |
183 | { | |
184 | return "$path/$name"; | |
185 | } | |
186 | } | |
187 | } | |
188 | ||
fd9ad230 RL |
189 | sub do_rehash_rule { |
190 | my ($target, $deps) = @_; | |
191 | my $ret = <<"EOF"; | |
192 | $target: $deps | |
31ba0e17 | 193 | touch $target |
fd9ad230 RL |
194 | EOF |
195 | return $ret | |
3b4d86bf | 196 | } |
fd9ad230 RL |
197 | sub do_test_rule { |
198 | my ($target, $deps, $test_cmd) = @_; | |
199 | my $ret = <<"EOF"; | |
200 | $target: $deps force.$target | |
201 | TOP=. BIN_D=\$(BIN_D) TEST_D=\$(TEST_D) \\ | |
b00387a0 | 202 | PERL=\$(PERL) \$(PERL) test/$test_cmd \$(TESTS) |
fd9ad230 | 203 | force.$target: |
3b4d86bf | 204 | |
fd9ad230 RL |
205 | EOF |
206 | return $ret; | |
207 | } | |
a7f5cd7f | 208 | |
3b4d86bf | 209 | |
d02b48c6 | 210 | 1; |