descrip.mms.tmpl 62 KB

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