lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | ## descrip.mms to build OpenSSL on OpenVMS |
| 2 | ## |
| 3 | ## {- join("\n## ", @autowarntext) -} |
| 4 | {- |
| 5 | use File::Spec::Functions qw/:DEFAULT abs2rel rel2abs/; |
| 6 | use File::Basename; |
| 7 | |
| 8 | # Our prefix, claimed when speaking with the VSI folks Tuesday |
| 9 | # January 26th 2016 |
| 10 | our $osslprefix = 'OSSL$'; |
| 11 | (our $osslprefix_q = $osslprefix) =~ s/\$/\\\$/; |
| 12 | |
| 13 | our $sover_dirname = sprintf "%02d%02d", split(/\./, $config{shlib_version_number}); |
| 14 | our $osslver = sprintf "%02d%02d", split(/\./, $config{version}); |
| 15 | |
lh | 758261d | 2023-07-13 05:52:04 -0700 | [diff] [blame^] | 16 | our $shlibvariant = $target{shlib_variant} || ""; |
| 17 | |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 18 | our $sourcedir = $config{sourcedir}; |
| 19 | our $builddir = $config{builddir}; |
| 20 | sub sourcefile { |
| 21 | catfile($sourcedir, @_); |
| 22 | } |
| 23 | sub buildfile { |
| 24 | catfile($builddir, @_); |
| 25 | } |
| 26 | sub sourcedir { |
| 27 | catdir($sourcedir, @_); |
| 28 | } |
| 29 | sub builddir { |
| 30 | catdir($builddir, @_); |
| 31 | } |
| 32 | sub tree { |
| 33 | (my $x = shift) =~ s|\]$|...]|; |
| 34 | $x |
| 35 | } |
| 36 | sub move { |
| 37 | my $f = catdir(@_); |
| 38 | my $b = abs2rel(rel2abs("."),rel2abs($f)); |
| 39 | $sourcedir = catdir($b,$sourcedir) |
| 40 | if !file_name_is_absolute($sourcedir); |
| 41 | $builddir = catdir($b,$builddir) |
| 42 | if !file_name_is_absolute($builddir); |
| 43 | ""; |
| 44 | } |
| 45 | |
| 46 | # Because we need to make two computations of these data, |
| 47 | # we store them in arrays for reuse |
| 48 | our @libs = |
| 49 | map { (my $x = $_) =~ s/\.a$//; $x } |
| 50 | @{$unified_info{libraries}}; |
| 51 | our @shlibs = |
lh | 758261d | 2023-07-13 05:52:04 -0700 | [diff] [blame^] | 52 | map { $unified_info{sharednames}->{$_}.$shlibvariant || () } |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 53 | grep(!/\.a$/, @{$unified_info{libraries}}); |
| 54 | our @install_libs = |
| 55 | map { (my $x = $_) =~ s/\.a$//; $x } |
| 56 | @{$unified_info{install}->{libraries}}; |
| 57 | our @install_shlibs = |
lh | 758261d | 2023-07-13 05:52:04 -0700 | [diff] [blame^] | 58 | map { $unified_info{sharednames}->{$_}.$shlibvariant || () } |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 59 | grep(!/\.a$/, @{$unified_info{install}->{libraries}}); |
| 60 | |
| 61 | # This is a horrible hack, but is needed because recursive inclusion of files |
| 62 | # in different directories does not work well with HP C. |
| 63 | my $sd = sourcedir("crypto", "async", "arch"); |
| 64 | foreach (grep /\[\.crypto\.async\.arch\].*\.o$/, keys %{$unified_info{sources}}) { |
| 65 | (my $x = $_) =~ s|\.o$|.OBJ|; |
| 66 | $unified_info{before}->{$x} |
| 67 | = qq(arch_include = F\$PARSE("$sd","A.;",,,"SYNTAX_ONLY") - "A.;" |
| 68 | define arch 'arch_include'); |
| 69 | $unified_info{after}->{$x} |
| 70 | = qq(deassign arch); |
| 71 | } |
| 72 | my $sd1 = sourcedir("ssl","record"); |
| 73 | my $sd2 = sourcedir("ssl","statem"); |
| 74 | my @ssl_locl_users = grep(/^\[\.(?:ssl\.(?:record|statem)|test)\].*\.o$/, |
| 75 | keys %{$unified_info{sources}}); |
| 76 | foreach (@ssl_locl_users) { |
| 77 | (my $x = $_) =~ s|\.o$|.OBJ|; |
| 78 | $unified_info{before}->{$x} |
| 79 | = qq(record_include = F\$PARSE("$sd1","A.;",,,"SYNTAX_ONLY") - "A.;" |
| 80 | define record 'record_include' |
| 81 | statem_include = F\$PARSE("$sd2","A.;",,,"SYNTAX_ONLY") - "A.;" |
| 82 | define statem 'statem_include'); |
| 83 | $unified_info{after}->{$x} |
| 84 | = qq(deassign statem |
| 85 | deassign record); |
| 86 | } |
| 87 | # This makes sure things get built in the order they need |
| 88 | # to. You're welcome. |
| 89 | sub dependmagic { |
| 90 | my $target = shift; |
| 91 | |
| 92 | return "$target : build_generated\n\t\pipe \$(MMS) \$(MMSQUALIFIERS) depend && \$(MMS) \$(MMSQUALIFIERS) _$target\n_$target"; |
| 93 | } |
| 94 | #use Data::Dumper; |
| 95 | #print STDERR "DEBUG: before:\n", Dumper($unified_info{before}); |
| 96 | #print STDERR "DEBUG: after:\n", Dumper($unified_info{after}); |
| 97 | ""; |
| 98 | -} |
| 99 | PLATFORM={- $config{target} -} |
| 100 | OPTIONS={- $config{options} -} |
| 101 | CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -}) |
| 102 | SRCDIR={- $config{sourcedir} -} |
| 103 | BLDDIR={- $config{builddir} -} |
| 104 | |
| 105 | # Allow both V and VERBOSE to indicate verbosity. This only applies |
| 106 | # to testing. |
| 107 | VERBOSE=$(V) |
| 108 | |
| 109 | VERSION={- $config{version} -} |
| 110 | MAJOR={- $config{major} -} |
| 111 | MINOR={- $config{minor} -} |
| 112 | SHLIB_VERSION_NUMBER={- $config{shlib_version_number} -} |
| 113 | SHLIB_VERSION_HISTORY={- $config{shlib_version_history} -} |
| 114 | SHLIB_MAJOR={- $config{shlib_major} -} |
| 115 | SHLIB_MINOR={- $config{shlib_minor} -} |
| 116 | SHLIB_TARGET={- $target{shared_target} -} |
| 117 | |
| 118 | EXE_EXT=.EXE |
| 119 | LIB_EXT=.OLB |
| 120 | SHLIB_EXT=.EXE |
| 121 | OBJ_EXT=.OBJ |
| 122 | DEP_EXT=.D |
| 123 | |
| 124 | LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @libs) -} |
| 125 | SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @shlibs) -} |
| 126 | ENGINES={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{engines}}) -} |
| 127 | PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{programs}}) -} |
| 128 | SCRIPTS={- join(", ", map { "-\n\t".$_ } @{$unified_info{scripts}}) -} |
| 129 | {- output_off() if $disabled{makedepend}; "" -} |
| 130 | DEPS={- our @deps = map { (my $x = $_) =~ s|\.o$|\$(DEP_EXT)|; $x; } |
| 131 | grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ } |
| 132 | keys %{$unified_info{sources}}; |
| 133 | join(", ", map { "-\n\t".$_ } @deps); -} |
| 134 | {- output_on() if $disabled{makedepend}; "" -} |
| 135 | GENERATED_MANDATORY={- join(", ", map { "-\n\t".$_ } @{$unified_info{depends}->{""}} ) -} |
| 136 | GENERATED={- # common0.tmpl provides @generated |
| 137 | join(", ", map { (my $x = $_) =~ s|\.[sS]$|.asm|; "-\n\t".$x } |
| 138 | @generated) -} |
| 139 | |
| 140 | INSTALL_LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @install_libs) -} |
| 141 | INSTALL_SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @install_shlibs) -} |
| 142 | INSTALL_ENGINES={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{install}->{engines}}) -} |
| 143 | INSTALL_PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{install}->{programs}}) -} |
| 144 | {- output_off() if $disabled{apps}; "" -} |
| 145 | BIN_SCRIPTS=[.tools]c_rehash.pl |
| 146 | MISC_SCRIPTS=[.apps]CA.pl, [.apps]tsget.pl |
| 147 | {- output_on() if $disabled{apps}; "" -} |
| 148 | |
| 149 | APPS_OPENSSL={- use File::Spec::Functions; |
| 150 | catfile("apps","openssl") -} |
| 151 | |
| 152 | # DESTDIR is for package builders so that they can configure for, say, |
| 153 | # SYS$COMMON:[OPENSSL] and yet have everything installed in STAGING:[USER]. |
| 154 | # In that case, configure with --prefix=SYS$COMMON:[OPENSSL] and then run |
| 155 | # MMS with /MACROS=(DESTDIR=STAGING:[USER]). The result will end up in |
| 156 | # STAGING:[USER.OPENSSL]. |
| 157 | # Normally it is left empty. |
| 158 | DESTDIR= |
| 159 | |
| 160 | # Do not edit this manually. Use Configure --prefix=DIR to change this! |
| 161 | INSTALLTOP={- our $installtop = |
| 162 | catdir($config{prefix}) || "SYS\$COMMON:[OPENSSL]"; |
| 163 | $installtop -} |
| 164 | SYSTARTUP={- catdir($installtop, '[.SYS$STARTUP]'); -} |
| 165 | # This is the standard central area to store certificates, private keys... |
| 166 | OPENSSLDIR={- catdir($config{openssldir}) or |
| 167 | $config{prefix} ? catdir($config{prefix},"COMMON") |
| 168 | : "SYS\$COMMON:[OPENSSL-COMMON]" -} |
| 169 | # The same, but for C |
| 170 | OPENSSLDIR_C={- $osslprefix -}DATAROOT:[000000] |
| 171 | # Where installed engines reside, for C |
| 172 | ENGINESDIR_C={- $osslprefix -}ENGINES{- $sover_dirname.$target{pointer_size} -}: |
| 173 | |
| 174 | ##### User defined commands and flags ################################ |
| 175 | |
| 176 | CC={- $config{CC} -} |
| 177 | CPP={- $config{CPP} -} |
| 178 | DEFINES={- our $defines1 = join('', map { ",$_" } @{$config{CPPDEFINES}}) -} |
| 179 | INCLUDES={- our $includes1 = join(',', @{$config{CPPINCLUDES}}) -} |
| 180 | CPPFLAGS={- our $cppflags1 = join('', @{$config{CPPFLAGS}}) -} |
| 181 | CFLAGS={- join('', @{$config{CFLAGS}}) -} |
| 182 | LDFLAGS={- join('', @{$config{LFLAGS}}) -} |
| 183 | EX_LIBS={- join('', map { ",$_" } @{$config{LDLIBS}}) -} |
| 184 | |
| 185 | PERL={- $config{PERL} -} |
| 186 | |
| 187 | AS={- $config{AS} -} |
| 188 | ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -} |
| 189 | |
| 190 | ##### Special command flags ########################################## |
| 191 | |
| 192 | ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY) |
| 193 | |
| 194 | ##### Project flags ################################################## |
| 195 | |
| 196 | # Variables starting with CNF_ are common variables for all product types |
| 197 | |
| 198 | CNF_ASFLAGS={- join('', $target{asflags} || (), |
| 199 | @{$config{asflags}}) -} |
| 200 | CNF_DEFINES={- our $defines2 = join('', map { ",$_" } @{$target{defines}}, |
| 201 | @{$config{defines}}) -} |
| 202 | CNF_INCLUDES={- our $includes2 = join(',', @{$target{includes}}, |
| 203 | @{$config{includes}}) -} |
| 204 | CNF_CPPFLAGS={- our $cppflags2 = join('', $target{cppflags} || (), |
| 205 | @{$config{cppflags}}) -} |
| 206 | CNF_CFLAGS={- join('', $target{cflags} || (), |
| 207 | @{$config{cflags}}) -} |
| 208 | CNF_CXXFLAGS={- join('', $target{cxxflags} || (), |
| 209 | @{$config{cxxflags}}) -} |
| 210 | CNF_LDFLAGS={- join('', $target{lflags} || (), |
| 211 | @{$config{lflags}}) -} |
| 212 | CNF_EX_LIBS={- join('', map{ ",$_" } @{$target{ex_libs}}, |
| 213 | @{$config{ex_libs}}) -} |
| 214 | |
| 215 | # Variables starting with LIB_ are used to build library object files |
| 216 | # and shared libraries. |
| 217 | # Variables starting with DSO_ are used to build DSOs and their object files. |
| 218 | # Variables starting with BIN_ are used to build programs and their object |
| 219 | # files. |
| 220 | |
| 221 | LIB_ASFLAGS={- join(' ', $target{lib_asflags} || (), |
| 222 | @{$config{lib_asflags}}, |
| 223 | '$(CNF_ASFLAGS)', '$(ASFLAGS)') -} |
| 224 | LIB_DEFINES={- our $lib_defines = |
| 225 | join('', (map { ",$_" } @{$target{lib_defines}}, |
| 226 | @{$target{shared_defines}}, |
| 227 | @{$config{lib_defines}}, |
| 228 | @{$config{shared_defines}})); |
| 229 | join('', $lib_defines, |
| 230 | (map { ",$_" } 'OPENSSLDIR="""$(OPENSSLDIR_C)"""', |
| 231 | 'ENGINESDIR="""$(ENGINESDIR_C)"""'), |
| 232 | '$(CNF_DEFINES)', '$(DEFINES)') -} |
| 233 | LIB_INCLUDES={- our $lib_includes = |
| 234 | join(',', @{$target{lib_includes}}, |
| 235 | @{$target{shared_includes}}, |
| 236 | @{$config{lib_includes}}, |
| 237 | @{$config{shared_includes}}) -} |
| 238 | LIB_CPPFLAGS={- our $lib_cppflags = |
| 239 | join('', $target{lib_cppflags} || (), |
| 240 | $target{shared_cppflags} || (), |
| 241 | @{$config{lib_cppflags}}, |
| 242 | @{$config{shared_cppflag}}); |
| 243 | join('', "'qual_includes'", |
| 244 | '/DEFINE=(__dummy$(LIB_DEFINES))', |
| 245 | $lib_cppflags, |
| 246 | '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -} |
| 247 | LIB_CFLAGS={- join('', $target{lib_cflags} || (), |
| 248 | $target{shared_cflag} || (), |
| 249 | @{$config{lib_cflags}}, |
| 250 | @{$config{shared_cflag}}, |
| 251 | '$(CNF_CFLAGS)', '$(CFLAGS)') -} |
| 252 | LIB_LDFLAGS={- join('', $target{lib_lflags} || (), |
| 253 | $target{shared_ldflag} || (), |
| 254 | @{$config{lib_lflags}}, |
| 255 | @{$config{shared_ldflag}}, |
| 256 | '$(CNF_LDFLAGS)', '$(LDFLAGS)') -} |
| 257 | LIB_EX_LIBS=$(CNF_EX_LIBS)$(EX_LIBS) |
| 258 | DSO_ASFLAGS={- join(' ', $target{dso_asflags} || (), |
| 259 | $target{module_asflags} || (), |
| 260 | @{$config{dso_asflags}}, |
| 261 | @{$config{module_asflags}}, |
| 262 | '$(CNF_ASFLAGS)', '$(ASFLAGS)') -} |
| 263 | DSO_DEFINES={- join('', (map { ",$_" } @{$target{dso_defines}}, |
| 264 | @{$target{module_defines}}, |
| 265 | @{$config{dso_defines}}, |
| 266 | @{$config{module_defines}}), |
| 267 | '$(CNF_DEFINES)', '$(DEFINES)') -} |
| 268 | DSO_INCLUDES={- join(',', @{$target{dso_includes}}, |
| 269 | @{$target{module_includes}}, |
| 270 | @{$config{dso_includes}}, |
| 271 | @{$config{module_includes}}) -} |
| 272 | DSO_CPPFLAGS={- join('', "'qual_includes'", |
| 273 | '/DEFINE=(__dummy$(DSO_DEFINES))', |
| 274 | $target{dso_cppflags} || (), |
| 275 | $target{module_cppflags} || (), |
| 276 | @{$config{dso_cppflags}}, |
| 277 | @{$config{module_cppflags}}, |
| 278 | '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -} |
| 279 | DSO_CFLAGS={- join('', $target{dso_cflags} || (), |
| 280 | $target{module_cflags} || (), |
| 281 | @{$config{dso_cflags}}, |
| 282 | @{$config{module_cflags}}, |
| 283 | '$(CNF_CFLAGS)', '$(CFLAGS)') -} |
| 284 | DSO_LDFLAGS={- join('', $target{dso_lflags} || (), |
| 285 | $target{module_ldflags} || (), |
| 286 | @{$config{dso_lflags}}, |
| 287 | @{$config{module_ldflags}}, |
| 288 | '$(CNF_LDFLAGS)', '$(LDFLAGS)') -} |
| 289 | DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS) |
| 290 | BIN_ASFLAGS={- join(' ', $target{bin_asflags} || (), |
| 291 | @{$config{bin_asflags}}, |
| 292 | '$(CNF_ASFLAGS)', '$(ASFLAGS)') -} |
| 293 | BIN_DEFINES={- join('', (map { ",$_" } @{$target{bin_defines}}, |
| 294 | @{$config{bin_defines}}), |
| 295 | '$(CNF_DEFINES)', '$(DEFINES)') -} |
| 296 | BIN_INCLUDES={- join(',', @{$target{bin_includes}}, |
| 297 | @{$config{bin_includes}}) -} |
| 298 | BIN_CPPFLAGS={- join('', "'qual_includes'", |
| 299 | '/DEFINE=(__dummy$(DSO_DEFINES))', |
| 300 | $target{bin_cppflags} || (), |
| 301 | @{$config{bin_cppflag}}, |
| 302 | '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -} |
| 303 | BIN_CFLAGS={- join('', $target{bin_cflag} || (), |
| 304 | @{$config{bin_cflag}}, |
| 305 | '$(CNF_CFLAGS)', '$(CFLAGS)') -} |
| 306 | BIN_LDFLAGS={- join('', $target{bin_lflags} || (), |
| 307 | @{$config{bin_lflags}} || (), |
| 308 | '$(CNF_LDFLAGS)', '$(LDFLAGS)') -} |
| 309 | BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS) |
| 310 | NO_INST_LIB_CFLAGS={- join('', $target{no_inst_lib_cflags} |
| 311 | // $target{lib_cflags} |
| 312 | // (), |
| 313 | $target{shared_cflag} || (), |
| 314 | @{$config{lib_cflags}}, |
| 315 | @{$config{shared_cflag}}, |
| 316 | '$(CNF_CFLAGS)', '$(CFLAGS)') -} |
| 317 | NO_INST_DSO_CFLAGS={- join('', $target{no_inst_lib_cflags} |
| 318 | // $target{lib_cflags} |
| 319 | // (), |
| 320 | $target{dso_cflags} || (), |
| 321 | @{$config{lib_cflags}}, |
| 322 | @{$config{dso_cflags}}, |
| 323 | '$(CNF_CFLAGS)', '$(CFLAGS)') -} |
| 324 | NO_INST_BIN_CFLAGS={- join('', $target{no_inst_bin_cflags} |
| 325 | // $target{bin_cflags} |
| 326 | // (), |
| 327 | @{$config{bin_cflags}}, |
| 328 | '$(CNF_CFLAGS)', '$(CFLAGS)') -} |
| 329 | |
| 330 | PERLASM_SCHEME={- $target{perlasm_scheme} -} |
| 331 | |
| 332 | # CPPFLAGS_Q is used for one thing only: to build up buildinf.h |
| 333 | CPPFLAGS_Q={- (my $c = $lib_cppflags.$cppflags2.$cppflags1) =~ s|"|""|g; |
| 334 | (my $d = $lib_defines.$defines2.$defines1) =~ s|"|""|g; |
| 335 | my $i = join(',', $lib_includes || (), $includes2 || (), |
| 336 | $includes1 || ()); |
| 337 | my $x = $c; |
| 338 | $x .= "/INCLUDE=($i)" if $i; |
| 339 | $x .= "/DEFINE=($d)" if $d; |
| 340 | $x; -} |
| 341 | |
| 342 | # .FIRST and .LAST are special targets with MMS and MMK. |
| 343 | # The defines in there are for C. includes that look like |
| 344 | # this: |
| 345 | # |
| 346 | # #include <openssl/foo.h> |
| 347 | # #include "internal/bar.h" |
| 348 | # #include "crypto/something.h" |
| 349 | # |
| 350 | # will use the logical names to find the files. Expecting |
| 351 | # DECompHP C to find files in subdirectories of whatever was |
| 352 | # given with /INCLUDE is a fantasy, unfortunately. |
| 353 | NODEBUG=@ |
| 354 | .FIRST : |
| 355 | $(NODEBUG) openssl_inc1 = F$PARSE("[.include.openssl]","A.;",,,"syntax_only") - "A.;" |
| 356 | $(NODEBUG) openssl_inc2 = F$PARSE("{- catdir($config{sourcedir},"[.include.openssl]") -}","A.;",,,"SYNTAX_ONLY") - "A.;" |
| 357 | $(NODEBUG) internal_inc1 = F$PARSE("[.include.internal]","A.;",,,"SYNTAX_ONLY") - "A.;" |
| 358 | $(NODEBUG) internal_inc2 = F$PARSE("{- catdir($config{sourcedir},"[.include.internal]") -}","A.;",,,"SYNTAX_ONLY") - "A.;" |
| 359 | $(NODEBUG) crypto_inc1 = F$PARSE("[.include.crypto]","A.;",,,"SYNTAX_ONLY") - "A.;" |
| 360 | $(NODEBUG) crypto_inc2 = F$PARSE("{- catdir($config{sourcedir},"[.include.crypto]") -}","A.;",,,"SYNTAX_ONLY") - "A.;" |
| 361 | $(NODEBUG) DEFINE openssl 'openssl_inc1','openssl_inc2' |
| 362 | $(NODEBUG) DEFINE internal 'internal_inc1','internal_inc2' |
| 363 | $(NODEBUG) DEFINE crypto 'crypto_inc1','crypto_inc2' |
| 364 | $(NODEBUG) staging_dir = "$(DESTDIR)" |
| 365 | $(NODEBUG) staging_instdir = "" |
| 366 | $(NODEBUG) staging_datadir = "" |
| 367 | $(NODEBUG) IF staging_dir .NES. "" THEN - |
| 368 | staging_instdir = F$PARSE("A.;",staging_dir,"[]",,"SYNTAX_ONLY") |
| 369 | $(NODEBUG) IF staging_instdir - "]A.;" .NES. staging_instdir THEN - |
| 370 | staging_instdir = staging_instdir - "]A.;" + ".OPENSSL-INSTALL]" |
| 371 | $(NODEBUG) IF staging_instdir - "A.;" .NES. staging_instdir THEN - |
| 372 | staging_instdir = staging_instdir - "A.;" + "[OPENSSL-INSTALL]" |
| 373 | $(NODEBUG) IF staging_dir .NES. "" THEN - |
| 374 | staging_datadir = F$PARSE("A.;",staging_dir,"[]",,"SYNTAX_ONLY") |
| 375 | $(NODEBUG) IF staging_datadir - "]A.;" .NES. staging_datadir THEN - |
| 376 | staging_datadir = staging_datadir - "]A.;" + ".OPENSSL-COMMON]" |
| 377 | $(NODEBUG) IF staging_datadir - "A.;" .NES. staging_datadir THEN - |
| 378 | staging_datadir = staging_datadir - "A.;" + "[OPENSSL-COMMON]" |
| 379 | $(NODEBUG) ! |
| 380 | $(NODEBUG) ! Installation logical names |
| 381 | $(NODEBUG) ! |
| 382 | $(NODEBUG) ! This also creates a few DCL variables that are used for |
| 383 | $(NODEBUG) ! the "install_msg" target. |
| 384 | $(NODEBUG) ! |
| 385 | $(NODEBUG) installroot = F$PARSE(staging_instdir,"$(INSTALLTOP)","[]A.;",,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;" |
| 386 | $(NODEBUG) installtop = installroot + ".]" |
| 387 | $(NODEBUG) dataroot = F$PARSE(staging_datadir,"$(OPENSSLDIR)","[]A.;",,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;" |
| 388 | $(NODEBUG) datatop = dataroot + ".]" |
| 389 | $(NODEBUG) DEFINE ossl_installroot 'installtop' |
| 390 | $(NODEBUG) DEFINE ossl_dataroot 'datatop' |
| 391 | $(NODEBUG) ! |
| 392 | $(NODEBUG) ! Figure out the architecture |
| 393 | $(NODEBUG) ! |
| 394 | $(NODEBUG) arch = f$edit( f$getsyi( "arch_name"), "upcase") |
| 395 | $(NODEBUG) ! |
| 396 | $(NODEBUG) ! Set up logical names for the libraries, so LINK and |
| 397 | $(NODEBUG) ! running programs can use them. |
| 398 | $(NODEBUG) ! |
| 399 | $(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEFINE ".uc($_)." 'F\$ENV(\"DEFAULT\")'".uc($_)."\$(SHLIB_EXT)" } @shlibs) || "!" -} |
| 400 | |
| 401 | .LAST : |
| 402 | $(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEASSIGN ".uc($_) } @shlibs) || "!" -} |
| 403 | $(NODEBUG) DEASSIGN ossl_dataroot |
| 404 | $(NODEBUG) DEASSIGN ossl_installroot |
| 405 | $(NODEBUG) DEASSIGN crypto |
| 406 | $(NODEBUG) DEASSIGN internal |
| 407 | $(NODEBUG) DEASSIGN openssl |
| 408 | .DEFAULT : |
| 409 | @ ! MMS cannot handle no actions... |
| 410 | |
| 411 | # The main targets ################################################### |
| 412 | |
| 413 | {- dependmagic('all'); -} : build_libs_nodep, build_engines_nodep, build_programs_nodep |
| 414 | {- dependmagic('build_libs'); -} : build_libs_nodep |
| 415 | {- dependmagic('build_engines'); -} : build_engines_nodep |
| 416 | {- dependmagic('build_programs'); -} : build_programs_nodep |
| 417 | |
| 418 | build_generated : $(GENERATED_MANDATORY) |
| 419 | build_libs_nodep : $(LIBS), $(SHLIBS) |
| 420 | build_engines_nodep : $(ENGINES) |
| 421 | build_programs_nodep : $(PROGRAMS), $(SCRIPTS) |
| 422 | |
| 423 | # Kept around for backward compatibility |
| 424 | build_apps build_tests : build_programs |
| 425 | |
| 426 | # Convenience target to prebuild all generated files, not just the mandatory |
| 427 | # ones |
| 428 | build_all_generated : $(GENERATED_MANDATORY) $(GENERATED) |
| 429 | @ ! {- output_off() if $disabled{makedepend}; "" -} |
| 430 | @ WRITE SYS$OUTPUT "Warning: consider configuring with no-makedepend, because if" |
| 431 | @ WRITE SYS$OUTPUT " target system doesn't have $(PERL)," |
| 432 | @ WRITE SYS$OUTPUT " then make will fail..." |
| 433 | @ ! {- output_on() if $disabled{makedepend}; "" -} |
| 434 | |
| 435 | test : tests |
| 436 | {- dependmagic('tests'); -} : build_programs_nodep, build_engines_nodep |
| 437 | @ ! {- output_off() if $disabled{tests}; "" -} |
| 438 | SET DEFAULT [.test]{- move("test") -} |
| 439 | CREATE/DIR [.test-runs] |
| 440 | DEFINE SRCTOP {- sourcedir() -} |
| 441 | DEFINE BLDTOP {- builddir() -} |
| 442 | DEFINE RESULT_D {- builddir(qw(test test-runs)) -} |
| 443 | engines = F$PARSE("{- builddir("engines") -}","A.;",,,"syntax_only") - "A.;" |
| 444 | DEFINE OPENSSL_ENGINES 'engines' |
| 445 | DEFINE OPENSSL_DEBUG_MEMORY "on" |
| 446 | IF "$(VERBOSE)" .NES. "" THEN DEFINE VERBOSE "$(VERBOSE)" |
| 447 | $(PERL) {- sourcefile("test", "run_tests.pl") -} $(TESTS) |
| 448 | DEASSIGN OPENSSL_DEBUG_MEMORY |
| 449 | DEASSIGN OPENSSL_ENGINES |
| 450 | DEASSIGN BLDTOP |
| 451 | DEASSIGN SRCTOP |
| 452 | SET DEFAULT [-]{- move("..") -} |
| 453 | @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -} |
| 454 | @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options" |
| 455 | @ ! {- output_on() if !$disabled{tests}; "" -} |
| 456 | |
| 457 | list-tests : |
| 458 | @ ! {- output_off() if $disabled{tests}; "" -} |
| 459 | @ DEFINE SRCTOP {- sourcedir() -} |
| 460 | @ $(PERL) {- sourcefile("test", "run_tests.pl") -} list |
| 461 | @ DEASSIGN SRCTOP |
| 462 | @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -} |
| 463 | @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options" |
| 464 | @ ! {- output_on() if !$disabled{tests}; "" -} |
| 465 | |
| 466 | install : install_sw install_ssldirs install_docs install_msg |
| 467 | @ ! |
| 468 | |
| 469 | install_msg : |
| 470 | @ WRITE SYS$OUTPUT "" |
| 471 | @ WRITE SYS$OUTPUT "######################################################################" |
| 472 | @ WRITE SYS$OUTPUT "" |
| 473 | @ IF "$(DESTDIR)" .EQS. "" THEN - |
| 474 | @{- sourcefile("VMS", "msg_install.com") -} "$(SYSTARTUP)" "{- $osslver -}" |
| 475 | @ IF "$(DESTDIR)" .NES. "" THEN - |
| 476 | @{- sourcefile("VMS", "msg_staging.com") -} - |
| 477 | "''installroot']" "''dataroot']" "$(INSTALLTOP)" "$(OPENSSLDIR)" - |
| 478 | "$(SYSTARTUP)" "{- $osslver -}" |
| 479 | |
| 480 | check_install : |
| 481 | spawn/nolog @ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com |
| 482 | |
| 483 | uninstall : uninstall_docs uninstall_sw |
| 484 | |
| 485 | # Because VMS wants the generation number (or *) to delete files, we can't |
| 486 | # use $(LIBS), $(PROGRAMS), $(GENERATED) and $(ENGINES)directly. |
| 487 | libclean : |
| 488 | {- join("\n\t", map { "- DELETE $_.OLB;*" } @libs) || "@ !" -} |
| 489 | {- join("\n\t", map { "- DELETE $_.EXE;*,$_.MAP;*" } @shlibs) || "@ !" -} |
| 490 | |
| 491 | clean : libclean |
| 492 | {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{programs}}) || "@ !" -} |
| 493 | {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{engines}}) || "@ !" -} |
| 494 | {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{scripts}}) || "@ !" -} |
| 495 | {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{depends}->{""}}) || "@ !" -} |
| 496 | {- join("\n\t", map { "- DELETE $_;*" } @generated) || "@ !" -} |
| 497 | - DELETE [...]*.MAP;* |
| 498 | - DELETE [...]*.D;* |
| 499 | - DELETE [...]*.OBJ;*,*.LIS;* |
| 500 | - DELETE []CXX$DEMANGLER_DB.;* |
| 501 | - DELETE [.VMS]openssl_startup.com;* |
| 502 | - DELETE [.VMS]openssl_shutdown.com;* |
| 503 | - DELETE []vmsconfig.pm;* |
| 504 | |
| 505 | distclean : clean |
| 506 | - DELETE configdata.pm;* |
| 507 | - DELETE descrip.mms;* |
| 508 | |
| 509 | depend : descrip.mms |
| 510 | descrip.mms : FORCE |
| 511 | @ ! {- output_off() if $disabled{makedepend}; "" -} |
| 512 | @ $(PERL) {- sourcefile("util", "add-depends.pl") -} "VMS C" |
| 513 | @ ! {- output_on() if $disabled{makedepend}; "" -} |
| 514 | |
| 515 | # Install helper targets ############################################# |
| 516 | |
| 517 | install_sw : install_dev install_engines install_runtime - |
| 518 | install_startup install_ivp |
| 519 | |
| 520 | uninstall_sw : uninstall_dev uninstall_engines uninstall_runtime - |
| 521 | uninstall_startup uninstall_ivp |
| 522 | |
| 523 | install_docs : install_html_docs |
| 524 | |
| 525 | uninstall_docs : uninstall_html_docs |
| 526 | |
| 527 | install_ssldirs : check_INSTALLTOP |
| 528 | - CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[000000] |
| 529 | IF F$SEARCH("OSSL_DATAROOT:[000000]CERTS.DIR;1") .EQS. "" THEN - |
| 530 | CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[CERTS] |
| 531 | IF F$SEARCH("OSSL_DATAROOT:[000000]PRIVATE.DIR;1") .EQS. "" THEN - |
| 532 | CREATE/DIR/PROT=(S:RWED,O:RWE,G,W) OSSL_DATAROOT:[PRIVATE] |
| 533 | IF F$SEARCH("OSSL_DATAROOT:[000000]MISC.DIR;1") .EQS. "" THEN - |
| 534 | CREATE/DIR/PROT=(S:RWED,O:RWE,G,W) OSSL_DATAROOT:[MISC] |
| 535 | COPY/PROT=W:RE $(MISC_SCRIPTS) OSSL_DATAROOT:[MISC] |
| 536 | @ ! Install configuration file |
| 537 | COPY/PROT=W:R {- sourcefile("apps", "openssl-vms.cnf") -} - |
| 538 | ossl_dataroot:[000000]openssl.cnf-dist |
| 539 | IF F$SEARCH("OSSL_DATAROOT:[000000]openssl.cnf") .EQS. "" THEN - |
| 540 | COPY/PROT=W:R {- sourcefile("apps", "openssl-vms.cnf") -} - |
| 541 | ossl_dataroot:[000000]openssl.cnf |
| 542 | @ ! Install CTLOG configuration file |
| 543 | COPY/PROT=W:R {- sourcefile("apps", "ct_log_list.cnf") -} - |
| 544 | ossl_dataroot:[000000]ct_log_list.cnf-dist |
| 545 | IF F$SEARCH("OSSL_DATAROOT:[000000]ct_log_list.cnf") .EQS. "" THEN - |
| 546 | COPY/PROT=W:R {- sourcefile("apps", "ct_log_list.cnf") -} - |
| 547 | ossl_dataroot:[000000]ct_log_list.cnf |
| 548 | |
| 549 | install_dev : check_INSTALLTOP install_runtime_libs |
| 550 | @ WRITE SYS$OUTPUT "*** Installing development files" |
| 551 | @ ! Install header files |
| 552 | - CREATE/DIR ossl_installroot:[include.openssl] |
| 553 | COPY/PROT=W:R openssl:*.h ossl_installroot:[include.openssl] |
| 554 | @ ! Install static (development) libraries |
| 555 | - CREATE/DIR ossl_installroot:[LIB.'arch'] |
| 556 | {- join("\n ", |
| 557 | map { "COPY/PROT=W:R $_.OLB ossl_installroot:[LIB.'arch']" } |
| 558 | @install_libs) -} |
| 559 | |
| 560 | install_engines : check_INSTALLTOP install_runtime_libs build_engines |
| 561 | @ {- output_off() unless scalar @{$unified_info{engines}}; "" -} ! |
| 562 | @ WRITE SYS$OUTPUT "*** Installing engines" |
| 563 | - CREATE/DIR ossl_installroot:[ENGINES{- $sover_dirname.$target{pointer_size} -}.'arch'] |
| 564 | {- join("\n ", |
| 565 | map { "COPY/PROT=W:RE $_.EXE ossl_installroot:[ENGINES$sover_dirname$target{pointer_size}.'arch']" } |
| 566 | @{$unified_info{install}->{engines}}) -} |
| 567 | @ {- output_on() unless scalar @{$unified_info{engines}}; "" -} ! |
| 568 | |
| 569 | install_runtime : install_programs |
| 570 | |
| 571 | install_runtime_libs : check_INSTALLTOP build_libs |
| 572 | @ {- output_off() if $disabled{shared}; "" -} ! |
| 573 | @ WRITE SYS$OUTPUT "*** Installing shareable images" |
| 574 | @ ! Install shared (runtime) libraries |
| 575 | - CREATE/DIR ossl_installroot:[LIB.'arch'] |
| 576 | {- join("\n ", |
| 577 | map { "COPY/PROT=W:R $_.EXE ossl_installroot:[LIB.'arch']" } |
| 578 | @install_shlibs) -} |
| 579 | @ {- output_on() if $disabled{shared}; "" -} ! |
| 580 | |
| 581 | install_programs : check_INSTALLTOP install_runtime_libs build_programs |
| 582 | @ {- output_off() if $disabled{apps}; "" -} ! |
| 583 | @ ! Install the main program |
| 584 | - CREATE/DIR ossl_installroot:[EXE.'arch'] |
| 585 | COPY/PROT=W:RE [.APPS]openssl.EXE - |
| 586 | ossl_installroot:[EXE.'arch']openssl{- $osslver -}.EXE |
| 587 | @ ! Install scripts |
| 588 | COPY/PROT=W:RE $(BIN_SCRIPTS) ossl_installroot:[EXE] |
| 589 | @ ! {- output_on() if $disabled{apps}; "" -} |
| 590 | |
| 591 | install_startup : [.VMS]openssl_startup.com [.VMS]openssl_shutdown.com - |
| 592 | [.VMS]openssl_utils.com, check_INSTALLTOP |
| 593 | - CREATE/DIR ossl_installroot:[SYS$STARTUP] |
| 594 | COPY/PROT=W:RE [.VMS]openssl_startup.com - |
| 595 | ossl_installroot:[SYS$STARTUP]openssl_startup{- $osslver -}.com |
| 596 | COPY/PROT=W:RE [.VMS]openssl_shutdown.com - |
| 597 | ossl_installroot:[SYS$STARTUP]openssl_shutdown{- $osslver -}.com |
| 598 | COPY/PROT=W:RE [.VMS]openssl_utils.com - |
| 599 | ossl_installroot:[SYS$STARTUP]openssl_utils{- $osslver -}.com |
| 600 | |
| 601 | install_ivp : [.VMS]openssl_ivp.com check_INSTALLTOP |
| 602 | - CREATE/DIR ossl_installroot:[SYSTEST] |
| 603 | COPY/PROT=W:RE [.VMS]openssl_ivp.com - |
| 604 | ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com |
| 605 | |
| 606 | [.VMS]openssl_startup.com : vmsconfig.pm {- sourcefile("VMS", "openssl_startup.com.in") -} |
| 607 | - CREATE/DIR [.VMS] |
| 608 | $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} - |
| 609 | {- sourcefile("VMS", "openssl_startup.com.in") -} - |
| 610 | > [.VMS]openssl_startup.com |
| 611 | |
| 612 | [.VMS]openssl_utils.com : vmsconfig.pm {- sourcefile("VMS", "openssl_utils.com.in") -} |
| 613 | - CREATE/DIR [.VMS] |
| 614 | $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} - |
| 615 | {- sourcefile("VMS", "openssl_utils.com.in") -} - |
| 616 | > [.VMS]openssl_utils.com |
| 617 | |
| 618 | [.VMS]openssl_shutdown.com : vmsconfig.pm {- sourcefile("VMS", "openssl_shutdown.com.in") -} |
| 619 | - CREATE/DIR [.VMS] |
| 620 | $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} - |
| 621 | {- sourcefile("VMS", "openssl_shutdown.com.in") -} - |
| 622 | > [.VMS]openssl_shutdown.com |
| 623 | |
| 624 | [.VMS]openssl_ivp.com : vmsconfig.pm {- sourcefile("VMS", "openssl_ivp.com.in") -} |
| 625 | - CREATE/DIR [.VMS] |
| 626 | $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} - |
| 627 | {- sourcefile("VMS", "openssl_ivp.com.in") -} - |
| 628 | > [.VMS]openssl_ivp.com |
| 629 | |
| 630 | vmsconfig.pm : configdata.pm |
| 631 | OPEN/WRITE/SHARE=READ CONFIG []vmsconfig.pm |
| 632 | WRITE CONFIG "package vmsconfig;" |
| 633 | WRITE CONFIG "use strict; use warnings;" |
| 634 | WRITE CONFIG "use Exporter;" |
| 635 | WRITE CONFIG "our @ISA = qw(Exporter);" |
| 636 | WRITE CONFIG "our @EXPORT = qw(%config %target %withargs %unified_info %disabled);" |
| 637 | WRITE CONFIG "our %config = (" |
| 638 | WRITE CONFIG " target => '","{- $config{target} -}","'," |
| 639 | WRITE CONFIG " version => '","{- $config{version} -}","'," |
| 640 | WRITE CONFIG " shlib_version_number => '","{- $config{shlib_version_number} -}","'," |
| 641 | WRITE CONFIG " shlib_major => '","{- $config{shlib_major} -}","'," |
| 642 | WRITE CONFIG " shlib_minor => '","{- $config{shlib_minor} -}","'," |
| 643 | WRITE CONFIG " no_shared => '","{- $disabled{shared} -}","'," |
| 644 | WRITE CONFIG " INSTALLTOP => '$(INSTALLTOP)'," |
| 645 | WRITE CONFIG " OPENSSLDIR => '$(OPENSSLDIR)'," |
| 646 | WRITE CONFIG " pointer_size => '","{- $target{pointer_size} -}","'," |
| 647 | WRITE CONFIG ");" |
| 648 | WRITE CONFIG "our %target = ();" |
| 649 | WRITE CONFIG "our %disabled = ();" |
| 650 | WRITE CONFIG "our %withargs = ();" |
| 651 | WRITE CONFIG "our %unified_info = ();" |
| 652 | WRITE CONFIG "1;" |
| 653 | CLOSE CONFIG |
| 654 | |
| 655 | install_html_docs : check_INSTALLTOP |
| 656 | sourcedir = F$PARSE("{- $sourcedir -}A.;","[]") - "]A.;" + ".DOC]" |
| 657 | $(PERL) {- sourcefile("util", "process_docs.pl") -} - |
| 658 | --sourcedir='sourcedir' --destdir=ossl_installroot:[HTML] - |
| 659 | --type=html |
| 660 | |
| 661 | check_INSTALLTOP : |
| 662 | @ IF "$(INSTALLTOP)" .EQS. "" THEN - |
| 663 | WRITE SYS$ERROR "INSTALLTOP should not be empty" |
| 664 | @ IF "$(INSTALLTOP)" .EQS. "" THEN - |
| 665 | EXIT %x10000002 |
| 666 | |
| 667 | # Helper targets ##################################################### |
| 668 | |
| 669 | # Developer targets ################################################## |
| 670 | |
| 671 | debug_logicals : |
| 672 | SH LOGICAL/PROC openssl,internal,ossl_installroot,ossl_dataroot |
| 673 | |
| 674 | # Building targets ################################################### |
| 675 | |
| 676 | configdata.pm : $(SRCDIR)Configure $(SRCDIR)config.com {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -} |
| 677 | perl configdata.pm -r |
| 678 | @ WRITE SYS$OUTPUT "*************************************************" |
| 679 | @ WRITE SYS$OUTPUT "*** ***" |
| 680 | @ WRITE SYS$OUTPUT "*** Please run the same mms command again ***" |
| 681 | @ WRITE SYS$OUTPUT "*** ***" |
| 682 | @ WRITE SYS$OUTPUT "*************************************************" |
| 683 | @ PIPE ( EXIT %X10000000 ) |
| 684 | |
| 685 | reconfigure reconf : |
| 686 | perl configdata.pm -r |
| 687 | |
| 688 | {- |
| 689 | use File::Basename; |
| 690 | use File::Spec::Functions qw/abs2rel rel2abs catfile catdir/; |
| 691 | |
| 692 | # Helper function to figure out dependencies on libraries |
| 693 | # It takes a list of library names and outputs a list of dependencies |
| 694 | sub compute_lib_depends { |
| 695 | if ($disabled{shared}) { |
| 696 | return map { $_ =~ /\.a$/ ? $`.".OLB" : $_.".OLB" } @_; |
| 697 | } |
| 698 | return map { $_ =~ /\.a$/ |
| 699 | ? $`.".OLB" |
lh | 758261d | 2023-07-13 05:52:04 -0700 | [diff] [blame^] | 700 | : $unified_info{sharednames}->{$_}.$shlibvariant.".EXE" } @_; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 701 | } |
| 702 | |
| 703 | # Helper function to deal with inclusion directory specs. |
| 704 | # We have to deal with two things: |
| 705 | # 1. comma separation and no possibility of trailing comma |
| 706 | # 2. no inclusion directories given at all |
| 707 | # 3. long compiler command lines |
| 708 | # To resolve 1, we need to iterate through the sources of inclusion |
| 709 | # directories, and only add a comma when needed. |
| 710 | # To resolve 2, we need to have a variable that will hold the whole |
| 711 | # inclusion qualifier, or be the empty string if there are no inclusion |
| 712 | # directories. That's the symbol 'qual_includes' that's used in CPPFLAGS |
| 713 | # To resolve 3, we creata a logical name TMP_INCLUDES: to hold the list |
| 714 | # of inclusion directories. |
| 715 | # |
| 716 | # This function returns a list of two lists, one being the collection of |
| 717 | # commands to execute before the compiler is called, and the other being |
| 718 | # the collection of commands to execute after. It takes as arguments the |
| 719 | # collection of strings to include as directory specs. |
| 720 | sub includes { |
| 721 | my @stuff = ( @_ ); |
| 722 | my @before = ( |
| 723 | 'qual_includes :=', |
| 724 | ); |
| 725 | my @after = ( |
| 726 | 'DELETE/SYMBOL/LOCAL qual_includes', |
| 727 | ); |
| 728 | |
| 729 | if (scalar @stuff > 0) { |
| 730 | push @before, 'tmp_includes := '.shift(@stuff); |
| 731 | while (@stuff) { |
| 732 | push @before, 'tmp_add := '.shift(@stuff); |
| 733 | push @before, 'IF tmp_includes .NES. "" .AND. tmp_add .NES. "" THEN tmp_includes = tmp_includes + ","'; |
| 734 | push @before, 'tmp_includes = tmp_includes + tmp_add'; |
| 735 | } |
| 736 | push @before, "IF tmp_includes .NES. \"\" THEN DEFINE tmp_includes 'tmp_includes'"; |
| 737 | push @before, 'IF tmp_includes .NES. "" THEN qual_includes := /INCLUDE=(tmp_includes:)'; |
| 738 | push @before, 'DELETE/SYMBOL/LOCAL tmp_includes'; |
| 739 | push @before, 'DELETE/SYMBOL/LOCAL tmp_add'; |
| 740 | push @after, 'DEASSIGN tmp_includes:' |
| 741 | } |
| 742 | return ([ @before ], [ @after ]); |
| 743 | } |
| 744 | |
| 745 | sub generatesrc { |
| 746 | my %args = @_; |
| 747 | (my $target = $args{src}) =~ s/\.[sS]$/.asm/; |
| 748 | my $generator = join(" ", @{$args{generator}}); |
| 749 | my $generator_incs = join("", map { ' "-I'.$_.'"' } @{$args{generator_incs}}); |
| 750 | my $deps = join(", -\n\t\t", @{$args{generator_deps}}, @{$args{deps}}); |
| 751 | |
| 752 | if ($target !~ /\.asm$/) { |
| 753 | if ($args{generator}->[0] =~ m|^.*\.in$|) { |
| 754 | my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, |
| 755 | "util", "dofile.pl")), |
| 756 | rel2abs($config{builddir})); |
| 757 | return <<"EOF"; |
| 758 | $target : $args{generator}->[0] $deps |
| 759 | \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile \\ |
| 760 | "-o$target{build_file}" $generator > \$\@ |
| 761 | EOF |
| 762 | } else { |
| 763 | return <<"EOF"; |
| 764 | $target : $args{generator}->[0] $deps |
| 765 | \$(PERL)$generator_incs $generator > \$\@ |
| 766 | EOF |
| 767 | } |
| 768 | } else { |
| 769 | if ($args{generator}->[0] =~ /\.pl$/) { |
| 770 | $generator = '$(PERL)'.$generator_incs.' '.$generator; |
| 771 | } elsif ($args{generator}->[0] =~ /\.S$/) { |
| 772 | $generator = undef; |
| 773 | } else { |
| 774 | die "Generator type for $src unknown: $generator\n"; |
| 775 | } |
| 776 | |
| 777 | my $cppflags = { |
| 778 | lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)', |
| 779 | dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)', |
| 780 | bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)' |
| 781 | } -> {$args{intent}}; |
| 782 | my @incs_cmds = includes({ lib => '$(LIB_INCLUDES)', |
| 783 | dso => '$(DSO_INCLUDES)', |
| 784 | bin => '$(BIN_INCLUDES)' } -> {$args{intent}}, |
| 785 | '$(CNF_INCLUDES)', |
| 786 | '$(INCLUDES)', |
| 787 | @{$args{incs}}); |
| 788 | my $incs_on = join("\n\t\@ ", @{$incs_cmds[0]}) || '!'; |
| 789 | my $incs_off = join("\n\t\@ ", @{$incs_cmds[1]}) || '!'; |
| 790 | if (defined($generator)) { |
| 791 | # If the target is named foo.S in build.info, we want to |
| 792 | # end up generating foo.s in two steps. |
| 793 | if ($args{src} =~ /\.S$/) { |
| 794 | return <<"EOF"; |
| 795 | $target : $args{generator}->[0] $deps |
| 796 | $generator \$\@-S |
| 797 | \@ $incs_on |
| 798 | PIPE \$(CPP) $cppflags \$\@-S | - |
| 799 | \$(PERL) -ne "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" > \$\@-i |
| 800 | \@ $incs_off |
| 801 | RENAME \$\@-i \$\@ |
| 802 | DELETE \$\@-S; |
| 803 | EOF |
| 804 | } |
| 805 | # Otherwise.... |
| 806 | return <<"EOF"; |
| 807 | $target : $args{generator}->[0] $deps |
| 808 | $generator \$\@ |
| 809 | EOF |
| 810 | } |
| 811 | return <<"EOF"; |
| 812 | $target : $args{generator}->[0] $deps |
| 813 | \@ $incs_on |
| 814 | SHOW SYMBOL qual_includes |
| 815 | PIPE \$(CPP) $cppflags $args{generator}->[0] | - |
| 816 | \$(PERL) "-ne" "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" > \$\@ |
| 817 | \@ $incs_off |
| 818 | EOF |
| 819 | } |
| 820 | } |
| 821 | |
| 822 | sub src2obj { |
| 823 | my %args = @_; |
| 824 | my @srcs = map { (my $x = $_) =~ s/\.s$/.asm/; $x |
| 825 | } ( @{$args{srcs}} ); |
| 826 | (my $obj = $args{obj}) =~ s|\.o$||; |
| 827 | my $deps = join(", -\n\t\t", @srcs, @{$args{deps}}); |
| 828 | |
| 829 | # Because VMS C isn't very good at combining a /INCLUDE path with |
| 830 | # #includes having a relative directory (like '#include "../foo.h"), |
| 831 | # the best choice is to move to the first source file's intended |
| 832 | # directory before compiling, and make sure to write the object file |
| 833 | # in the correct position (important when the object tree is other |
| 834 | # than the source tree). |
| 835 | my $forward = dirname($args{srcs}->[0]); |
| 836 | my $backward = abs2rel(rel2abs("."), rel2abs($forward)); |
| 837 | my $objd = abs2rel(rel2abs(dirname($obj)), rel2abs($forward)); |
| 838 | my $objn = basename($obj); |
| 839 | my $srcs = |
| 840 | join(", ", map { abs2rel(rel2abs($_), rel2abs($forward)) } @srcs); |
| 841 | my $before = $unified_info{before}->{$obj.".OBJ"} || "\@ !"; |
| 842 | my $after = $unified_info{after}->{$obj.".OBJ"} || "\@ !"; |
| 843 | |
| 844 | my $cflags; |
| 845 | if ($args{installed}) { |
| 846 | $cflags = { lib => '$(LIB_CFLAGS)', |
| 847 | dso => '$(DSO_CFLAGS)', |
| 848 | bin => '$(BIN_CFLAGS)' } -> {$args{intent}}; |
| 849 | } else { |
| 850 | $cflags = { lib => '$(NO_INST_LIB_CFLAGS)', |
| 851 | dso => '$(NO_INST_DSO_CFLAGS)', |
| 852 | bin => '$(NO_INST_BIN_CFLAGS)' } -> {$args{intent}}; |
| 853 | } |
| 854 | $cflags .= { lib => '$(LIB_CPPFLAGS)', |
| 855 | dso => '$(DSO_CPPFLAGS)', |
| 856 | bin => '$(BIN_CPPFLAGS)' } -> {$args{intent}}; |
| 857 | my $asflags = { lib => ' $(LIB_ASFLAGS)', |
| 858 | dso => ' $(DSO_ASFLAGS)', |
| 859 | bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}}; |
| 860 | |
| 861 | my @incs_cmds = includes({ lib => '$(LIB_INCLUDES)', |
| 862 | dso => '$(DSO_INCLUDES)', |
| 863 | bin => '$(BIN_INCLUDES)' } -> {$args{intent}}, |
| 864 | '$(INCLUDES)', |
| 865 | map { |
| 866 | file_name_is_absolute($_) |
| 867 | ? $_ : catdir($backward,$_) |
| 868 | } @{$args{incs}}); |
| 869 | my $incs_on = join("\n\t\@ ", @{$incs_cmds[0]}) || '!'; |
| 870 | my $incs_off = join("\n\t\@ ", @{$incs_cmds[1]}) || '!'; |
| 871 | |
| 872 | if ($srcs[0] =~ /\.asm$/) { |
| 873 | return <<"EOF"; |
| 874 | $obj.OBJ : $deps |
| 875 | ${before} |
| 876 | SET DEFAULT $forward |
| 877 | \$(AS) $asflags \$(ASOUTFLAG)${objd}${objn}.OBJ $srcs |
| 878 | SET DEFAULT $backward |
| 879 | ${after} |
| 880 | - PURGE $obj.OBJ |
| 881 | EOF |
| 882 | } elsif ($srcs[0] =~ /.S$/) { |
| 883 | return <<"EOF"; |
| 884 | $obj.OBJ : $deps |
| 885 | ${before} |
| 886 | SET DEFAULT $forward |
| 887 | \@ $incs_on |
| 888 | PIPE \$(CPP) ${cflags} $srcs | - |
| 889 | \$(PERL) -ne "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" - |
| 890 | > ${objd}${objn}.asm |
| 891 | \@ $incs_off |
| 892 | SET DEFAULT $backward |
| 893 | ${after} |
| 894 | \$(AS) $asflags \$(ASOUTFLAG)$obj.OBJ $obj.asm |
| 895 | - PURGE $obj.OBJ |
| 896 | EOF |
| 897 | } |
| 898 | |
| 899 | my $depbuild = $disabled{makedepend} ? "" |
| 900 | : " /MMS=(FILE=${objd}${objn}.D,TARGET=$obj.OBJ)"; |
| 901 | |
| 902 | return <<"EOF"; |
| 903 | $obj.OBJ : $deps |
| 904 | ${before} |
| 905 | SET DEFAULT $forward |
| 906 | \@ $incs_on |
| 907 | \$(CC) ${cflags}${depbuild} /OBJECT=${objd}${objn}.OBJ /REPOSITORY=$backward $srcs |
| 908 | \@ $incs_off |
| 909 | SET DEFAULT $backward |
| 910 | ${after} |
| 911 | - PURGE $obj.OBJ |
| 912 | EOF |
| 913 | } |
| 914 | sub libobj2shlib { |
| 915 | my %args = @_; |
| 916 | my $lib = $args{lib}; |
lh | 758261d | 2023-07-13 05:52:04 -0700 | [diff] [blame^] | 917 | my $shlib = $args{shlib}.$shlibvariant; |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 918 | my $libd = dirname($lib); |
| 919 | my $libn = basename($lib); |
| 920 | my @objs = map { (my $x = $_) =~ s|\.o$|.OBJ|; $x } |
| 921 | grep { $_ =~ m|\.o$| } |
| 922 | @{$args{objs}}; |
| 923 | my @defs = grep { $_ =~ /\.opt$/ } @{$args{objs}}; |
| 924 | my @deps = compute_lib_depends(@{$args{deps}}); |
| 925 | die "More than one symbol vector" if scalar @defs > 1; |
| 926 | my $deps = join(", -\n\t\t", @defs, @deps); |
| 927 | my $shlib_target = $disabled{shared} ? "" : $target{shared_target}; |
| 928 | my $translatesyms_pl = abs2rel(rel2abs(catfile($config{sourcedir}, |
| 929 | "VMS", "translatesyms.pl")), |
| 930 | rel2abs($config{builddir})); |
| 931 | # The "[]" hack is because in .OPT files, each line inherits the |
| 932 | # previous line's file spec as default, so if no directory spec |
| 933 | # is present in the current line and the previous line has one that |
| 934 | # doesn't apply, you're in for a surprise. |
| 935 | my $write_opt1 = |
| 936 | join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_; |
| 937 | "WRITE OPT_FILE \"$x" } @objs). |
| 938 | "\""; |
| 939 | my $write_opt2 = |
| 940 | join("\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_; |
| 941 | $x =~ s|(\.EXE)|$1/SHARE|; |
| 942 | $x =~ s|(\.OLB)|$1/LIB|; |
| 943 | "WRITE OPT_FILE \"$x\"" } @deps) |
| 944 | || "\@ !"; |
| 945 | return <<"EOF" |
| 946 | $shlib.EXE : $lib.OLB $deps |
| 947 | \$(PERL) $translatesyms_pl \$(BLDDIR)CXX\$DEMANGLER_DB. < $defs[0] > $defs[0]-translated |
| 948 | OPEN/WRITE/SHARE=READ OPT_FILE $lib-components.OPT |
| 949 | $write_opt1 |
| 950 | $write_opt2 |
| 951 | CLOSE OPT_FILE |
| 952 | LINK \$(LIB_LDFLAGS)/SHARE=\$\@ $defs[0]-translated/OPT,- |
| 953 | $lib-components.OPT/OPT \$(LIB_EX_LIBS) |
| 954 | DELETE $defs[0]-translated;*,$lib-components.OPT;* |
| 955 | PURGE $shlib.EXE,$shlib.MAP |
| 956 | EOF |
| 957 | . ($config{target} =~ m|alpha| ? "" : <<"EOF" |
| 958 | SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@ |
| 959 | EOF |
| 960 | ); |
| 961 | } |
| 962 | sub obj2dso { |
| 963 | my %args = @_; |
| 964 | my $lib = $args{lib}; |
| 965 | my $libd = dirname($lib); |
| 966 | my $libn = basename($lib); |
| 967 | (my $libn_nolib = $libn) =~ s/^lib//; |
| 968 | my @objs = map { (my $x = $_) =~ s|\.o$|.OBJ|; $x } @{$args{objs}}; |
| 969 | my @deps = compute_lib_depends(@{$args{deps}}); |
| 970 | my $deps = join(", -\n\t\t", @objs, @deps); |
| 971 | my $shlib_target = $disabled{shared} ? "" : $target{shared_target}; |
| 972 | my $engine_opt = abs2rel(rel2abs(catfile($config{sourcedir}, |
| 973 | "VMS", "engine.opt")), |
| 974 | rel2abs($config{builddir})); |
| 975 | # The "[]" hack is because in .OPT files, each line inherits the |
| 976 | # previous line's file spec as default, so if no directory spec |
| 977 | # is present in the current line and the previous line has one that |
| 978 | # doesn't apply, you're in for a surprise. |
| 979 | my $write_opt1 = |
| 980 | join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_; |
| 981 | "WRITE OPT_FILE \"$x" } @objs). |
| 982 | "\""; |
| 983 | my $write_opt2 = |
| 984 | join("\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_; |
| 985 | $x =~ s|(\.EXE)|$1/SHARE|; |
| 986 | $x =~ s|(\.OLB)|$1/LIB|; |
| 987 | "WRITE OPT_FILE \"$x\"" } @deps) |
| 988 | || "\@ !"; |
| 989 | return <<"EOF" |
| 990 | $lib.EXE : $deps |
| 991 | OPEN/WRITE/SHARE=READ OPT_FILE $lib.OPT |
| 992 | TYPE $engine_opt /OUTPUT=OPT_FILE: |
| 993 | $write_opt1 |
| 994 | $write_opt2 |
| 995 | CLOSE OPT_FILE |
| 996 | LINK \$(DSO_LDFLAGS)/SHARE=\$\@ $lib.OPT/OPT \$(DSO_EX_LIBS) |
| 997 | - PURGE $lib.EXE,$lib.OPT,$lib.MAP |
| 998 | EOF |
| 999 | . ($config{target} =~ m|alpha| ? "" : <<"EOF" |
| 1000 | SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@ |
| 1001 | EOF |
| 1002 | ); |
| 1003 | } |
| 1004 | sub obj2lib { |
| 1005 | my %args = @_; |
| 1006 | (my $lib = $args{lib}) =~ s/\.a$//; |
| 1007 | my @objs = map { (my $x = $_) =~ s|\.o$|.OBJ|; $x } @{$args{objs}}; |
| 1008 | my $objs = join(", -\n\t\t", @objs); |
| 1009 | my $fill_lib = join("\n\t", (map { "LIBRARY/REPLACE $lib.OLB $_" } |
| 1010 | @objs)); |
| 1011 | return <<"EOF"; |
| 1012 | $lib.OLB : $objs |
| 1013 | LIBRARY/CREATE/OBJECT $lib.OLB |
| 1014 | $fill_lib |
| 1015 | - PURGE $lib.OLB |
| 1016 | EOF |
| 1017 | } |
| 1018 | sub obj2bin { |
| 1019 | my %args = @_; |
| 1020 | my $bin = $args{bin}; |
| 1021 | my $bind = dirname($bin); |
| 1022 | my $binn = basename($bin); |
| 1023 | my @objs = map { (my $x = $_) =~ s|\.o$|.OBJ|; $x } @{$args{objs}}; |
| 1024 | my $objs = join(",", @objs); |
| 1025 | my @deps = compute_lib_depends(@{$args{deps}}); |
| 1026 | my $deps = join(", -\n\t\t", @objs, @deps); |
| 1027 | |
| 1028 | my $olb_count = scalar grep(m|\.OLB$|, @deps); |
| 1029 | my $analyse_objs = "@ !"; |
| 1030 | if ($olb_count > 0) { |
| 1031 | my $analyse_quals = |
| 1032 | $config{target} =~ m|alpha| ? "/GSD" : "/SECTIONS=SYMTAB"; |
| 1033 | $analyse_objs = "- pipe ANALYSE/OBJECT$analyse_quals $objs | SEARCH SYS\$INPUT \"\"\"main\"\"\" ; nomain = \$severity .NE. 1" |
| 1034 | } |
| 1035 | # The "[]" hack is because in .OPT files, each line inherits the |
| 1036 | # previous line's file spec as default, so if no directory spec |
| 1037 | # is present in the current line and the previous line has one that |
| 1038 | # doesn't apply, you're in for a surprise. |
| 1039 | my $write_opt1 = |
| 1040 | join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_; |
| 1041 | "\@ WRITE OPT_FILE \"$x" } @objs). |
| 1042 | "\""; |
| 1043 | my $write_opt2 = |
| 1044 | join("\n\t", map { my @lines = (); |
| 1045 | my $x = $_ =~ /\[/ ? $_ : "[]".$_; |
| 1046 | if ($x =~ m|\.EXE$|) { |
| 1047 | push @lines, "\@ WRITE OPT_FILE \"$x/SHARE\""; |
| 1048 | } elsif ($x =~ m|\.OLB$|) { |
| 1049 | (my $l = $x) =~ s/\W/_/g; |
| 1050 | push @lines, |
| 1051 | "\@ IF nomain THEN WRITE OPT_FILE \"$x/LIB\$(INCLUDE_MAIN_$l)\"", |
| 1052 | "\@ IF .NOT. nomain THEN WRITE OPT_FILE \"$x/LIB\"" |
| 1053 | } |
| 1054 | @lines |
| 1055 | } @deps) |
| 1056 | || "\@ !"; |
| 1057 | # The linking commands looks a bit complex, but it's for good reason. |
| 1058 | # When you link, say, foo.obj, bar.obj and libsomething.exe/share, and |
| 1059 | # bar.obj happens to have a symbol that also exists in libsomething.exe, |
| 1060 | # the linker will warn about it, loudly, and will then choose to pick |
| 1061 | # the first copy encountered (the one in bar.obj in this example). |
| 1062 | # On Unix and on Windows, the corresponding maneuvre goes through |
| 1063 | # silently with the same effect. |
| 1064 | # With some test programs, made for checking the internals of OpenSSL, |
| 1065 | # we do this kind of linking deliberately, picking a few specific object |
| 1066 | # files from within [.crypto] or [.ssl] so we can reach symbols that are |
| 1067 | # otherwise unreachable (since the shareable images only exports the |
| 1068 | # symbols listed in [.util]*.num), and then with the shared libraries |
| 1069 | # themselves. So we need to silence the warning about multiply defined |
| 1070 | # symbols, to mimic the way linking work on Unix and Windows, and so |
| 1071 | # the build isn't interrupted (MMS stops when warnings are signaled, |
| 1072 | # by default), and so someone building doesn't have to worry where it |
| 1073 | # isn't necessary. If there are other warnings, however, we show them |
| 1074 | # and let it break the build. |
| 1075 | return <<"EOF" |
| 1076 | $bin.EXE : $deps |
| 1077 | $analyse_objs |
| 1078 | @ OPEN/WRITE/SHARE=READ OPT_FILE $bin.OPT |
| 1079 | $write_opt1 |
| 1080 | $write_opt2 |
| 1081 | @ CLOSE OPT_FILE |
| 1082 | TYPE $bin.opt ! For debugging |
| 1083 | - pipe SPAWN/WAIT/NOLOG/OUT=$bin.LINKLOG - |
| 1084 | LINK \$(BIN_LDFLAGS)/EXEC=\$\@ $bin.OPT/OPT \$(BIN_EX_LIBS) ; - |
| 1085 | link_status = \$status ; link_severity = link_status .AND. 7 |
| 1086 | @ search_severity = 1 |
| 1087 | -@ IF link_severity .EQ. 0 THEN - |
| 1088 | pipe SEARCH $bin.LINKLOG "%","-"/MATCH=AND | - |
| 1089 | SPAWN/WAIT/NOLOG/OUT=NLA0: - |
| 1090 | SEARCH SYS\$INPUT: "-W-MULDEF,"/MATCH=NOR ; - |
| 1091 | search_severity = \$severity |
| 1092 | @ ! search_severity is 3 when the last search didn't find any matching |
| 1093 | @ ! string: %SEARCH-I-NOMATCHES, no strings matched |
| 1094 | @ ! If that was the result, we pretend linking got through without |
| 1095 | @ ! fault or warning. |
| 1096 | @ IF search_severity .EQ. 3 THEN link_severity = 1 |
| 1097 | @ ! At this point, if link_severity shows that there was a fault |
| 1098 | @ ! or warning, make sure to restore the linking status. |
| 1099 | -@ IF .NOT. link_severity THEN TYPE $bin.LINKLOG |
| 1100 | -@ DELETE $bin.LINKLOG;* |
| 1101 | @ IF .NOT. link_severity THEN SPAWN/WAIT/NOLOG EXIT 'link_status' |
| 1102 | - PURGE $bin.EXE,$bin.OPT |
| 1103 | EOF |
| 1104 | . ($config{target} =~ m|alpha| ? "" : <<"EOF" |
| 1105 | SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@ |
| 1106 | EOF |
| 1107 | ); |
| 1108 | } |
| 1109 | sub in2script { |
| 1110 | my %args = @_; |
| 1111 | my $script = $args{script}; |
| 1112 | return "" if grep { $_ eq $script } @{$args{sources}}; # No overwrite! |
| 1113 | my $sources = join(" ", @{$args{sources}}); |
| 1114 | my $dofile = abs2rel(rel2abs(catfile($config{sourcedir}, |
| 1115 | "util", "dofile.pl")), |
| 1116 | rel2abs($config{builddir})); |
| 1117 | return <<"EOF"; |
| 1118 | $script : $sources |
| 1119 | \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile - |
| 1120 | "-o$target{build_file}" $sources > $script |
| 1121 | SET FILE/PROT=(S:RWED,O:RWED,G:RE,W:RE) $script |
| 1122 | PURGE $script |
| 1123 | EOF |
| 1124 | } |
| 1125 | "" # Important! This becomes part of the template result. |
| 1126 | -} |