home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume12 / cake / part06 / Lib / Main < prev    next >
Encoding:
Text File  |  1987-10-15  |  3.1 KB  |  123 lines

  1. $    Cakefile to handle programs.
  2.  
  3. $    Using Main is appropriate if a directory contains the sources
  4. $    for a single binary; if the number of binaries is greater than
  5. $    one, you should use the cakefile System. Main (and System) can
  6. $    handle programs written in any language, as long as the cakefile
  7. $    for that language defines the macros expected by Main. These
  8. $    macros are LINK_CMD, SRCSUFF, OBJSUFF and SUFFIXLIST. Currently
  9. $    there exist cakefiles for C and NU-Prolog. These cakefile should
  10. $    be included before Main.
  11.  
  12. $    You should define the macro FILES to contain the list of source
  13. $    files WITHOUT their suffix, and optionally MAIN as the name of
  14. $    the binary (default: the name of the first file in FILES).
  15. $    With these defined, you can make the targets MAIN (link the
  16. $    object files), print (print all sources), uprint (print those
  17. $    sources which were modified after the last printing), count
  18. $    (run wc on all sources), ssize (sort the output of wc),
  19. $    clean (remove generated files) and clobber (remove generated
  20. $    files and the binary). Printing is done by PRINT_CMD if
  21. $    defined, lpr -p otherwise; removal is done by RM_CMD if
  22. $    defined, rmv otherwise (rmv copies its args to /tmp).
  23.  
  24. $    You may define DEST as the name of an installation directory
  25. $    or HOME as where HOME/bin is the installation directory,
  26. $    and you can invoke the target install to do the installation
  27. $    (using INST_CMD if defined, cp otherwise). You may define
  28. $    LIB as a list of libraries to pass on to LINK and CHECK CMDs.
  29.  
  30. $    The rules for the targets lint, tags and defs depend on
  31. $    values for the macros CHECK_CMD, TAGS_CMD and DEFS_CMD,
  32. $    which should be language-specific utilities; the macros
  33. $    should be defined in the language's cakefile.
  34.  
  35. #ifndef    FILES
  36.     it's no use trying to use Main without defining FILES
  37. #endif
  38. #ifndef    LINK_CMD
  39.     it's no use trying to use Main without defining LINK_CMD
  40. #endif
  41. #ifndef    SRCSUFF
  42.     it's no use trying to use Main without defining SRCSUFF
  43. #endif
  44. #ifndef    OBJSUFF
  45.     it's no use trying to use Main without defining OBJSUFF
  46. #endif
  47. #ifndef    SUFFIXLIST
  48.     it's no use trying to use Main without defining SUFFIXLIST
  49. #endif
  50.  
  51. #ifndef    PRINT_CMD
  52. #define    PRINT_CMD    lpr -p
  53. #endif
  54. #ifndef    INST_CMD
  55. #define    INST_CMD    cp
  56. #endif
  57. #ifndef    RM_CMD
  58. #define    RM_CMD        rmv
  59. #endif
  60.  
  61. #ifndef    MAIN
  62. #define    MAIN        [[echo FILES | awk '{ print $1; }']]
  63. #endif
  64. #ifndef    LIB
  65. #define    LIB
  66. #endif
  67.  
  68. #define    SRC    [[sub X X''SRCSUFF FILES]]
  69. #define    OBJ    [[sub X X''OBJSUFF FILES]]
  70.  
  71. %::        OBJ            if % in MAIN
  72.         LINK_CMD OBJ LIB
  73.  
  74. #ifdef    DEST
  75. install&:    MAIN
  76.         INST_CMD MAIN DEST
  77. #else
  78. #ifdef    HOME
  79. install&:    MAIN
  80.         INST_CMD MAIN HOME/bin
  81. #endif
  82. #endif
  83.  
  84. #ifdef    CHECK_CMD
  85. #ifdef    IRREL
  86. lint&:        SRC
  87.         CHECK_CMD SRC LIB |& irrel IRREL
  88. #else
  89. lint&:        SRC
  90.         CHECK_CMD SRC LIB
  91. #endif
  92. #endif
  93.  
  94. print&:
  95.         PRINT_CMD [[usrc SUFFIXLIST FILES]]
  96.         @-touch .print
  97.  
  98. uprint&:
  99.         PRINT_CMD [[later .print [[usrc SUFFIXLIST FILES]]]]
  100.         @-touch .print
  101.  
  102. #ifdef    TAGS_CMD
  103. tags:        SRC
  104.         TAGS_CMD SRC
  105. #endif
  106.  
  107. #ifdef    DEFS_CMD
  108. defs:        SRC
  109.         DEFS_CMD SRC
  110. #endif
  111.  
  112. count&:
  113.         wc -v [[usrc SUFFIXLIST FILES]]
  114.  
  115. ssize&:
  116.         ssize [[usrc SUFFIXLIST FILES]]
  117.  
  118. clean&:
  119.         RM_CMD OBJ [[gsrc SUFFIXLIST FILES]]
  120.  
  121. clobber&:    clean
  122.         RM_CMD MAIN
  123.