descrip.mms.tmpl 58 KB

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