descrip.mms.tmpl 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184
  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 $osslprefix_q = platform->osslprefix()) =~ s/\$/\\\$/;
  8. our $sover_dirname = platform->shlib_version_as_filename();
  9. our $osslver = sprintf "%02d%02d", split(/\./, $config{version});
  10. our $sourcedir = $config{sourcedir};
  11. our $builddir = $config{builddir};
  12. sub sourcefile {
  13. catfile($sourcedir, @_);
  14. }
  15. sub buildfile {
  16. catfile($builddir, @_);
  17. }
  18. sub sourcedir {
  19. catdir($sourcedir, @_);
  20. }
  21. sub builddir {
  22. catdir($builddir, @_);
  23. }
  24. sub tree {
  25. (my $x = shift) =~ s|\]$|...]|;
  26. $x
  27. }
  28. sub move {
  29. my $f = catdir(@_);
  30. my $b = abs2rel(rel2abs("."),rel2abs($f));
  31. $sourcedir = catdir($b,$sourcedir)
  32. if !file_name_is_absolute($sourcedir);
  33. $builddir = catdir($b,$builddir)
  34. if !file_name_is_absolute($builddir);
  35. "";
  36. }
  37. # Because we need to make two computations of these data,
  38. # we store them in arrays for reuse
  39. our @libs =
  40. map { platform->staticname($_) }
  41. @{$unified_info{libraries}};
  42. our @shlibs =
  43. map { platform->sharedname($_) // () }
  44. @{$unified_info{libraries}};
  45. our @install_libs =
  46. map { platform->staticname($_) }
  47. grep { !$unified_info{attributes}->{$_}->{noinst} }
  48. @{$unified_info{libraries}};
  49. our @install_shlibs =
  50. map { platform->sharedname($_) // () }
  51. grep { !$unified_info{attributes}->{$_}->{noinst} }
  52. @{$unified_info{libraries}};
  53. our @install_engines =
  54. grep { !$unified_info{attributes}->{$_}->{noinst} }
  55. @{$unified_info{engines}};
  56. our @install_programs =
  57. grep { !$unified_info{attributes}->{$_}->{noinst} }
  58. @{$unified_info{programs}};
  59. our @install_bin_scripts =
  60. grep { !$unified_info{attributes}->{$_}->{noinst}
  61. && !$unified_info{attributes}->{$_}->{misc} }
  62. @{$unified_info{scripts}};
  63. our @install_misc_scripts =
  64. grep { !$unified_info{attributes}->{$_}->{noinst}
  65. && $unified_info{attributes}->{$_}->{misc} }
  66. @{$unified_info{scripts}};
  67. # This is a horrible hack, but is needed because recursive inclusion of files
  68. # in different directories does not work well with HP C.
  69. my $sd = sourcedir("crypto", "async", "arch");
  70. foreach (grep /\[\.crypto\.async\.arch\].*\.o$/, keys %{$unified_info{sources}}) {
  71. my $obj = platform->obj($_);
  72. $unified_info{before}->{$obj}
  73. = qq(arch_include = F\$PARSE("$sd","A.;",,,"SYNTAX_ONLY") - "A.;"
  74. define arch 'arch_include');
  75. $unified_info{after}->{$obj}
  76. = qq(deassign arch);
  77. }
  78. my $sd1 = sourcedir("ssl","record");
  79. my $sd2 = sourcedir("ssl","statem");
  80. my @ssl_locl_users = grep(/^\[\.(?:ssl\.(?:record|statem)|test)\].*\.o$/,
  81. keys %{$unified_info{sources}});
  82. foreach (@ssl_locl_users) {
  83. my $obj = platform->obj($_);
  84. $unified_info{before}->{$obj}
  85. = qq(record_include = F\$PARSE("$sd1","A.;",,,"SYNTAX_ONLY") - "A.;"
  86. define record 'record_include'
  87. statem_include = F\$PARSE("$sd2","A.;",,,"SYNTAX_ONLY") - "A.;"
  88. define statem 'statem_include');
  89. $unified_info{after}->{$obj}
  90. = qq(deassign statem
  91. deassign record);
  92. }
  93. # This makes sure things get built in the order they need
  94. # to. You're welcome.
  95. sub dependmagic {
  96. my $target = shift;
  97. return "$target : build_generated\n\t\pipe \$(MMS) \$(MMSQUALIFIERS) depend && \$(MMS) \$(MMSQUALIFIERS) _$target\n_$target";
  98. }
  99. "";
  100. -}
  101. PLATFORM={- $config{target} -}
  102. OPTIONS={- $config{options} -}
  103. CONFIGURE_ARGS=({- join(", ",quotify_l(@{$config{perlargv}})) -})
  104. SRCDIR={- $config{sourcedir} -}
  105. BLDDIR={- $config{builddir} -}
  106. # Allow both V and VERBOSE to indicate verbosity. This only applies
  107. # to testing.
  108. VERBOSE=$(V)
  109. VERSION={- "$config{full_version}" -}
  110. MAJOR={- $config{major} -}
  111. MINOR={- $config{minor} -}
  112. SHLIB_VERSION_NUMBER={- $config{shlib_version} -}
  113. SHLIB_TARGET={- $target{shared_target} -}
  114. LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @libs) -}
  115. SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @shlibs) -}
  116. ENGINES={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{engines}}) -}
  117. PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @{$unified_info{programs}}) -}
  118. SCRIPTS={- join(", ", map { "-\n\t".$_ } @{$unified_info{scripts}}) -}
  119. {- output_off() if $disabled{makedepend}; "" -}
  120. DEPS={- our @deps = map { platform->isobj($_) ? platform->dep($_) : $_ }
  121. grep { $unified_info{sources}->{$_}->[0] =~ /\.c$/ }
  122. keys %{$unified_info{sources}};
  123. join(", ", map { "-\n\t".$_ } @deps); -}
  124. {- output_on() if $disabled{makedepend}; "" -}
  125. GENERATED_MANDATORY={- join(", ", map { "-\n\t".$_ } @{$unified_info{depends}->{""}} ) -}
  126. GENERATED={- # common0.tmpl provides @generated
  127. join(", ", map { platform->convertext($_) } @generated) -}
  128. INSTALL_LIBS={- join(", ", map { "-\n\t".$_.".OLB" } @install_libs) -}
  129. INSTALL_SHLIBS={- join(", ", map { "-\n\t".$_.".EXE" } @install_shlibs) -}
  130. INSTALL_ENGINES={- join(", ", map { "-\n\t".$_.".EXE" } @install_engines) -}
  131. INSTALL_PROGRAMS={- join(", ", map { "-\n\t".$_.".EXE" } @install_programs) -}
  132. BIN_SCRIPTS={- join(", ", @install_bin_scripts) -}
  133. MISC_SCRIPTS={- join(", ", @install_misc_scripts) -}
  134. APPS_OPENSSL={- use File::Spec::Functions;
  135. catfile("apps","openssl") -}
  136. # DESTDIR is for package builders so that they can configure for, say,
  137. # SYS$COMMON:[OPENSSL] and yet have everything installed in STAGING:[USER].
  138. # In that case, configure with --prefix=SYS$COMMON:[OPENSSL] and then run
  139. # MMS with /MACROS=(DESTDIR=STAGING:[USER]). The result will end up in
  140. # STAGING:[USER.OPENSSL].
  141. # Normally it is left empty.
  142. DESTDIR=
  143. # Do not edit this manually. Use Configure --prefix=DIR to change this!
  144. INSTALLTOP={- our $installtop =
  145. catdir($config{prefix}) || "SYS\$COMMON:[OPENSSL]";
  146. $installtop -}
  147. SYSTARTUP={- catdir($installtop, '[.SYS$STARTUP]'); -}
  148. # This is the standard central area to store certificates, private keys...
  149. OPENSSLDIR={- catdir($config{openssldir}) or
  150. $config{prefix} ? catdir($config{prefix},"COMMON")
  151. : "SYS\$COMMON:[OPENSSL-COMMON]" -}
  152. # The same, but for C
  153. OPENSSLDIR_C={- platform->osslprefix() -}DATAROOT:[000000]
  154. # Where installed engines reside, for C
  155. ENGINESDIR_C={- platform->osslprefix() -}ENGINES{- $sover_dirname.$target{pointer_size} -}:
  156. ##### User defined commands and flags ################################
  157. CC={- $config{CC} -}
  158. CPP={- $config{CPP} -}
  159. DEFINES={- our $defines1 = join('', map { ",$_" } @{$config{CPPDEFINES}}) -}
  160. INCLUDES={- our $includes1 = join(',', @{$config{CPPINCLUDES}}) -}
  161. CPPFLAGS={- our $cppflags1 = join('', @{$config{CPPFLAGS}}) -}
  162. CFLAGS={- join('', @{$config{CFLAGS}}) -}
  163. LDFLAGS={- join('', @{$config{LFLAGS}}) -}
  164. EX_LIBS={- join('', map { ",$_" } @{$config{LDLIBS}}) -}
  165. PERL={- $config{PERL} -}
  166. AS={- $config{AS} -}
  167. ASFLAGS={- join(' ', @{$config{ASFLAGS}}) -}
  168. ##### Special command flags ##########################################
  169. ASOUTFLAG={- $target{asoutflag} -}$(OSSL_EMPTY)
  170. ##### Project flags ##################################################
  171. # Variables starting with CNF_ are common variables for all product types
  172. CNF_ASFLAGS={- join('', $target{asflags} || (),
  173. @{$config{asflags}}) -}
  174. CNF_DEFINES={- our $defines2 = join('', (map { ",$_" } @{$target{defines}},
  175. @{$config{defines}}),
  176. "'extradefines'") -}
  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_cflags} || (),
  277. @{$config{bin_cflags}},
  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_dso_cflags}
  291. // $target{dso_cflags}
  292. // (),
  293. $target{no_inst_module_cflags}
  294. // $target{module_cflags}
  295. // (),
  296. @{$config{dso_cflags}},
  297. @{$config{module_cflags}},
  298. '$(CNF_CFLAGS)', '$(CFLAGS)') -}
  299. NO_INST_BIN_CFLAGS={- join('', $target{no_inst_bin_cflags}
  300. // $target{bin_cflags}
  301. // (),
  302. @{$config{bin_cflags}},
  303. '$(CNF_CFLAGS)', '$(CFLAGS)') -}
  304. PERLASM_SCHEME={- $target{perlasm_scheme} -}
  305. # CPPFLAGS_Q is used for one thing only: to build up buildinf.h
  306. CPPFLAGS_Q={- (my $c = $lib_cppflags.$cppflags2.$cppflags1) =~ s|"|""|g;
  307. (my $d = $lib_defines.$defines2.$defines1) =~ s|"|""|g;
  308. my $i = join(',', $lib_includes || (), $includes2 || (),
  309. $includes1 || ());
  310. my $x = $c;
  311. $x .= "/INCLUDE=($i)" if $i;
  312. $x .= "/DEFINE=($d)" if $d;
  313. $x; -}
  314. # .FIRST and .LAST are special targets with MMS and MMK.
  315. # The defines in there are for C. includes that look like
  316. # this:
  317. #
  318. # #include <openssl/foo.h>
  319. # #include "internal/bar.h"
  320. #
  321. # will use the logical names to find the files. Expecting
  322. # DECompHP C to find files in subdirectories of whatever was
  323. # given with /INCLUDE is a fantasy, unfortunately.
  324. NODEBUG=@
  325. .FIRST :
  326. $(NODEBUG) openssl_inc1 = F$PARSE("[.include.openssl]","A.;",,,"syntax_only") - "A.;"
  327. $(NODEBUG) openssl_inc2 = F$PARSE("{- catdir($config{sourcedir},"[.include.openssl]") -}","A.;",,,"SYNTAX_ONLY") - "A.;"
  328. $(NODEBUG) internal_inc1 = F$PARSE("[.crypto.include.internal]","A.;",,,"SYNTAX_ONLY") - "A.;"
  329. $(NODEBUG) internal_inc2 = F$PARSE("{- catdir($config{sourcedir},"[.include.internal]") -}","A.;",,,"SYNTAX_ONLY") - "A.;"
  330. $(NODEBUG) internal_inc3 = F$PARSE("{- catdir($config{sourcedir},"[.crypto.include.internal]") -}","A.;",,,"SYNTAX_ONLY") - "A.;"
  331. $(NODEBUG) DEFINE openssl 'openssl_inc1','openssl_inc2'
  332. $(NODEBUG) DEFINE internal 'internal_inc1','internal_inc2','internal_inc3'
  333. $(NODEBUG) staging_dir = "$(DESTDIR)"
  334. $(NODEBUG) staging_instdir = ""
  335. $(NODEBUG) staging_datadir = ""
  336. $(NODEBUG) IF staging_dir .NES. "" THEN -
  337. staging_instdir = F$PARSE("A.;",staging_dir,"[]",,"SYNTAX_ONLY")
  338. $(NODEBUG) IF staging_instdir - "]A.;" .NES. staging_instdir THEN -
  339. staging_instdir = staging_instdir - "]A.;" + ".OPENSSL-INSTALL]"
  340. $(NODEBUG) IF staging_instdir - "A.;" .NES. staging_instdir THEN -
  341. staging_instdir = staging_instdir - "A.;" + "[OPENSSL-INSTALL]"
  342. $(NODEBUG) IF staging_dir .NES. "" THEN -
  343. staging_datadir = F$PARSE("A.;",staging_dir,"[]",,"SYNTAX_ONLY")
  344. $(NODEBUG) IF staging_datadir - "]A.;" .NES. staging_datadir THEN -
  345. staging_datadir = staging_datadir - "]A.;" + ".OPENSSL-COMMON]"
  346. $(NODEBUG) IF staging_datadir - "A.;" .NES. staging_datadir THEN -
  347. staging_datadir = staging_datadir - "A.;" + "[OPENSSL-COMMON]"
  348. $(NODEBUG) !
  349. $(NODEBUG) ! Installation logical names
  350. $(NODEBUG) !
  351. $(NODEBUG) installtop = F$PARSE(staging_instdir,"$(INSTALLTOP)","[]A.;",,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;" + ".]"
  352. $(NODEBUG) datatop = F$PARSE(staging_datadir,"$(OPENSSLDIR)","[]A.;",,"SYNTAX_ONLY,NO_CONCEAL") - ".][000000" - "[000000." - "][" - "]A.;" + ".]"
  353. $(NODEBUG) DEFINE ossl_installroot 'installtop'
  354. $(NODEBUG) DEFINE ossl_dataroot 'datatop'
  355. $(NODEBUG) !
  356. $(NODEBUG) ! Figure out the architecture
  357. $(NODEBUG) !
  358. $(NODEBUG) arch = f$edit( f$getsyi( "arch_name"), "upcase")
  359. $(NODEBUG) !
  360. $(NODEBUG) ! Set up logical names for the libraries, so LINK and
  361. $(NODEBUG) ! running programs can use them.
  362. $(NODEBUG) !
  363. $(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEFINE ".uc($_)." 'F\$ENV(\"DEFAULT\")'".uc($_)."\$(SHLIB_EXT)" } @shlibs) || "!" -}
  364. .LAST :
  365. $(NODEBUG) {- join("\n\t\$(NODEBUG) ", map { "DEASSIGN ".uc($_) } @shlibs) || "!" -}
  366. $(NODEBUG) DEASSIGN ossl_dataroot
  367. $(NODEBUG) DEASSIGN ossl_installroot
  368. $(NODEBUG) DEASSIGN internal
  369. $(NODEBUG) DEASSIGN openssl
  370. .DEFAULT :
  371. @ ! MMS cannot handle no actions...
  372. # The main targets ###################################################
  373. {- dependmagic('all'); -} : build_libs_nodep, build_engines_nodep, build_programs_nodep
  374. {- dependmagic('build_libs'); -} : build_libs_nodep
  375. {- dependmagic('build_engines'); -} : build_engines_nodep
  376. {- dependmagic('build_programs'); -} : build_programs_nodep
  377. build_generated : $(GENERATED_MANDATORY)
  378. build_libs_nodep : $(LIBS), $(SHLIBS)
  379. build_engines_nodep : $(ENGINES)
  380. build_programs_nodep : $(PROGRAMS), $(SCRIPTS)
  381. # Kept around for backward compatibility
  382. build_apps build_tests : build_programs
  383. # Convenience target to prebuild all generated files, not just the mandatory
  384. # ones
  385. build_all_generated : $(GENERATED_MANDATORY) $(GENERATED)
  386. @ ! {- output_off() if $disabled{makedepend}; "" -}
  387. @ WRITE SYS$OUTPUT "Warning: consider configuring with no-makedepend, because if"
  388. @ WRITE SYS$OUTPUT " target system doesn't have $(PERL),"
  389. @ WRITE SYS$OUTPUT " then make will fail..."
  390. @ ! {- output_on() if $disabled{makedepend}; "" -}
  391. test : tests
  392. {- dependmagic('tests'); -} : build_programs_nodep, build_engines_nodep
  393. @ ! {- output_off() if $disabled{tests}; "" -}
  394. SET DEFAULT [.test]{- move("test") -}
  395. CREATE/DIR [.test-runs]
  396. DEFINE SRCTOP {- sourcedir() -}
  397. DEFINE BLDTOP {- builddir() -}
  398. DEFINE RESULT_D {- builddir(qw(test test-runs)) -}
  399. DEFINE OPENSSL_ENGINES {- builddir("engines") -}
  400. DEFINE OPENSSL_DEBUG_MEMORY "on"
  401. IF "$(VERBOSE)" .NES. "" THEN DEFINE VERBOSE "$(VERBOSE)"
  402. $(PERL) {- sourcefile("test", "run_tests.pl") -} $(TESTS)
  403. DEASSIGN OPENSSL_DEBUG_MEMORY
  404. DEASSIGN OPENSSL_ENGINES
  405. DEASSIGN BLDTOP
  406. DEASSIGN SRCTOP
  407. SET DEFAULT [-]{- move("..") -}
  408. @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
  409. @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options"
  410. @ ! {- output_on() if !$disabled{tests}; "" -}
  411. list-tests :
  412. @ ! {- output_off() if $disabled{tests}; "" -}
  413. @ DEFINE SRCTOP {- sourcedir() -}
  414. @ $(PERL) {- sourcefile("test", "run_tests.pl") -} list
  415. @ DEASSIGN SRCTOP
  416. @ ! {- if ($disabled{tests}) { output_on(); } else { output_off(); } "" -}
  417. @ WRITE SYS$OUTPUT "Tests are not supported with your chosen Configure options"
  418. @ ! {- output_on() if !$disabled{tests}; "" -}
  419. install : install_sw install_ssldirs install_docs
  420. @ WRITE SYS$OUTPUT ""
  421. @ WRITE SYS$OUTPUT "######################################################################"
  422. @ WRITE SYS$OUTPUT ""
  423. @ IF "$(DESTDIR)" .EQS. "" THEN -
  424. PIPE ( WRITE SYS$OUTPUT "Installation complete" ; -
  425. WRITE SYS$OUTPUT "" ; -
  426. WRITE SYS$OUTPUT "Run @$(SYSTARTUP)openssl_startup{- $osslver -} to set up logical names" ; -
  427. WRITE SYS$OUTPUT "then run @$(SYSTARTUP)openssl_utils{- $osslver -} to define commands" ; -
  428. WRITE SYS$OUTPUT "" )
  429. @ IF "$(DESTDIR)" .NES. "" THEN -
  430. PIPE ( WRITE SYS$OUTPUT "Staging installation complete" ; -
  431. WRITE SYS$OUTPUT "" ; -
  432. WRITE SYS$OUTPUT "Finish or package in such a way that the contents of the directory tree" ; -
  433. WRITE SYS$OUTPUT staging_instdir ; -
  434. WRITE SYS$OUTPUT "ends up in $(INSTALLTOP)," ; -
  435. WRITE SYS$OUTPUT "and that the contents of the contents of the directory tree" ; -
  436. WRITE SYS$OUTPUT staging_datadir ; -
  437. WRITE SYS$OUTPUT "ends up in $(OPENSSLDIR)" ; -
  438. WRITE SYS$OUTPUT "" ; -
  439. WRITE SYS$OUTPUT "When in its final destination," ; -
  440. WRITE SYS$OUTPUT "Run @$(SYSTARTUP)openssl_startup{- $osslver -} to set up logical names" ; -
  441. WRITE SYS$OUTPUT "then run @$(SYSTARTUP)openssl_utils{- $osslver -} to define commands" ; -
  442. WRITE SYS$OUTPUT "" )
  443. check_install :
  444. spawn/nolog @ossl_installroot:[SYSTEST]openssl_ivp{- $osslver -}.com
  445. uninstall : uninstall_docs uninstall_sw
  446. # Because VMS wants the generation number (or *) to delete files, we can't
  447. # use $(LIBS), $(PROGRAMS), $(GENERATED) and $(ENGINES)directly.
  448. libclean :
  449. {- join("\n\t", map { "- DELETE $_.OLB;*" } @libs) || "@ !" -}
  450. {- join("\n\t", map { "- DELETE $_.EXE;*,$_.MAP;*" } @shlibs) || "@ !" -}
  451. clean : libclean
  452. {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{programs}}) || "@ !" -}
  453. {- join("\n\t", map { "- DELETE $_.EXE;*,$_.OPT;*" } @{$unified_info{engines}}) || "@ !" -}
  454. {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{scripts}}) || "@ !" -}
  455. {- join("\n\t", map { "- DELETE $_;*" } @{$unified_info{depends}->{""}}) || "@ !" -}
  456. {- join("\n\t", map { "- DELETE $_;*" } @generated) || "@ !" -}
  457. - DELETE [...]*.MAP;*
  458. - DELETE [...]*.D;*
  459. - DELETE [...]*.OBJ;*,*.LIS;*
  460. - DELETE []CXX$DEMANGLER_DB.;*
  461. - DELETE [.VMS]openssl_startup.com;*
  462. - DELETE [.VMS]openssl_shutdown.com;*
  463. - DELETE []vmsconfig.pm;*
  464. distclean : clean
  465. - DELETE configdata.pm;*
  466. - DELETE descrip.mms;*
  467. depend : descrip.mms
  468. descrip.mms : FORCE
  469. @ ! {- output_off() if $disabled{makedepend}; "" -}
  470. @ $(PERL) {- sourcefile("util", "add-depends.pl") -} "VMS C"
  471. @ ! {- output_on() if $disabled{makedepend}; "" -}
  472. # Install helper targets #############################################
  473. install_sw : install_dev install_engines install_runtime -
  474. install_startup install_ivp
  475. uninstall_sw : uninstall_dev uninstall_engines uninstall_runtime -
  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_dev : check_INSTALLTOP install_runtime_libs
  501. @ WRITE SYS$OUTPUT "*** Installing development files"
  502. @ ! Install header files
  503. - CREATE/DIR ossl_installroot:[include.openssl]
  504. COPY/PROT=W:R openssl:*.h ossl_installroot:[include.openssl]
  505. @ ! Install static (development) libraries
  506. - CREATE/DIR ossl_installroot:[LIB.'arch']
  507. {- join("\n ",
  508. map { "COPY/PROT=W:R $_.OLB ossl_installroot:[LIB.'arch']" }
  509. @install_libs) -}
  510. install_engines : check_INSTALLTOP install_runtime_libs build_engines
  511. @ {- output_off() unless scalar @{$unified_info{engines}}; "" -} !
  512. @ WRITE SYS$OUTPUT "*** Installing engines"
  513. - CREATE/DIR ossl_installroot:[ENGINES{- $sover_dirname.$target{pointer_size} -}.'arch']
  514. {- join("\n ",
  515. map { "COPY/PROT=W:RE $_.EXE ossl_installroot:[ENGINES$sover_dirname$target{pointer_size}.'arch']" }
  516. @install_engines) -}
  517. @ {- output_on() unless scalar @{$unified_info{engines}}; "" -} !
  518. install_runtime : install_programs
  519. install_runtime_libs : check_INSTALLTOP build_libs
  520. @ {- output_off() if $disabled{shared}; "" -} !
  521. @ WRITE SYS$OUTPUT "*** Installing shareable images"
  522. @ ! Install shared (runtime) libraries
  523. - CREATE/DIR ossl_installroot:[LIB.'arch']
  524. {- join("\n ",
  525. map { "COPY/PROT=W:R $_.EXE ossl_installroot:[LIB.'arch']" }
  526. @install_shlibs) -}
  527. @ {- output_on() if $disabled{shared}; "" -} !
  528. install_programs : check_INSTALLTOP install_runtime_libs build_programs
  529. @ {- output_off() if $disabled{apps}; "" -} !
  530. @ ! Install the main program
  531. - CREATE/DIR ossl_installroot:[EXE.'arch']
  532. COPY/PROT=W:RE [.APPS]openssl.EXE -
  533. ossl_installroot:[EXE.'arch']openssl{- $osslver -}.EXE
  534. @ ! Install scripts
  535. COPY/PROT=W:RE $(BIN_SCRIPTS) ossl_installroot:[EXE]
  536. @ ! {- output_on() if $disabled{apps}; "" -}
  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 => '","{- $config{shlib_version} -}","',"
  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. # Depending on shared libraries:
  626. # On Windows POSIX layers, we depend on {libname}.dll.a
  627. # On Unix platforms, we depend on {shlibname}.so
  628. return map {
  629. { lib => platform->sharedlib($_) // platform->staticlib($_),
  630. attrs => $unified_info{attributes}->{$_} }
  631. } @_;
  632. }
  633. # Helper function to deal with inclusion directory specs.
  634. # We have to deal with two things:
  635. # 1. comma separation and no possibility of trailing comma
  636. # 2. no inclusion directories given at all
  637. # 3. long compiler command lines
  638. # To resolve 1, we need to iterate through the sources of inclusion
  639. # directories, and only add a comma when needed.
  640. # To resolve 2, we need to have a variable that will hold the whole
  641. # inclusion qualifier, or be the empty string if there are no inclusion
  642. # directories. That's the symbol 'qual_includes' that's used in CPPFLAGS
  643. # To resolve 3, we creata a logical name TMP_INCLUDES: to hold the list
  644. # of inclusion directories.
  645. #
  646. # This function returns a list of two lists, one being the collection of
  647. # commands to execute before the compiler is called, and the other being
  648. # the collection of commands to execute after. It takes as arguments the
  649. # collection of strings to include as directory specs.
  650. sub includes {
  651. my @stuff = ( @_ );
  652. my @before = (
  653. 'qual_includes :=',
  654. );
  655. my @after = (
  656. 'DELETE/SYMBOL/LOCAL qual_includes',
  657. );
  658. if (scalar @stuff > 0) {
  659. push @before, 'tmp_includes := '.shift(@stuff);
  660. while (@stuff) {
  661. push @before, 'tmp_add := '.shift(@stuff);
  662. push @before, 'IF tmp_includes .NES. "" .AND. tmp_add .NES. "" THEN tmp_includes = tmp_includes + ","';
  663. push @before, 'tmp_includes = tmp_includes + tmp_add';
  664. }
  665. push @before, "IF tmp_includes .NES. \"\" THEN DEFINE tmp_includes 'tmp_includes'";
  666. push @before, 'IF tmp_includes .NES. "" THEN qual_includes := /INCLUDE=(tmp_includes:)';
  667. push @before, 'DELETE/SYMBOL/LOCAL tmp_includes';
  668. push @before, 'DELETE/SYMBOL/LOCAL tmp_add';
  669. push @after, 'DEASSIGN tmp_includes:'
  670. }
  671. return ([ @before ], [ @after ]);
  672. }
  673. sub generatesrc {
  674. my %args = @_;
  675. my $generator = join(" ", @{$args{generator}});
  676. my $generator_incs = join("", map { ' "-I'.$_.'"' } @{$args{generator_incs}});
  677. my $deps = join(", -\n\t\t", @{$args{generator_deps}}, @{$args{deps}});
  678. if (platform->isdef($args{src})) {
  679. my $target = platform->def($args{src});
  680. my $mkdef = sourcefile('util', 'mkdef.pl');
  681. my $ord_ver = $args{intent} eq 'lib' ? ' --version $(VERSION)' : '';
  682. my $ord_name =
  683. $args{generator}->[1] || basename($args{product}, '.EXE');
  684. my $case_insensitive =
  685. $target{$args{intent}.'_cflags'} =~ m|/NAMES=[^/]*AS_IS|i
  686. ? '' : ' --case-insensitive';
  687. return <<"EOF";
  688. $target : $args{generator}->[0] $deps $mkdef
  689. \$(PERL) $mkdef$ord_ver --ordinals $args{generator}->[0] --name $ord_name "--OS" "VMS"$case_insensitive > $target
  690. EOF
  691. } elsif (!platform->isasm($args{src})) {
  692. my $target = $args{src};
  693. if ($args{generator}->[0] =~ m|^.*\.in$|) {
  694. my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
  695. "util", "dofile.pl")),
  696. rel2abs($config{builddir}));
  697. return <<"EOF";
  698. $target : $args{generator}->[0] $deps
  699. \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile \\
  700. "-o$target{build_file}" $generator > \$\@
  701. EOF
  702. } else {
  703. return <<"EOF";
  704. $target : $args{generator}->[0] $deps
  705. \$(PERL)$generator_incs $generator > \$\@
  706. EOF
  707. }
  708. } else {
  709. my $target = platform->asm($args{src});
  710. if ($args{generator}->[0] =~ /\.pl$/) {
  711. $generator = '$(PERL)'.$generator_incs.' '.$generator;
  712. } elsif ($args{generator}->[0] =~ /\.S$/) {
  713. $generator = undef;
  714. } else {
  715. die "Generator type for $src unknown: $generator\n";
  716. }
  717. my $cppflags = {
  718. shlib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
  719. lib => '$(LIB_CFLAGS) $(LIB_CPPFLAGS)',
  720. dso => '$(DSO_CFLAGS) $(DSO_CPPFLAGS)',
  721. bin => '$(BIN_CFLAGS) $(BIN_CPPFLAGS)'
  722. } -> {$args{intent}};
  723. my @incs_cmds = includes({ shlib => '$(LIB_INCLUDES)',
  724. lib => '$(LIB_INCLUDES)',
  725. dso => '$(DSO_INCLUDES)',
  726. bin => '$(BIN_INCLUDES)' } -> {$args{intent}},
  727. '$(CNF_INCLUDES)',
  728. '$(INCLUDES)',
  729. @{$args{incs}});
  730. my $incs_on = join("\n\t\@ ", @{$incs_cmds[0]}) || '!';
  731. my $incs_off = join("\n\t\@ ", @{$incs_cmds[1]}) || '!';
  732. my $defs = join("", map { ",".$_ } @{$args{defs}});
  733. if (defined($generator)) {
  734. # If the target is named foo.S in build.info, we want to
  735. # end up generating foo.s in two steps.
  736. if ($args{src} =~ /\.S$/) {
  737. return <<"EOF";
  738. $target : $args{generator}->[0] $deps
  739. $generator \$\@-S
  740. \@ $incs_on
  741. \@ extradefines = "$defs"
  742. PIPE \$(CPP) $cppflags \$\@-S | -
  743. \$(PERL) -ne "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" > \$\@-i
  744. \@ DELETE/SYMBOL/LOCAL extradefines
  745. \@ $incs_off
  746. RENAME \$\@-i \$\@
  747. DELETE \$\@-S;
  748. EOF
  749. }
  750. # Otherwise....
  751. return <<"EOF";
  752. $target : $args{generator}->[0] $deps
  753. $generator \$\@
  754. EOF
  755. }
  756. return <<"EOF";
  757. $target : $args{generator}->[0] $deps
  758. \@ $incs_on
  759. \@ extradefines = "$defs"
  760. SHOW SYMBOL qual_includes
  761. PIPE \$(CPP) $cppflags $args{generator}->[0] | -
  762. \$(PERL) "-ne" "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" > \$\@
  763. \@ DELETE/SYMBOL/LOCAL extradefines
  764. \@ $incs_off
  765. EOF
  766. }
  767. }
  768. sub src2obj {
  769. my %args = @_;
  770. my @srcs = map { (my $x = $_) =~ s/\.s$/.asm/; $x } ( @{$args{srcs}} );
  771. my $obj = platform->obj($args{obj});
  772. my $deps = join(", -\n\t\t", @srcs, @{$args{deps}});
  773. # Because VMS C isn't very good at combining a /INCLUDE path with
  774. # #includes having a relative directory (like '#include "../foo.h"),
  775. # the best choice is to move to the first source file's intended
  776. # directory before compiling, and make sure to write the object file
  777. # in the correct position (important when the object tree is other
  778. # than the source tree).
  779. my $forward = dirname($args{srcs}->[0]);
  780. my $backward = abs2rel(rel2abs("."), rel2abs($forward));
  781. my $objd = abs2rel(rel2abs(dirname($obj)), rel2abs($forward));
  782. my $objn = basename($obj, platform->objext());
  783. my $srcs =
  784. join(", ", map { abs2rel(rel2abs($_), rel2abs($forward)) } @srcs);
  785. my $before = $unified_info{before}->{$obj} || "\@ !";
  786. my $after = $unified_info{after}->{$obj} || "\@ !";
  787. if ($srcs[0] =~ /\.asm$/) {
  788. my $asflags = { shlib => ' $(LIB_ASFLAGS)',
  789. lib => ' $(LIB_ASFLAGS)',
  790. dso => ' $(DSO_ASFLAGS)',
  791. bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
  792. return <<"EOF";
  793. $obj : $deps
  794. ${before}
  795. SET DEFAULT $forward
  796. \$(AS) $asflags \$(ASOUTFLAG)${objd}${objn}.OBJ $srcs
  797. SET DEFAULT $backward
  798. EOF
  799. }
  800. my $cflags;
  801. if ($args{attrs}->{noinst}) {
  802. $cflags = { shlib => '$(NO_INST_LIB_CFLAGS)',
  803. lib => '$(NO_INST_LIB_CFLAGS)',
  804. dso => '$(NO_INST_DSO_CFLAGS)',
  805. bin => '$(NO_INST_BIN_CFLAGS)' } -> {$args{intent}};
  806. } else {
  807. $cflags = { shlib => '$(LIB_CFLAGS)',
  808. lib => '$(LIB_CFLAGS)',
  809. dso => '$(DSO_CFLAGS)',
  810. bin => '$(BIN_CFLAGS)' } -> {$args{intent}};
  811. }
  812. $cflags .= { shlib => '$(LIB_CPPFLAGS)',
  813. lib => '$(LIB_CPPFLAGS)',
  814. dso => '$(DSO_CPPFLAGS)',
  815. bin => '$(BIN_CPPFLAGS)' } -> {$args{intent}};
  816. my $defs = join("", map { ",".$_ } @{$args{defs}});
  817. my $asflags = { shlib => ' $(LIB_ASFLAGS)',
  818. lib => ' $(LIB_ASFLAGS)',
  819. dso => ' $(DSO_ASFLAGS)',
  820. bin => ' $(BIN_ASFLAGS)' } -> {$args{intent}};
  821. my @incs_cmds = includes({ shlib => '$(LIB_INCLUDES)',
  822. lib => '$(LIB_INCLUDES)',
  823. dso => '$(DSO_INCLUDES)',
  824. bin => '$(BIN_INCLUDES)' } -> {$args{intent}},
  825. '$(INCLUDES)',
  826. map {
  827. file_name_is_absolute($_)
  828. ? $_ : catdir($backward,$_)
  829. } @{$args{incs}});
  830. my $incs_on = join("\n\t\@ ", @{$incs_cmds[0]}) || '!';
  831. my $incs_off = join("\n\t\@ ", @{$incs_cmds[1]}) || '!';
  832. if ($srcs[0] =~ /\.asm$/) {
  833. return <<"EOF";
  834. $obj.OBJ : $deps
  835. ${before}
  836. SET DEFAULT $forward
  837. \$(AS) $asflags \$(ASOUTFLAG)${objd}${objn}.OBJ $srcs
  838. SET DEFAULT $backward
  839. ${after}
  840. - PURGE $obj.OBJ
  841. EOF
  842. } elsif ($srcs[0] =~ /.S$/) {
  843. return <<"EOF";
  844. $obj.OBJ : $deps
  845. ${before}
  846. SET DEFAULT $forward
  847. \@ $incs_on
  848. \@ extradefines = "$defs"
  849. PIPE \$(CPP) ${cflags} $srcs | -
  850. \$(PERL) -ne "/^#(\\s*line)?\\s*[0-9]+\\s+""/ or print" -
  851. > ${objd}${objn}.asm
  852. \@ DELETE/SYMBOL/LOCAL extradefines
  853. \@ $incs_off
  854. SET DEFAULT $backward
  855. ${after}
  856. \$(AS) $asflags \$(ASOUTFLAG)$obj.OBJ $obj.asm
  857. - PURGE $obj.OBJ
  858. EOF
  859. }
  860. my $depbuild = $disabled{makedepend} ? ""
  861. : " /MMS=(FILE=${objd}${objn}.D,TARGET=$obj)";
  862. return <<"EOF";
  863. $obj : $deps
  864. ${before}
  865. SET DEFAULT $forward
  866. \@ $incs_on
  867. \@ extradefines = "$defs"
  868. \$(CC) ${cflags}${depbuild} /OBJECT=${objd}${objn}.OBJ /REPOSITORY=$backward $srcs
  869. \@ DELETE/SYMBOL/LOCAL extradefines
  870. \@ $incs_off
  871. SET DEFAULT $backward
  872. ${after}
  873. - PURGE $obj
  874. EOF
  875. }
  876. sub obj2shlib {
  877. my %args = @_;
  878. my $shlibname = platform->sharedname($args{lib});
  879. my $shlib = platform->sharedlib($args{lib});
  880. my @objs = map { platform->convertext($_) }
  881. grep { platform->isobj($_) }
  882. @{$args{objs}};
  883. my @defs = map { platform->convertext($_) }
  884. grep { platform->isdef($_) }
  885. @{$args{objs}};
  886. my @deps = compute_lib_depends(@{$args{deps}});
  887. die "More than one symbol vector" if scalar @defs > 1;
  888. my $deps = join(", -\n\t\t", @objs, @defs, map { $_->{lib} } @deps);
  889. my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
  890. my $translatesyms_pl = abs2rel(rel2abs(catfile($config{sourcedir},
  891. "VMS", "translatesyms.pl")),
  892. rel2abs($config{builddir}));
  893. # The "[]" hack is because in .OPT files, each line inherits the
  894. # previous line's file spec as default, so if no directory spec
  895. # is present in the current line and the previous line has one that
  896. # doesn't apply, you're in for a surprise.
  897. my $write_opt1 =
  898. join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
  899. "WRITE OPT_FILE \"$x" } @objs).
  900. "\"";
  901. my $write_opt2 =
  902. join("\n\t", map { my $x = $_->{lib} =~ /\[/
  903. ? $_->{lib} : "[]".$_->{lib};
  904. $x =~ s|(\.EXE)|$1/SHARE|;
  905. $x =~ s|(\.OLB)|$1/LIB|;
  906. "WRITE OPT_FILE \"$x\"" } @deps)
  907. || "\@ !";
  908. return <<"EOF"
  909. $shlib : $deps
  910. \$(PERL) $translatesyms_pl \$(BLDDIR)CXX\$DEMANGLER_DB. < $defs[0] > $defs[0]-translated
  911. OPEN/WRITE/SHARE=READ OPT_FILE $shlibname-components.OPT
  912. $write_opt1
  913. $write_opt2
  914. CLOSE OPT_FILE
  915. LINK \$(LIB_LDFLAGS)/SHARE=\$\@ $defs[0]-translated/OPT,-
  916. $shlibname-components.OPT/OPT \$(LIB_EX_LIBS)
  917. DELETE $defs[0]-translated;*,$shlibname-components.OPT;*
  918. PURGE $shlibname.EXE,$shlibname.MAP
  919. EOF
  920. . ($config{target} =~ m|alpha| ? "" : <<"EOF"
  921. SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
  922. EOF
  923. );
  924. }
  925. sub obj2dso {
  926. my %args = @_;
  927. my $dsoname = platform->dsoname($args{lib});
  928. my $dso = platform->dso($args{lib});
  929. my @objs = map { platform->convertext($_) }
  930. grep { platform->isobj($_) }
  931. @{$args{objs}};
  932. my @defs = map { platform->convertext($_) }
  933. grep { platform->isdef($_) }
  934. @{$args{objs}};
  935. my @deps = compute_lib_depends(@{$args{deps}});
  936. my $deps = join(", -\n\t\t", @objs, @defs, map { $_->{lib} } @deps);
  937. die "More than one symbol vector" if scalar @defs > 1;
  938. my $shlib_target = $disabled{shared} ? "" : $target{shared_target};
  939. # The "[]" hack is because in .OPT files, each line inherits the
  940. # previous line's file spec as default, so if no directory spec
  941. # is present in the current line and the previous line has one that
  942. # doesn't apply, you're in for a surprise.
  943. my $write_opt1 =
  944. join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
  945. "WRITE OPT_FILE \"$x" } @objs).
  946. "\"";
  947. my $write_opt2 =
  948. join("\n\t", map { my $x = $_->{lib} =~ /\[/
  949. ? $_->{lib} : "[]".$_->{lib};
  950. $x =~ s|(\.EXE)|$1/SHARE|;
  951. $x =~ s|(\.OLB)|$1/LIB|;
  952. "WRITE OPT_FILE \"$x\"" } @deps)
  953. || "\@ !";
  954. return <<"EOF"
  955. $dso : $deps
  956. OPEN/WRITE/SHARE=READ OPT_FILE $dsoname-components.OPT
  957. $write_opt1
  958. $write_opt2
  959. CLOSE OPT_FILE
  960. LINK \$(DSO_LDFLAGS)/SHARE=\$\@ $defs[0]/OPT,-
  961. $dsoname-components.OPT/OPT \$(DSO_EX_LIBS)
  962. - PURGE $dsoname.EXE,$dsoname.OPT,$dsoname.MAP
  963. EOF
  964. . ($config{target} =~ m|alpha| ? "" : <<"EOF"
  965. SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
  966. EOF
  967. );
  968. }
  969. sub obj2lib {
  970. my %args = @_;
  971. my $lib = platform->staticlib($args{lib});
  972. my @objs = map { platform->convertext($_) }
  973. grep { platform->isobj($_) }
  974. @{$args{objs}};
  975. my $objs = join(", -\n\t\t", @objs);
  976. my $fill_lib = join("\n\t", (map { "LIBRARY/REPLACE $lib $_" } @objs));
  977. return <<"EOF";
  978. $lib : $objs
  979. LIBRARY/CREATE/OBJECT $lib
  980. $fill_lib
  981. - PURGE $lib
  982. EOF
  983. }
  984. sub obj2bin {
  985. my %args = @_;
  986. my $bin = platform->bin($args{bin});
  987. my $binname = platform->binname($args{bin});
  988. my @objs = map { platform->convertext($_) }
  989. grep { platform->isobj($_) }
  990. @{$args{objs}};
  991. my $objs = join(",", @objs);
  992. my @deps = compute_lib_depends(@{$args{deps}});
  993. my $deps = join(", -\n\t\t", @objs, map { $_->{lib} } @deps);
  994. my $olb_count = scalar grep(m|\.OLB$|, map { $_->{lib} } @deps);
  995. my $analyse_objs = "@ !";
  996. if ($olb_count > 0) {
  997. my $analyse_quals =
  998. $config{target} =~ m|alpha| ? "/GSD" : "/SECTIONS=SYMTAB";
  999. $analyse_objs = "- pipe ANALYSE/OBJECT$analyse_quals $objs | SEARCH SYS\$INPUT \"\"\"main\"\"\" ; nomain = \$severity .NE. 1"
  1000. }
  1001. # The "[]" hack is because in .OPT files, each line inherits the
  1002. # previous line's file spec as default, so if no directory spec
  1003. # is present in the current line and the previous line has one that
  1004. # doesn't apply, you're in for a surprise.
  1005. my $write_opt1 =
  1006. join(",-\"\n\t", map { my $x = $_ =~ /\[/ ? $_ : "[]".$_;
  1007. "\@ WRITE OPT_FILE \"$x" } @objs).
  1008. "\"";
  1009. my $write_opt2 =
  1010. join("\n\t", "WRITE OPT_FILE \"CASE_SENSITIVE=YES\"",
  1011. map { my @lines = ();
  1012. use Data::Dumper;
  1013. my $x = $_->{lib} =~ /\[/
  1014. ? $_->{lib} : "[]".$_->{lib};
  1015. if ($x =~ m|\.EXE$|) {
  1016. push @lines, "\@ WRITE OPT_FILE \"$x/SHARE\"";
  1017. } elsif ($x =~ m|\.OLB$|) {
  1018. # Special hack to include the MAIN object
  1019. # module explicitly. This will only be done
  1020. # if there isn't a 'main' in the program's
  1021. # object modules already.
  1022. my $main = $_->{attrs}->{has_main}
  1023. ? '/INCLUDE=main' : '';
  1024. push @lines,
  1025. "\@ IF nomain THEN WRITE OPT_FILE \"$x/LIB$main\"",
  1026. "\@ IF .NOT. nomain THEN WRITE OPT_FILE \"$x/LIB\""
  1027. }
  1028. @lines
  1029. } @deps)
  1030. || "\@ !";
  1031. # The linking commands looks a bit complex, but it's for good reason.
  1032. # When you link, say, foo.obj, bar.obj and libsomething.exe/share, and
  1033. # bar.obj happens to have a symbol that also exists in libsomething.exe,
  1034. # the linker will warn about it, loudly, and will then choose to pick
  1035. # the first copy encountered (the one in bar.obj in this example).
  1036. # On Unix and on Windows, the corresponding maneuvre goes through
  1037. # silently with the same effect.
  1038. # With some test programs, made for checking the internals of OpenSSL,
  1039. # we do this kind of linking deliberately, picking a few specific object
  1040. # files from within [.crypto] or [.ssl] so we can reach symbols that are
  1041. # otherwise unreachable (since the shareable images only exports the
  1042. # symbols listed in [.util]*.num), and then with the shared libraries
  1043. # themselves. So we need to silence the warning about multiply defined
  1044. # symbols, to mimic the way linking work on Unix and Windows, and so
  1045. # the build isn't interrupted (MMS stops when warnings are signaled,
  1046. # by default), and so someone building doesn't have to worry where it
  1047. # isn't necessary. If there are other warnings, however, we show them
  1048. # and let it break the build.
  1049. return <<"EOF"
  1050. $bin : $deps
  1051. $analyse_objs
  1052. @ OPEN/WRITE/SHARE=READ OPT_FILE $binname.OPT
  1053. $write_opt1
  1054. $write_opt2
  1055. @ CLOSE OPT_FILE
  1056. TYPE $binname.OPT ! For debugging
  1057. - pipe SPAWN/WAIT/NOLOG/OUT=$binname.LINKLOG -
  1058. LINK \$(BIN_LDFLAGS)/EXEC=\$\@ $binname.OPT/OPT \$(BIN_EX_LIBS) ; -
  1059. link_status = \$status ; link_severity = link_status .AND. 7
  1060. @ search_severity = 1
  1061. -@ IF link_severity .EQ. 0 THEN -
  1062. pipe SEARCH $binname.LINKLOG "%","-"/MATCH=AND | -
  1063. SPAWN/WAIT/NOLOG/OUT=NLA0: -
  1064. SEARCH SYS\$INPUT: "-W-MULDEF,"/MATCH=NOR ; -
  1065. search_severity = \$severity
  1066. @ ! search_severity is 3 when the last search didn't find any matching
  1067. @ ! string: %SEARCH-I-NOMATCHES, no strings matched
  1068. @ ! If that was the result, we pretend linking got through without
  1069. @ ! fault or warning.
  1070. @ IF search_severity .EQ. 3 THEN link_severity = 1
  1071. @ ! At this point, if link_severity shows that there was a fault
  1072. @ ! or warning, make sure to restore the linking status.
  1073. -@ IF .NOT. link_severity THEN TYPE $binname.LINKLOG
  1074. -@ DELETE $binname.LINKLOG;*
  1075. @ IF .NOT. link_severity THEN SPAWN/WAIT/NOLOG EXIT 'link_status'
  1076. - PURGE $bin,$binname.OPT
  1077. EOF
  1078. . ($config{target} =~ m|alpha| ? "" : <<"EOF"
  1079. SET IMAGE/FLAGS=(NOCALL_DEBUG) \$\@
  1080. EOF
  1081. );
  1082. }
  1083. sub in2script {
  1084. my %args = @_;
  1085. my $script = $args{script};
  1086. return "" if grep { $_ eq $script } @{$args{sources}}; # No overwrite!
  1087. my $sources = join(" ", @{$args{sources}});
  1088. my $dofile = abs2rel(rel2abs(catfile($config{sourcedir},
  1089. "util", "dofile.pl")),
  1090. rel2abs($config{builddir}));
  1091. return <<"EOF";
  1092. $script : $sources
  1093. \$(PERL) "-I\$(BLDDIR)" "-Mconfigdata" $dofile -
  1094. "-o$target{build_file}" $sources > $script
  1095. SET FILE/PROT=(S:RWED,O:RWED,G:RE,W:RE) $script
  1096. PURGE $script
  1097. EOF
  1098. }
  1099. "" # Important! This becomes part of the template result.
  1100. -}