?section CC ROUTINE
#FRAME
[#PUSH stem src obj htime file prev time stime otime
       comp out options sup buf col locn group
]

[#IF [#ARGUMENT /VALUE src/ WORD /SPACE/ END]]
[#IF [#EMPTYV src] |THEN|
  #OUTPUT Syntax: CC <file> <collector> <comp-options>
  #RESET FRAMES
  #RETURN
]

[#IF NOT [#FILEINFO /EXISTENCE/ [src]]
|THEN|
  #OUTPUT [src] does not exist !
  #RESET FRAMES
  #RETURN
]

#SETV stem src
#CHARDEL stem [#CHARCOUNT stem]
#SET obj [stem]O

[#IF [#ARGUMENT /VALUE out/ DEVICE END]]
[#IF [#EMPTYV out] |THEN| #SET out $T.#C]

#SETMANY col group, [#FILEINFO /VOLUME, SUBVOL/ [out]]
#SET locn [group].[stem]
#SET sup [#LOOKUPPROCESS /ANCESTOR/ [col]]


#SET options [#REST]

== Find newest Header file
#SET htime 0
#SET file [#FILENAMES /MAXIMUM 1/ *H]
[#LOOP |WHILE| NOT [#EMPTYV file]
|DO|
  #SET time [#FILEINFO /MODIFICATION/ [file]]
  [#IF time > htime |THEN| #SETV htime time]

  #SETV prev file
  #SET file [#FILENAMES /MAXIMUM 1, PREVIOUS [prev]/ *H]
]

#SET stime [#FILEINFO /MODIFICATION/ [src]]
#SET otime [#FILEINFO /MODIFICATION/ [obj]]

#SET comp 0

[#IF otime < htime
|THEN|
  #OUTPUT Header file(s) changed since object [obj] compiled
  #SET comp -1
]

[#IF otime < stime
|THEN|
  #OUTPUT Source file [src] changed since object [obj] compiled
  #SET comp -1
]

[#IF comp
|THEN|
  SPOOLCOM /OUTV buf/ OPEN [sup];JOB (OWNER, LOC [locn]),STATUS,DELETE !
  #OUTPUTV buf
  #OUTPUT Compiling [src]... [options]
  C /IN [src], OUT [out].[stem]/[obj];SYMBOLS,HIGHPIN [options]
  [#CASE [tacl^completioncode]
  | 0 |
    #OUTPUT Compiled OK: [src]
    SPOOLCOM /OUTV buf/ OPEN [sup];JOB (OWNER, LOC [locn]),STATUS,DELETE !
    #SET _completion:completioncode 0
  | 1 |
    #OUTPUT [src]: Compile Warnings
  |OTHERWISE|
    #OUTPUT [src]: Compile FAILED !
  ]
|ELSE|
  #OUTPUT Object file [obj] is up to date
  #SET _completion:completioncode 0
]

#UNFRAME
