2 ## Makefile for OpenSSL
4 ## {- join("\n## ", @autowarntext) -}
8 our $sover_dirname = platform->shlib_version_as_filename();
10 my $build_scheme = $target{build_scheme};
11 my $install_flavour = $build_scheme->[$#$build_scheme]; # last element
13 $install_flavour eq "VC-WOW" ? "ProgramFiles(x86)"
16 $install_flavour eq "VC-WOW" ? "CommonProgramFiles(x86)"
17 : "CommonProgramW6432";
18 our $win_installroot =
19 defined($ENV{$win_installenv}) ? $win_installenv : 'ProgramFiles';
21 defined($ENV{$win_commonenv}) ? $win_commonenv : 'CommonProgramFiles';
23 # expand variables early
24 $win_installroot = $ENV{$win_installroot};
25 $win_commonroot = $ENV{$win_commonroot};
27 # This makes sure things get built in the order they need
32 return "$target: build_generated\n\t\$(MAKE) /\$(MAKEFLAGS) depend && \$(MAKE) /\$(MAKEFLAGS) _$target\n_$target";
37 PLATFORM={- $config{target} -}
38 SRCDIR={- $config{sourcedir} -}
39 BLDDIR={- $config{builddir} -}
41 VERSION={- "$config{full_version}" -}
42 MAJOR={- $config{major} -}
43 MINOR={- $config{minor} -}
45 SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
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={- our @MODULES = map { platform->dso($_) } @{$unified_info{modules}};
51 join(" ", @MODULES) -}
52 MODULEPDBS={- join(" ", map { platform->dsopdb($_) } @{$unified_info{modules}}) -}
53 PROGRAMS={- our @PROGRAMS = map { platform->bin($_) } @{$unified_info{programs}}; join(" ", @PROGRAMS) -}
54 PROGRAMPDBS={- join(" ", map { $_.".pdb" } @{$unified_info{programs}}) -}
55 SCRIPTS={- our @SCRIPTS = @{$unified_info{scripts}}; join(" ", @SCRIPTS) -}
56 {- output_off() if $disabled{makedepend}; "" -}
57 DEPS={- join(" ", map { platform->isobj($_) ? platform->dep($_) : () }
58 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
59 keys %{$unified_info{sources}}); -}
60 {- output_on() if $disabled{makedepend}; "" -}
61 GENERATED_MANDATORY={- our @GENERATED_MANDATORY = @{$unified_info{depends}->{""}};
62 join(" ", @GENERATED_MANDATORY) -}
63 GENERATED={- # common0.tmpl provides @generated
64 our @GENERATED = map { platform->convertext($_) } @generated;
65 join(" ", @GENERATED) -}
68 join(" ", map { quotify1(platform->sharedlib_import($_)
69 // platform->staticlib($_)) }
70 grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
71 @{$unified_info{libraries}})
74 join(" ", map { my $x = platform->sharedlib($_);
75 $x ? quotify_l($x) : () }
76 grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
77 @{$unified_info{libraries}})
80 join(" ", map { my $x = platform->sharedlibpdb($_);
81 $x ? quotify_l($x) : () }
82 grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
83 @{$unified_info{libraries}})
86 join(" ", map { quotify1(platform->dso($_)) }
87 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
88 && $unified_info{attributes}->{modules}->{$_}->{engine} }
89 @{$unified_info{modules}})
92 join(" ", map { quotify1(platform->dsopdb($_)) }
93 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
94 && $unified_info{attributes}->{modules}->{$_}->{engine} }
95 @{$unified_info{modules}})
98 join(" ", map { quotify1(platform->bin($_)) }
99 grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
100 @{$unified_info{programs}})
102 INSTALL_PROGRAMPDBS={-
103 join(" ", map { quotify1(platform->binpdb($_)) }
104 grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
105 @{$unified_info{programs}})
108 join(" ", map { quotify1($_) }
109 grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
110 && !$unified_info{attributes}->{scripts}->{$_}->{misc} }
111 @{$unified_info{scripts}})
114 join(" ", map { quotify1($_) }
115 grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
116 && $unified_info{attributes}->{scripts}->{$_}->{misc} }
117 @{$unified_info{scripts}})
119 HTMLDOCS1={- our @HTMLDOCS1 = @{$unified_info{htmldocs}->{man1}};
120 join(" ", @HTMLDOCS1) -}
121 HTMLDOCS3={- our @HTMLDOCS3 = @{$unified_info{htmldocs}->{man3}};
122 join(" ", @HTMLDOCS3) -}
123 HTMLDOCS5={- our @HTMLDOCS5 = @{$unified_info{htmldocs}->{man5}};
124 join(" ", @HTMLDOCS5) -}
125 HTMLDOCS7={- our @HTMLDOCS7 = @{$unified_info{htmldocs}->{man7}};
126 join(" ", @HTMLDOCS7) -}
127 HTMLDOCS1_BLDDIRS={- my %dirs = map { dirname($_) => 1 } @HTMLDOCS1;
128 join(' ', sort keys %dirs) -}
129 HTMLDOCS3_BLDDIRS={- my %dirs = map { dirname($_) => 1 } @HTMLDOCS3;
130 join(' ', sort keys %dirs) -}
131 HTMLDOCS5_BLDDIRS={- my %dirs = map { dirname($_) => 1 } @HTMLDOCS5;
132 join(' ', sort keys %dirs) -}
133 HTMLDOCS7_BLDDIRS={- my %dirs = map { dirname($_) => 1 } @HTMLDOCS7;
134 join(' ', sort keys %dirs) -}
136 APPS_OPENSSL="{- use File::Spec::Functions;
137 catfile("apps","openssl") -}"
139 # Do not edit these manually. Use Configure with --prefix or --openssldir
140 # to change this! Short explanation in the top comment in Configure
141 INSTALLTOP_dev={- # $prefix is used in the OPENSSLDIR perl snippet
143 use File::Spec::Functions qw(:DEFAULT splitpath);
144 our $prefix = canonpath($config{prefix}
145 || "$win_installroot\\OpenSSL");
146 our ($prefix_dev, $prefix_dir, $prefix_file) =
147 splitpath($prefix, 1);
149 INSTALLTOP_dir={- canonpath($prefix_dir) -}
151 # The logic here is that if no --openssldir was given,
152 # OPENSSLDIR will get the value "$win_commonroot\\SSL".
153 # If --openssldir was given and the value is an absolute
154 # path, OPENSSLDIR will get its value without change.
155 # If the value from --openssldir is a relative path,
156 # OPENSSLDIR will get $prefix with the --openssldir
157 # value appended as a subdirectory.
159 use File::Spec::Functions qw(:DEFAULT splitpath);
161 $config{openssldir} ?
162 (file_name_is_absolute($config{openssldir}) ?
163 canonpath($config{openssldir})
164 : catdir($prefix, $config{openssldir}))
165 : canonpath("$win_commonroot\\SSL");
166 our ($openssldir_dev, $openssldir_dir, $openssldir_file) =
167 splitpath($openssldir, 1);
169 OPENSSLDIR_dir={- canonpath($openssldir_dir) -}
170 LIBDIR={- our $libdir = $config{libdir} || "lib";
171 file_name_is_absolute($libdir) ? "" : $libdir -}
172 MODULESDIR_dev={- use File::Spec::Functions qw(:DEFAULT splitpath catpath);
173 our $modulesprefix = catdir($prefix,$libdir);
174 our ($modulesprefix_dev, $modulesprefix_dir,
175 $modulesprefix_file) =
176 splitpath($modulesprefix, 1);
177 our $modulesdir_dev = $modulesprefix_dev;
178 our $modulesdir_dir =
179 catdir($modulesprefix_dir, "ossl-modules");
180 our $modulesdir = catpath($modulesdir_dev, $modulesdir_dir);
181 our $enginesdir_dev = $modulesprefix_dev;
182 our $enginesdir_dir =
183 catdir($modulesprefix_dir, "engines-$sover_dirname");
184 our $enginesdir = catpath($enginesdir_dev, $enginesdir_dir);
186 MODULESDIR_dir={- canonpath($modulesdir_dir) -}
187 ENGINESDIR_dev={- $enginesdir_dev -}
188 ENGINESDIR_dir={- canonpath($enginesdir_dir) -}
189 !IF "$(DESTDIR)" != ""
190 INSTALLTOP=$(DESTDIR)$(INSTALLTOP_dir)
191 OPENSSLDIR=$(DESTDIR)$(OPENSSLDIR_dir)
192 ENGINESDIR=$(DESTDIR)$(ENGINESDIR_dir)
193 MODULESDIR=$(DESTDIR)$(MODULESDIR_dir)
195 INSTALLTOP=$(INSTALLTOP_dev)$(INSTALLTOP_dir)
196 OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir)
197 ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir)
198 MODULESDIR=$(MODULESDIR_dev)$(MODULESDIR_dir)
201 # $(libdir) is chosen to be compatible with the GNU coding standards
202 libdir={- file_name_is_absolute($libdir)
203 ? $libdir : '$(INSTALLTOP)\$(LIBDIR)' -}
205 ##### User defined commands and flags ################################
207 CC="{- $config{CC} -}"
208 CPP="{- $config{CPP} -}"
209 CPPFLAGS={- our $cppflags1 = join(" ",
210 (map { "-D".$_} @{$config{CPPDEFINES}}),
211 (map { " -I ".$_} @{$config{CPPINCLUDES}}),
212 @{$config{CPPFLAGS}}) -}
213 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
214 LD="{- $config{LD} -}"
215 LDFLAGS={- join(' ', @{$config{LDFLAGS}}) -}
216 EX_LIBS={- join(' ', @{$config{LDLIBS}}) -}
218 PERL={- $config{PERL} -}
220 AR="{- $config{AR} -}"
221 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
223 MT="{- $config{MT} -}"
224 MTFLAGS= {- join(' ', @{$config{MTFLAGS}}) -}
226 AS="{- $config{AS} -}"
227 ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
229 RC="{- $config{RC} -}"
230 RCFLAGS={- join(' ', @{$config{RCFLAGS}}) -}
232 ECHO="$(PERL)" "$(SRCDIR)\util\echo.pl"
234 ##### Special command flags ##########################################
236 COUTFLAG={- $target{coutflag} -}$(OSSL_EMPTY)
237 LDOUTFLAG={- $target{ldoutflag} -}$(OSSL_EMPTY)
238 AROUTFLAG={- $target{aroutflag} -}$(OSSL_EMPTY)
239 MTINFLAG={- $target{mtinflag} -}$(OSSL_EMPTY)
240 MTOUTFLAG={- $target{mtoutflag} -}$(OSSL_EMPTY)
241 ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
242 RCOUTFLAG={- $target{rcoutflag} -}$(OSSL_EMPTY)
244 ##### Project flags ##################################################
246 # Variables starting with CNF_ are common variables for all product types
248 CNF_ASFLAGS={- join(' ', $target{asflags} || (),
249 @{$config{asflags}}) -}
250 CNF_CPPFLAGS={- our $cppfags2 =
251 join(' ', $target{cppflags} || (),
252 (map { '-D'.quotify1($_) } @{$target{defines}},
253 @{$config{defines}}),
254 (map { '-I'.quotify1($_) } @{$target{includes}},
255 @{$config{includes}}),
256 @{$config{cppflags}}) -}
257 CNF_CFLAGS={- join(' ', $target{cflags} || (),
258 @{$config{cflags}}) -}
259 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
260 @{$config{cxxflags}}) -}
261 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
262 @{$config{lflags}}) -}
263 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
264 @{$config{ex_libs}}) -}
266 # Variables starting with LIB_ are used to build library object files
267 # and shared libraries.
268 # Variables starting with DSO_ are used to build DSOs and their object files.
269 # Variables starting with BIN_ are used to build programs and their object
272 LIB_ASFLAGS={- join(' ', $target{lib_asflags} || (),
273 @{$config{lib_asflags}},
274 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
275 LIB_CPPFLAGS={- our $lib_cppflags =
276 join(' ', $target{lib_cppflags} || (),
277 $target{shared_cppflag} || (),
278 (map { '-D'.quotify1($_) }
279 @{$target{lib_defines}},
280 @{$target{shared_defines}},
281 @{$config{lib_defines}},
282 @{$config{shared_defines}}),
283 (map { '-I'.quotify1($_) }
284 @{$target{lib_includes}},
285 @{$target{shared_includes}},
286 @{$config{lib_includes}},
287 @{$config{shared_includes}}),
288 @{$config{lib_cppflags}},
289 @{$config{shared_cppflag}});
290 join(' ', $lib_cppflags,
291 (map { '-D'.quotify1($_) }
292 "OPENSSLDIR=\"$openssldir\"",
293 "ENGINESDIR=\"$enginesdir\"",
294 "MODULESDIR=\"$modulesdir\""),
295 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
296 LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
297 $target{shared_cflag} || (),
298 @{$config{lib_cflags}},
299 @{$config{shared_cflag}},
300 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
301 LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
302 $config{shared_ldflag} || (),
303 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
304 LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
305 DSO_ASFLAGS={- join(' ', $target{dso_asflags} || (),
306 $target{module_asflags} || (),
307 @{$config{dso_asflags}},
308 @{$config{module_asflags}},
309 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
310 DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
311 $target{module_cppflag} || (),
312 (map { '-D'.quotify1($_) }
313 @{$target{dso_defines}},
314 @{$target{module_defines}},
315 @{$config{dso_defines}},
316 @{$config{module_defines}}),
317 (map { '-I'.quotify1($_) }
318 @{$target{dso_includes}},
319 @{$target{module_includes}},
320 @{$config{dso_includes}},
321 @{$config{module_includes}}),
322 @{$config{dso_cppflags}},
323 @{$config{module_cppflags}},
324 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
325 DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
326 $target{module_cflags} || (),
327 @{$config{dso_cflags}},
328 @{$config{module_cflags}},
329 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
330 DSO_LDFLAGS={- join(' ', $target{dso_lflags} || (),
331 $target{module_ldflags} || (),
332 @{$config{dso_lflags}},
333 @{$config{module_ldflags}},
334 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
335 DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
336 BIN_ASFLAGS={- join(' ', $target{bin_asflags} || (),
337 @{$config{bin_asflags}},
338 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
339 BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
340 (map { '-D'.$_ } @{$config{bin_defines} || ()}),
341 @{$config{bin_cppflags}},
342 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
343 BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
344 @{$config{bin_cflags}},
345 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
346 BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
347 @{$config{bin_lflags}},
348 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
349 BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
351 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
352 CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
353 $cppflags2 =~ s|([\\"])|\\$1|g;
354 join(' ', $lib_cppflags || (), $cppflags2 || (),
357 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
359 PROCESSOR= {- $config{processor} -}
361 # The main targets ###################################################
363 {- dependmagic('build_sw'); -}: build_libs_nodep build_modules_nodep build_programs_nodep copy-utils
364 {- dependmagic('build_libs'); -}: build_libs_nodep
365 {- dependmagic('build_modules'); -}: build_modules_nodep
366 {- dependmagic('build_programs'); -}: build_programs_nodep
368 build_docs: build_html_docs
369 build_html_docs: $(HTMLDOCS1) $(HTMLDOCS3) $(HTMLDOCS5) $(HTMLDOCS7)
371 build_generated: $(GENERATED_MANDATORY)
372 build_libs_nodep: $(LIBS) {- join(" ",map { platform->sharedlib_import($_) // () } @{$unified_info{libraries}}) -}
373 build_modules_nodep: $(MODULES)
374 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
376 # Kept around for backward compatibility
377 build_apps build_tests: build_programs
379 # Convenience target to prebuild all generated files, not just the mandatory
381 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED) build_docs
382 @{- output_off() if $disabled{makedepend}; "" -}
383 @$(ECHO) "Warning: consider configuring with no-makedepend, because if"
384 @$(ECHO) " target system doesn't have $(PERL),"
385 @$(ECHO) " then make will fail..."
386 @{- output_on() if $disabled{makedepend}; "" -}
388 all: build_sw build_docs
391 {- dependmagic('tests'); -}: build_programs_nodep build_modules_nodep copy-utils
392 @{- output_off() if $disabled{tests}; "" -}
396 "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)
397 @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
398 @$(ECHO) "Tests are not supported with your chosen Configure options"
399 @{- output_on() if !$disabled{tests}; "" -}
402 @{- output_off() if $disabled{tests}; "" -}
403 @set SRCTOP=$(SRCDIR)
404 @"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list
405 @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
406 @$(ECHO) "Tests are not supported with your chosen Configure options"
407 @{- output_on() if !$disabled{tests}; "" -}
409 install: install_sw install_ssldirs install_docs
411 uninstall: uninstall_docs uninstall_sw
414 "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """{.,apps,test,fuzz}/$$1.*"""; } @ARGV" $(SHLIBS)
415 -del /Q /F $(LIBS) libcrypto.* libssl.* ossl_static.pdb
418 -rmdir /Q /S $(HTMLDOCS1_BLDDIRS)
419 -rmdir /Q /S $(HTMLDOCS3_BLDDIRS)
420 -rmdir /Q /S $(HTMLDOCS5_BLDDIRS)
421 -rmdir /Q /S $(HTMLDOCS7_BLDDIRS)
422 {- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) -}
423 {- join("\n\t", map { "-del /Q /F $_" } @MODULES) -}
424 {- join("\n\t", map { "-del /Q /F $_" } @SCRIPTS) -}
425 {- join("\n\t", map { "-del /Q /F $_" } @GENERATED_MANDATORY) -}
426 {- join("\n\t", map { "-del /Q /F $_" } @GENERATED) -}
427 -del /Q /S /F *.d *.obj *.pdb *.ilk *.manifest
428 -del /Q /S /F engines\*.lib engines\*.exp
429 -del /Q /S /F apps\*.lib apps\*.rc apps\*.res apps\*.exp
430 -del /Q /S /F test\*.exp
431 -rmdir /Q /S test\test-runs
434 -del /Q /F configdata.pm
438 @ {- output_off() if $disabled{makedepend}; "" -}
439 @ "$(PERL)" "$(SRCDIR)\util\add-depends.pl" "VC"
440 @ {- output_on() if $disabled{makedepend}; "" -}
442 # Install helper targets #############################################
444 install_sw: install_dev install_engines install_runtime
446 uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev
448 install_docs: install_html_docs
450 uninstall_docs: uninstall_html_docs
453 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\certs"
454 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\private"
455 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\misc"
456 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
457 "$(OPENSSLDIR)\openssl.cnf.dist"
458 @IF NOT EXIST "$(OPENSSLDIR)\openssl.cnf" \
459 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
460 "$(OPENSSLDIR)\openssl.cnf"
461 @if not "$(MISC_SCRIPTS)"=="" \
462 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(MISC_SCRIPTS) \
464 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
465 "$(OPENSSLDIR)\ct_log_list.cnf.dist"
466 @IF NOT EXIST "$(OPENSSLDIR)\ct_log_list.cnf" \
467 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
468 "$(OPENSSLDIR)\ct_log_list.cnf"
470 install_dev: install_runtime_libs
471 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
472 @$(ECHO) "*** Installing development files"
473 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
474 @{- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
475 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
476 "$(INSTALLTOP)\include\openssl"
477 @{- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
478 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "-exclude_re=/__DECC_" \
479 "$(SRCDIR)\include\openssl\*.h" \
480 "$(INSTALLTOP)\include\openssl"
481 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(BLDDIR)\include\openssl\*.h" \
482 "$(INSTALLTOP)\include\openssl"
483 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(libdir)"
484 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) "$(libdir)"
485 @if "$(SHLIBS)"=="" \
486 "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb "$(libdir)"
490 install_engines: install_runtime_libs build_modules
491 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
492 @$(ECHO) "*** Installing ENGINE modules"
493 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)"
494 @if not "$(INSTALL_ENGINES)"=="" \
495 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)"
496 @if not "$(INSTALL_ENGINES)"=="" \
497 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINEPDBS) "$(ENGINESDIR)"
501 install_runtime: install_programs
503 install_runtime_libs: build_libs
504 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
505 @$(ECHO) "*** Installing runtime libraries"
506 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
507 @if not "$(SHLIBS)"=="" \
508 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin"
509 @if not "$(SHLIBS)"=="" \
510 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBPDBS) \
513 install_programs: install_runtime_libs build_programs
514 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
515 @$(ECHO) "*** Installing runtime programs"
516 @if not "$(INSTALL_PROGRAMS)"=="" \
517 "$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
518 @if not "$(INSTALL_PROGRAMS)"=="" \
519 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \
521 @if not "$(INSTALL_PROGRAMS)"=="" \
522 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \
524 @if not "$(INSTALL_PROGRAMS)"=="" \
525 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \
530 install_html_docs: build_html_docs
531 @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
532 @echo *** Installing HTML docs
533 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man1"
534 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man3"
535 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man5"
536 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man7"
537 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man1\*.html \
538 "$(INSTALLTOP)\html\man1"
539 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man3\*.html \
540 "$(INSTALLTOP)\html\man3"
541 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man5\*.html \
542 "$(INSTALLTOP)\html\man5"
543 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man7\*.html \
544 "$(INSTALLTOP)\html\man7"
548 # Helper targets #####################################################
550 copy-utils: $(BLDDIR)\util\wrap.pl
552 $(BLDDIR)\util\wrap.pl: configdata.pm
553 @if NOT EXIST "$(BLDDIR)\util" mkdir "$(BLDDIR)\util"
554 @if NOT "$(SRCDIR)"=="$(BLDDIR)" copy "$(SRCDIR)\util\$(@F)" "$(BLDDIR)\util"
556 # Building targets ###################################################
558 configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
559 @$(ECHO) "Detected changed: $?"
560 "$(PERL)" configdata.pm -r
561 @$(ECHO) "**************************************************"
563 @$(ECHO) "*** Please run the same make command again ***"
565 @$(ECHO) "**************************************************"
569 "$(PERL)" configdata.pm -r
573 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
575 # Helper function to figure out dependencies on libraries
576 # It takes a list of library names and outputs a list of dependencies
577 sub compute_lib_depends {
578 if ($disabled{shared}) {
579 return map { platform->staticlib($_) } @_;
581 return map { platform->sharedlib_import($_) // platform->staticlib($_) } @_;
586 my ($gen0, @gens) = @{$args{generator}};
587 my $generator = '"'.$gen0.'"'.join('', map { " $_" } @gens);
588 my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}});
589 my $incs = join("", map { " -I \"$_\"" } @{$args{incs}});
590 my $defs = join("", map { " -D".$_ } @{$args{defs}});
591 my $deps = @{$args{deps}} ?
592 '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : '';
594 if ($args{src} =~ /\.html$/) {
595 my $title = basename($args{src}, ".html");
596 my $pod = $args{generator}->[0];
599 \$(PERL) \$(SRCDIR)/util/mkpod2html.pl -i "$pod" -o \$\@ -t "$title" -r "\$(SRCDIR)/doc"
601 } elsif (platform->isdef($args{src})) {
602 my $target = platform->def($args{src});
603 my $mkdef = abs2rel(rel2abs(catfile($config{sourcedir},
604 "util", "mkdef.pl")),
605 rel2abs($config{builddir}));
606 my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
608 $args{generator}->[1] || platform->dsoname($args{product});
610 $target: $args{generator}->[0] $deps $mkdef
611 "\$(PERL)" $mkdef$ord_ver --ordinals $args{generator}->[0] --name $ord_name --OS windows > $target
613 } elsif (!platform->isasm($args{src})) {
614 my $target = $args{src};
615 if ($args{generator}->[0] =~ m|^.*\.in$|) {
616 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
617 "util", "dofile.pl")),
618 rel2abs($config{builddir}));
619 my @modules = ( 'configdata.pm',
620 grep { $_ =~ m|\.pm$| } @{$args{deps}} );
621 my %moduleincs = map { '"-I'.dirname($_).'"' => 1 } @modules;
622 @modules = map { "-M".basename($_, '.pm') } @modules;
623 my $modules = join(' ', '', sort keys %moduleincs, @modules);
625 $target: "$args{generator}->[0]" $deps
626 "\$(PERL)"$modules "$dofile" "-o$target{build_file}" $generator > \$@
630 $target: "$args{generator}->[0]" $deps
631 "\$(PERL)"$generator_incs $generator > \$@
636 shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
637 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
638 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
639 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
640 } -> {$args{intent}};
641 my $target = platform->asm($args{src});
643 if ($args{generator}->[0] =~ /\.pl$/) {
644 $generator = '"$(PERL)"'.$generator_incs.' '.$generator
645 .' "$(PERLASM_SCHEME)"'.$incs.' '.$cppflags.$defs.' $(PROCESSSOR)';
646 } elsif ($args{generator}->[0] =~ /\.S$/) {
649 die "Generator type for $src unknown: $generator\n";
652 if (defined($generator)) {
653 # If the target is named foo.S in build.info, we want to
654 # end up generating foo.s in two steps.
655 if ($args{src} =~ /\.S$/) {
657 $target: "$args{generator}->[0]" $deps
660 \$(CPP) $incs $cppflags $defs \$@.S > \$@.i && move /Y \$@.i \$@
666 $target: "$args{generator}->[0]" $deps
672 $target: "$args{generator}->[0]" $deps
673 \$(CPP) $incs $cppflags $defs "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@
679 my $asmext = platform->asmext();
683 (platform->isasm($x) && grep { $x eq $_ } @generated)
684 ? platform->asm($x) : $x }
686 my $srcs = '"'.join('" "', @srcs).'"';
687 my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"';
688 my $incs = join("", map { ' -I "'.$_.'"' } @{$args{incs}});
689 my $defs = join("", map { " -D".$_ } @{$args{defs}});
690 my $cflags = { shlib => ' $(LIB_CFLAGS)',
691 lib => ' $(LIB_CFLAGS)',
692 dso => ' $(DSO_CFLAGS)',
693 bin => ' $(BIN_CFLAGS)' } -> {$args{intent}};
695 $cflags .= { shlib => ' $(LIB_CPPFLAGS)',
696 lib => ' $(LIB_CPPFLAGS)',
697 dso => ' $(DSO_CPPFLAGS)',
698 bin => ' $(BIN_CPPFLAGS)' } -> {$args{intent}};
699 my $asflags = { shlib => ' $(LIB_ASFLAGS)',
700 lib => ' $(LIB_ASFLAGS)',
701 dso => ' $(DSO_ASFLAGS)',
702 bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
703 my $makedepprog = $config{makedepprog};
704 if ($srcs[0] =~ /\.rc$/) {
705 my $res = platform->res($args{obj});
708 \$(RC) \$(RCFLAGS) \$(RCOUTFLAG)\$\@ $srcs
711 my $obj = platform->obj($args{obj});
712 my $dep = platform->dep($args{obj});
713 if ($srcs[0] =~ /\Q${asmext}\E$/) {
716 \$(AS) $asflags \$(ASOUTFLAG)\$\@ $srcs
718 } elsif ($srcs[0] =~ /.S$/) {
721 \$(CC) /EP -D__ASSEMBLER__ $cflags $defs $srcs > \$@.asm && \$(AS) $asflags \$(ASOUTFLAG)\$\@ \$@.asm
724 my $recipe = <<"EOF";
726 \$(CC) $cflags $defs -c \$(COUTFLAG)\$\@ $srcs
728 $recipe .= <<"EOF" unless $disabled{makedepend};
729 \$(CC) $cflags $defs /Zs /showIncludes $srcs 2>&1 > $dep
734 # We *know* this routine is only called when we've configure 'shared'.
735 # Also, note that even though the import library built here looks like
736 # a static library, it really isn't.
739 my $lib = $args{lib};
740 my @objs = map { platform->convertext($_) }
741 grep { platform->isobj($_) || platform->isres($_) }
743 my @defs = map { platform->def($_) }
744 grep { platform->isdef($_) }
746 my @deps = compute_lib_depends(@{$args{deps}});
747 die "More than one exported symbols list" if scalar @defs > 1;
748 my $linklibs = join("", map { "$_\n" } @deps);
749 my $objs = join("\n", @objs);
750 my $deps = join(" ", @objs, @defs, @deps);
751 my $import = platform->sharedlib_import($lib);
752 my $dll = platform->sharedlib($lib);
753 my $shared_def = join("", map { " /def:$_" } @defs);
755 # The import library may look like a static library, but it is not.
756 # We MUST make the import library depend on the DLL, in case someone
757 # mistakenly removes the latter.
760 IF EXIST $full.manifest DEL /F /Q $full.manifest
761 IF EXIST \$@ DEL /F /Q \$@
762 \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
763 /implib:$import \$(LDOUTFLAG)$dll$shared_def @<< || (DEL /Q \$(\@B).* $import && EXIT 1)
765 $linklibs\$(LIB_EX_LIBS)
767 IF EXIST $dll.manifest \\
768 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dll.manifest \$(MTOUTFLAG)$dll
769 IF EXIST apps\\$dll DEL /Q /F apps\\$dll
770 IF EXIST test\\$dll DEL /Q /F test\\$dll
771 IF EXIST fuzz\\$dll DEL /Q /F fuzz\\$dll
779 my $dso = platform->dso($args{module});
780 my $dso_n = platform->dsoname($args{module});
781 my @objs = map { platform->convertext($_) }
782 grep { platform->isobj($_) || platform->isres($_) }
784 my @defs = map { platform->def($_) }
785 grep { platform->isdef($_) }
787 my @deps = compute_lib_depends(@{$args{deps}});
788 my $objs = join("\n", @objs);
789 my $linklibs = join("", map { "$_\n" } @deps);
790 my $deps = join(" ", @objs, @defs, @deps);
791 my $shared_def = join("", map { " /def:$_" } @defs);
794 IF EXIST $dso.manifest DEL /F /Q $dso.manifest
795 \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \\
796 \$(LDOUTFLAG)$dso$shared_def @<< || (DEL /Q \$(\@B).* $dso_n.* && EXIT 1)
798 $linklibs \$(DSO_EX_LIBS)
800 IF EXIST $dso.manifest \\
801 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso.manifest \$(MTOUTFLAG)$dso
806 my $lib = platform->staticlib($args{lib});
807 my @objs = map { platform->obj($_) } @{$args{objs}};
808 my $objs = join("\n", @objs);
809 my $deps = join(" ", @objs);
812 \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib @<<
819 my $bin = platform->bin($args{bin});
820 my @objs = map { platform->convertext($_) }
821 grep { platform->isobj($_) || platform->isres($_) }
823 my @deps = compute_lib_depends(@{$args{deps}});
824 my $objs = join("\n", @objs);
825 my $linklibs = join("", map { "$_\n" } @deps);
826 my $deps = join(" ", @objs, @deps);
829 IF EXIST $bin.manifest DEL /F /Q $bin.manifest
830 \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin @<<
833 $linklibs\$(BIN_EX_LIBS)
835 IF EXIST $bin.manifest \\
836 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin.manifest \$(MTOUTFLAG)$bin
841 my $script = $args{script};
842 my $sources = '"'.join('" "', @{$args{sources}}).'"';
843 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
844 "util", "dofile.pl")),
845 rel2abs($config{builddir}));
848 "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
849 "-o$target{build_file}" $sources > "$script"
854 my $dir = $args{dir};
855 my @deps = map { platform->convertext($_) } @{$args{deps}};
857 my %extinfo = ( dso => platform->dsoext(),
858 lib => platform->libext(),
859 bin => platform->binext() );
861 # We already have a 'test' target, and the top directory is just plain
863 return if $dir eq "test" || $dir eq ".";
865 foreach my $type (("dso", "lib", "bin", "script")) {
866 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
867 # For lib object files, we could update the library. However,
868 # LIB on Windows doesn't work that way, so we won't create any
869 # actions for it, and the dependencies are already taken care of.
870 if ($type ne "lib") {
871 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
872 if (dirname($prod) eq $dir) {
873 push @deps, $prod.$extinfo{$type};
879 my $deps = join(" ", @deps);
880 my $actions = join("\n", "", @actions);
882 $dir $dir\\ : $deps$actions
885 "" # Important! This becomes part of the template result.