lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | ## |
| 2 | ## Makefile for OpenSSL |
| 3 | ## |
| 4 | ## {- join("\n## ", @autowarntext) -} |
| 5 | {- |
| 6 | our $objext = $target{obj_extension} || ".obj"; |
| 7 | our $resext = $target{res_extension} || ".res"; |
| 8 | our $depext = $target{dep_extension} || ".d"; |
| 9 | our $exeext = $target{exe_extension} || ".exe"; |
| 10 | our $libext = $target{lib_extension} || ".lib"; |
| 11 | our $shlibext = $target{shared_extension} || ".dll"; |
lh | 758261d | 2023-07-13 05:52:04 -0700 | [diff] [blame^] | 12 | our $shlibvariant = $target{shlib_variant} || ""; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 13 | our $shlibextimport = $target{shared_import_extension} || ".lib"; |
| 14 | our $dsoext = $target{dso_extension} || ".dll"; |
| 15 | |
| 16 | (our $sover_dirname = $config{shlib_version_number}) =~ s|\.|_|g; |
| 17 | |
| 18 | my $build_scheme = $target{build_scheme}; |
| 19 | my $install_flavour = $build_scheme->[$#$build_scheme]; # last element |
| 20 | my $win_installenv = |
| 21 | $install_flavour eq "VC-WOW" ? "ProgramFiles(x86)" |
| 22 | : "ProgramW6432"; |
| 23 | my $win_commonenv = |
| 24 | $install_flavour eq "VC-WOW" ? "CommonProgramFiles(x86)" |
| 25 | : "CommonProgramW6432"; |
| 26 | our $win_installroot = |
| 27 | defined($ENV{$win_installenv}) ? $win_installenv : 'ProgramFiles'; |
| 28 | our $win_commonroot = |
| 29 | defined($ENV{$win_commonenv}) ? $win_commonenv : 'CommonProgramFiles'; |
| 30 | |
| 31 | # expand variables early |
| 32 | $win_installroot = $ENV{$win_installroot}; |
| 33 | $win_commonroot = $ENV{$win_commonroot}; |
| 34 | |
| 35 | sub shlib { |
| 36 | my $lib = shift; |
| 37 | return () if $disabled{shared} || $lib =~ /\.a$/; |
| 38 | return () unless defined $unified_info{sharednames}->{$lib}; |
lh | 758261d | 2023-07-13 05:52:04 -0700 | [diff] [blame^] | 39 | return $unified_info{sharednames}->{$lib} . $shlibvariant . $shlibext; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | sub lib { |
| 43 | (my $lib = shift) =~ s/\.a$//; |
| 44 | $lib .= '_static' |
| 45 | if (defined $unified_info{sharednames}->{$lib}); |
| 46 | return $lib . $libext; |
| 47 | } |
| 48 | |
| 49 | sub shlib_import { |
| 50 | my $lib = shift; |
| 51 | return () if $disabled{shared} || $lib =~ /\.a$/; |
| 52 | return $lib . $shlibextimport; |
| 53 | } |
| 54 | |
| 55 | sub dso { |
| 56 | my $dso = shift; |
| 57 | |
| 58 | return $dso . $dsoext; |
| 59 | } |
| 60 | # This makes sure things get built in the order they need |
| 61 | # to. You're welcome. |
| 62 | sub dependmagic { |
| 63 | my $target = shift; |
| 64 | |
| 65 | return "$target: build_generated\n\t\$(MAKE) /\$(MAKEFLAGS) depend && \$(MAKE) /\$(MAKEFLAGS) _$target\n_$target"; |
| 66 | } |
| 67 | ''; |
| 68 | -} |
| 69 | |
| 70 | PLATFORM={- $config{target} -} |
| 71 | SRCDIR={- $config{sourcedir} -} |
| 72 | BLDDIR={- $config{builddir} -} |
| 73 | |
| 74 | VERSION={- $config{version} -} |
| 75 | MAJOR={- $config{major} -} |
| 76 | MINOR={- $config{minor} -} |
| 77 | |
| 78 | SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -} |
| 79 | |
| 80 | LIBS={- join(" ", map { ( shlib_import($_), lib($_) ) } @{$unified_info{libraries}}) -} |
| 81 | SHLIBS={- join(" ", map { shlib($_) } @{$unified_info{libraries}}) -} |
| 82 | SHLIBPDBS={- join(" ", map { local $shlibext = ".pdb"; shlib($_) } @{$unified_info{libraries}}) -} |
| 83 | ENGINES={- join(" ", map { dso($_) } @{$unified_info{engines}}) -} |
| 84 | ENGINEPDBS={- join(" ", map { local $dsoext = ".pdb"; dso($_) } @{$unified_info{engines}}) -} |
| 85 | PROGRAMS={- our @PROGRAMS = map { $_.$exeext } @{$unified_info{programs}}; join(" ", @PROGRAMS) -} |
| 86 | PROGRAMPDBS={- join(" ", map { $_.".pdb" } @{$unified_info{programs}}) -} |
| 87 | SCRIPTS={- join(" ", @{$unified_info{scripts}}) -} |
| 88 | {- output_off() if $disabled{makedepend}; "" -} |
| 89 | DEPS={- join(" ", map { (my $x = $_) =~ s|\.o$|$depext|; $x; } |
| 90 | grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ } |
| 91 | keys %{$unified_info{sources}}); -} |
| 92 | {- output_on() if $disabled{makedepend}; "" -} |
| 93 | GENERATED_MANDATORY={- join(" ", @{$unified_info{depends}->{""}} ) -} |
| 94 | GENERATED={- # common0.tmpl provides @generated |
| 95 | join(" ", map { (my $x = $_) =~ s|\.[sS]$|.asm|; $x } |
| 96 | @generated) -} |
| 97 | |
| 98 | INSTALL_LIBS={- join(" ", map { quotify1(shlib_import($_) or lib($_)) } @{$unified_info{install}->{libraries}}) -} |
| 99 | INSTALL_SHLIBS={- join(" ", map { quotify_l(shlib($_)) } @{$unified_info{install}->{libraries}}) -} |
| 100 | INSTALL_SHLIBPDBS={- join(" ", map { local $shlibext = ".pdb"; quotify_l(shlib($_)) } @{$unified_info{install}->{libraries}}) -} |
| 101 | INSTALL_ENGINES={- join(" ", map { quotify1(dso($_)) } @{$unified_info{install}->{engines}}) -} |
| 102 | INSTALL_ENGINEPDBS={- join(" ", map { local $dsoext = ".pdb"; quotify1(dso($_)) } @{$unified_info{install}->{engines}}) -} |
| 103 | INSTALL_PROGRAMS={- join(" ", map { quotify1($_.$exeext) } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -} |
| 104 | INSTALL_PROGRAMPDBS={- join(" ", map { quotify1($_.".pdb") } grep { !m|^test\\| } @{$unified_info{install}->{programs}}) -} |
| 105 | {- output_off() if $disabled{apps}; "" -} |
| 106 | BIN_SCRIPTS="$(BLDDIR)\tools\c_rehash.pl" |
| 107 | MISC_SCRIPTS="$(BLDDIR)\apps\CA.pl" "$(BLDDIR)\apps\tsget.pl" |
| 108 | {- output_on() if $disabled{apps}; "" -} |
| 109 | |
| 110 | APPS_OPENSSL={- use File::Spec::Functions; |
| 111 | "\"".catfile("apps","openssl")."\"" -} |
| 112 | |
| 113 | # Do not edit these manually. Use Configure with --prefix or --openssldir |
| 114 | # to change this! Short explanation in the top comment in Configure |
| 115 | INSTALLTOP_dev={- # $prefix is used in the OPENSSLDIR perl snippet |
| 116 | # |
| 117 | use File::Spec::Functions qw(:DEFAULT splitpath); |
| 118 | our $prefix = canonpath($config{prefix} |
| 119 | || "$win_installroot\\OpenSSL"); |
| 120 | our ($prefix_dev, $prefix_dir, $prefix_file) = |
| 121 | splitpath($prefix, 1); |
| 122 | $prefix_dev -} |
| 123 | INSTALLTOP_dir={- canonpath($prefix_dir) -} |
| 124 | OPENSSLDIR_dev={- # |
| 125 | # The logic here is that if no --openssldir was given, |
| 126 | # OPENSSLDIR will get the value "$win_commonroot\\SSL". |
| 127 | # If --openssldir was given and the value is an absolute |
| 128 | # path, OPENSSLDIR will get its value without change. |
| 129 | # If the value from --openssldir is a relative path, |
| 130 | # OPENSSLDIR will get $prefix with the --openssldir |
| 131 | # value appended as a subdirectory. |
| 132 | # |
| 133 | use File::Spec::Functions qw(:DEFAULT splitpath); |
| 134 | our $openssldir = |
| 135 | $config{openssldir} ? |
| 136 | (file_name_is_absolute($config{openssldir}) ? |
| 137 | canonpath($config{openssldir}) |
| 138 | : catdir($prefix, $config{openssldir})) |
| 139 | : canonpath("$win_commonroot\\SSL"); |
| 140 | our ($openssldir_dev, $openssldir_dir, $openssldir_file) = |
| 141 | splitpath($openssldir, 1); |
| 142 | $openssldir_dev -} |
| 143 | OPENSSLDIR_dir={- canonpath($openssldir_dir) -} |
| 144 | LIBDIR={- our $libdir = $config{libdir} || "lib"; |
| 145 | file_name_is_absolute($libdir) ? "" : $libdir -} |
| 146 | ENGINESDIR_dev={- use File::Spec::Functions qw(:DEFAULT splitpath); |
| 147 | our $enginesdir = catdir($prefix,$libdir,"engines-$sover_dirname"); |
| 148 | our ($enginesdir_dev, $enginesdir_dir, $enginesdir_file) = |
| 149 | splitpath($enginesdir, 1); |
| 150 | $enginesdir_dev -} |
| 151 | ENGINESDIR_dir={- canonpath($enginesdir_dir) -} |
| 152 | !IF "$(DESTDIR)" != "" |
| 153 | INSTALLTOP=$(DESTDIR)$(INSTALLTOP_dir) |
| 154 | OPENSSLDIR=$(DESTDIR)$(OPENSSLDIR_dir) |
| 155 | ENGINESDIR=$(DESTDIR)$(ENGINESDIR_dir) |
| 156 | !ELSE |
| 157 | INSTALLTOP=$(INSTALLTOP_dev)$(INSTALLTOP_dir) |
| 158 | OPENSSLDIR=$(OPENSSLDIR_dev)$(OPENSSLDIR_dir) |
| 159 | ENGINESDIR=$(ENGINESDIR_dev)$(ENGINESDIR_dir) |
| 160 | !ENDIF |
| 161 | |
| 162 | # $(libdir) is chosen to be compatible with the GNU coding standards |
| 163 | libdir={- file_name_is_absolute($libdir) |
| 164 | ? $libdir : '$(INSTALLTOP)\$(LIBDIR)' -} |
| 165 | |
| 166 | ##### User defined commands and flags ################################ |
| 167 | |
| 168 | CC={- $config{CC} -} |
| 169 | CPP={- $config{CPP} -} |
| 170 | CPPFLAGS={- our $cppflags1 = join(" ", |
| 171 | (map { "-D".$_} @{$config{CPPDEFINES}}), |
| 172 | (map { " /I ".$_} @{$config{CPPINCLUDES}}), |
| 173 | @{$config{CPPFLAGS}}) -} |
| 174 | CFLAGS={- join(' ', @{$config{CFLAGS}}) -} |
| 175 | LD={- $config{LD} -} |
| 176 | LDFLAGS={- join(' ', @{$config{LDFLAGS}}) -} |
| 177 | EX_LIBS={- join(' ', @{$config{LDLIBS}}) -} |
| 178 | |
| 179 | PERL={- $config{PERL} -} |
| 180 | |
| 181 | AR={- $config{AR} -} |
| 182 | ARFLAGS= {- join(' ', @{$config{ARFLAGS}}) -} |
| 183 | |
| 184 | MT={- $config{MT} -} |
| 185 | MTFLAGS= {- join(' ', @{$config{MTFLAGS}}) -} |
| 186 | |
| 187 | AS={- $config{AS} -} |
| 188 | ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -} |
| 189 | |
| 190 | RC={- $config{RC} -} |
| 191 | RCFLAGS={- join(' ', @{$config{RCFLAGS}}) -} |
| 192 | |
| 193 | ECHO="$(PERL)" "$(SRCDIR)\util\echo.pl" |
| 194 | |
| 195 | ##### Special command flags ########################################## |
| 196 | |
| 197 | COUTFLAG={- $target{coutflag} -}$(OSSL_EMPTY) |
| 198 | LDOUTFLAG={- $target{ldoutflag} -}$(OSSL_EMPTY) |
| 199 | AROUTFLAG={- $target{aroutflag} -}$(OSSL_EMPTY) |
| 200 | MTINFLAG={- $target{mtinflag} -}$(OSSL_EMPTY) |
| 201 | MTOUTFLAG={- $target{mtoutflag} -}$(OSSL_EMPTY) |
| 202 | ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY) |
| 203 | RCOUTFLAG={- $target{rcoutflag} -}$(OSSL_EMPTY) |
| 204 | |
| 205 | ##### Project flags ################################################## |
| 206 | |
| 207 | # Variables starting with CNF_ are common variables for all product types |
| 208 | |
| 209 | CNF_ASFLAGS={- join(' ', $target{asflags} || (), |
| 210 | @{$config{asflags}}) -} |
| 211 | CNF_CPPFLAGS={- our $cppfags2 = |
| 212 | join(' ', $target{cppflags} || (), |
| 213 | (map { '-D'.quotify1($_) } @{$target{defines}}, |
| 214 | @{$config{defines}}), |
| 215 | (map { '-I'.'"'.$_.'"' } @{$target{includes}}, |
| 216 | @{$config{includes}}), |
| 217 | @{$config{cppflags}}) -} |
| 218 | CNF_CFLAGS={- join(' ', $target{cflags} || (), |
| 219 | @{$config{cflags}}) -} |
| 220 | CNF_CXXFLAGS={- join(' ', $target{cxxflags} || (), |
| 221 | @{$config{cxxflags}}) -} |
| 222 | CNF_LDFLAGS={- join(' ', $target{lflags} || (), |
| 223 | @{$config{lflags}}) -} |
| 224 | CNF_EX_LIBS={- join(' ', $target{ex_libs} || (), |
| 225 | @{$config{ex_libs}}) -} |
| 226 | |
| 227 | # Variables starting with LIB_ are used to build library object files |
| 228 | # and shared libraries. |
| 229 | # Variables starting with DSO_ are used to build DSOs and their object files. |
| 230 | # Variables starting with BIN_ are used to build programs and their object |
| 231 | # files. |
| 232 | |
| 233 | LIB_ASFLAGS={- join(' ', $target{lib_asflags} || (), |
| 234 | @{$config{lib_asflags}}, |
| 235 | '$(CNF_ASFLAGS)', '$(ASFLAGS)') -} |
| 236 | LIB_CPPFLAGS={- our $lib_cppflags = |
| 237 | join(' ', $target{lib_cppflags} || (), |
| 238 | $target{shared_cppflag} || (), |
| 239 | (map { '-D'.quotify1($_) } |
| 240 | @{$target{lib_defines}}, |
| 241 | @{$target{shared_defines}}, |
| 242 | @{$config{lib_defines}}, |
| 243 | @{$config{shared_defines}}), |
| 244 | (map { '-I'.quotify1($_) } |
| 245 | @{$target{lib_includes}}, |
| 246 | @{$target{shared_includes}}, |
| 247 | @{$config{lib_includes}}, |
| 248 | @{$config{shared_includes}}), |
| 249 | @{$config{lib_cppflags}}, |
| 250 | @{$config{shared_cppflag}}); |
| 251 | join(' ', $lib_cppflags, |
| 252 | (map { '-D'.quotify1($_) } |
| 253 | "OPENSSLDIR=\"$openssldir\"", |
| 254 | "ENGINESDIR=\"$enginesdir\""), |
| 255 | '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -} |
| 256 | LIB_CFLAGS={- join(' ', $target{lib_cflags} || (), |
| 257 | $target{shared_cflag} || (), |
| 258 | @{$config{lib_cflags}}, |
| 259 | @{$config{shared_cflag}}, |
| 260 | '$(CNF_CFLAGS)', '$(CFLAGS)') -} |
| 261 | LIB_LDFLAGS={- join(' ', $target{shared_ldflag} || (), |
| 262 | $config{shared_ldflag} || (), |
| 263 | '$(CNF_LDFLAGS)', '$(LDFLAGS)') -} |
| 264 | LIB_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS) |
| 265 | DSO_ASFLAGS={- join(' ', $target{dso_asflags} || (), |
| 266 | $target{module_asflags} || (), |
| 267 | @{$config{dso_asflags}}, |
| 268 | @{$config{module_asflags}}, |
| 269 | '$(CNF_ASFLAGS)', '$(ASFLAGS)') -} |
| 270 | DSO_CPPFLAGS={- join(' ', $target{dso_cppflags} || (), |
| 271 | $target{module_cppflags} || (), |
| 272 | @{$config{dso_cppflags}}, |
| 273 | @{$config{module_cppflags}}, |
| 274 | '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -} |
| 275 | DSO_CFLAGS={- join(' ', $target{dso_cflags} || (), |
| 276 | $target{module_cflags} || (), |
| 277 | @{$config{dso_cflags}}, |
| 278 | @{$config{module_cflags}}, |
| 279 | '$(CNF_CFLAGS)', '$(CFLAGS)') -} |
| 280 | DSO_LDFLAGS={- join(' ', $target{dso_lflags} || (), |
| 281 | $target{module_ldflags} || (), |
| 282 | @{$config{dso_lflags}}, |
| 283 | @{$config{module_ldflags}}, |
| 284 | '$(CNF_LDFLAGS)', '$(LDFLAGS)') -} |
| 285 | DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS) |
| 286 | BIN_ASFLAGS={- join(' ', $target{bin_asflags} || (), |
| 287 | @{$config{bin_asflags}}, |
| 288 | '$(CNF_ASFLAGS)', '$(ASFLAGS)') -} |
| 289 | BIN_CPPFLAGS={- join(' ', $target{bin_cppflags} || (), |
| 290 | @{$config{bin_cppflags}}, |
| 291 | '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -} |
| 292 | BIN_CFLAGS={- join(' ', $target{bin_cflags} || (), |
| 293 | @{$config{bin_cflags}}, |
| 294 | '$(CNF_CFLAGS)', '$(CFLAGS)') -} |
| 295 | BIN_LDFLAGS={- join(' ', $target{bin_lflags} || (), |
| 296 | @{$config{bin_lflags}}, |
| 297 | '$(CNF_LDFLAGS)', '$(LDFLAGS)') -} |
| 298 | BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS) |
| 299 | |
| 300 | # CPPFLAGS_Q is used for one thing only: to build up buildinf.h |
| 301 | CPPFLAGS_Q={- $cppflags1 =~ s|([\\"])|\\$1|g; |
| 302 | $cppflags2 =~ s|([\\"])|\\$1|g; |
| 303 | join(' ', $lib_cppflags || (), $cppflags2 || (), |
| 304 | $cppflags1 || ()) -} |
| 305 | |
| 306 | PERLASM_SCHEME= {- $target{perlasm_scheme} -} |
| 307 | |
| 308 | PROCESSOR= {- $config{processor} -} |
| 309 | |
| 310 | # The main targets ################################################### |
| 311 | |
| 312 | {- dependmagic('all'); -}: build_libs_nodep build_engines_nodep build_programs_nodep |
| 313 | {- dependmagic('build_libs'); -}: build_libs_nodep |
| 314 | {- dependmagic('build_engines'); -}: build_engines_nodep |
| 315 | {- dependmagic('build_programs'); -}: build_programs_nodep |
| 316 | |
| 317 | build_generated: $(GENERATED_MANDATORY) |
| 318 | build_libs_nodep: $(LIBS) {- join(" ",map { shlib_import($_) } @{$unified_info{libraries}}) -} |
| 319 | build_engines_nodep: $(ENGINES) |
| 320 | build_programs_nodep: $(PROGRAMS) $(SCRIPTS) |
| 321 | |
| 322 | # Kept around for backward compatibility |
| 323 | build_apps build_tests: build_programs |
| 324 | |
| 325 | # Convenience target to prebuild all generated files, not just the mandatory |
| 326 | # ones |
| 327 | build_all_generated: $(GENERATED_MANDATORY) $(GENERATED) |
| 328 | @{- output_off() if $disabled{makedepend}; "\@rem" -} |
| 329 | @$(ECHO) "Warning: consider configuring with no-makedepend, because if" |
| 330 | @$(ECHO) " target system doesn't have $(PERL)," |
| 331 | @$(ECHO) " then make will fail..." |
| 332 | @{- output_on() if $disabled{makedepend}; "\@rem" -} |
| 333 | |
| 334 | test: tests |
| 335 | {- dependmagic('tests'); -}: build_programs_nodep build_engines_nodep |
| 336 | @{- output_off() if $disabled{tests}; "\@rem" -} |
| 337 | -mkdir $(BLDDIR)\test\test-runs |
| 338 | set SRCTOP=$(SRCDIR) |
| 339 | set BLDTOP=$(BLDDIR) |
| 340 | set RESULT_D=$(BLDDIR)\test\test-runs |
| 341 | set PERL=$(PERL) |
| 342 | set OPENSSL_ENGINES=$(MAKEDIR)\engines |
| 343 | set OPENSSL_DEBUG_MEMORY=on |
| 344 | "$(PERL)" "$(SRCDIR)\test\run_tests.pl" $(TESTS) |
| 345 | @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "\@rem" -} |
| 346 | @$(ECHO) "Tests are not supported with your chosen Configure options" |
| 347 | @{- output_on() if !$disabled{tests}; "\@rem" -} |
| 348 | |
| 349 | list-tests: |
| 350 | @{- output_off() if $disabled{tests}; "\@rem" -} |
| 351 | @set SRCTOP=$(SRCDIR) |
| 352 | @"$(PERL)" "$(SRCDIR)\test\run_tests.pl" list |
| 353 | @{- if ($disabled{tests}) { output_on(); } else { output_off(); } "\@rem" -} |
| 354 | @$(ECHO) "Tests are not supported with your chosen Configure options" |
| 355 | @{- output_on() if !$disabled{tests}; "\@rem" -} |
| 356 | |
| 357 | install: install_sw install_ssldirs install_docs |
| 358 | |
| 359 | uninstall: uninstall_docs uninstall_sw |
| 360 | |
| 361 | libclean: |
| 362 | "$(PERL)" -e "map { m/(.*)\.dll$$/; unlink glob """{.,apps,test,fuzz}/$$1.*"""; } @ARGV" $(SHLIBS) |
| 363 | -del /Q /F $(LIBS) libcrypto.* libssl.* ossl_static.pdb |
| 364 | |
| 365 | clean: libclean |
| 366 | {- join("\n\t", map { "-del /Q /F $_" } @PROGRAMS) || "\@rem" -} |
| 367 | -del /Q /F $(ENGINES) |
| 368 | -del /Q /F $(SCRIPTS) |
| 369 | -del /Q /F $(GENERATED_MANDATORY) |
| 370 | -del /Q /F $(GENERATED) |
| 371 | -del /Q /S /F *.d *.obj *.pdb *.ilk *.manifest |
| 372 | -del /Q /S /F engines\*.lib engines\*.exp |
| 373 | -del /Q /S /F apps\*.lib apps\*.rc apps\*.res apps\*.exp |
| 374 | -del /Q /S /F test\*.exp |
| 375 | -rmdir /Q /S test\test-runs |
| 376 | |
| 377 | distclean: clean |
| 378 | -del /Q /F configdata.pm |
| 379 | -del /Q /F makefile |
| 380 | |
| 381 | depend: |
| 382 | @ {- output_off() if $disabled{makedepend}; "\@rem" -} |
| 383 | @ "$(PERL)" "$(SRCDIR)\util\add-depends.pl" "VC" |
| 384 | @ {- output_on() if $disabled{makedepend}; "\@rem" -} |
| 385 | |
| 386 | # Install helper targets ############################################# |
| 387 | |
| 388 | install_sw: install_dev install_engines install_runtime |
| 389 | |
| 390 | uninstall_sw: uninstall_runtime uninstall_engines uninstall_dev |
| 391 | |
| 392 | install_docs: install_html_docs |
| 393 | |
| 394 | uninstall_docs: uninstall_html_docs |
| 395 | |
| 396 | install_ssldirs: |
| 397 | @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\certs" |
| 398 | @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\private" |
| 399 | @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(OPENSSLDIR)\misc" |
| 400 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \ |
| 401 | "$(OPENSSLDIR)\openssl.cnf.dist" |
| 402 | @IF NOT EXIST "$(OPENSSLDIR)\openssl.cnf" \ |
| 403 | "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\openssl.cnf" \ |
| 404 | "$(OPENSSLDIR)\openssl.cnf" |
| 405 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(MISC_SCRIPTS) \ |
| 406 | "$(OPENSSLDIR)\misc" |
| 407 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \ |
| 408 | "$(OPENSSLDIR)\ct_log_list.cnf.dist" |
| 409 | @IF NOT EXIST "$(OPENSSLDIR)\ct_log_list.cnf" \ |
| 410 | "$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\apps\ct_log_list.cnf" \ |
| 411 | "$(OPENSSLDIR)\ct_log_list.cnf" |
| 412 | |
| 413 | install_dev: install_runtime_libs |
| 414 | @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 ) |
| 415 | @$(ECHO) "*** Installing development files" |
| 416 | @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\include\openssl" |
| 417 | @{- output_off() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "\@rem" -} |
| 418 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(SRCDIR)\ms\applink.c" \ |
| 419 | "$(INSTALLTOP)\include\openssl" |
| 420 | @{- output_on() unless grep { $_ eq "OPENSSL_USE_APPLINK" } (@{$target{defines}}, @{$config{defines}}); "\@rem" -} |
| 421 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" "-exclude_re=/__DECC_" \ |
| 422 | "$(SRCDIR)\include\openssl\*.h" \ |
| 423 | "$(INSTALLTOP)\include\openssl" |
| 424 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" "$(BLDDIR)\include\openssl\*.h" \ |
| 425 | "$(INSTALLTOP)\include\openssl" |
| 426 | @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(libdir)" |
| 427 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_LIBS) "$(libdir)" |
| 428 | @if "$(SHLIBS)"=="" \ |
| 429 | "$(PERL)" "$(SRCDIR)\util\copy.pl" ossl_static.pdb "$(libdir)" |
| 430 | |
| 431 | uninstall_dev: |
| 432 | |
| 433 | install_engines: install_runtime_libs build_engines |
| 434 | @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 ) |
| 435 | @$(ECHO) "*** Installing engines" |
| 436 | @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(ENGINESDIR)" |
| 437 | @if not "$(ENGINES)"=="" \ |
| 438 | "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINES) "$(ENGINESDIR)" |
| 439 | @if not "$(ENGINES)"=="" \ |
| 440 | "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_ENGINEPDBS) "$(ENGINESDIR)" |
| 441 | |
| 442 | uninstall_engines: |
| 443 | |
| 444 | install_runtime: install_programs |
| 445 | |
| 446 | install_runtime_libs: build_libs |
| 447 | @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 ) |
| 448 | @$(ECHO) "*** Installing runtime libraries" |
| 449 | @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin" |
| 450 | @if not "$(SHLIBS)"=="" \ |
| 451 | "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBS) "$(INSTALLTOP)\bin" |
| 452 | @if not "$(SHLIBS)"=="" \ |
| 453 | "$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_SHLIBPDBS) \ |
| 454 | "$(INSTALLTOP)\bin" |
| 455 | |
| 456 | install_programs: install_runtime_libs build_programs |
| 457 | @if "$(INSTALLTOP)"=="" ( $(ECHO) "INSTALLTOP should not be empty" & exit 1 ) |
| 458 | @$(ECHO) "*** Installing runtime programs" |
| 459 | @"$(PERL)" "$(SRCDIR)\util\mkdir-p.pl" "$(INSTALLTOP)\bin" |
| 460 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMS) \ |
| 461 | "$(INSTALLTOP)\bin" |
| 462 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(INSTALL_PROGRAMPDBS) \ |
| 463 | "$(INSTALLTOP)\bin" |
| 464 | @"$(PERL)" "$(SRCDIR)\util\copy.pl" $(BIN_SCRIPTS) \ |
| 465 | "$(INSTALLTOP)\bin" |
| 466 | |
| 467 | uninstall_runtime: |
| 468 | |
| 469 | install_html_docs: |
| 470 | "$(PERL)" "$(SRCDIR)\util\process_docs.pl" \ |
| 471 | "--destdir=$(INSTALLTOP)\html" --type=html |
| 472 | |
| 473 | uninstall_html_docs: |
| 474 | |
| 475 | # Building targets ################################################### |
| 476 | |
| 477 | configdata.pm: "$(SRCDIR)\Configure" {- join(" ", map { '"'.$_.'"' } @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -} |
| 478 | @$(ECHO) "Detected changed: $?" |
| 479 | "$(PERL)" configdata.pm -r |
| 480 | @$(ECHO) "**************************************************" |
| 481 | @$(ECHO) "*** ***" |
| 482 | @$(ECHO) "*** Please run the same make command again ***" |
| 483 | @$(ECHO) "*** ***" |
| 484 | @$(ECHO) "**************************************************" |
| 485 | @exit 1 |
| 486 | |
| 487 | reconfigure reconf: |
| 488 | "$(PERL)" configdata.pm -r |
| 489 | |
| 490 | {- |
| 491 | use File::Basename; |
| 492 | use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/; |
| 493 | |
| 494 | # Helper function to figure out dependencies on libraries |
| 495 | # It takes a list of library names and outputs a list of dependencies |
| 496 | sub compute_lib_depends { |
| 497 | if ($disabled{shared}) { |
| 498 | return map { lib($_) } @_; |
| 499 | } |
| 500 | return map { shlib_import($_) or lib($_) } @_; |
| 501 | } |
| 502 | |
| 503 | sub generatesrc { |
| 504 | my %args = @_; |
| 505 | (my $target = $args{src}) =~ s/\.[sS]$/.asm/; |
| 506 | my ($gen0, @gens) = @{$args{generator}}; |
| 507 | my $generator = '"'.$gen0.'"'.join('', map { " $_" } @gens); |
| 508 | my $generator_incs = join("", map { " -I \"$_\"" } @{$args{generator_incs}}); |
| 509 | my $incs = join("", map { " /I \"$_\"" } @{$args{incs}}); |
| 510 | my $deps = @{$args{deps}} ? |
| 511 | '"'.join('" "', @{$args{generator_deps}}, @{$args{deps}}).'"' : ''; |
| 512 | |
| 513 | if ($target !~ /\.asm$/) { |
| 514 | if ($args{generator}->[0] =~ m|^.*\.in$|) { |
| 515 | my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, |
| 516 | "util", "dofile.pl")), |
| 517 | rel2abs($config{builddir})); |
| 518 | return <<"EOF"; |
| 519 | $target: "$args{generator}->[0]" $deps |
| 520 | "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\ |
| 521 | "-o$target{build_file}" $generator > \$@ |
| 522 | EOF |
| 523 | } else { |
| 524 | return <<"EOF"; |
| 525 | $target: "$args{generator}->[0]" $deps |
| 526 | "\$(PERL)"$generator_incs $generator > \$@ |
| 527 | EOF |
| 528 | } |
| 529 | } else { |
| 530 | if ($args{generator}->[0] =~ /\.pl$/) { |
| 531 | $generator = '"$(PERL)"'.$generator_incs.' '.$generator; |
| 532 | } elsif ($args{generator}->[0] =~ /\.S$/) { |
| 533 | $generator = undef; |
| 534 | } else { |
| 535 | die "Generator type for $src unknown: $generator\n"; |
| 536 | } |
| 537 | |
| 538 | my $cppflags = $incs; |
| 539 | $cppflags .= { |
| 540 | lib => ' $(LIB_CFLAGS) $(LIB_CPPFLAGS)', |
| 541 | dso => ' $(DSO_CFLAGS) $(DSO_CPPFLAGS)', |
| 542 | bin => ' $(BIN_CFLAGS) $(BIN_CPPFLAGS)' |
| 543 | } -> {$args{intent}}; |
| 544 | if (defined($generator)) { |
| 545 | # If the target is named foo.S in build.info, we want to |
| 546 | # end up generating foo.s in two steps. |
| 547 | if ($args{src} =~ /\.S$/) { |
| 548 | return <<"EOF"; |
| 549 | $target: "$args{generator}->[0]" $deps |
| 550 | set ASM=\$(AS) |
| 551 | $generator \$@.S |
| 552 | \$(CPP) $cppflags \$@.S > \$@.i && move /Y \$@.i \$@ |
| 553 | del /Q \$@.S |
| 554 | EOF |
| 555 | } |
| 556 | # Otherwise.... |
| 557 | return <<"EOF"; |
| 558 | $target: "$args{generator}->[0]" $deps |
| 559 | set ASM=\$(AS) |
| 560 | $generator \$@ |
| 561 | EOF |
| 562 | } |
| 563 | return <<"EOF"; |
| 564 | $target: "$args{generator}->[0]" $deps |
| 565 | \$(CPP) $incs $cppflags "$args{generator}->[0]" > \$@.i && move /Y \$@.i \$@ |
| 566 | EOF |
| 567 | } |
| 568 | } |
| 569 | |
| 570 | sub src2obj { |
| 571 | my %args = @_; |
| 572 | my @srcs = map { (my $x = $_) =~ s/\.s$/.asm/; $x |
| 573 | } ( @{$args{srcs}} ); |
| 574 | my $srcs = '"'.join('" "', @srcs).'"'; |
| 575 | my $deps = '"'.join('" "', @srcs, @{$args{deps}}).'"'; |
| 576 | my $incs = join("", map { ' /I "'.$_.'"' } @{$args{incs}}); |
| 577 | my $cflags = { lib => ' $(LIB_CFLAGS)', |
| 578 | dso => ' $(DSO_CFLAGS)', |
| 579 | bin => ' $(BIN_CFLAGS)' } -> {$args{intent}}; |
| 580 | $cflags .= $incs; |
| 581 | $cflags .= { lib => ' $(LIB_CPPFLAGS)', |
| 582 | dso => ' $(DSO_CPPFLAGS)', |
| 583 | bin => ' $(BIN_CPPFLAGS)' } -> {$args{intent}}; |
| 584 | my $asflags = { lib => ' $(LIB_ASFLAGS)', |
| 585 | dso => ' $(DSO_ASFLAGS)', |
| 586 | bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}}; |
| 587 | my $makedepprog = $config{makedepprog}; |
| 588 | if ($srcs[0] =~ /\.rc$/) { |
| 589 | return <<"EOF"; |
| 590 | $args{obj}: $deps |
| 591 | \$(RC) \$(RCFLAGS) \$(RCOUTFLAG)\$\@ $srcs |
| 592 | EOF |
| 593 | } |
| 594 | (my $obj = $args{obj}) =~ s|\.o$||; |
| 595 | if ($srcs[0] =~ /\.asm$/) { |
| 596 | return <<"EOF"; |
| 597 | $obj$objext: $deps |
| 598 | \$(AS) $asflags \$(ASOUTFLAG)\$\@ $srcs |
| 599 | EOF |
| 600 | } elsif ($srcs[0] =~ /.S$/) { |
| 601 | return <<"EOF"; |
| 602 | $obj$objext: $deps |
| 603 | \$(CC) /EP /D__ASSEMBLER__ $cflags $srcs > \$@.asm && \$(AS) $asflags \$(ASOUTFLAG)\$\@ \$@.asm |
| 604 | EOF |
| 605 | } |
| 606 | my $recipe = <<"EOF"; |
| 607 | $obj$objext: $deps |
| 608 | \$(CC) $cflags -c \$(COUTFLAG)\$\@ $srcs |
| 609 | EOF |
| 610 | $recipe .= <<"EOF" unless $disabled{makedepend}; |
| 611 | \$(CC) $cflags /Zs /showIncludes $srcs 2>&1 > $obj$depext |
| 612 | EOF |
| 613 | return $recipe; |
| 614 | } |
| 615 | |
| 616 | # We *know* this routine is only called when we've configure 'shared'. |
| 617 | # Also, note that even though the import library built here looks like |
| 618 | # a static library, it really isn't. |
| 619 | sub libobj2shlib { |
| 620 | my %args = @_; |
| 621 | my $lib = $args{lib}; |
| 622 | my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } |
| 623 | grep { $_ =~ m/\.(?:o|res)$/ } |
| 624 | @{$args{objs}}; |
| 625 | my @defs = grep { $_ =~ /\.def$/ } @{$args{objs}}; |
| 626 | my @deps = compute_lib_depends(@{$args{deps}}); |
| 627 | die "More than one exported symbols list" if scalar @defs > 1; |
| 628 | my $linklibs = join("", map { "$_\n" } @deps); |
| 629 | my $objs = join("\n", @objs); |
| 630 | my $deps = join(" ", @objs, @defs, @deps); |
| 631 | my $import = shlib_import($lib); |
| 632 | my $dll = shlib($lib); |
| 633 | my $shared_def = join("", map { " /def:$_" } @defs); |
| 634 | return <<"EOF" |
| 635 | # The import library may look like a static library, but it is not. |
| 636 | # We MUST make the import library depend on the DLL, in case someone |
| 637 | # mistakenly removes the latter. |
| 638 | $import: $dll |
| 639 | $dll: $deps |
| 640 | IF EXIST $full.manifest DEL /F /Q $full.manifest |
| 641 | IF EXIST \$@ DEL /F /Q \$@ |
| 642 | \$(LD) \$(LDFLAGS) \$(LIB_LDFLAGS) \\ |
| 643 | /implib:$import \$(LDOUTFLAG)$dll$shared_def @<< || (DEL /Q \$(\@B).* $import && EXIT 1) |
| 644 | $objs |
| 645 | $linklibs\$(LIB_EX_LIBS) |
| 646 | << |
| 647 | IF EXIST $dll.manifest \\ |
| 648 | \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dll.manifest \$(MTOUTFLAG)$dll |
| 649 | IF EXIST apps\\$dll DEL /Q /F apps\\$dll |
| 650 | IF EXIST test\\$dll DEL /Q /F test\\$dll |
| 651 | IF EXIST fuzz\\$dll DEL /Q /F fuzz\\$dll |
| 652 | COPY $dll apps |
| 653 | COPY $dll test |
| 654 | COPY $dll fuzz |
| 655 | EOF |
| 656 | } |
| 657 | sub obj2dso { |
| 658 | my %args = @_; |
| 659 | my $dso = $args{lib}; |
| 660 | my $dso_n = basename($dso); |
| 661 | my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}}; |
| 662 | my @deps = compute_lib_depends(@{$args{deps}}); |
| 663 | my $objs = join("\n", @objs); |
| 664 | my $linklibs = join("", map { "$_\n" } @deps); |
| 665 | my $deps = join(" ", @objs, @deps); |
| 666 | return <<"EOF"; |
| 667 | $dso$dsoext: $deps |
| 668 | IF EXIST $dso$dsoext.manifest DEL /F /Q $dso$dsoext.manifest |
| 669 | \$(LD) \$(LDFLAGS) \$(DSO_LDFLAGS) \$(LDOUTFLAG)$dso$dsoext /def:<< @<< |
| 670 | LIBRARY $dso_n |
| 671 | EXPORTS |
| 672 | bind_engine @1 |
| 673 | v_check @2 |
| 674 | << |
| 675 | $objs |
| 676 | $linklibs \$(DSO_EX_LIBS) |
| 677 | << |
| 678 | IF EXIST $dso$dsoext.manifest \\ |
| 679 | \$(MT) \$(MTFLAGS) \$(MTINFLAG)$dso$dsoext.manifest \$(MTOUTFLAG)$dso$dsoext |
| 680 | EOF |
| 681 | } |
| 682 | sub obj2lib { |
| 683 | my %args = @_; |
| 684 | my $lib = lib($args{lib}); |
| 685 | my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}}; |
| 686 | my $objs = join("\n", @objs); |
| 687 | my $deps = join(" ", @objs); |
| 688 | return <<"EOF"; |
| 689 | $lib: $deps |
| 690 | \$(AR) \$(ARFLAGS) \$(AROUTFLAG)$lib @<< |
| 691 | $objs |
| 692 | << |
| 693 | EOF |
| 694 | } |
| 695 | sub obj2bin { |
| 696 | my %args = @_; |
| 697 | my $bin = $args{bin}; |
| 698 | my @objs = map { (my $x = $_) =~ s|\.o$|$objext|; $x } @{$args{objs}}; |
| 699 | my @deps = compute_lib_depends(@{$args{deps}}); |
| 700 | my $objs = join("\n", @objs); |
| 701 | my $linklibs = join("", map { "$_\n" } @deps); |
| 702 | my $deps = join(" ", @objs, @deps); |
| 703 | return <<"EOF"; |
| 704 | $bin$exeext: $deps |
| 705 | IF EXIST $bin$exeext.manifest DEL /F /Q $bin$exeext.manifest |
| 706 | \$(LD) \$(LDFLAGS) \$(BIN_LDFLAGS) \$(LDOUTFLAG)$bin$exeext @<< |
| 707 | $objs |
| 708 | setargv.obj |
| 709 | $linklibs\$(BIN_EX_LIBS) |
| 710 | << |
| 711 | IF EXIST $bin$exeext.manifest \\ |
| 712 | \$(MT) \$(MTFLAGS) \$(MTINFLAG)$bin$exeext.manifest \$(MTOUTFLAG)$bin$exeext |
| 713 | EOF |
| 714 | } |
| 715 | sub in2script { |
| 716 | my %args = @_; |
| 717 | my $script = $args{script}; |
| 718 | my $sources = '"'.join('" "', @{$args{sources}}).'"'; |
| 719 | my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, |
| 720 | "util", "dofile.pl")), |
| 721 | rel2abs($config{builddir})); |
| 722 | return <<"EOF"; |
| 723 | $script: $sources |
| 724 | "\$(PERL)" "-I\$(BLDDIR)" -Mconfigdata "$dofile" \\ |
| 725 | "-o$target{build_file}" $sources > "$script" |
| 726 | EOF |
| 727 | } |
| 728 | sub generatedir { |
| 729 | my %args = @_; |
| 730 | my $dir = $args{dir}; |
| 731 | my @deps = map { s|\.o$|$objext|; $_ } @{$args{deps}}; |
| 732 | my @actions = (); |
| 733 | my %extinfo = ( dso => $dsoext, |
| 734 | lib => $libext, |
| 735 | bin => $exeext ); |
| 736 | |
| 737 | # We already have a 'test' target, and the top directory is just plain |
| 738 | # silly |
| 739 | return if $dir eq "test" || $dir eq "."; |
| 740 | |
| 741 | foreach my $type (("dso", "lib", "bin", "script")) { |
| 742 | next unless defined($unified_info{dirinfo}->{$dir}->{products}->{$type}); |
| 743 | # For lib object files, we could update the library. However, |
| 744 | # LIB on Windows doesn't work that way, so we won't create any |
| 745 | # actions for it, and the dependencies are already taken care of. |
| 746 | if ($type ne "lib") { |
| 747 | foreach my $prod (@{$unified_info{dirinfo}->{$dir}->{products}->{$type}}) { |
| 748 | if (dirname($prod) eq $dir) { |
| 749 | push @deps, $prod.$extinfo{$type}; |
| 750 | } |
| 751 | } |
| 752 | } |
| 753 | } |
| 754 | |
| 755 | my $deps = join(" ", @deps); |
| 756 | my $actions = join("\n", "", @actions); |
| 757 | return <<"EOF"; |
| 758 | $dir $dir\\ : $deps$actions |
| 759 | EOF |
| 760 | } |
| 761 | "" # Important! This becomes part of the template result. |
| 762 | -} |