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