descrip.mms.tmpl 60 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413
  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. use OpenSSL::Util;
  8. (our $osslprefix_q = platform->osslprefix()) =~ s/\$/\\\$/;
  9. our $sover_dirname = platform->shlib_version_as_filename();
  10. our $osslver = sprintf "%02d", split(/\./, $config{version});
  11. our $sourcedir = $config{sourcedir};
  12. our $builddir = $config{builddir};
  13. sub make_unix_path {
  14. # Split the native path
  15. (my $vol, my $dirs, my $file) = File::Spec->splitpath($_[0]);
  16. my @dirs = File::Spec->splitdir($dirs);
  17. # Reassemble it as a Unix path
  18. $vol =~ s|:$||;
  19. return File::Spec::Unix->catpath(
  20. '', File::Spec::Unix->catdir('', $vol ? $vol : (), @dirs), $file);
  21. }
  22. sub sourcefile {
  23. catfile($sourcedir, @_);
  24. }
  25. sub buildfile {
  26. catfile($builddir, @_);
  27. }
  28. sub sourcedir {
  29. catdir($sourcedir, @_);
  30. }
  31. sub builddir {
  32. catdir($builddir, @_);
  33. }
  34. sub tree {
  35. (my $x = shift) =~ s|\]$|...]|;
  36. $x
  37. }
  38. # Because we need to make two computations of these data,
  39. # we store them in arrays for reuse
  40. our @libs =
  41. map { platform->staticname($_) }
  42. @{$unified_info{libraries}};
  43. our @shlibs =
  44. map { platform->sharedname($_) // () }
  45. @{$unified_info{libraries}};
  46. our @install_libs =
  47. map { platform->staticname($_) }
  48. grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
  49. @{$unified_info{libraries}};
  50. our @install_shlibs =
  51. map { platform->sharedname($_) // () }
  52. grep { !$unified_info{attributes}->{libraries}->{$_}->{noinst} }
  53. @{$unified_info{libraries}};
  54. our @install_engines =
  55. grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
  56. && $unified_info{attributes}->{modules}->{$_}->{engine} }
  57. @{$unified_info{modules}};
  58. our @install_modules =
  59. grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
  60. && !$unified_info{attributes}->{modules}->{$_}->{engine}
  61. && !$unified_info{attributes}->{modules}->{$_}->{fips} }
  62. @{$unified_info{modules}};
  63. our @install_fipsmodules =
  64. grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
  65. && $unified_info{attributes}->{modules}->{$_}->{fips} }
  66. @{$unified_info{modules}};
  67. our @install_programs =
  68. grep { !$unified_info{attributes}->{programs}->{$_}->{noinst} }
  69. @{$unified_info{programs}};
  70. our @install_bin_scripts =
  71. grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
  72. && !$unified_info{attributes}->{scripts}->{$_}->{misc} }
  73. @{$unified_info{scripts}};
  74. our @install_misc_scripts =
  75. grep { !$unified_info{attributes}->{scripts}->{$_}->{noinst}
  76. && $unified_info{attributes}->{scripts}->{$_}->{misc} }
  77. @{$unified_info{scripts}};
  78. # Configured flags
  79. our @cnf_asflags = ($target{asflags} || (), @{$config{asflags}});
  80. our @cnf_defines = (@{$target{defines}}, @{$config{defines}});
  81. our @cnf_includes = (@{$target{includes}}, @{$config{includes}});
  82. our @cnf_cppflags = ($target{cppflags} || (), @{$config{cppflags}});
  83. our @cnf_cflags = ($target{cflags} || (), @{$config{cflags}});
  84. our @cnf_cxxflags = ($target{cxxflags} || (), @{$config{cxxflags}});
  85. our @cnf_ldflags = ($target{lflags} || (), @{$config{lflags}});
  86. our @cnf_ex_libs = (map{ ",$_" } @{$target{ex_libs}}, @{$config{ex_libs}});
  87. # Variables starting with $lib_ are used to build library object files
  88. # and shared libraries.
  89. # Variables starting with $dso_ are used to build DSOs and their object files.
  90. # Variables starting with $bin_ are used to build programs and their object
  91. # files.
  92. # The following array is special and is treated separately from the rest of
  93. # the lib_ variables.
  94. our @lib_cppincludes = (@{$target{lib_includes}}, @{$target{shared_includes}},
  95. @{$config{lib_includes}}, @{$config{shared_includes}},
  96. @cnf_includes);
  97. our $lib_cppdefines =
  98. join(',', @{$target{lib_defines}}, @{$target{shared_defines}},
  99. @{$config{lib_defines}}, @{$config{shared_defines}},
  100. @cnf_defines,
  101. 'OPENSSLDIR="""$(OPENSSLDIR_C)"""',
  102. 'ENGINESDIR="""$(ENGINESDIR_C)"""',
  103. 'MODULESDIR="""$(MODULESDIR_C)"""'
  104. )
  105. . '$(DEFINES)'
  106. . "'extradefines'";
  107. our $lib_asflags =
  108. join(' ', $target{lib_asflags} || (), @{$config{lib_asflags}},
  109. @cnf_asflags, '$(ASFLAGS)');
  110. our $lib_cppflags =
  111. join('', $target{lib_cppflags} || (), $target{shared_cppflags} || (),
  112. @{$config{lib_cppflags}}, @{$config{shared_cppflag}},
  113. @cnf_cppflags, '/DEFINE=('.$lib_cppdefines.')', '$(CPPFLAGS)');
  114. my @lib_cflags = ( $target{lib_cflags} // () );
  115. my @lib_cflags_no_inst = ( $target{no_inst_lib_cflags} // @lib_cflags );
  116. my @lib_cflags_cont = ( $target{shared_cflag} || (),
  117. @{$config{lib_cflags}}, @{$config{shared_cflag}},
  118. @cnf_cflags, '$(CFLAGS)');
  119. our $lib_cflags = join('', @lib_cflags, @lib_cflags_cont );
  120. our $lib_cflags_no_inst = join('', @lib_cflags_no_inst, @lib_cflags_cont );
  121. our $lib_ldflags =
  122. join('', $target{lib_lflags} || (), $target{shared_ldflag} || (),
  123. @{$config{lib_lflags}}, @{$config{shared_ldflag}},
  124. @cnf_ldflags, '$(LDFLAGS)');
  125. our $lib_ex_libs = join('', @cnf_ex_libs, '$(EX_LIBS)');
  126. # The following array is special and is treated separately from the rest of
  127. # the dso_ variables.
  128. our @dso_cppincludes = (@{$target{dso_includes}}, @{$target{module_includes}},
  129. @{$config{dso_includes}}, @{$config{module_includes}},
  130. @cnf_includes);
  131. our $dso_cppdefines =
  132. join(',', @{$target{dso_defines}}, @{$target{module_defines}},
  133. @{$config{dso_defines}}, @{$config{module_defines}},
  134. @cnf_defines,
  135. )
  136. . '$(DEFINES)'
  137. . "'extradefines'";
  138. our $dso_asflags =
  139. join(' ', $target{dso_asflags} || (), $target{module_asflags} || (),
  140. @{$config{dso_asflags}}, @{$config{module_asflags}},
  141. @cnf_asflags, '$(ASFLAGS)');
  142. our $dso_cppflags =
  143. join('', $target{dso_cppflags} || (), $target{module_cppflags} || (),
  144. @{$config{dso_cppflags}}, @{$config{module_cppflag}},
  145. @cnf_cppflags,
  146. '/DEFINE=('.$dso_cppdefines.')',
  147. '$(CPPFLAGS)');
  148. my @dso_cflags = ( $target{dso_cflags} // () );
  149. my @dso_cflags_no_inst = ( $target{no_inst_dso_cflags} // @dso_cflags );
  150. my @dso_cflags_cont = ( $target{module_cflag} || (),
  151. @{$config{dso_cflags}}, @{$config{module_cflag}},
  152. @cnf_cflags, '$(CFLAGS)');
  153. our $dso_cflags = join('', @dso_cflags, @dso_cflags_cont );
  154. our $dso_cflags_no_inst = join('', @dso_cflags_no_inst, @dso_cflags_cont );
  155. our $dso_ldflags =
  156. join('', $target{dso_lflags} || (), $target{module_ldflag} || (),
  157. @{$config{dso_lflags}}, @{$config{module_ldflag}},
  158. @cnf_ldflags, '$(LDFLAGS)');
  159. our $dso_ex_libs = join('', @cnf_ex_libs, '$(EX_LIBS)');
  160. # The following array is special and is treated separately from the rest of
  161. # the bin_ variables.
  162. our @bin_cppincludes = (@{$target{bin_includes}},
  163. @{$config{bin_includes}},
  164. @cnf_includes);
  165. our $bin_cppdefines =
  166. join(',', @{$target{bin_defines}},
  167. @{$config{bin_defines}},
  168. @cnf_defines,
  169. )
  170. . '$(DEFINES)'
  171. . "'extradefines'";
  172. our $bin_asflags =
  173. join(' ', $target{bin_asflags} || (),
  174. @{$config{bin_asflags}},
  175. @cnf_asflags, '$(ASFLAGS)');
  176. our $bin_cppflags =
  177. join('', $target{bin_cppflags} || (),
  178. @{$config{bin_cppflags}},
  179. @cnf_cppflags,
  180. '/DEFINE=('.$bin_cppdefines.')',
  181. '$(CPPFLAGS)');
  182. my @bin_cflags = ( $target{bin_cflags} // () );
  183. my @bin_cflags_no_inst = ( $target{no_inst_bin_cflags} // @bin_cflags );
  184. my @bin_cflags_cont = ( @{$config{bin_cflags}},
  185. @cnf_cflags, '$(CFLAGS)');
  186. our $bin_cflags = join('', @bin_cflags, @bin_cflags_cont );
  187. our $bin_cflags_no_inst = join('', @bin_cflags_no_inst, @bin_cflags_cont );
  188. our $bin_ldflags =
  189. join('', $target{bin_lflags} || (),
  190. @{$config{bin_lflags}},
  191. @cnf_ldflags, '$(LDFLAGS)');
  192. our $bin_ex_libs = join('', @cnf_ex_libs, '$(EX_LIBS)');
  193. # This is a horrible hack, but is needed because recursive inclusion of files
  194. # in different directories does not work well with VMS C. We try to help by
  195. # specifying extra relative directories. They must always be in Unix format,
  196. # relative to the directory where the .c file is located. The logic is that
  197. # any inclusion, merged with one of these relative directories, will find the
  198. # requested inclusion file.
  199. foreach (grep /\[\.crypto\.async\.arch\].*\.o$/, keys %{$unified_info{sources}}) {
  200. my $obj = platform->obj($_);
  201. push @{$unified_info{includes_extra}->{$obj}}, qw(../);
  202. }
  203. foreach (grep /\[\.crypto\.ec\.curve448\].*?\.o$/, keys %{$unified_info{sources}}) {
  204. my $obj = platform->obj($_);
  205. push @{$unified_info{includes_extra}->{$obj}}, qw(./arch_32 ./arch64);
  206. }
  207. foreach (grep /\[\.crypto\.ec\.curve448.arch_(?:32|64)\].*?\.o$/, keys %{$unified_info{sources}}) {
  208. my $obj = platform->obj($_);
  209. push @{$unified_info{includes_extra}->{$obj}}, qw(../);
  210. }
  211. foreach (grep /\[\.ssl\.(?:record|statem)\].*?\.o$/, keys %{$unified_info{sources}}) {
  212. my $obj = platform->obj($_);
  213. # Most of the files in [.ssl.record] and [.ssl.statem] include
  214. # "../ssl_local.h", which includes things like "record/record.h".
  215. # Adding "../" as an inclusion directory helps making this sort of header
  216. # from these directories.
  217. push @{$unified_info{includes_extra}->{$obj}}, qw(../);
  218. }
  219. foreach (grep /\[\.test\].*?\.o$/, keys %{$unified_info{sources}}) {
  220. my $obj = platform->obj($_);
  221. push @{$unified_info{includes_extra}->{$obj}}, qw(../ssl ./helpers);
  222. }
  223. foreach (grep /\[\.test\.helpers\].*?\.o$/, keys %{$unified_info{sources}}) {
  224. my $obj = platform->obj($_);
  225. push @{$unified_info{includes_extra}->{$obj}}, qw(../../ssl);
  226. }
  227. # This makes sure things get built in the order they need
  228. # to. You're welcome.
  229. sub dependmagic {
  230. my $target = shift;
  231. return "$target : build_generated\n\t\pipe \$(MMS) \$(MMSQUALIFIERS) depend && \$(MMS) \$(MMSQUALIFIERS) _$target\n_$target";
  232. }
  233. "";
  234. -}
  235. PLATFORM={- $config{target} -}
  236. OPTIONS={- $config{options} -}
  237. CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
  238. SRCDIR={- $config{sourcedir} -}
  239. BLDDIR={- $config{builddir} -}
  240. FIPSKEY={- $config{FIPSKEY} -}
  241. # Allow both V and VERBOSE to indicate verbosity. This only applies
  242. # to testing.
  243. VERBOSE=$(V)
  244. VERBOSE_FAILURE=$(VF)
  245. VERSION={- "$config{full_version}" -}
  246. VERSION_NUMBER={- "$config{version}" -}
  247. MAJOR={- $config{major} -}
  248. MINOR={- $config{minor} -}
  249. SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
  250. SHLIB_TARGET={- $target{shared_target} -}
  251. LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @libs) -}
  252. SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @shlibs) -}
  253. MODULES={- join(", ", map { "-\n\t".$_.".EXE" }
  254. # Drop all modules that are dependencies, they will
  255. # be processed through their dependents
  256. grep { my $x = $_;
  257. !grep { grep { $_ eq $x } @$_ }
  258. values %{$unified_info{depends}} }
  259. @{$unified_info{modules}}) -}
  260. FIPSMODULE={- # We do some extra checking here, as there should be only one
  261. use File::Basename;
  262. our @fipsmodules =
  263. grep { !$unified_info{attributes}->{modules}->{$_}->{noinst}
  264. && $unified_info{attributes}->{modules}->{$_}->{fips} }
  265. @{$unified_info{modules}};
  266. die "More that one FIPS module" if scalar @fipsmodules > 1;
  267. join(" ", map { platform->dso($_) } @fipsmodules) -}
  268. FIPSMODULENAME={- die "More that one FIPS module" if scalar @fipsmodules > 1;
  269. join(", ", map { basename(platform->dso($_)) } @fipsmodules) -}
  270. PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{programs}}) -}
  271. SCRIPTS={- join(", ", map { "-\n\t".$_ } @{$unified_info{scripts}}) -}
  272. {- output_off() if $disabled{makedepend}; "" -}
  273. DEPS={- our @deps = map { platform->isobj($_) ? platform->dep($_) : $_ }
  274. grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
  275. keys %{$unified_info{sources}};
  276. join(", ", map { "-\n\t".$_ } @deps); -}
  277. {- output_on() if $disabled{makedepend}; "" -}
  278. GENERATED_MANDATORY={- join(", ",
  279. map { "-\n\t".$_ } @{$unified_info{depends}->{""}} ) -}
  280. GENERATED_PODS={- # common0.tmpl provides @generated
  281. join(", ",
  282. map { my $x = $_;
  283. (
  284. grep {
  285. $unified_info{attributes}->{depends}
  286. ->{$x}->{$_}->{pod} // 0
  287. }
  288. keys %{$unified_info{attributes}->{depends}->{$x}}
  289. ) ? "-\n\t".$x : ();
  290. }
  291. @generated) -}
  292. GENERATED={- # common0.tmpl provides @generated
  293. join(", ", map { platform->convertext($_) } @generated) -}
  294. INSTALL_LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @install_libs) -}
  295. INSTALL_SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @install_shlibs) -}
  296. INSTALL_ENGINES={- join(", ", map { "-\n\t".$_.".EXE" } @install_engines) -}
  297. INSTALL_MODULES={- join(", ", map { "-\n\t".$_.".EXE" } @install_modules) -}
  298. INSTALL_FIPSMODULE={- join(", ", map { "-\n\t".$_.".EXE" } @install_fipsmodules) -}
  299. INSTALL_FIPSMODULECONF=[.providers]fipsmodule.cnf
  300. INSTALL_PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @install_programs) -}
  301. BIN_SCRIPTS={- join(", ", @install_bin_scripts) -}
  302. MISC_SCRIPTS={- join(", ", @install_misc_scripts) -}
  303. HTMLDOCS1={- join(", ", map { "-\n\t".$_ } @{$unified_info{htmldocs}->{man1}}) -}
  304. HTMLDOCS3={- join(", ", map { "-\n\t".$_ } @{$unified_info{htmldocs}->{man3}}) -}
  305. HTMLDOCS5={- join(", ", map { "-\n\t".$_ } @{$unified_info{htmldocs}->{man5}}) -}
  306. HTMLDOCS7={- join(", ", map { "-\n\t".$_ } @{$unified_info{htmldocs}->{man7}}) -}
  307. APPS_OPENSSL="{- use File::Spec::Functions;
  308. catfile("apps","openssl") -}"
  309. # DESTDIR is for package builders so that they can configure for, say,
  310. # SYS$COMMON:[OPENSSL] and yet have everything installed in STAGING:[USER].
  311. # In that case, configure with --prefix=SYS$COMMON:[OPENSSL] and then run
  312. # MMS with /MACROS=(DESTDIR=STAGING:[USER]). The result will end up in
  313. # STAGING:[USER.OPENSSL].
  314. # Normally it is left empty.
  315. DESTDIR=
  316. # Do not edit this manually. Use Configure --prefix=DIR to change this!
  317. INSTALLTOP={- our $installtop =
  318. catdir($config{prefix}) || "SYS\$COMMON:[OPENSSL]";
  319. $installtop -}
  320. SYSTARTUP={- catdir($installtop, '[.SYS$STARTUP]'); -}
  321. # This is the standard central area to store certificates, private keys...
  322. OPENSSLDIR={- catdir($config{openssldir}) or
  323. $config{prefix} ? catdir($config{prefix},"COMMON")
  324. : "SYS\$COMMON:[OPENSSL-COMMON]" -}
  325. # The same, but for C
  326. OPENSSLDIR_C={- platform->osslprefix() -}DATAROOT:[000000]
  327. # Where installed ENGINE modules reside, for C
  328. ENGINESDIR_C={- platform->osslprefix() -}ENGINES{- $sover_dirname.$target{pointer_size} -}:
  329. # Where modules reside, for C
  330. MODULESDIR_C={- platform->osslprefix() -}MODULES{- $target{pointer_size} -}:
  331. ##### User defined commands and flags ################################
  332. CC={- $config{CC} -}
  333. CPP={- $config{CPP} -}
  334. DEFINES={- our $defines = join('', map { ",$_" } @{$config{CPPDEFINES}}) -}
  335. #INCLUDES={- our $includes = join(',', @{$config{CPPINCLUDES}}) -}
  336. CPPFLAGS={- our $cppflags = join('', @{$config{CPPFLAGS}}) -}
  337. CFLAGS={- join('', @{$config{CFLAGS}}) -}
  338. LDFLAGS={- join('', @{$config{LFLAGS}}) -}
  339. EX_LIBS={- join('', map { ",$_" } @{$config{LDLIBS}}) -}
  340. PERL={- $config{PERL} -}
  341. AS={- $config{AS} -}
  342. ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
  343. ##### Special command flags ##########################################
  344. ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
  345. PERLASM_SCHEME={- $target{perlasm_scheme} -}
  346. # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
  347. CPPFLAGS_Q={- (my $c = $lib_cppflags.$cppflags) =~ s|"|""|g;
  348. (my $d = $lib_cppdefines) =~ s|"|""|g;
  349. my $i = join(',', @lib_cppincludes || (), '$(INCLUDES)');
  350. my $x = $c;
  351. $x .= "/INCLUDE=($i)" if $i;
  352. $x .= "/DEFINE=($d)" if $d;
  353. $x; -}
  354. # .FIRST and .LAST are special targets with MMS and MMK.
  355. NODEBUG=@
  356. .FIRST :
  357. {- join( "\n \$(NODEBUG) ", @{ $target{setup_commands} // [] },
  358. '!' ) -}
  359. $(NODEBUG) sourcetop = F$PARSE("$(SRCDIR)","[]A.;",,,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;" + ".]"
  360. $(NODEBUG) DEFINE ossl_sourceroot 'sourcetop'
  361. $(NODEBUG) !
  362. $(NODEBUG) staging_dir = "$(DESTDIR)"
  363. $(NODEBUG) staging_instdir = ""
  364. $(NODEBUG) staging_datadir = ""
  365. $(NODEBUG) IF staging_dir .NES. "" THEN -
  366. staging_instdir = F$PARSE("A.;",staging_dir,"[]",,"SYNTAX_ONLY")
  367. $(NODEBUG) IF staging_instdir - "]A.;" .NES. staging_instdir THEN -
  368. staging_instdir = staging_instdir - "]A.;" + ".OPENSSL-INSTALL]"
  369. $(NODEBUG) IF staging_instdir - "A.;" .NES. staging_instdir THEN -
  370. staging_instdir = staging_instdir - "A.;" + "[OPENSSL-INSTALL]"
  371. $(NODEBUG) IF staging_dir .NES. "" THEN -
  372. staging_datadir = F$PARSE("A.;",staging_dir,"[]",,"SYNTAX_ONLY")
  373. $(NODEBUG) IF staging_datadir - "]A.;" .NES. staging_datadir THEN -
  374. staging_datadir = staging_datadir - "]A.;" + ".OPENSSL-COMMON]"
  375. $(NODEBUG) IF staging_datadir - "A.;" .NES. staging_datadir THEN -
  376. staging_datadir = staging_datadir - "A.;" + "[OPENSSL-COMMON]"
  377. $(NODEBUG) !
  378. $(NODEBUG) ! Installation logical names
  379. $(NODEBUG) !
  380. $(NODEBUG) ! This also creates a few DCL variables that are used for
  381. $(NODEBUG) ! the "install_msg" target.
  382. $(NODEBUG) !
  383. $(NODEBUG) installroot = F$PARSE(staging_instdir,"$(INSTALLTOP)","[]A.;",,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;"
  384. $(NODEBUG) installtop = installroot + ".]"
  385. $(NODEBUG) dataroot = F$PARSE(staging_datadir,"$(OPENSSLDIR)","[]A.;",,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;"
  386. $(NODEBUG) datatop = dataroot + ".]"
  387. $(NODEBUG) DEFINE ossl_installroot 'installtop'
  388. $(NODEBUG) DEFINE ossl_dataroot 'datatop'
  389. $(NODEBUG) !
  390. $(NODEBUG) ! Override disturbing system logicals. We can't deassign
  391. $(NODEBUG) ! them, so we create it instead. This is an unfortunate
  392. $(NODEBUG) ! necessity.
  393. $(NODEBUG) !
  394. $(NODEBUG) openssl_inc1 = F$PARSE("[.include.openssl]","A.;",,,"syntax_only") - "A.;"
  395. $(NODEBUG) openssl_inc2 = F$PARSE("sourcetop:[include.openssl]","A.;",,,"SYNTAX_ONLY") - "A.;"
  396. $(NODEBUG) DEFINE openssl 'openssl_inc1','openssl_inc2'
  397. $(NODEBUG) !
  398. $(NODEBUG) ! Figure out the architecture
  399. $(NODEBUG) !
  400. $(NODEBUG) arch = f$edit( f$getsyi( "arch_name"), "upcase")
  401. $(NODEBUG) !
  402. $(NODEBUG) ! Set up logical names for the libraries, so LINK and
  403. $(NODEBUG) ! running programs can use them.
  404. $(NODEBUG) !
  405. $(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEFINE ".uc($_)." 'F\$ENV(\"DEFAULT\")'".uc($_)."\$(SHLIB_EXT)" } @shlibs) || "!" -}
  406. .LAST :
  407. $(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEASSIGN ".uc($_) } @shlibs) || "!" -}
  408. $(NODEBUG) DEASSIGN openssl
  409. $(NODEBUG) DEASSIGN ossl_dataroot
  410. $(NODEBUG) DEASSIGN ossl_installroot
  411. $(NODEBUG) DEASSIGN ossl_sourceroot
  412. .DEFAULT :
  413. @ ! MMS cannot handle no actions...
  414. # The main targets ###################################################
  415. {- dependmagic('build_sw'); -} : build_libs_nodep, build_modules_nodep, build_programs_nodep
  416. {- dependmagic('build_libs'); -} : build_libs_nodep
  417. {- dependmagic('build_modules'); -} : build_modules_nodep
  418. {- dependmagic('build_programs'); -} : build_programs_nodep
  419. build_generated_pods : $(GENERATED_PODS)
  420. build_docs : build_html_docs
  421. build_html_docs : $(HTMLDOCS1) $(HTMLDOCS3) $(HTMLDOCS5) $(HTMLDOCS7)
  422. build_generated : $(GENERATED_MANDATORY)
  423. build_libs_nodep : $(LIBS), $(SHLIBS)
  424. build_modules_nodep : $(MODULES)
  425. build_programs_nodep : $(PROGRAMS), $(SCRIPTS)
  426. # Kept around for backward compatibility
  427. build_apps build_tests : build_programs
  428. # Convenience target to prebuild all generated files, not just the mandatory
  429. # ones
  430. build_all_generated : $(GENERATED_MANDATORY) $(GENERATED) build_docs
  431. @ ! {- output_off() if $disabled{makedepend}; "" -}
  432. @ WRITE SYS$OUTPUT "Warning: consider configuring with no-makedepend, because if"
  433. @ WRITE SYS$OUTPUT " target system doesn't have $(PERL),"
  434. @ WRITE SYS$OUTPUT " then make will fail..."
  435. @ ! {- output_on() if $disabled{makedepend}; "" -}
  436. all : build_sw build_docs
  437. test : tests
  438. {- dependmagic('tests'); -} : build_programs_nodep, build_modules_nodep run_tests
  439. run_tests :
  440. @ ! {- output_off() if $disabled{tests}; "" -}
  441. DEFINE SRCTOP "$(SRCDIR)"
  442. DEFINE BLDTOP "$(BLDDIR)"
  443. DEFINE FIPSKEY "$(FIPSKEY)"
  444. IF "$(VERBOSE)" .NES. "" THEN DEFINE VERBOSE "$(VERBOSE)"
  445. $(PERL) {- sourcefile("test", "run_tests.pl") -} $(TESTS)
  446. DEASSIGN BLDTOP
  447. DEASSIGN SRCTOP
  448. DEASSIGN FIPSKEY
  449. @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
  450. @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options"
  451. @ ! {- output_on() if !$disabled{tests}; "" -}
  452. list-tests :
  453. @ ! {- output_off() if $disabled{tests}; "" -}
  454. @ DEFINE SRCTOP "$(SRCDIR)"
  455. @ $(PERL) {- sourcefile("test", "run_tests.pl") -} list
  456. @ DEASSIGN SRCTOP
  457. @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
  458. @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options"
  459. @ ! {- output_on() if !$disabled{tests}; "" -}
  460. install : install_sw install_ssldirs install_docs {- $disabled{fips} ? "" : "install_fips" -} install_msg
  461. install_msg :
  462. @ WRITE SYS$OUTPUT ""
  463. @ WRITE SYS$OUTPUT "######################################################################"
  464. @ WRITE SYS$OUTPUT ""
  465. @ IF "$(DESTDIR)" .EQS. "" THEN -
  466. @{- sourcefile("VMS", "msg_install.com") -} "$(SYSTARTUP)" "{- $osslver -}"
  467. @ IF "$(DESTDIR)" .NES. "" THEN -
  468. @{- sourcefile("VMS", "msg_staging.com") -} -
  469. "''installroot']" "''dataroot']" "$(INSTALLTOP)" "$(OPENSSLDIR)" -
  470. "$(SYSTARTUP)" "{- $osslver -}"
  471. check_install :
  472. spawn/nolog @ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com
  473. uninstall : uninstall_docs uninstall_sw {- $disabled{fips} ? "" : "uninstall_fips" -}
  474. # Because VMS wants the generation number (or *) to delete files, we can't
  475. # use $(LIBS), $(PROGRAMS), $(GENERATED) and $(MODULES) directly.
  476. libclean :
  477. {- join("\n\t", map { "- DELETE $_.OLB;*" } @libs) || "@ !" -}
  478. {- join("\n\t", map { "- DELETE $_.EXE;*,$_.MAP;*" } @shlibs) || "@ !" -}
  479. clean : libclean
  480. {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{htmldocs}->{man1}}) || "@ !" -}
  481. {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{htmldocs}->{man3}}) || "@ !" -}
  482. {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{htmldocs}->{man5}}) || "@ !" -}
  483. {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{htmldocs}->{man7}}) || "@ !" -}
  484. {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{programs}}) || "@ !" -}
  485. {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{modules}}) || "@ !" -}
  486. {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{scripts}}) || "@ !" -}
  487. {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{depends}->{""}}) || "@ !" -}
  488. {- join("\n\t", map { "- DELETE $_;*" } @generated) || "@ !" -}
  489. - DELETE [...]*.MAP;*
  490. - DELETE [...]*.D;*
  491. - DELETE [...]*.OBJ;*,*.LIS;*
  492. - DELETE []CXX$DEMANGLER_DB.;*
  493. - DELETE [.VMS]openssl_startup.com;*
  494. - DELETE [.VMS]openssl_shutdown.com;*
  495. - DELETE []vmsconfig.pm;*
  496. distclean : clean
  497. - DELETE [.include.openssl]configuration.h;*
  498. - DELETE configdata.pm;*
  499. - DELETE descrip.mms;*
  500. depend : descrip.mms
  501. @ ! {- output_off() if $disabled{makedepend}; "" -}
  502. @ $(PERL) {- sourcefile("util", "add-depends.pl") -} "{- $config{makedep_scheme} -}"
  503. @ ! {- output_on() if $disabled{makedepend}; "" -}
  504. # Install helper targets #############################################
  505. install_sw : install_dev install_engines install_modules -
  506. install_runtime install_startup install_ivp
  507. uninstall_sw : uninstall_dev uninstall_modules uninstall_engines -
  508. uninstall_runtime uninstall_startup uninstall_ivp
  509. install_docs : install_html_docs
  510. uninstall_docs : uninstall_html_docs
  511. {- output_off() if $disabled{fips}; "" -}
  512. install_fips : build_sw $(INSTALL_FIPSMODULECONF)
  513. @ WRITE SYS$OUTPUT "*** Installing FIPS module"
  514. - CREATE/DIR ossl_installroot:[MODULES{- $target{pointer_size} -}.'arch']
  515. - CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[000000]
  516. COPY/PROT=W:RE $(INSTALL_FIPSMODULES) -
  517. ossl_installroot:[MODULES{- $target{pointer_size} -}.'arch']$(FIPSMODULENAME)
  518. @ WRITE SYS$OUTPUT "*** Installing FIPS module configuration"
  519. COPY/PROT=W:RE $(INSTALL_FIPSMODULECONF) OSSL_DATAROOT:[000000]
  520. uninstall_fips :
  521. @ WRITE SYS$OUTPUT "*** Uninstalling FIPS module configuration"
  522. DELETE OSSL_DATAROOT:[000000]fipsmodule.cnf;*
  523. @ WRITE SYS$OUTPUT "*** Uninstalling FIPS module"
  524. DELETE ossl_installroot:[MODULES{- $target{pointer_size} -}.'arch']$(FIPSMODULENAME);*
  525. {- output_on() if $disabled{fips}; "" -}
  526. install_ssldirs : check_INSTALLTOP
  527. - CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[000000]
  528. IF F$SEARCH("OSSL_DATAROOT:[000000]CERTS.DIR;1") .EQS. "" THEN -
  529. CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[CERTS]
  530. IF F$SEARCH("OSSL_DATAROOT:[000000]PRIVATE.DIR;1") .EQS. "" THEN -
  531. CREATE/DIR/PROT=(S:RWED,O:RWE,G,W) OSSL_DATAROOT:[PRIVATE]
  532. IF F$SEARCH("OSSL_DATAROOT:[000000]MISC.DIR;1") .EQS. "" THEN -
  533. CREATE/DIR/PROT=(S:RWED,O:RWE,G,W) OSSL_DATAROOT:[MISC]
  534. COPY/PROT=W:RE $(MISC_SCRIPTS) OSSL_DATAROOT:[MISC]
  535. @ ! Install configuration file
  536. COPY/PROT=W:R {- sourcefile("apps", "openssl-vms.cnf") -} -
  537. ossl_dataroot:[000000]openssl.cnf-dist
  538. IF F$SEARCH("OSSL_DATAROOT:[000000]openssl.cnf") .EQS. "" THEN -
  539. COPY/PROT=W:R {- sourcefile("apps", "openssl-vms.cnf") -} -
  540. ossl_dataroot:[000000]openssl.cnf
  541. @ ! Install CTLOG configuration file
  542. COPY/PROT=W:R {- sourcefile("apps", "ct_log_list.cnf") -} -
  543. ossl_dataroot:[000000]ct_log_list.cnf-dist
  544. IF F$SEARCH("OSSL_DATAROOT:[000000]ct_log_list.cnf") .EQS. "" THEN -
  545. COPY/PROT=W:R {- sourcefile("apps", "ct_log_list.cnf") -} -
  546. ossl_dataroot:[000000]ct_log_list.cnf
  547. install_dev : check_INSTALLTOP install_runtime_libs
  548. @ WRITE SYS$OUTPUT "*** Installing development files"
  549. @ ! Install header files
  550. - CREATE/DIR ossl_installroot:[include.openssl]
  551. COPY/PROT=W:R ossl_sourceroot:[include.openssl]*.h -
  552. ossl_installroot:[include.openssl]
  553. COPY/PROT=W:R [.include.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. install_engines : check_INSTALLTOP install_runtime_libs build_modules
  560. @ {- output_off() unless scalar @install_engines; "" -} !
  561. @ WRITE SYS$OUTPUT "*** Installing engines"
  562. - CREATE/DIR ossl_installroot:[ENGINES{- $sover_dirname.$target{pointer_size} -}.'arch']
  563. {- join("\n ",
  564. map { "COPY/PROT=W:RE $_.EXE ossl_installroot:[ENGINES$sover_dirname$target{pointer_size}.'arch']" }
  565. @install_engines) -}
  566. @ {- output_on() unless scalar @install_engines; "" -} !
  567. install_modules : check_INSTALLTOP install_runtime_libs build_modules
  568. @ {- output_off() unless scalar @install_modules; "" -} !
  569. @ WRITE SYS$OUTPUT "*** Installing modules"
  570. - CREATE/DIR ossl_installroot:[MODULES{- $target{pointer_size} -}.'arch']
  571. {- join("\n ",
  572. map { "COPY/PROT=W:RE $_.EXE ossl_installroot:[MODULES$target{pointer_size}.'arch']" }
  573. @install_modules) -}
  574. @ {- output_on() unless scalar @install_modules; "" -} !
  575. install_runtime : install_programs
  576. install_runtime_libs : check_INSTALLTOP build_libs
  577. @ {- output_off() if $disabled{shared}; "" -} !
  578. @ WRITE SYS$OUTPUT "*** Installing shareable images"
  579. @ ! Install shared (runtime) libraries
  580. - CREATE/DIR ossl_installroot:[LIB.'arch']
  581. {- join("\n ",
  582. map { "COPY/PROT=W:R $_.EXE ossl_installroot:[LIB.'arch']" }
  583. @install_shlibs) -}
  584. @ {- output_on() if $disabled{shared}; "" -} !
  585. install_programs : check_INSTALLTOP install_runtime_libs build_programs
  586. @ {- output_off() if $disabled{apps}; "" -} !
  587. @ ! Install the main program
  588. - CREATE/DIR ossl_installroot:[EXE.'arch']
  589. COPY/PROT=W:RE [.APPS]openssl.EXE -
  590. ossl_installroot:[EXE.'arch']openssl{- $osslver -}.EXE
  591. @ ! Install scripts
  592. COPY/PROT=W:RE $(BIN_SCRIPTS) ossl_installroot:[EXE]
  593. @ ! {- output_on() if $disabled{apps}; "" -}
  594. install_startup : [.VMS]openssl_startup.com [.VMS]openssl_shutdown.com -
  595. [.VMS]openssl_utils.com, check_INSTALLTOP
  596. - CREATE/DIR ossl_installroot:[SYS$STARTUP]
  597. COPY/PROT=W:RE [.VMS]openssl_startup.com -
  598. ossl_installroot:[SYS$STARTUP]openssl_startup{- $osslver -}.com
  599. COPY/PROT=W:RE [.VMS]openssl_shutdown.com -
  600. ossl_installroot:[SYS$STARTUP]openssl_shutdown{- $osslver -}.com
  601. COPY/PROT=W:RE [.VMS]openssl_utils.com -
  602. ossl_installroot:[SYS$STARTUP]openssl_utils{- $osslver -}.com
  603. install_ivp : [.VMS]openssl_ivp.com check_INSTALLTOP
  604. - CREATE/DIR ossl_installroot:[SYSTEST]
  605. COPY/PROT=W:RE [.VMS]openssl_ivp.com -
  606. ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com
  607. [.VMS]openssl_startup.com : vmsconfig.pm {- sourcefile("VMS", "openssl_startup.com.in") -}
  608. - CREATE/DIR [.VMS]
  609. $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
  610. {- sourcefile("VMS", "openssl_startup.com.in") -} -
  611. > [.VMS]openssl_startup.com
  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. [.VMS]openssl_shutdown.com : vmsconfig.pm {- sourcefile("VMS", "openssl_shutdown.com.in") -}
  618. - CREATE/DIR [.VMS]
  619. $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
  620. {- sourcefile("VMS", "openssl_shutdown.com.in") -} -
  621. > [.VMS]openssl_shutdown.com
  622. [.VMS]openssl_ivp.com : vmsconfig.pm {- sourcefile("VMS", "openssl_ivp.com.in") -}
  623. - CREATE/DIR [.VMS]
  624. $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
  625. {- sourcefile("VMS", "openssl_ivp.com.in") -} -
  626. > [.VMS]openssl_ivp.com
  627. vmsconfig.pm : configdata.pm
  628. OPEN/WRITE/SHARE=READ CONFIG []vmsconfig.pm
  629. WRITE CONFIG "package vmsconfig;"
  630. WRITE CONFIG "use strict; use warnings;"
  631. WRITE CONFIG "use Exporter;"
  632. WRITE CONFIG "our @ISA = qw(Exporter);"
  633. WRITE CONFIG "our @EXPORT = qw(%config %target %withargs %unified_info %disabled);"
  634. WRITE CONFIG "our %config = ("
  635. WRITE CONFIG " target => '","{- $config{target} -}","',"
  636. WRITE CONFIG " version => '","{- $config{version} -}","',"
  637. WRITE CONFIG " shlib_version => '","{- $config{shlib_version} -}","',"
  638. WRITE CONFIG " shlib_major => '","{- $config{shlib_major} -}","',"
  639. WRITE CONFIG " shlib_minor => '","{- $config{shlib_minor} -}","',"
  640. WRITE CONFIG " no_shared => '","{- $disabled{shared} -}","',"
  641. WRITE CONFIG " INSTALLTOP => '$(INSTALLTOP)',"
  642. WRITE CONFIG " OPENSSLDIR => '$(OPENSSLDIR)',"
  643. WRITE CONFIG " pointer_size => '","{- $target{pointer_size} -}","',"
  644. WRITE CONFIG ");"
  645. WRITE CONFIG "our %target = ();"
  646. WRITE CONFIG "our %disabled = ();"
  647. WRITE CONFIG "our %withargs = ();"
  648. WRITE CONFIG "our %unified_info = ();"
  649. WRITE CONFIG "1;"
  650. CLOSE CONFIG
  651. install_html_docs : check_INSTALLTOP build_html_docs
  652. @ WRITE SYS$OUTPUT "*** Installing HTML docs"
  653. - CREATE/DIR ossl_installroot:[HTML.MAN1]
  654. - CREATE/DIR ossl_installroot:[HTML.MAN3]
  655. - CREATE/DIR ossl_installroot:[HTML.MAN5]
  656. - CREATE/DIR ossl_installroot:[HTML.MAN7]
  657. {- join("\n ",
  658. ( map { "COPY/PROT=W:RE $_ ossl_installroot:[HTML.MAN1]" }
  659. @{$unified_info{htmldocs}->{man1}} ),
  660. ( map { "COPY/PROT=W:RE $_ ossl_installroot:[HTML.MAN3]" }
  661. @{$unified_info{htmldocs}->{man3}} ),
  662. ( map { "COPY/PROT=W:RE $_ ossl_installroot:[HTML.MAN5]" }
  663. @{$unified_info{htmldocs}->{man5}} ),
  664. ( map { "COPY/PROT=W:RE $_ ossl_installroot:[HTML.MAN7]" }
  665. @{$unified_info{htmldocs}->{man7}} )) -}
  666. check_INSTALLTOP :
  667. @ IF "$(INSTALLTOP)" .EQS. "" THEN -
  668. WRITE SYS$ERROR "INSTALLTOP should not be empty"
  669. @ IF "$(INSTALLTOP)" .EQS. "" THEN -
  670. EXIT %x10000002
  671. # Developer targets ##################################################
  672. debug_logicals :
  673. SH LOGICAL/PROC openssl,internal,ossl_installroot,ossl_dataroot
  674. # Building targets ###################################################
  675. descrip.mms : configdata.pm {- join(" ", @{$config{build_file_templates}}) -}
  676. perl configdata.pm
  677. @ WRITE SYS$OUTPUT "*************************************************"
  678. @ WRITE SYS$OUTPUT "*** ***"
  679. @ WRITE SYS$OUTPUT "*** Please run the same mms command again ***"
  680. @ WRITE SYS$OUTPUT "*** ***"
  681. @ WRITE SYS$OUTPUT "*************************************************"
  682. @ PIPE ( EXIT %X10000000 )
  683. configdata.pm : $(SRCDIR)Configure $(SRCDIR)config.com {- join(" ", @{$config{build_infos}}, @{$config{conf_files}}) -}
  684. perl configdata.pm -r
  685. @ WRITE SYS$OUTPUT "*************************************************"
  686. @ WRITE SYS$OUTPUT "*** ***"
  687. @ WRITE SYS$OUTPUT "*** Please run the same mms command again ***"
  688. @ WRITE SYS$OUTPUT "*** ***"
  689. @ WRITE SYS$OUTPUT "*************************************************"
  690. @ PIPE ( EXIT %X10000000 )
  691. reconfigure reconf :
  692. perl configdata.pm -r
  693. {-
  694. use File::Basename;
  695. use File::Spec::Functions qw/abs2rel rel2abs catfile catdir/;
  696. use File::Spec::Unix;
  697. # Helper function to convert dependencies in platform agnostic form to
  698. # dependencies in platform form.
  699. sub compute_platform_depends {
  700. map { my $x = $_;
  701. grep { $x eq $_ } @{$unified_info{programs}} and platform->bin($x)
  702. or grep { $x eq $_ } @{$unified_info{modules}} and platform->dso($x)
  703. or grep { $x eq $_ } @{$unified_info{libraries}} and platform->lib($x)
  704. or platform->convertext($x); } @_;
  705. }
  706. # Helper function to figure out dependencies on libraries
  707. # It takes a list of library names and outputs a list of dependencies
  708. sub compute_lib_depends {
  709. # Depending on shared libraries:
  710. # On Windows POSIX layers, we depend on {libname}.dll.a
  711. # On Unix platforms, we depend on {shlibname}.so
  712. return map {
  713. { lib => platform->sharedlib($_) // platform->staticlib($_),
  714. attrs => $unified_info{attributes}->{libraries}->{$_} }
  715. } @_;
  716. }
  717. # Helper function to deal with inclusion directory specs.
  718. # We're dealing with two issues:
  719. # 1. A lot of include directory specs take up a lot of command line real
  720. # estate, and the DCL command line is very limited (2KiB).
  721. # 2. For optimal usage, include directory paths must be in Unix form,
  722. # that's the only way the C compiler can merge multiple include paths
  723. # in a sane way (we can stop worrying about 1.h including foo/2.h
  724. # including ../3.h).
  725. #
  726. # To resolve 1, we need to create a file with include directory pragmas,
  727. # and let the compiler use it with /FIRST_INCLUDE=.
  728. # To resolve 2, we convert all include directory specs we get to Unix,
  729. # with available File::Spec functions.
  730. #
  731. # We use CRC-24 from https://tools.ietf.org/html/rfc4880#section-6,
  732. # reimplemented in Perl to get a workable and constant file name for each
  733. # combination of include directory specs. It is assumed that the order of
  734. # these directories don't matter.
  735. #
  736. # This function takes as input a list of include directories
  737. # This function returns a list two things:
  738. # 1. The file name to use with /FIRST_INCLUDE=
  739. # 2. Text to insert into descrip.mms (may be the empty string)
  740. sub crc24 {
  741. my $input = shift;
  742. my $init_value = 0x00B704CE;
  743. my $poly_value = 0x01864CFB;
  744. my $crc = $init_value;
  745. foreach my $x (unpack ('C*', $input)) {
  746. $crc ^= $x << 16;
  747. for (my $i; $i < 8; $i++) {
  748. $crc <<= 1;
  749. if ($crc & 0x01000000) {
  750. $crc ^= $poly_value;
  751. }
  752. }
  753. }
  754. $crc &= 0xFFFFFF;
  755. return $crc;
  756. }
  757. my %includefile_cache;
  758. sub make_includefile {
  759. my %dirs = map {
  760. my $udir = make_unix_path(rel2abs($_));
  761. $udir => 1;
  762. } @_;
  763. my @dirs = sort keys %dirs;
  764. my $filename = sprintf 'incdirs_%x.h', crc24(join(',', @dirs));
  765. if ($includefile_cache{$filename}) {
  766. return ($filename, "");
  767. }
  768. my $scripture = <<"EOF";
  769. $filename :
  770. open/write inc_output $filename
  771. EOF
  772. foreach (@dirs) {
  773. $scripture .= <<"EOF";
  774. write inc_output "#pragma include_directory ""$_"""
  775. EOF
  776. }
  777. $scripture .= <<"EOF";
  778. close inc_output
  779. EOF
  780. $includefile_cache{$filename} = $scripture;
  781. return ($filename, $scripture);
  782. }
  783. # On VMS, (some) header file directories include the files
  784. # __DECC_INCLUDE_EPILOGUE.H and __DECC_INCLUDE_PROLOGUE.H.
  785. # When header files are generated, and the build directory
  786. # isn't the same as the source directory, these files must
  787. # be copied alongside the generated header file, or their
  788. # effect will be lost.
  789. # We use the same include file cache as make_includefile
  790. # to check if the scripture to copy these files has already
  791. # been generated.
  792. sub make_decc_include_files {
  793. my $outd = shift;
  794. my $ind = shift;
  795. # If the build directory and the source directory are the
  796. # same, there's no need to copy the prologue and epilogue
  797. # files.
  798. return ('') if $outd eq $ind;
  799. my $outprologue = catfile($outd, '__DECC_INCLUDE_PROLOGUE.H');
  800. my $outepilogue = catfile($outd, '__DECC_INCLUDE_EPILOGUE.H');
  801. my $inprologue = catfile($ind, '__DECC_INCLUDE_PROLOGUE.H');
  802. my $inepilogue = catfile($ind, '__DECC_INCLUDE_EPILOGUE.H');
  803. my @filenames = ();
  804. my $scripture = '';
  805. if ($includefile_cache{$outprologue}) {
  806. push @filenames, $outprologue;
  807. } elsif (-f $inprologue) {
  808. my $local_scripture .= <<"EOF";
  809. $outprologue : $inprologue
  810. COPY $inprologue $outprologue
  811. EOF
  812. $includefile_cache{$outprologue} = $local_scripture;
  813. push @filenames, $outprologue;
  814. $scripture .= $local_scripture;
  815. }
  816. if ($includefile_cache{$outepilogue}) {
  817. push @filenames, $outepilogue;
  818. } elsif (-f $inepilogue) {
  819. my $local_scripture .= <<"EOF";
  820. $outepilogue : $inepilogue
  821. COPY $inepilogue $outepilogue
  822. EOF
  823. $includefile_cache{$outepilogue} = $local_scripture;
  824. push @filenames, $outepilogue;
  825. $scripture .= $local_scripture;
  826. }
  827. return (@filenames, $scripture);
  828. }
  829. sub generatetarget {
  830. my %args = @_;
  831. my $deps = join(" ", compute_platform_depends(@{$args{deps}}));
  832. return <<"EOF";
  833. $args{target} : $deps
  834. EOF
  835. }
  836. sub generatesrc {
  837. my %args = @_;
  838. my $gen0 = $args{generator}->[0];
  839. my $gen_args = join('', map { " $_" }
  840. @{$args{generator}}[1..$#{$args{generator}}]);
  841. my $gen_incs = join("", map { ' "-I'.$_.'"' } @{$args{generator_incs}});
  842. my $deps = join(", -\n\t\t",
  843. compute_platform_depends(@{$args{generator_deps}},
  844. @{$args{deps}}));
  845. if ($args{src} =~ /\.html$/) {
  846. #
  847. # HTML generator
  848. #
  849. my $title = basename($args{src}, ".html");
  850. my $pod = $gen0;
  851. my $mkpod2html = sourcefile('util', 'mkpod2html.pl');
  852. my $srcdoc = sourcedir('doc');
  853. return <<"EOF";
  854. $args{src} : $pod
  855. \$(PERL) $mkpod2html -i $pod -o \$\@ -t "$title" -r "$srcdoc"
  856. EOF
  857. } elsif ($args{src} =~ /\.(\d)$/) {
  858. #
  859. # Man-page generator, on VMS we simply ignore man-pages
  860. #
  861. return "";
  862. } elsif (platform->isdef($args{src})) {
  863. #
  864. # Linker script-ish generator
  865. #
  866. my $target = platform->def($args{src});
  867. my $mkdef = sourcefile('util', 'mkdef.pl');
  868. my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION_NUMBER)' : '';
  869. my $ord_name =
  870. $args{generator}->[1] || basename($args{product}, '.EXE');
  871. my $case_insensitive =
  872. $target{$args{intent}.'_cflags'} =~ m|/NAMES=[^/]*AS_IS|i
  873. ? '' : ' --case-insensitive';
  874. return <<"EOF";
  875. $target : $gen0 $deps $mkdef
  876. \$(PERL) $mkdef$ord_ver --type $args{intent} --ordinals $gen0 --name $ord_name "--OS" "VMS"$case_insensitive > $target
  877. EOF
  878. } elsif (platform->isasm($args{src})
  879. || platform->iscppasm($args{src})) {
  880. #
  881. # Assembler generator
  882. #
  883. my $cppflags =
  884. { shlib => "$lib_cflags $lib_cppflags",
  885. lib => "$lib_cflags $lib_cppflags",
  886. dso => "$dso_cflags $dso_cppflags",
  887. bin => "$bin_cflags $bin_cppflags" } -> {$args{intent}};
  888. my $defs = join("", map { ",".$_ } @{$args{defs}});
  889. my $target = platform->isasm($args{src})
  890. ? platform->asm($args{src})
  891. : $args{src};
  892. my $generator;
  893. if ($gen0 =~ /\.pl$/) {
  894. $generator = '$(PERL)'.$gen_incs.' '.$gen0.$gen_args
  895. .' '.$cppflags;
  896. } elsif ($gen0 =~ /\.S$/) {
  897. $generator = undef;
  898. } else {
  899. die "Generator type for $src unknown: $gen0.$gen_args\n";
  900. }
  901. if (defined($generator)) {
  902. return <<"EOF";
  903. $target : $gen0 $deps
  904. \@ extradefines = "$defs"
  905. $generator \$\@
  906. \@ DELETE/SYMBOL/LOCAL extradefines
  907. EOF
  908. }
  909. return <<"EOF";
  910. $target : $gen0 $deps
  911. \@ extradefines = "$defs"
  912. PIPE \$(CPP) $cppflags $gen0 | -
  913. \$(PERL) "-ne" "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" > \$\@
  914. \@ DELETE/SYMBOL/LOCAL extradefines
  915. EOF
  916. } elsif ($gen0 =~ m|^.*\.in$|) {
  917. #
  918. # "dofile" generator (file.in -> file)
  919. #
  920. my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
  921. "util", "dofile.pl")),
  922. rel2abs($config{builddir}));
  923. my @perlmodules = ( 'configdata.pm',
  924. grep { $_ =~ m|\.pm$| } @{$args{deps}} );
  925. my %perlmoduleincs = map { '"-I'.dirname($_).'"' => 1 } @perlmodules;
  926. my @decc_include_data
  927. = make_decc_include_files(dirname($args{src}), dirname($gen0));
  928. my $decc_include_scripture = pop @decc_include_data;
  929. $deps = join(' ', $deps, @decc_include_data,
  930. compute_platform_depends(@perlmodules));
  931. @perlmodules = map { '"-M'.basename($_, '.pm').'"' } @perlmodules;
  932. my $perlmodules = join(' ', '', sort keys %perlmoduleincs, @perlmodules);
  933. return <<"EOF";
  934. $args{src} : $gen0 $deps
  935. \$(PERL)$perlmodules $dofile "-o$target{build_file}" $gen0$gen_args > \$\@
  936. $decc_include_scripture
  937. EOF
  938. } elsif (grep { $_ eq $gen0 } @{$unified_info{programs}}) {
  939. #
  940. # Generic generator using OpenSSL programs
  941. #
  942. # Redo $gen0, to ensure that we have the proper extension
  943. $gen0 = platform->bin($gen0);
  944. return <<"EOF";
  945. $args{src} : $gen0 $deps
  946. PIPE MCR $gen0$gen_args > \$@
  947. EOF
  948. } else {
  949. #
  950. # Generic generator using Perl
  951. #
  952. return <<"EOF";
  953. $args{src} : $gen0 $deps
  954. \$(PERL)$gen_incs $gen0$gen_args > \$\@
  955. EOF
  956. }
  957. }
  958. sub src2obj {
  959. my $asmext = platform->asmext();
  960. my %args = @_;
  961. my @srcs =
  962. map { my $x = $_;
  963. (platform->isasm($x) && grep { $x eq $_ } @generated)
  964. ? platform->asm($x) : $x }
  965. ( @{$args{srcs}} );
  966. my $obj = platform->obj($args{obj});
  967. my $dep = platform->dep($args{obj});
  968. my $deps = join(", -\n\t\t", @srcs, @{$args{deps}});
  969. # Because VMS C isn't very good at combining a /INCLUDE path with
  970. # #includes having a relative directory (like '#include "../foo.h"),
  971. # the best choice is to move to the first source file's intended
  972. # directory before compiling, and make sure to write the object file
  973. # in the correct position (important when the object tree is other
  974. # than the source tree).
  975. my $forward = dirname($args{srcs}->[0]);
  976. my $backward = abs2rel(rel2abs("."), rel2abs($forward));
  977. my $objd = abs2rel(rel2abs(dirname($obj)), rel2abs($forward));
  978. my $objn = basename($obj);
  979. my $depd = abs2rel(rel2abs(dirname($dep)), rel2abs($forward));
  980. my $depn = basename($dep);
  981. my $srcs =
  982. join(", ", map { abs2rel(rel2abs($_), rel2abs($forward)) } @srcs);
  983. my $incextra = join(',', map { "\"$_\"" }
  984. @{$unified_info{includes_extra}->{$obj}});
  985. $incextra = "/INCLUDE=($incextra)" if $incextra;
  986. my $cflags;
  987. if ($args{attrs}->{noinst}) {
  988. $cflags .= { shlib => $lib_cflags_no_inst,
  989. lib => $lib_cflags_no_inst,
  990. dso => $dso_cflags_no_inst,
  991. bin => $bin_cflags_no_inst } -> {$args{intent}};
  992. } else {
  993. $cflags .= { shlib => $lib_cflags,
  994. lib => $lib_cflags,
  995. dso => $dso_cflags,
  996. bin => $bin_cflags } -> {$args{intent}};
  997. }
  998. $cflags .= { shlib => $lib_cppflags,
  999. lib => $lib_cppflags,
  1000. dso => $dso_cppflags,
  1001. bin => $bin_cppflags } -> {$args{intent}};
  1002. $cflags .= $incextra;
  1003. my $defs = join("", map { ",".$_ } @{$args{defs}});
  1004. my $asflags = { shlib => $lib_asflags,
  1005. lib => $lib_asflags,
  1006. dso => $dso_asflags,
  1007. bin => $bin_asflags } -> {$args{intent}};
  1008. if ($srcs[0] =~ /\Q${asmext}\E$/) {
  1009. return <<"EOF";
  1010. $obj : $deps
  1011. SET DEFAULT $forward
  1012. \$(AS) $asflags \$(ASOUTFLAG)${objd}${objn} $srcs
  1013. SET DEFAULT $backward
  1014. - PURGE $obj
  1015. EOF
  1016. } elsif ($srcs[0] =~ /.S$/) {
  1017. return <<"EOF";
  1018. $obj : $deps
  1019. SET DEFAULT $forward
  1020. \@ $incs_on
  1021. \@ extradefines = "$defs"
  1022. PIPE \$(CPP) ${cflags} $srcs | -
  1023. \$(PERL) -ne "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" -
  1024. > ${objd}${objn}-asm
  1025. \@ DELETE/SYMBOL/LOCAL extradefines
  1026. \@ $incs_off
  1027. SET DEFAULT $backward
  1028. \$(AS) $asflags \$(ASOUTFLAG)$obj $obj-asm
  1029. - PURGE $obj
  1030. EOF
  1031. }
  1032. my ($incdir_filename, $incdir_scripture) =
  1033. make_includefile(@{ { shlib => [ @lib_cppincludes ],
  1034. lib => [ @lib_cppincludes ],
  1035. dso => [ @dso_cppincludes ],
  1036. bin => [ @bin_cppincludes ] } -> {$args{intent}} },
  1037. @{$args{incs}});
  1038. $deps .= ", -\n\t\t$incdir_filename";
  1039. $cflags =
  1040. $target{cflag_incfirst}
  1041. . '"'.make_unix_path(rel2abs($incdir_filename)).'"'
  1042. . $cflags;
  1043. my $depbuild = $disabled{makedepend} ? ""
  1044. : " /MMS=(FILE=${depd}${depn},TARGET=$obj)";
  1045. return <<"EOF";
  1046. $obj : $deps
  1047. SET DEFAULT $forward
  1048. \@ $incs_on
  1049. \@ extradefines = "$defs"
  1050. \$(CC) ${cflags}${depbuild} /OBJECT=${objd}${objn} /REPOSITORY=$backward $srcs
  1051. \@ DELETE/SYMBOL/LOCAL extradefines
  1052. \@ $incs_off
  1053. SET DEFAULT $backward
  1054. - PURGE $obj
  1055. $incdir_scripture
  1056. EOF
  1057. }
  1058. sub obj2shlib {
  1059. my %args = @_;
  1060. my $shlibname = platform->sharedname($args{lib});
  1061. my $shlib = platform->sharedlib($args{lib});
  1062. my @objs = map { platform->convertext($_) }
  1063. grep { platform->isobj($_) }
  1064. @{$args{objs}};
  1065. my @defs = map { platform->convertext($_) }
  1066. grep { platform->isdef($_) }
  1067. @{$args{objs}};
  1068. my @deps = compute_lib_depends(@{$args{deps}});
  1069. die "More than one symbol vector" if scalar @defs > 1;
  1070. my $deps = join(", -\n\t\t", @objs, @defs, map { $_->{lib} } @deps);
  1071. my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
  1072. my $translatesyms_pl = abs2rel(rel2abs(catfile($config{sourcedir},
  1073. "VMS", "translatesyms.pl")),
  1074. rel2abs($config{builddir}));
  1075. # The "[]" hack is because in .OPT files, each line inherits the
  1076. # previous line's file spec as default, so if no directory spec
  1077. # is present in the current line and the previous line has one that
  1078. # doesn't apply, you're in for a surprise.
  1079. my $write_opt1 =
  1080. join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
  1081. "WRITE OPT_FILE \"$x" } @objs).
  1082. "\"";
  1083. my $write_opt2 =
  1084. join("\n\t", map { my $x = $_->{lib} =~ /\[/
  1085. ? $_->{lib} : "[]".$_->{lib};
  1086. $x =~ s|(\.EXE)|$1/SHARE|;
  1087. $x =~ s|(\.OLB)|$1/LIB|;
  1088. "WRITE OPT_FILE \"$x\"" } @deps)
  1089. || "\@ !";
  1090. return <<"EOF"
  1091. $shlib : $deps
  1092. \$(PERL) $translatesyms_pl \$(BLDDIR)CXX\$DEMANGLER_DB. < $defs[0] > $defs[0]-translated
  1093. OPEN/WRITE/SHARE=READ OPT_FILE $shlibname-components.OPT
  1094. $write_opt1
  1095. $write_opt2
  1096. CLOSE OPT_FILE
  1097. LINK ${lib_ldflags}/SHARE=\$\@ $defs[0]-translated/OPT,-
  1098. $shlibname-components.OPT/OPT \$(LIB_EX_LIBS)
  1099. DELETE $defs[0]-translated;*,$shlibname-components.OPT;*
  1100. PURGE $shlibname.EXE,$shlibname.MAP
  1101. EOF
  1102. . ($config{target} =~ m|alpha| ? "" : <<"EOF"
  1103. SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
  1104. EOF
  1105. );
  1106. }
  1107. sub obj2dso {
  1108. my %args = @_;
  1109. my $dsoname = platform->dsoname($args{module});
  1110. my $dso = platform->dso($args{module});
  1111. my @objs = map { platform->convertext($_) }
  1112. grep { platform->isobj($_) }
  1113. @{$args{objs}};
  1114. my @defs = map { platform->convertext($_) }
  1115. grep { platform->isdef($_) }
  1116. @{$args{objs}};
  1117. my @deps = compute_lib_depends(@{$args{deps}});
  1118. my $deps = join(", -\n\t\t", @objs, @defs, map { $_->{lib} } @deps);
  1119. die "More than one symbol vector" if scalar @defs > 1;
  1120. my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
  1121. # The "[]" hack is because in .OPT files, each line inherits the
  1122. # previous line's file spec as default, so if no directory spec
  1123. # is present in the current line and the previous line has one that
  1124. # doesn't apply, you're in for a surprise.
  1125. # Furthermore, we collect all object files and static libraries in
  1126. # an explicit cluster, to make it clear to the linker that these files
  1127. # shall be processed before shareable images.
  1128. # The shareable images are used with /SELECTIVE, to avoid warnings of
  1129. # multiply defined symbols when the module object files override some
  1130. # symbols that are present in the shareable image.
  1131. my $write_opt1 =
  1132. join(",-\"\n\t",
  1133. "\@ WRITE OPT_FILE \"CLUSTER=_,,",
  1134. (map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
  1135. "\@ WRITE OPT_FILE \"$x" } @objs),
  1136. (map { my $x = ($_->{lib} =~ /\[/) ? $_->{lib} : "[]".$_->{lib};
  1137. "\@ WRITE OPT_FILE \"$x/LIB" }
  1138. grep { $_->{lib} =~ m|\.OLB$| }
  1139. @deps))
  1140. ."\"";
  1141. my $write_opt2 =
  1142. join("\n\t",
  1143. (map { my $x = ($_->{lib} =~ /\[/) ? $_->{lib} : "[]".$_->{lib};
  1144. "\@ WRITE OPT_FILE \"$x/SHARE/SELECTIVE\"" }
  1145. grep { $_->{lib} =~ m|\.EXE$| }
  1146. @deps))
  1147. || "\@ !";
  1148. return <<"EOF"
  1149. $dso : $deps
  1150. OPEN/WRITE/SHARE=READ OPT_FILE $dsoname-components.OPT
  1151. $write_opt1
  1152. $write_opt2
  1153. CLOSE OPT_FILE
  1154. LINK ${dso_ldflags}/SHARE=\$\@ $defs[0]/OPT,-
  1155. $dsoname-components.OPT/OPT \$(DSO_EX_LIBS)
  1156. - PURGE $dsoname.EXE,$dsoname.OPT,$dsoname.MAP
  1157. EOF
  1158. . ($config{target} =~ m|alpha| ? "" : <<"EOF"
  1159. SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
  1160. EOF
  1161. );
  1162. }
  1163. sub obj2lib {
  1164. my %args = @_;
  1165. my $lib = platform->staticlib($args{lib});
  1166. my @objs = map { platform->convertext($_) }
  1167. grep { platform->isobj($_) }
  1168. @{$args{objs}};
  1169. my $objs = join(", -\n\t\t", @objs);
  1170. my $fill_lib = join("\n\t", (map { "LIBRARY/REPLACE $lib $_" } @objs));
  1171. return <<"EOF";
  1172. $lib : $objs
  1173. LIBRARY/CREATE/OBJECT $lib
  1174. $fill_lib
  1175. - PURGE $lib
  1176. EOF
  1177. }
  1178. sub obj2bin {
  1179. my %args = @_;
  1180. my $bin = platform->bin($args{bin});
  1181. my $binname = platform->binname($args{bin});
  1182. my @objs = map { platform->convertext($_) }
  1183. grep { platform->isobj($_) }
  1184. @{$args{objs}};
  1185. my $objs = join(",", @objs);
  1186. my @deps = compute_lib_depends(@{$args{deps}});
  1187. my $deps = join(", -\n\t\t", @objs, map { $_->{lib} } @deps);
  1188. my $olb_count = scalar grep(m|\.OLB$|, map { $_->{lib} } @deps);
  1189. my $analyse_objs = "@ !";
  1190. if ($olb_count > 0) {
  1191. my $analyse_quals =
  1192. $config{target} =~ m|alpha| ? "/GSD" : "/SECTIONS=SYMTAB";
  1193. $analyse_objs = "- pipe ANALYSE/OBJECT$analyse_quals $objs | SEARCH SYS\$INPUT \"\"\"main\"\"\" ; nomain = \$severity .NE. 1"
  1194. }
  1195. # The "[]" hack is because in .OPT files, each line inherits the
  1196. # previous line's file spec as default, so if no directory spec
  1197. # is present in the current line and the previous line has one that
  1198. # doesn't apply, you're in for a surprise.
  1199. my $write_opt1 =
  1200. "\@ WRITE OPT_FILE \"CASE_SENSITIVE=YES\"\n\t"
  1201. .join(",-\"\n\t",
  1202. "\@ WRITE OPT_FILE \"CLUSTER=_,,",
  1203. (map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
  1204. "\@ WRITE OPT_FILE \"$x" } @objs),
  1205. (map { my $x = ($_->{lib} =~ /\[/) ? $_->{lib} : "[]".$_->{lib};
  1206. # Special hack to include the MAIN object module
  1207. # explicitly, if it's known that there is one.
  1208. # |incmain| is defined in the rule generation further
  1209. # down, with the necessary /INCLUDE=main option unless
  1210. # the program has been determined to have a main function
  1211. # already.
  1212. $_->{attrs}->{has_main}
  1213. ? "\@ WRITE OPT_FILE \"$x/LIB''incmain'"
  1214. : "\@ WRITE OPT_FILE \"$x/LIB" }
  1215. grep { $_->{lib} =~ m|\.OLB$| }
  1216. @deps))
  1217. ."\"";
  1218. my $write_opt2 =
  1219. join("\n\t",
  1220. (map { my $x = $_->{lib} =~ /\[/ ? $_->{lib} : "[]".$_->{lib};
  1221. "\@ WRITE OPT_FILE \"$x/SHARE/SELECTIVE\"" }
  1222. grep { $_->{lib} =~ m|\.EXE$| }
  1223. @deps))
  1224. || "\@ !";
  1225. # The linking commands looks a bit complex, but it's for good reason.
  1226. # When you link, say, foo.obj, bar.obj and libsomething.exe/share, and
  1227. # bar.obj happens to have a symbol that also exists in libsomething.exe,
  1228. # the linker will warn about it, loudly, and will then choose to pick
  1229. # the first copy encountered (the one in bar.obj in this example).
  1230. # On Unix and on Windows, the corresponding maneuver goes through
  1231. # silently with the same effect.
  1232. # With some test programs, made for checking the internals of OpenSSL,
  1233. # we do this kind of linking deliberately, picking a few specific object
  1234. # files from within [.crypto] or [.ssl] so we can reach symbols that are
  1235. # otherwise unreachable (since the shareable images only exports the
  1236. # symbols listed in [.util]*.num), and then with the shared libraries
  1237. # themselves. So we need to silence the warning about multiply defined
  1238. # symbols, to mimic the way linking work on Unix and Windows, and so
  1239. # the build isn't interrupted (MMS stops when warnings are signaled,
  1240. # by default), and so someone building doesn't have to worry where it
  1241. # isn't necessary. If there are other warnings, however, we show them
  1242. # and let it break the build.
  1243. return <<"EOF"
  1244. $bin : $deps
  1245. $analyse_objs
  1246. @ incmain = "/INCLUDE=main"
  1247. @ IF .NOT. nomain THEN incmain = ""
  1248. @ OPEN/WRITE/SHARE=READ OPT_FILE $binname.OPT
  1249. $write_opt1
  1250. $write_opt2
  1251. @ CLOSE OPT_FILE
  1252. TYPE $binname.OPT ! For debugging
  1253. - pipe SPAWN/WAIT/NOLOG/OUT=$binname.LINKLOG -
  1254. LINK ${bin_ldflags}/EXEC=\$\@ $binname.OPT/OPT \$(BIN_EX_LIBS) ; -
  1255. link_status = \$status ; link_severity = link_status .AND. 7
  1256. @ search_severity = 1
  1257. -@ IF link_severity .EQ. 0 THEN -
  1258. pipe SEARCH $binname.LINKLOG "%","-"/MATCH=AND | -
  1259. SPAWN/WAIT/NOLOG/OUT=NLA0: -
  1260. SEARCH SYS\$INPUT: "-W-MULDEF,"/MATCH=NOR ; -
  1261. search_severity = \$severity
  1262. @ ! search_severity is 3 when the last search didn't find any matching
  1263. @ ! string: %SEARCH-I-NOMATCHES, no strings matched
  1264. @ ! If that was the result, we pretend linking got through without
  1265. @ ! fault or warning.
  1266. @ IF search_severity .EQ. 3 THEN link_severity = 1
  1267. @ ! At this point, if link_severity shows that there was a fault
  1268. @ ! or warning, make sure to restore the linking status.
  1269. -@ IF .NOT. link_severity THEN TYPE $binname.LINKLOG
  1270. -@ DELETE $binname.LINKLOG;*
  1271. @ IF .NOT. link_severity THEN SPAWN/WAIT/NOLOG EXIT 'link_status'
  1272. - PURGE $bin,$binname.OPT
  1273. EOF
  1274. . ($config{target} =~ m|alpha| ? "" : <<"EOF"
  1275. SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
  1276. EOF
  1277. );
  1278. }
  1279. sub in2script {
  1280. my %args = @_;
  1281. my $script = $args{script};
  1282. return "" if grep { $_ eq $script } @{$args{sources}}; # No overwrite!
  1283. my $sources = join(" ", @{$args{sources}});
  1284. my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
  1285. "util", "dofile.pl")),
  1286. rel2abs($config{builddir}));
  1287. return <<"EOF";
  1288. $script : $sources configdata.pm
  1289. \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile -
  1290. "-o$target{build_file}" $sources > $script
  1291. SET FILE/PROT=(S:RWED,O:RWED,G:RE,W:RE) $script
  1292. PURGE $script
  1293. EOF
  1294. }
  1295. "" # Important! This becomes part of the template result.
  1296. -}