home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / fchek284.zip / cc.com < prev    next >
Text File  |  1994-10-10  |  2KB  |  55 lines

  1. $! name: CC.COM
  2. $! author: R. Moniot
  3. $! date: 14-Apr-87
  4. $! purpose: bring C object module up to date with its source.
  5. $! usage:  @CC PROG DEPENDENCIES [/CFLAGS...]
  6. $!        Where PROG is source filename (OMIT extension .C), and
  7. $!        DEPENDENCIES is comma-separated list (possibly null) of
  8. $!        files (WITH their extensions) on which PROG depends, other
  9. $!        than the source file.  Optional compiler flags must come
  10. $!        last.
  11. $!
  12. $!    Look for .C file and .OBJ file, and do the right things.
  13. $!
  14. $ dependency = p1 + ".C"
  15. $ if f$search(dependency) .eqs. "" then goto NoSuchFile
  16. $ if f$search(p1 + ".OBJ") .eqs. "" then goto Compile
  17. $!
  18. $!    If both exist, look at creation dates to see if compilation needed
  19. $!
  20. $ srcdate = f$cvtime(f$file_attributes(p1+".C","cdt"))
  21. $ objdate = f$cvtime(f$file_attributes(p1+".OBJ","cdt")) 
  22. $ if objdate .lts. srcdate then goto Compile
  23. $!
  24. $!  check dependencies.  rest holds remainder of string.
  25. $    rest = p2
  26. $ Loop:
  27. $    len = f$length(rest)
  28. $    pos = f$locate(",",rest)
  29. $    dependency = f$extract(0,pos,rest)
  30. $    if dependency .eqs. "" then goto Exit
  31. $    if f$search(dependency) .eqs. "" then goto NoSuchFile
  32. $    depdate = f$cvtime(f$file_attributes(dependency,"cdt"))
  33. $    if objdate .lts. depdate then goto Compile
  34. $    if pos .eq. len then goto Exit
  35. $    rest = f$extract(pos+1,len-pos-1,rest)
  36. $ goto Loop
  37. $!
  38. $!    Object does not exist or is older than source: recompile
  39. $!
  40. $ Compile:
  41. $    write sys$output "CC " + p1+" "+p3+p4+p5+p6+p7+p8
  42. $    cc 'p1' 'p3' 'p4' 'p5' 'p6' 'p7' 'p8'
  43. $    exit
  44. $!
  45. $!    Source is older than object: all is OK
  46. $!
  47. $ Exit:
  48. $    write sys$output p1 + ".OBJ is up to date."
  49. $    exit
  50. $!
  51. $ NoSuchFile:
  52. $    write sys$output dependency + " does not exist"
  53. $! exit, and return control to command level
  54. $    stop
  55.