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} -}
40 FIPSKEY={- $config{FIPSKEY} -}
42 VERSION={- "$config{full_version}" -}
43 MAJOR={- $config{major} -}
44 MINOR={- $config{minor} -}
46 SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
48 LIBS={- join(" ", map { ( platform->sharedlib_import($_), platform->staticlib($_) ) } @{$unified_info{libraries}}) -}
49 SHLIBS={- join(" ", map { platform->sharedlib($_) // () } @{$unified_info{libraries}}) -}
50 SHLIBPDBS={- join(" ", map { platform->sharedlibpdb($_) // () } @{$unified_info{libraries}}) -}
51 MODULES={- our @MODULES = map { platform->dso($_) } @{$unified_info{modules}};
52 join(" ", @MODULES) -}
53 MODULEPDBS={- join(" ", map { platform->dsopdb($_) } @{$unified_info{modules}}) -}
54 PROGRAMS={- our @PROGRAMS = map { platform->bin($_) } @{$unified_info{programs}}; join(" ", @PROGRAMS) -}
55 PROGRAMPDBS={- join(" ", map { $_.".pdb" } @{$unified_info{programs}}) -}
56 SCRIPTS={- our @SCRIPTS = @{$unified_info{scripts}}; join(" ", @SCRIPTS) -}
57 {- output_off() if $disabled{makedepend}; "" -}
58 DEPS={- join(" ", map { platform->isobj($_) ? platform->dep($_) : () }
59 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
60 keys %{$unified_info{sources}}); -}
61 {- output_on() if $disabled{makedepend}; "" -}
62 GENERATED_MANDATORY={- our @GENERATED_MANDATORY = @{$unified_info{depends}->{""}};
63 join(" ", @GENERATED_MANDATORY) -}
64 GENERATED={- # common0.tmpl provides @generated
65 our @GENERATED = map { platform->convertext($_) } @generated;
66 join(" ", @GENERATED) -}
69 join(" ", map { quotify1(platform->sharedlib_import($_)
70 // platform->staticlib($_)) }
71 grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
72 @{$unified_info{libraries}})
75 join(" ", map { my $x = platform->sharedlib($_);
76 $x ? quotify_l($x) : () }
77 grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
78 @{$unified_info{libraries}})
81 join(" ", map { my $x = platform->sharedlibpdb($_);
82 $x ? quotify_l($x) : () }
83 grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
84 @{$unified_info{libraries}})
87 join(" ", map { quotify1(platform->dso($_)) }
88 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
89 && $unified_info{attributes}->{modules}->{$_}->{engine} }
90 @{$unified_info{modules}})
93 join(" ", map { quotify1(platform->dsopdb($_)) }
94 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
95 && $unified_info{attributes}->{modules}->{$_}->{engine} }
96 @{$unified_info{modules}})
99 join(" ", map { platform->dso($_) }
100 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
101 && !$unified_info{attributes}->{modules}->{$_}->{engine} }
102 @{$unified_info{modules}})
104 INSTALL_MODULEPDBS={-
105 join(" ", map { quotify1(platform->dsopdb($_)) }
106 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
107 && !$unified_info{attributes}->{modules}->{$_}->{engine} }
108 @{$unified_info{modules}})
111 join(" ", map { quotify1(platform->bin($_)) }
112 grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
113 @{$unified_info{programs}})
115 INSTALL_PROGRAMPDBS={-
116 join(" ", map { quotify1(platform->binpdb($_)) }
117 grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
118 @{$unified_info{programs}})
121 join(" ", map { quotify1($_) }
122 grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
123 && !$unified_info{attributes}->{scripts}->{$_}->{misc} }
124 @{$unified_info{scripts}})
127 join(" ", map { quotify1($_) }
128 grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
129 && $unified_info{attributes}->{scripts}->{$_}->{misc} }
130 @{$unified_info{scripts}})
132 HTMLDOCS1={- our @HTMLDOCS1 = @{$unified_info{htmldocs}->{man1}};
133 join(" ", @HTMLDOCS1) -}
134 HTMLDOCS3={- our @HTMLDOCS3 = @{$unified_info{htmldocs}->{man3}};
135 join(" ", @HTMLDOCS3) -}
136 HTMLDOCS5={- our @HTMLDOCS5 = @{$unified_info{htmldocs}->{man5}};
137 join(" ", @HTMLDOCS5) -}
138 HTMLDOCS7={- our @HTMLDOCS7 = @{$unified_info{htmldocs}->{man7}};
139 join(" ", @HTMLDOCS7) -}
140 HTMLDOCS1_BLDDIRS={- my %dirs = map { dirname($_) => 1 } @HTMLDOCS1;
141 join(' ', sort keys %dirs) -}
142 HTMLDOCS3_BLDDIRS={- my %dirs = map { dirname($_) => 1 } @HTMLDOCS3;
143 join(' ', sort keys %dirs) -}
144 HTMLDOCS5_BLDDIRS={- my %dirs = map { dirname($_) => 1 } @HTMLDOCS5;
145 join(' ', sort keys %dirs) -}
146 HTMLDOCS7_BLDDIRS={- my %dirs = map { dirname($_) => 1 } @HTMLDOCS7;
147 join(' ', sort keys %dirs) -}
149 APPS_OPENSSL="{- use File::Spec::Functions;
150 catfile("apps","openssl") -}"
152 # Do not edit these manually. Use Configure with --prefix or --openssldir
153 # to change this! Short explanation in the top comment in Configure
154 INSTALLTOP_dev={- # $prefix is used in the OPENSSLDIR perl snippet
156 use File::Spec::Functions qw(:DEFAULT splitpath);
157 our $prefix = canonpath($config{prefix}
158 || "$win_installroot\\OpenSSL");
159 our ($prefix_dev, $prefix_dir, $prefix_file) =
160 splitpath($prefix, 1);
162 INSTALLTOP_dir={- canonpath($prefix_dir) -}
164 # The logic here is that if no --openssldir was given,
165 # OPENSSLDIR will get the value "$win_commonroot\\SSL".
166 # If --openssldir was given and the value is an absolute
167 # path, OPENSSLDIR will get its value without change.
168 # If the value from --openssldir is a relative path,
169 # OPENSSLDIR will get $prefix with the --openssldir
170 # value appended as a subdirectory.
172 use File::Spec::Functions qw(:DEFAULT splitpath);
174 $config{openssldir} ?
175 (file_name_is_absolute($config{openssldir}) ?
176 canonpath($config{openssldir})
177 : catdir($prefix, $config{openssldir}))
178 : canonpath("$win_commonroot\\SSL");
179 our ($openssldir_dev, $openssldir_dir, $openssldir_file) =
180 splitpath($openssldir, 1);
182 OPENSSLDIR_dir={- canonpath($openssldir_dir) -}
183 LIBDIR={- our $libdir = $config{libdir} || "lib";
184 file_name_is_absolute($libdir) ? "" : $libdir -}
185 MODULESDIR_dev={- use File::Spec::Functions qw(:DEFAULT splitpath catpath);
186 our $modulesprefix = catdir($prefix,$libdir);
187 our ($modulesprefix_dev, $modulesprefix_dir,
188 $modulesprefix_file) =
189 splitpath($modulesprefix, 1);
190 our $modulesdir_dev = $modulesprefix_dev;
191 our $modulesdir_dir =
192 catdir($modulesprefix_dir, "ossl-modules");
193 our $modulesdir = catpath($modulesdir_dev, $modulesdir_dir);
194 our $enginesdir_dev = $modulesprefix_dev;
195 our $enginesdir_dir =
196 catdir($modulesprefix_dir, "engines-$sover_dirname");
197 our $enginesdir = catpath($enginesdir_dev, $enginesdir_dir);
199 MODULESDIR_dir={- canonpath($modulesdir_dir) -}
200 ENGINESDIR_dev={- $enginesdir_dev -}
201 ENGINESDIR_dir={- canonpath($enginesdir_dir) -}
202 !IF "$(DESTDIR)" != ""
203 INSTALLTOP=$(DESTDIR)$(INSTALLTOP_dir)
204 OPENSSLDIR=$(DESTDIR)$(OPENSSLDIR_dir)
205 ENGINESDIR=$(DESTDIR)$(ENGINESDIR_dir)
206 MODULESDIR=$(DESTDIR)$(MODULESDIR_dir)
208 INSTALLTOP=$(INSTALLTOP_dev)$(INSTALLTOP_dir)
209 OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir)
210 ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir)
211 MODULESDIR=$(MODULESDIR_dev)$(MODULESDIR_dir)
214 # $(libdir) is chosen to be compatible with the GNU coding standards
215 libdir={- file_name_is_absolute($libdir)
216 ? $libdir : '$(INSTALLTOP)\$(LIBDIR)' -}
218 ##### User defined commands and flags ################################
220 CC="{- $config{CC} -}"
221 CPP="{- $config{CPP} -}"
222 CPPFLAGS={- our $cppflags1 = join(" ",
223 (map { "-D".$_} @{$config{CPPDEFINES}}),
224 (map { " -I ".$_} @{$config{CPPINCLUDES}}),
225 @{$config{CPPFLAGS}}) -}
226 CFLAGS={- join(' ', @{$config{CFLAGS}}) -}
227 LD="{- $config{LD} -}"
228 LDFLAGS={- join(' ', @{$config{LDFLAGS}}) -}
229 EX_LIBS={- join(' ', @{$config{LDLIBS}}) -}
231 PERL={- $config{PERL} -}
233 AR="{- $config{AR} -}"
234 ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -}
236 MT="{- $config{MT} -}"
237 MTFLAGS= {- join(' ', @{$config{MTFLAGS}}) -}
239 AS="{- $config{AS} -}"
240 ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
242 RC="{- $config{RC} -}"
243 RCFLAGS={- join(' ', @{$config{RCFLAGS}}) -}
245 ECHO="$(PERL)" "$(SRCDIR)\util\echo.pl"
247 ##### Special command flags ##########################################
249 COUTFLAG={- $target{coutflag} -}$(OSSL_EMPTY)
250 LDOUTFLAG={- $target{ldoutflag} -}$(OSSL_EMPTY)
251 AROUTFLAG={- $target{aroutflag} -}$(OSSL_EMPTY)
252 MTINFLAG={- $target{mtinflag} -}$(OSSL_EMPTY)
253 MTOUTFLAG={- $target{mtoutflag} -}$(OSSL_EMPTY)
254 ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
255 RCOUTFLAG={- $target{rcoutflag} -}$(OSSL_EMPTY)
257 ##### Project flags ##################################################
259 # Variables starting with CNF_ are common variables for all product types
261 CNF_ASFLAGS={- join(' ', $target{asflags} || (),
262 @{$config{asflags}}) -}
263 CNF_CPPFLAGS={- our $cppfags2 =
264 join(' ', $target{cppflags} || (),
265 (map { '-D'.quotify1($_) } @{$target{defines}},
266 @{$config{defines}}),
267 (map { '-I'.'"'.$_.'"' } @{$target{includes}},
268 @{$config{includes}}),
269 @{$config{cppflags}}) -}
270 CNF_CFLAGS={- join(' ', $target{cflags} || (),
271 @{$config{cflags}}) -}
272 CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (),
273 @{$config{cxxflags}}) -}
274 CNF_LDFLAGS={- join(' ', $target{lflags} || (),
275 @{$config{lflags}}) -}
276 CNF_EX_LIBS={- join(' ', $target{ex_libs} || (),
277 @{$config{ex_libs}}) -}
279 # Variables starting with LIB_ are used to build library object files
280 # and shared libraries.
281 # Variables starting with DSO_ are used to build DSOs and their object files.
282 # Variables starting with BIN_ are used to build programs and their object
285 LIB_ASFLAGS={- join(' ', $target{lib_asflags} || (),
286 @{$config{lib_asflags}},
287 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
288 LIB_CPPFLAGS={- our $lib_cppflags =
289 join(' ', $target{lib_cppflags} || (),
290 $target{shared_cppflag} || (),
291 (map { '-D'.quotify1($_) }
292 @{$target{lib_defines}},
293 @{$target{shared_defines}},
294 @{$config{lib_defines}},
295 @{$config{shared_defines}}),
296 (map { '-I'.quotify1($_) }
297 @{$target{lib_includes}},
298 @{$target{shared_includes}},
299 @{$config{lib_includes}},
300 @{$config{shared_includes}}),
301 @{$config{lib_cppflags}},
302 @{$config{shared_cppflag}});
303 join(' ', $lib_cppflags,
304 (map { '-D'.quotify1($_) }
305 "OPENSSLDIR=\"$openssldir\"",
306 "ENGINESDIR=\"$enginesdir\"",
307 "MODULESDIR=\"$modulesdir\""),
308 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
309 LIB_CFLAGS={- join(' ', $target{lib_cflags} || (),
310 $target{shared_cflag} || (),
311 @{$config{lib_cflags}},
312 @{$config{shared_cflag}},
313 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
314 LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (),
315 $config{shared_ldflag} || (),
316 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
317 LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
318 DSO_ASFLAGS={- join(' ', $target{dso_asflags} || (),
319 $target{module_asflags} || (),
320 @{$config{dso_asflags}},
321 @{$config{module_asflags}},
322 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
323 DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (),
324 $target{module_cppflag} || (),
325 (map { '-D'.quotify1($_) }
326 @{$target{dso_defines}},
327 @{$target{module_defines}},
328 @{$config{dso_defines}},
329 @{$config{module_defines}}),
330 (map { '-I'.quotify1($_) }
331 @{$target{dso_includes}},
332 @{$target{module_includes}},
333 @{$config{dso_includes}},
334 @{$config{module_includes}}),
335 @{$config{dso_cppflags}},
336 @{$config{module_cppflags}},
337 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
338 DSO_CFLAGS={- join(' ', $target{dso_cflags} || (),
339 $target{module_cflags} || (),
340 @{$config{dso_cflags}},
341 @{$config{module_cflags}},
342 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
343 DSO_LDFLAGS={- join(' ', $target{dso_lflags} || (),
344 $target{module_ldflags} || (),
345 @{$config{dso_lflags}},
346 @{$config{module_ldflags}},
347 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
348 DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
349 BIN_ASFLAGS={- join(' ', $target{bin_asflags} || (),
350 @{$config{bin_asflags}},
351 '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
352 BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (),
353 (map { '-D'.$_ } @{$config{bin_defines} || ()}),
354 @{$config{bin_cppflags}},
355 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
356 BIN_CFLAGS={- join(' ', $target{bin_cflags} || (),
357 @{$config{bin_cflags}},
358 '$(CNF_CFLAGS)', '$(CFLAGS)') -}
359 BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (),
360 @{$config{bin_lflags}},
361 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
362 BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
364 # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
365 CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g;
366 $cppflags2 =~ s|([\\"])|\\$1|g;
367 join(' ', $lib_cppflags || (), $cppflags2 || (),
370 PERLASM_SCHEME= {- $target{perlasm_scheme} -}
372 PROCESSOR= {- $config{processor} -}
374 # The main targets ###################################################
376 {- dependmagic('build_sw'); -}: build_libs_nodep build_modules_nodep build_programs_nodep copy-utils
377 {- dependmagic('build_libs'); -}: build_libs_nodep
378 {- dependmagic('build_modules'); -}: build_modules_nodep
379 {- dependmagic('build_programs'); -}: build_programs_nodep
381 build_docs: build_html_docs
382 build_html_docs: $(HTMLDOCS1) $(HTMLDOCS3) $(HTMLDOCS5) $(HTMLDOCS7)
384 build_generated: $(GENERATED_MANDATORY)
385 build_libs_nodep: $(LIBS) {- join(" ",map { platform->sharedlib_import($_) // () } @{$unified_info{libraries}}) -}
386 build_modules_nodep: $(MODULES)
387 build_programs_nodep: $(PROGRAMS) $(SCRIPTS)
389 # Kept around for backward compatibility
390 build_apps build_tests: build_programs
392 # Convenience target to prebuild all generated files, not just the mandatory
394 build_all_generated: $(GENERATED_MANDATORY) $(GENERATED) build_docs
395 @{- output_off() if $disabled{makedepend}; "" -}
396 @$(ECHO) "Warning: consider configuring with no-makedepend, because if"
397 @$(ECHO) " target system doesn't have $(PERL),"
398 @$(ECHO) " then make will fail..."
399 @{- output_on() if $disabled{makedepend}; "" -}
401 all: build_sw build_docs
404 {- dependmagic('tests'); -}: build_programs_nodep build_modules_nodep copy-utils
405 @{- output_off() if $disabled{tests}; "" -}
409 set FIPSKEY=$(FIPSKEY)
410 "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS)
411 @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
412 @$(ECHO) "Tests are not supported with your chosen Configure options"
413 @{- output_on() if !$disabled{tests}; "" -}
416 @{- output_off() if $disabled{tests}; "" -}
417 @set SRCTOP=$(SRCDIR)
418 @"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list
419 @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
420 @$(ECHO) "Tests are not supported with your chosen Configure options"
421 @{- output_on() if !$disabled{tests}; "" -}
423 install: install_sw install_ssldirs install_docs
425 uninstall: uninstall_docs uninstall_sw
428 "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """{.,apps,test,fuzz}/$$1.*"""; } @ARGV" $(SHLIBS)
429 -del /Q /F $(LIBS) libcrypto.* libssl.* ossl_static.pdb
432 -rmdir /Q /S $(HTMLDOCS1_BLDDIRS)
433 -rmdir /Q /S $(HTMLDOCS3_BLDDIRS)
434 -rmdir /Q /S $(HTMLDOCS5_BLDDIRS)
435 -rmdir /Q /S $(HTMLDOCS7_BLDDIRS)
436 {- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) -}
437 {- join("\n\t", map { "-del /Q /F $_" } @MODULES) -}
438 {- join("\n\t", map { "-del /Q /F $_" } @SCRIPTS) -}
439 {- join("\n\t", map { "-del /Q /F $_" } @GENERATED_MANDATORY) -}
440 {- join("\n\t", map { "-del /Q /F $_" } @GENERATED) -}
441 -del /Q /S /F *.d *.obj *.pdb *.ilk *.manifest
442 -del /Q /S /F engines\*.lib engines\*.exp
443 -del /Q /S /F apps\*.lib apps\*.rc apps\*.res apps\*.exp
444 -del /Q /S /F test\*.exp
445 -rmdir /Q /S test\test-runs
448 -del /Q /F configdata.pm
452 @ {- output_off() if $disabled{makedepend}; "" -}
453 @ "$(PERL)" "$(SRCDIR)\util\add-depends.pl" "VC"
454 @ {- output_on() if $disabled{makedepend}; "" -}
456 # Install helper targets #############################################
458 install_sw: install_dev install_engines install_modules install_runtime
460 uninstall_sw: uninstall_runtime uninstall_modules uninstall_engines uninstall_dev
462 install_docs: install_html_docs
464 uninstall_docs: uninstall_html_docs
467 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\certs"
468 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\private"
469 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\misc"
470 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
471 "$(OPENSSLDIR)\openssl.cnf.dist"
472 @IF NOT EXIST "$(OPENSSLDIR)\openssl.cnf" \
473 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \
474 "$(OPENSSLDIR)\openssl.cnf"
475 @if not "$(MISC_SCRIPTS)"=="" \
476 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(MISC_SCRIPTS) \
478 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
479 "$(OPENSSLDIR)\ct_log_list.cnf.dist"
480 @IF NOT EXIST "$(OPENSSLDIR)\ct_log_list.cnf" \
481 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \
482 "$(OPENSSLDIR)\ct_log_list.cnf"
484 install_dev: install_runtime_libs
485 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
486 @$(ECHO) "*** Installing development files"
487 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl"
488 @{- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
489 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \
490 "$(INSTALLTOP)\include\openssl"
491 @{- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "" -}
492 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "-exclude_re=/__DECC_" \
493 "$(SRCDIR)\include\openssl\*.h" \
494 "$(INSTALLTOP)\include\openssl"
495 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(BLDDIR)\include\openssl\*.h" \
496 "$(INSTALLTOP)\include\openssl"
497 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(libdir)"
498 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) "$(libdir)"
499 @if "$(SHLIBS)"=="" \
500 "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb "$(libdir)"
504 _install_modules_deps: install_runtime_libs build_modules
506 install_engines: _install_modules_deps
507 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
508 @$(ECHO) "*** Installing engines"
509 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)"
510 @if not "$(INSTALL_ENGINES)"=="" \
511 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)"
512 @if not "$(INSTALL_ENGINES)"=="" \
513 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINEPDBS) "$(ENGINESDIR)"
517 install_modules: _install_modules_deps
518 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
519 @$(ECHO) "*** Installing modules"
520 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(MODULESDIR)"
521 @if not "$(INSTALL_MODULES)"=="" \
522 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_MODULES) "$(MODULESDIR)"
523 @if not "$(INSTALL_MODULES)"=="" \
524 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_MODULEPDBS) "$(MODULESDIR)"
528 install_runtime: install_programs
530 install_runtime_libs: build_libs
531 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
532 @$(ECHO) "*** Installing runtime libraries"
533 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
534 @if not "$(SHLIBS)"=="" \
535 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin"
536 @if not "$(SHLIBS)"=="" \
537 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBPDBS) \
540 install_programs: install_runtime_libs build_programs
541 @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 )
542 @$(ECHO) "*** Installing runtime programs"
543 @if not "$(INSTALL_PROGRAMS)"=="" \
544 "$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin"
545 @if not "$(INSTALL_PROGRAMS)"=="" \
546 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \
548 @if not "$(INSTALL_PROGRAMS)"=="" \
549 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \
551 @if not "$(INSTALL_PROGRAMS)"=="" \
552 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \
557 install_html_docs: build_html_docs
558 @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 )
559 @echo *** Installing HTML docs
560 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man1"
561 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man3"
562 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man5"
563 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\html\man7"
564 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man1\*.html \
565 "$(INSTALLTOP)\html\man1"
566 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man3\*.html \
567 "$(INSTALLTOP)\html\man3"
568 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man5\*.html \
569 "$(INSTALLTOP)\html\man5"
570 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\doc\html\man7\*.html \
571 "$(INSTALLTOP)\html\man7"
575 # Helper targets #####################################################
577 copy-utils: $(BLDDIR)\util\wrap.pl
579 $(BLDDIR)\util\wrap.pl: configdata.pm
580 @if NOT EXIST "$(BLDDIR)\util" mkdir "$(BLDDIR)\util"
581 @if NOT "$(SRCDIR)"=="$(BLDDIR)" copy "$(SRCDIR)\util\$(@F)" "$(BLDDIR)\util"
583 # Building targets ###################################################
585 configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
586 @$(ECHO) "Detected changed: $?"
587 "$(PERL)" configdata.pm -r
588 @$(ECHO) "**************************************************"
590 @$(ECHO) "*** Please run the same make command again ***"
592 @$(ECHO) "**************************************************"
596 "$(PERL)" configdata.pm -r
600 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/;
602 # Helper function to figure out dependencies on libraries
603 # It takes a list of library names and outputs a list of dependencies
604 sub compute_lib_depends {
605 if ($disabled{shared}) {
606 return map { platform->staticlib($_) } @_;
608 return map { platform->sharedlib_import($_) // platform->staticlib($_) } @_;
613 my ($gen0, @gens) = @{$args{generator}};
614 my $generator = '"'.$gen0.'"'.join('', map { " $_" } @gens);
615 my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}});
616 my $incs = join("", map { " -I \"$_\"" } @{$args{incs}});
617 my $defs = join("", map { " -D".$_ } @{$args{defs}});
618 my $deps = @{$args{deps}} ?
619 '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : '';
621 if ($args{src} =~ /\.html$/) {
622 my $title = basename($args{src}, ".html");
623 my $pod = $args{generator}->[0];
626 \$(PERL) \$(SRCDIR)/util/mkpod2html.pl -i "$pod" -o \$\@ -t "$title" -r "\$(SRCDIR)/doc"
628 } elsif (platform->isdef($args{src})) {
629 my $target = platform->def($args{src});
630 my $mkdef = abs2rel(rel2abs(catfile($config{sourcedir},
631 "util", "mkdef.pl")),
632 rel2abs($config{builddir}));
633 my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
635 $args{generator}->[1] || platform->dsoname($args{product});
637 $target: $args{generator}->[0] $deps $mkdef
638 "\$(PERL)" $mkdef$ord_ver --ordinals $args{generator}->[0] --name $ord_name --OS windows > $target
640 } elsif (!platform->isasm($args{src})) {
641 my $target = $args{src};
642 if ($args{generator}->[0] =~ m|^.*\.in$|) {
643 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
644 "util", "dofile.pl")),
645 rel2abs($config{builddir}));
646 my @modules = ( 'configdata.pm',
647 grep { $_ =~ m|\.pm$| } @{$args{deps}} );
648 my %moduleincs = map { '"-I'.dirname($_).'"' => 1 } @modules;
649 @modules = map { "-M".basename($_, '.pm') } @modules;
650 my $modules = join(' ', '', sort keys %moduleincs, @modules);
652 $target: "$args{generator}->[0]" $deps
653 "\$(PERL)"$modules "$dofile" "-o$target{build_file}" $generator > \$@
657 $target: "$args{generator}->[0]" $deps
658 "\$(PERL)"$generator_incs $generator > \$@
663 shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
664 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
665 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
666 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
667 } -> {$args{intent}};
668 my $target = platform->asm($args{src});
670 if ($args{generator}->[0] =~ /\.pl$/) {
671 $generator = '"$(PERL)"'.$generator_incs.' '.$generator
672 .' "$(PERLASM_SCHEME)"'.$incs.' '.$cppflags.$defs.' $(PROCESSSOR)';
673 } elsif ($args{generator}->[0] =~ /\.S$/) {
676 die "Generator type for $src unknown: $generator\n";
679 if (defined($generator)) {
680 # If the target is named foo.S in build.info, we want to
681 # end up generating foo.s in two steps.
682 if ($args{src} =~ /\.S$/) {
684 $target: "$args{generator}->[0]" $deps
687 \$(CPP) $incs $cppflags $defs \$@.S > \$@.i && move /Y \$@.i \$@
693 $target: "$args{generator}->[0]" $deps
699 $target: "$args{generator}->[0]" $deps
700 \$(CPP) $incs $cppflags $defs "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@
706 my $asmext = platform->asmext();
710 (platform->isasm($x) && grep { $x eq $_ } @generated)
711 ? platform->asm($x) : $x }
713 my $srcs = '"'.join('" "', @srcs).'"';
714 my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"';
715 my $incs = join("", map { ' -I "'.$_.'"' } @{$args{incs}});
716 my $defs = join("", map { " -D".$_ } @{$args{defs}});
717 my $cflags = { shlib => ' $(LIB_CFLAGS)',
718 lib => ' $(LIB_CFLAGS)',
719 dso => ' $(DSO_CFLAGS)',
720 bin => ' $(BIN_CFLAGS)' } -> {$args{intent}};
722 $cflags .= { shlib => ' $(LIB_CPPFLAGS)',
723 lib => ' $(LIB_CPPFLAGS)',
724 dso => ' $(DSO_CPPFLAGS)',
725 bin => ' $(BIN_CPPFLAGS)' } -> {$args{intent}};
726 my $asflags = { shlib => ' $(LIB_ASFLAGS)',
727 lib => ' $(LIB_ASFLAGS)',
728 dso => ' $(DSO_ASFLAGS)',
729 bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
730 my $makedepprog = $config{makedepprog};
731 if ($srcs[0] =~ /\.rc$/) {
732 my $res = platform->res($args{obj});
735 \$(RC) \$(RCFLAGS) \$(RCOUTFLAG)\$\@ $srcs
738 my $obj = platform->obj($args{obj});
739 my $dep = platform->dep($args{obj});
740 if ($srcs[0] =~ /\Q${asmext}\E$/) {
743 \$(AS) $asflags \$(ASOUTFLAG)\$\@ $srcs
745 } elsif ($srcs[0] =~ /.S$/) {
748 \$(CC) /EP -D__ASSEMBLER__ $cflags $defs $srcs > \$@.asm && \$(AS) $asflags \$(ASOUTFLAG)\$\@ \$@.asm
751 my $recipe = <<"EOF";
753 \$(CC) $cflags $defs -c \$(COUTFLAG)\$\@ $srcs
755 $recipe .= <<"EOF" unless $disabled{makedepend};
756 \$(CC) $cflags $defs /Zs /showIncludes $srcs 2>&1 > $dep
761 # We *know* this routine is only called when we've configure 'shared'.
762 # Also, note that even though the import library built here looks like
763 # a static library, it really isn't.
766 my $lib = $args{lib};
767 my @objs = map { platform->convertext($_) }
768 grep { platform->isobj($_) || platform->isres($_) }
770 my @defs = map { platform->def($_) }
771 grep { platform->isdef($_) }
773 my @deps = compute_lib_depends(@{$args{deps}});
774 die "More than one exported symbols list" if scalar @defs > 1;
775 my $linklibs = join("", map { "$_\n" } @deps);
776 my $objs = join("\n", @objs);
777 my $deps = join(" ", @objs, @defs, @deps);
778 my $import = platform->sharedlib_import($lib);
779 my $dll = platform->sharedlib($lib);
780 my $shared_def = join("", map { " /def:$_" } @defs);
782 # The import library may look like a static library, but it is not.
783 # We MUST make the import library depend on the DLL, in case someone
784 # mistakenly removes the latter.
787 IF EXIST $full.manifest DEL /F /Q $full.manifest
788 IF EXIST \$@ DEL /F /Q \$@
789 \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\
790 /implib:$import \$(LDOUTFLAG)$dll$shared_def @<< || (DEL /Q \$(\@B).* $import && EXIT 1)
792 $linklibs\$(LIB_EX_LIBS)
794 IF EXIST $dll.manifest \\
795 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dll.manifest \$(MTOUTFLAG)$dll
796 IF EXIST apps\\$dll DEL /Q /F apps\\$dll
797 IF EXIST test\\$dll DEL /Q /F test\\$dll
798 IF EXIST fuzz\\$dll DEL /Q /F fuzz\\$dll
806 my $dso = platform->dso($args{module});
807 my $dso_n = platform->dsoname($args{module});
808 my @objs = map { platform->convertext($_) }
809 grep { platform->isobj($_) || platform->isres($_) }
811 my @defs = map { platform->def($_) }
812 grep { platform->isdef($_) }
814 my @deps = compute_lib_depends(@{$args{deps}});
815 my $objs = join("\n", @objs);
816 my $linklibs = join("", map { "$_\n" } @deps);
817 my $deps = join(" ", @objs, @defs, @deps);
818 my $shared_def = join("", map { " /def:$_" } @defs);
821 IF EXIST $dso.manifest DEL /F /Q $dso.manifest
822 \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \\
823 \$(LDOUTFLAG)$dso$shared_def @<< || (DEL /Q \$(\@B).* $dso_n.* && EXIT 1)
825 $linklibs \$(DSO_EX_LIBS)
827 IF EXIST $dso.manifest \\
828 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso.manifest \$(MTOUTFLAG)$dso
833 my $lib = platform->staticlib($args{lib});
834 my @objs = map { platform->obj($_) } @{$args{objs}};
835 my $objs = join("\n", @objs);
836 my $deps = join(" ", @objs);
839 \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib @<<
846 my $bin = platform->bin($args{bin});
847 my @objs = map { platform->convertext($_) }
848 grep { platform->isobj($_) || platform->isres($_) }
850 my @deps = compute_lib_depends(@{$args{deps}});
851 my $objs = join("\n", @objs);
852 my $linklibs = join("", map { "$_\n" } @deps);
853 my $deps = join(" ", @objs, @deps);
856 IF EXIST $bin.manifest DEL /F /Q $bin.manifest
857 \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin @<<
860 $linklibs\$(BIN_EX_LIBS)
862 IF EXIST $bin.manifest \\
863 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin.manifest \$(MTOUTFLAG)$bin
868 my $script = $args{script};
869 my $sources = '"'.join('" "', @{$args{sources}}).'"';
870 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
871 "util", "dofile.pl")),
872 rel2abs($config{builddir}));
875 "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\
876 "-o$target{build_file}" $sources > "$script"
881 my $dir = $args{dir};
882 my @deps = map { platform->convertext($_) } @{$args{deps}};
884 my %extinfo = ( dso => platform->dsoext(),
885 lib => platform->libext(),
886 bin => platform->binext() );
888 # We already have a 'test' target, and the top directory is just plain
890 return if $dir eq "test" || $dir eq ".";
892 foreach my $type (("dso", "lib", "bin", "script")) {
893 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type});
894 # For lib object files, we could update the library. However,
895 # LIB on Windows doesn't work that way, so we won't create any
896 # actions for it, and the dependencies are already taken care of.
897 if ($type ne "lib") {
898 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) {
899 if (dirname($prod) eq $dir) {
900 push @deps, $prod.$extinfo{$type};
906 my $deps = join(" ", @deps);
907 my $actions = join("\n", "", @actions);
909 $dir $dir\\ : $deps$actions
912 "" # Important! This becomes part of the template result.