]> git.ipfire.org Git - thirdparty/openssl.git/blob - Configurations/windows-makefile.tmpl
Add build file support for generic symbol exports with DSOs
[thirdparty/openssl.git] / Configurations / windows-makefile.tmpl
1 ##
2 ## Makefile for OpenSSL
3 ##
4 ## {- join("\n## ", @autowarntext) -}
5 {-
6 our $objext = $target{obj_extension} || ".obj";
7 our $resext = $target{res_extension} || ".res";
8 our $depext = $target{dep_extension} || ".d";
9 our $defext = $target{dep_extension} || ".def";
10 our $exeext = $target{exe_extension} || ".exe";
11 our $libext = $target{lib_extension} || ".lib";
12 our $shlibext = $target{shared_extension} || ".dll";
13 our $shlibextimport = $target{shared_import_extension} || ".lib";
14 our $dsoext = $target{dso_extension} || ".dll";
15
16 (our $sover_dirname = $config{shlib_version_number}) =~ s|\.|_|g;
17
18 my $build_scheme = $target{build_scheme};
19 my $install_flavour = $build_scheme->[$#$build_scheme]; # last element
20 my $win_installenv =
21 $install_flavour eq "VC-WOW" ? "ProgramFiles(x86)"
22 : "ProgramW6432";
23 my $win_commonenv =
24 $install_flavour eq "VC-WOW" ? "CommonProgramFiles(x86)"
25 : "CommonProgramW6432";
26 our $win_installroot =
27 defined($ENV{$win_installenv}) ? $win_installenv : 'ProgramFiles';
28 our $win_commonroot =
29 defined($ENV{$win_commonenv}) ? $win_commonenv : 'CommonProgramFiles';
30
31 # expand variables early
32 $win_installroot = $ENV{$win_installroot};
33 $win_commonroot = $ENV{$win_commonroot};
34
35 sub shlib {
36 my $lib = shift;
37 return () if $disabled{shared} || $lib =~ /\.a$/;
38 return () unless defined $unified_info{sharednames}->{$lib};
39 return $unified_info{sharednames}->{$lib} . $shlibext;
40 }
41
42 sub lib {
43 (my $lib = shift) =~ s/\.a$//;
44 return $lib . $libext;
45 }
46
47 sub shlib_import {
48 my $lib = shift;
49 return () if $disabled{shared} || $lib =~ /\.a$/;
50 return $lib . $shlibextimport;
51 }
52
53 sub dso {
54 my $dso = shift;
55
56 return $dso . $dsoext;
57 }
58 # This makes sure things get built in the order they need
59 # to. You're welcome.
60 sub dependmagic {
61 my $target = shift;
62
63 return "$target: build_generated\n\t\$(MAKE) /\$(MAKEFLAGS) depend && \$(MAKE) /\$(MAKEFLAGS) _$target\n_$target";
64 }
65 '';
66 -}
67
68 PLATFORM={- $config{target} -}
69 SRCDIR={- $config{sourcedir} -}
70 BLDDIR={- $config{builddir} -}
71
72 VERSION={- $config{version} -}
73 MAJOR={- $config{major} -}
74 MINOR={- $config{minor} -}
75
76 SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -}
77
78 LIBS={- join(" ", map { lib($_) } @{$unified_info{libraries}}) -}
79 SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -}
80 SHLIBPDBS={- join(" ", map { local $shlibext = ".pdb"; shlib($_) } @{$unified_info{libraries}}) -}
81 ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -}
82 ENGINEPDBS={- join(" ", map { local $dsoext = ".pdb"; dso($_) } @{$unified_info{engines}}) -}
83 PROGRAMS={- our @PROGRAMS = map { $_.$exeext } @{$unified_info{programs}}; join(" ", @PROGRAMS) -}
84 PROGRAMPDBS={- join(" ", map { $_.".pdb" } @{$unified_info{programs}}) -}
85 SCRIPTS={- join(" ", @{$unified_info{scripts}}) -}
86 {- output_off() if $disabled{makedepend}; "" -}
87 DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; }
88 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
89 keys %{$unified_info{sources}}); -}
90 {- output_on() if $disabled{makedepend}; "" -}
91 GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -}
92 GENERATED={- # common0.tmpl provides @generated
93 join(" ", map { my $x = $_;
94 $x =~ s|\.[sS]$|.asm|;
95 $x =~ s|\.ld$|$defext|;
96 $x }
97 @generated) -}
98
99 INSTALL_LIBS={- join(" ", map { quotify1(lib($_)) } @{$unified_info{install}->{libraries}}) -}
100 INSTALL_SHLIBS={- join(" ", map { quotify_l(shlib($_)) } @{$unified_info{install}->{libraries}}) -}
101 INSTALL_SHLIBPDBS={- join(" ", map { local $shlibext = ".pdb"; quotify_l(shlib($_)) } @{$unified_info{install}->{libraries}}) -}
102 INSTALL_ENGINES={- join(" ", map { quotify1(dso($_)) } @{$unified_info{install}->{engines}}) -}
103 INSTALL_ENGINEPDBS={- join(" ", map { local $dsoext = ".pdb"; quotify1(dso($_)) } @{$unified_info{install}->{engines}}) -}
104 INSTALL_PROGRAMS={- join(" ", map { quotify1($_.$exeext) } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -}
105 INSTALL_PROGRAMPDBS={- join(" ", map { quotify1($_.".pdb") } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -}
106 {- output_off() if $disabled{apps}; "" -}
107 BIN_SCRIPTS="$(BLDDIR)\tools\c_rehash.pl"
108 MISC_SCRIPTS="$(BLDDIR)\apps\CA.pl" "$(BLDDIR)\apps\tsget.pl"
109 {- output_on() if $disabled{apps}; "" -}
110
111 APPS_OPENSSL={- use File::Spec::Functions;
112 "\"".catfile("apps","openssl")."\"" -}
113
114 # Do not edit these manually. Use Configure with --prefix or --openssldir
115 # to change this! Short explanation in the top comment in Configure
116 INSTALLTOP_dev={- # $prefix is used in the OPENSSLDIR perl snippet
117 #
118 use File::Spec::Functions qw(:DEFAULT splitpath);
119 our $prefix = canonpath($config{prefix}
120 || "$win_installroot\\OpenSSL");
121 our ($prefix_dev, $prefix_dir, $prefix_file) =
122 splitpath($prefix, 1);
123 $prefix_dev -}
124 INSTALLTOP_dir={- canonpath($prefix_dir) -}
125 OPENSSLDIR_dev={- #
126 # The logic here is that if no --openssldir was given,
127 # OPENSSLDIR will get the value "$win_commonroot\\SSL".
128 # If --openssldir was given and the value is an absolute
129 # path, OPENSSLDIR will get its value without change.
130 # If the value from --openssldir is a relative path,
131 # OPENSSLDIR will get $prefix with the --openssldir
132 # value appended as a subdirectory.
133 #
134 use File::Spec::Functions qw(:DEFAULT splitpath);
135 our $openssldir =
136 $config{openssldir} ?
137 (file_name_is_absolute($config{openssldir}) ?
138 canonpath($config{openssldir})
139 : catdir($prefix, $config{openssldir}))
140 : canonpath("$win_commonroot\\SSL");
141 our ($openssldir_dev, $openssldir_dir, $openssldir_file) =
142 splitpath($openssldir, 1);
143 $openssldir_dev -}
144 OPENSSLDIR_dir={- canonpath($openssldir_dir) -}
145 LIBDIR={- our $libdir = $config{libdir} || "lib";
146 file_name_is_absolute($libdir) ? "" : $libdir -}
147 ENGINESDIR_dev={- use File::Spec::Functions qw(:DEFAULT splitpath);
148 our $enginesdir = catdir($prefix,$libdir,"engines-$sover_dirname");
149 our ($enginesdir_dev, $enginesdir_dir, $enginesdir_file) =
150 splitpath($enginesdir, 1);
151 $enginesdir_dev -}
152 ENGINESDIR_dir={- canonpath($enginesdir_dir) -}
153 !IF "$(DESTDIR)" != ""
154 INSTALLTOP=$(DESTDIR)$(INSTALLTOP_dir)
155 OPENSSLDIR=$(DESTDIR)$(OPENSSLDIR_dir)
156 ENGINESDIR=$(DESTDIR)$(ENGINESDIR_dir)
157 !ELSE
158 INSTALLTOP=$(INSTALLTOP_dev)$(INSTALLTOP_dir)
159 OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir)
160 ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir)
161 !ENDIF
162
163 # $(libdir) is chosen to be compatible with the GNU coding standards
164 libdir={- file_name_is_absolute($libdir)
165 ? $libdir : '$(INSTALLTOP)\$(LIBDIR)' -}
166
167 ##### User defined commands and flags ################################
168
169 CC={- $config{CC} -}
170 CPP={- $config{CPP} -}
171 CPPFLAGS={- our $cppflags1 = join(" ",
172 (map { "-D".$_} @{$config{CPPDEFINES}}),
173 (map { " /I ".$_} @{$config{CPPINCLUDES}}),
174 @{$config{CPPFLAGS}}) -}
175 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
176 LD={- $config{LD} -}
177 LDFLAGS={- join(' ', @{$config{LDFLAGS}}) -}
178 EX_LIBS={- join(' ', @{$config{LDLIBS}}) -}
179
180 PERL={- $config{PERL} -}
181
182 AR={- $config{AR} -}
183 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
184
185 MT={- $config{MT} -}
186 MTFLAGS= {- join(' ', @{$config{MTFLAGS}}) -}
187
188 AS={- $config{AS} -}
189 ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
190
191 RC={- $config{RC} -}
192
193 ECHO="$(PERL)" "$(SRCDIR)\util\echo.pl"
194
195 ##### Special command flags ##########################################
196
197 COUTFLAG={- $target{coutflag} -}$(OSSL_EMPTY)
198 LDOUTFLAG={- $target{ldoutflag} -}$(OSSL_EMPTY)
199 AROUTFLAG={- $target{aroutflag} -}$(OSSL_EMPTY)
200 MTINFLAG={- $target{mtinflag} -}$(OSSL_EMPTY)
201 MTOUTFLAG={- $target{mtoutflag} -}$(OSSL_EMPTY)
202 ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
203 RCOUTFLAG={- $target{rcoutflag} -}$(OSSL_EMPTY)
204
205 ##### Project flags ##################################################
206
207 # Variables starting with CNF_ are common variables for all product types
208
209 CNF_ASFLAGS={- join(' ', $target{asflags} || (),
210 @{$config{asflags}}) -}
211 CNF_CPPFLAGS={- our $cppfags2 =
212 join(' ', $target{cppflags} || (),
213 (map { '-D'.quotify1($_) } @{$target{defines}},
214 @{$config{defines}}),
215 (map { '-I'.quotify1($_) } @{$target{includes}},
216 @{$config{includes}}),
217 @{$config{cppflags}}) -}
218 CNF_CFLAGS={- join(' ', $target{cflags} || (),
219 @{$config{cflags}}) -}
220 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
221 @{$config{cxxflags}}) -}
222 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
223 @{$config{lflags}}) -}
224 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
225 @{$config{ex_libs}}) -}
226
227 # Variables starting with LIB_ are used to build library object files
228 # and shared libraries.
229 # Variables starting with DSO_ are used to build DSOs and their object files.
230 # Variables starting with BIN_ are used to build programs and their object
231 # files.
232
233 LIB_ASFLAGS={- join(' ', $target{lib_asflags} || (),
234 @{$config{lib_asflags}},
235 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
236 LIB_CPPFLAGS={- our $lib_cppflags =
237 join(' ', $target{lib_cppflags} || (),
238 $target{shared_cppflag} || (),
239 (map { '-D'.quotify1($_) }
240 @{$target{lib_defines}},
241 @{$target{shared_defines}},
242 @{$config{lib_defines}},
243 @{$config{shared_defines}}),
244 (map { '-I'.quotify1($_) }
245 @{$target{lib_includes}},
246 @{$target{shared_includes}},
247 @{$config{lib_includes}},
248 @{$config{shared_includes}}),
249 @{$config{lib_cppflags}},
250 @{$config{shared_cppflag}});
251 join(' ', $lib_cppflags,
252 (map { '-D'.quotify1($_) }
253 "OPENSSLDIR=\"$openssldir\"",
254 "ENGINESDIR=\"$enginesdir\""),
255 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
256 LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
257 $target{shared_cflag} || (),
258 @{$config{lib_cflags}},
259 @{$config{shared_cflag}},
260 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
261 LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
262 $config{shared_ldflag} || (),
263 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
264 LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
265 DSO_ASFLAGS={- join(' ', $target{dso_asflags} || (),
266 $target{module_asflags} || (),
267 @{$config{dso_asflags}},
268 @{$config{module_asflags}},
269 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
270 DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
271 $target{module_cppflags} || (),
272 @{$config{dso_cppflags}},
273 @{$config{module_cppflags}},
274 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
275 DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
276 $target{module_cflags} || (),
277 @{$config{dso_cflags}},
278 @{$config{module_cflags}},
279 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
280 DSO_LDFLAGS={- join(' ', $target{dso_lflags} || (),
281 $target{module_ldflags} || (),
282 @{$config{dso_lflags}},
283 @{$config{module_ldflags}},
284 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
285 DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
286 BIN_ASFLAGS={- join(' ', $target{bin_asflags} || (),
287 @{$config{bin_asflags}},
288 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
289 BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
290 @{$config{bin_cppflags}},
291 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
292 BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
293 @{$config{bin_cflags}},
294 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
295 BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
296 @{$config{bin_lflags}},
297 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
298 BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
299
300 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
301 CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
302 $cppflags2 =~ s|([\\"])|\\$1|g;
303 join(' ', $lib_cppflags || (), $cppflags2 || (),
304 $cppflags1 || ()) -}
305
306 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
307
308 PROCESSOR= {- $config{processor} -}
309
310 # The main targets ###################################################
311
312 {- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep
313 {- dependmagic('build_libs'); -}: build_libs_nodep
314 {- dependmagic('build_engines'); -}: build_engines_nodep
315 {- dependmagic('build_programs'); -}: build_programs_nodep
316
317 build_generated: $(GENERATED_MANDATORY)
318 build_libs_nodep: $(LIBS) {- join(" ",map { shlib_import($_) } @{$unified_info{libraries}}) -}
319 build_engines_nodep: $(ENGINES)
320 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
321
322 # Kept around for backward compatibility
323 build_apps build_tests: build_programs
324
325 # Convenience target to prebuild all generated files, not just the mandatory
326 # ones
327 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED)
328 @{- output_off() if $disabled{makedepend}; "" -}
329 @$(ECHO) "Warning: consider configuring with no-makedepend, because if"
330 @$(ECHO) " target system doesn't have $(PERL),"
331 @$(ECHO) " then make will fail..."
332 @{- output_on() if $disabled{makedepend}; "" -}
333
334 test: tests
335 {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep
336 @{- output_off() if $disabled{tests}; "" -}
337 -mkdir $(BLDDIR)\test\test-runs
338 set SRCTOP=$(SRCDIR)
339 set BLDTOP=$(BLDDIR)
340 set RESULT_D=$(BLDDIR)\test\test-runs
341 set PERL=$(PERL)
342 set OPENSSL_ENGINES=$(MAKEDIR)\engines
343 set OPENSSL_DEBUG_MEMORY=on
344 "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)
345 @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
346 @$(ECHO) "Tests are not supported with your chosen Configure options"
347 @{- output_on() if !$disabled{tests}; "" -}
348
349 list-tests:
350 @{- output_off() if $disabled{tests}; "" -}
351 @set SRCTOP=$(SRCDIR)
352 @"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list
353 @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
354 @$(ECHO) "Tests are not supported with your chosen Configure options"
355 @{- output_on() if !$disabled{tests}; "" -}
356
357 install: install_sw install_ssldirs install_docs
358
359 uninstall: uninstall_docs uninstall_sw
360
361 libclean:
362 "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """{.,apps,test,fuzz}/$$1.*"""; } @ARGV" $(SHLIBS)
363 -del /Q /F $(LIBS) libcrypto.* libssl.* ossl_static.pdb
364
365 clean: libclean
366 {- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) -}
367 -del /Q /F $(ENGINES)
368 -del /Q /F $(SCRIPTS)
369 -del /Q /F $(GENERATED_MANDATORY)
370 -del /Q /F $(GENERATED)
371 -del /Q /S /F *.d *.obj *.pdb *.ilk *.manifest
372 -del /Q /S /F engines\*.lib engines\*.exp
373 -del /Q /S /F apps\*.lib apps\*.rc apps\*.res apps\*.exp
374 -del /Q /S /F test\*.exp
375 -rmdir /Q /S test\test-runs
376
377 distclean: clean
378 -del /Q /F configdata.pm
379 -del /Q /F makefile
380
381 depend:
382 @ {- output_off() if $disabled{makedepend}; "" -}
383 @ "$(PERL)" "$(SRCDIR)\util\add-depends.pl" "VC"
384 @ {- output_on() if $disabled{makedepend}; "" -}
385
386 # Install helper targets #############################################
387
388 install_sw: all install_dev install_engines install_runtime
389
390 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
391
392 install_docs: install_html_docs
393
394 uninstall_docs: uninstall_html_docs
395
396 install_ssldirs:
397 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\certs"
398 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\private"
399 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\misc"
400 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
401 "$(OPENSSLDIR)\openssl.cnf.dist"
402 @IF NOT EXIST "$(OPENSSLDIR)\openssl.cnf" \
403 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
404 "$(OPENSSLDIR)\openssl.cnf"
405 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(MISC_SCRIPTS) \
406 "$(OPENSSLDIR)\misc"
407 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
408 "$(OPENSSLDIR)\ct_log_list.cnf.dist"
409 @IF NOT EXIST "$(OPENSSLDIR)\ct_log_list.cnf" \
410 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
411 "$(OPENSSLDIR)\ct_log_list.cnf"
412
413 install_dev:
414 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
415 @$(ECHO) "*** Installing development files"
416 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
417 @{- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$config{defines}}; "" -}
418 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
419 "$(INSTALLTOP)\include\openssl"
420 @{- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$config{defines}}; "" -}
421 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "-exclude_re=/__DECC_" \
422 "$(SRCDIR)\include\openssl\*.h" \
423 "$(INSTALLTOP)\include\openssl"
424 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(BLDDIR)\include\openssl\*.h" \
425 "$(INSTALLTOP)\include\openssl"
426 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(libdir)"
427 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) "$(libdir)"
428 @if "$(SHLIBS)"=="" \
429 "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb "$(libdir)"
430
431 uninstall_dev:
432
433 install_engines:
434 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
435 @$(ECHO) "*** Installing engines"
436 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)"
437 @if not "$(ENGINES)"=="" \
438 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)"
439 @if not "$(ENGINES)"=="" \
440 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINEPDBS) "$(ENGINESDIR)"
441
442 uninstall_engines:
443
444 install_runtime:
445 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
446 @$(ECHO) "*** Installing runtime files"
447 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
448 @if not "$(SHLIBS)"=="" \
449 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin"
450 @if not "$(SHLIBS)"=="" \
451 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBPDBS) \
452 "$(INSTALLTOP)\bin"
453 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \
454 "$(INSTALLTOP)\bin"
455 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \
456 "$(INSTALLTOP)\bin"
457 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \
458 "$(INSTALLTOP)\bin"
459
460 uninstall_runtime:
461
462 install_html_docs:
463 "$(PERL)" "$(SRCDIR)\util\process_docs.pl" \
464 "--destdir=$(INSTALLTOP)\html" --type=html
465
466 uninstall_html_docs:
467
468 # Building targets ###################################################
469
470 configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
471 @$(ECHO) "Detected changed: $?"
472 "$(PERL)" configdata.pm -r
473 @$(ECHO) "**************************************************"
474 @$(ECHO) "*** ***"
475 @$(ECHO) "*** Please run the same make command again ***"
476 @$(ECHO) "*** ***"
477 @$(ECHO) "**************************************************"
478 @exit 1
479
480 reconfigure reconf:
481 "$(PERL)" configdata.pm -r
482
483 {-
484 use File::Basename;
485 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
486
487 # Helper function to figure out dependencies on libraries
488 # It takes a list of library names and outputs a list of dependencies
489 sub compute_lib_depends {
490 if ($disabled{shared}) {
491 return map { lib($_) } @_;
492 }
493 foreach (@_) {
494 (my $l = $_) =~ s/\.a$//;
495 die "Linking with static variants of shared libraries is not supported in this configuration\n"
496 if $l ne $_ && shlib($l);
497 }
498 return map { shlib_import($_) or lib($_) } @_;
499 }
500
501 sub generatesrc {
502 my %args = @_;
503 my ($gen0, @gens) = @{$args{generator}};
504 my $generator = '"'.$gen0.'"'.join('', map { " $_" } @gens);
505 my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}});
506 my $incs = join("", map { " /I \"$_\"" } @{$args{incs}});
507 my $deps = @{$args{deps}} ?
508 '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : '';
509
510 if ($args{src} =~ /\.ld$/) {
511 (my $target = $args{src}) =~ s/\.ld$/$defext/;
512 my $mkdef = abs2rel(rel2abs(catfile($config{sourcedir},
513 "util", "mkdef.pl")),
514 rel2abs($config{builddir}));
515 my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
516 my $ord_name =
517 $args{generator}->[1] || basename($args{product}, $dsoext);
518 return <<"EOF";
519 $target: $args{generator}->[0] $deps $mkdef
520 \$(PERL) $mkdef$ord_ver --ordinals $args{generator}->[0] --name $ord_name --OS windows > $target
521 EOF
522 } elsif ($args{src} !~ /\.[sS]$/) {
523 my $target = $args{src};
524 if ($args{generator}->[0] =~ m|^.*\.in$|) {
525 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
526 "util", "dofile.pl")),
527 rel2abs($config{builddir}));
528 return <<"EOF";
529 $target: "$args{generator}->[0]" $deps
530 "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
531 "-o$target{build_file}" $generator > \$@
532 EOF
533 } else {
534 return <<"EOF";
535 $target: "$args{generator}->[0]" $deps
536 "\$(PERL)"$generator_incs $generator > \$@
537 EOF
538 }
539 } else {
540 (my $target = $args{src}) =~ s/\.[sS]$/.asm/;
541 if ($args{generator}->[0] =~ /\.pl$/) {
542 $generator = '"$(PERL)"'.$generator_incs.' '.$generator;
543 } elsif ($args{generator}->[0] =~ /\.S$/) {
544 $generator = undef;
545 } else {
546 die "Generator type for $src unknown: $generator\n";
547 }
548
549 my $cppflags = $incs;
550 $cppflags .= {
551 shlib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
552 lib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)',
553 dso => ' $(DSO_CFLAGS) $(DSO_CPPFLAGS)',
554 bin => ' $(BIN_CFLAGS) $(BIN_CPPFLAGS)'
555 } -> {$args{intent}};
556 if (defined($generator)) {
557 # If the target is named foo.S in build.info, we want to
558 # end up generating foo.s in two steps.
559 if ($args{src} =~ /\.S$/) {
560 return <<"EOF";
561 $target: "$args{generator}->[0]" $deps
562 set ASM=\$(AS)
563 $generator \$@.S
564 \$(CPP) $cppflags \$@.S > \$@.i && move /Y \$@.i \$@
565 del /Q \$@.S
566 EOF
567 }
568 # Otherwise....
569 return <<"EOF";
570 $target: "$args{generator}->[0]" $deps
571 set ASM=\$(AS)
572 $generator \$@
573 EOF
574 }
575 return <<"EOF";
576 $target: "$args{generator}->[0]" $deps
577 \$(CPP) $incs $cppflags "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@
578 EOF
579 }
580 }
581
582 sub src2obj {
583 my %args = @_;
584 my @srcs = map { (my $x = $_) =~ s/\.s$/.asm/; $x
585 } ( @{$args{srcs}} );
586 my $srcs = '"'.join('" "', @srcs).'"';
587 my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"';
588 my $incs = join("", map { ' /I "'.$_.'"' } @{$args{incs}});
589 my $cflags = { shlib => ' $(LIB_CFLAGS)',
590 lib => ' $(LIB_CFLAGS)',
591 dso => ' $(DSO_CFLAGS)',
592 bin => ' $(BIN_CFLAGS)' } -> {$args{intent}};
593 $cflags .= $incs;
594 $cflags .= { shlib => ' $(LIB_CPPFLAGS)',
595 lib => ' $(LIB_CPPFLAGS)',
596 dso => ' $(DSO_CPPFLAGS)',
597 bin => ' $(BIN_CPPFLAGS)' } -> {$args{intent}};
598 my $asflags = { shlib => ' $(LIB_ASFLAGS)',
599 lib => ' $(LIB_ASFLAGS)',
600 dso => ' $(DSO_ASFLAGS)',
601 bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
602 my $makedepprog = $config{makedepprog};
603 if ($srcs[0] =~ /\.rc$/) {
604 return <<"EOF";
605 $args{obj}: $deps
606 \$(RC) \$(RCOUTFLAG)\$\@ $srcs
607 EOF
608 }
609 (my $obj = $args{obj}) =~ s|\.o$||;
610 if ($srcs[0] =~ /\.asm$/) {
611 return <<"EOF";
612 $obj$objext: $deps
613 \$(AS) $asflags \$(ASOUTFLAG)\$\@ $srcs
614 EOF
615 } elsif ($srcs[0] =~ /.S$/) {
616 return <<"EOF";
617 $obj$objext: $deps
618 \$(CC) /EP /D__ASSEMBLER__ $cflags $srcs > \$@.asm && \$(AS) $asflags \$(ASOUTFLAG)\$\@ \$@.asm
619 EOF
620 }
621 return <<"EOF" if (!$disabled{makedepend});
622 $obj$depext: $deps
623 \$(CC) $cflags /Zs /showIncludes $srcs 2>&1 > $obj$depext
624 $obj$objext: $obj$depext
625 \$(CC) $cflags -c \$(COUTFLAG)\$\@ $srcs
626 EOF
627 return <<"EOF" if ($disabled{makedepend});
628 $obj$objext: $deps
629 \$(CC) $cflags -c \$(COUTFLAG)\$\@ $srcs
630 EOF
631 }
632
633 # On Unix, we build shlibs from static libs, so we're ignoring the
634 # object file array. We *know* this routine is only called when we've
635 # configure 'shared'.
636 sub obj2shlib {
637 my %args = @_;
638 my $lib = $args{lib};
639 my $shlib = $args{shlib};
640 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x }
641 grep { $_ =~ m/\.(?:o|res)$/ }
642 @{$args{objs}};
643 my @defs = map { (my $x = $_) =~ s|\.ld$||; "$x$defext" }
644 grep { $_ =~ /\.ld$/ }
645 @{$args{objs}};
646 my @deps = compute_lib_depends(@{$args{deps}});
647 die "More than one exported symbols list" if scalar @defs > 1;
648 my $linklibs = join("", map { "$_\n" } @deps);
649 my $objs = join("\n", @objs);
650 my $deps = join(" ", @objs, @defs, @deps);
651 my $target = shlib_import($lib);
652 my $shared_def = join("", map { " /def:$_" } @defs);
653 return <<"EOF"
654 $target: $deps
655 IF EXIST $shlib$shlibext.manifest DEL /F /Q $shlib$shlibext.manifest
656 IF EXIST \$@ DEL /F /Q \$@
657 \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
658 /implib:\$@ \$(LDOUTFLAG)$shlib$shlibext$shared_def @<< || (DEL /Q \$(\@B).* $shlib.* && EXIT 1)
659 $objs
660 $linklibs\$(LIB_EX_LIBS)
661 <<
662 IF EXIST $shlib$shlibext.manifest \\
663 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$shlib$shlibext.manifest \$(MTOUTFLAG)$shlib$shlibext
664 IF EXIST apps\\$shlib$shlibext DEL /Q /F apps\\$shlib$shlibext
665 IF EXIST test\\$shlib$shlibext DEL /Q /F test\\$shlib$shlibext
666 IF EXIST fuzz\\$shlib$shlibext DEL /Q /F fuzz\\$shlib$shlibext
667 COPY $shlib$shlibext apps
668 COPY $shlib$shlibext test
669 COPY $shlib$shlibext fuzz
670 EOF
671 }
672 sub obj2dso {
673 my %args = @_;
674 my $dso = $args{lib};
675 my $dso_n = basename($dso);
676 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x }
677 grep { $_ =~ m/\.(?:o|res)$/ }
678 @{$args{objs}};
679 my @defs = map { (my $x = $_) =~ s|\.ld$|$defext|; $x }
680 grep { $_ =~ /\.ld$/ }
681 @{$args{objs}};
682 my @deps = compute_lib_depends(@{$args{deps}});
683 my $objs = join("\n", @objs);
684 my $linklibs = join("", map { "$_\n" } @deps);
685 my $deps = join(" ", @objs, @defs, @deps);
686 my $shared_def = join("", map { " /def:$_" } @defs);
687 return <<"EOF";
688 $dso$dsoext: $deps
689 IF EXIST $dso$dsoext.manifest DEL /F /Q $dso$dsoext.manifest
690 \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \\
691 \$(LDOUTFLAG)$dso$dsoext$shared_def @<< || (DEL /Q \$(\@B).* $dso.* && EXIT 1)
692 $objs
693 $linklibs \$(DSO_EX_LIBS)
694 <<
695 IF EXIST $dso$dsoext.manifest \\
696 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso$dsoext.manifest \$(MTOUTFLAG)$dso$dsoext
697 EOF
698 }
699 sub obj2lib {
700 my %args = @_;
701 my $lib = $args{lib};
702
703 # Because static libs and import libs are both named the same in native
704 # Windows, we can't have both. We skip the static lib in that case,
705 # as the shared libs are what we use anyway.
706 return "" unless $disabled{"shared"} || $lib =~ /\.a$/;
707
708 $lib =~ s/\.a$//;
709 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
710 my $objs = join("\n", @objs);
711 my $deps = join(" ", @objs);
712 return <<"EOF";
713 $lib$libext: $deps
714 \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib$libext @<<
715 $objs
716 <<
717 EOF
718 }
719 sub obj2bin {
720 my %args = @_;
721 my $bin = $args{bin};
722 my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}};
723 my @deps = compute_lib_depends(@{$args{deps}});
724 my $objs = join("\n", @objs);
725 my $linklibs = join("", map { "$_\n" } @deps);
726 my $deps = join(" ", @objs, @deps);
727 return <<"EOF";
728 $bin$exeext: $deps
729 IF EXIST $bin$exeext.manifest DEL /F /Q $bin$exeext.manifest
730 \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin$exeext @<<
731 $objs
732 setargv.obj
733 $linklibs\$(BIN_EX_LIBS)
734 <<
735 IF EXIST $bin$exeext.manifest \\
736 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin$exeext.manifest \$(MTOUTFLAG)$bin$exeext
737 EOF
738 }
739 sub in2script {
740 my %args = @_;
741 my $script = $args{script};
742 my $sources = '"'.join('" "', @{$args{sources}}).'"';
743 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
744 "util", "dofile.pl")),
745 rel2abs($config{builddir}));
746 return <<"EOF";
747 $script: $sources
748 "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
749 "-o$target{build_file}" $sources > "$script"
750 EOF
751 }
752 sub generatedir {
753 my %args = @_;
754 my $dir = $args{dir};
755 my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}};
756 my @actions = ();
757 my %extinfo = ( dso => $dsoext,
758 lib => $libext,
759 bin => $exeext );
760
761 foreach my $type (("dso", "lib", "bin", "script")) {
762 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
763 # For lib object files, we could update the library. However,
764 # LIB on Windows doesn't work that way, so we won't create any
765 # actions for it, and the dependencies are already taken care of.
766 if ($type ne "lib") {
767 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
768 if (dirname($prod) eq $dir) {
769 push @deps, $prod.$extinfo{$type};
770 }
771 }
772 }
773 }
774
775 my $deps = join(" ", @deps);
776 my $actions = join("\n", "", @actions);
777 return <<"EOF";
778 $args{dir} $args{dir}\\ : $deps$actions
779 EOF
780 }
781 "" # Important! This becomes part of the template result.
782 -}