1## 2## Makefile for OpenSSL 3## 4## {- join("\n## ", @autowarntext) -} 5{- 6 use OpenSSL::Util; 7 8 our $makedep_scheme = $config{makedep_scheme}; 9 our $makedepcmd = platform->makedepcmd(); 10 11 sub windowsdll { $config{target} =~ /^(?:Cygwin|mingw)/ } 12 13 # Shared AIX support is special. We put libcrypto[64].so.ver into 14 # libcrypto.a and use libcrypto_a.a as static one, unless using 15 # shared_target style aix-solib. In that mode, create 16 # libcrypto.so as a link-import library that inserts runtime 17 # dependencies on libcrypto.so.ver, and the static library is 18 # named libcrypto.a. 19 sub sharedaix { !$disabled{shared} && $target{shared_target} =~ /^aix(?!-solib$)/ } 20 sub sharedaix_solib { !$disabled{shared} && $target{shared_target} =~ /^aix-solib$/ } 21 22 our $sover_dirname = platform->shlib_version_as_filename(); 23 24 # This makes sure things get built in the order they need 25 # to. You're welcome. 26 sub dependmagic { 27 my $target = shift; 28 my $help = shift; 29 30 return "$target: build_generated ## $help\n\t\"\$(MAKE)\" depend && \"\$(MAKE)\" _$target\n_$target"; 31 } 32 33 our $COLUMNS = $ENV{COLUMNS}; 34 if ($COLUMNS =~ /^\d+$/) { 35 $COLUMNS = int($COLUMNS) - 2; # 2 to leave space for ending ' \' 36 } else { 37 $COLUMNS = 76; 38 } 39 40 sub fill_lines { 41 my $item_sep = shift; # string 42 my $line_length = shift; # number of chars 43 44 my @result = (); 45 my $resultpos = 0; 46 47 foreach (@_) { 48 my $fill_line = $result[$resultpos] // ''; 49 my $newline = 50 ($fill_line eq '' ? '' : $fill_line . $item_sep) . $_; 51 52 if (length($newline) > $line_length) { 53 # If this is a single item and the intended result line 54 # is empty, we put it there anyway 55 if ($fill_line eq '') { 56 $result[$resultpos++] = $newline; 57 } else { 58 $result[++$resultpos] = $_; 59 } 60 } else { 61 $result[$resultpos] = $newline; 62 } 63 } 64 return @result; 65 } 66 ''; 67-} 68PLATFORM={- $config{target} -} 69OPTIONS={- $config{options} -} 70CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -}) 71SRCDIR={- $config{sourcedir} -} 72BLDDIR={- $config{builddir} -} 73FIPSKEY={- $config{FIPSKEY} -} 74 75VERSION={- "$config{full_version}" -} 76VERSION_NUMBER={- "$config{version}" -} 77MAJOR={- $config{major} -} 78MINOR={- $config{minor} -} 79SHLIB_VERSION_NUMBER={- $config{shlib_version} -} 80SHLIB_TARGET={- $target{shared_target} -} 81 82LIBS={- join(" \\\n" . ' ' x 5, 83 fill_lines(" ", $COLUMNS - 5, 84 map { platform->staticlib($_) // () } 85 @{$unified_info{libraries}})) -} 86SHLIBS={- join(" \\\n" . ' ' x 7, 87 fill_lines(" ", $COLUMNS - 7, 88 map { platform->sharedlib($_) // () } 89 @{$unified_info{libraries}})) -} 90SHLIB_INFO={- join(" \\\n" . ' ' x 11, 91 fill_lines(" ", $COLUMNS - 11, 92 map { my $x = platform->sharedlib($_); 93 my $y = platform->sharedlib_simple($_) // ''; 94 my $z = platform->sharedlib_import($_) // ''; 95 $x ? "\"$x;$y;$z\"" : () } 96 @{$unified_info{libraries}})) -} 97MODULES={- join(" \\\n" . ' ' x 8, 98 fill_lines(" ", $COLUMNS - 8, 99 map { platform->dso($_) } 100 # Drop all modules that are dependencies, they will 101 # be processed through their dependents 102 grep { my $x = $_; 103 !grep { grep { $_ eq $x } @$_ } 104 values %{$unified_info{depends}} } 105 @{$unified_info{modules}})) -} 106FIPSMODULE={- # We do some extra checking here, as there should be only one 107 use File::Basename; 108 our @fipsmodules = 109 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst} 110 && $unified_info{attributes}->{modules}->{$_}->{fips} } 111 @{$unified_info{modules}}; 112 die "More that one FIPS module" if scalar @fipsmodules > 1; 113 join(" ", map { platform->dso($_) } @fipsmodules) -} 114FIPSMODULENAME={- die "More that one FIPS module" if scalar @fipsmodules > 1; 115 join(" ", map { basename(platform->dso($_)) } @fipsmodules) -} 116 117PROGRAMS={- join(" \\\n" . ' ' x 9, 118 fill_lines(" ", $COLUMNS - 9, 119 map { platform->bin($_) } 120 @{$unified_info{programs}})) -} 121SCRIPTS={- join(" \\\n" . ' ' x 8, 122 fill_lines(" ", $COLUMNS - 8, @{$unified_info{scripts}})) -} 123{- output_off() if $disabled{makedepend}; "" -} 124DEPS={- join(" \\\n" . ' ' x 5, 125 fill_lines(" ", $COLUMNS - 5, 126 map { platform->isobj($_) ? platform->dep($_) : () } 127 grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ } 128 keys %{$unified_info{sources}})); -} 129{- output_on() if $disabled{makedepend}; "" -} 130GENERATED_MANDATORY={- join(" \\\n" . ' ' x 20, 131 fill_lines(" ", $COLUMNS - 20, 132 @{$unified_info{depends}->{""}})) -} 133GENERATED_PODS={- # common0.tmpl provides @generated 134 join(" \\\n" . ' ' x 15, 135 fill_lines(" ", $COLUMNS - 15, 136 map { my $x = $_; 137 ( 138 grep { 139 $unified_info{attributes}->{depends} 140 ->{$x}->{$_}->{pod} // 0 141 } 142 keys %{$unified_info{attributes}->{depends}->{$x}} 143 ) ? $x : (); 144 } 145 @generated)) -} 146GENERATED={- # common0.tmpl provides @generated 147 join(" \\\n" . ' ' x 5, 148 fill_lines(" ", $COLUMNS - 5, 149 map { platform->convertext($_) } @generated )) -} 150 151INSTALL_LIBS={- 152 join(" \\\n" . ' ' x 13, 153 fill_lines(" ", $COLUMNS - 13, 154 map { platform->staticlib($_) // () } 155 grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} } 156 @{$unified_info{libraries}})) 157-} 158INSTALL_SHLIBS={- 159 join(" \\\n" . ' ' x 15, 160 fill_lines(" ", $COLUMNS - 15, 161 map { platform->sharedlib($_) // () } 162 grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} } 163 @{$unified_info{libraries}})) 164-} 165INSTALL_SHLIB_INFO={- 166 join(" \\\n" . ' ' x 19, 167 fill_lines(" ", $COLUMNS - 19, 168 map { my $x = platform->sharedlib($_); 169 my $y = platform->sharedlib_simple($_) // ''; 170 my $z = platform->sharedlib_import($_) // ''; 171 $x ? "\"$x;$y;$z\"" : () } 172 grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} } 173 @{$unified_info{libraries}})) 174-} 175INSTALL_ENGINES={- 176 join(" \\\n" . ' ' x 16, 177 fill_lines(" ", $COLUMNS - 16, 178 map { platform->dso($_) } 179 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst} 180 && $unified_info{attributes}->{modules}->{$_}->{engine} } 181 @{$unified_info{modules}})) 182-} 183INSTALL_MODULES={- 184 join(" \\\n" . ' ' x 16, 185 fill_lines(" ", $COLUMNS - 16, 186 map { platform->dso($_) } 187 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst} 188 && !$unified_info{attributes}->{modules}->{$_}->{engine} 189 && !$unified_info{attributes}->{modules}->{$_}->{fips} } 190 @{$unified_info{modules}})) 191-} 192INSTALL_FIPSMODULE={- 193 join(" \\\n" . ' ' x 16, 194 fill_lines(" ", $COLUMNS - 16, 195 map { platform->dso($_) } 196 grep { !$unified_info{attributes}->{modules}->{$_}->{noinst} 197 && $unified_info{attributes}->{modules}->{$_}->{fips} } 198 @{$unified_info{modules}})) 199-} 200INSTALL_FIPSMODULECONF=providers/fipsmodule.cnf 201INSTALL_PROGRAMS={- 202 join(" \\\n" . ' ' x 16, 203 fill_lines(" ", $COLUMNS - 16, map { platform->bin($_) } 204 grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} } 205 @{$unified_info{programs}})) 206-} 207INSTALL_EXPORTERS_PKGCONFIG={- 208 join(" \\\n" . ' ' x 28, 209 fill_lines(" ", $COLUMNS - 28, 210 grep { $unified_info{attributes}->{generate}->{$_}->{exporter} eq 'pkg-config'} 211 sort keys %{$unified_info{generate}})) 212-} 213INSTALL_EXPORTERS_CMAKE={- 214 join(" \\\n" . ' ' x 24, 215 fill_lines(" ", $COLUMNS - 24, 216 grep { $unified_info{attributes}->{generate}->{$_}->{exporter} eq 'cmake'} 217 sort keys %{$unified_info{generate}})) 218-} 219BIN_SCRIPTS={- 220 join(" \\\n" . ' ' x 12, 221 fill_lines(" ", $COLUMNS - 12, 222 map { my $x = $unified_info{attributes}->{scripts}->{$_}->{linkname}; 223 $x ? "$_:$x" : $_ } 224 grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst} 225 && !$unified_info{attributes}->{scripts}->{$_}->{misc} } 226 @{$unified_info{scripts}})) 227-} 228MISC_SCRIPTS={- 229 join(" \\\n" . ' ' x 13, 230 fill_lines(" ", $COLUMNS - 13, 231 map { my $x = $unified_info{attributes}->{scripts}->{$_}->{linkname}; 232 $x ? "$_:$x" : $_ } 233 grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst} 234 && $unified_info{attributes}->{scripts}->{$_}->{misc} } 235 @{$unified_info{scripts}})) 236-} 237IMAGEDOCS1={- 238 join(" \\\n" . ' ' x 10, 239 fill_lines(" ", $COLUMNS - 10, 240 @{$unified_info{imagedocs}->{man1}})) -} 241IMAGEDOCS3={- 242 join(" \\\n" . ' ' x 10, 243 fill_lines(" ", $COLUMNS - 10, 244 @{$unified_info{imagedocs}->{man3}})) -} 245IMAGEDOCS5={- 246 join(" \\\n" . ' ' x 10, 247 fill_lines(" ", $COLUMNS - 10, 248 @{$unified_info{imagedocs}->{man5}})) -} 249IMAGEDOCS7={- 250 join(" \\\n" . ' ' x 10, 251 fill_lines(" ", $COLUMNS - 10, 252 @{$unified_info{imagedocs}->{man7}})) -} 253HTMLDOCS1={- 254 join(" \\\n" . ' ' x 10, 255 fill_lines(" ", $COLUMNS - 10, 256 @{$unified_info{htmldocs}->{man1}})) -} 257HTMLDOCS3={- 258 join(" \\\n" . ' ' x 10, 259 fill_lines(" ", $COLUMNS - 10, 260 @{$unified_info{htmldocs}->{man3}})) -} 261HTMLDOCS5={- 262 join(" \\\n" . ' ' x 10, 263 fill_lines(" ", $COLUMNS - 10, 264 @{$unified_info{htmldocs}->{man5}})) -} 265HTMLDOCS7={- 266 join(" \\\n" . ' ' x 10, 267 fill_lines(" ", $COLUMNS - 10, 268 @{$unified_info{htmldocs}->{man7}})) -} 269MANDOCS1={- 270 join(" \\\n" . ' ' x 9, 271 fill_lines(" ", $COLUMNS - 9, 272 @{$unified_info{mandocs}->{man1}})) -} 273MANDOCS3={- 274 join(" \\\n" . ' ' x 9, 275 fill_lines(" ", $COLUMNS - 9, 276 @{$unified_info{mandocs}->{man3}})) -} 277MANDOCS5={- 278 join(" \\\n" . ' ' x 9, 279 fill_lines(" ", $COLUMNS - 9, 280 @{$unified_info{mandocs}->{man5}})) -} 281MANDOCS7={- 282 join(" \\\n" . ' ' x 9, 283 fill_lines(" ", $COLUMNS - 9, 284 @{$unified_info{mandocs}->{man7}})) -} 285 286APPS_OPENSSL="{- use File::Spec::Functions; 287 catfile("apps","openssl") -}" 288 289# DESTDIR is for package builders so that they can configure for, say, 290# /usr/ and yet have everything installed to /tmp/somedir/usr/. 291# Normally it is left empty. 292DESTDIR= 293 294# Do not edit these manually. Use Configure with --prefix or --openssldir 295# to change this! Short explanation in the top comment in Configure 296INSTALLTOP={- # $prefix is used in the OPENSSLDIR perl snippet 297 # 298 our $prefix = $config{prefix} || "/usr/local"; 299 $prefix -} 300OPENSSLDIR={- # 301 # The logic here is that if no --openssldir was given, 302 # OPENSSLDIR will get the value from $prefix plus "/ssl". 303 # If --openssldir was given and the value is an absolute 304 # path, OPENSSLDIR will get its value without change. 305 # If the value from --openssldir is a relative path, 306 # OPENSSLDIR will get $prefix with the --openssldir 307 # value appended as a subdirectory. 308 # 309 use File::Spec::Functions; 310 our $openssldir = 311 $config{openssldir} ? 312 (file_name_is_absolute($config{openssldir}) ? 313 $config{openssldir} 314 : catdir($prefix, $config{openssldir})) 315 : catdir($prefix, "ssl"); 316 $openssldir -} 317LIBDIR={- our $libdir = $config{libdir}; 318 unless ($libdir) { 319 $libdir = "lib$target{multilib}"; 320 } 321 file_name_is_absolute($libdir) ? "" : $libdir -} 322# $(libdir) is chosen to be compatible with the GNU coding standards 323libdir={- file_name_is_absolute($libdir) 324 ? $libdir : '$(INSTALLTOP)/$(LIBDIR)' -} 325ENGINESDIR=$(libdir)/engines-{- $sover_dirname -} 326MODULESDIR=$(libdir)/ossl-modules 327 328# Convenience variable for those who want to set the rpath in shared 329# libraries and applications 330LIBRPATH=$(libdir) 331 332BINDIR={- our $bindir = $config{bindir}; 333 unless ($bindir) { 334 $bindir = "bin$target{multibin}"; 335 } 336 file_name_is_absolute($bindir) ? "" : $bindir -} 337bindir={- file_name_is_absolute($bindir) 338 ? $bindir : '$(INSTALLTOP)/$(BINDIR)' -} 339 340PKGCONFIGDIR=$(libdir)/pkgconfig 341CMAKECONFIGDIR=$(libdir)/cmake/OpenSSL 342 343MANDIR=$(INSTALLTOP)/share/man 344DOCDIR=$(INSTALLTOP)/share/doc/$(BASENAME) 345HTMLDIR=$(DOCDIR)/html 346 347# MANSUFFIX is for the benefit of anyone who may want to have a suffix 348# appended after the manpage file section number. "ssl" is popular, 349# resulting in files such as config.5ssl rather than config.5. 350MANSUFFIX=ossl 351HTMLSUFFIX=html 352 353# For "optional" echo messages, to get "real" silence 354ECHO = echo 355 356##### User defined commands and flags ################################ 357 358# We let the C compiler driver to take care of .s files. This is done in 359# order to be excused from maintaining a separate set of architecture 360# dependent assembler flags. E.g. if you throw -mcpu=ultrasparc at SPARC 361# gcc, then the driver will automatically translate it to -xarch=v8plus 362# and pass it down to assembler. In any case, we do not define AS or 363# ASFLAGS for this reason. 364 365CROSS_COMPILE={- $config{CROSS_COMPILE} -} 366CC=$(CROSS_COMPILE){- $config{CC} -} 367CXX={- $config{CXX} ? "\$(CROSS_COMPILE)$config{CXX}" : '' -} 368CPPFLAGS={- our $cppflags1 = join(" ", 369 (map { "-D".$_} @{$config{CPPDEFINES}}), 370 (map { "-I".$_} @{$config{CPPINCLUDES}}), 371 @{$config{CPPFLAGS}}) -} 372CFLAGS={- join(' ', @{$config{CFLAGS}}) -} 373CXXFLAGS={- join(' ', @{$config{CXXFLAGS}}) -} 374LDFLAGS= {- join(' ', @{$config{LDFLAGS}}) -} 375EX_LIBS= {- join(' ', @{$config{LDLIBS}}) -} 376OBJCOPY={- $config{OBJCOPY} -} 377 378MAKEDEPEND={- $config{makedepcmd} -} 379 380PERL={- $config{PERL} -} 381 382AR=$(CROSS_COMPILE){- $config{AR} -} 383ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -} 384RANLIB={- $config{RANLIB} ? "\$(CROSS_COMPILE)$config{RANLIB}" : "true"; -} 385RC= $(CROSS_COMPILE){- $config{RC} -} 386RCFLAGS={- join(' ', @{$config{RCFLAGS}}) -} {- $target{shared_rcflag} -} 387 388RM= rm -f 389RMDIR= rmdir 390TAR= {- $target{TAR} || "tar" -} 391TARFLAGS= {- $target{TARFLAGS} -} 392 393BASENAME= openssl 394NAME= $(BASENAME)-$(VERSION) 395# Relative to $(SRCDIR) 396TARFILE= ../$(NAME).tar 397 398##### Project flags ################################################## 399 400# Variables starting with CNF_ are common variables for all product types 401 402CNF_CPPFLAGS={- our $cppflags2 = 403 join(' ', $target{cppflags} || (), 404 (map { "-D".$_} @{$target{defines}}, 405 @{$config{defines}}), 406 (map { "-I".$_} @{$target{includes}}, 407 @{$config{includes}}), 408 @{$config{cppflags}}) -} 409CNF_CFLAGS={- join(' ', $target{cflags} || (), 410 @{$config{cflags}}) -} 411CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (), 412 @{$config{cxxflags}}) -} 413CNF_LDFLAGS={- join(' ', $target{lflags} || (), 414 @{$config{lflags}}) -} 415CNF_EX_LIBS={- join(' ', $target{ex_libs} || (), 416 @{$config{ex_libs}}) -} 417 418# Variables starting with LIB_ are used to build library object files 419# and shared libraries. 420# Variables starting with DSO_ are used to build DSOs and their object files. 421# Variables starting with BIN_ are used to build programs and their object 422# files. 423 424LIB_CPPFLAGS={- our $lib_cppflags = 425 join(' ', $target{lib_cppflags} || (), 426 $target{shared_cppflag} || (), 427 (map { '-D'.$_ } 428 @{$target{lib_defines} || ()}, 429 @{$target{shared_defines} || ()}, 430 @{$config{lib_defines} || ()}, 431 @{$config{shared_defines} || ()}), 432 (map { '-I'.quotify1($_) } 433 @{$target{lib_includes}}, 434 @{$target{shared_includes}}, 435 @{$config{lib_includes}}, 436 @{$config{shared_includes}}), 437 @{$config{lib_cppflags}}, 438 @{$config{shared_cppflag}}); 439 join(' ', $lib_cppflags, 440 (map { '-D'.$_ } 441 'OPENSSLDIR="\"$(OPENSSLDIR)\""', 442 'ENGINESDIR="\"$(ENGINESDIR)\""', 443 'MODULESDIR="\"$(MODULESDIR)\""'), 444 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -} 445LIB_CFLAGS={- join(' ', $target{lib_cflags} || (), 446 $target{shared_cflag} || (), 447 @{$config{lib_cflags}}, 448 @{$config{shared_cflag}}, 449 '$(CNF_CFLAGS)', '$(CFLAGS)') -} 450LIB_CXXFLAGS={- join(' ', $target{lib_cxxflags} || (), 451 $target{shared_cxxflag} || (), 452 @{$config{lib_cxxflags}}, 453 @{$config{shared_cxxflag}}, 454 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -} 455LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (), 456 $config{shared_ldflag} || (), 457 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -} 458LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS) 459DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (), 460 $target{module_cppflags} || (), 461 (map { '-D'.$_ } 462 @{$target{dso_defines}}, 463 @{$target{module_defines}}, 464 @{$config{dso_defines} || ()}, 465 @{$config{module_defines} || ()}), 466 (map { '-I'.quotify1($_) } 467 @{$target{dso_includes}}, 468 @{$target{module_includes}}, 469 @{$config{dso_includes}}, 470 @{$config{module_includes}}), 471 @{$config{dso_cppflags}}, 472 @{$config{module_cppflags}}, 473 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -} 474DSO_CFLAGS={- join(' ', $target{dso_cflags} || (), 475 $target{module_cflags} || (), 476 @{$config{dso_cflags}}, 477 @{$config{module_cflags}}, 478 '$(CNF_CFLAGS)', '$(CFLAGS)') -} 479DSO_CXXFLAGS={- join(' ', $target{dso_cxxflags} || (), 480 $target{module_cxxflags} || (), 481 @{$config{dso_cxxflags}}, 482 @{$config{module_cxxflag}}, 483 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -} 484DSO_LDFLAGS={- join(' ', $target{dso_ldflags} || (), 485 $target{module_ldflags} || (), 486 @{$config{dso_ldflags}}, 487 @{$config{module_ldflags}}, 488 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -} 489DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS) 490BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (), 491 (map { '-D'.$_ } @{$config{bin_defines} || ()}), 492 @{$config{bin_cppflags}}, 493 '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -} 494BIN_CFLAGS={- join(' ', $target{bin_cflags} || (), 495 @{$config{bin_cflags}}, 496 '$(CNF_CFLAGS)', '$(CFLAGS)') -} 497BIN_CXXFLAGS={- join(' ', $target{bin_cxxflags} || (), 498 @{$config{bin_cxxflags}}, 499 '$(CNF_CXXFLAGS)', '$(CXXFLAGS)') -} 500BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (), 501 @{$config{bin_lflags}}, 502 '$(CNF_LDFLAGS)', '$(LDFLAGS)') -} 503BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS) 504 505# CPPFLAGS_Q is used for one thing only: to build up buildinf.h 506CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g; 507 $cppflags2 =~ s|([\\"])|\\$1|g; 508 $lib_cppflags =~ s|([\\"])|\\$1|g; 509 join(' ', $lib_cppflags || (), $cppflags2 || (), 510 $cppflags1 || ()) -} 511 512PERLASM_SCHEME= {- $target{perlasm_scheme} -} 513 514# For x86 assembler: Set PROCESSOR to 386 if you want to support 515# the 80386. 516PROCESSOR= {- $config{processor} -} 517 518# We want error [and other] messages in English. Trouble is that make(1) 519# doesn't pass macros down as environment variables unless there already 520# was corresponding variable originally set. In other words we can only 521# reassign environment variables, but not set new ones, not in portable 522# manner that is. That's why we reassign several, just to be sure... 523LC_ALL=C 524LC_MESSAGES=C 525LANG=C 526 527# The main targets ################################################### 528 529##@ Software 530 531{- dependmagic('build_sw', 'Build all the software (default target)'); -}: build_libs_nodep build_modules_nodep build_programs_nodep link-utils 532{- dependmagic('build_libs', 'Build the libraries libssl and libcrypto'); -}: build_libs_nodep 533{- dependmagic('build_modules', 'Build the modules (i.e. providers and engines)'); -}: build_modules_nodep 534{- dependmagic('build_programs', 'Build the openssl executables and scripts'); -}: build_programs_nodep 535 536all: build_sw {- "build_docs" if !$disabled{docs}; -} ## Build software and documentation 537debuginfo: $(SHLIBS) 538 @set -e; for i in $(SHLIBS); do \ 539 $(OBJCOPY) --only-keep-debug $$i $$i.debug; \ 540 $(OBJCOPY) --strip-debug --add-gnu-debuglink=$$i.debug $$i; \ 541 done; 542 543##@ Documentation 544build_generated_pods: $(GENERATED_PODS) 545build_docs: build_man_docs build_html_docs ## Create documentation 546build_man_docs: $(MANDOCS1) $(MANDOCS3) $(MANDOCS5) $(MANDOCS7) ## Create manpages 547build_html_docs: $(HTMLDOCS1) $(HTMLDOCS3) $(HTMLDOCS5) $(HTMLDOCS7) ## Create HTML documentation 548 549build_generated: $(GENERATED_MANDATORY) 550build_libs_nodep: $(LIBS) {- join(" ",map { platform->sharedlib_simple($_) // platform->sharedlib_import($_) // platform->sharedlib($_) // () } @{$unified_info{libraries}}) -} 551build_modules_nodep: $(MODULES) 552build_programs_nodep: $(PROGRAMS) $(SCRIPTS) 553 554# Kept around for backward compatibility 555build_apps build_tests: build_programs 556 557# Convenience target to prebuild all generated files, not just the mandatory 558# ones 559build_all_generated: $(GENERATED_MANDATORY) $(GENERATED) build_docs 560 @ : {- output_off() if $disabled{makedepend}; "" -} 561 @echo "Warning: consider configuring with no-makedepend, because if" 562 @echo " target system doesn't have $(PERL)," 563 @echo " then make will fail..." 564 @ : {- output_on() if $disabled{makedepend}; "" -} 565 566##@ Help 567.PHONY: help 568help: ## Show this help screen 569 @$(PERL) $(SRCDIR)/util/help.pl $(BLDDIR)/Makefile 570 571##@ Testing 572test: tests ## Run tests (alias of "tests") 573{- dependmagic('tests', 'Run tests'); -}: build_programs_nodep build_modules_nodep link-utils 574 "$(MAKE)" run_tests 575run_tests: FORCE 576 @ : {- output_off() if $disabled{tests}; "" -} 577 ( SRCTOP=$(SRCDIR) \ 578 BLDTOP=$(BLDDIR) \ 579 PERL="$(PERL)" \ 580 FIPSKEY="$(FIPSKEY)" \ 581 EXE_EXT={- platform->binext() -} \ 582 $(PERL) $(SRCDIR)/test/run_tests.pl $(TESTS) ) 583 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -} 584 @echo "Tests are not supported with your chosen Configure options" 585 @ : {- output_on() if !$disabled{tests}; "" -} 586 587list-tests: ## List available tests that can be invoked via "make test TESTS=<name>" 588 @ : {- output_off() if $disabled{tests}; "" -} 589 "$(MAKE)" run_tests TESTS=list 590 @ : {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -} 591 @echo "Tests are not supported with your chosen Configure options" 592 @ : {- output_on() if !$disabled{tests}; "" -} 593 594##@ Workspace cleaning 595 596libclean: 597 @set -e; for s in $(SHLIB_INFO); do \ 598 if [ "$$s" = ";" ]; then continue; fi; \ 599 s1=`echo "$$s" | cut -f1 -d";"`; \ 600 s2=`echo "$$s" | cut -f2 -d";"`; \ 601 s3=`echo "$$s" | cut -f3 -d";"`; \ 602 $(ECHO) $(RM) $$s1; {- output_off() unless windowsdll(); "" -}\ 603 $(RM) apps/$$s1; \ 604 $(RM) test/$$s1; \ 605 $(RM) fuzz/$$s1; {- output_on() unless windowsdll(); "" -}\ 606 $(RM) $$s1; \ 607 if [ "$$s2" != "" ]; then \ 608 $(ECHO) $(RM) $$s2; \ 609 $(RM) $$s2; \ 610 fi; \ 611 if [ "$$s3" != "" ]; then \ 612 $(ECHO) $(RM) $$s3; \ 613 $(RM) $$s3; \ 614 fi; \ 615 done 616 $(RM) $(LIBS) 617 $(RM) *{- platform->defext() -} 618 619clean: libclean ## Clean the workspace, keep the configuration 620 $(RM) $(HTMLDOCS1) 621 $(RM) $(HTMLDOCS3) 622 $(RM) $(HTMLDOCS5) 623 $(RM) $(HTMLDOCS7) 624 $(RM) $(MANDOCS1) 625 $(RM) $(MANDOCS3) 626 $(RM) $(MANDOCS5) 627 $(RM) $(MANDOCS7) 628 $(RM) $(PROGRAMS) $(TESTPROGS) $(MODULES) $(FIPSMODULE) $(SCRIPTS) 629 $(RM) $(GENERATED_MANDATORY) $(GENERATED) 630 -find . -name '*{- platform->depext() -}' \! -name '.*' \! -type d -exec $(RM) {} \; 631 -find . -name '*{- platform->objext() -}' \! -name '.*' \! -type d -exec $(RM) {} \; 632 $(RM) core 633 $(RM) tags TAGS doc-nits md-nits 634 $(RM) -r test/test-runs 635 $(RM) providers/fips*.new 636 -find . -type l \! -name '.*' -exec $(RM) {} \; 637 638distclean: clean ## Clean and remove the configuration 639 $(RM) include/openssl/configuration.h 640 $(RM) configdata.pm 641 $(RM) Makefile 642 643# We check if any depfile is newer than Makefile and decide to 644# concatenate only if that is true. 645depend: Makefile 646 @: {- output_off() if $disabled{makedepend}; "" -} 647 @$(PERL) $(SRCDIR)/util/add-depends.pl "{- $makedep_scheme -}" 648 @: {- output_on() if $disabled{makedepend}; "" -} 649 650# Install helper targets ############################################# 651##@ Installation 652 653install: install_sw install_ssldirs {- "install_docs" if !$disabled{docs}; -} {- $disabled{fips} ? "" : "install_fips" -} ## Install software and documentation, create OpenSSL directories 654 655uninstall: {- "uninstall_docs" if !$disabled{docs}; -} uninstall_sw {- $disabled{fips} ? "" : "uninstall_fips" -} ## Uninstall software and documentation 656 657install_sw: install_dev install_engines install_modules install_runtime ## Install just the software and libraries 658 659uninstall_sw: uninstall_runtime uninstall_modules uninstall_engines uninstall_dev ## Uninstall the software and libraries 660 661install_docs: install_man_docs install_html_docs ## Install manpages and HTML documentation 662 663uninstall_docs: uninstall_man_docs uninstall_html_docs ## Uninstall manpages and HTML documentation 664 $(RM) -r "$(DESTDIR)$(DOCDIR)" 665 666{- output_off() if $disabled{fips}; "" -} 667install_fips: build_sw $(INSTALL_FIPSMODULECONF) 668 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) 669 @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(MODULESDIR)" 670 @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(OPENSSLDIR)" 671 @$(ECHO) "*** Installing FIPS module" 672 @$(ECHO) "install $(INSTALL_FIPSMODULE) -> $(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME)" 673 @cp "$(INSTALL_FIPSMODULE)" "$(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).new" 674 @chmod 755 "$(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).new" 675 @mv -f "$(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME).new" \ 676 "$(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME)" 677 @$(ECHO) "*** Installing FIPS module configuration" 678 @$(ECHO) "install $(INSTALL_FIPSMODULECONF) -> $(DESTDIR)$(OPENSSLDIR)/fipsmodule.cnf" 679 @cp $(INSTALL_FIPSMODULECONF) "$(DESTDIR)$(OPENSSLDIR)/fipsmodule.cnf" 680 681uninstall_fips: 682 @$(ECHO) "*** Uninstalling FIPS module configuration" 683 $(RM) "$(DESTDIR)$(OPENSSLDIR)/fipsmodule.cnf" 684 @$(ECHO) "*** Uninstalling FIPS module" 685 $(RM) "$(DESTDIR)$(MODULESDIR)/$(FIPSMODULENAME)" 686{- if ($disabled{fips}) { output_on(); } else { output_off(); } "" -} 687install_fips: 688 @$(ECHO) "The 'install_fips' target requires the 'enable-fips' option" 689 690uninstall_fips: 691 @$(ECHO) "The 'uninstall_fips' target requires the 'enable-fips' option" 692{- output_on() if !$disabled{fips}; "" -} 693 694 695install_ssldirs: 696 @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(OPENSSLDIR)/certs" 697 @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(OPENSSLDIR)/private" 698 @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(OPENSSLDIR)/misc" 699 @set -e; for x in dummy $(MISC_SCRIPTS); do \ 700 if [ "$$x" = "dummy" ]; then continue; fi; \ 701 x1=`echo "$$x" | cut -f1 -d:`; \ 702 x2=`echo "$$x" | cut -f2 -d:`; \ 703 fn=`basename $$x1`; \ 704 $(ECHO) "install $$x1 -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \ 705 cp $$x1 "$(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new"; \ 706 chmod 755 "$(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new"; \ 707 mv -f "$(DESTDIR)$(OPENSSLDIR)/misc/$$fn.new" \ 708 "$(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \ 709 if [ "$$x1" != "$$x2" ]; then \ 710 ln=`basename "$$x2"`; \ 711 : {- output_off() unless windowsdll(); "" -}; \ 712 $(ECHO) "copy $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \ 713 cp "$(DESTDIR)$(OPENSSLDIR)/misc/$$fn" "$(DESTDIR)$(OPENSSLDIR)/misc/$$ln"; \ 714 : {- output_on() unless windowsdll(); 715 output_off() if windowsdll(); "" -}; \ 716 $(ECHO) "link $(DESTDIR)$(OPENSSLDIR)/misc/$$ln -> $(DESTDIR)$(OPENSSLDIR)/misc/$$fn"; \ 717 ln -sf $$fn "$(DESTDIR)$(OPENSSLDIR)/misc/$$ln"; \ 718 : {- output_on() if windowsdll(); "" -}; \ 719 fi; \ 720 done 721 @$(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist" 722 @cp $(SRCDIR)/apps/openssl.cnf "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new" 723 @chmod 644 "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new" 724 @mv -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf.new" "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf.dist" 725 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf" ]; then \ 726 $(ECHO) "install $(SRCDIR)/apps/openssl.cnf -> $(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \ 727 cp $(SRCDIR)/apps/openssl.cnf "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \ 728 chmod 644 "$(DESTDIR)$(OPENSSLDIR)/openssl.cnf"; \ 729 fi 730 @$(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist" 731 @cp $(SRCDIR)/apps/ct_log_list.cnf "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new" 732 @chmod 644 "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new" 733 @mv -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.new" "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf.dist" 734 @if [ ! -f "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf" ]; then \ 735 $(ECHO) "install $(SRCDIR)/apps/ct_log_list.cnf -> $(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \ 736 cp $(SRCDIR)/apps/ct_log_list.cnf "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \ 737 chmod 644 "$(DESTDIR)$(OPENSSLDIR)/ct_log_list.cnf"; \ 738 fi 739 740install_dev: install_runtime_libs 741 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) 742 @$(ECHO) "*** Installing development files" 743 @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(INSTALLTOP)/include/openssl" 744 @ : {- output_off() if $disabled{uplink}; "" -} 745 @$(ECHO) "install $(SRCDIR)/ms/applink.c -> $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c" 746 @cp $(SRCDIR)/ms/applink.c "$(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c" 747 @chmod 644 "$(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c" 748 @ : {- output_on() if $disabled{uplink}; "" -} 749 @set -e; for i in $(SRCDIR)/include/openssl/*.h \ 750 $(BLDDIR)/include/openssl/*.h; do \ 751 fn=`basename $$i`; \ 752 $(ECHO) "install $$i -> $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \ 753 cp $$i "$(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \ 754 chmod 644 "$(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \ 755 done 756 @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(libdir)" 757 @set -e; for l in $(INSTALL_LIBS); do \ 758 fn=`basename $$l`; \ 759 $(ECHO) "install $$l -> $(DESTDIR)$(libdir)/$$fn"; \ 760 cp $$l "$(DESTDIR)$(libdir)/$$fn.new"; \ 761 $(RANLIB) "$(DESTDIR)$(libdir)/$$fn.new"; \ 762 chmod 644 "$(DESTDIR)$(libdir)/$$fn.new"; \ 763 mv -f "$(DESTDIR)$(libdir)/$$fn.new" \ 764 "$(DESTDIR)$(libdir)/$$fn"; \ 765 done 766 @ : {- output_off() if $disabled{shared}; "" -} 767 @set -e; for s in $(INSTALL_SHLIB_INFO); do \ 768 s1=`echo "$$s" | cut -f1 -d";"`; \ 769 s2=`echo "$$s" | cut -f2 -d";"`; \ 770 s3=`echo "$$s" | cut -f3 -d";"`; \ 771 fn1=`basename "$$s1"`; \ 772 fn2=`basename "$$s2"`; \ 773 fn3=`basename "$$s3"`; \ 774 : {- output_off(); output_on() unless windowsdll() or sharedaix() or sharedaix_solib(); "" -}; \ 775 if [ "$$fn2" != "" ]; then \ 776 $(ECHO) "link $(DESTDIR)$(libdir)/$$fn2 -> $(DESTDIR)$(libdir)/$$fn1"; \ 777 ln -sf $$fn1 "$(DESTDIR)$(libdir)/$$fn2"; \ 778 fi; \ 779 : {- output_off() unless windowsdll() or sharedaix() or sharedaix_solib(); output_on() if windowsdll() or sharedaix_solib(); "" -}; \ 780 if [ "$$fn3" != "" ]; then \ 781 $(ECHO) "install $$s3 -> $(DESTDIR)$(libdir)/$$fn3"; \ 782 cp $$s3 "$(DESTDIR)$(libdir)/$$fn3.new"; \ 783 chmod 755 "$(DESTDIR)$(libdir)/$$fn3.new"; \ 784 mv -f "$(DESTDIR)$(libdir)/$$fn3.new" \ 785 "$(DESTDIR)$(libdir)/$$fn3"; \ 786 fi; \ 787 : {- output_off() if windowsdll() or sharedaix_solib(); output_on() if sharedaix(); "" -}; \ 788 a="$(DESTDIR)$(libdir)/$$fn2"; \ 789 $(ECHO) "install $$s1 -> $$a"; \ 790 if [ -f $$a ]; then ( trap "rm -rf /tmp/ar.$$$$" INT 0; \ 791 mkdir /tmp/ar.$$$$; ( cd /tmp/ar.$$$$; \ 792 cp -f $$a $$a.new; \ 793 for so in `$(AR) t $$a`; do \ 794 $(AR) x $$a $$so; \ 795 chmod u+w $$so; \ 796 strip -X32_64 -e $$so; \ 797 $(AR) r $$a.new $$so; \ 798 done; \ 799 )); fi; \ 800 $(AR) r $$a.new $$s1; \ 801 mv -f $$a.new $$a; \ 802 : {- output_off() if sharedaix(); output_on(); "" -}; \ 803 done 804 @ : {- output_on() if $disabled{shared}; "" -} 805 @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(PKGCONFIGDIR)" 806 @for e in $(INSTALL_EXPORTERS_PKGCONFIG); do \ 807 fn=`basename $$e`; \ 808 $(ECHO) "install $$e -> $(DESTDIR)$(PKGCONFIGDIR)/$$fn"; \ 809 cp $$e "$(DESTDIR)$(PKGCONFIGDIR)/$$fn"; \ 810 chmod 644 "$(DESTDIR)$(PKGCONFIGDIR)/$$fn"; \ 811 done 812 @$(PERL) $(SRCDIR)/util/mkdir-p.pl $(DESTDIR)$(CMAKECONFIGDIR) 813 @for e in $(INSTALL_EXPORTERS_CMAKE); do \ 814 fn=`basename $$e`; \ 815 $(ECHO) "install $$e -> $(DESTDIR)$(CMAKECONFIGDIR)/$$fn"; \ 816 cp $$e $(DESTDIR)$(CMAKECONFIGDIR)/$$fn; \ 817 chmod 644 $(DESTDIR)$(CMAKECONFIGDIR)/$$fn; \ 818 done 819 820uninstall_dev: uninstall_runtime_libs 821 @$(ECHO) "*** Uninstalling development files" 822 @ : {- output_off() if $disabled{uplink}; "" -} 823 @$(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c" 824 @$(RM) "$(DESTDIR)$(INSTALLTOP)/include/openssl/applink.c" 825 @ : {- output_on() if $disabled{uplink}; "" -} 826 @set -e; for i in $(SRCDIR)/include/openssl/*.h \ 827 $(BLDDIR)/include/openssl/*.h; do \ 828 fn=`basename $$i`; \ 829 $(ECHO) "$(RM) $(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \ 830 $(RM) "$(DESTDIR)$(INSTALLTOP)/include/openssl/$$fn"; \ 831 done 832 -$(RMDIR) "$(DESTDIR)$(INSTALLTOP)/include/openssl" 833 -$(RMDIR) "$(DESTDIR)$(INSTALLTOP)/include" 834 @set -e; for l in $(INSTALL_LIBS); do \ 835 fn=`basename $$l`; \ 836 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn"; \ 837 $(RM) "$(DESTDIR)$(libdir)/$$fn"; \ 838 done 839 @ : {- output_off() if $disabled{shared}; "" -} 840 @set -e; for s in $(INSTALL_SHLIB_INFO); do \ 841 s1=`echo "$$s" | cut -f1 -d";"`; \ 842 s2=`echo "$$s" | cut -f2 -d";"`; \ 843 s3=`echo "$$s" | cut -f3 -d";"`; \ 844 fn1=`basename "$$s1"`; \ 845 fn2=`basename "$$s2"`; \ 846 fn3=`basename "$$s3"`; \ 847 : {- output_off() if windowsdll(); "" -}; \ 848 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn1"; \ 849 $(RM) "$(DESTDIR)$(libdir)/$$fn1"; \ 850 if [ -n "$$fn2" ]; then \ 851 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn2"; \ 852 $(RM) "$(DESTDIR)$(libdir)/$$fn2"; \ 853 fi; \ 854 : {- output_on() if windowsdll(); "" -}{- output_off() unless windowsdll(); "" -}; \ 855 if [ -n "$$fn3" ]; then \ 856 $(ECHO) "$(RM) $(DESTDIR)$(libdir)/$$fn3"; \ 857 $(RM) "$(DESTDIR)$(libdir)/$$fn3"; \ 858 fi; \ 859 : {- output_on() unless windowsdll(); "" -}; \ 860 done 861 @ : {- output_on() if $disabled{shared}; "" -} 862 @for e in $(INSTALL_EXPORTERS_PKGCONFIG); do \ 863 fn=`basename "$$e"`; \ 864 $(RM) "$(DESTDIR)$(PKGCONFIGDIR)/$$fn"; \ 865 done 866 @for e in $(INSTALL_EXPORTERS_CMAKE); do \ 867 fn=`basename "$$e"`; \ 868 $(RM) "$(DESTDIR)$(CMAKECONFIGDIR)/$$fn"; \ 869 done 870 -$(RMDIR) "$(DESTDIR)$(PKGCONFIGDIR)" 871 -$(RMDIR) "$(DESTDIR)$(CMAKECONFIGDIR)" 872 -$(RMDIR) "$(DESTDIR)$(libdir)" 873 874_install_modules_deps: install_runtime_libs build_modules 875 876install_engines: _install_modules_deps 877 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) 878 @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(ENGINESDIR)/" 879 @$(ECHO) "*** Installing engines" 880 @set -e; for e in dummy $(INSTALL_ENGINES); do \ 881 if [ "$$e" = "dummy" ]; then continue; fi; \ 882 fn=`basename $$e`; \ 883 $(ECHO) "install $$e -> $(DESTDIR)$(ENGINESDIR)/$$fn"; \ 884 cp $$e "$(DESTDIR)$(ENGINESDIR)/$$fn.new"; \ 885 chmod 755 "$(DESTDIR)$(ENGINESDIR)/$$fn.new"; \ 886 mv -f "$(DESTDIR)$(ENGINESDIR)/$$fn.new" \ 887 "$(DESTDIR)$(ENGINESDIR)/$$fn"; \ 888 done 889 890uninstall_engines: 891 @$(ECHO) "*** Uninstalling engines" 892 @set -e; for e in dummy $(INSTALL_ENGINES); do \ 893 if [ "$$e" = "dummy" ]; then continue; fi; \ 894 fn=`basename $$e`; \ 895 $(ECHO) "$(RM) $(DESTDIR)$(ENGINESDIR)/$$fn"; \ 896 $(RM) "$(DESTDIR)$(ENGINESDIR)/$$fn"; \ 897 done 898 -$(RMDIR) "$(DESTDIR)$(ENGINESDIR)" 899 900install_modules: _install_modules_deps 901 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) 902 @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(MODULESDIR)/" 903 @$(ECHO) "*** Installing modules" 904 @set -e; for e in dummy $(INSTALL_MODULES); do \ 905 if [ "$$e" = "dummy" ]; then continue; fi; \ 906 fn=`basename $$e`; \ 907 $(ECHO) "install $$e -> $(DESTDIR)$(MODULESDIR)/$$fn"; \ 908 cp $$e "$(DESTDIR)$(MODULESDIR)/$$fn.new"; \ 909 chmod 755 "$(DESTDIR)$(MODULESDIR)/$$fn.new"; \ 910 mv -f "$(DESTDIR)$(MODULESDIR)/$$fn.new" \ 911 "$(DESTDIR)$(MODULESDIR)/$$fn"; \ 912 done 913 914uninstall_modules: 915 @$(ECHO) "*** Uninstalling modules" 916 @set -e; for e in dummy $(INSTALL_MODULES); do \ 917 if [ "$$e" = "dummy" ]; then continue; fi; \ 918 fn=`basename $$e`; \ 919 $(ECHO) "$(RM) $(DESTDIR)$(MODULESDIR)/$$fn"; \ 920 $(RM) "$(DESTDIR)$(MODULESDIR)/$$fn"; \ 921 done 922 -$(RMDIR) "$(DESTDIR)$(MODULESDIR)" 923 924install_runtime: install_programs 925 926install_runtime_libs: build_libs 927 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) 928 @ : {- output_off() if windowsdll(); "" -} 929 @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(libdir)" 930 @ : {- output_on() if windowsdll(); output_off() unless windowsdll(); "" -} 931 @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(bindir)/" 932 @ : {- output_on() unless windowsdll(); "" -} 933 @$(ECHO) "*** Installing runtime libraries" 934 @set -e; for s in dummy $(INSTALL_SHLIBS); do \ 935 if [ "$$s" = "dummy" ]; then continue; fi; \ 936 fn=`basename $$s`; \ 937 : {- output_off() unless windowsdll(); "" -}; \ 938 $(ECHO) "install $$s -> $(DESTDIR)$(bindir)/$$fn"; \ 939 cp $$s "$(DESTDIR)$(bindir)/$$fn.new"; \ 940 chmod 755 "$(DESTDIR)$(bindir)/$$fn.new"; \ 941 mv -f "$(DESTDIR)$(bindir)/$$fn.new" \ 942 "$(DESTDIR)$(bindir)/$$fn"; \ 943 : {- output_on() unless windowsdll(); "" -}{- output_off() if windowsdll(); "" -}; \ 944 $(ECHO) "install $$s -> $(DESTDIR)$(libdir)/$$fn"; \ 945 cp $$s "$(DESTDIR)$(libdir)/$$fn.new"; \ 946 chmod 755 "$(DESTDIR)$(libdir)/$$fn.new"; \ 947 mv -f "$(DESTDIR)$(libdir)/$$fn.new" \ 948 "$(DESTDIR)$(libdir)/$$fn"; \ 949 : {- output_on() if windowsdll(); "" -}; \ 950 done 951 952install_programs: install_runtime_libs build_programs 953 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) 954 @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(bindir)" 955 @$(ECHO) "*** Installing runtime programs" 956 @set -e; for x in dummy $(INSTALL_PROGRAMS); do \ 957 if [ "$$x" = "dummy" ]; then continue; fi; \ 958 fn=`basename $$x`; \ 959 $(ECHO) "install $$x -> $(DESTDIR)$(bindir)/$$fn"; \ 960 cp $$x "$(DESTDIR)$(bindir)/$$fn.new"; \ 961 chmod 755 "$(DESTDIR)$(bindir)/$$fn.new"; \ 962 mv -f "$(DESTDIR)$(bindir)/$$fn.new" \ 963 "$(DESTDIR)$(bindir)/$$fn"; \ 964 done 965 @set -e; for x in dummy $(BIN_SCRIPTS); do \ 966 if [ "$$x" = "dummy" ]; then continue; fi; \ 967 fn=`basename $$x`; \ 968 $(ECHO) "install $$x -> $(DESTDIR)$(bindir)/$$fn"; \ 969 cp $$x "$(DESTDIR)$(bindir)/$$fn.new"; \ 970 chmod 755 "$(DESTDIR)$(bindir)/$$fn.new"; \ 971 mv -f "$(DESTDIR)$(bindir)/$$fn.new" \ 972 "$(DESTDIR)$(bindir)/$$fn"; \ 973 done 974 975uninstall_runtime: uninstall_programs uninstall_runtime_libs 976 977uninstall_programs: 978 @$(ECHO) "*** Uninstalling runtime programs" 979 @set -e; for x in dummy $(INSTALL_PROGRAMS); \ 980 do \ 981 if [ "$$x" = "dummy" ]; then continue; fi; \ 982 fn=`basename $$x`; \ 983 $(ECHO) "$(RM) $(DESTDIR)$(bindir)/$$fn"; \ 984 $(RM) "$(DESTDIR)$(bindir)/$$fn"; \ 985 done; 986 @set -e; for x in dummy $(BIN_SCRIPTS); \ 987 do \ 988 if [ "$$x" = "dummy" ]; then continue; fi; \ 989 fn=`basename $$x`; \ 990 $(ECHO) "$(RM) $(DESTDIR)$(bindir)/$$fn"; \ 991 $(RM) "$(DESTDIR)$(bindir)/$$fn"; \ 992 done 993 -$(RMDIR) "$(DESTDIR)$(bindir)" 994 995uninstall_runtime_libs: 996 @$(ECHO) "*** Uninstalling runtime libraries" 997 @ : {- output_off() unless windowsdll(); "" -} 998 @set -e; for s in dummy $(INSTALL_SHLIBS); do \ 999 if [ "$$s" = "dummy" ]; then continue; fi; \ 1000 fn=`basename $$s`; \ 1001 $(ECHO) "$(RM) $(DESTDIR)$(bindir)/$$fn"; \ 1002 $(RM) "$(DESTDIR)$(bindir)/$$fn"; \ 1003 done 1004 @ : {- output_on() unless windowsdll(); "" -} 1005 1006 1007install_man_docs: build_man_docs 1008 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) 1009 @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(MANDIR)/man1" 1010 @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(MANDIR)/man3" 1011 @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(MANDIR)/man5" 1012 @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(MANDIR)/man7" 1013 @$(ECHO) "*** Installing manpages" 1014 @set -e; for x in dummy $(MANDOCS1); do \ 1015 if [ "$$x" = "dummy" ]; then continue; fi; \ 1016 fn=`basename $$x`; \ 1017 $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX)"; \ 1018 cp $$x "$(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX)"; \ 1019 chmod 644 "$(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX)"; \ 1020 $(PERL) $(SRCDIR)/util/write-man-symlinks install $(SRCDIR)/doc/man1 $(BLDDIR)/doc/man1 $${fn}$(MANSUFFIX) "$(DESTDIR)$(MANDIR)/man1"; \ 1021 done 1022 @set -e; for x in dummy $(MANDOCS3); do \ 1023 if [ "$$x" = "dummy" ]; then continue; fi; \ 1024 fn=`basename $$x`; \ 1025 $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX)"; \ 1026 cp $$x "$(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX)"; \ 1027 chmod 644 "$(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX)"; \ 1028 $(PERL) $(SRCDIR)/util/write-man-symlinks install $(SRCDIR)/doc/man3 $(BLDDIR)/doc/man3 $${fn}$(MANSUFFIX) "$(DESTDIR)$(MANDIR)/man3"; \ 1029 done 1030 @set -e; for x in dummy $(MANDOCS5); do \ 1031 if [ "$$x" = "dummy" ]; then continue; fi; \ 1032 fn=`basename $$x`; \ 1033 $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX)"; \ 1034 cp $$x "$(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX)"; \ 1035 chmod 644 "$(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX)"; \ 1036 $(PERL) $(SRCDIR)/util/write-man-symlinks install $(SRCDIR)/doc/man5 $(BLDDIR)/doc/man5 $${fn}$(MANSUFFIX) "$(DESTDIR)$(MANDIR)/man5"; \ 1037 done 1038 @set -e; for x in dummy $(MANDOCS7); do \ 1039 if [ "$$x" = "dummy" ]; then continue; fi; \ 1040 fn=`basename $$x`; \ 1041 $(ECHO) "install $$x -> $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX)"; \ 1042 cp $$x "$(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX)"; \ 1043 chmod 644 "$(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX)"; \ 1044 $(PERL) $(SRCDIR)/util/write-man-symlinks install $(SRCDIR)/doc/man7 $(BLDDIR)/doc/man7 $${fn}$(MANSUFFIX) "$(DESTDIR)$(MANDIR)/man7"; \ 1045 done 1046 1047uninstall_man_docs: build_man_docs 1048 @$(ECHO) "*** Uninstalling manpages" 1049 @set -e; for x in dummy $(MANDOCS1); do \ 1050 if [ "$$x" = "dummy" ]; then continue; fi; \ 1051 fn=`basename $$x`; \ 1052 $(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX)"; \ 1053 $(RM) "$(DESTDIR)$(MANDIR)/man1/$${fn}$(MANSUFFIX)"; \ 1054 $(PERL) $(SRCDIR)/util/write-man-symlinks uninstall $(SRCDIR)/doc/man1 $(BLDDIR)/doc/man1 $${fn}$(MANSUFFIX) "$(DESTDIR)$(MANDIR)/man1"; \ 1055 done 1056 @set -e; for x in dummy $(MANDOCS3); do \ 1057 if [ "$$x" = "dummy" ]; then continue; fi; \ 1058 fn=`basename $$x`; \ 1059 $(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX)"; \ 1060 $(RM) "$(DESTDIR)$(MANDIR)/man3/$${fn}$(MANSUFFIX)"; \ 1061 $(PERL) $(SRCDIR)/util/write-man-symlinks uninstall $(SRCDIR)/doc/man3 $(BLDDIR)/doc/man3 $${fn}$(MANSUFFIX) "$(DESTDIR)$(MANDIR)/man3"; \ 1062 done 1063 @set -e; for x in dummy $(MANDOCS5); do \ 1064 if [ "$$x" = "dummy" ]; then continue; fi; \ 1065 fn=`basename $$x`; \ 1066 $(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX)"; \ 1067 $(RM) "$(DESTDIR)$(MANDIR)/man5/$${fn}$(MANSUFFIX)"; \ 1068 $(PERL) $(SRCDIR)/util/write-man-symlinks uninstall $(SRCDIR)/doc/man5 $(BLDDIR)/doc/man5 $${fn}$(MANSUFFIX) "$(DESTDIR)$(MANDIR)/man5"; \ 1069 done 1070 @set -e; for x in dummy $(MANDOCS7); do \ 1071 if [ "$$x" = "dummy" ]; then continue; fi; \ 1072 fn=`basename $$x`; \ 1073 $(ECHO) "$(RM) $(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX)"; \ 1074 $(RM) "$(DESTDIR)$(MANDIR)/man7/$${fn}$(MANSUFFIX)"; \ 1075 $(PERL) $(SRCDIR)/util/write-man-symlinks uninstall $(SRCDIR)/doc/man7 $(BLDDIR)/doc/man7 $${fn}$(MANSUFFIX) "$(DESTDIR)$(MANDIR)/man7"; \ 1076 done 1077 1078install_html_docs: install_image_docs build_html_docs 1079 @[ -n "$(INSTALLTOP)" ] || (echo INSTALLTOP should not be empty; exit 1) 1080 @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(HTMLDIR)/man1" 1081 @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(HTMLDIR)/man3" 1082 @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(HTMLDIR)/man5" 1083 @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(HTMLDIR)/man7" 1084 @$(ECHO) "*** Installing HTML manpages" 1085 @set -e; for x in dummy $(HTMLDOCS1); do \ 1086 if [ "$$x" = "dummy" ]; then continue; fi; \ 1087 fn=`basename $$x`; \ 1088 $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man1/$$fn"; \ 1089 cp $$x "$(DESTDIR)$(HTMLDIR)/man1/$$fn"; \ 1090 chmod 644 "$(DESTDIR)$(HTMLDIR)/man1/$$fn"; \ 1091 done 1092 @set -e; for x in dummy $(HTMLDOCS3); do \ 1093 if [ "$$x" = "dummy" ]; then continue; fi; \ 1094 fn=`basename $$x`; \ 1095 $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man3/$$fn"; \ 1096 cp $$x "$(DESTDIR)$(HTMLDIR)/man3/$$fn"; \ 1097 chmod 644 "$(DESTDIR)$(HTMLDIR)/man3/$$fn"; \ 1098 done 1099 @set -e; for x in dummy $(HTMLDOCS5); do \ 1100 if [ "$$x" = "dummy" ]; then continue; fi; \ 1101 fn=`basename $$x`; \ 1102 $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man5/$$fn"; \ 1103 cp $$x "$(DESTDIR)$(HTMLDIR)/man5/$$fn"; \ 1104 chmod 644 "$(DESTDIR)$(HTMLDIR)/man5/$$fn"; \ 1105 done 1106 @set -e; for x in dummy $(HTMLDOCS7); do \ 1107 if [ "$$x" = "dummy" ]; then continue; fi; \ 1108 fn=`basename $$x`; \ 1109 $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man7/$$fn"; \ 1110 cp $$x "$(DESTDIR)$(HTMLDIR)/man7/$$fn"; \ 1111 chmod 644 "$(DESTDIR)$(HTMLDIR)/man7/$$fn"; \ 1112 done 1113 1114uninstall_html_docs: uninstall_image_docs 1115 @$(ECHO) "*** Uninstalling HTML manpages" 1116 @set -e; for x in dummy $(HTMLDOCS1); do \ 1117 if [ "$$x" = "dummy" ]; then continue; fi; \ 1118 fn=`basename $$x`; \ 1119 $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man1/$$fn"; \ 1120 $(RM) "$(DESTDIR)$(HTMLDIR)/man1/$$fn"; \ 1121 done 1122 @set -e; for x in dummy $(HTMLDOCS3); do \ 1123 if [ "$$x" = "dummy" ]; then continue; fi; \ 1124 fn=`basename $$x`; \ 1125 $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man3/$$fn"; \ 1126 $(RM) "$(DESTDIR)$(HTMLDIR)/man3/$$fn"; \ 1127 done 1128 @set -e; for x in dummy $(HTMLDOCS5); do \ 1129 if [ "$$x" = "dummy" ]; then continue; fi; \ 1130 fn=`basename $$x`; \ 1131 $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man5/$$fn"; \ 1132 $(RM) "$(DESTDIR)$(HTMLDIR)/man5/$$fn"; \ 1133 done 1134 @set -e; for x in dummy $(HTMLDOCS7); do \ 1135 if [ "$$x" = "dummy" ]; then continue; fi; \ 1136 fn=`basename $$x`; \ 1137 $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man7/$$fn"; \ 1138 $(RM) "$(DESTDIR)$(HTMLDIR)/man7/$$fn"; \ 1139 done 1140 1141install_image_docs: 1142 @$(PERL) $(SRCDIR)/util/mkdir-p.pl "$(DESTDIR)$(HTMLDIR)/man7/img" 1143 @set -e; for x in dummy $(IMAGEDOCS7); do \ 1144 if [ "$$x" = "dummy" ]; then continue; fi; \ 1145 fn=`basename $$x`; \ 1146 $(ECHO) "install $$x -> $(DESTDIR)$(HTMLDIR)/man7/img/$$fn"; \ 1147 cp $(SRCDIR)/$$x "$(DESTDIR)$(HTMLDIR)/man7/img/$$fn"; \ 1148 chmod 644 "$(DESTDIR)$(HTMLDIR)/man7/img/$$fn"; \ 1149 done 1150 1151uninstall_image_docs: 1152 @set -e; for x in dummy $(IMAGEDOCS7); do \ 1153 if [ "$$x" = "dummy" ]; then continue; fi; \ 1154 fn=`basename $$x`; \ 1155 $(ECHO) "$(RM) $(DESTDIR)$(HTMLDIR)/man7/img/$$fn"; \ 1156 $(RM) "$(DESTDIR)$(HTMLDIR)/man7/img/$$fn"; \ 1157 done 1158 1159# Developer targets (note: these are only available on Unix) ######### 1160##@ Code maintenance 1161 1162# It's important that generate_buildinfo comes after ordinals, as ordinals 1163# is sensitive to build.info changes. 1164update: generate errors ordinals generate_buildinfo ## Update errors, ordinals and build info 1165 1166.PHONY: generate generate_apps generate_crypto_bn generate_crypto_objects \ 1167 generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids 1168generate: generate_apps generate_crypto_bn generate_crypto_objects \ 1169 generate_crypto_conf generate_crypto_asn1 generate_fuzz_oids 1170 1171.PHONY: generate_buildinfo generate_doc_buildinfo 1172generate_buildinfo: generate_doc_buildinfo 1173 1174.PHONY: doc-nits md-nits 1175doc-nits: build_generated_pods ## Evaluate OpenSSL documentation 1176 $(PERL) $(SRCDIR)/util/find-doc-nits -c -n -l -e -i 1177 1178# This uses "mdl", the markdownlint application, which is written in ruby. 1179# The source is at https://github.com/markdownlint/markdownlint 1180# If you have ruby installed, "gem install mdl" should work. 1181# Another option is at https://snapcraft.io/install/mdl/debian 1182# Finally, there's a Node.js version, which we haven't tried, that 1183# can be found at https://github.com/DavidAnson/markdownlint 1184md-nits: ## Evaluate markdown files via "mdl" 1185 mdl -s $(SRCDIR)/util/markdownlint.rb . 1186 1187# Test coverage is a good idea for the future 1188#coverage: $(PROGRAMS) $(TESTPROGRAMS) 1189# ... 1190 1191.PHONY: lint 1192lint: ## Evaluate C code via "splint" 1193 @( cd $(SRCDIR); \ 1194 echo splint -DLINT -posixlib -preproc -D__gnuc_va_list=void \ 1195 -I. -Iinclude -Iapps/include $(CRYPTOHEADERS) $(SSLHEADERS) $(SRCS) ) 1196 1197.PHONY: check-format 1198check-format: ## Evaluate C code according to OpenSSL coding standards 1199 ( cd $(SRCDIR); $(PERL) util/check-format.pl \ 1200 $(SRCS) \$(CRYPTOHEADERS) $(SSLHEADERS) ) 1201 1202generate_apps: 1203 ( cd $(SRCDIR); $(PERL) VMS/VMSify-conf.pl \ 1204 < apps/openssl.cnf > apps/openssl-vms.cnf ) 1205 1206generate_crypto_bn: 1207 ( cd $(SRCDIR); $(PERL) crypto/bn/bn_prime.pl > crypto/bn/bn_prime.h ) 1208 1209generate_crypto_objects: 1210 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl -n \ 1211 crypto/objects/objects.txt \ 1212 crypto/objects/obj_mac.num \ 1213 > crypto/objects/obj_mac.new && \ 1214 mv crypto/objects/obj_mac.new crypto/objects/obj_mac.num ) 1215 ( cd $(SRCDIR); $(PERL) crypto/objects/objects.pl \ 1216 crypto/objects/objects.txt \ 1217 crypto/objects/obj_mac.num \ 1218 > include/openssl/obj_mac.h ) 1219 ( cd $(SRCDIR); $(PERL) crypto/objects/obj_dat.pl \ 1220 include/openssl/obj_mac.h \ 1221 > crypto/objects/obj_dat.h ) 1222 ( cd $(SRCDIR); $(PERL) crypto/objects/objxref.pl \ 1223 crypto/objects/obj_mac.num \ 1224 crypto/objects/obj_xref.txt \ 1225 > crypto/objects/obj_xref.h ) 1226 ( cd $(SRCDIR); sed -e '1,8d' crypto/objects/obj_compat.h >> include/openssl/obj_mac.h ) 1227 1228generate_crypto_conf: 1229 ( cd $(SRCDIR); $(PERL) crypto/conf/keysets.pl \ 1230 > crypto/conf/conf_def.h ) 1231 1232generate_crypto_asn1: 1233 ( cd $(SRCDIR); $(PERL) crypto/asn1/charmap.pl \ 1234 > crypto/asn1/charmap.h ) 1235 1236generate_fuzz_oids: 1237 ( cd $(SRCDIR); $(PERL) fuzz/mkfuzzoids.pl \ 1238 crypto/objects/obj_dat.h \ 1239 > fuzz/oids.txt ) 1240 1241generate_doc_buildinfo: 1242 ( $(PERL) -I$(BLDDIR) -Mconfigdata \ 1243 $(SRCDIR)/util/dofile.pl -o Makefile \ 1244 $(SRCDIR)/doc/build.info.in \ 1245 > $(SRCDIR)/doc/build.info.new; \ 1246 if ( test -e $(SRCDIR)/doc/build.info \ 1247 && cmp $(SRCDIR)/doc/build.info.new $(SRCDIR)/doc/build.info \ 1248 > /dev/null ); \ 1249 then \ 1250 rm $(SRCDIR)/doc/build.info.new; \ 1251 else \ 1252 mv $(SRCDIR)/doc/build.info.new $(SRCDIR)/doc/build.info; \ 1253 fi ) 1254 1255generate_fips_sources: providers/fips.module.sources.new 1256providers/fips.module.sources.new: configdata.pm 1257 rm -rf sources-tmp 1258 mkdir sources-tmp 1259 ( \ 1260 srcdir=`cd $(SRCDIR); pwd`; \ 1261 cd sources-tmp \ 1262 && $$srcdir/Configure --banner=Configured enable-fips -O0 \ 1263 && ./configdata.pm --query 'get_sources("providers/fips")' > sources1 \ 1264 && "$(MAKE)" -sj 4 build_generated providers/fips.so \ 1265 && find . -name '*.d' | xargs cat > dep1 \ 1266 && "$(MAKE)" distclean \ 1267 && $$srcdir/Configure --banner=Configured enable-fips no-asm -O0 \ 1268 && ./configdata.pm --query 'get_sources("providers/fips")' > sources2 \ 1269 && "$(MAKE)" -sj 4 build_generated providers/fips.so \ 1270 && find . -name '*.d' | xargs cat > dep2 \ 1271 && cat sources1 sources2 \ 1272 | grep -v ' : \\$$' | grep -v util/providers.num \ 1273 | sed -e 's/^ *//' -e 's/ *\\$$//' \ 1274 | sort | uniq > sources \ 1275 && cat dep1 dep2 \ 1276 | $(PERL) -p -e 's/\\\n//' \ 1277 | sed -e 's/^.*: *//' -e 's/ */ /g' \ 1278 | fgrep -f sources \ 1279 | tr ' ' '\n' \ 1280 | sort | uniq > deps.raw \ 1281 && cat deps.raw \ 1282 | xargs ./configdata.pm --query 'get_sources(@ARGV)' \ 1283 | $(PERL) -p -e 's/\\\n//' \ 1284 | sed -e 's/\./\\\./g' -e 's/ : */:/' -e 's/^/s:/' -e 's/$$/:/' \ 1285 > deps.sed \ 1286 && cat deps.raw | sed -f deps.sed > deps \ 1287 ) 1288 ( \ 1289 cat sources-tmp/sources sources-tmp/deps \ 1290 | $(PERL) -p -e 's:^ *\Q../\E:: ;' \ 1291 -e 's:^\Q$(SRCDIR)/\E:: if "$(SRCDIR)" ne "." ;' \ 1292 -e 'my $$x; do { $$x = $$_; s:(^|/)((?!\Q../\E)[^/]*/)\Q..\E($$|/):$$1: } while ($$x ne $$_) ;' ; \ 1293 cd $(SRCDIR); \ 1294 for x in crypto/bn/asm/*.pl crypto/bn/asm/*.S \ 1295 crypto/aes/asm/*.pl crypto/aes/asm/*.S \ 1296 crypto/ec/asm/*.pl \ 1297 crypto/modes/asm/*.pl \ 1298 crypto/sha/asm/*.pl \ 1299 crypto/*cpuid.pl crypto/*cpuid.S \ 1300 crypto/*cap.c; do \ 1301 echo "$$x"; \ 1302 done \ 1303 ) | grep -v sm2p256 | sort | uniq > providers/fips.module.sources.new 1304 rm -rf sources-tmp 1305 1306# Set to -force to force a rebuild 1307ERROR_REBUILD= 1308errors: 1309 ( b=`pwd`; set -e; cd $(SRCDIR); \ 1310 $(PERL) util/ck_errf.pl -strict -internal; \ 1311 $(PERL) -I$$b util/mkerr.pl $(ERROR_REBUILD) -internal ) 1312 ( b=`pwd`; set -e; cd $(SRCDIR)/engines; \ 1313 for E in *.ec ; do \ 1314 $(PERL) ../util/ck_errf.pl -strict \ 1315 -conf $$E `basename $$E .ec`.c; \ 1316 $(PERL) -I$$b ../util/mkerr.pl $(ERROR_REBUILD) -static \ 1317 -conf $$E `basename $$E .ec`.c ; \ 1318 done ) 1319 1320{- use File::Basename; 1321 1322 my @sslheaders_tmpl = 1323 qw( include/openssl/ssl.h 1324 include/openssl/ssl2.h 1325 include/openssl/ssl3.h 1326 include/openssl/sslerr.h 1327 include/openssl/tls1.h 1328 include/openssl/dtls1.h 1329 include/openssl/srtp.h 1330 include/openssl/quic.h 1331 include/openssl/sslerr_legacy.h ); 1332 my @cryptoheaders_tmpl = 1333 qw( include/internal/dso.h 1334 include/internal/o_dir.h 1335 include/internal/err.h 1336 include/internal/evp.h 1337 include/internal/pem.h 1338 include/internal/asn1.h 1339 include/internal/sslconf.h ); 1340 my @cryptoskipheaders = ( @sslheaders_tmpl, 1341 qw( include/openssl/asn1_mac.h 1342 include/openssl/conf_api.h 1343 include/openssl/ebcdic.h 1344 include/openssl/opensslconf.h 1345 include/openssl/symhacks.h ) ); 1346 our %cryptoheaders = (); 1347 our %sslheaders = (); 1348 foreach my $d ( qw( include/openssl include/internal ) ) { 1349 my @header_patterns = 1350 map { catfile($config{sourcedir}, $d, $_) } ( '*.h', '*.h.in' ); 1351 foreach my $f ( map { glob($_) } @header_patterns ) { 1352 my $base = basename($f); 1353 my $base_in = basename($f, '.in'); 1354 my $dir = catfile($config{sourcedir}, $d); 1355 if ($base ne $base_in) { 1356 # We have a .h.in file, which means the header file is in the 1357 # build tree. 1358 $base = $base_in; 1359 $dir = catfile($config{builddir}, $d); 1360 } 1361 my $new_f = catfile($dir, $base); 1362 my $fn = "$d/$base"; 1363 # The logic to add files to @cryptoheaders is a bit complex. The 1364 # file to be added must be either in the public header directory 1365 # or one of the pre-declared internal headers, and must under no 1366 # circumstances be one of those that must be skipped. 1367 $cryptoheaders{$new_f} = 1 1368 if (($d eq 'include/openssl' 1369 || ( grep { $_ eq $fn } @cryptoheaders_tmpl )) 1370 && !( grep { $_ eq $fn } @cryptoskipheaders )); 1371 # The logic to add files to @sslheaders is much simpler... 1372 $sslheaders{$new_f} = 1 if grep { $_ eq $fn } @sslheaders_tmpl; 1373 } 1374 } 1375 ""; 1376-} 1377SRCS={- 1378sub uniq { my %seen; grep !$seen{$_}++, @_; } 1379sub flat(@) { return map { ref eq 'ARRAY' ? @$_ : $_ } @_; } 1380join(" \\\n" . ' ' x 5, fill_lines(" ", $COLUMNS - 5, 1381 uniq(grep /\.(c|cc|cpp)$/, 1382 flat (map { $unified_info{sources}->{$_} } 1383 (sort keys %{$unified_info{sources}}))))) 1384-} 1385CRYPTOHEADERS={- join(" \\\n" . ' ' x 14, 1386 fill_lines(" ", $COLUMNS - 14, sort keys %cryptoheaders)) -} 1387SSLHEADERS={- join(" \\\n" . ' ' x 11, 1388 fill_lines(" ", $COLUMNS - 11, sort keys %sslheaders)) -} 1389 1390renumber: build_generated 1391 $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \ 1392 --ordinals $(SRCDIR)/util/libcrypto.num \ 1393 --symhacks $(SRCDIR)/include/openssl/symhacks.h \ 1394 --renumber \ 1395 $(CRYPTOHEADERS) 1396 $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \ 1397 --ordinals $(SRCDIR)/util/libssl.num \ 1398 --symhacks $(SRCDIR)/include/openssl/symhacks.h \ 1399 --renumber \ 1400 $(SSLHEADERS) 1401 1402.PHONY: ordinals 1403ordinals: build_generated 1404 $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \ 1405 --ordinals $(SRCDIR)/util/libcrypto.num \ 1406 --symhacks $(SRCDIR)/include/openssl/symhacks.h \ 1407 $(CRYPTOHEADERS) 1408 $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \ 1409 --ordinals $(SRCDIR)/util/libssl.num \ 1410 --symhacks $(SRCDIR)/include/openssl/symhacks.h \ 1411 $(SSLHEADERS) 1412 1413test_ordinals: 1414 "$(MAKE)" run_tests TESTS=test_ordinals 1415 1416tags TAGS: FORCE 1417 rm -f TAGS tags 1418 -( cd $(SRCDIR); util/ctags.sh ) 1419 -etags `find . -name '*.[ch]' -o -name '*.pm'` 1420 1421providers/fips.checksum.new: providers/fips.module.sources.new 1422 @which unifdef > /dev/null || \ 1423 ( echo >&2 "ERROR: unifdef not in your \$$PATH, FIPS checksums not calculated"; \ 1424 false ) 1425 ( sources=`pwd`/providers/fips.module.sources.new; \ 1426 cd $(SRCDIR) \ 1427 && cat $$sources \ 1428 | xargs ./util/fips-checksums.sh ) \ 1429 > providers/fips-sources.checksums.new \ 1430 && sha256sum providers/fips-sources.checksums.new \ 1431 | sed -e 's|\.new||' > providers/fips.checksum.new 1432 1433fips-checksums: providers/fips.checksum.new 1434 1435$(SRCDIR)/providers/fips.checksum: providers/fips.checksum.new 1436 cp -p providers/fips.module.sources.new $(SRCDIR)/providers/fips.module.sources 1437 cp -p providers/fips-sources.checksums.new $(SRCDIR)/providers/fips-sources.checksums 1438 cp -p providers/fips.checksum.new $(SRCDIR)/providers/fips.checksum 1439 1440update-fips-checksums: $(SRCDIR)/providers/fips.checksum 1441 1442diff-fips-checksums: fips-checksums 1443 diff -u $(SRCDIR)/providers/fips.module.sources providers/fips.module.sources.new 1444 diff -u $(SRCDIR)/providers/fips-sources.checksums providers/fips-sources.checksums.new 1445 diff -u $(SRCDIR)/providers/fips.checksum providers/fips.checksum.new 1446 1447# Release targets (note: only available on Unix) ##################### 1448 1449tar: 1450 (cd $(SRCDIR); ./util/mktar.sh --name='$(NAME)' --tarfile='$(TARFILE)') 1451 1452# Helper targets ##################################################### 1453 1454link-utils: $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/apps/openssl.cnf 1455 1456$(BLDDIR)/util/opensslwrap.sh: Makefile 1457 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \ 1458 mkdir -p "$(BLDDIR)/util"; \ 1459 ln -sf "../$(SRCDIR)/util/`basename "$@"`" "$(BLDDIR)/util"; \ 1460 fi 1461 1462$(BLDDIR)/apps/openssl.cnf: Makefile 1463 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \ 1464 mkdir -p "$(BLDDIR)/apps"; \ 1465 ln -sf "../$(SRCDIR)/apps/`basename "$@"`" "$(BLDDIR)/apps"; \ 1466 fi 1467 1468FORCE: 1469 1470# Building targets ################################################### 1471 1472Makefile: configdata.pm \ 1473 {- join(" \\\n" . ' ' x 10, 1474 fill_lines(" ", $COLUMNS - 10, 1475 @{$config{build_file_templates}})) -} 1476 @echo "Detected changed: $?" 1477 $(PERL) configdata.pm 1478 @echo "**************************************************" 1479 @echo "*** ***" 1480 @echo "*** Please run the same make command again ***" 1481 @echo "*** ***" 1482 @echo "**************************************************" 1483 @false 1484 1485configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config \ 1486 {- join(" \\\n" . ' ' x 15, 1487 fill_lines(" ", $COLUMNS - 15, 1488 @{$config{build_infos}}, 1489 @{$config{conf_files}})) -} 1490 @echo "Detected changed: $?" 1491 $(PERL) configdata.pm -r 1492 @echo "**************************************************" 1493 @echo "*** ***" 1494 @echo "*** Please run the same make command again ***" 1495 @echo "*** ***" 1496 @echo "**************************************************" 1497 @false 1498 1499reconfigure reconf: 1500 $(PERL) configdata.pm -r 1501 1502{- 1503 use File::Basename; 1504 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/; 1505 1506 # Helper function to convert dependencies in platform agnostic form to 1507 # dependencies in platform form. 1508 sub compute_platform_depends { 1509 map { my $x = $_; 1510 1511 grep { $x eq $_ } @{$unified_info{programs}} and platform->bin($x) 1512 or grep { $x eq $_ } @{$unified_info{modules}} and platform->dso($x) 1513 or grep { $x eq $_ } @{$unified_info{libraries}} and platform->lib($x) 1514 or platform->convertext($x); } @_; 1515 } 1516 1517 # Helper function to figure out dependencies on libraries 1518 # It takes a list of library names and outputs a list of dependencies 1519 sub compute_lib_depends { 1520 # Depending on shared libraries: 1521 # On Windows POSIX layers, we depend on {libname}.dll.a 1522 # On Unix platforms, we depend on {shlibname}.so 1523 return map { platform->sharedlib_simple($_) 1524 // platform->sharedlib_import($_) 1525 // platform->sharedlib($_) 1526 // platform->staticlib($_) 1527 } @_; 1528 } 1529 1530 sub generatetarget { 1531 my %args = @_; 1532 my $deps = join(" ", compute_platform_depends(@{$args{deps}})); 1533 return <<"EOF"; 1534$args{target}: $deps 1535EOF 1536 } 1537 1538 sub generatesrc { 1539 my %args = @_; 1540 my $gen0 = $args{generator}->[0]; 1541 my $gen_args = join('', map { " $_" } 1542 @{$args{generator}}[1..$#{$args{generator}}]); 1543 my $gen_incs = join("", map { " -I".$_ } @{$args{generator_incs}}); 1544 my $incs = join("", map { " -I".$_ } @{$args{incs}}); 1545 my $defs = join("", map { " -D".$_ } @{$args{defs}}); 1546 my $deps = join(" ", compute_platform_depends(@{$args{generator_deps}}, 1547 @{$args{deps}})); 1548 1549 if ($args{src} =~ /\.html$/) { 1550 # 1551 # HTML generator 1552 # 1553 my $title = basename($args{src}, ".html"); 1554 my $pod = $gen0; 1555 return <<"EOF"; 1556$args{src}: $pod 1557 \$(PERL) \$(SRCDIR)/util/mkpod2html.pl -i "$pod" -o \$\@ -t "$title" -r "\$(SRCDIR)/doc" 1558EOF 1559 } elsif ($args{src} =~ /\.(\d)$/) { 1560 # 1561 # Man-page generator 1562 # 1563 my $section = $1; 1564 my $name = uc basename($args{src}, ".$section"); 1565 my $pod = $gen0; 1566 return <<"EOF"; 1567$args{src}: $pod 1568 pod2man --name=$name --section=$section\$(MANSUFFIX) --center=OpenSSL \\ 1569 --release=\$(VERSION) $pod >\$\@ 1570EOF 1571 } elsif (platform->isdef($args{src})) { 1572 # 1573 # Linker script-ish generator 1574 # 1575 my $target = platform->def($args{src}); 1576 (my $mkdef_os = $target{shared_target}) =~ s|-shared$||; 1577 my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION_NUMBER)' : ''; 1578 my $ord_name = $args{generator}->[1] || $args{product}; 1579 return <<"EOF"; 1580$target: $gen0 $deps \$(SRCDIR)/util/mkdef.pl 1581 \$(PERL) \$(SRCDIR)/util/mkdef.pl$ord_ver --type $args{intent} --ordinals $gen0 --name $ord_name --OS $mkdef_os > $target 1582EOF 1583 } elsif (platform->isasm($args{src}) 1584 || platform->iscppasm($args{src})) { 1585 # 1586 # Assembler generator 1587 # 1588 my $cppflags = { 1589 shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)', 1590 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)', 1591 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)', 1592 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)' 1593 } -> {$args{intent}}; 1594 1595 my $generator; 1596 if ($gen0 =~ /\.pl$/) { 1597 $generator = 'CC="$(CC)" $(PERL)'.$gen_incs.' '.$gen0.$gen_args 1598 .' "$(PERLASM_SCHEME)"'.$incs.' '.$cppflags.$defs.' $(PROCESSOR)'; 1599 } elsif ($gen0 =~ /\.m4$/) { 1600 $generator = 'm4 -B 8192'.$gen_incs.' '.$gen0.$gen_args.' >' 1601 } elsif ($gen0 =~ /\.S$/) { 1602 $generator = undef; 1603 } else { 1604 die "Generator type for $args{src} unknown: $gen0\n"; 1605 } 1606 1607 if (defined($generator)) { 1608 return <<"EOF"; 1609$args{src}: $gen0 $deps 1610 $generator \$@ 1611EOF 1612 } 1613 return <<"EOF"; 1614$args{src}: $gen0 $deps 1615 \$(CC) $incs $cppflags $defs -E $gen0 | \\ 1616 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@ 1617EOF 1618 } elsif ($gen0 =~ m|^.*\.in$|) { 1619 # 1620 # "dofile" generator (file.in -> file) 1621 # 1622 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, 1623 "util", "dofile.pl")), 1624 rel2abs($config{builddir})); 1625 my @perlmodules = (); 1626 my %perlmoduleincs = (); 1627 my %perlmoduledeps = (); 1628 foreach my $x (('configdata.pm', @{$args{deps}})) { 1629 # Compute (i)nclusion directory, (m)odule name and (d)ependency 1630 my $i, $m, $d; 1631 if ($x =~ /\|/) { 1632 $i = $`; 1633 $d = $'; 1634 1635 # Massage the module part to become a real perl module spec 1636 $m = $d; 1637 $m =~ s|\.pm$||; 1638 # Directory specs are :: in perl package names 1639 $m =~ s|/|::|g; 1640 1641 # Full file name of the dependency 1642 $d = catfile($i, $d) if $i; 1643 } elsif ($x =~ /\.pm$/) { 1644 $i = dirname($x); 1645 $m = basename($x, '.pm'); 1646 $d = $x; 1647 } else { 1648 # All other dependencies are simply collected 1649 $d = $x; 1650 } 1651 push @perlmodules, '"-M'.$m.'"' if $m; 1652 $perlmoduledeps{$d} = 1; 1653 $perlmoduleincs{'"-I'.$i.'"'} = 1 if $i; 1654 } 1655 1656 # Because of the special treatment of dependencies, we need to 1657 # recompute $deps completely 1658 my $deps 1659 = join(" ", compute_platform_depends(@{$args{generator_deps}}, 1660 sort keys %perlmoduledeps)); 1661 my $perlmodules = join(' ', '', ( sort keys %perlmoduleincs ), @perlmodules); 1662 1663 return <<"EOF"; 1664$args{src}: $gen0 $deps 1665 \$(PERL)$perlmodules "$dofile" "-o$target{build_file}" $gen0$gen_args > \$@ 1666EOF 1667 } elsif (grep { $_ eq $gen0 } @{$unified_info{programs}}) { 1668 # 1669 # Generic generator using OpenSSL programs 1670 # 1671 1672 # Redo $gen0, to ensure that we have the proper extension where 1673 # necessary. 1674 $gen0 = platform->bin($gen0); 1675 # Use $(PERL) to execute wrap.pl directly to avoid calling env 1676 return <<"EOF"; 1677$args{src}: $gen0 $deps \$(BLDDIR)/util/wrap.pl 1678 \$(PERL) \$(BLDDIR)/util/wrap.pl $gen0$gen_args > \$@ 1679EOF 1680 } else { 1681 # 1682 # Generic generator using Perl 1683 # 1684 return <<"EOF"; 1685$args{src}: $gen0 $deps 1686 \$(PERL)$gen_incs $gen0$gen_args > \$@ 1687EOF 1688 } 1689 } 1690 1691 # Should one wonder about the end of the Perl snippet, it's because this 1692 # second regexp eats up line endings as well, if the removed path is the 1693 # last in the line. We may therefore need to put back a line ending. 1694 sub src2obj { 1695 my %args = @_; 1696 my $obj = platform->convertext($args{obj}); 1697 my $dep = platform->dep($args{obj}); 1698 my @srcs = @{$args{srcs}}; 1699 my $srcs = join(" ", @srcs); 1700 my $deps = join(" ", @srcs, @{$args{deps}}); 1701 my $incs = join("", map { " -I".$_ } @{$args{incs}}); 1702 my $defs = join("", map { " -D".$_ } @{$args{defs}}); 1703 my $cmd; 1704 my $cmdflags; 1705 my $cmdcompile; 1706 if (grep /\.rc$/, @srcs) { 1707 $cmd = '$(RC)'; 1708 $cmdflags = '$(RCFLAGS)'; 1709 $cmdcompile = ''; 1710 } elsif (grep /\.(cc|cpp)$/, @srcs) { 1711 $cmd = '$(CXX)'; 1712 $cmdcompile = ' -c'; 1713 $cmdflags = { 1714 shlib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)', 1715 lib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)', 1716 dso => '$(DSO_CXXFLAGS) $(DSO_CPPFLAGS)', 1717 bin => '$(BIN_CXXFLAGS) $(BIN_CPPFLAGS)' 1718 } -> {$args{intent}}; 1719 } else { 1720 $cmd = '$(CC)'; 1721 $cmdcompile = ' -c'; 1722 $cmdflags = { 1723 shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)', 1724 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)', 1725 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)', 1726 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)' 1727 } -> {$args{intent}}; 1728 } 1729 my $recipe; 1730 # extension-specific rules 1731 if (grep /\.s$/, @srcs) { 1732 $recipe .= <<"EOF"; 1733$obj: $deps 1734 $cmd $cmdflags -c -o \$\@ $srcs 1735EOF 1736 } elsif (grep /\.S$/, @srcs) { 1737 # Originally there was multi-step rule with $(CC) -E file.S 1738 # followed by $(CC) -c file.s. It compensated for one of 1739 # legacy platform compiler's inability to handle .S files. 1740 # The platform is long discontinued by vendor so there is 1741 # hardly a point to drag it along... 1742 $recipe .= <<"EOF"; 1743$obj: $deps 1744 $cmd $incs $defs $cmdflags -c -o \$\@ $srcs 1745EOF 1746 } elsif ($makedep_scheme eq 'gcc' && !grep /\.rc$/, @srcs) { 1747 $recipe .= <<"EOF"; 1748$obj: $deps 1749 $cmd $incs $defs $cmdflags -MMD -MF $dep.tmp -c -o \$\@ $srcs 1750 \@touch $dep.tmp 1751 \@if cmp $dep.tmp $dep > /dev/null 2> /dev/null; then \\ 1752 rm -f $dep.tmp; \\ 1753 else \\ 1754 mv $dep.tmp $dep; \\ 1755 fi 1756EOF 1757 } else { 1758 $recipe .= <<"EOF"; 1759$obj: $deps 1760 $cmd $incs $defs $cmdflags $cmdcompile -o \$\@ $srcs 1761EOF 1762 if ($makedep_scheme eq 'makedepend') { 1763 $recipe .= <<"EOF"; 1764 \$(MAKEDEPEND) -f- -Y -- $incs $cmdflags -- $srcs 2>/dev/null \\ 1765 > $dep 1766EOF 1767 } 1768 } 1769 return $recipe; 1770 } 1771 # We *know* this routine is only called when we've configure 'shared'. 1772 sub obj2shlib { 1773 my %args = @_; 1774 my @linkdirs = (); 1775 my @linklibs = (); 1776 foreach (@{$args{deps}}) { 1777 if (platform->isstaticlib($_)) { 1778 push @linklibs, platform->convertext($_); 1779 } else { 1780 my $d = "-L" . dirname($_); 1781 my $l = basename($_); 1782 $l =~ s/^lib//; 1783 $l = "-l" . $l; 1784 push @linklibs, $l; 1785 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs; 1786 } 1787 } 1788 my $linkflags = join("", map { $_." " } @linkdirs); 1789 my $linklibs = join("", map { $_." " } @linklibs); 1790 my @objs = map { platform->convertext($_) } 1791 grep { !platform->isdef($_) } 1792 @{$args{objs}}; 1793 my @defs = map { platform->def($_) } 1794 grep { platform->isdef($_) } 1795 @{$args{objs}}; 1796 my @deps = compute_lib_depends(@{$args{deps}}); 1797 die "More than one exported symbol map" if scalar @defs > 1; 1798 1799 my $full = platform->sharedlib($args{lib}); 1800 # $import is for Windows and subsystems thereof, where static import 1801 # libraries for DLLs are a thing. On platforms that have this mechanism, 1802 # $import has the name of this import library. On platforms that don't 1803 # have this mechanism, $import will be |undef|. 1804 # It's also used on AIX in solib mode, which creates import libraries 1805 # for the shared libraries. 1806 my $import = platform->sharedlib_import($args{lib}); 1807 # $simple is for platforms where full shared library names include the 1808 # shared library version, and there's a simpler name that doesn't include 1809 # that version. On such platforms, $simple has the simpler name. On 1810 # other platforms, it will be |undef|. 1811 my $simple = platform->sharedlib_simple($args{lib}); 1812 1813 my $argfile = defined $target{shared_argfileflag} ? $full.".args" : undef; 1814 my $shared_soname = ""; 1815 $shared_soname .= ' '.$target{shared_sonameflag}.basename($full) 1816 if defined $target{shared_sonameflag}; 1817 my $shared_imp = ""; 1818 $shared_imp .= ' '.$target{shared_impflag}.basename($import) 1819 if defined $target{shared_impflag} && defined $import; 1820 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs); 1821 1822 # There is at least one platform where the compiler-as-linker needs to 1823 # have one object file directly on the command line. That won't hurt 1824 # any other platform, so we do that for everyone when there's an argfile 1825 # to be had. This depends heavily on splice, which removes elements from 1826 # the given array, and returns them so they can be captured. 1827 my @argfileobjs = $argfile 1828 ? splice(@objs, 1) 1829 : (); 1830 my $argfilecmds = $argfile 1831 ? join("\n\t", map { "echo $_ >> $argfile" } @argfileobjs) 1832 : undef; 1833 my $argfiledeps = $argfile 1834 ? join(" \\\n" . ' ' x (length($argfile) + 2), 1835 fill_lines(' ', $COLUMNS - length($full) - 2, @argfileobjs)) 1836 : undef; 1837 my @fulldeps = (@objs, ($argfile ? $argfile : ()), @defs, @deps); 1838 my @fullobjs = ( 1839 @objs, 1840 ($argfile ? $target{shared_argfileflag}.$argfile : ()) 1841 ); 1842 my $fulldeps = 1843 join(" \\\n" . ' ' x (length($full) + 2), 1844 fill_lines(' ', $COLUMNS - length($full) - 2, @fulldeps)); 1845 my $fullobjs = 1846 join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @fullobjs)); 1847 1848 my $recipe = ''; 1849 1850 if (defined $simple && $simple ne $full) { 1851 if (sharedaix()) { 1852 $recipe .= <<"EOF"; 1853$simple: $full 1854 rm -f $simple && \\ 1855 \$(AR) r $simple $full 1856EOF 1857 } else { 1858 $recipe .= <<"EOF"; 1859$simple: $full 1860 rm -f $simple && \\ 1861 ln -s $full $simple 1862EOF 1863 } 1864 } 1865 if (defined $import) { 1866 if (sharedaix_solib()) { 1867 $recipe .= <<"EOF"; 1868$import: $full $defs[0] 1869 rm -f $import && \\ 1870 echo \\#!$full > $import && \\ 1871 cat $defs[0] >>$import 1872EOF 1873 } else { 1874 $recipe .= <<"EOF"; 1875$import: $full 1876EOF 1877 } 1878 } 1879 $recipe .= <<"EOF"; 1880$full: $fulldeps 1881 \$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\ 1882 -o $full$shared_def \\ 1883 $fullobjs \\ 1884 $linklibs \$(LIB_EX_LIBS) 1885EOF 1886 if (windowsdll()) { 1887 $recipe .= <<"EOF"; 1888 rm -f apps/$full 1889 rm -f fuzz/$full 1890 cp -p $full apps/ 1891 cp -p $full fuzz/ 1892EOF 1893 if (!$disabled{tests}) { 1894 $recipe .= <<"EOF"; 1895 rm -f test/$full 1896 cp -p $full test/ 1897EOF 1898 } 1899 } 1900 $recipe .= <<"EOF" if defined $argfile; 1901$argfile: $argfiledeps 1902 \$(RM) $argfile 1903 $argfilecmds 1904EOF 1905 return $recipe; 1906 } 1907 sub obj2dso { 1908 my %args = @_; 1909 my $dso = platform->dso($args{module}); 1910 my @linkdirs = (); 1911 my @linklibs = (); 1912 foreach (@{$args{deps}}) { 1913 next unless defined $_; 1914 if (platform->isstaticlib($_)) { 1915 push @linklibs, platform->convertext($_); 1916 } else { 1917 my $d = "-L" . dirname($_); 1918 my $l = basename($_); 1919 $l =~ s/^lib//; 1920 $l = "-l" . $l; 1921 push @linklibs, $l; 1922 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs; 1923 } 1924 } 1925 my $linkflags = join("", map { $_." " } @linkdirs); 1926 my $linklibs = join("", map { $_." " } @linklibs); 1927 my @objs = map { platform->convertext($_) } 1928 grep { !platform->isdef($_) } 1929 @{$args{objs}}; 1930 my @defs = map { platform->def($_) } 1931 grep { platform->isdef($_) } 1932 @{$args{objs}}; 1933 my @deps = compute_lib_depends(@{$args{deps}}); 1934 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs); 1935 # Next line needs to become "less magic" (see PR #11950) 1936 $shared_def .= ' '.$target{shared_fipsflag} if (defined $target{shared_fipsflag} && $shared_def =~ m/providers\/fips/); 1937 my $objs = join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @objs)); 1938 my $deps = join(" \\\n" . ' ' x (length($dso) + 2), 1939 fill_lines(' ', $COLUMNS - length($dso) - 2, 1940 @objs, @defs, @deps)); 1941 1942 return <<"EOF"; 1943$dso: $deps 1944 \$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\ 1945 -o $dso$shared_def \\ 1946 $objs \\ 1947 $linklibs\$(DSO_EX_LIBS) 1948EOF 1949 } 1950 sub obj2lib { 1951 my %args = @_; 1952 my $lib = platform->staticlib($args{lib}); 1953 my @objs = map { platform->obj($_) } @{$args{objs}}; 1954 my $deps = join(" \\\n" . ' ' x (length($lib) + 2), 1955 fill_lines(' ', $COLUMNS - length($lib) - 2, @objs)); 1956 my $max_per_call = 500; 1957 my @objs_grouped; 1958 push @objs_grouped, join(" ", splice @objs, 0, $max_per_call) while @objs; 1959 my $fill_lib = 1960 join("\n\t", (map { "\$(AR) \$(ARFLAGS) $lib $_" } @objs_grouped)); 1961 return <<"EOF"; 1962$lib: $deps 1963 \$(RM) $lib 1964 $fill_lib 1965 \$(RANLIB) \$\@ || echo Never mind. 1966EOF 1967 } 1968 sub obj2bin { 1969 my %args = @_; 1970 my $bin = platform->bin($args{bin}); 1971 my @objs = map { platform->obj($_) } @{$args{objs}}; 1972 my @deps = compute_lib_depends(@{$args{deps}}); 1973 my $objs = join(" \\\n" . ' ' x (length($bin) + 2), 1974 fill_lines(' ', $COLUMNS - length($bin) - 2, @objs)); 1975 my @linkdirs = (); 1976 my @linklibs = (); 1977 foreach (@{$args{deps}}) { 1978 next unless defined $_; 1979 if (platform->isstaticlib($_)) { 1980 push @linklibs, platform->convertext($_); 1981 } else { 1982 my $d = "-L" . dirname($_); 1983 my $l = basename($_); 1984 $l =~ s/^lib//; 1985 $l = "-l" . $l; 1986 push @linklibs, $l; 1987 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs; 1988 } 1989 } 1990 my $linkflags = join("", map { $_." " } @linkdirs); 1991 my $linklibs = join("", map { $_." " } @linklibs); 1992 my $cmd = '$(CC)'; 1993 my $cmdflags = '$(BIN_CFLAGS)'; 1994 if (grep /_cc\.o$/, @{$args{objs}}) { 1995 $cmd = '$(CXX)'; 1996 $cmdflags = '$(BIN_CXXFLAGS)'; 1997 } 1998 1999 my $objs = join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @objs)); 2000 my $deps = join(" \\\n" . ' ' x (length($bin) + 2), 2001 fill_lines(' ', $COLUMNS - length($bin) - 2, 2002 @objs, @deps)); 2003 2004 return <<"EOF"; 2005$bin: $deps 2006 rm -f $bin 2007 \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\ 2008 -o $bin \\ 2009 $objs \\ 2010 $linklibs\$(BIN_EX_LIBS) 2011EOF 2012 } 2013 sub in2script { 2014 my %args = @_; 2015 my $script = $args{script}; 2016 my $sources = join(" ", @{$args{sources}}); 2017 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, 2018 "util", "dofile.pl")), 2019 rel2abs($config{builddir})); 2020 return <<"EOF"; 2021$script: $sources configdata.pm 2022 \$(RM) "$script" 2023 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\ 2024 "-o$target{build_file}" $sources > "$script" 2025 chmod a+x $script 2026EOF 2027 } 2028 sub generatedir { 2029 my %args = @_; 2030 my $dir = $args{dir}; 2031 my @deps = compute_platform_depends(@{$args{deps}}); 2032 my @comments = (); 2033 2034 # We already have a 'test' target, and the top directory is just plain 2035 # silly 2036 return if $dir eq "test" || $dir eq "."; 2037 2038 foreach my $type (("dso", "lib", "bin", "script")) { 2039 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type}); 2040 # For lib object files, we could update the library. However, it 2041 # was decided that it's enough to build the directory local object 2042 # files, so we don't need to add any actions, and the dependencies 2043 # are already taken care of. 2044 if ($type ne "lib") { 2045 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) { 2046 if (dirname($prod) eq $dir) { 2047 push @deps, compute_platform_depends($prod); 2048 } else { 2049 push @comments, "# No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}}); 2050 } 2051 } 2052 } 2053 } 2054 2055 my $target = "$dir $dir/"; 2056 my $deps = join(" \\\n\t", 2057 fill_lines(' ', $COLUMNS - 8, @deps)); 2058 my $comments = join("\n", "", @comments); 2059 return <<"EOF"; 2060$target: \\ 2061 $deps$comments 2062EOF 2063 } 2064 "" # Important! This becomes part of the template result. 2065-} 2066