]>
Commit | Line | Data |
---|---|---|
7c0e1aa6 RL |
1 | ## |
2 | ## Makefile for OpenSSL | |
3 | ## | |
4 | ## {- join("\n## ", @autowarntext) -} | |
5 | {- | |
6 | our $objext = $target{obj_extension} || ".obj"; | |
7 | our $depext = $target{dep_extension} || ".d"; | |
8 | our $exeext = $target{exe_extension} || ".exe"; | |
9 | our $libext = $target{lib_extension} || ".lib"; | |
10 | our $shlibext = $target{shared_extension} || ".dll"; | |
11 | our $shlibextimport = $target{shared_import_extension} || ".lib"; | |
12 | our $dsoext = $target{dso_extension} || ".dll"; | |
13 | ||
8c16829e RL |
14 | my $win_installenv = |
15 | $target{build_scheme}->[2] eq "VC-W32" ? | |
16 | "ProgramFiles(x86)" : "ProgramW6432"; | |
17 | my $win_commonenv = | |
18 | $target{build_scheme}->[2] eq "VC-W32" | |
19 | ? "CommonProgramFiles(x86)" : "CommonProgramW6432"; | |
20 | our $win_installroot = | |
21 | defined($ENV{$win_installenv}) | |
9921b7b6 | 22 | ? $win_installenv : 'ProgramFiles'; |
8c16829e RL |
23 | our $win_commonroot = |
24 | defined($ENV{$win_commonenv}) | |
9921b7b6 AP |
25 | ? $win_commonenv : 'CommonProgramFiles'; |
26 | ||
27 | # expand variables early | |
28 | $win_installroot = $ENV{$win_installroot}; | |
29 | $win_commonroot = $ENV{$win_commonroot}; | |
8c16829e | 30 | |
7c0e1aa6 RL |
31 | sub shlib { |
32 | return () if $disabled{shared}; | |
33 | my $lib = shift; | |
34 | return $unified_info{sharednames}->{$lib} . $shlibext; | |
35 | } | |
36 | ||
37 | sub shlib_import { | |
38 | return () if $disabled{shared}; | |
39 | my $lib = shift; | |
40 | return $lib . $shlibextimport; | |
41 | } | |
42 | ||
43 | sub dso { | |
44 | my $dso = shift; | |
45 | ||
46 | return $dso . $dsoext; | |
47 | } | |
48 | ''; | |
49 | -} | |
50 | ||
51 | PLATFORM={- $config{target} -} | |
52 | SRCDIR={- $config{sourcedir} -} | |
53 | BLDDIR={- $config{builddir} -} | |
54 | ||
55 | VERSION={- $config{version} -} | |
56 | MAJOR={- $config{major} -} | |
57 | MINOR={- $config{minor} -} | |
58 | ||
59 | SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -} | |
60 | ||
61 | LIBS={- join(" ", map { $_.$libext } @{$unified_info{libraries}}) -} | |
62 | SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -} | |
3ec8a1cf | 63 | SHLIBPDBS={- join(" ", map { local $shlibext = ".pdb"; shlib($_) } @{$unified_info{libraries}}) -} |
7c0e1aa6 | 64 | ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -} |
3ec8a1cf | 65 | ENGINEPDBS={- join(" ", map { local $dsoext = ".pdb"; dso($_) } @{$unified_info{engines}}) -} |
7c0e1aa6 | 66 | PROGRAMS={- join(" ", map { $_.$exeext } grep { !m|^test\\| } @{$unified_info{programs}}) -} |
3ec8a1cf | 67 | PROGRAMPDBS={- join(" ", map { $_.".pdb" } grep { !m|^test\\| } @{$unified_info{programs}}) -} |
7c0e1aa6 RL |
68 | TESTPROGS={- join(" ", map { $_.$exeext } grep { m|^test\\| } @{$unified_info{programs}}) -} |
69 | SCRIPTS={- join(" ", @{$unified_info{scripts}}) -} | |
2ff4d293 RL |
70 | {- output_off() if $disabled{apps}; "" -} |
71 | BIN_SCRIPTS=$(BLDDIR)\tools\c_rehash.pl | |
72 | MISC_SCRIPTS=$(BLDDIR)\apps\CA.pl $(BLDDIR)\apps\tsget.pl | |
73 | {- output_on() if $disabled{apps}; "" -} | |
7c0e1aa6 | 74 | |
bb6b950e | 75 | {- output_off() if $disabled{makedepend}; "" -} |
7c0e1aa6 RL |
76 | DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; } |
77 | grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ } | |
78 | keys %{$unified_info{sources}}); -} | |
bb6b950e | 79 | {- output_on() if $disabled{makedepend}; "" -} |
05a7aee0 RL |
80 | GENERATED={- join(" ", |
81 | ( map { (my $x = $_) =~ s|\.[sS]$|\.asm|; $x } | |
82 | grep { defined $unified_info{generate}->{$_} } | |
83 | map { @{$unified_info{sources}->{$_}} } | |
84 | grep { /\.o$/ } keys %{$unified_info{sources}} ), | |
85 | ( grep { /\.h$/ } keys %{$unified_info{generate}} )) -} | |
7c0e1aa6 RL |
86 | |
87 | # Do not edit these manually. Use Configure with --prefix or --openssldir | |
88 | # to change this! Short explanation in the top comment in Configure | |
89 | INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet | |
90 | # | |
8c16829e | 91 | our $prefix = $config{prefix} || "$win_installroot\\OpenSSL"; |
7c0e1aa6 RL |
92 | $prefix -} |
93 | OPENSSLDIR={- # | |
94 | # The logic here is that if no --openssldir was given, | |
95 | # OPENSSLDIR will get the value from $prefix plus "/ssl". | |
96 | # If --openssldir was given and the value is an absolute | |
97 | # path, OPENSSLDIR will get its value without change. | |
98 | # If the value from --openssldir is a relative path, | |
99 | # OPENSSLDIR will get $prefix with the --openssldir | |
100 | # value appended as a subdirectory. | |
101 | # | |
102 | use File::Spec::Functions; | |
103 | our $openssldir = | |
104 | $config{openssldir} ? | |
105 | (file_name_is_absolute($config{openssldir}) ? | |
106 | $config{openssldir} | |
107 | : catdir($prefix, $config{openssldir})) | |
8c16829e | 108 | : "$win_commonroot\\SSL"; |
7c0e1aa6 | 109 | $openssldir -} |
8c16829e | 110 | LIBDIR={- our $libdir = $config{libdir} || "lib"; |
7c0e1aa6 RL |
111 | $libdir -} |
112 | ENGINESDIR={- use File::Spec::Functions; | |
113 | our $enginesdir = catdir($prefix,$libdir,"engines"); | |
114 | $enginesdir -} | |
115 | ||
116 | CC={- $target{cc} -} | |
117 | CFLAGS={- join(" ",(map { "-D".$_} @{$target{defines}}, @{$config{defines}})) -} {- join(" ", quotify_l("-DENGINESDIR=\"$enginesdir\"", "-DOPENSSLDIR=\"$openssldir\"")) -} {- $target{cflags} -} {- $config{cflags} -} | |
118 | COUTFLAG={- $target{coutflag} || "/Fo" -} | |
0ef1ce49 RL |
119 | RC={- $target{rc} || "rc" -} |
120 | RCOUTFLAG={- $target{rcoutflag} || "/fo" -} | |
7c0e1aa6 RL |
121 | LD={- $target{ld} || "link" -} |
122 | LDFLAGS={- $target{lflags} -} | |
123 | LDOUTFLAG={- $target{loutflag} || "/out:" -} | |
2fe73036 RL |
124 | EX_LIBS={- $target{ex_libs} -} |
125 | LIB_CFLAGS={- join(" ", $target{lib_cflags}, $target{shared_cflag}) || "" -} | |
bbd9a50f | 126 | LIB_LDFLAGS={- $target{shared_ldflag} || "" -} |
2fe73036 RL |
127 | DSO_CFLAGS={- join(" ", $target{dso_cflags}, $target{shared_cflag}) || "" -} |
128 | DSO_LDFLAGS={- join(" ", $target{dso_lflags}, $target{shared_ldflag}) || "" -} | |
7c0e1aa6 | 129 | BIN_CFLAGS={- $target{bin_cflags} -} |
2fe73036 | 130 | BIN_LDFLAGS={- $target{bin_lflags} -} |
7c0e1aa6 RL |
131 | |
132 | PERL={- $config{perl} -} | |
133 | ||
134 | AR={- $target{ar} -} | |
135 | ARFLAGS= {- $target{arflags} -} | |
136 | AROUTFLAG={- $target{aroutflag} || "/out:" -} | |
137 | ||
138 | AS={- $target{as} -} | |
139 | ASFLAGS={- $target{asflags} -} | |
140 | ASOUTFLAG={- $target{asoutflag} -} | |
141 | PERLASM_SCHEME= {- $target{perlasm_scheme} -} | |
142 | ||
143 | PROCESSOR= {- $config{processor} -} | |
144 | ||
145 | # The main targets ################################################### | |
146 | ||
2fe73036 | 147 | all: configdata.pm build_libs_nodep build_engines_nodep build_apps_nodep depend |
7c0e1aa6 RL |
148 | |
149 | build_libs: configdata.pm build_libs_nodep depend | |
150 | build_libs_nodep: $(LIBS) | |
151 | build_engines: configdata.pm build_engines_nodep depend | |
152 | build_engines_nodep: $(ENGINES) | |
153 | build_apps: configdata.pm build_apps_nodep depend | |
154 | build_apps_nodep: $(PROGRAMS) $(SCRIPTS) | |
155 | build_tests: configdata.pm build_tests_nodep depend | |
156 | build_tests_nodep: $(TESTPROGS) | |
157 | ||
1b741653 RL |
158 | test: tests |
159 | tests: build_tests_nodep build_apps_nodep build_engines_nodep depend | |
d90a6beb | 160 | @rem {- output_off() if $disabled{tests}; "" -} |
7c0e1aa6 RL |
161 | set SRCTOP=$(SRCDIR) |
162 | set BLDTOP=$(BLDDIR) | |
163 | set PERL=$(PERL) | |
cb663908 | 164 | "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS) |
d90a6beb MC |
165 | @rem {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -} |
166 | @echo "Tests are not supported with your chosen Configure options" | |
167 | @rem {- output_on() if !$disabled{tests}; "" -} | |
7c0e1aa6 RL |
168 | |
169 | list-tests: | |
170 | @set TOP=$(SRCDIR) | |
171 | @set PERL=$(PERL) | |
cb663908 | 172 | @"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list |
7c0e1aa6 | 173 | |
8c16829e RL |
174 | install: install_sw install_ssldirs install_docs |
175 | ||
176 | uninstall: uninstall_docs uninstall_sw | |
177 | ||
3415c711 | 178 | libclean: |
cb663908 RL |
179 | "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """$$1.*"""; } @ARGV" $(SHLIBS) |
180 | "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """apps/$$1.*"""; } @ARGV" $(SHLIBS) | |
181 | "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """test/$$1.*"""; } @ARGV" $(SHLIBS) | |
c3ad47f5 | 182 | -del /Q /F $(LIBS) |
592b6fb4 | 183 | -del /Q ossl_static.pdb |
3415c711 RL |
184 | |
185 | clean: libclean | |
c3ad47f5 | 186 | -del /Q /F $(PROGRAMS) $(TESTPROGS) $(ENGINES) $(SCRIPTS) |
05a7aee0 | 187 | -del /Q /S /F $(GENERATED) |
c3ad47f5 AP |
188 | -del /Q /S /F *.d |
189 | -del /Q /S /F *.obj | |
190 | -del /Q /S /F *.pdb | |
191 | -del /Q /S /F *.exp | |
192 | -del /Q /S /F engines\*.ilk | |
193 | -del /Q /S /F engines\*.lib | |
b202bf67 RL |
194 | -del /Q /S /F apps\*.lib |
195 | -del /Q /S /F engines\*.manifest | |
196 | -del /Q /S /F apps\*.manifest | |
67152812 | 197 | -del /Q /S /F test\*.manifest |
3415c711 | 198 | |
7c0e1aa6 RL |
199 | depend: |
200 | ||
8c16829e RL |
201 | # Install helper targets ############################################# |
202 | ||
203 | install_sw: all install_dev install_engines install_runtime | |
204 | ||
205 | uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev | |
206 | ||
207 | install_docs: | |
cb663908 | 208 | "$(PERL)" "$(SRCDIR)\util\process_docs.pl" \ |
e990ec52 | 209 | "--destdir=$(DESTDIR)$(INSTALLTOP)\html" --type=html |
8c16829e RL |
210 | |
211 | uninstall_docs: | |
212 | ||
213 | install_ssldirs: | |
cb663908 RL |
214 | @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(DESTDIR)$(OPENSSLDIR)\certs" |
215 | @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(DESTDIR)$(OPENSSLDIR)\private" | |
216 | @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(DESTDIR)$(OPENSSLDIR)\misc" | |
217 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \ | |
592b6fb4 | 218 | "$(DESTDIR)$(OPENSSLDIR)" |
cb663908 | 219 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(MISC_SCRIPTS) \ |
2ff4d293 | 220 | "$(DESTDIR)$(OPENSSLDIR)\misc" |
8c16829e RL |
221 | |
222 | install_dev: | |
223 | @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 ) | |
224 | @echo *** Installing development files | |
cb663908 RL |
225 | @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(DESTDIR)$(INSTALLTOP)\include\openssl" |
226 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\include\openssl\*.h" \ | |
8c16829e | 227 | "$(DESTDIR)$(INSTALLTOP)\include\openssl" |
cb663908 | 228 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\include\openssl\*.h \ |
8c16829e | 229 | "$(DESTDIR)$(INSTALLTOP)\include\openssl" |
cb663908 RL |
230 | @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(DESTDIR)$(INSTALLTOP)\$(LIBDIR)" |
231 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(LIBS) \ | |
8c16829e | 232 | "$(DESTDIR)$(INSTALLTOP)\$(LIBDIR)" |
3ec8a1cf | 233 | @if "$(SHLIBS)"=="" \ |
cb663908 | 234 | "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb \ |
3ec8a1cf | 235 | "$(DESTDIR)$(INSTALLTOP)\$(LIBDIR)" |
8c16829e RL |
236 | |
237 | uninstall_dev: | |
238 | ||
239 | install_engines: | |
240 | @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 ) | |
241 | @echo *** Installing engines | |
cb663908 | 242 | @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(DESTDIR)$(ENGINESDIR)" |
8c16829e | 243 | @if not "$(ENGINES)"=="" \ |
cb663908 | 244 | "$(PERL)" "$(SRCDIR)\util\copy.pl" $(ENGINES) "$(DESTDIR)$(ENGINESDIR)" |
3ec8a1cf | 245 | @if not "$(ENGINES)"=="" \ |
cb663908 | 246 | "$(PERL)" "$(SRCDIR)\util\copy.pl" $(ENGINEPDBS) "$(DESTDIR)$(ENGINESDIR)" |
8c16829e RL |
247 | |
248 | uninstall_engines: | |
249 | ||
250 | install_runtime: | |
251 | @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 ) | |
252 | @echo *** Installing runtime files | |
cb663908 | 253 | @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(DESTDIR)$(INSTALLTOP)\bin" |
8c16829e | 254 | @if not "$(SHLIBS)"=="" \ |
cb663908 | 255 | "$(PERL)" "$(SRCDIR)\util\copy.pl" $(SHLIBS) "$(DESTDIR)$(INSTALLTOP)\bin" |
3ec8a1cf | 256 | @if not "$(SHLIBS)"=="" \ |
cb663908 | 257 | "$(PERL)" "$(SRCDIR)\util\copy.pl" $(SHLIBPDBS) \ |
3ec8a1cf | 258 | "$(DESTDIR)$(INSTALLTOP)\bin" |
cb663908 | 259 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(PROGRAMS) \ |
3ec8a1cf | 260 | "$(DESTDIR)$(INSTALLTOP)\bin" |
cb663908 | 261 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(PROGRAMPDBS) \ |
3ec8a1cf | 262 | "$(DESTDIR)$(INSTALLTOP)\bin" |
cb663908 | 263 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \ |
5f94746f | 264 | "$(DESTDIR)$(INSTALLTOP)\bin" |
8c16829e RL |
265 | |
266 | uninstall_runtime: | |
267 | ||
7c0e1aa6 RL |
268 | # Building targets ################################################### |
269 | ||
cb663908 | 270 | configdata.pm: "{- $config{build_file_template} -}" "$(SRCDIR)\Configure" |
7c0e1aa6 RL |
271 | @echo "Detected changed: $?" |
272 | @echo "Reconfiguring..." | |
cb663908 | 273 | "$(PERL)" "$(SRCDIR)\Configure" reconf |
7c0e1aa6 RL |
274 | @echo "**************************************************" |
275 | @echo "*** ***" | |
276 | @echo "*** Please run the same make command again ***" | |
277 | @echo "*** ***" | |
278 | @echo "**************************************************" | |
6ddb62a5 | 279 | @exit 1 |
7c0e1aa6 RL |
280 | |
281 | {- | |
282 | use File::Basename; | |
283 | use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/; | |
284 | ||
285 | # Helper function to figure out dependencies on libraries | |
286 | # It takes a list of library names and outputs a list of dependencies | |
287 | sub compute_lib_depends { | |
288 | if ($disabled{shared}) { | |
289 | return map { $_.$libext } @_; | |
290 | } | |
291 | return map { shlib_import($_) } @_; | |
292 | } | |
293 | ||
9a1394c5 RL |
294 | sub generatesrc { |
295 | my %args = @_; | |
296 | (my $target = $args{src}) =~ s/\.[sS]$/.asm/; | |
cb663908 RL |
297 | my $generator = '"'.join('" "', @{$args{generator}}).'"'; |
298 | my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}}); | |
299 | my $incs = join("", map { " /I \"$_\"" } @{$args{incs}}); | |
300 | my $deps = @{$args{deps}} ? | |
301 | '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : ''; | |
9a1394c5 RL |
302 | |
303 | if ($target !~ /\.asm$/) { | |
304 | return <<"EOF"; | |
cb663908 RL |
305 | $target: "$args{generator}->[0]" $deps |
306 | "\$(PERL)"$generator_incs $generator > \$@ | |
9a1394c5 RL |
307 | EOF |
308 | } else { | |
309 | if ($args{generator}->[0] =~ /\.pl$/) { | |
cb663908 | 310 | $generator = '"$(PERL)"'.$generator_incs.' '.$generator; |
9a1394c5 RL |
311 | } elsif ($args{generator}->[0] =~ /\.S$/) { |
312 | $generator = undef; | |
313 | } else { | |
314 | die "Generator type for $src unknown: $generator\n"; | |
315 | } | |
316 | ||
317 | if (defined($generator)) { | |
318 | # If the target is named foo.S in build.info, we want to | |
319 | # end up generating foo.s in two steps. | |
320 | if ($args{src} =~ /\.S$/) { | |
321 | return <<"EOF"; | |
cb663908 | 322 | $target: "$args{generator}->[0]" $deps |
9a1394c5 | 323 | set ASM=\$(AS) |
9a1394c5 | 324 | $generator \$@.S |
b75ac3c2 | 325 | \$(CC) \$(CFLAGS) $incs /EP /C \$@.S > \$@.i && move /Y \$@.i \$@ |
9a1394c5 RL |
326 | del /Q \$@.S |
327 | EOF | |
328 | } | |
329 | # Otherwise.... | |
330 | return <<"EOF"; | |
cb663908 | 331 | $target: "$args{generator}->[0]" $deps |
9a1394c5 | 332 | set ASM=\$(AS) |
9a1394c5 RL |
333 | $generator \$@ |
334 | EOF | |
335 | } | |
336 | return <<"EOF"; | |
cb663908 RL |
337 | $target: "$args{generator}->[0]" $deps |
338 | \$(CC) \$(CFLAGS) $incs /EP /C "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@ | |
9a1394c5 RL |
339 | EOF |
340 | } | |
341 | } | |
342 | ||
7c0e1aa6 RL |
343 | sub src2obj { |
344 | my %args = @_; | |
345 | my $obj = $args{obj}; | |
6ddb62a5 AP |
346 | my @srcs = map { (my $x = $_) =~ s/\.s$/.asm/; $x |
347 | } ( @{$args{srcs}} ); | |
cb663908 RL |
348 | my $srcs = '"'.join('" "', @srcs).'"'; |
349 | my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"'; | |
350 | my $incs = join("", map { ' /I "'.$_.'"' } @{$args{incs}}); | |
da430a55 RL |
351 | unless ($disabled{zlib}) { |
352 | if ($withargs{zlib_include}) { | |
cb663908 | 353 | $incs .= ' /I "'.$withargs{zlib_include}.'"'; |
da430a55 RL |
354 | } |
355 | } | |
2fe73036 | 356 | my $ecflags = { lib => '$(LIB_CFLAGS)', |
7c0e1aa6 RL |
357 | dso => '$(DSO_CFLAGS)', |
358 | bin => '$(BIN_CFLAGS)' } -> {$args{intent}}; | |
359 | my $makedepprog = $config{makedepprog}; | |
360 | if ($srcs[0] =~ /\.asm$/) { | |
361 | return <<"EOF"; | |
362 | $obj$objext: $deps | |
363 | \$(AS) \$(ASFLAGS) \$(ASOUTFLAG)\$\@ $srcs | |
364 | EOF | |
365 | } | |
bb6b950e | 366 | return <<"EOF" if (!$disabled{makedepend}); |
7c0e1aa6 RL |
367 | $obj$depext: $deps |
368 | \$(CC) \$(CFLAGS) $ecflags$inc /Zs /showIncludes $srcs 2>&1 | \\ | |
cb663908 | 369 | "\$(PERL)" -n << > $obj$depext |
7c0e1aa6 RL |
370 | chomp; |
371 | s/^Note: including file: *//; | |
372 | \$\$collect{\$\$_} = 1; | |
373 | END { print '$obj$objext: ',join(" ", sort keys \%collect),"\\n" } | |
dc8941f0 | 374 | << |
7c0e1aa6 RL |
375 | $obj$objext: $obj$depext |
376 | \$(CC) \$(CFLAGS) $ecflags$incs -c \$(COUTFLAG)\$\@ @<< | |
377 | $srcs | |
dc8941f0 | 378 | << |
bb6b950e AP |
379 | EOF |
380 | return <<"EOF" if ($disabled{makedepend}); | |
381 | $obj$objext: $deps | |
382 | \$(CC) \$(CFLAGS) $ecflags$incs -c \$(COUTFLAG)\$\@ $srcs | |
7c0e1aa6 RL |
383 | EOF |
384 | } | |
385 | ||
386 | # On Unix, we build shlibs from static libs, so we're ignoring the | |
387 | # object file array. We *know* this routine is only called when we've | |
388 | # configure 'shared'. | |
389 | sub libobj2shlib { | |
390 | my %args = @_; | |
391 | my $lib = $args{lib}; | |
392 | my $shlib = $args{shlib}; | |
393 | (my $mkdef_key = $lib) =~ s/^lib//i; | |
394 | my $objs = join("\n", map { $_.$objext } @{$args{objs}}); | |
395 | my $linklibs = join("", | |
396 | map { "\n$_" } compute_lib_depends(@{$args{deps}})); | |
397 | my $deps = join(" ", | |
398 | (map { $_.$objext } @{$args{objs}}), | |
399 | compute_lib_depends(@{$args{deps}})); | |
400 | my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : ""; | |
401 | my $mkdef_pl = abs2rel(rel2abs(catfile($config{sourcedir}, | |
402 | "util", "mkdef.pl")), | |
403 | rel2abs($config{builddir})); | |
0ef1ce49 RL |
404 | my $mkrc_pl = abs2rel(rel2abs(catfile($config{sourcedir}, |
405 | "util", "mkrc.pl")), | |
406 | rel2abs($config{builddir})); | |
7c0e1aa6 RL |
407 | my $target = shlib_import($lib); |
408 | return <<"EOF" | |
cb663908 RL |
409 | $target: $deps "$ordinalsfile" "$mkdef_pl" |
410 | "\$(PERL)" "$mkdef_pl" "$mkdef_key" 32 > $shlib.def | |
411 | "\$(PERL)" -i.tmp -pe "s|^LIBRARY\\s+${mkdef_key}32|LIBRARY $shlib|;" $shlib.def | |
685b6f29 | 412 | DEL $shlib.def.tmp |
cb663908 | 413 | "\$(PERL)" "$mkrc_pl" $shlib$shlibext > $shlib.rc |
0ef1ce49 | 414 | \$(RC) \$(RCOUTFLAG)$shlib.res $shlib.rc |
bbd9a50f | 415 | \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\ |
d237d699 | 416 | /implib:\$@ \$(LDOUTFLAG)$shlib$shlibext /def:$shlib.def @<< || (DEL /Q \$(\@B).* $shlib.* && EXIT 1) |
0ef1ce49 | 417 | $objs $shlib.res$linklibs \$(EX_LIBS) |
7c0e1aa6 | 418 | << |
7d52e554 RL |
419 | IF EXIST apps\\$shlib$shlibext DEL /Q /F apps\\$shlib$shlibext |
420 | IF EXIST test\\$shlib$shlibext DEL /Q /F test\\$shlib$shlibext | |
685b6f29 RL |
421 | COPY $shlib$shlibext apps |
422 | COPY $shlib$shlibext test | |
7c0e1aa6 RL |
423 | EOF |
424 | } | |
425 | sub obj2dso { | |
426 | my %args = @_; | |
427 | my $dso = $args{lib}; | |
2fe73036 | 428 | my $dso_n = basename($dso); |
7c0e1aa6 RL |
429 | my $objs = join("\n", map { $_.$objext } @{$args{objs}}); |
430 | my $linklibs = join("", | |
431 | map { "\n$_" } compute_lib_depends(@{$args{deps}})); | |
432 | my $deps = join(" ", | |
433 | (map { $_.$objext } @{$args{objs}}), | |
434 | compute_lib_depends(@{$args{deps}})); | |
435 | return <<"EOF"; | |
436 | $dso$dsoext: $deps | |
2fe73036 RL |
437 | \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \$(LDOUTFLAG)$dso$dsoext /def:<< @<< |
438 | LIBRARY $dso_n | |
7c0e1aa6 RL |
439 | EXPORTS |
440 | bind_engine @1 | |
441 | v_check @2 | |
442 | << | |
443 | $objs$linklibs \$(EX_LIBS) | |
444 | << | |
445 | EOF | |
446 | } | |
447 | sub obj2lib { | |
b805b444 RL |
448 | # Because static libs and import libs are both named the same in native |
449 | # Windows, we can't have both. We skip the static lib in that case, | |
450 | # as the shared libs are what we use anyway. | |
451 | return "" unless $disabled{"shared"}; | |
452 | ||
7c0e1aa6 RL |
453 | my %args = @_; |
454 | my $lib = $args{lib}; | |
455 | my $objs = join("\n", map { $_.$objext } @{$args{objs}}); | |
456 | my $deps = join(" ", map { $_.$objext } @{$args{objs}}); | |
457 | return <<"EOF"; | |
458 | $lib$libext: $deps | |
459 | \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib$libext @<< | |
68cd4e3f | 460 | \$\? |
7c0e1aa6 RL |
461 | << |
462 | EOF | |
463 | } | |
464 | sub obj2bin { | |
465 | my %args = @_; | |
466 | my $bin = $args{bin}; | |
467 | my $objs = join("\n", map { $_.$objext } @{$args{objs}}); | |
468 | my $linklibs = join("", | |
469 | map { "\n$_" } compute_lib_depends(@{$args{deps}})); | |
470 | my $deps = join(" ", | |
471 | (map { $_.$objext } @{$args{objs}}), | |
472 | compute_lib_depends(@{$args{deps}})); | |
473 | return <<"EOF"; | |
474 | $bin$exeext: $deps | |
2fe73036 | 475 | \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin$exeext @<< |
7c0e1aa6 RL |
476 | $objs setargv.obj$linklibs \$(EX_LIBS) |
477 | << | |
478 | EOF | |
479 | } | |
480 | sub in2script { | |
481 | my %args = @_; | |
482 | my $script = $args{script}; | |
cb663908 | 483 | my $sources = '"'.join('" "', @{$args{sources}}).'"'; |
7c0e1aa6 RL |
484 | my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, |
485 | "util", "dofile.pl")), | |
486 | rel2abs($config{builddir})); | |
487 | return <<"EOF"; | |
488 | $script: $sources | |
cb663908 | 489 | "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\ |
7c0e1aa6 | 490 | "-o$target{build_file}" $sources > "$script" |
0ad1d94d RL |
491 | EOF |
492 | } | |
493 | sub generatedir { | |
494 | my %args = @_; | |
495 | my $dir = $args{dir}; | |
496 | my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}}; | |
497 | my @actions = (); | |
498 | my %extinfo = ( dso => $dsoext, | |
499 | lib => $libext, | |
500 | bin => $exeext ); | |
501 | ||
502 | foreach my $type (("dso", "lib", "bin", "script")) { | |
503 | next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type}); | |
504 | if ($type eq "lib") { | |
505 | foreach my $lib (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) { | |
506 | push @actions, <<"EOF"; | |
507 | \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib$libext @<< | |
508 | \$\? | |
509 | << | |
510 | EOF | |
511 | } | |
512 | } else { | |
513 | foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) { | |
514 | if (dirname($prod) eq $dir) { | |
515 | push @deps, $prod.$extinfo{$type}; | |
516 | } else { | |
517 | push @actions, "\t@ : No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}}); | |
518 | } | |
519 | } | |
520 | } | |
521 | } | |
522 | ||
523 | my $deps = join(" ", @deps); | |
524 | my $actions = join("\n", "", @actions); | |
525 | return <<"EOF"; | |
526 | $args{dir} $args{dir}\\ : $deps$actions | |
7c0e1aa6 RL |
527 | EOF |
528 | } | |
529 | "" # Important! This becomes part of the template result. | |
530 | -} |