descrip.mms.tmpl 49 KB

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