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