descrip.mms.tmpl 64 KB

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