1## 2## Makefile for OpenSSL 3## 4## {- join("\n## ", @autowarntext) -} 5{- 6 our $objext = $target{obj_extension} || ".obj"; 7 our $depext = $target{dep_extension} || ".d"; 8 our $exeext = $target{exe_extension} || ".exe"; 9 our $libext = $target{lib_extension} || ".lib"; 10 our $shlibext = $target{shared_extension} || ".dll"; 11 our $shlibextimport = $target{shared_import_extension} || ".lib"; 12 our $dsoext = $target{dso_extension} || ".dll"; 13 14 our $sover = $config{shlib_major}."_".$config{shlib_minor}; 15 16 my $win_installenv = 17 $target{build_scheme}->[2] eq "VC-W32" ? 18 "ProgramFiles(x86)" : "ProgramW6432"; 19 my $win_commonenv = 20 $target{build_scheme}->[2] eq "VC-W32" 21 ? "CommonProgramFiles(x86)" : "CommonProgramW6432"; 22 our $win_installroot = 23 defined($ENV{$win_installenv}) 24 ? $win_installenv : 'ProgramFiles'; 25 our $win_commonroot = 26 defined($ENV{$win_commonenv}) 27 ? $win_commonenv : 'CommonProgramFiles'; 28 29 # expand variables early 30 $win_installroot = $ENV{$win_installroot}; 31 $win_commonroot = $ENV{$win_commonroot}; 32 33 sub shlib { 34 return () if $disabled{shared}; 35 my $lib = shift; 36 return $unified_info{sharednames}->{$lib} . $shlibext; 37 } 38 39 sub shlib_import { 40 return () if $disabled{shared}; 41 my $lib = shift; 42 return $lib . $shlibextimport; 43 } 44 45 sub dso { 46 my $dso = shift; 47 48 return $dso . $dsoext; 49 } 50 # This makes sure things get built in the order they need 51 # to. You're welcome. 52 sub dependmagic { 53 my $target = shift; 54 55 return "$target: build_generated\n\t\$(MAKE) depend && \$(MAKE) _$target\n_$target"; 56 } 57 ''; 58-} 59 60PLATFORM={- $config{target} -} 61SRCDIR={- $config{sourcedir} -} 62BLDDIR={- $config{builddir} -} 63 64VERSION={- $config{version} -} 65MAJOR={- $config{major} -} 66MINOR={- $config{minor} -} 67 68SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -} 69 70LIBS={- join(" ", map { $_.$libext } @{$unified_info{libraries}}) -} 71SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -} 72SHLIBPDBS={- join(" ", map { local $shlibext = ".pdb"; shlib($_) } @{$unified_info{libraries}}) -} 73ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -} 74ENGINEPDBS={- join(" ", map { local $dsoext = ".pdb"; dso($_) } @{$unified_info{engines}}) -} 75PROGRAMS={- our @PROGRAMS = map { $_.$exeext } @{$unified_info{programs}}; join(" ", @PROGRAMS) -} 76PROGRAMPDBS={- join(" ", map { $_.".pdb" } @{$unified_info{programs}}) -} 77SCRIPTS={- join(" ", @{$unified_info{scripts}}) -} 78{- output_off() if $disabled{makedepend}; "" -} 79DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; } 80 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ } 81 keys %{$unified_info{sources}}); -} 82{- output_on() if $disabled{makedepend}; "" -} 83GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -} 84GENERATED={- join(" ", 85 ( map { (my $x = $_) =~ s|\.[sS]$|\.asm|; $x } 86 grep { defined $unified_info{generate}->{$_} } 87 map { @{$unified_info{sources}->{$_}} } 88 grep { /\.o$/ } keys %{$unified_info{sources}} ), 89 ( grep { /\.h$/ } keys %{$unified_info{generate}} )) -} 90 91INSTALL_LIBS={- join(" ", map { $_.$libext } @{$unified_info{install}->{libraries}}) -} 92INSTALL_SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{install}->{libraries}}) -} 93INSTALL_SHLIBPDBS={- join(" ", map { local $shlibext = ".pdb"; shlib($_) } @{$unified_info{install}->{libraries}}) -} 94INSTALL_ENGINES={- join(" ", map { dso($_) } @{$unified_info{install}->{engines}}) -} 95INSTALL_ENGINEPDBS={- join(" ", map { local $dsoext = ".pdb"; dso($_) } @{$unified_info{install}->{engines}}) -} 96INSTALL_PROGRAMS={- join(" ", map { $_.$exeext } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -} 97INSTALL_PROGRAMPDBS={- join(" ", map { $_.".pdb" } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -} 98{- output_off() if $disabled{apps}; "" -} 99BIN_SCRIPTS=$(BLDDIR)\tools\c_rehash.pl 100MISC_SCRIPTS=$(BLDDIR)\apps\CA.pl $(BLDDIR)\apps\tsget.pl 101{- output_on() if $disabled{apps}; "" -} 102 103APPS_OPENSSL={- use File::Spec::Functions; 104 catfile("apps","openssl") -} 105 106# Do not edit these manually. Use Configure with --prefix or --openssldir 107# to change this! Short explanation in the top comment in Configure 108INSTALLTOP_dev={- # $prefix is used in the OPENSSLDIR perl snippet 109 # 110 use File::Spec::Functions qw(:DEFAULT splitpath); 111 our $prefix = canonpath($config{prefix} 112 || "$win_installroot\\OpenSSL"); 113 our ($prefix_dev, $prefix_dir, $prefix_file) = 114 splitpath($prefix, 1); 115 $prefix_dev -} 116INSTALLTOP_dir={- canonpath($prefix_dir) -} 117OPENSSLDIR_dev={- # 118 # The logic here is that if no --openssldir was given, 119 # OPENSSLDIR will get the value from $prefix plus "/ssl". 120 # If --openssldir was given and the value is an absolute 121 # path, OPENSSLDIR will get its value without change. 122 # If the value from --openssldir is a relative path, 123 # OPENSSLDIR will get $prefix with the --openssldir 124 # value appended as a subdirectory. 125 # 126 use File::Spec::Functions qw(:DEFAULT splitpath); 127 our $openssldir = 128 $config{openssldir} ? 129 (file_name_is_absolute($config{openssldir}) ? 130 canonpath($config{openssldir}) 131 : catdir($prefix, $config{openssldir})) 132 : canonpath("$win_commonroot\\SSL"); 133 our ($openssldir_dev, $openssldir_dir, $openssldir_file) = 134 splitpath($openssldir, 1); 135 $openssldir_dev -} 136OPENSSLDIR_dir={- canonpath($openssldir_dir) -} 137LIBDIR={- our $libdir = $config{libdir} || "lib"; 138 $libdir -} 139ENGINESDIR_dev={- use File::Spec::Functions qw(:DEFAULT splitpath); 140 our $enginesdir = catdir($prefix,$libdir,"engines-$sover"); 141 our ($enginesdir_dev, $enginesdir_dir, $enginesdir_file) = 142 splitpath($enginesdir, 1); 143 $enginesdir_dev -} 144ENGINESDIR_dir={- canonpath($enginesdir_dir) -} 145!IF "$(DESTDIR)" != "" 146INSTALLTOP=$(DESTDIR)$(INSTALLTOP_dir) 147OPENSSLDIR=$(DESTDIR)$(OPENSSLDIR_dir) 148ENGINESDIR=$(DESTDIR)$(ENGINESDIR_dir) 149!ELSE 150INSTALLTOP=$(INSTALLTOP_dev)$(INSTALLTOP_dir) 151OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir) 152ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir) 153!ENDIF 154 155CC={- $target{cc} -} 156CFLAGS={- join(" ",(map { "-D".$_} @{$target{defines}}, @{$config{defines}})) -} {- join(" ", quotify_l("-DENGINESDIR=\"$enginesdir\"", "-DOPENSSLDIR=\"$openssldir\"")) -} {- $target{cflags} -} {- $config{cflags} -} 157COUTFLAG={- $target{coutflag} || "/Fo" -}$(OSSL_EMPTY) 158RC={- $target{rc} || "rc" -} 159RCOUTFLAG={- $target{rcoutflag} || "/fo" -}$(OSSL_EMPTY) 160LD={- $target{ld} || "link" -} 161LDFLAGS={- $target{lflags} -} 162LDOUTFLAG={- $target{loutflag} || "/out:" -}$(OSSL_EMPTY) 163EX_LIBS={- $target{ex_libs} -} 164LIB_CFLAGS={- join(" ", $target{lib_cflags}, $target{shared_cflag}) || "" -} 165LIB_LDFLAGS={- $target{shared_ldflag} || "" -} 166DSO_CFLAGS={- join(" ", $target{dso_cflags}, $target{shared_cflag}) || "" -} 167DSO_LDFLAGS={- join(" ", $target{dso_lflags}, $target{shared_ldflag}) || "" -} 168BIN_CFLAGS={- $target{bin_cflags} -} 169BIN_LDFLAGS={- $target{bin_lflags} -} 170 171PERL={- $config{perl} -} 172 173AR={- $target{ar} -} 174ARFLAGS= {- $target{arflags} -} 175AROUTFLAG={- $target{aroutflag} || "/out:" -}$(OSSL_EMPTY) 176 177MT={- $target{mt} -} 178MTFLAGS= {- $target{mtflags} -} 179MTINFLAG={- $target{mtinflag} || "-manifest " -}$(OSSL_EMPTY) 180MTOUTFLAG={- $target{mtoutflag} || "-outputresource:" -}$(OSSL_EMPTY) 181 182AS={- $target{as} -} 183ASFLAGS={- $target{asflags} -} 184ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY) 185PERLASM_SCHEME= {- $target{perlasm_scheme} -} 186 187PROCESSOR= {- $config{processor} -} 188 189# The main targets ################################################### 190 191{- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep 192{- dependmagic('build_libs'); -}: build_libs_nodep 193{- dependmagic('build_engines'); -}: build_engines_nodep 194{- dependmagic('build_programs'); -}: build_programs_nodep 195 196build_generated: $(GENERATED_MANDATORY) 197build_libs_nodep: $(LIBS) {- join(" ",map { shlib_import($_) } @{$unified_info{libraries}}) -} 198build_engines_nodep: $(ENGINES) 199build_programs_nodep: $(PROGRAMS) $(SCRIPTS) 200 201# Kept around for backward compatibility 202build_apps build_tests: build_programs 203 204# Convenience target to prebuild all generated files, not just the mandatory 205# ones 206build_all_generated: $(GENERATED_MANDATORY) $(GENERATED) 207 208test: tests 209{- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep 210 @rem {- output_off() if $disabled{tests}; "" -} 211 -mkdir $(BLDDIR)\test\test-runs 212 set SRCTOP=$(SRCDIR) 213 set BLDTOP=$(BLDDIR) 214 set RESULT_D=$(BLDDIR)\test\test-runs 215 set PERL=$(PERL) 216 set OPENSSL_ENGINES=$(MAKEDIR)\engines 217 set OPENSSL_DEBUG_MEMORY=on 218 "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS) 219 @rem {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -} 220 @echo "Tests are not supported with your chosen Configure options" 221 @rem {- output_on() if !$disabled{tests}; "" -} 222 223list-tests: 224 @rem {- output_off() if $disabled{tests}; "" -} 225 @set SRCTOP=$(SRCDIR) 226 @"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list 227 @rem {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -} 228 @echo "Tests are not supported with your chosen Configure options" 229 @rem {- output_on() if !$disabled{tests}; "" -} 230 231install: install_sw install_ssldirs install_docs 232 233uninstall: uninstall_docs uninstall_sw 234 235libclean: 236 "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """$$1.*"""; } @ARGV" $(SHLIBS) 237 "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """apps/$$1.*"""; } @ARGV" $(SHLIBS) 238 "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """test/$$1.*"""; } @ARGV" $(SHLIBS) 239 "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """fuzz/$$1.*"""; } @ARGV" $(SHLIBS) 240 -del /Q /F $(LIBS) 241 -del /Q ossl_static.pdb 242 243clean: libclean 244 {- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) -} 245 -del /Q /F $(ENGINES) 246 -del /Q /F $(SCRIPTS) 247 -del /Q /F $(GENERATED) 248 -del /Q /S /F *.d 249 -del /Q /S /F *.obj 250 -del /Q /S /F *.pdb 251 -del /Q /S /F *.exp 252 -del /Q /S /F engines\*.ilk 253 -del /Q /S /F engines\*.lib 254 -del /Q /S /F apps\*.lib 255 -del /Q /S /F engines\*.manifest 256 -del /Q /S /F apps\*.manifest 257 -del /Q /S /F test\*.manifest 258 259distclean: clean 260 -del /Q /F configdata.pm 261 -del /Q /F makefile 262 263depend: 264 265# Install helper targets ############################################# 266 267install_sw: all install_dev install_engines install_runtime 268 269uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev 270 271install_docs: install_html_docs 272 273uninstall_docs: uninstall_html_docs 274 275install_ssldirs: 276 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\certs" 277 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\private" 278 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\misc" 279 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \ 280 "$(OPENSSLDIR)\openssl.cnf.dist" 281 @IF NOT EXIST "$(OPENSSLDIR)\openssl.cnf" \ 282 "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \ 283 "$(OPENSSLDIR)\openssl.cnf" 284 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(MISC_SCRIPTS) \ 285 "$(OPENSSLDIR)\misc" 286 287install_dev: 288 @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 ) 289 @echo *** Installing development files 290 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl" 291 @rem {- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -} 292 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \ 293 "$(INSTALLTOP)\include\openssl" 294 @rem {- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } @{$target{defines}}; "" -} 295 @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\include\openssl\*.h" \ 296 "$(INSTALLTOP)\include\openssl" 297 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BLDDIR)\include\openssl\*.h \ 298 "$(INSTALLTOP)\include\openssl" 299 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\$(LIBDIR)" 300 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) \ 301 "$(INSTALLTOP)\$(LIBDIR)" 302 @if "$(SHLIBS)"=="" \ 303 "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb \ 304 "$(INSTALLTOP)\$(LIBDIR)" 305 306uninstall_dev: 307 308install_engines: 309 @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 ) 310 @echo *** Installing engines 311 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)" 312 @if not "$(ENGINES)"=="" \ 313 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)" 314 @if not "$(ENGINES)"=="" \ 315 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINEPDBS) "$(ENGINESDIR)" 316 317uninstall_engines: 318 319install_runtime: 320 @if "$(INSTALLTOP)"=="" ( echo INSTALLTOP should not be empty & exit 1 ) 321 @echo *** Installing runtime files 322 @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin" 323 @if not "$(SHLIBS)"=="" \ 324 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin" 325 @if not "$(SHLIBS)"=="" \ 326 "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBPDBS) \ 327 "$(INSTALLTOP)\bin" 328 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \ 329 "$(INSTALLTOP)\bin" 330 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \ 331 "$(INSTALLTOP)\bin" 332 @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \ 333 "$(INSTALLTOP)\bin" 334 335uninstall_runtime: 336 337install_html_docs: 338 "$(PERL)" "$(SRCDIR)\util\process_docs.pl" \ 339 "--destdir=$(INSTALLTOP)\html" --type=html 340 341uninstall_html_docs: 342 343# Building targets ################################################### 344 345configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -} 346 @echo "Detected changed: $?" 347 @echo "Reconfiguring..." 348 "$(PERL)" "$(SRCDIR)\Configure" reconf 349 @echo "**************************************************" 350 @echo "*** ***" 351 @echo "*** Please run the same make command again ***" 352 @echo "*** ***" 353 @echo "**************************************************" 354 @exit 1 355 356{- 357 use File::Basename; 358 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/; 359 360 # Helper function to figure out dependencies on libraries 361 # It takes a list of library names and outputs a list of dependencies 362 sub compute_lib_depends { 363 if ($disabled{shared}) { 364 return map { $_.$libext } @_; 365 } 366 return map { shlib_import($_) } @_; 367 } 368 369 sub generatesrc { 370 my %args = @_; 371 (my $target = $args{src}) =~ s/\.[sS]$/.asm/; 372 my ($gen0, @gens) = @{$args{generator}}; 373 my $generator = '"'.$gen0.'"'.join('', map { " $_" } @gens); 374 my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}}); 375 my $incs = join("", map { " /I \"$_\"" } @{$args{incs}}); 376 my $deps = @{$args{deps}} ? 377 '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : ''; 378 379 if ($target !~ /\.asm$/) { 380 if ($args{generator}->[0] =~ m|^.*\.in$|) { 381 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, 382 "util", "dofile.pl")), 383 rel2abs($config{builddir})); 384 return <<"EOF"; 385$target: "$args{generator}->[0]" $deps 386 "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\ 387 "-o$target{build_file}" $generator > \$@ 388EOF 389 } else { 390 return <<"EOF"; 391$target: "$args{generator}->[0]" $deps 392 "\$(PERL)"$generator_incs $generator > \$@ 393EOF 394 } 395 } else { 396 if ($args{generator}->[0] =~ /\.pl$/) { 397 $generator = '"$(PERL)"'.$generator_incs.' '.$generator; 398 } elsif ($args{generator}->[0] =~ /\.S$/) { 399 $generator = undef; 400 } else { 401 die "Generator type for $src unknown: $generator\n"; 402 } 403 404 if (defined($generator)) { 405 # If the target is named foo.S in build.info, we want to 406 # end up generating foo.s in two steps. 407 if ($args{src} =~ /\.S$/) { 408 return <<"EOF"; 409$target: "$args{generator}->[0]" $deps 410 set ASM=\$(AS) 411 $generator \$@.S 412 \$(CC) $incs \$(CFLAGS) /EP /C \$@.S > \$@.i && move /Y \$@.i \$@ 413 del /Q \$@.S 414EOF 415 } 416 # Otherwise.... 417 return <<"EOF"; 418$target: "$args{generator}->[0]" $deps 419 set ASM=\$(AS) 420 $generator \$@ 421EOF 422 } 423 return <<"EOF"; 424$target: "$args{generator}->[0]" $deps 425 \$(CC) $incs \$(CFLAGS) /EP /C "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@ 426EOF 427 } 428 } 429 430 sub src2obj { 431 my %args = @_; 432 my $obj = $args{obj}; 433 my @srcs = map { (my $x = $_) =~ s/\.s$/.asm/; $x 434 } ( @{$args{srcs}} ); 435 my $srcs = '"'.join('" "', @srcs).'"'; 436 my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"'; 437 my $incs = join("", map { ' /I "'.$_.'"' } @{$args{incs}}); 438 unless ($disabled{zlib}) { 439 if ($withargs{zlib_include}) { 440 $incs .= ' /I "'.$withargs{zlib_include}.'"'; 441 } 442 } 443 my $ecflags = { lib => '$(LIB_CFLAGS)', 444 dso => '$(DSO_CFLAGS)', 445 bin => '$(BIN_CFLAGS)' } -> {$args{intent}}; 446 my $makedepprog = $config{makedepprog}; 447 if ($srcs[0] =~ /\.asm$/) { 448 return <<"EOF"; 449$obj$objext: $deps 450 \$(AS) \$(ASFLAGS) \$(ASOUTFLAG)\$\@ $srcs 451EOF 452 } 453 return <<"EOF" if (!$disabled{makedepend}); 454$obj$depext: $deps 455 \$(CC) \$(CFLAGS) $ecflags$inc /Zs /showIncludes $srcs 2>&1 | \\ 456 "\$(PERL)" -n << > $obj$depext 457chomp; 458s/^Note: including file: *//; 459\$\$collect{\$\$_} = 1; 460END { print '$obj$objext: ',join(" ", sort keys \%collect),"\\n" } 461<< 462$obj$objext: $obj$depext 463 \$(CC) $incs \$(CFLAGS) $ecflags -c \$(COUTFLAG)\$\@ $srcs 464EOF 465 return <<"EOF" if ($disabled{makedepend}); 466$obj$objext: $deps 467 \$(CC) $incs \$(CFLAGS) $ecflags -c \$(COUTFLAG)\$\@ $srcs 468EOF 469 } 470 471 # On Unix, we build shlibs from static libs, so we're ignoring the 472 # object file array. We *know* this routine is only called when we've 473 # configure 'shared'. 474 sub libobj2shlib { 475 my %args = @_; 476 my $lib = $args{lib}; 477 my $shlib = $args{shlib}; 478 (my $mkdef_key = $lib) =~ s/^lib//i; 479 my $objs = join("\n", map { $_.$objext } @{$args{objs}}); 480 my $linklibs = join("", 481 map { "\n$_" } compute_lib_depends(@{$args{deps}})); 482 my $deps = join(" ", 483 (map { $_.$objext } @{$args{objs}}), 484 compute_lib_depends(@{$args{deps}})); 485 my $ordinalsfile = defined($args{ordinals}) ? $args{ordinals}->[1] : ""; 486 my $mkdef_pl = abs2rel(rel2abs(catfile($config{sourcedir}, 487 "util", "mkdef.pl")), 488 rel2abs($config{builddir})); 489 my $mkrc_pl = abs2rel(rel2abs(catfile($config{sourcedir}, 490 "util", "mkrc.pl")), 491 rel2abs($config{builddir})); 492 my $target = shlib_import($lib); 493 return <<"EOF" 494$target: $deps "$ordinalsfile" "$mkdef_pl" 495 "\$(PERL)" "$mkdef_pl" "$mkdef_key" 32 > $shlib.def 496 "\$(PERL)" -i.tmp -pe "s|^LIBRARY\\s+${mkdef_key}32|LIBRARY $shlib|;" $shlib.def 497 DEL $shlib.def.tmp 498 "\$(PERL)" "$mkrc_pl" $shlib$shlibext > $shlib.rc 499 \$(RC) \$(RCOUTFLAG)$shlib.res $shlib.rc 500 IF EXIST $shlib$shlibext.manifest DEL /F /Q $shlib$shlibext.manifest 501 \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\ 502 /implib:\$@ \$(LDOUTFLAG)$shlib$shlibext /def:$shlib.def @<< || (DEL /Q \$(\@B).* $shlib.* && EXIT 1) 503$objs $shlib.res$linklibs \$(EX_LIBS) 504<< 505 IF EXIST $shlib$shlibext.manifest \\ 506 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$shlib$shlibext.manifest \$(MTOUTFLAG)$shlib$shlibext 507 IF EXIST apps\\$shlib$shlibext DEL /Q /F apps\\$shlib$shlibext 508 IF EXIST test\\$shlib$shlibext DEL /Q /F test\\$shlib$shlibext 509 IF EXIST fuzz\\$shlib$shlibext DEL /Q /F fuzz\\$shlib$shlibext 510 COPY $shlib$shlibext apps 511 COPY $shlib$shlibext test 512 COPY $shlib$shlibext fuzz 513EOF 514 } 515 sub obj2dso { 516 my %args = @_; 517 my $dso = $args{lib}; 518 my $dso_n = basename($dso); 519 my $objs = join("\n", map { $_.$objext } @{$args{objs}}); 520 my $linklibs = join("", 521 map { "\n$_" } compute_lib_depends(@{$args{deps}})); 522 my $deps = join(" ", 523 (map { $_.$objext } @{$args{objs}}), 524 compute_lib_depends(@{$args{deps}})); 525 return <<"EOF"; 526$dso$dsoext: $deps 527 IF EXIST $dso$dsoext.manifest DEL /F /Q $dso$dsoext.manifest 528 \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \$(LDOUTFLAG)$dso$dsoext /def:<< @<< 529LIBRARY $dso_n 530EXPORTS 531 bind_engine @1 532 v_check @2 533<< 534$objs$linklibs \$(EX_LIBS) 535<< 536 IF EXIST $dso$dsoext.manifest \\ 537 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso$dsoext.manifest \$(MTOUTFLAG)$dso$dsoext 538EOF 539 } 540 sub obj2lib { 541 # Because static libs and import libs are both named the same in native 542 # Windows, we can't have both. We skip the static lib in that case, 543 # as the shared libs are what we use anyway. 544 return "" unless $disabled{"shared"}; 545 546 my %args = @_; 547 my $lib = $args{lib}; 548 my $objs = join("\n", map { $_.$objext } @{$args{objs}}); 549 my $deps = join(" ", map { $_.$objext } @{$args{objs}}); 550 return <<"EOF"; 551$lib$libext: $deps 552 \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib$libext @<< 553\$** 554<< 555EOF 556 } 557 sub obj2bin { 558 my %args = @_; 559 my $bin = $args{bin}; 560 my $objs = join("\n", map { $_.$objext } @{$args{objs}}); 561 my $linklibs = join("", 562 map { "\n$_" } compute_lib_depends(@{$args{deps}})); 563 my $deps = join(" ", 564 (map { $_.$objext } @{$args{objs}}), 565 compute_lib_depends(@{$args{deps}})); 566 return <<"EOF"; 567$bin$exeext: $deps 568 IF EXIST $bin$exeext.manifest DEL /F /Q $bin$exeext.manifest 569 \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin$exeext @<< 570$objs setargv.obj$linklibs \$(EX_LIBS) 571<< 572 IF EXIST $bin$exeext.manifest \\ 573 \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin$exeext.manifest \$(MTOUTFLAG)$bin$exeext 574EOF 575 } 576 sub in2script { 577 my %args = @_; 578 my $script = $args{script}; 579 my $sources = '"'.join('" "', @{$args{sources}}).'"'; 580 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, 581 "util", "dofile.pl")), 582 rel2abs($config{builddir})); 583 return <<"EOF"; 584$script: $sources 585 "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\ 586 "-o$target{build_file}" $sources > "$script" 587EOF 588 } 589 sub generatedir { 590 my %args = @_; 591 my $dir = $args{dir}; 592 my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}}; 593 my @actions = (); 594 my %extinfo = ( dso => $dsoext, 595 lib => $libext, 596 bin => $exeext ); 597 598 foreach my $type (("dso", "lib", "bin", "script")) { 599 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type}); 600 # For lib object files, we could update the library. However, 601 # LIB on Windows doesn't work that way, so we won't create any 602 # actions for it, and the dependencies are already taken care of. 603 if ($type ne "lib") { 604 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) { 605 if (dirname($prod) eq $dir) { 606 push @deps, $prod.$extinfo{$type}; 607 } else { 608 push @actions, "\t@rem No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}}); 609 } 610 } 611 } 612 } 613 614 my $deps = join(" ", @deps); 615 my $actions = join("\n", "", @actions); 616 return <<"EOF"; 617$args{dir} $args{dir}\\ : $deps$actions 618EOF 619 } 620 "" # Important! This becomes part of the template result. 621-} 622