]> sjero.net Git - wget/blob - vms/COLLECT_DEPS.COM
Fix build when libpsl is not available
[wget] / vms / COLLECT_DEPS.COM
1 $!                                              5 December 2006.  SMS.
2 $!
3 $! Common VMS accessory procedure.
4 $!
5 $!    For the product named by P1,
6 $!    P2 = output file specification.
7 $!    Collect all source file dependencies specified by P3,
8 $!    and add P4 prefix to the object file.
9 $!    Convert absolute dependencies to relative from one level above P5,
10 $!    and add P6 prefix (typically a rooted logical name with ":[").
11 $!    Convert "[.P7]" to "[.P4]" in dependencies.
12 $!
13 $! MMS /EXTENDED_SYNTAX can't easily pass a macro invocation for P4, so
14 $! we remove any internal spaces which might have been added to prevent
15 $! immediate evaluation of such a macro invocation.
16 $!
17 $ prefix = f$edit( p4, "COLLAPSE")
18 $ here = f$environment( "DEFAULT")
19 $ dev_lose = f$edit( f$parse( p5, , , "DEVICE", "SYNTAX_ONLY"), "UPCASE")
20 $ dir_lose = f$edit( f$parse( p5, , , "DIRECTORY", "SYNTAX_ONLY"), "UPCASE")
21 $ set default 'dev_lose''dir_lose'
22 $ set default [-]
23 $ dev_dir_lose = f$environment( "DEFAULT")- "]"
24 $!
25 $ p6_last = f$extract( (f$length( p6)- 1), 1, p6)
26 $!
27 $ dest = ""
28 $ if (p7 .nes. "")
29 $ then
30 $    dest = ".''p7']"
31 $ endif
32 $!
33 $ set default 'here'
34 $!
35 $! For portability, make the output file record format Stream_LF.
36 $!
37 $ create /fdl = sys$input 'p2'
38 RECORD
39         Carriage_Control carriage_return
40         Format stream_lf
41 $!
42 $ open /read /write /error = end_main deps_out 'p2'
43 $ on error then goto loop_main_end
44 $!
45 $! Include proper-inclusion-check preface.
46 $!
47 $ incl_macro = "INCL_"+ f$parse( p2, , , "NAME", "SYNTAX_ONLY")
48 $ write deps_out "#"
49 $ write deps_out "# ''p1' - MMS (or MMK) Source Dependency File."
50 $ write deps_out "#"
51 $ write deps_out ""
52 $ write deps_out -
53    "# This description file is included by other description files.  It is"
54 $ write deps_out -
55    "# not intended to be used alone.  Verify proper inclusion."
56 $ write deps_out ""
57 $ write deps_out ".IFDEF ''incl_macro'"
58 $ write deps_out ".ELSE"
59 $ write deps_out -
60    "$$$$ THIS DESCRIPTION FILE IS NOT INTENDED TO BE USED THIS WAY."
61 $ write deps_out ".ENDIF"
62 $ write deps_out ""
63 $!
64 $! Actual dependencies from individual dependency files.
65 $!
66 $ loop_main_top:
67 $    file = f$search( p3)
68 $    if (file .eqs. "") then goto loop_main_end
69 $!
70 $    open /read /error = end_subs deps_in 'file'
71 $    loop_subs_top:
72 $       read /error = loop_subs_end deps_in line
73 $       line_reduced = f$edit( line, "COMPRESS, TRIM, UPCASE")
74 $       colon = f$locate( " : ", line_reduced)
75 $       if (colon .ge. f$length( line_reduced)) then goto loop_subs_top
76 $       d_d_l_loc = f$locate( dev_dir_lose, -
77          f$extract( (colon+ 3), 1000, line_reduced))
78 $       if (d_d_l_loc .eq. 0)
79 $       then
80 $          front = f$extract( 0, (colon+ 3), line_reduced)
81 $          back = f$extract( (colon+ 3+ f$length( dev_dir_lose)+ 1), -
82             1000, line_reduced)
83 $!
84 $!         If specified, replace final ".P7]" with part of P4.
85 $!
86 $!         This allows a system-specific subdirectory name on a
87 $!         dependency file to be replaced with an MMS macro, for
88 $!         example, ".ALPHA]" with ".$(DEST)]".
89 $!
90 $          if (dest .nes. "")
91 $          then
92 $             dest_dot_loc = f$locate( dest, back)
93 $             if (dest_dot_loc .lt. f$length( back))
94 $             then
95 $                back = f$extract( 0, dest_dot_loc, back)+ -
96                   f$extract( 1, 1000, prefix)+ -
97                   f$extract( (dest_dot_loc+ f$length( dest)), 1000, back)
98 $             endif
99 $          endif
100 $!
101 $!         Replace null subdirectory with "000000".
102 $!
103 $          if (f$length( back) .gt. 0)
104 $          then
105 $             mid = p6
106 $          else
107 $             mid = "000000]"
108 $          endif
109 $!
110 $          line = front+ mid+ back
111 $          write deps_out "''prefix'"+ "''line'"
112 $       endif
113 $    goto loop_subs_top
114 $!
115 $    loop_subs_end:
116 $    close deps_in
117 $!
118 $ goto loop_main_top
119 $!
120 $ loop_main_end:
121 $ close deps_out
122 $!
123 $ end_main:
124 $!