2
0

descrip.mms.tmpl 49 KB

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