The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
/* MAKECPIP EXEC      Make program to build a C/370 module           */
/*                    Author: George Petrov, 29 Sep 1994             */

arg fn . '(' cparms                   /* Filter name                 */
'pipe (end ?) < 'fn' makefile',       /* get all source files from   */
    '| frlab GLOBALS:'||,
    '| drop',
    '| strip',
    '| var globals'
cparms = cparms globals
say ''
say 'Compile options : 'cparms
say ''
if pos('REB',cparms) > 0 then do
parse var cparms cp1 'REB' . ' ' cp2  /* REBuild options specified ? */
cparms = cp1||cp2
pipe1=,
'pipe (end ?) < 'fn' makefile',       /* get all source files from   */
    '| nfind *'||,                    /* the makefile and compile    */
    '| frlab TEXT:'||,                /* only the those who are      */
    '| r: tolab MODULE:'||,           /* changed or never compiled   */
    '| drop',
    '| o: fanout',
    '| chop before str /(/',
    '| statew',
    '| c: fanout',                    /* compiled                    */
    '| specs /Compiling / 1 w1-3 n / .../ n',
    '| cons'
end
else do
pipe1=,
'pipe (end ?) < 'fn' makefile',       /* get all source files from   */
    '| nfind *'||,                    /* the makefile and compile    */
    '| frlab TEXT:'||,                /* only the those who are      */
    '| r: tolab MODULE:'||,           /* changed or never compiled   */
    '| drop',
    '| o: fanout',
    '| specs w1 1 /C/ nw w3 nw write w1 1 /TEXT A/ nw',
    '| chop before str /(/',
    '| statew',
    '| change (57 66) / /0/',
    '| sort 1.8 d',                  /* sort the date and time      */
    '| uniq 1-17 singles',           /* if the first is a source    */
    '| sort 1.8 d 64.2 d 57.2 d 60.2 d 66.8 d',    /* sort the date */
    '| uniq 1-8 first',          /*    if the first is a source    */
    '| locate 9.8 /C      /',         /* program then it has to be   */
    '| c: fanout',                    /* compiled                    */
    '| specs /Compiling / 1 w1-3 n / .../ n',
    '| cons'
end
pipe2= '?',
    'r:',
    '| drop',
    '| specs w1 1',                 /* save the module name in var  */
    '| var module',
    '?',
    'o:',
    '| specs w1 1',
    '| join * / /',
    '| var texts',                  /* save all the text file names */
    '?',                            /* for later include            */
    'c:',
    '| specs /CC / 1 w1-3 n /(NOTERM 'cparms'/ nw',   /* compile! */
    '| err: cms | cons',
    '?',
    'err:',
    '| nfind 0'||,
    '| var err',
    '| specs /----> Errors found! RC=/ 1 1-* n',
    '| cons'
/*  '| g: gate'*/
pipe1 pipe2
say ''
if symbol('err') = 'VAR' & err ^= 0 then do
      say 'Errors found in source files - link aborted! RC = 'err
      exit err
end
say 'Generating module 'module
'pipe cms cmod' fn texts' | > 'fn' LINK A'
exit rc
error:
say 'Error in REXX detected!'
Say 'Syntax error on line' Sigl':' Sourceline(Sigl)
Say 'Error was:' Errortext(RC)
return rc