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/conf_api.h 1342 include/openssl/ebcdic.h 1343 include/openssl/opensslconf.h 1344 include/openssl/symhacks.h ) ); 1345 our %cryptoheaders = (); 1346 our %sslheaders = (); 1347 foreach my $d ( qw( include/openssl include/internal ) ) { 1348 my @header_patterns = 1349 map { catfile($config{sourcedir}, $d, $_) } ( '*.h', '*.h.in' ); 1350 foreach my $f ( map { glob($_) } @header_patterns ) { 1351 my $base = basename($f); 1352 my $base_in = basename($f, '.in'); 1353 my $dir = catfile($config{sourcedir}, $d); 1354 if ($base ne $base_in) { 1355 # We have a .h.in file, which means the header file is in the 1356 # build tree. 1357 $base = $base_in; 1358 $dir = catfile($config{builddir}, $d); 1359 } 1360 my $new_f = catfile($dir, $base); 1361 my $fn = "$d/$base"; 1362 # The logic to add files to @cryptoheaders is a bit complex. The 1363 # file to be added must be either in the public header directory 1364 # or one of the pre-declared internal headers, and must under no 1365 # circumstances be one of those that must be skipped. 1366 $cryptoheaders{$new_f} = 1 1367 if (($d eq 'include/openssl' 1368 || ( grep { $_ eq $fn } @cryptoheaders_tmpl )) 1369 && !( grep { $_ eq $fn } @cryptoskipheaders )); 1370 # The logic to add files to @sslheaders is much simpler... 1371 $sslheaders{$new_f} = 1 if grep { $_ eq $fn } @sslheaders_tmpl; 1372 } 1373 } 1374 ""; 1375-} 1376SRCS={- 1377sub uniq { my %seen; grep !$seen{$_}++, @_; } 1378sub flat(@) { return map { ref eq 'ARRAY' ? @$_ : $_ } @_; } 1379join(" \\\n" . ' ' x 5, fill_lines(" ", $COLUMNS - 5, 1380 uniq(grep /\.(c|cc|cpp)$/, 1381 flat (map { $unified_info{sources}->{$_} } 1382 (sort keys %{$unified_info{sources}}))))) 1383-} 1384CRYPTOHEADERS={- join(" \\\n" . ' ' x 14, 1385 fill_lines(" ", $COLUMNS - 14, sort keys %cryptoheaders)) -} 1386SSLHEADERS={- join(" \\\n" . ' ' x 11, 1387 fill_lines(" ", $COLUMNS - 11, sort keys %sslheaders)) -} 1388 1389renumber: build_generated 1390 $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \ 1391 --ordinals $(SRCDIR)/util/libcrypto.num \ 1392 --symhacks $(SRCDIR)/include/openssl/symhacks.h \ 1393 --renumber \ 1394 $(CRYPTOHEADERS) 1395 $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \ 1396 --ordinals $(SRCDIR)/util/libssl.num \ 1397 --symhacks $(SRCDIR)/include/openssl/symhacks.h \ 1398 --renumber \ 1399 $(SSLHEADERS) 1400 1401.PHONY: ordinals 1402ordinals: build_generated 1403 $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \ 1404 --ordinals $(SRCDIR)/util/libcrypto.num \ 1405 --symhacks $(SRCDIR)/include/openssl/symhacks.h \ 1406 $(CRYPTOHEADERS) 1407 $(PERL) $(SRCDIR)/util/mknum.pl --version $(VERSION_NUMBER) --no-warnings \ 1408 --ordinals $(SRCDIR)/util/libssl.num \ 1409 --symhacks $(SRCDIR)/include/openssl/symhacks.h \ 1410 $(SSLHEADERS) 1411 1412test_ordinals: 1413 "$(MAKE)" run_tests TESTS=test_ordinals 1414 1415tags TAGS: FORCE 1416 rm -f TAGS tags 1417 -( cd $(SRCDIR); util/ctags.sh ) 1418 -etags `find . -name '*.[ch]' -o -name '*.pm'` 1419 1420providers/fips.checksum.new: providers/fips.module.sources.new 1421 @which unifdef > /dev/null || \ 1422 ( echo >&2 "ERROR: unifdef not in your \$$PATH, FIPS checksums not calculated"; \ 1423 false ) 1424 ( sources=`pwd`/providers/fips.module.sources.new; \ 1425 cd $(SRCDIR) \ 1426 && cat $$sources \ 1427 | xargs ./util/fips-checksums.sh ) \ 1428 > providers/fips-sources.checksums.new \ 1429 && sha256sum providers/fips-sources.checksums.new \ 1430 | sed -e 's|\.new||' > providers/fips.checksum.new 1431 1432fips-checksums: providers/fips.checksum.new 1433 1434$(SRCDIR)/providers/fips.checksum: providers/fips.checksum.new 1435 cp -p providers/fips.module.sources.new $(SRCDIR)/providers/fips.module.sources 1436 cp -p providers/fips-sources.checksums.new $(SRCDIR)/providers/fips-sources.checksums 1437 cp -p providers/fips.checksum.new $(SRCDIR)/providers/fips.checksum 1438 1439update-fips-checksums: $(SRCDIR)/providers/fips.checksum 1440 1441diff-fips-checksums: fips-checksums 1442 diff -u $(SRCDIR)/providers/fips.module.sources providers/fips.module.sources.new 1443 diff -u $(SRCDIR)/providers/fips-sources.checksums providers/fips-sources.checksums.new 1444 diff -u $(SRCDIR)/providers/fips.checksum providers/fips.checksum.new 1445 1446# Release targets (note: only available on Unix) ##################### 1447 1448tar: 1449 (cd $(SRCDIR); ./util/mktar.sh --name='$(NAME)' --tarfile='$(TARFILE)') 1450 1451# Helper targets ##################################################### 1452 1453link-utils: $(BLDDIR)/util/opensslwrap.sh $(BLDDIR)/apps/openssl.cnf 1454 1455$(BLDDIR)/util/opensslwrap.sh: Makefile 1456 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \ 1457 mkdir -p "$(BLDDIR)/util"; \ 1458 ln -sf "../$(SRCDIR)/util/`basename "$@"`" "$(BLDDIR)/util"; \ 1459 fi 1460 1461$(BLDDIR)/apps/openssl.cnf: Makefile 1462 @if [ "$(SRCDIR)" != "$(BLDDIR)" ]; then \ 1463 mkdir -p "$(BLDDIR)/apps"; \ 1464 ln -sf "../$(SRCDIR)/apps/`basename "$@"`" "$(BLDDIR)/apps"; \ 1465 fi 1466 1467FORCE: 1468 1469# Building targets ################################################### 1470 1471Makefile: configdata.pm \ 1472 {- join(" \\\n" . ' ' x 10, 1473 fill_lines(" ", $COLUMNS - 10, 1474 @{$config{build_file_templates}})) -} 1475 @echo "Detected changed: $?" 1476 $(PERL) configdata.pm 1477 @echo "**************************************************" 1478 @echo "*** ***" 1479 @echo "*** Please run the same make command again ***" 1480 @echo "*** ***" 1481 @echo "**************************************************" 1482 @false 1483 1484configdata.pm: $(SRCDIR)/Configure $(SRCDIR)/config \ 1485 {- join(" \\\n" . ' ' x 15, 1486 fill_lines(" ", $COLUMNS - 15, 1487 @{$config{build_infos}}, 1488 @{$config{conf_files}})) -} 1489 @echo "Detected changed: $?" 1490 $(PERL) configdata.pm -r 1491 @echo "**************************************************" 1492 @echo "*** ***" 1493 @echo "*** Please run the same make command again ***" 1494 @echo "*** ***" 1495 @echo "**************************************************" 1496 @false 1497 1498reconfigure reconf: 1499 $(PERL) configdata.pm -r 1500 1501{- 1502 use File::Basename; 1503 use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/; 1504 1505 # Helper function to convert dependencies in platform agnostic form to 1506 # dependencies in platform form. 1507 sub compute_platform_depends { 1508 map { my $x = $_; 1509 1510 grep { $x eq $_ } @{$unified_info{programs}} and platform->bin($x) 1511 or grep { $x eq $_ } @{$unified_info{modules}} and platform->dso($x) 1512 or grep { $x eq $_ } @{$unified_info{libraries}} and platform->lib($x) 1513 or platform->convertext($x); } @_; 1514 } 1515 1516 # Helper function to figure out dependencies on libraries 1517 # It takes a list of library names and outputs a list of dependencies 1518 sub compute_lib_depends { 1519 # Depending on shared libraries: 1520 # On Windows POSIX layers, we depend on {libname}.dll.a 1521 # On Unix platforms, we depend on {shlibname}.so 1522 return map { platform->sharedlib_simple($_) 1523 // platform->sharedlib_import($_) 1524 // platform->sharedlib($_) 1525 // platform->staticlib($_) 1526 } @_; 1527 } 1528 1529 sub generatetarget { 1530 my %args = @_; 1531 my $deps = join(" ", compute_platform_depends(@{$args{deps}})); 1532 return <<"EOF"; 1533$args{target}: $deps 1534EOF 1535 } 1536 1537 sub generatesrc { 1538 my %args = @_; 1539 my $gen0 = $args{generator}->[0]; 1540 my $gen_args = join('', map { " $_" } 1541 @{$args{generator}}[1..$#{$args{generator}}]); 1542 my $gen_incs = join("", map { " -I".$_ } @{$args{generator_incs}}); 1543 my $incs = join("", map { " -I".$_ } @{$args{incs}}); 1544 my $defs = join("", map { " -D".$_ } @{$args{defs}}); 1545 my $deps = join(" ", compute_platform_depends(@{$args{generator_deps}}, 1546 @{$args{deps}})); 1547 1548 if ($args{src} =~ /\.html$/) { 1549 # 1550 # HTML generator 1551 # 1552 my $title = basename($args{src}, ".html"); 1553 my $pod = $gen0; 1554 return <<"EOF"; 1555$args{src}: $pod 1556 \$(PERL) \$(SRCDIR)/util/mkpod2html.pl -i "$pod" -o \$\@ -t "$title" -r "\$(SRCDIR)/doc" 1557EOF 1558 } elsif ($args{src} =~ /\.(\d)$/) { 1559 # 1560 # Man-page generator 1561 # 1562 my $section = $1; 1563 my $name = uc basename($args{src}, ".$section"); 1564 my $pod = $gen0; 1565 return <<"EOF"; 1566$args{src}: $pod 1567 pod2man --name=$name --section=$section\$(MANSUFFIX) --center=OpenSSL \\ 1568 --release=\$(VERSION) $pod >\$\@ 1569EOF 1570 } elsif (platform->isdef($args{src})) { 1571 # 1572 # Linker script-ish generator 1573 # 1574 my $target = platform->def($args{src}); 1575 (my $mkdef_os = $target{shared_target}) =~ s|-shared$||; 1576 my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION_NUMBER)' : ''; 1577 my $ord_name = $args{generator}->[1] || $args{product}; 1578 return <<"EOF"; 1579$target: $gen0 $deps \$(SRCDIR)/util/mkdef.pl 1580 \$(PERL) \$(SRCDIR)/util/mkdef.pl$ord_ver --type $args{intent} --ordinals $gen0 --name $ord_name --OS $mkdef_os > $target 1581EOF 1582 } elsif (platform->isasm($args{src}) 1583 || platform->iscppasm($args{src})) { 1584 # 1585 # Assembler generator 1586 # 1587 my $cppflags = { 1588 shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)', 1589 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)', 1590 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)', 1591 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)' 1592 } -> {$args{intent}}; 1593 1594 my $generator; 1595 if ($gen0 =~ /\.pl$/) { 1596 $generator = 'CC="$(CC)" $(PERL)'.$gen_incs.' '.$gen0.$gen_args 1597 .' "$(PERLASM_SCHEME)"'.$incs.' '.$cppflags.$defs.' $(PROCESSOR)'; 1598 } elsif ($gen0 =~ /\.m4$/) { 1599 $generator = 'm4 -B 8192'.$gen_incs.' '.$gen0.$gen_args.' >' 1600 } elsif ($gen0 =~ /\.S$/) { 1601 $generator = undef; 1602 } else { 1603 die "Generator type for $args{src} unknown: $gen0\n"; 1604 } 1605 1606 if (defined($generator)) { 1607 return <<"EOF"; 1608$args{src}: $gen0 $deps 1609 $generator \$@ 1610EOF 1611 } 1612 return <<"EOF"; 1613$args{src}: $gen0 $deps 1614 \$(CC) $incs $cppflags $defs -E $gen0 | \\ 1615 \$(PERL) -ne '/^#(line)?\\s*[0-9]+/ or print' > \$@ 1616EOF 1617 } elsif ($gen0 =~ m|^.*\.in$|) { 1618 # 1619 # "dofile" generator (file.in -> file) 1620 # 1621 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, 1622 "util", "dofile.pl")), 1623 rel2abs($config{builddir})); 1624 my @perlmodules = (); 1625 my %perlmoduleincs = (); 1626 my %perlmoduledeps = (); 1627 foreach my $x (('configdata.pm', @{$args{deps}})) { 1628 # Compute (i)nclusion directory, (m)odule name and (d)ependency 1629 my $i, $m, $d; 1630 if ($x =~ /\|/) { 1631 $i = $`; 1632 $d = $'; 1633 1634 # Massage the module part to become a real perl module spec 1635 $m = $d; 1636 $m =~ s|\.pm$||; 1637 # Directory specs are :: in perl package names 1638 $m =~ s|/|::|g; 1639 1640 # Full file name of the dependency 1641 $d = catfile($i, $d) if $i; 1642 } elsif ($x =~ /\.pm$/) { 1643 $i = dirname($x); 1644 $m = basename($x, '.pm'); 1645 $d = $x; 1646 } else { 1647 # All other dependencies are simply collected 1648 $d = $x; 1649 } 1650 push @perlmodules, '"-M'.$m.'"' if $m; 1651 $perlmoduledeps{$d} = 1; 1652 $perlmoduleincs{'"-I'.$i.'"'} = 1 if $i; 1653 } 1654 1655 # Because of the special treatment of dependencies, we need to 1656 # recompute $deps completely 1657 my $deps 1658 = join(" ", compute_platform_depends(@{$args{generator_deps}}, 1659 sort keys %perlmoduledeps)); 1660 my $perlmodules = join(' ', '', ( sort keys %perlmoduleincs ), @perlmodules); 1661 1662 return <<"EOF"; 1663$args{src}: $gen0 $deps 1664 \$(PERL)$perlmodules "$dofile" "-o$target{build_file}" $gen0$gen_args > \$@ 1665EOF 1666 } elsif (grep { $_ eq $gen0 } @{$unified_info{programs}}) { 1667 # 1668 # Generic generator using OpenSSL programs 1669 # 1670 1671 # Redo $gen0, to ensure that we have the proper extension where 1672 # necessary. 1673 $gen0 = platform->bin($gen0); 1674 # Use $(PERL) to execute wrap.pl directly to avoid calling env 1675 return <<"EOF"; 1676$args{src}: $gen0 $deps \$(BLDDIR)/util/wrap.pl 1677 \$(PERL) \$(BLDDIR)/util/wrap.pl $gen0$gen_args > \$@ 1678EOF 1679 } else { 1680 # 1681 # Generic generator using Perl 1682 # 1683 return <<"EOF"; 1684$args{src}: $gen0 $deps 1685 \$(PERL)$gen_incs $gen0$gen_args > \$@ 1686EOF 1687 } 1688 } 1689 1690 # Should one wonder about the end of the Perl snippet, it's because this 1691 # second regexp eats up line endings as well, if the removed path is the 1692 # last in the line. We may therefore need to put back a line ending. 1693 sub src2obj { 1694 my %args = @_; 1695 my $obj = platform->convertext($args{obj}); 1696 my $dep = platform->dep($args{obj}); 1697 my @srcs = @{$args{srcs}}; 1698 my $srcs = join(" ", @srcs); 1699 my $deps = join(" ", @srcs, @{$args{deps}}); 1700 my $incs = join("", map { " -I".$_ } @{$args{incs}}); 1701 my $defs = join("", map { " -D".$_ } @{$args{defs}}); 1702 my $cmd; 1703 my $cmdflags; 1704 my $cmdcompile; 1705 if (grep /\.rc$/, @srcs) { 1706 $cmd = '$(RC)'; 1707 $cmdflags = '$(RCFLAGS)'; 1708 $cmdcompile = ''; 1709 } elsif (grep /\.(cc|cpp)$/, @srcs) { 1710 $cmd = '$(CXX)'; 1711 $cmdcompile = ' -c'; 1712 $cmdflags = { 1713 shlib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)', 1714 lib => '$(LIB_CXXFLAGS) $(LIB_CPPFLAGS)', 1715 dso => '$(DSO_CXXFLAGS) $(DSO_CPPFLAGS)', 1716 bin => '$(BIN_CXXFLAGS) $(BIN_CPPFLAGS)' 1717 } -> {$args{intent}}; 1718 } else { 1719 $cmd = '$(CC)'; 1720 $cmdcompile = ' -c'; 1721 $cmdflags = { 1722 shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)', 1723 lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)', 1724 dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)', 1725 bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)' 1726 } -> {$args{intent}}; 1727 } 1728 my $recipe; 1729 # extension-specific rules 1730 if (grep /\.s$/, @srcs) { 1731 $recipe .= <<"EOF"; 1732$obj: $deps 1733 $cmd $cmdflags -c -o \$\@ $srcs 1734EOF 1735 } elsif (grep /\.S$/, @srcs) { 1736 # Originally there was multi-step rule with $(CC) -E file.S 1737 # followed by $(CC) -c file.s. It compensated for one of 1738 # legacy platform compiler's inability to handle .S files. 1739 # The platform is long discontinued by vendor so there is 1740 # hardly a point to drag it along... 1741 $recipe .= <<"EOF"; 1742$obj: $deps 1743 $cmd $incs $defs $cmdflags -c -o \$\@ $srcs 1744EOF 1745 } elsif ($makedep_scheme eq 'gcc' && !grep /\.rc$/, @srcs) { 1746 $recipe .= <<"EOF"; 1747$obj: $deps 1748 $cmd $incs $defs $cmdflags -MMD -MF $dep.tmp -c -o \$\@ $srcs 1749 \@touch $dep.tmp 1750 \@if cmp $dep.tmp $dep > /dev/null 2> /dev/null; then \\ 1751 rm -f $dep.tmp; \\ 1752 else \\ 1753 mv $dep.tmp $dep; \\ 1754 fi 1755EOF 1756 } else { 1757 $recipe .= <<"EOF"; 1758$obj: $deps 1759 $cmd $incs $defs $cmdflags $cmdcompile -o \$\@ $srcs 1760EOF 1761 if ($makedep_scheme eq 'makedepend') { 1762 $recipe .= <<"EOF"; 1763 \$(MAKEDEPEND) -f- -Y -- $incs $cmdflags -- $srcs 2>/dev/null \\ 1764 > $dep 1765EOF 1766 } 1767 } 1768 return $recipe; 1769 } 1770 # We *know* this routine is only called when we've configure 'shared'. 1771 sub obj2shlib { 1772 my %args = @_; 1773 my @linkdirs = (); 1774 my @linklibs = (); 1775 foreach (@{$args{deps}}) { 1776 if (platform->isstaticlib($_)) { 1777 push @linklibs, platform->convertext($_); 1778 } else { 1779 my $d = "-L" . dirname($_); 1780 my $l = basename($_); 1781 $l =~ s/^lib//; 1782 $l = "-l" . $l; 1783 push @linklibs, $l; 1784 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs; 1785 } 1786 } 1787 my $linkflags = join("", map { $_." " } @linkdirs); 1788 my $linklibs = join("", map { $_." " } @linklibs); 1789 my @objs = map { platform->convertext($_) } 1790 grep { !platform->isdef($_) } 1791 @{$args{objs}}; 1792 my @defs = map { platform->def($_) } 1793 grep { platform->isdef($_) } 1794 @{$args{objs}}; 1795 my @deps = compute_lib_depends(@{$args{deps}}); 1796 die "More than one exported symbol map" if scalar @defs > 1; 1797 1798 my $full = platform->sharedlib($args{lib}); 1799 # $import is for Windows and subsystems thereof, where static import 1800 # libraries for DLLs are a thing. On platforms that have this mechanism, 1801 # $import has the name of this import library. On platforms that don't 1802 # have this mechanism, $import will be |undef|. 1803 # It's also used on AIX in solib mode, which creates import libraries 1804 # for the shared libraries. 1805 my $import = platform->sharedlib_import($args{lib}); 1806 # $simple is for platforms where full shared library names include the 1807 # shared library version, and there's a simpler name that doesn't include 1808 # that version. On such platforms, $simple has the simpler name. On 1809 # other platforms, it will be |undef|. 1810 my $simple = platform->sharedlib_simple($args{lib}); 1811 1812 my $argfile = defined $target{shared_argfileflag} ? $full.".args" : undef; 1813 my $shared_soname = ""; 1814 $shared_soname .= ' '.$target{shared_sonameflag}.basename($full) 1815 if defined $target{shared_sonameflag}; 1816 my $shared_imp = ""; 1817 $shared_imp .= ' '.$target{shared_impflag}.basename($import) 1818 if defined $target{shared_impflag} && defined $import; 1819 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs); 1820 1821 # There is at least one platform where the compiler-as-linker needs to 1822 # have one object file directly on the command line. That won't hurt 1823 # any other platform, so we do that for everyone when there's an argfile 1824 # to be had. This depends heavily on splice, which removes elements from 1825 # the given array, and returns them so they can be captured. 1826 my @argfileobjs = $argfile 1827 ? splice(@objs, 1) 1828 : (); 1829 my $argfilecmds = $argfile 1830 ? join("\n\t", map { "echo $_ >> $argfile" } @argfileobjs) 1831 : undef; 1832 my $argfiledeps = $argfile 1833 ? join(" \\\n" . ' ' x (length($argfile) + 2), 1834 fill_lines(' ', $COLUMNS - length($full) - 2, @argfileobjs)) 1835 : undef; 1836 my @fulldeps = (@objs, ($argfile ? $argfile : ()), @defs, @deps); 1837 my @fullobjs = ( 1838 @objs, 1839 ($argfile ? $target{shared_argfileflag}.$argfile : ()) 1840 ); 1841 my $fulldeps = 1842 join(" \\\n" . ' ' x (length($full) + 2), 1843 fill_lines(' ', $COLUMNS - length($full) - 2, @fulldeps)); 1844 my $fullobjs = 1845 join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @fullobjs)); 1846 1847 my $recipe = ''; 1848 1849 if (defined $simple && $simple ne $full) { 1850 if (sharedaix()) { 1851 $recipe .= <<"EOF"; 1852$simple: $full 1853 rm -f $simple && \\ 1854 \$(AR) r $simple $full 1855EOF 1856 } else { 1857 $recipe .= <<"EOF"; 1858$simple: $full 1859 rm -f $simple && \\ 1860 ln -s $full $simple 1861EOF 1862 } 1863 } 1864 if (defined $import) { 1865 if (sharedaix_solib()) { 1866 $recipe .= <<"EOF"; 1867$import: $full $defs[0] 1868 rm -f $import && \\ 1869 echo \\#!$full > $import && \\ 1870 cat $defs[0] >>$import 1871EOF 1872 } else { 1873 $recipe .= <<"EOF"; 1874$import: $full 1875EOF 1876 } 1877 } 1878 $recipe .= <<"EOF"; 1879$full: $fulldeps 1880 \$(CC) \$(LIB_CFLAGS) $linkflags\$(LIB_LDFLAGS)$shared_soname$shared_imp \\ 1881 -o $full$shared_def \\ 1882 $fullobjs \\ 1883 $linklibs \$(LIB_EX_LIBS) 1884EOF 1885 if (windowsdll()) { 1886 $recipe .= <<"EOF"; 1887 rm -f apps/$full 1888 rm -f fuzz/$full 1889 cp -p $full apps/ 1890 cp -p $full fuzz/ 1891EOF 1892 if (!$disabled{tests}) { 1893 $recipe .= <<"EOF"; 1894 rm -f test/$full 1895 cp -p $full test/ 1896EOF 1897 } 1898 } 1899 $recipe .= <<"EOF" if defined $argfile; 1900$argfile: $argfiledeps 1901 \$(RM) $argfile 1902 $argfilecmds 1903EOF 1904 return $recipe; 1905 } 1906 sub obj2dso { 1907 my %args = @_; 1908 my $dso = platform->dso($args{module}); 1909 my @linkdirs = (); 1910 my @linklibs = (); 1911 foreach (@{$args{deps}}) { 1912 next unless defined $_; 1913 if (platform->isstaticlib($_)) { 1914 push @linklibs, platform->convertext($_); 1915 } else { 1916 my $d = "-L" . dirname($_); 1917 my $l = basename($_); 1918 $l =~ s/^lib//; 1919 $l = "-l" . $l; 1920 push @linklibs, $l; 1921 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs; 1922 } 1923 } 1924 my $linkflags = join("", map { $_." " } @linkdirs); 1925 my $linklibs = join("", map { $_." " } @linklibs); 1926 my @objs = map { platform->convertext($_) } 1927 grep { !platform->isdef($_) } 1928 @{$args{objs}}; 1929 my @defs = map { platform->def($_) } 1930 grep { platform->isdef($_) } 1931 @{$args{objs}}; 1932 my @deps = compute_lib_depends(@{$args{deps}}); 1933 my $shared_def = join("", map { ' '.$target{shared_defflag}.$_ } @defs); 1934 # Next line needs to become "less magic" (see PR #11950) 1935 $shared_def .= ' '.$target{shared_fipsflag} if (defined $target{shared_fipsflag} && $shared_def =~ m/providers\/fips/); 1936 my $objs = join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @objs)); 1937 my $deps = join(" \\\n" . ' ' x (length($dso) + 2), 1938 fill_lines(' ', $COLUMNS - length($dso) - 2, 1939 @objs, @defs, @deps)); 1940 1941 return <<"EOF"; 1942$dso: $deps 1943 \$(CC) \$(DSO_CFLAGS) $linkflags\$(DSO_LDFLAGS) \\ 1944 -o $dso$shared_def \\ 1945 $objs \\ 1946 $linklibs\$(DSO_EX_LIBS) 1947EOF 1948 } 1949 sub obj2lib { 1950 my %args = @_; 1951 my $lib = platform->staticlib($args{lib}); 1952 my @objs = map { platform->obj($_) } @{$args{objs}}; 1953 my $deps = join(" \\\n" . ' ' x (length($lib) + 2), 1954 fill_lines(' ', $COLUMNS - length($lib) - 2, @objs)); 1955 my $max_per_call = 500; 1956 my @objs_grouped; 1957 push @objs_grouped, join(" ", splice @objs, 0, $max_per_call) while @objs; 1958 my $fill_lib = 1959 join("\n\t", (map { "\$(AR) \$(ARFLAGS) $lib $_" } @objs_grouped)); 1960 return <<"EOF"; 1961$lib: $deps 1962 \$(RM) $lib 1963 $fill_lib 1964 \$(RANLIB) \$\@ || echo Never mind. 1965EOF 1966 } 1967 sub obj2bin { 1968 my %args = @_; 1969 my $bin = platform->bin($args{bin}); 1970 my @objs = map { platform->obj($_) } @{$args{objs}}; 1971 my @deps = compute_lib_depends(@{$args{deps}}); 1972 my $objs = join(" \\\n" . ' ' x (length($bin) + 2), 1973 fill_lines(' ', $COLUMNS - length($bin) - 2, @objs)); 1974 my @linkdirs = (); 1975 my @linklibs = (); 1976 foreach (@{$args{deps}}) { 1977 next unless defined $_; 1978 if (platform->isstaticlib($_)) { 1979 push @linklibs, platform->convertext($_); 1980 } else { 1981 my $d = "-L" . dirname($_); 1982 my $l = basename($_); 1983 $l =~ s/^lib//; 1984 $l = "-l" . $l; 1985 push @linklibs, $l; 1986 push @linkdirs, $d unless grep { $d eq $_ } @linkdirs; 1987 } 1988 } 1989 my $linkflags = join("", map { $_." " } @linkdirs); 1990 my $linklibs = join("", map { $_." " } @linklibs); 1991 my $cmd = '$(CC)'; 1992 my $cmdflags = '$(BIN_CFLAGS)'; 1993 if (grep /_cc\.o$/, @{$args{objs}}) { 1994 $cmd = '$(CXX)'; 1995 $cmdflags = '$(BIN_CXXFLAGS)'; 1996 } 1997 1998 my $objs = join(" \\\n\t\t", fill_lines(' ', $COLUMNS - 16, @objs)); 1999 my $deps = join(" \\\n" . ' ' x (length($bin) + 2), 2000 fill_lines(' ', $COLUMNS - length($bin) - 2, 2001 @objs, @deps)); 2002 2003 return <<"EOF"; 2004$bin: $deps 2005 rm -f $bin 2006 \$\${LDCMD:-$cmd} $cmdflags $linkflags\$(BIN_LDFLAGS) \\ 2007 -o $bin \\ 2008 $objs \\ 2009 $linklibs\$(BIN_EX_LIBS) 2010EOF 2011 } 2012 sub in2script { 2013 my %args = @_; 2014 my $script = $args{script}; 2015 my $sources = join(" ", @{$args{sources}}); 2016 my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, 2017 "util", "dofile.pl")), 2018 rel2abs($config{builddir})); 2019 return <<"EOF"; 2020$script: $sources configdata.pm 2021 \$(RM) "$script" 2022 \$(PERL) "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\ 2023 "-o$target{build_file}" $sources > "$script" 2024 chmod a+x $script 2025EOF 2026 } 2027 sub generatedir { 2028 my %args = @_; 2029 my $dir = $args{dir}; 2030 my @deps = compute_platform_depends(@{$args{deps}}); 2031 my @comments = (); 2032 2033 # We already have a 'test' target, and the top directory is just plain 2034 # silly 2035 return if $dir eq "test" || $dir eq "."; 2036 2037 foreach my $type (("dso", "lib", "bin", "script")) { 2038 next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type}); 2039 # For lib object files, we could update the library. However, it 2040 # was decided that it's enough to build the directory local object 2041 # files, so we don't need to add any actions, and the dependencies 2042 # are already taken care of. 2043 if ($type ne "lib") { 2044 foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) { 2045 if (dirname($prod) eq $dir) { 2046 push @deps, compute_platform_depends($prod); 2047 } else { 2048 push @comments, "# No support to produce $type ".join(", ", @{$unified_info{dirinfo}->{$dir}->{products}->{$type}}); 2049 } 2050 } 2051 } 2052 } 2053 2054 my $target = "$dir $dir/"; 2055 my $deps = join(" \\\n\t", 2056 fill_lines(' ', $COLUMNS - 8, @deps)); 2057 my $comments = join("\n", "", @comments); 2058 return <<"EOF"; 2059$target: \\ 2060 $deps$comments 2061EOF 2062 } 2063 "" # Important! This becomes part of the template result. 2064-} 2065