descrip.mms.tmpl 49 KB

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