descrip.mms.tmpl 64 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483
  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 run_tests
  476. run_tests :
  477. @ ! {- output_off() if $disabled{tests}; "" -}
  478. DEFINE SRCTOP "$(SRCDIR)"
  479. DEFINE BLDTOP "$(BLDDIR)"
  480. DEFINE FIPSKEY "$(FIPSKEY)"
  481. IF "$(VERBOSE)" .NES. "" THEN DEFINE VERBOSE "$(VERBOSE)"
  482. $(PERL) {- sourcefile("test", "run_tests.pl") -} $(TESTS)
  483. DEASSIGN BLDTOP
  484. DEASSIGN SRCTOP
  485. DEASSIGN FIPSKEY
  486. @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
  487. @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options"
  488. @ ! {- output_on() if !$disabled{tests}; "" -}
  489. list-tests :
  490. @ ! {- output_off() if $disabled{tests}; "" -}
  491. @ DEFINE SRCTOP "$(SRCDIR)"
  492. @ $(PERL) {- sourcefile("test", "run_tests.pl") -} list
  493. @ DEASSIGN SRCTOP
  494. @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
  495. @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options"
  496. @ ! {- output_on() if !$disabled{tests}; "" -}
  497. install : install_sw install_ssldirs install_docs {- $disabled{fips} ? "" : "install_fips" -} install_msg
  498. install_msg :
  499. @ WRITE SYS$OUTPUT ""
  500. @ WRITE SYS$OUTPUT "######################################################################"
  501. @ WRITE SYS$OUTPUT ""
  502. @ IF "$(DESTDIR)" .EQS. "" THEN -
  503. @{- sourcefile("VMS", "msg_install.com") -} "$(SYSTARTUP)" "{- $osslver -}"
  504. @ IF "$(DESTDIR)" .NES. "" THEN -
  505. @{- sourcefile("VMS", "msg_staging.com") -} -
  506. "''installroot']" "''dataroot']" "$(INSTALLTOP)" "$(OPENSSLDIR)" -
  507. "$(SYSTARTUP)" "{- $osslver -}"
  508. check_install :
  509. spawn/nolog @ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com
  510. uninstall : uninstall_docs uninstall_sw {- $disabled{fips} ? "" : "uninstall_fips" -}
  511. # Because VMS wants the generation number (or *) to delete files, we can't
  512. # use $(LIBS), $(PROGRAMS), $(GENERATED) and $(MODULES) directly.
  513. libclean :
  514. {- join("\n\t", map { "- DELETE $_.OLB;*" } @libs) || "@ !" -}
  515. {- join("\n\t", map { "- DELETE $_.EXE;*,$_.MAP;*" } @shlibs) || "@ !" -}
  516. clean : libclean
  517. {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{htmldocs}->{man1}}) || "@ !" -}
  518. {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{htmldocs}->{man3}}) || "@ !" -}
  519. {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{htmldocs}->{man5}}) || "@ !" -}
  520. {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{htmldocs}->{man7}}) || "@ !" -}
  521. {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{programs}}) || "@ !" -}
  522. {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{modules}}) || "@ !" -}
  523. {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{scripts}}) || "@ !" -}
  524. {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{depends}->{""}}) || "@ !" -}
  525. {- join("\n\t", map { "- DELETE $_;*" } @generated) || "@ !" -}
  526. - DELETE [...]*.MAP;*
  527. - DELETE [...]*.D;*
  528. - DELETE [...]*.OBJ;*,*.LIS;*
  529. - DELETE []CXX$DEMANGLER_DB.;*
  530. - DELETE [.VMS]openssl_startup.com;*
  531. - DELETE [.VMS]openssl_shutdown.com;*
  532. - DELETE []vmsconfig.pm;*
  533. distclean : clean
  534. - DELETE [.include.openssl]configuration.h;*
  535. - DELETE configdata.pm;*
  536. - DELETE descrip.mms;*
  537. depend : descrip.mms
  538. @ ! {- output_off() if $disabled{makedepend}; "" -}
  539. @ $(PERL) {- sourcefile("util", "add-depends.pl") -} "{- $config{makedep_scheme} -}"
  540. @ ! {- output_on() if $disabled{makedepend}; "" -}
  541. # Install helper targets #############################################
  542. install_sw : install_dev install_engines install_modules -
  543. install_runtime install_startup install_ivp
  544. uninstall_sw : uninstall_dev uninstall_modules uninstall_engines -
  545. uninstall_runtime uninstall_startup uninstall_ivp
  546. install_docs : install_html_docs
  547. uninstall_docs : uninstall_html_docs
  548. {- output_off() if $disabled{fips}; "" -}
  549. install_fips : build_sw $(INSTALL_FIPSMODULECONF)
  550. @ WRITE SYS$OUTPUT "*** Installing FIPS module"
  551. - CREATE/DIR ossl_installroot:[MODULES{- $target{pointer_size} -}.'arch']
  552. - CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[000000]
  553. COPY/PROT=W:RE $(INSTALL_FIPSMODULES) -
  554. ossl_installroot:[MODULES{- $target{pointer_size} -}.'arch']$(FIPSMODULENAME)
  555. @ WRITE SYS$OUTPUT "*** Installing FIPS module configuration"
  556. COPY/PROT=W:RE $(INSTALL_FIPSMODULECONF) OSSL_DATAROOT:[000000]
  557. uninstall_fips :
  558. @ WRITE SYS$OUTPUT "*** Uninstalling FIPS module configuration"
  559. DELETE OSSL_DATAROOT:[000000]fipsmodule.cnf;*
  560. @ WRITE SYS$OUTPUT "*** Uninstalling FIPS module"
  561. DELETE ossl_installroot:[MODULES{- $target{pointer_size} -}.'arch']$(FIPSMODULENAME);*
  562. {- output_on() if $disabled{fips}; "" -}
  563. install_ssldirs : check_INSTALLTOP
  564. - CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[000000]
  565. IF F$SEARCH("OSSL_DATAROOT:[000000]CERTS.DIR;1") .EQS. "" THEN -
  566. CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[CERTS]
  567. IF F$SEARCH("OSSL_DATAROOT:[000000]PRIVATE.DIR;1") .EQS. "" THEN -
  568. CREATE/DIR/PROT=(S:RWED,O:RWE,G,W) OSSL_DATAROOT:[PRIVATE]
  569. IF F$SEARCH("OSSL_DATAROOT:[000000]MISC.DIR;1") .EQS. "" THEN -
  570. CREATE/DIR/PROT=(S:RWED,O:RWE,G,W) OSSL_DATAROOT:[MISC]
  571. COPY/PROT=W:RE $(MISC_SCRIPTS) OSSL_DATAROOT:[MISC]
  572. @ ! Install configuration file
  573. COPY/PROT=W:R {- sourcefile("apps", "openssl-vms.cnf") -} -
  574. ossl_dataroot:[000000]openssl.cnf-dist
  575. IF F$SEARCH("OSSL_DATAROOT:[000000]openssl.cnf") .EQS. "" THEN -
  576. COPY/PROT=W:R {- sourcefile("apps", "openssl-vms.cnf") -} -
  577. ossl_dataroot:[000000]openssl.cnf
  578. @ ! Install CTLOG configuration file
  579. COPY/PROT=W:R {- sourcefile("apps", "ct_log_list.cnf") -} -
  580. ossl_dataroot:[000000]ct_log_list.cnf-dist
  581. IF F$SEARCH("OSSL_DATAROOT:[000000]ct_log_list.cnf") .EQS. "" THEN -
  582. COPY/PROT=W:R {- sourcefile("apps", "ct_log_list.cnf") -} -
  583. ossl_dataroot:[000000]ct_log_list.cnf
  584. install_dev : check_INSTALLTOP install_runtime_libs
  585. @ WRITE SYS$OUTPUT "*** Installing development files"
  586. @ ! Install header files
  587. - CREATE/DIR ossl_installroot:[include.openssl]
  588. COPY/PROT=W:R ossl_sourceroot:[include.openssl]*.h -
  589. ossl_installroot:[include.openssl]
  590. COPY/PROT=W:R [.include.openssl]*.h ossl_installroot:[include.openssl]
  591. @ ! Install static (development) libraries
  592. - CREATE/DIR ossl_installroot:[LIB.'arch']
  593. {- join("\n ",
  594. map { "COPY/PROT=W:R $_.OLB ossl_installroot:[LIB.'arch']" }
  595. @install_libs) -}
  596. install_engines : check_INSTALLTOP install_runtime_libs build_modules
  597. @ {- output_off() unless scalar @install_engines; "" -} !
  598. @ WRITE SYS$OUTPUT "*** Installing engines"
  599. - CREATE/DIR ossl_installroot:[ENGINES{- $sover_dirname.$target{pointer_size} -}.'arch']
  600. {- join("\n ",
  601. map { "COPY/PROT=W:RE $_.EXE ossl_installroot:[ENGINES$sover_dirname$target{pointer_size}.'arch']" }
  602. @install_engines) -}
  603. @ {- output_on() unless scalar @install_engines; "" -} !
  604. install_modules : check_INSTALLTOP install_runtime_libs build_modules
  605. @ {- output_off() unless scalar @install_modules; "" -} !
  606. @ WRITE SYS$OUTPUT "*** Installing modules"
  607. - CREATE/DIR ossl_installroot:[MODULES{- $target{pointer_size} -}.'arch']
  608. {- join("\n ",
  609. map { "COPY/PROT=W:RE $_.EXE ossl_installroot:[MODULES$target{pointer_size}.'arch']" }
  610. @install_modules) -}
  611. @ {- output_on() unless scalar @install_modules; "" -} !
  612. install_runtime : install_programs
  613. install_runtime_libs : check_INSTALLTOP build_libs
  614. @ {- output_off() if $disabled{shared}; "" -} !
  615. @ WRITE SYS$OUTPUT "*** Installing shareable images"
  616. @ ! Install shared (runtime) libraries
  617. - CREATE/DIR ossl_installroot:[LIB.'arch']
  618. {- join("\n ",
  619. map { "COPY/PROT=W:R $_.EXE ossl_installroot:[LIB.'arch']" }
  620. @install_shlibs) -}
  621. @ {- output_on() if $disabled{shared}; "" -} !
  622. install_programs : check_INSTALLTOP install_runtime_libs build_programs
  623. @ {- output_off() if $disabled{apps}; "" -} !
  624. @ ! Install the main program
  625. - CREATE/DIR ossl_installroot:[EXE.'arch']
  626. COPY/PROT=W:RE [.APPS]openssl.EXE -
  627. ossl_installroot:[EXE.'arch']openssl{- $osslver -}.EXE
  628. @ ! Install scripts
  629. COPY/PROT=W:RE $(BIN_SCRIPTS) ossl_installroot:[EXE]
  630. @ ! {- output_on() if $disabled{apps}; "" -}
  631. install_startup : [.VMS]openssl_startup.com [.VMS]openssl_shutdown.com -
  632. [.VMS]openssl_utils.com, check_INSTALLTOP
  633. - CREATE/DIR ossl_installroot:[SYS$STARTUP]
  634. COPY/PROT=W:RE [.VMS]openssl_startup.com -
  635. ossl_installroot:[SYS$STARTUP]openssl_startup{- $osslver -}.com
  636. COPY/PROT=W:RE [.VMS]openssl_shutdown.com -
  637. ossl_installroot:[SYS$STARTUP]openssl_shutdown{- $osslver -}.com
  638. COPY/PROT=W:RE [.VMS]openssl_utils.com -
  639. ossl_installroot:[SYS$STARTUP]openssl_utils{- $osslver -}.com
  640. install_ivp : [.VMS]openssl_ivp.com check_INSTALLTOP
  641. - CREATE/DIR ossl_installroot:[SYSTEST]
  642. COPY/PROT=W:RE [.VMS]openssl_ivp.com -
  643. ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com
  644. [.VMS]openssl_startup.com : vmsconfig.pm {- sourcefile("VMS", "openssl_startup.com.in") -}
  645. - CREATE/DIR [.VMS]
  646. $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
  647. {- sourcefile("VMS", "openssl_startup.com.in") -} -
  648. > [.VMS]openssl_startup.com
  649. [.VMS]openssl_utils.com : vmsconfig.pm {- sourcefile("VMS", "openssl_utils.com.in") -}
  650. - CREATE/DIR [.VMS]
  651. $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
  652. {- sourcefile("VMS", "openssl_utils.com.in") -} -
  653. > [.VMS]openssl_utils.com
  654. [.VMS]openssl_shutdown.com : vmsconfig.pm {- sourcefile("VMS", "openssl_shutdown.com.in") -}
  655. - CREATE/DIR [.VMS]
  656. $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
  657. {- sourcefile("VMS", "openssl_shutdown.com.in") -} -
  658. > [.VMS]openssl_shutdown.com
  659. [.VMS]openssl_ivp.com : vmsconfig.pm {- sourcefile("VMS", "openssl_ivp.com.in") -}
  660. - CREATE/DIR [.VMS]
  661. $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
  662. {- sourcefile("VMS", "openssl_ivp.com.in") -} -
  663. > [.VMS]openssl_ivp.com
  664. vmsconfig.pm : configdata.pm
  665. OPEN/WRITE/SHARE=READ CONFIG []vmsconfig.pm
  666. WRITE CONFIG "package vmsconfig;"
  667. WRITE CONFIG "use strict; use warnings;"
  668. WRITE CONFIG "use Exporter;"
  669. WRITE CONFIG "our @ISA = qw(Exporter);"
  670. WRITE CONFIG "our @EXPORT = qw(%config %target %withargs %unified_info %disabled);"
  671. WRITE CONFIG "our %config = ("
  672. WRITE CONFIG " target => '","{- $config{target} -}","',"
  673. WRITE CONFIG " version => '","{- $config{version} -}","',"
  674. WRITE CONFIG " shlib_version => '","{- $config{shlib_version} -}","',"
  675. WRITE CONFIG " shlib_major => '","{- $config{shlib_major} -}","',"
  676. WRITE CONFIG " shlib_minor => '","{- $config{shlib_minor} -}","',"
  677. WRITE CONFIG " no_shared => '","{- $disabled{shared} -}","',"
  678. WRITE CONFIG " INSTALLTOP => '$(INSTALLTOP)',"
  679. WRITE CONFIG " OPENSSLDIR => '$(OPENSSLDIR)',"
  680. WRITE CONFIG " pointer_size => '","{- $target{pointer_size} -}","',"
  681. WRITE CONFIG ");"
  682. WRITE CONFIG "our %target = ();"
  683. WRITE CONFIG "our %disabled = ();"
  684. WRITE CONFIG "our %withargs = ();"
  685. WRITE CONFIG "our %unified_info = ();"
  686. WRITE CONFIG "1;"
  687. CLOSE CONFIG
  688. install_html_docs : check_INSTALLTOP build_html_docs
  689. @ WRITE SYS$OUTPUT "*** Installing HTML docs"
  690. - CREATE/DIR ossl_installroot:[HTML.MAN1]
  691. - CREATE/DIR ossl_installroot:[HTML.MAN3]
  692. - CREATE/DIR ossl_installroot:[HTML.MAN5]
  693. - CREATE/DIR ossl_installroot:[HTML.MAN7]
  694. {- join("\n ",
  695. ( map { "COPY/PROT=W:RE $_ ossl_installroot:[HTML.MAN1]" }
  696. @{$unified_info{htmldocs}->{man1}} ),
  697. ( map { "COPY/PROT=W:RE $_ ossl_installroot:[HTML.MAN3]" }
  698. @{$unified_info{htmldocs}->{man3}} ),
  699. ( map { "COPY/PROT=W:RE $_ ossl_installroot:[HTML.MAN5]" }
  700. @{$unified_info{htmldocs}->{man5}} ),
  701. ( map { "COPY/PROT=W:RE $_ ossl_installroot:[HTML.MAN7]" }
  702. @{$unified_info{htmldocs}->{man7}} )) -}
  703. check_INSTALLTOP :
  704. @ IF "$(INSTALLTOP)" .EQS. "" THEN -
  705. WRITE SYS$ERROR "INSTALLTOP should not be empty"
  706. @ IF "$(INSTALLTOP)" .EQS. "" THEN -
  707. EXIT %x10000002
  708. # Developer targets ##################################################
  709. debug_logicals :
  710. SH LOGICAL/PROC openssl,internal,ossl_installroot,ossl_dataroot
  711. # Building targets ###################################################
  712. descrip.mms : configdata.pm {- join(" ", @{$config{build_file_templates}}) -}
  713. perl configdata.pm
  714. @ WRITE SYS$OUTPUT "*************************************************"
  715. @ WRITE SYS$OUTPUT "*** ***"
  716. @ WRITE SYS$OUTPUT "*** Please run the same mms command again ***"
  717. @ WRITE SYS$OUTPUT "*** ***"
  718. @ WRITE SYS$OUTPUT "*************************************************"
  719. @ PIPE ( EXIT %X10000000 )
  720. configdata.pm : $(SRCDIR)Configure $(SRCDIR)config.com {- join(" ", @{$config{build_infos}}, @{$config{conf_files}}) -}
  721. perl configdata.pm -r
  722. @ WRITE SYS$OUTPUT "*************************************************"
  723. @ WRITE SYS$OUTPUT "*** ***"
  724. @ WRITE SYS$OUTPUT "*** Please run the same mms command again ***"
  725. @ WRITE SYS$OUTPUT "*** ***"
  726. @ WRITE SYS$OUTPUT "*************************************************"
  727. @ PIPE ( EXIT %X10000000 )
  728. reconfigure reconf :
  729. perl configdata.pm -r
  730. {-
  731. use File::Basename;
  732. use File::Spec::Functions qw/abs2rel rel2abs catfile catdir/;
  733. use File::Spec::Unix;
  734. # Helper function to convert dependencies in platform agnostic form to
  735. # dependencies in platform form.
  736. sub compute_platform_depends {
  737. map { my $x = $_;
  738. grep { $x eq $_ } @{$unified_info{programs}} and platform->bin($x)
  739. or grep { $x eq $_ } @{$unified_info{modules}} and platform->dso($x)
  740. or grep { $x eq $_ } @{$unified_info{libraries}} and platform->lib($x)
  741. or platform->convertext($x); } @_;
  742. }
  743. # Helper function to figure out dependencies on libraries
  744. # It takes a list of library names and outputs a list of dependencies
  745. sub compute_lib_depends {
  746. # Depending on shared libraries:
  747. # On Windows POSIX layers, we depend on {libname}.dll.a
  748. # On Unix platforms, we depend on {shlibname}.so
  749. return map {
  750. { lib => platform->sharedlib($_) // platform->staticlib($_),
  751. attrs => $unified_info{attributes}->{libraries}->{$_} }
  752. } @_;
  753. }
  754. # Helper function to deal with inclusion directory specs.
  755. # We're dealing with two issues:
  756. # 1. A lot of include directory specs take up a lot of command line real
  757. # estate, and the DCL command line is very limited (2KiB).
  758. # 2. For optimal usage, include directory paths must be in Unix form,
  759. # that's the only way the C compiler can merge multiple include paths
  760. # in a sane way (we can stop worrying about 1.h including foo/2.h
  761. # including ../3.h).
  762. #
  763. # To resolve 1, we need to create a file with include directory pragmas,
  764. # and let the compiler use it with /FIRST_INCLUDE=.
  765. # To resolve 2, we convert all include directory specs we get to Unix,
  766. # with available File::Spec functions.
  767. #
  768. # We use CRC-24 from https://tools.ietf.org/html/rfc4880#section-6,
  769. # reimplemented in Perl to get a workable and constant file name for each
  770. # combination of include directory specs. It is assumed that the order of
  771. # these directories don't matter.
  772. #
  773. # This function takes as input a list of include directories
  774. # This function returns a list two things:
  775. # 1. The file name to use with /FIRST_INCLUDE=
  776. # 2. Text to insert into descrip.mms (may be the empty string)
  777. sub crc24 {
  778. my $input = shift;
  779. my $init_value = 0x00B704CE;
  780. my $poly_value = 0x01864CFB;
  781. my $crc = $init_value;
  782. foreach my $x (unpack ('C*', $input)) {
  783. $crc ^= $x << 16;
  784. for (my $i; $i < 8; $i++) {
  785. $crc <<= 1;
  786. if ($crc & 0x01000000) {
  787. $crc ^= $poly_value;
  788. }
  789. }
  790. }
  791. $crc &= 0xFFFFFF;
  792. return $crc;
  793. }
  794. my %includefile_cache;
  795. sub make_includefile {
  796. my %dirs = map {
  797. my $udir = make_unix_path(rel2abs($_));
  798. $udir => 1;
  799. } @_;
  800. my @dirs = sort keys %dirs;
  801. my $filename = sprintf 'incdirs_%x.h', crc24(join(',', @dirs));
  802. if ($includefile_cache{$filename}) {
  803. return ($filename, "");
  804. }
  805. my $scripture = <<"EOF";
  806. $filename :
  807. open/write inc_output $filename
  808. EOF
  809. foreach (@dirs) {
  810. $scripture .= <<"EOF";
  811. write inc_output "#pragma include_directory ""$_"""
  812. EOF
  813. }
  814. $scripture .= <<"EOF";
  815. close inc_output
  816. EOF
  817. $includefile_cache{$filename} = $scripture;
  818. return ($filename, $scripture);
  819. }
  820. # On VMS, (some) header file directories include the files
  821. # __DECC_INCLUDE_EPILOGUE.H and __DECC_INCLUDE_PROLOGUE.H.
  822. # When header files are generated, and the build directory
  823. # isn't the same as the source directory, these files must
  824. # be copied alongside the generated header file, or their
  825. # effect will be lost.
  826. # We use the same include file cache as make_includefile
  827. # to check if the scripture to copy these files has already
  828. # been generated.
  829. sub make_decc_include_files {
  830. my $outd = shift;
  831. my $ind = shift;
  832. # If the build directory and the source directory are the
  833. # same, there's no need to copy the prologue and epilogue
  834. # files.
  835. return ('') if $outd eq $ind;
  836. my $outprologue = catfile($outd, '__DECC_INCLUDE_PROLOGUE.H');
  837. my $outepilogue = catfile($outd, '__DECC_INCLUDE_EPILOGUE.H');
  838. my $inprologue = catfile($ind, '__DECC_INCLUDE_PROLOGUE.H');
  839. my $inepilogue = catfile($ind, '__DECC_INCLUDE_EPILOGUE.H');
  840. my @filenames = ();
  841. my $scripture = '';
  842. if ($includefile_cache{$outprologue}) {
  843. push @filenames, $outprologue;
  844. } elsif (-f $inprologue) {
  845. my $local_scripture .= <<"EOF";
  846. $outprologue : $inprologue
  847. COPY $inprologue $outprologue
  848. EOF
  849. $includefile_cache{$outprologue} = $local_scripture;
  850. push @filenames, $outprologue;
  851. $scripture .= $local_scripture;
  852. }
  853. if ($includefile_cache{$outepilogue}) {
  854. push @filenames, $outepilogue;
  855. } elsif (-f $inepilogue) {
  856. my $local_scripture .= <<"EOF";
  857. $outepilogue : $inepilogue
  858. COPY $inepilogue $outepilogue
  859. EOF
  860. $includefile_cache{$outepilogue} = $local_scripture;
  861. push @filenames, $outepilogue;
  862. $scripture .= $local_scripture;
  863. }
  864. return (@filenames, $scripture);
  865. }
  866. sub generatetarget {
  867. my %args = @_;
  868. my $deps = join(" ", compute_platform_depends(@{$args{deps}}));
  869. return <<"EOF";
  870. $args{target} : $deps
  871. EOF
  872. }
  873. sub generatesrc {
  874. my %args = @_;
  875. my $gen0 = $args{generator}->[0];
  876. my $gen_args = join('', map { " $_" }
  877. @{$args{generator}}[1..$#{$args{generator}}]);
  878. my $gen_incs = join("", map { ' "-I'.$_.'"' } @{$args{generator_incs}});
  879. my $deps = join(", -\n\t\t",
  880. compute_platform_depends(@{$args{generator_deps}},
  881. @{$args{deps}}));
  882. if ($args{src} =~ /\.html$/) {
  883. #
  884. # HTML generator
  885. #
  886. my $title = basename($args{src}, ".html");
  887. my $pod = $gen0;
  888. my $mkpod2html = sourcefile('util', 'mkpod2html.pl');
  889. my $srcdoc = sourcedir('doc');
  890. return <<"EOF";
  891. $args{src} : $pod
  892. \$(PERL) $mkpod2html -i $pod -o \$\@ -t "$title" -r "$srcdoc"
  893. EOF
  894. } elsif ($args{src} =~ /\.(\d)$/) {
  895. #
  896. # Man-page generator, on VMS we simply ignore man-pages
  897. #
  898. return "";
  899. } elsif (platform->isdef($args{src})) {
  900. #
  901. # Linker script-ish generator
  902. #
  903. my $target = platform->def($args{src});
  904. my $mkdef = sourcefile('util', 'mkdef.pl');
  905. my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION_NUMBER)' : '';
  906. my $ord_name =
  907. $args{generator}->[1] || basename($args{product}, '.EXE');
  908. my $case_insensitive =
  909. $target{$args{intent}.'_cflags'} =~ m|/NAMES=[^/]*AS_IS|i
  910. ? '' : ' --case-insensitive';
  911. return <<"EOF";
  912. $target : $gen0 $deps $mkdef
  913. \$(PERL) $mkdef$ord_ver --type $args{intent} --ordinals $gen0 --name $ord_name "--OS" "VMS"$case_insensitive > $target
  914. EOF
  915. } elsif (platform->isasm($args{src})
  916. || platform->iscppasm($args{src})) {
  917. #
  918. # Assembler generator
  919. #
  920. my $cppflags =
  921. { shlib => "$lib_cflags $lib_cppflags",
  922. lib => "$lib_cflags $lib_cppflags",
  923. dso => "$dso_cflags $dso_cppflags",
  924. bin => "$bin_cflags $bin_cppflags" } -> {$args{intent}};
  925. my $defs = join("", map { ",".$_ } @{$args{defs}});
  926. my $target = platform->isasm($args{src})
  927. ? platform->asm($args{src})
  928. : $args{src};
  929. my $generator;
  930. if ($gen0 =~ /\.pl$/) {
  931. $generator = '$(PERL)'.$gen_incs.' '.$gen0.$gen_args
  932. .' '.$cppflags;
  933. } elsif ($gen0 =~ /\.S$/) {
  934. $generator = undef;
  935. } else {
  936. die "Generator type for $src unknown: $gen0.$gen_args\n";
  937. }
  938. if (defined($generator)) {
  939. return <<"EOF";
  940. $target : $gen0 $deps
  941. \@ extradefines = "$defs"
  942. $generator \$\@
  943. \@ DELETE/SYMBOL/LOCAL extradefines
  944. EOF
  945. }
  946. return <<"EOF";
  947. $target : $gen0 $deps
  948. \@ extradefines = "$defs"
  949. PIPE \$(CPP) $cppflags $gen0 | -
  950. \$(PERL) "-ne" "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" > \$\@
  951. \@ DELETE/SYMBOL/LOCAL extradefines
  952. EOF
  953. } elsif ($gen0 =~ m|^.*\.in$|) {
  954. #
  955. # "dofile" generator (file.in -> file)
  956. #
  957. my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
  958. "util", "dofile.pl")),
  959. rel2abs($config{builddir}));
  960. my @perlmodules = ();
  961. my %perlmoduleincs = ();
  962. my %perlmoduledeps = ();
  963. foreach my $x (('configdata.pm', @{$args{deps}})) {
  964. # Compute (i)nclusion directory, (m)odule name and (d)ependency
  965. my $i, $m, $d;
  966. if ($x =~ /\|/) {
  967. $i = $`;
  968. $d = $';
  969. # Massage the module part to become a real perl module spec
  970. $m = $d;
  971. $m =~ s|\.pm$||;
  972. # Directory specs are :: in perl package names
  973. $m =~ s|/|::|g;
  974. # Full file name of the dependency
  975. $d = catfile($i, $d) if $i;
  976. } elsif ($x =~ /\.pm$/) {
  977. $i = dirname($x);
  978. $m = basename($x, '.pm');
  979. $d = $x;
  980. } else {
  981. # All other dependencies are simply collected
  982. $d = $x;
  983. }
  984. push @perlmodules, '"-M'.$m.'"' if $m;
  985. $perlmoduledeps{$d} = 1;
  986. $perlmoduleincs{'"-I'.$i.'"'} = 1 if $i;
  987. }
  988. my @decc_include_data
  989. = make_decc_include_files(dirname($args{src}), dirname($gen0));
  990. my $decc_include_scripture = pop @decc_include_data;
  991. # Because of the special treatment of dependencies, we need to
  992. # recompute $deps completely
  993. my $deps
  994. = join(" ", @decc_include_data,
  995. compute_platform_depends(@{$args{generator_deps}},
  996. sort keys %perlmoduledeps));
  997. my $perlmodules = join(' ', '', ( sort keys %perlmoduleincs ), @perlmodules);
  998. return <<"EOF";
  999. $args{src} : $gen0 $deps
  1000. \$(PERL)$perlmodules $dofile "-o$target{build_file}" $gen0$gen_args > \$\@
  1001. $decc_include_scripture
  1002. EOF
  1003. } elsif (grep { $_ eq $gen0 } @{$unified_info{programs}}) {
  1004. #
  1005. # Generic generator using OpenSSL programs
  1006. #
  1007. # Redo $gen0, to ensure that we have the proper extension
  1008. $gen0 = platform->bin($gen0);
  1009. return <<"EOF";
  1010. $args{src} : $gen0 $deps
  1011. PIPE MCR $gen0$gen_args > \$@
  1012. EOF
  1013. } else {
  1014. #
  1015. # Generic generator using Perl
  1016. #
  1017. return <<"EOF";
  1018. $args{src} : $gen0 $deps
  1019. \$(PERL)$gen_incs $gen0$gen_args > \$\@
  1020. EOF
  1021. }
  1022. }
  1023. sub src2obj {
  1024. my $asmext = platform->asmext();
  1025. my %args = @_;
  1026. my @srcs =
  1027. map { my $x = $_;
  1028. (platform->isasm($x) && grep { $x eq $_ } @generated)
  1029. ? platform->asm($x) : $x }
  1030. ( @{$args{srcs}} );
  1031. my $obj = platform->obj($args{obj});
  1032. my $dep = platform->dep($args{obj});
  1033. my $deps = join(", -\n\t\t", @srcs, @{$args{deps}});
  1034. # Because VMS C isn't very good at combining a /INCLUDE path with
  1035. # #includes having a relative directory (like '#include "../foo.h"),
  1036. # the best choice is to move to the first source file's intended
  1037. # directory before compiling, and make sure to write the object file
  1038. # in the correct position (important when the object tree is other
  1039. # than the source tree).
  1040. my $forward = dirname($args{srcs}->[0]);
  1041. my $backward = abs2rel(rel2abs("."), rel2abs($forward));
  1042. my $objd = abs2rel(rel2abs(dirname($obj)), rel2abs($forward));
  1043. my $objn = basename($obj);
  1044. my $depd = abs2rel(rel2abs(dirname($dep)), rel2abs($forward));
  1045. my $depn = basename($dep);
  1046. my $srcs =
  1047. join(", ", map { abs2rel(rel2abs($_), rel2abs($forward)) } @srcs);
  1048. my $incextra = join(',', map { "\"$_\"" }
  1049. @{$unified_info{includes_extra}->{$obj}});
  1050. $incextra = "/INCLUDE=($incextra)" if $incextra;
  1051. my $cflags;
  1052. if ($args{attrs}->{noinst}) {
  1053. $cflags .= { shlib => $lib_cflags_no_inst,
  1054. lib => $lib_cflags_no_inst,
  1055. dso => $dso_cflags_no_inst,
  1056. bin => $bin_cflags_no_inst } -> {$args{intent}};
  1057. } else {
  1058. $cflags .= { shlib => $lib_cflags,
  1059. lib => $lib_cflags,
  1060. dso => $dso_cflags,
  1061. bin => $bin_cflags } -> {$args{intent}};
  1062. }
  1063. $cflags .= { shlib => $lib_cppflags,
  1064. lib => $lib_cppflags,
  1065. dso => $dso_cppflags,
  1066. bin => $bin_cppflags } -> {$args{intent}};
  1067. $cflags .= $incextra;
  1068. my $defs = join("", map { ",".$_ } @{$args{defs}});
  1069. my $asflags = { shlib => $lib_asflags,
  1070. lib => $lib_asflags,
  1071. dso => $dso_asflags,
  1072. bin => $bin_asflags } -> {$args{intent}};
  1073. if ($srcs[0] =~ /\Q${asmext}\E$/) {
  1074. return <<"EOF";
  1075. $obj : $deps
  1076. SET DEFAULT $forward
  1077. \$(AS) $asflags \$(ASOUTFLAG)${objd}${objn} $srcs
  1078. SET DEFAULT $backward
  1079. - PURGE $obj
  1080. EOF
  1081. } elsif ($srcs[0] =~ /.S$/) {
  1082. return <<"EOF";
  1083. $obj : $deps
  1084. SET DEFAULT $forward
  1085. \@ $incs_on
  1086. \@ extradefines = "$defs"
  1087. PIPE \$(CPP) ${cflags} $srcs | -
  1088. \$(PERL) -ne "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" -
  1089. > ${objd}${objn}-asm
  1090. \@ DELETE/SYMBOL/LOCAL extradefines
  1091. \@ $incs_off
  1092. SET DEFAULT $backward
  1093. \$(AS) $asflags \$(ASOUTFLAG)$obj $obj-asm
  1094. - PURGE $obj
  1095. EOF
  1096. }
  1097. my ($incdir_filename, $incdir_scripture) =
  1098. make_includefile(@{ { shlib => [ @lib_cppincludes ],
  1099. lib => [ @lib_cppincludes ],
  1100. dso => [ @dso_cppincludes ],
  1101. bin => [ @bin_cppincludes ] } -> {$args{intent}} },
  1102. @{$args{incs}});
  1103. $deps .= ", -\n\t\t$incdir_filename";
  1104. $cflags =
  1105. $target{cflag_incfirst}
  1106. . '"'.make_unix_path(rel2abs($incdir_filename)).'"'
  1107. . $cflags;
  1108. my $depbuild = $disabled{makedepend} ? ""
  1109. : " /MMS=(FILE=${depd}${depn},TARGET=$obj)";
  1110. return <<"EOF";
  1111. $obj : $deps
  1112. SET DEFAULT $forward
  1113. \@ $incs_on
  1114. \@ extradefines = "$defs"
  1115. \$(CC) ${cflags}${depbuild} /OBJECT=${objd}${objn} /REPOSITORY=$backward $srcs
  1116. \@ DELETE/SYMBOL/LOCAL extradefines
  1117. \@ $incs_off
  1118. SET DEFAULT $backward
  1119. - PURGE $obj
  1120. $incdir_scripture
  1121. EOF
  1122. }
  1123. sub obj2shlib {
  1124. my %args = @_;
  1125. my $shlibname = platform->sharedname($args{lib});
  1126. my $shlib = platform->sharedlib($args{lib});
  1127. my @objs = map { platform->convertext($_) }
  1128. grep { platform->isobj($_) }
  1129. @{$args{objs}};
  1130. my @defs = map { platform->convertext($_) }
  1131. grep { platform->isdef($_) }
  1132. @{$args{objs}};
  1133. my @deps = compute_lib_depends(@{$args{deps}});
  1134. die "More than one symbol vector" if scalar @defs > 1;
  1135. my $deps = join(", -\n\t\t", @objs, @defs, map { $_->{lib} } @deps);
  1136. my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
  1137. my $translatesyms_pl = abs2rel(rel2abs(catfile($config{sourcedir},
  1138. "VMS", "translatesyms.pl")),
  1139. rel2abs($config{builddir}));
  1140. # The "[]" hack is because in .OPT files, each line inherits the
  1141. # previous line's file spec as default, so if no directory spec
  1142. # is present in the current line and the previous line has one that
  1143. # doesn't apply, you're in for a surprise.
  1144. my $write_opt1 =
  1145. join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
  1146. "WRITE OPT_FILE \"$x" } @objs).
  1147. "\"";
  1148. my $write_opt2 =
  1149. join("\n\t", map { my $x = $_->{lib} =~ /\[/
  1150. ? $_->{lib} : "[]".$_->{lib};
  1151. $x =~ s|(\.EXE)|$1/SHARE|;
  1152. $x =~ s|(\.OLB)|$1/LIB|;
  1153. "WRITE OPT_FILE \"$x\"" } @deps)
  1154. || "\@ !";
  1155. return <<"EOF"
  1156. $shlib : $deps
  1157. \$(PERL) $translatesyms_pl \$(BLDDIR)CXX\$DEMANGLER_DB. < $defs[0] > $defs[0]-translated
  1158. OPEN/WRITE/SHARE=READ OPT_FILE $shlibname-components.OPT
  1159. $write_opt1
  1160. $write_opt2
  1161. CLOSE OPT_FILE
  1162. LINK ${lib_ldflags}/SHARE=\$\@ $defs[0]-translated/OPT,-
  1163. $shlibname-components.OPT/OPT \$(LIB_EX_LIBS)
  1164. DELETE $defs[0]-translated;*,$shlibname-components.OPT;*
  1165. PURGE $shlibname.EXE,$shlibname.MAP
  1166. EOF
  1167. . ($config{target} =~ m|alpha| ? "" : <<"EOF"
  1168. SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
  1169. EOF
  1170. );
  1171. }
  1172. sub obj2dso {
  1173. my %args = @_;
  1174. my $dsoname = platform->dsoname($args{module});
  1175. my $dso = platform->dso($args{module});
  1176. my @objs = map { platform->convertext($_) }
  1177. grep { platform->isobj($_) }
  1178. @{$args{objs}};
  1179. my @defs = map { platform->convertext($_) }
  1180. grep { platform->isdef($_) }
  1181. @{$args{objs}};
  1182. my @deps = compute_lib_depends(@{$args{deps}});
  1183. my $deps = join(", -\n\t\t", @objs, @defs, map { $_->{lib} } @deps);
  1184. die "More than one symbol vector" if scalar @defs > 1;
  1185. my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
  1186. # The "[]" hack is because in .OPT files, each line inherits the
  1187. # previous line's file spec as default, so if no directory spec
  1188. # is present in the current line and the previous line has one that
  1189. # doesn't apply, you're in for a surprise.
  1190. # Furthermore, we collect all object files and static libraries in
  1191. # an explicit cluster, to make it clear to the linker that these files
  1192. # shall be processed before shareable images.
  1193. # The shareable images are used with /SELECTIVE, to avoid warnings of
  1194. # multiply defined symbols when the module object files override some
  1195. # symbols that are present in the shareable image.
  1196. my $write_opt1 =
  1197. join(",-\"\n\t",
  1198. "\@ WRITE OPT_FILE \"CLUSTER=_,,",
  1199. (map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
  1200. "\@ WRITE OPT_FILE \"$x" } @objs),
  1201. (map { my $x = ($_->{lib} =~ /\[/) ? $_->{lib} : "[]".$_->{lib};
  1202. "\@ WRITE OPT_FILE \"$x/LIB" }
  1203. grep { $_->{lib} =~ m|\.OLB$| }
  1204. @deps))
  1205. ."\"";
  1206. my $write_opt2 =
  1207. join("\n\t",
  1208. (map { my $x = ($_->{lib} =~ /\[/) ? $_->{lib} : "[]".$_->{lib};
  1209. "\@ WRITE OPT_FILE \"$x/SHARE/SELECTIVE\"" }
  1210. grep { $_->{lib} =~ m|\.EXE$| }
  1211. @deps))
  1212. || "\@ !";
  1213. return <<"EOF"
  1214. $dso : $deps
  1215. OPEN/WRITE/SHARE=READ OPT_FILE $dsoname-components.OPT
  1216. $write_opt1
  1217. $write_opt2
  1218. CLOSE OPT_FILE
  1219. LINK ${dso_ldflags}/SHARE=\$\@ $defs[0]/OPT,-
  1220. $dsoname-components.OPT/OPT \$(DSO_EX_LIBS)
  1221. - PURGE $dsoname.EXE,$dsoname.OPT,$dsoname.MAP
  1222. EOF
  1223. . ($config{target} =~ m|alpha| ? "" : <<"EOF"
  1224. SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
  1225. EOF
  1226. );
  1227. }
  1228. sub obj2lib {
  1229. my %args = @_;
  1230. my $lib = platform->staticlib($args{lib});
  1231. my @objs = map { platform->convertext($_) }
  1232. grep { platform->isobj($_) }
  1233. @{$args{objs}};
  1234. my $objs = join(", -\n\t\t", @objs);
  1235. my $fill_lib = join("\n\t", (map { "LIBRARY/REPLACE $lib $_" } @objs));
  1236. return <<"EOF";
  1237. $lib : $objs
  1238. LIBRARY/CREATE/OBJECT $lib
  1239. $fill_lib
  1240. - PURGE $lib
  1241. EOF
  1242. }
  1243. sub obj2bin {
  1244. my %args = @_;
  1245. my $bin = platform->bin($args{bin});
  1246. my $binname = platform->binname($args{bin});
  1247. my @objs = map { platform->convertext($_) }
  1248. grep { platform->isobj($_) }
  1249. @{$args{objs}};
  1250. my $objs = join(",", @objs);
  1251. my @deps = compute_lib_depends(@{$args{deps}});
  1252. my $deps = join(", -\n\t\t", @objs, map { $_->{lib} } @deps);
  1253. my $olb_count = scalar grep(m|\.OLB$|, map { $_->{lib} } @deps);
  1254. my $analyse_objs = "@ !";
  1255. if ($olb_count > 0) {
  1256. my $analyse_quals =
  1257. $config{target} =~ m|alpha| ? "/GSD" : "/SECTIONS=SYMTAB";
  1258. $analyse_objs = "- pipe ANALYSE/OBJECT$analyse_quals $objs | SEARCH SYS\$INPUT \"\"\"main\"\"\" ; nomain = \$severity .NE. 1"
  1259. }
  1260. # The "[]" hack is because in .OPT files, each line inherits the
  1261. # previous line's file spec as default, so if no directory spec
  1262. # is present in the current line and the previous line has one that
  1263. # doesn't apply, you're in for a surprise.
  1264. my $write_opt1 =
  1265. "\@ WRITE OPT_FILE \"CASE_SENSITIVE=YES\"\n\t"
  1266. .join(",-\"\n\t",
  1267. "\@ WRITE OPT_FILE \"CLUSTER=_,,",
  1268. (map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
  1269. "\@ WRITE OPT_FILE \"$x" } @objs),
  1270. (map { my $x = ($_->{lib} =~ /\[/) ? $_->{lib} : "[]".$_->{lib};
  1271. # Special hack to include the MAIN object module
  1272. # explicitly, if it's known that there is one.
  1273. # |incmain| is defined in the rule generation further
  1274. # down, with the necessary /INCLUDE=main option unless
  1275. # the program has been determined to have a main function
  1276. # already.
  1277. $_->{attrs}->{has_main}
  1278. ? "\@ WRITE OPT_FILE \"$x/LIB''incmain'"
  1279. : "\@ WRITE OPT_FILE \"$x/LIB" }
  1280. grep { $_->{lib} =~ m|\.OLB$| }
  1281. @deps))
  1282. ."\"";
  1283. my $write_opt2 =
  1284. join("\n\t",
  1285. (map { my $x = $_->{lib} =~ /\[/ ? $_->{lib} : "[]".$_->{lib};
  1286. "\@ WRITE OPT_FILE \"$x/SHARE/SELECTIVE\"" }
  1287. grep { $_->{lib} =~ m|\.EXE$| }
  1288. @deps))
  1289. || "\@ !";
  1290. # The linking commands looks a bit complex, but it's for good reason.
  1291. # When you link, say, foo.obj, bar.obj and libsomething.exe/share, and
  1292. # bar.obj happens to have a symbol that also exists in libsomething.exe,
  1293. # the linker will warn about it, loudly, and will then choose to pick
  1294. # the first copy encountered (the one in bar.obj in this example).
  1295. # On Unix and on Windows, the corresponding maneuver goes through
  1296. # silently with the same effect.
  1297. # With some test programs, made for checking the internals of OpenSSL,
  1298. # we do this kind of linking deliberately, picking a few specific object
  1299. # files from within [.crypto] or [.ssl] so we can reach symbols that are
  1300. # otherwise unreachable (since the shareable images only exports the
  1301. # symbols listed in [.util]*.num), and then with the shared libraries
  1302. # themselves. So we need to silence the warning about multiply defined
  1303. # symbols, to mimic the way linking work on Unix and Windows, and so
  1304. # the build isn't interrupted (MMS stops when warnings are signaled,
  1305. # by default), and so someone building doesn't have to worry where it
  1306. # isn't necessary. If there are other warnings, however, we show them
  1307. # and let it break the build.
  1308. return <<"EOF"
  1309. $bin : $deps
  1310. $analyse_objs
  1311. @ incmain = "/INCLUDE=main"
  1312. @ IF .NOT. nomain THEN incmain = ""
  1313. @ OPEN/WRITE/SHARE=READ OPT_FILE $binname.OPT
  1314. $write_opt1
  1315. $write_opt2
  1316. @ CLOSE OPT_FILE
  1317. TYPE $binname.OPT ! For debugging
  1318. - pipe SPAWN/WAIT/NOLOG/OUT=$binname.LINKLOG -
  1319. LINK ${bin_ldflags}/EXEC=\$\@ $binname.OPT/OPT \$(BIN_EX_LIBS) ; -
  1320. link_status = \$status ; link_severity = link_status .AND. 7
  1321. @ search_severity = 1
  1322. -@ IF link_severity .EQ. 0 THEN -
  1323. pipe SEARCH $binname.LINKLOG "%","-"/MATCH=AND | -
  1324. SPAWN/WAIT/NOLOG/OUT=NLA0: -
  1325. SEARCH SYS\$INPUT: "-W-MULDEF,"/MATCH=NOR ; -
  1326. search_severity = \$severity
  1327. @ ! search_severity is 3 when the last search didn't find any matching
  1328. @ ! string: %SEARCH-I-NOMATCHES, no strings matched
  1329. @ ! If that was the result, we pretend linking got through without
  1330. @ ! fault or warning.
  1331. @ IF search_severity .EQ. 3 THEN link_severity = 1
  1332. @ ! At this point, if link_severity shows that there was a fault
  1333. @ ! or warning, make sure to restore the linking status.
  1334. -@ IF .NOT. link_severity THEN TYPE $binname.LINKLOG
  1335. -@ DELETE $binname.LINKLOG;*
  1336. @ IF .NOT. link_severity THEN SPAWN/WAIT/NOLOG EXIT 'link_status'
  1337. - PURGE $bin,$binname.OPT
  1338. EOF
  1339. . ($config{target} =~ m|alpha| ? "" : <<"EOF"
  1340. SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
  1341. EOF
  1342. );
  1343. }
  1344. sub in2script {
  1345. my %args = @_;
  1346. my $script = $args{script};
  1347. return "" if grep { $_ eq $script } @{$args{sources}}; # No overwrite!
  1348. my $sources = join(" ", @{$args{sources}});
  1349. my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
  1350. "util", "dofile.pl")),
  1351. rel2abs($config{builddir}));
  1352. return <<"EOF";
  1353. $script : $sources configdata.pm
  1354. \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile -
  1355. "-o$target{build_file}" $sources > $script
  1356. SET FILE/PROT=(S:RWED,O:RWED,G:RE,W:RE) $script
  1357. PURGE $script
  1358. EOF
  1359. }
  1360. "" # Important! This becomes part of the template result.
  1361. -}