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

  1. $    Cakefile to handle programs.
  2.  
  3. $    Using System is appropriate if a directory contains the sources
  4. $    for more than one binary; if the number of binaries is one,
  5. $    you should use the cakefile Main. System (and Main) can handle
  6. $    programs written in any language, as long as the cakefile
  7. $    for that language defines the macros expected by System. 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 System.
  11.  
  12. $    System is intended to behave like Main; for basic documentation
  13. $    see Main. The difference is that whereas the configuration of
  14. $    a program can be given to Main as a single macro (FILES), a
  15. $    file is needed to convey it to System. This file is named by the
  16. $    macro CONF (default Conf). Each line of this file has on it
  17. $    first, the name of the binary, second, a list of the names
  18. $    of the sourcefiles that make up this binary (the source names
  19. $    should not have the language-specific suffix; i.e. you should
  20. $    strip the .c from the names of C source files).
  21.  
  22. $    The target available with System are much the same as with Main.
  23. $    The difference is that they are available in two versions.
  24. $    When they are prefixed by the name of a binary, they apply
  25. $    only to that binary; when they are not prefixed, they apply
  26. $    to all binaries. For example, cake bin.lint runs CHECK_CMD on
  27. $    the sources for the binary bin, while cake lint runs it on
  28. $    the sources for all the binaries, using one run of CHECK_CMD
  29. $    per binary.
  30.  
  31. #ifndef    PRINT_CMD
  32. #define    PRINT_CMD    lpr -p
  33. #endif
  34. #ifndef    INST_CMD
  35. #define    INST_CMD    cp
  36. #endif
  37. #ifndef    RM_CMD
  38. #define    RM_CMD        rmv
  39. #endif
  40.  
  41. #ifndef    LIB
  42. #define    LIB
  43. #endif
  44.  
  45. #ifndef    CONF
  46. #define    CONF        Conf
  47. #endif
  48.  
  49. #define    MAINS        [[mainfile "" CONF]]
  50. #define    FILES(x)    [[extract x "" CONF]]
  51. #define    SRC(x)        [[extract x SRCSUFF CONF]]
  52. #define    OBJ(x)        [[extract x OBJSUFF CONF]]
  53. #define    ALLFILES    [[extract "" "" CONF | sort -u]]
  54. #define    ALLSRC        [[extract "" SRCSUFF CONF | sort -u]]
  55. #define    ALLOBJ        [[extract "" OBJSUFF CONF | sort -u]]
  56.  
  57. xyzzy&::    MAINS
  58.  
  59. %:        OBJ(%)            if % in MAINS
  60.         LINK_CMD OBJ(%) LIB
  61.  
  62. #ifdef    DEST
  63. %.install&:    %            if % in MAINS
  64.         INST_CMD % DEST
  65. #else
  66. #ifdef    HOME
  67. %.install&:    %            if % in MAINS
  68.         INST_CMD % HOME/bin
  69. #else
  70. #define    NOINSTALL
  71. #endif
  72. #endif
  73.  
  74. #ifndef    NOINSTALL
  75. install&:    [[mainfile .install CONF]]
  76. #endif
  77.  
  78. #ifdef    CHECK_CMD
  79. #ifdef    IRREL
  80. %.lint&:    SRC(%)            if % in MAINS
  81.         CHECK_CMD SRC(%) LIB |& irrel IRREL
  82. #else
  83. %.lint&:    SRC(%)            if % in MAINS
  84.         CHECK_CMD SRC(%) LIB
  85. #endif
  86.  
  87. lint&:        [[mainfile .lint CONF]]
  88. #endif
  89.  
  90. %.print&:                if % in MAINS
  91.         PRINT_CMD [[usrc SUFFIXLIST FILES(%)]]
  92.         @-touch .print.%
  93.  
  94. %.uprint&:                if % in MAINS
  95.         PRINT_CMD [[later .print.% [[usrc SUFFIXLIST FILES(%)]]]]
  96.         @-touch .print.%
  97.  
  98. print&:
  99.         PRINT_CMD [[usrc SUFFIXLIST ALLFILES]]
  100.         @-touch .print
  101.  
  102. uprint&:
  103.         PRINT_CMD [[later .print [[usrc SUFFIXLIST ALLFILES]]]]
  104.         @-touch .print
  105.  
  106. #ifdef    TAGS_CMD
  107. tags:        ALLSRC
  108.         TAGS_CMD ALLSRC
  109. #endif
  110.  
  111. #ifdef    DEFS_CMD
  112. defs:        ALLSRC
  113.         DEFS_CMD ALLSRC > defs
  114. #endif
  115.  
  116. %.count&:                if % in MAINS
  117.         wc -v [[usrc SUFFIXLIST FILES(%)]]
  118.  
  119. %.ssize&:                if % in MAINS
  120.         ssize [[usrc SUFFIXLIST FILES(%)]]
  121.  
  122. count&:
  123.         wc -v [[usrc SUFFIXLIST ALLFILES]]
  124.  
  125. ssize&:
  126.         ssize [[usrc SUFFIXLIST ALLFILES]]
  127.  
  128. %.clean&:                if % in MAINS
  129.         RM_CMD OBJ(%) [[gsrc SUFFIXLIST FILES(%)]]
  130.  
  131. %.clobber&:    %.clean            if % in MAINS
  132.         RM_CMD %
  133.  
  134. clean&:
  135.         RM_CMD ALLOBJ [[gsrc SUFFIXLIST ALLFILES]]
  136.  
  137. clobber&:    clean
  138.         RM_CMD MAINS
  139.