1/* MAKECPIP EXEC      Make program to build a C/370 module           */
2/*                    Author: George Petrov, 29 Sep 1994             */
3
4arg fn . '(' cparms                   /* Filter name                 */
5'pipe (end ?) < 'fn' makefile',       /* get all source files from   */
6    '| frlab GLOBALS:'||,
7    '| drop',
8    '| strip',
9    '| var globals'
10cparms = cparms globals
11say ''
12say 'Compile options : 'cparms
13say ''
14if pos('REB',cparms) > 0 then do
15parse var cparms cp1 'REB' . ' ' cp2  /* REBuild options specified ? */
16cparms = cp1||cp2
17pipe1=,
18'pipe (end ?) < 'fn' makefile',       /* get all source files from   */
19    '| nfind *'||,                    /* the makefile and compile    */
20    '| frlab TEXT:'||,                /* only the those who are      */
21    '| r: tolab MODULE:'||,           /* changed or never compiled   */
22    '| drop',
23    '| o: fanout',
24    '| chop before str /(/',
25    '| statew',
26    '| c: fanout',                    /* compiled                    */
27    '| specs /Compiling / 1 w1-3 n / .../ n',
28    '| cons'
29end
30else do
31pipe1=,
32'pipe (end ?) < 'fn' makefile',       /* get all source files from   */
33    '| nfind *'||,                    /* the makefile and compile    */
34    '| frlab TEXT:'||,                /* only the those who are      */
35    '| r: tolab MODULE:'||,           /* changed or never compiled   */
36    '| drop',
37    '| o: fanout',
38    '| specs w1 1 /C/ nw w3 nw write w1 1 /TEXT A/ nw',
39    '| chop before str /(/',
40    '| statew',
41    '| change (57 66) / /0/',
42    '| sort 1.8 d',                  /* sort the date and time      */
43    '| uniq 1-17 singles',           /* if the first is a source    */
44    '| sort 1.8 d 64.2 d 57.2 d 60.2 d 66.8 d',    /* sort the date */
45    '| uniq 1-8 first',          /*    if the first is a source    */
46    '| locate 9.8 /C      /',         /* program then it has to be   */
47    '| c: fanout',                    /* compiled                    */
48    '| specs /Compiling / 1 w1-3 n / .../ n',
49    '| cons'
50end
51pipe2= '?',
52    'r:',
53    '| drop',
54    '| specs w1 1',                 /* save the module name in var  */
55    '| var module',
56    '?',
57    'o:',
58    '| specs w1 1',
59    '| join * / /',
60    '| var texts',                  /* save all the text file names */
61    '?',                            /* for later include            */
62    'c:',
63    '| specs /CC / 1 w1-3 n /(NOTERM 'cparms'/ nw',   /* compile! */
64    '| err: cms | cons',
65    '?',
66    'err:',
67    '| strip both',
68    '| nfind 0'||,
69    '| var err',
70    '| specs /----> Errors found! RC=/ 1 1-* n',
71    '| cons'
72/*  '| g: gate'*/
73pipe1 pipe2
74say ''
75if symbol('err') = 'VAR' & err ^= 0 then do
76      say 'Errors found in source files - link aborted! RC = 'err
77      exit err
78end
79say 'Generating module 'module
80'pipe cms cmod' fn texts' DMSCSL | > 'fn' LINK A'
81'set cmstype ht'
82'state 'fn' LINK A'
83rcc = rc
84'set cmstype rt'
85if rcc = 0 then do
86   say ''
87   say 'ERRORS discovered during linking!'
88   say 'See: 'fn' LINK A for more info'
89end
90exit rc
91error:
92say 'Error in REXX detected!'
93Say 'Syntax error on line' Sigl':' Sourceline(Sigl)
94Say 'Error was:' Errortext(RC)
95return rc
96