descrip.mms.tmpl 49 KB

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