1$!                                              1 December 2006.  SMS.
2$!
3$! Info-ZIP VMS accessory procedure.
4$!
5$!    For the product named by P1,
6$!    collect all source file dependencies specified by P3,
7$!    and add P4 prefix.
8$!    Convert absolute dependencies to relative from one level above P5.
9$!    P2 = output file specification.
10$!
11$! MMS /EXTENDED_SYNTAX can't easily pass a macro invocation for P4, so
12$! we remove any internal spaces which might have been added to prevent
13$! immediate evaluation of a macro invocation.
14$!
15$ prefix = f$edit( p4, "COLLAPSE")
16$!
17$ dev_lose = f$edit( f$parse( p5, , , "DEVICE", "SYNTAX_ONLY"), "UPCASE")
18$ dir_lose = f$edit( f$parse( p5, , , "DIRECTORY", "SYNTAX_ONLY"), "UPCASE")
19$ suffix = ".VMS]"
20$ suffix_loc = f$locate( suffix, dir_lose)
21$ if (suffix_loc .lt f$length( dir_lose))
22$ then
23$    dev_dir_lose = dev_lose+ dir_lose- suffix
24$ else
25$    dev_dir_lose = dev_lose+ dir_lose- "]"
26$ endif
27$!
28$! For portability, make the output file record format Stream_LF.
29$!
30$ create /fdl = sys$input 'p2'
31RECORD
32        Carriage_Control carriage_return
33        Format stream_lf
34$!
35$ open /read /write /error = end_main deps_out 'p2'
36$ on error then goto loop_main_end
37$!
38$! Include proper-inclusion-check preface.
39$!
40$ incl_macro = "INCL_"+ f$parse( p2, , , "NAME", "SYNTAX_ONLY")
41$ write deps_out "#"
42$ write deps_out "# ''p1' for VMS - MMS (or MMK) Source Dependency File."
43$ write deps_out "#"
44$ write deps_out ""
45$ write deps_out -
46   "# This description file is included by other description files.  It is"
47$ write deps_out -
48   "# not intended to be used alone.  Verify proper inclusion."
49$ write deps_out ""
50$ write deps_out ".IFDEF ''incl_macro'"
51$ write deps_out ".ELSE"
52$ write deps_out -
53   "$$$$ THIS DESCRIPTION FILE IS NOT INTENDED TO BE USED THIS WAY."
54$ write deps_out ".ENDIF"
55$ write deps_out ""
56$!
57$! Actual dependencies from individual dependency files.
58$!
59$ loop_main_top:
60$    file = f$search( p3)
61$    if (file .eqs. "") then goto loop_main_end
62$!
63$    open /read /error = end_subs deps_in 'file'
64$    loop_subs_top:
65$       read /error = loop_subs_end deps_in line
66$       line_reduced = f$edit( line, "COMPRESS, TRIM, UPCASE")
67$       colon = f$locate( " : ", line_reduced)
68$       d_d_l_loc = f$locate( dev_dir_lose, -
69         f$extract( (colon+ 3), 1000, line_reduced))
70$       if (d_d_l_loc .eq. 0)
71$       then
72$          front = f$extract( 0, (colon+ 3), line_reduced)
73$          back = f$extract( (colon+ 3+ f$length( dev_dir_lose)), -
74            1000, line_reduced)
75$          line = front+ "["+ back
76$       endif
77$       write deps_out "''prefix'"+ "''line'"
78$    goto loop_subs_top
79$!
80$    loop_subs_end:
81$    close deps_in
82$!
83$ goto loop_main_top
84$!
85$ loop_main_end:
86$ close deps_out
87$!
88$ end_main:
89$!
90