descrip.mms.tmpl 61 KB

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