descrip.mms.tmpl 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146
  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. # Our prefix, claimed when speaking with the VSI folks Tuesday
  8. # January 26th 2016
  9. our $osslprefix = 'OSSL$';
  10. (our $osslprefix_q = $osslprefix) =~ s/\$/\\\$/;
  11. our $sover_dirname = sprintf "%02d%02d", split(/\./, $config{shlib_version_number});
  12. our $osslver = sprintf "%02d%02d", split(/\./, $config{version});
  13. our $sourcedir = $config{sourcedir};
  14. our $builddir = $config{builddir};
  15. sub sourcefile {
  16. catfile($sourcedir, @_);
  17. }
  18. sub buildfile {
  19. catfile($builddir, @_);
  20. }
  21. sub sourcedir {
  22. catdir($sourcedir, @_);
  23. }
  24. sub builddir {
  25. catdir($builddir, @_);
  26. }
  27. sub tree {
  28. (my $x = shift) =~ s|\]$|...]|;
  29. $x
  30. }
  31. sub move {
  32. my $f = catdir(@_);
  33. my $b = abs2rel(rel2abs("."),rel2abs($f));
  34. $sourcedir = catdir($b,$sourcedir)
  35. if !file_name_is_absolute($sourcedir);
  36. $builddir = catdir($b,$builddir)
  37. if !file_name_is_absolute($builddir);
  38. "";
  39. }
  40. # Because we need to make two computations of these data,
  41. # we store them in arrays for reuse
  42. our @libs =
  43. map { (my $x = $_) =~ s/\.a$//; $x }
  44. @{$unified_info{libraries}};
  45. our @shlibs =
  46. map { $unified_info{sharednames}->{$_} || () }
  47. grep(!/\.a$/, @{$unified_info{libraries}});
  48. our @install_libs =
  49. map { (my $x = $_) =~ s/\.a$//; $x }
  50. @{$unified_info{install}->{libraries}};
  51. our @install_shlibs =
  52. map { $unified_info{sharednames}->{$_} || () }
  53. grep(!/\.a$/, @{$unified_info{install}->{libraries}});
  54. # This is a horrible hack, but is needed because recursive inclusion of files
  55. # in different directories does not work well with HP C.
  56. my $sd = sourcedir("crypto", "async", "arch");
  57. foreach (grep /\[\.crypto\.async\.arch\].*\.o$/, keys %{$unified_info{sources}}) {
  58. (my $x = $_) =~ s|\.o$|.OBJ|;
  59. $unified_info{before}->{$x}
  60. = qq(arch_include = F\$PARSE("$sd","A.;",,,"SYNTAX_ONLY") - "A.;"
  61. define arch 'arch_include');
  62. $unified_info{after}->{$x}
  63. = qq(deassign arch);
  64. }
  65. my $sd1 = sourcedir("ssl","record");
  66. my $sd2 = sourcedir("ssl","statem");
  67. my @ssl_locl_users = grep(/^\[\.(?:ssl\.(?:record|statem)|test)\].*\.o$/,
  68. keys %{$unified_info{sources}});
  69. foreach (@ssl_locl_users) {
  70. (my $x = $_) =~ s|\.o$|.OBJ|;
  71. $unified_info{before}->{$x}
  72. = qq(record_include = F\$PARSE("$sd1","A.;",,,"SYNTAX_ONLY") - "A.;"
  73. define record 'record_include'
  74. statem_include = F\$PARSE("$sd2","A.;",,,"SYNTAX_ONLY") - "A.;"
  75. define statem 'statem_include');
  76. $unified_info{after}->{$x}
  77. = qq(deassign statem
  78. deassign record);
  79. }
  80. # This makes sure things get built in the order they need
  81. # to. You're welcome.
  82. sub dependmagic {
  83. my $target = shift;
  84. return "$target : build_generated\n\t\pipe \$(MMS) \$(MMSQUALIFIERS) depend && \$(MMS) \$(MMSQUALIFIERS) _$target\n_$target";
  85. }
  86. #use Data::Dumper;
  87. #print STDERR "DEBUG: before:\n", Dumper($unified_info{before});
  88. #print STDERR "DEBUG: after:\n", Dumper($unified_info{after});
  89. "";
  90. -}
  91. PLATFORM={- $config{target} -}
  92. OPTIONS={- $config{options} -}
  93. CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
  94. SRCDIR={- $config{sourcedir} -}
  95. BLDDIR={- $config{builddir} -}
  96. # Allow both V and VERBOSE to indicate verbosity. This only applies
  97. # to testing.
  98. VERBOSE=$(V)
  99. VERSION={- "$config{full_version}" -}
  100. MAJOR={- $config{major} -}
  101. MINOR={- $config{minor} -}
  102. SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
  103. SHLIB_TARGET={- $target{shared_target} -}
  104. EXE_EXT=.EXE
  105. LIB_EXT=.OLB
  106. SHLIB_EXT=.EXE
  107. OBJ_EXT=.OBJ
  108. DEP_EXT=.D
  109. LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @libs) -}
  110. SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @shlibs) -}
  111. ENGINES={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{engines}}) -}
  112. PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{programs}}) -}
  113. SCRIPTS={- join(", ", map { "-\n\t".$_ } @{$unified_info{scripts}}) -}
  114. {- output_off() if $disabled{makedepend}; "" -}
  115. DEPS={- our @deps = map { (my $x = $_) =~ s|\.o$|\$(DEP_EXT)|; $x; }
  116. grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
  117. keys %{$unified_info{sources}};
  118. join(", ", map { "-\n\t".$_ } @deps); -}
  119. {- output_on() if $disabled{makedepend}; "" -}
  120. GENERATED_MANDATORY={- join(", ", map { "-\n\t".$_ } @{$unified_info{depends}->{""}} ) -}
  121. GENERATED={- # common0.tmpl provides @generated
  122. join(", ", map { my $x = $_;
  123. $x =~ s|\.[sS]$|.asm|;
  124. $x =~ s|\.ld$|.OPT|;
  125. "-\n\t".$x }
  126. @generated) -}
  127. INSTALL_LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @install_libs) -}
  128. INSTALL_SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @install_shlibs) -}
  129. INSTALL_ENGINES={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{install}->{engines}}) -}
  130. INSTALL_PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{install}->{programs}}) -}
  131. {- output_off() if $disabled{apps}; "" -}
  132. BIN_SCRIPTS=[.tools]c_rehash.pl
  133. MISC_SCRIPTS=[.apps]CA.pl, [.apps]tsget.pl
  134. {- output_on() if $disabled{apps}; "" -}
  135. APPS_OPENSSL={- use File::Spec::Functions;
  136. catfile("apps","openssl") -}
  137. # DESTDIR is for package builders so that they can configure for, say,
  138. # SYS$COMMON:[OPENSSL] and yet have everything installed in STAGING:[USER].
  139. # In that case, configure with --prefix=SYS$COMMON:[OPENSSL] and then run
  140. # MMS with /MACROS=(DESTDIR=STAGING:[USER]). The result will end up in
  141. # STAGING:[USER.OPENSSL].
  142. # Normally it is left empty.
  143. DESTDIR=
  144. # Do not edit this manually. Use Configure --prefix=DIR to change this!
  145. INSTALLTOP={- our $installtop =
  146. catdir($config{prefix}) || "SYS\$COMMON:[OPENSSL]";
  147. $installtop -}
  148. SYSTARTUP={- catdir($installtop, '[.SYS$STARTUP]'); -}
  149. # This is the standard central area to store certificates, private keys...
  150. OPENSSLDIR={- catdir($config{openssldir}) or
  151. $config{prefix} ? catdir($config{prefix},"COMMON")
  152. : "SYS\$COMMON:[OPENSSL-COMMON]" -}
  153. # The same, but for C
  154. OPENSSLDIR_C={- $osslprefix -}DATAROOT:[000000]
  155. # Where installed engines reside, for C
  156. ENGINESDIR_C={- $osslprefix -}ENGINES{- $sover_dirname.$target{pointer_size} -}:
  157. ##### User defined commands and flags ################################
  158. CC={- $config{CC} -}
  159. CPP={- $config{CPP} -}
  160. DEFINES={- our $defines1 = join('', map { ",$_" } @{$config{CPPDEFINES}}) -}
  161. INCLUDES={- our $includes1 = join(',', @{$config{CPPINCLUDES}}) -}
  162. CPPFLAGS={- our $cppflags1 = join('', @{$config{CPPFLAGS}}) -}
  163. CFLAGS={- join('', @{$config{CFLAGS}}) -}
  164. LDFLAGS={- join('', @{$config{LFLAGS}}) -}
  165. EX_LIBS={- join('', map { ",$_" } @{$config{LDLIBS}}) -}
  166. PERL={- $config{PERL} -}
  167. AS={- $config{AS} -}
  168. ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
  169. ##### Special command flags ##########################################
  170. ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
  171. ##### Project flags ##################################################
  172. # Variables starting with CNF_ are common variables for all product types
  173. CNF_ASFLAGS={- join('', $target{asflags} || (),
  174. @{$config{asflags}}) -}
  175. CNF_DEFINES={- our $defines2 = join('', (map { ",$_" } @{$target{defines}},
  176. @{$config{defines}}),
  177. "'extradefines'") -}
  178. CNF_INCLUDES={- our $includes2 = join(',', @{$target{includes}},
  179. @{$config{includes}}) -}
  180. CNF_CPPFLAGS={- our $cppflags2 = join('', $target{cppflags} || (),
  181. @{$config{cppflags}}) -}
  182. CNF_CFLAGS={- join('', $target{cflags} || (),
  183. @{$config{cflags}}) -}
  184. CNF_CXXFLAGS={- join('', $target{cxxflags} || (),
  185. @{$config{cxxflags}}) -}
  186. CNF_LDFLAGS={- join('', $target{lflags} || (),
  187. @{$config{lflags}}) -}
  188. CNF_EX_LIBS={- join('', map{ ",$_" } @{$target{ex_libs}},
  189. @{$config{ex_libs}}) -}
  190. # Variables starting with LIB_ are used to build library object files
  191. # and shared libraries.
  192. # Variables starting with DSO_ are used to build DSOs and their object files.
  193. # Variables starting with BIN_ are used to build programs and their object
  194. # files.
  195. LIB_ASFLAGS={- join(' ', $target{lib_asflags} || (),
  196. @{$config{lib_asflags}},
  197. '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
  198. LIB_DEFINES={- our $lib_defines =
  199. join('', (map { ",$_" } @{$target{lib_defines}},
  200. @{$target{shared_defines}},
  201. @{$config{lib_defines}},
  202. @{$config{shared_defines}}));
  203. join('', $lib_defines,
  204. (map { ",$_" } 'OPENSSLDIR="""$(OPENSSLDIR_C)"""',
  205. 'ENGINESDIR="""$(ENGINESDIR_C)"""'),
  206. '$(CNF_DEFINES)', '$(DEFINES)') -}
  207. LIB_INCLUDES={- our $lib_includes =
  208. join(',', @{$target{lib_includes}},
  209. @{$target{shared_includes}},
  210. @{$config{lib_includes}},
  211. @{$config{shared_includes}}) -}
  212. LIB_CPPFLAGS={- our $lib_cppflags =
  213. join('', $target{lib_cppflags} || (),
  214. $target{shared_cppflags} || (),
  215. @{$config{lib_cppflags}},
  216. @{$config{shared_cppflag}});
  217. join('', "'qual_includes'",
  218. '/DEFINE=(__dummy$(LIB_DEFINES))',
  219. $lib_cppflags,
  220. '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
  221. LIB_CFLAGS={- join('', $target{lib_cflags} || (),
  222. $target{shared_cflag} || (),
  223. @{$config{lib_cflags}},
  224. @{$config{shared_cflag}},
  225. '$(CNF_CFLAGS)', '$(CFLAGS)') -}
  226. LIB_LDFLAGS={- join('', $target{lib_lflags} || (),
  227. $target{shared_ldflag} || (),
  228. @{$config{lib_lflags}},
  229. @{$config{shared_ldflag}},
  230. '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
  231. LIB_EX_LIBS=$(CNF_EX_LIBS)$(EX_LIBS)
  232. DSO_ASFLAGS={- join(' ', $target{dso_asflags} || (),
  233. $target{module_asflags} || (),
  234. @{$config{dso_asflags}},
  235. @{$config{module_asflags}},
  236. '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
  237. DSO_DEFINES={- join('', (map { ",$_" } @{$target{dso_defines}},
  238. @{$target{module_defines}},
  239. @{$config{dso_defines}},
  240. @{$config{module_defines}}),
  241. '$(CNF_DEFINES)', '$(DEFINES)') -}
  242. DSO_INCLUDES={- join(',', @{$target{dso_includes}},
  243. @{$target{module_includes}},
  244. @{$config{dso_includes}},
  245. @{$config{module_includes}}) -}
  246. DSO_CPPFLAGS={- join('', "'qual_includes'",
  247. '/DEFINE=(__dummy$(DSO_DEFINES))',
  248. $target{dso_cppflags} || (),
  249. $target{module_cppflags} || (),
  250. @{$config{dso_cppflags}},
  251. @{$config{module_cppflags}},
  252. '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
  253. DSO_CFLAGS={- join('', $target{dso_cflags} || (),
  254. $target{module_cflags} || (),
  255. @{$config{dso_cflags}},
  256. @{$config{module_cflags}},
  257. '$(CNF_CFLAGS)', '$(CFLAGS)') -}
  258. DSO_LDFLAGS={- join('', $target{dso_lflags} || (),
  259. $target{module_ldflags} || (),
  260. @{$config{dso_lflags}},
  261. @{$config{module_ldflags}},
  262. '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
  263. DSO_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
  264. BIN_ASFLAGS={- join(' ', $target{bin_asflags} || (),
  265. @{$config{bin_asflags}},
  266. '$(CNF_ASFLAGS)', '$(ASFLAGS)') -}
  267. BIN_DEFINES={- join('', (map { ",$_" } @{$target{bin_defines}},
  268. @{$config{bin_defines}}),
  269. '$(CNF_DEFINES)', '$(DEFINES)') -}
  270. BIN_INCLUDES={- join(',', @{$target{bin_includes}},
  271. @{$config{bin_includes}}) -}
  272. BIN_CPPFLAGS={- join('', "'qual_includes'",
  273. '/DEFINE=(__dummy$(DSO_DEFINES))',
  274. $target{bin_cppflags} || (),
  275. @{$config{bin_cppflag}},
  276. '$(CNF_CPPFLAGS)', '$(CPPFLAGS)') -}
  277. BIN_CFLAGS={- join('', $target{bin_cflags} || (),
  278. @{$config{bin_cflags}},
  279. '$(CNF_CFLAGS)', '$(CFLAGS)') -}
  280. BIN_LDFLAGS={- join('', $target{bin_lflags} || (),
  281. @{$config{bin_lflags}} || (),
  282. '$(CNF_LDFLAGS)', '$(LDFLAGS)') -}
  283. BIN_EX_LIBS=$(CNF_EX_LIBS) $(EX_LIBS)
  284. NO_INST_LIB_CFLAGS={- join('', $target{no_inst_lib_cflags}
  285. // $target{lib_cflags}
  286. // (),
  287. $target{shared_cflag} || (),
  288. @{$config{lib_cflags}},
  289. @{$config{shared_cflag}},
  290. '$(CNF_CFLAGS)', '$(CFLAGS)') -}
  291. NO_INST_DSO_CFLAGS={- join('', $target{no_inst_dso_cflags}
  292. // $target{dso_cflags}
  293. // (),
  294. $target{no_inst_module_cflags}
  295. // $target{module_cflags}
  296. // (),
  297. @{$config{dso_cflags}},
  298. @{$config{module_cflags}},
  299. '$(CNF_CFLAGS)', '$(CFLAGS)') -}
  300. NO_INST_BIN_CFLAGS={- join('', $target{no_inst_bin_cflags}
  301. // $target{bin_cflags}
  302. // (),
  303. @{$config{bin_cflags}},
  304. '$(CNF_CFLAGS)', '$(CFLAGS)') -}
  305. PERLASM_SCHEME={- $target{perlasm_scheme} -}
  306. # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
  307. CPPFLAGS_Q={- (my $c = $lib_cppflags.$cppflags2.$cppflags1) =~ s|"|""|g;
  308. (my $d = $lib_defines.$defines2.$defines1) =~ s|"|""|g;
  309. my $i = join(',', $lib_includes || (), $includes2 || (),
  310. $includes1 || ());
  311. my $x = $c;
  312. $x .= "/INCLUDE=($i)" if $i;
  313. $x .= "/DEFINE=($d)" if $d;
  314. $x; -}
  315. # .FIRST and .LAST are special targets with MMS and MMK.
  316. # The defines in there are for C. includes that look like
  317. # this:
  318. #
  319. # #include <openssl/foo.h>
  320. # #include "internal/bar.h"
  321. #
  322. # will use the logical names to find the files. Expecting
  323. # DECompHP C to find files in subdirectories of whatever was
  324. # given with /INCLUDE is a fantasy, unfortunately.
  325. NODEBUG=@
  326. .FIRST :
  327. $(NODEBUG) openssl_inc1 = F$PARSE("[.include.openssl]","A.;",,,"syntax_only") - "A.;"
  328. $(NODEBUG) openssl_inc2 = F$PARSE("{- catdir($config{sourcedir},"[.include.openssl]") -}","A.;",,,"SYNTAX_ONLY") - "A.;"
  329. $(NODEBUG) internal_inc1 = F$PARSE("[.crypto.include.internal]","A.;",,,"SYNTAX_ONLY") - "A.;"
  330. $(NODEBUG) internal_inc2 = F$PARSE("{- catdir($config{sourcedir},"[.include.internal]") -}","A.;",,,"SYNTAX_ONLY") - "A.;"
  331. $(NODEBUG) internal_inc3 = F$PARSE("{- catdir($config{sourcedir},"[.crypto.include.internal]") -}","A.;",,,"SYNTAX_ONLY") - "A.;"
  332. $(NODEBUG) DEFINE openssl 'openssl_inc1','openssl_inc2'
  333. $(NODEBUG) DEFINE internal 'internal_inc1','internal_inc2','internal_inc3'
  334. $(NODEBUG) staging_dir = "$(DESTDIR)"
  335. $(NODEBUG) staging_instdir = ""
  336. $(NODEBUG) staging_datadir = ""
  337. $(NODEBUG) IF staging_dir .NES. "" THEN -
  338. staging_instdir = F$PARSE("A.;",staging_dir,"[]",,"SYNTAX_ONLY")
  339. $(NODEBUG) IF staging_instdir - "]A.;" .NES. staging_instdir THEN -
  340. staging_instdir = staging_instdir - "]A.;" + ".OPENSSL-INSTALL]"
  341. $(NODEBUG) IF staging_instdir - "A.;" .NES. staging_instdir THEN -
  342. staging_instdir = staging_instdir - "A.;" + "[OPENSSL-INSTALL]"
  343. $(NODEBUG) IF staging_dir .NES. "" THEN -
  344. staging_datadir = F$PARSE("A.;",staging_dir,"[]",,"SYNTAX_ONLY")
  345. $(NODEBUG) IF staging_datadir - "]A.;" .NES. staging_datadir THEN -
  346. staging_datadir = staging_datadir - "]A.;" + ".OPENSSL-COMMON]"
  347. $(NODEBUG) IF staging_datadir - "A.;" .NES. staging_datadir THEN -
  348. staging_datadir = staging_datadir - "A.;" + "[OPENSSL-COMMON]"
  349. $(NODEBUG) !
  350. $(NODEBUG) ! Installation logical names
  351. $(NODEBUG) !
  352. $(NODEBUG) installtop = F$PARSE(staging_instdir,"$(INSTALLTOP)","[]A.;",,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;" + ".]"
  353. $(NODEBUG) datatop = F$PARSE(staging_datadir,"$(OPENSSLDIR)","[]A.;",,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;" + ".]"
  354. $(NODEBUG) DEFINE ossl_installroot 'installtop'
  355. $(NODEBUG) DEFINE ossl_dataroot 'datatop'
  356. $(NODEBUG) !
  357. $(NODEBUG) ! Figure out the architecture
  358. $(NODEBUG) !
  359. $(NODEBUG) arch = f$edit( f$getsyi( "arch_name"), "upcase")
  360. $(NODEBUG) !
  361. $(NODEBUG) ! Set up logical names for the libraries, so LINK and
  362. $(NODEBUG) ! running programs can use them.
  363. $(NODEBUG) !
  364. $(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEFINE ".uc($_)." 'F\$ENV(\"DEFAULT\")'".uc($_)."\$(SHLIB_EXT)" } @shlibs) || "!" -}
  365. .LAST :
  366. $(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEASSIGN ".uc($_) } @shlibs) || "!" -}
  367. $(NODEBUG) DEASSIGN ossl_dataroot
  368. $(NODEBUG) DEASSIGN ossl_installroot
  369. $(NODEBUG) DEASSIGN internal
  370. $(NODEBUG) DEASSIGN openssl
  371. .DEFAULT :
  372. @ ! MMS cannot handle no actions...
  373. # The main targets ###################################################
  374. {- dependmagic('all'); -} : build_libs_nodep, build_engines_nodep, build_programs_nodep
  375. {- dependmagic('build_libs'); -} : build_libs_nodep
  376. {- dependmagic('build_engines'); -} : build_engines_nodep
  377. {- dependmagic('build_programs'); -} : build_programs_nodep
  378. build_generated : $(GENERATED_MANDATORY)
  379. build_libs_nodep : $(LIBS), $(SHLIBS)
  380. build_engines_nodep : $(ENGINES)
  381. build_programs_nodep : $(PROGRAMS), $(SCRIPTS)
  382. # Kept around for backward compatibility
  383. build_apps build_tests : build_programs
  384. # Convenience target to prebuild all generated files, not just the mandatory
  385. # ones
  386. build_all_generated : $(GENERATED_MANDATORY) $(GENERATED)
  387. @ ! {- output_off() if $disabled{makedepend}; "" -}
  388. @ WRITE SYS$OUTPUT "Warning: consider configuring with no-makedepend, because if"
  389. @ WRITE SYS$OUTPUT " target system doesn't have $(PERL),"
  390. @ WRITE SYS$OUTPUT " then make will fail..."
  391. @ ! {- output_on() if $disabled{makedepend}; "" -}
  392. test : tests
  393. {- dependmagic('tests'); -} : build_programs_nodep, build_engines_nodep
  394. @ ! {- output_off() if $disabled{tests}; "" -}
  395. SET DEFAULT [.test]{- move("test") -}
  396. CREATE/DIR [.test-runs]
  397. DEFINE SRCTOP {- sourcedir() -}
  398. DEFINE BLDTOP {- builddir() -}
  399. DEFINE RESULT_D {- builddir(qw(test test-runs)) -}
  400. DEFINE OPENSSL_ENGINES {- builddir("engines") -}
  401. DEFINE OPENSSL_DEBUG_MEMORY "on"
  402. IF "$(VERBOSE)" .NES. "" THEN DEFINE VERBOSE "$(VERBOSE)"
  403. $(PERL) {- sourcefile("test", "run_tests.pl") -} $(TESTS)
  404. DEASSIGN OPENSSL_DEBUG_MEMORY
  405. DEASSIGN OPENSSL_ENGINES
  406. DEASSIGN BLDTOP
  407. DEASSIGN SRCTOP
  408. SET DEFAULT [-]{- move("..") -}
  409. @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
  410. @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options"
  411. @ ! {- output_on() if !$disabled{tests}; "" -}
  412. list-tests :
  413. @ ! {- output_off() if $disabled{tests}; "" -}
  414. @ DEFINE SRCTOP {- sourcedir() -}
  415. @ $(PERL) {- sourcefile("test", "run_tests.pl") -} list
  416. @ DEASSIGN SRCTOP
  417. @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
  418. @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options"
  419. @ ! {- output_on() if !$disabled{tests}; "" -}
  420. install : install_sw install_ssldirs install_docs
  421. @ WRITE SYS$OUTPUT ""
  422. @ WRITE SYS$OUTPUT "######################################################################"
  423. @ WRITE SYS$OUTPUT ""
  424. @ IF "$(DESTDIR)" .EQS. "" THEN -
  425. PIPE ( WRITE SYS$OUTPUT "Installation complete" ; -
  426. WRITE SYS$OUTPUT "" ; -
  427. WRITE SYS$OUTPUT "Run @$(SYSTARTUP)openssl_startup{- $osslver -} to set up logical names" ; -
  428. WRITE SYS$OUTPUT "then run @$(SYSTARTUP)openssl_utils{- $osslver -} to define commands" ; -
  429. WRITE SYS$OUTPUT "" )
  430. @ IF "$(DESTDIR)" .NES. "" THEN -
  431. PIPE ( WRITE SYS$OUTPUT "Staging installation complete" ; -
  432. WRITE SYS$OUTPUT "" ; -
  433. WRITE SYS$OUTPUT "Finish or package in such a way that the contents of the directory tree" ; -
  434. WRITE SYS$OUTPUT staging_instdir ; -
  435. WRITE SYS$OUTPUT "ends up in $(INSTALLTOP)," ; -
  436. WRITE SYS$OUTPUT "and that the contents of the contents of the directory tree" ; -
  437. WRITE SYS$OUTPUT staging_datadir ; -
  438. WRITE SYS$OUTPUT "ends up in $(OPENSSLDIR)" ; -
  439. WRITE SYS$OUTPUT "" ; -
  440. WRITE SYS$OUTPUT "When in its final destination," ; -
  441. WRITE SYS$OUTPUT "Run @$(SYSTARTUP)openssl_startup{- $osslver -} to set up logical names" ; -
  442. WRITE SYS$OUTPUT "then run @$(SYSTARTUP)openssl_utils{- $osslver -} to define commands" ; -
  443. WRITE SYS$OUTPUT "" )
  444. check_install :
  445. spawn/nolog @ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com
  446. uninstall : uninstall_docs uninstall_sw
  447. # Because VMS wants the generation number (or *) to delete files, we can't
  448. # use $(LIBS), $(PROGRAMS), $(GENERATED) and $(ENGINES)directly.
  449. libclean :
  450. {- join("\n\t", map { "- DELETE $_.OLB;*" } @libs) || "@ !" -}
  451. {- join("\n\t", map { "- DELETE $_.EXE;*,$_.MAP;*" } @shlibs) || "@ !" -}
  452. clean : libclean
  453. {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{programs}}) || "@ !" -}
  454. {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{engines}}) || "@ !" -}
  455. {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{scripts}}) || "@ !" -}
  456. {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{depends}->{""}}) || "@ !" -}
  457. {- join("\n\t", map { "- DELETE $_;*" } @generated) || "@ !" -}
  458. - DELETE [...]*.MAP;*
  459. - DELETE [...]*.D;*
  460. - DELETE [...]*.OBJ;*,*.LIS;*
  461. - DELETE []CXX$DEMANGLER_DB.;*
  462. - DELETE [.VMS]openssl_startup.com;*
  463. - DELETE [.VMS]openssl_shutdown.com;*
  464. - DELETE []vmsconfig.pm;*
  465. distclean : clean
  466. - DELETE configdata.pm;*
  467. - DELETE descrip.mms;*
  468. depend : descrip.mms
  469. descrip.mms : FORCE
  470. @ ! {- output_off() if $disabled{makedepend}; "" -}
  471. @ $(PERL) {- sourcefile("util", "add-depends.pl") -} "VMS C"
  472. @ ! {- output_on() if $disabled{makedepend}; "" -}
  473. # Install helper targets #############################################
  474. install_sw : install_dev install_engines install_runtime -
  475. install_startup install_ivp
  476. uninstall_sw : uninstall_dev uninstall_engines uninstall_runtime -
  477. uninstall_startup uninstall_ivp
  478. install_docs : install_html_docs
  479. uninstall_docs : uninstall_html_docs
  480. install_ssldirs : check_INSTALLTOP
  481. - CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[000000]
  482. IF F$SEARCH("OSSL_DATAROOT:[000000]CERTS.DIR;1") .EQS. "" THEN -
  483. CREATE/DIR/PROT=(S:RWED,O:RWE,G:RE,W:RE) OSSL_DATAROOT:[CERTS]
  484. IF F$SEARCH("OSSL_DATAROOT:[000000]PRIVATE.DIR;1") .EQS. "" THEN -
  485. CREATE/DIR/PROT=(S:RWED,O:RWE,G,W) OSSL_DATAROOT:[PRIVATE]
  486. IF F$SEARCH("OSSL_DATAROOT:[000000]MISC.DIR;1") .EQS. "" THEN -
  487. CREATE/DIR/PROT=(S:RWED,O:RWE,G,W) OSSL_DATAROOT:[MISC]
  488. COPY/PROT=W:RE $(MISC_SCRIPTS) OSSL_DATAROOT:[MISC]
  489. @ ! Install configuration file
  490. COPY/PROT=W:R {- sourcefile("apps", "openssl-vms.cnf") -} -
  491. ossl_dataroot:[000000]openssl.cnf-dist
  492. IF F$SEARCH("OSSL_DATAROOT:[000000]openssl.cnf") .EQS. "" THEN -
  493. COPY/PROT=W:R {- sourcefile("apps", "openssl-vms.cnf") -} -
  494. ossl_dataroot:[000000]openssl.cnf
  495. @ ! Install CTLOG configuration file
  496. COPY/PROT=W:R {- sourcefile("apps", "ct_log_list.cnf") -} -
  497. ossl_dataroot:[000000]ct_log_list.cnf-dist
  498. IF F$SEARCH("OSSL_DATAROOT:[000000]ct_log_list.cnf") .EQS. "" THEN -
  499. COPY/PROT=W:R {- sourcefile("apps", "ct_log_list.cnf") -} -
  500. ossl_dataroot:[000000]ct_log_list.cnf
  501. install_dev : check_INSTALLTOP install_runtime_libs
  502. @ WRITE SYS$OUTPUT "*** Installing development files"
  503. @ ! Install header files
  504. - CREATE/DIR ossl_installroot:[include.openssl]
  505. COPY/PROT=W:R openssl:*.h ossl_installroot:[include.openssl]
  506. @ ! Install static (development) libraries
  507. - CREATE/DIR ossl_installroot:[LIB.'arch']
  508. {- join("\n ",
  509. map { "COPY/PROT=W:R $_.OLB ossl_installroot:[LIB.'arch']" }
  510. @install_libs) -}
  511. install_engines : check_INSTALLTOP install_runtime_libs build_engines
  512. @ {- output_off() unless scalar @{$unified_info{engines}}; "" -} !
  513. @ WRITE SYS$OUTPUT "*** Installing engines"
  514. - CREATE/DIR ossl_installroot:[ENGINES{- $sover_dirname.$target{pointer_size} -}.'arch']
  515. {- join("\n ",
  516. map { "COPY/PROT=W:RE $_.EXE ossl_installroot:[ENGINES$sover_dirname$target{pointer_size}.'arch']" }
  517. @{$unified_info{install}->{engines}}) -}
  518. @ {- output_on() unless scalar @{$unified_info{engines}}; "" -} !
  519. install_runtime : install_programs
  520. install_runtime_libs : check_INSTALLTOP build_libs
  521. @ {- output_off() if $disabled{shared}; "" -} !
  522. @ WRITE SYS$OUTPUT "*** Installing shareable images"
  523. @ ! Install shared (runtime) libraries
  524. - CREATE/DIR ossl_installroot:[LIB.'arch']
  525. {- join("\n ",
  526. map { "COPY/PROT=W:R $_.EXE ossl_installroot:[LIB.'arch']" }
  527. @install_shlibs) -}
  528. @ {- output_on() if $disabled{shared}; "" -} !
  529. install_programs : check_INSTALLTOP install_runtime_libs build_programs
  530. @ {- output_off() if $disabled{apps}; "" -} !
  531. @ ! Install the main program
  532. - CREATE/DIR ossl_installroot:[EXE.'arch']
  533. COPY/PROT=W:RE [.APPS]openssl.EXE -
  534. ossl_installroot:[EXE.'arch']openssl{- $osslver -}.EXE
  535. @ ! Install scripts
  536. COPY/PROT=W:RE $(BIN_SCRIPTS) ossl_installroot:[EXE]
  537. @ ! {- output_on() if $disabled{apps}; "" -}
  538. install_startup : [.VMS]openssl_startup.com [.VMS]openssl_shutdown.com -
  539. [.VMS]openssl_utils.com, check_INSTALLTOP
  540. - CREATE/DIR ossl_installroot:[SYS$STARTUP]
  541. COPY/PROT=W:RE [.VMS]openssl_startup.com -
  542. ossl_installroot:[SYS$STARTUP]openssl_startup{- $osslver -}.com
  543. COPY/PROT=W:RE [.VMS]openssl_shutdown.com -
  544. ossl_installroot:[SYS$STARTUP]openssl_shutdown{- $osslver -}.com
  545. COPY/PROT=W:RE [.VMS]openssl_utils.com -
  546. ossl_installroot:[SYS$STARTUP]openssl_utils{- $osslver -}.com
  547. install_ivp : [.VMS]openssl_ivp.com check_INSTALLTOP
  548. - CREATE/DIR ossl_installroot:[SYSTEST]
  549. COPY/PROT=W:RE [.VMS]openssl_ivp.com -
  550. ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com
  551. [.VMS]openssl_startup.com : vmsconfig.pm {- sourcefile("VMS", "openssl_startup.com.in") -}
  552. - CREATE/DIR [.VMS]
  553. $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
  554. {- sourcefile("VMS", "openssl_startup.com.in") -} -
  555. > [.VMS]openssl_startup.com
  556. [.VMS]openssl_utils.com : vmsconfig.pm {- sourcefile("VMS", "openssl_utils.com.in") -}
  557. - CREATE/DIR [.VMS]
  558. $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
  559. {- sourcefile("VMS", "openssl_utils.com.in") -} -
  560. > [.VMS]openssl_utils.com
  561. [.VMS]openssl_shutdown.com : vmsconfig.pm {- sourcefile("VMS", "openssl_shutdown.com.in") -}
  562. - CREATE/DIR [.VMS]
  563. $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
  564. {- sourcefile("VMS", "openssl_shutdown.com.in") -} -
  565. > [.VMS]openssl_shutdown.com
  566. [.VMS]openssl_ivp.com : vmsconfig.pm {- sourcefile("VMS", "openssl_ivp.com.in") -}
  567. - CREATE/DIR [.VMS]
  568. $(PERL) "-I." "-Mvmsconfig" {- sourcefile("util", "dofile.pl") -} -
  569. {- sourcefile("VMS", "openssl_ivp.com.in") -} -
  570. > [.VMS]openssl_ivp.com
  571. vmsconfig.pm : configdata.pm
  572. OPEN/WRITE/SHARE=READ CONFIG []vmsconfig.pm
  573. WRITE CONFIG "package vmsconfig;"
  574. WRITE CONFIG "use strict; use warnings;"
  575. WRITE CONFIG "use Exporter;"
  576. WRITE CONFIG "our @ISA = qw(Exporter);"
  577. WRITE CONFIG "our @EXPORT = qw(%config %target %withargs %unified_info %disabled);"
  578. WRITE CONFIG "our %config = ("
  579. WRITE CONFIG " target => '","{- $config{target} -}","',"
  580. WRITE CONFIG " version => '","{- $config{version} -}","',"
  581. WRITE CONFIG " shlib_version_number => '","{- $config{shlib_version_number} -}","',"
  582. WRITE CONFIG " shlib_major => '","{- $config{shlib_major} -}","',"
  583. WRITE CONFIG " shlib_minor => '","{- $config{shlib_minor} -}","',"
  584. WRITE CONFIG " no_shared => '","{- $disabled{shared} -}","',"
  585. WRITE CONFIG " INSTALLTOP => '$(INSTALLTOP)',"
  586. WRITE CONFIG " OPENSSLDIR => '$(OPENSSLDIR)',"
  587. WRITE CONFIG " pointer_size => '","{- $target{pointer_size} -}","',"
  588. WRITE CONFIG ");"
  589. WRITE CONFIG "our %target = ();"
  590. WRITE CONFIG "our %disabled = ();"
  591. WRITE CONFIG "our %withargs = ();"
  592. WRITE CONFIG "our %unified_info = ();"
  593. WRITE CONFIG "1;"
  594. CLOSE CONFIG
  595. install_html_docs : check_INSTALLTOP
  596. sourcedir = F$PARSE("{- $sourcedir -}A.;","[]") - "]A.;" + ".DOC]"
  597. $(PERL) {- sourcefile("util", "process_docs.pl") -} -
  598. --sourcedir='sourcedir' --destdir=ossl_installroot:[HTML] -
  599. --type=html
  600. check_INSTALLTOP :
  601. @ IF "$(INSTALLTOP)" .EQS. "" THEN -
  602. WRITE SYS$ERROR "INSTALLTOP should not be empty"
  603. @ IF "$(INSTALLTOP)" .EQS. "" THEN -
  604. EXIT %x10000002
  605. # Helper targets #####################################################
  606. # Developer targets ##################################################
  607. debug_logicals :
  608. SH LOGICAL/PROC openssl,internal,ossl_installroot,ossl_dataroot
  609. # Building targets ###################################################
  610. configdata.pm : $(SRCDIR)Configure $(SRCDIR)config.com {- join(" ", @{$config{build_file_templates}}, @{$config{build_infos}}, @{$config{conf_files}}) -}
  611. perl configdata.pm -r
  612. @ WRITE SYS$OUTPUT "*************************************************"
  613. @ WRITE SYS$OUTPUT "*** ***"
  614. @ WRITE SYS$OUTPUT "*** Please run the same mms command again ***"
  615. @ WRITE SYS$OUTPUT "*** ***"
  616. @ WRITE SYS$OUTPUT "*************************************************"
  617. @ PIPE ( EXIT %X10000000 )
  618. reconfigure reconf :
  619. perl configdata.pm -r
  620. {-
  621. use File::Basename;
  622. use File::Spec::Functions qw/abs2rel rel2abs catfile catdir/;
  623. # Helper function to figure out dependencies on libraries
  624. # It takes a list of library names and outputs a list of dependencies
  625. sub compute_lib_depends {
  626. if ($disabled{shared}) {
  627. return map { $_ =~ /\.a$/ ? $`.".OLB" : $_.".OLB" } @_;
  628. }
  629. return map { $_ =~ /\.a$/
  630. ? $`.".OLB"
  631. : $unified_info{sharednames}->{$_}.".EXE" } @_;
  632. }
  633. # Helper function to deal with inclusion directory specs.
  634. # We have to deal with two things:
  635. # 1. comma separation and no possibility of trailing comma
  636. # 2. no inclusion directories given at all
  637. # 3. long compiler command lines
  638. # To resolve 1, we need to iterate through the sources of inclusion
  639. # directories, and only add a comma when needed.
  640. # To resolve 2, we need to have a variable that will hold the whole
  641. # inclusion qualifier, or be the empty string if there are no inclusion
  642. # directories. That's the symbol 'qual_includes' that's used in CPPFLAGS
  643. # To resolve 3, we creata a logical name TMP_INCLUDES: to hold the list
  644. # of inclusion directories.
  645. #
  646. # This function returns a list of two lists, one being the collection of
  647. # commands to execute before the compiler is called, and the other being
  648. # the collection of commands to execute after. It takes as arguments the
  649. # collection of strings to include as directory specs.
  650. sub includes {
  651. my @stuff = ( @_ );
  652. my @before = (
  653. 'qual_includes :=',
  654. );
  655. my @after = (
  656. 'DELETE/SYMBOL/LOCAL qual_includes',
  657. );
  658. if (scalar @stuff > 0) {
  659. push @before, 'tmp_includes := '.shift(@stuff);
  660. while (@stuff) {
  661. push @before, 'tmp_add := '.shift(@stuff);
  662. push @before, 'IF tmp_includes .NES. "" .AND. tmp_add .NES. "" THEN tmp_includes = tmp_includes + ","';
  663. push @before, 'tmp_includes = tmp_includes + tmp_add';
  664. }
  665. push @before, "IF tmp_includes .NES. \"\" THEN DEFINE tmp_includes 'tmp_includes'";
  666. push @before, 'IF tmp_includes .NES. "" THEN qual_includes := /INCLUDE=(tmp_includes:)';
  667. push @before, 'DELETE/SYMBOL/LOCAL tmp_includes';
  668. push @before, 'DELETE/SYMBOL/LOCAL tmp_add';
  669. push @after, 'DEASSIGN tmp_includes:'
  670. }
  671. return ([ @before ], [ @after ]);
  672. }
  673. sub generatesrc {
  674. my %args = @_;
  675. my $generator = join(" ", @{$args{generator}});
  676. my $generator_incs = join("", map { ' "-I'.$_.'"' } @{$args{generator_incs}});
  677. my $deps = join(", -\n\t\t", @{$args{generator_deps}}, @{$args{deps}});
  678. if ($args{src} =~ /\.ld$/) {
  679. (my $target = $args{src}) =~ s/\.ld$/.OPT/;
  680. my $mkdef = sourcefile('util', 'mkdef.pl');
  681. my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
  682. my $ord_name =
  683. $args{generator}->[1] || basename($args{product}, '.EXE');
  684. my $case_insensitive =
  685. $target{$args{intent}.'_cflags'} =~ m|/NAMES=[^/]*AS_IS|i
  686. ? '' : ' --case-insensitive';
  687. return <<"EOF";
  688. $target : $args{generator}->[0] $deps $mkdef
  689. \$(PERL) $mkdef$ord_ver --ordinals $args{generator}->[0] --name $ord_name "--OS" "VMS"$case_insensitive > $target
  690. EOF
  691. } elsif ($args{src} !~ /\.[sS]$/) {
  692. my $target = $args{src};
  693. if ($args{generator}->[0] =~ m|^.*\.in$|) {
  694. my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
  695. "util", "dofile.pl")),
  696. rel2abs($config{builddir}));
  697. return <<"EOF";
  698. $target : $args{generator}->[0] $deps
  699. \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile \\
  700. "-o$target{build_file}" $generator > \$\@
  701. EOF
  702. } else {
  703. return <<"EOF";
  704. $target : $args{generator}->[0] $deps
  705. \$(PERL)$generator_incs $generator > \$\@
  706. EOF
  707. }
  708. } else {
  709. (my $target = $args{src}) =~ s/\.[sS]$/.asm/;
  710. if ($args{generator}->[0] =~ /\.pl$/) {
  711. $generator = '$(PERL)'.$generator_incs.' '.$generator;
  712. } elsif ($args{generator}->[0] =~ /\.S$/) {
  713. $generator = undef;
  714. } else {
  715. die "Generator type for $src unknown: $generator\n";
  716. }
  717. my $cppflags = {
  718. shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
  719. lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
  720. dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
  721. bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
  722. } -> {$args{intent}};
  723. my @incs_cmds = includes({ shlib => '$(LIB_INCLUDES)',
  724. lib => '$(LIB_INCLUDES)',
  725. dso => '$(DSO_INCLUDES)',
  726. bin => '$(BIN_INCLUDES)' } -> {$args{intent}},
  727. '$(CNF_INCLUDES)',
  728. '$(INCLUDES)',
  729. @{$args{incs}});
  730. my $incs_on = join("\n\t\@ ", @{$incs_cmds[0]}) || '!';
  731. my $incs_off = join("\n\t\@ ", @{$incs_cmds[1]}) || '!';
  732. my $defs = join("", map { ",".$_ } @{$args{defs}});
  733. if (defined($generator)) {
  734. # If the target is named foo.S in build.info, we want to
  735. # end up generating foo.s in two steps.
  736. if ($args{src} =~ /\.S$/) {
  737. return <<"EOF";
  738. $target : $args{generator}->[0] $deps
  739. $generator \$\@-S
  740. \@ $incs_on
  741. \@ extradefines = "$defs"
  742. PIPE \$(CPP) $cppflags \$\@-S | -
  743. \$(PERL) -ne "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" > \$\@-i
  744. \@ DELETE/SYMBOL/LOCAL extradefines
  745. \@ $incs_off
  746. RENAME \$\@-i \$\@
  747. DELETE \$\@-S;
  748. EOF
  749. }
  750. # Otherwise....
  751. return <<"EOF";
  752. $target : $args{generator}->[0] $deps
  753. $generator \$\@
  754. EOF
  755. }
  756. return <<"EOF";
  757. $target : $args{generator}->[0] $deps
  758. \@ $incs_on
  759. \@ extradefines = "$defs"
  760. SHOW SYMBOL qual_includes
  761. PIPE \$(CPP) $cppflags $args{generator}->[0] | -
  762. \$(PERL) "-ne" "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" > \$\@
  763. \@ DELETE/SYMBOL/LOCAL extradefines
  764. \@ $incs_off
  765. EOF
  766. }
  767. }
  768. sub src2obj {
  769. my %args = @_;
  770. my @srcs = map { (my $x = $_) =~ s/\.[sS]$/.asm/; $x
  771. } ( @{$args{srcs}} );
  772. (my $obj = $args{obj}) =~ s|\.o$||;
  773. my $deps = join(", -\n\t\t", @srcs, @{$args{deps}});
  774. # Because VMS C isn't very good at combining a /INCLUDE path with
  775. # #includes having a relative directory (like '#include "../foo.h"),
  776. # the best choice is to move to the first source file's intended
  777. # directory before compiling, and make sure to write the object file
  778. # in the correct position (important when the object tree is other
  779. # than the source tree).
  780. my $forward = dirname($args{srcs}->[0]);
  781. my $backward = abs2rel(rel2abs("."), rel2abs($forward));
  782. my $objd = abs2rel(rel2abs(dirname($obj)), rel2abs($forward));
  783. my $objn = basename($obj);
  784. my $srcs =
  785. join(", ", map { abs2rel(rel2abs($_), rel2abs($forward)) } @srcs);
  786. my $before = $unified_info{before}->{$obj.".OBJ"} || "\@ !";
  787. my $after = $unified_info{after}->{$obj.".OBJ"} || "\@ !";
  788. if ($srcs[0] =~ /\.asm$/) {
  789. my $asflags = { shlib => ' $(LIB_ASFLAGS)',
  790. lib => ' $(LIB_ASFLAGS)',
  791. dso => ' $(DSO_ASFLAGS)',
  792. bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
  793. return <<"EOF";
  794. $obj.OBJ : $deps
  795. ${before}
  796. SET DEFAULT $forward
  797. \$(AS) $asflags \$(ASOUTFLAG)${objd}${objn}.OBJ $srcs
  798. SET DEFAULT $backward
  799. EOF
  800. }
  801. my $cflags;
  802. if ($args{installed}) {
  803. $cflags = { shlib => '$(LIB_CFLAGS)',
  804. lib => '$(LIB_CFLAGS)',
  805. dso => '$(DSO_CFLAGS)',
  806. bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
  807. } else {
  808. $cflags = { shlib => '$(NO_INST_LIB_CFLAGS)',
  809. lib => '$(NO_INST_LIB_CFLAGS)',
  810. dso => '$(NO_INST_DSO_CFLAGS)',
  811. bin => '$(NO_INST_BIN_CFLAGS)' } -> {$args{intent}};
  812. }
  813. $cflags .= { shlib => '$(LIB_CPPFLAGS)',
  814. lib => '$(LIB_CPPFLAGS)',
  815. dso => '$(DSO_CPPFLAGS)',
  816. bin => '$(BIN_CPPFLAGS)' } -> {$args{intent}};
  817. my $defs = join("", map { ",".$_ } @{$args{defs}});
  818. my @incs_cmds = includes({ shlib => '$(LIB_INCLUDES)',
  819. lib => '$(LIB_INCLUDES)',
  820. dso => '$(DSO_INCLUDES)',
  821. bin => '$(BIN_INCLUDES)' } -> {$args{intent}},
  822. '$(INCLUDES)',
  823. map {
  824. file_name_is_absolute($_)
  825. ? $_ : catdir($backward,$_)
  826. } @{$args{incs}});
  827. my $incs_on = join("\n\t\@ ", @{$incs_cmds[0]}) || '!';
  828. my $incs_off = join("\n\t\@ ", @{$incs_cmds[1]}) || '!';
  829. my $depbuild = $disabled{makedepend} ? ""
  830. : " /MMS=(FILE=${objd}${objn}.D,TARGET=$obj.OBJ)";
  831. return <<"EOF";
  832. $obj.OBJ : $deps
  833. ${before}
  834. SET DEFAULT $forward
  835. \@ $incs_on
  836. \@ extradefines = "$defs"
  837. \$(CC) ${cflags}${depbuild} /OBJECT=${objd}${objn}.OBJ /REPOSITORY=$backward $srcs
  838. \@ DELETE/SYMBOL/LOCAL extradefines
  839. \@ $incs_off
  840. SET DEFAULT $backward
  841. ${after}
  842. - PURGE $obj.OBJ
  843. EOF
  844. }
  845. sub obj2shlib {
  846. my %args = @_;
  847. my $lib = $args{lib};
  848. my $shlib = $args{shlib};
  849. my $libd = dirname($lib);
  850. my $libn = basename($lib);
  851. my @objs = map { (my $x = $_) =~ s|\.o$|.OBJ|; $x }
  852. grep { $_ =~ m|\.o$| }
  853. @{$args{objs}};
  854. my @defs = map { (my $x = $_) =~ s|\.ld$|.OPT|; $x }
  855. grep { $_ =~ m|\.ld$| }
  856. @{$args{objs}};
  857. my @deps = compute_lib_depends(@{$args{deps}});
  858. die "More than one symbol vector" if scalar @defs > 1;
  859. my $deps = join(", -\n\t\t", @objs, @defs, @deps);
  860. my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
  861. my $translatesyms_pl = abs2rel(rel2abs(catfile($config{sourcedir},
  862. "VMS", "translatesyms.pl")),
  863. rel2abs($config{builddir}));
  864. # The "[]" hack is because in .OPT files, each line inherits the
  865. # previous line's file spec as default, so if no directory spec
  866. # is present in the current line and the previous line has one that
  867. # doesn't apply, you're in for a surprise.
  868. my $write_opt1 =
  869. join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
  870. "WRITE OPT_FILE \"$x" } @objs).
  871. "\"";
  872. my $write_opt2 =
  873. join("\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
  874. $x =~ s|(\.EXE)|$1/SHARE|;
  875. $x =~ s|(\.OLB)|$1/LIB|;
  876. "WRITE OPT_FILE \"$x\"" } @deps)
  877. || "\@ !";
  878. return <<"EOF"
  879. $shlib.EXE : $deps
  880. \$(PERL) $translatesyms_pl \$(BLDDIR)CXX\$DEMANGLER_DB. < $defs[0] > $defs[0]-translated
  881. OPEN/WRITE/SHARE=READ OPT_FILE $lib-components.OPT
  882. $write_opt1
  883. $write_opt2
  884. CLOSE OPT_FILE
  885. LINK \$(LIB_LDFLAGS)/SHARE=\$\@ $defs[0]-translated/OPT,-
  886. $lib-components.OPT/OPT \$(LIB_EX_LIBS)
  887. DELETE $defs[0]-translated;*,$lib-components.OPT;*
  888. PURGE $shlib.EXE,$shlib.MAP
  889. EOF
  890. . ($config{target} =~ m|alpha| ? "" : <<"EOF"
  891. SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
  892. EOF
  893. );
  894. }
  895. sub obj2dso {
  896. my %args = @_;
  897. my $lib = $args{lib};
  898. my $libd = dirname($lib);
  899. my $libn = basename($lib);
  900. (my $libn_nolib = $libn) =~ s/^lib//;
  901. my @objs = map { (my $x = $_) =~ s|\.o$|.OBJ|; $x }
  902. grep { $_ =~ m|\.o$| }
  903. @{$args{objs}};
  904. my @defs = map { (my $x = $_) =~ s|\.ld$|.OPT|; $x }
  905. grep { $_ =~ m|\.ld$| }
  906. @{$args{objs}};
  907. my @deps = compute_lib_depends(@{$args{deps}});
  908. my $deps = join(", -\n\t\t", @objs, @defs, @deps);
  909. die "More than one symbol vector" if scalar @defs > 1;
  910. my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
  911. # The "[]" hack is because in .OPT files, each line inherits the
  912. # previous line's file spec as default, so if no directory spec
  913. # is present in the current line and the previous line has one that
  914. # doesn't apply, you're in for a surprise.
  915. my $write_opt1 =
  916. join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
  917. "WRITE OPT_FILE \"$x" } @objs).
  918. "\"";
  919. my $write_opt2 =
  920. join("\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
  921. $x =~ s|(\.EXE)|$1/SHARE|;
  922. $x =~ s|(\.OLB)|$1/LIB|;
  923. "WRITE OPT_FILE \"$x\"" } @deps)
  924. || "\@ !";
  925. return <<"EOF"
  926. $lib.EXE : $deps
  927. OPEN/WRITE/SHARE=READ OPT_FILE $lib-components.OPT
  928. $write_opt1
  929. $write_opt2
  930. CLOSE OPT_FILE
  931. LINK \$(DSO_LDFLAGS)/SHARE=\$\@ $defs[0]/OPT,-
  932. $lib-components.OPT/OPT \$(DSO_EX_LIBS)
  933. - PURGE $lib.EXE,$lib.OPT,$lib.MAP
  934. EOF
  935. . ($config{target} =~ m|alpha| ? "" : <<"EOF"
  936. SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
  937. EOF
  938. );
  939. }
  940. sub obj2lib {
  941. my %args = @_;
  942. (my $lib = $args{lib}) =~ s/\.a$//;
  943. my @objs = map { (my $x = $_) =~ s|\.o$|.OBJ|; $x } @{$args{objs}};
  944. my $objs = join(", -\n\t\t", @objs);
  945. my $fill_lib = join("\n\t", (map { "LIBRARY/REPLACE $lib.OLB $_" }
  946. @objs));
  947. return <<"EOF";
  948. $lib.OLB : $objs
  949. LIBRARY/CREATE/OBJECT $lib.OLB
  950. $fill_lib
  951. - PURGE $lib.OLB
  952. EOF
  953. }
  954. sub obj2bin {
  955. my %args = @_;
  956. my $bin = $args{bin};
  957. my $bind = dirname($bin);
  958. my $binn = basename($bin);
  959. my @objs = map { (my $x = $_) =~ s|\.o$|.OBJ|; $x } @{$args{objs}};
  960. my $objs = join(",", @objs);
  961. my @deps = compute_lib_depends(@{$args{deps}});
  962. my $deps = join(", -\n\t\t", @objs, @deps);
  963. my $olb_count = scalar grep(m|\.OLB$|, @deps);
  964. my $analyse_objs = "@ !";
  965. if ($olb_count > 0) {
  966. my $analyse_quals =
  967. $config{target} =~ m|alpha| ? "/GSD" : "/SECTIONS=SYMTAB";
  968. $analyse_objs = "- pipe ANALYSE/OBJECT$analyse_quals $objs | SEARCH SYS\$INPUT \"\"\"main\"\"\" ; nomain = \$severity .NE. 1"
  969. }
  970. # The "[]" hack is because in .OPT files, each line inherits the
  971. # previous line's file spec as default, so if no directory spec
  972. # is present in the current line and the previous line has one that
  973. # doesn't apply, you're in for a surprise.
  974. my $write_opt1 =
  975. join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
  976. "\@ WRITE OPT_FILE \"$x" } @objs).
  977. "\"";
  978. my $write_opt2 =
  979. join("\n\t", map { my @lines = (
  980. "\ WRITE OPT_FILE \"CASE_SENSITIVE=YES\""
  981. );
  982. my $x = $_ =~ /\[/ ? $_ : "[]".$_;
  983. if ($x =~ m|\.EXE$|) {
  984. push @lines, "\@ WRITE OPT_FILE \"$x/SHARE\"";
  985. } elsif ($x =~ m|\.OLB$|) {
  986. (my $l = $x) =~ s/\W/_/g;
  987. push @lines,
  988. "\@ IF nomain THEN WRITE OPT_FILE \"$x/LIB\$(INCLUDE_MAIN_$l)\"",
  989. "\@ IF .NOT. nomain THEN WRITE OPT_FILE \"$x/LIB\""
  990. }
  991. @lines
  992. } @deps)
  993. || "\@ !";
  994. # The linking commands looks a bit complex, but it's for good reason.
  995. # When you link, say, foo.obj, bar.obj and libsomething.exe/share, and
  996. # bar.obj happens to have a symbol that also exists in libsomething.exe,
  997. # the linker will warn about it, loudly, and will then choose to pick
  998. # the first copy encountered (the one in bar.obj in this example).
  999. # On Unix and on Windows, the corresponding maneuvre goes through
  1000. # silently with the same effect.
  1001. # With some test programs, made for checking the internals of OpenSSL,
  1002. # we do this kind of linking deliberately, picking a few specific object
  1003. # files from within [.crypto] or [.ssl] so we can reach symbols that are
  1004. # otherwise unreachable (since the shareable images only exports the
  1005. # symbols listed in [.util]*.num), and then with the shared libraries
  1006. # themselves. So we need to silence the warning about multiply defined
  1007. # symbols, to mimic the way linking work on Unix and Windows, and so
  1008. # the build isn't interrupted (MMS stops when warnings are signaled,
  1009. # by default), and so someone building doesn't have to worry where it
  1010. # isn't necessary. If there are other warnings, however, we show them
  1011. # and let it break the build.
  1012. return <<"EOF"
  1013. $bin.EXE : $deps
  1014. $analyse_objs
  1015. @ OPEN/WRITE/SHARE=READ OPT_FILE $bin.OPT
  1016. $write_opt1
  1017. $write_opt2
  1018. @ CLOSE OPT_FILE
  1019. TYPE $bin.opt ! For debugging
  1020. - pipe SPAWN/WAIT/NOLOG/OUT=$bin.LINKLOG -
  1021. LINK \$(BIN_LDFLAGS)/EXEC=\$\@ $bin.OPT/OPT \$(BIN_EX_LIBS) ; -
  1022. link_status = \$status ; link_severity = link_status .AND. 7
  1023. @ search_severity = 1
  1024. -@ IF link_severity .EQ. 0 THEN -
  1025. pipe SEARCH $bin.LINKLOG "%","-"/MATCH=AND | -
  1026. SPAWN/WAIT/NOLOG/OUT=NLA0: -
  1027. SEARCH SYS\$INPUT: "-W-MULDEF,"/MATCH=NOR ; -
  1028. search_severity = \$severity
  1029. @ ! search_severity is 3 when the last search didn't find any matching
  1030. @ ! string: %SEARCH-I-NOMATCHES, no strings matched
  1031. @ ! If that was the result, we pretend linking got through without
  1032. @ ! fault or warning.
  1033. @ IF search_severity .EQ. 3 THEN link_severity = 1
  1034. @ ! At this point, if link_severity shows that there was a fault
  1035. @ ! or warning, make sure to restore the linking status.
  1036. -@ IF .NOT. link_severity THEN TYPE $bin.LINKLOG
  1037. -@ DELETE $bin.LINKLOG;*
  1038. @ IF .NOT. link_severity THEN SPAWN/WAIT/NOLOG EXIT 'link_status'
  1039. - PURGE $bin.EXE,$bin.OPT
  1040. EOF
  1041. . ($config{target} =~ m|alpha| ? "" : <<"EOF"
  1042. SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
  1043. EOF
  1044. );
  1045. }
  1046. sub in2script {
  1047. my %args = @_;
  1048. my $script = $args{script};
  1049. return "" if grep { $_ eq $script } @{$args{sources}}; # No overwrite!
  1050. my $sources = join(" ", @{$args{sources}});
  1051. my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
  1052. "util", "dofile.pl")),
  1053. rel2abs($config{builddir}));
  1054. return <<"EOF";
  1055. $script : $sources
  1056. \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile -
  1057. "-o$target{build_file}" $sources > $script
  1058. SET FILE/PROT=(S:RWED,O:RWED,G:RE,W:RE) $script
  1059. PURGE $script
  1060. EOF
  1061. }
  1062. "" # Important! This becomes part of the template result.
  1063. -}