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