descrip.mms.tmpl 50 KB

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