2
0

descrip.mms.tmpl 60 KB

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