home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume12 / cake / part01 next >
Encoding:
Internet Message Format  |  1987-10-14  |  42.9 KB

  1. Subject:  v12i007:  Cake, a make replacement, Part01/09
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rs@uunet.UU.NET
  5.  
  6. Submitted-by: Zoltan Somogyi <zs@munnari.oz>
  7. Posting-number: Volume 12, Issue 7
  8. Archive-name: cake/part01
  9.  
  10. Cake is a rewrite of make from the ground up. The main difference is one
  11. of attitude: cake is considerably more general and flexible, and can be
  12. extended and customized by the user to a much greater extent. It is applicable
  13. to a wide range of domains, not just program development: for example, standard
  14. cakefiles exist to handle documents and VLSI designs.
  15.  
  16. The main differences between make and cake:
  17.  
  18. -    Cake dependencies may be dynamic, and their applicability may be
  19.     conditional upon a test.
  20.  
  21. -    Cake rules have the same syntax and semantics as ordinary dependencies,
  22.     and may more than one target.
  23.  
  24. -    There are no restrictions on the forms of either the targets or the
  25.     sources. This enables cake to handle files in more than one directory
  26.     and to interface with SCCS, RCS and archivers, among others, without
  27.     any special arrangements.
  28.  
  29. -    Cake has a more general search algorithm than make. When seeking a
  30.     target it considers all rules which could update it even if the
  31.     corresponding intermediate files do not exist; it recreates them
  32.     if (and only if) it is necessary to do so.
  33.  
  34. -    Cakefiles are passed through the C preprocessor. They may therefore
  35.     #include other cakefiles (including standard ones) and use #if and
  36.     #ifdef to customize themselves.
  37.  
  38. -    Cake allows the user to choose his own shell, and to include shell
  39.     scripts in actions.
  40.  
  41. -    Cake can check to see if a newly 'updated' file has actually been
  42.     changed via a byte-by-byte comparison, which works even if the modify
  43.     date has been touched. If there is no change, cake avoids recomputing
  44.     the file's dependents.
  45.  
  46. -    Cake has a lot more options (whether one considers these an improvement
  47.     of course depends on whether one needs them).
  48.  
  49. Cake is not backwards-compatible with make.
  50.  
  51. The copyright on cake is derived from GNU Emacs.
  52.  
  53. The following files are shar files. To extract their contents, give them
  54. to /bin/sh as input. Some of them should be put in different directories,
  55. according to the map below:
  56.  
  57. Part01        .
  58. Part02        .
  59. Part03        .
  60. Part04        ./Aux
  61. Part05        ./Lex
  62. Part06        ./Lib
  63. Part07        ./Man
  64. Part08        ./Man
  65. Part09        ./Script
  66.  
  67. Some of the programs in Aux and some of the scripts in Script are also usable
  68. independently of cake. For example, the program Aux/subcmd solves the consistent
  69. renaming problem (e.g. how to move x to .x, y to .y z to .z etc in one command),
  70. and the script Script/ol is an outline generator for -me documents.
  71.  
  72. Zoltan Somogyi
  73. Department of Computer Science
  74. University of Melbourne
  75. Parkville, 3052 Victoria, Australia
  76.  
  77. UUCP:    {uunet,mcvax,ukc}!munnari.oz!zs
  78. ARPA:    zs%munnari.oz@uunet.uu.net
  79. CSNET:    zs%munnari.oz@australia
  80.  
  81. #! /bin/sh
  82. # This is a shell archive, meaning:
  83. # 1. Remove everything above the #! /bin/sh line.
  84. # 2. Save the resulting text in a file.
  85. # 3. Execute the file with /bin/sh (not csh) to create:
  86. #    README
  87. #    COPYING
  88. #    Makefile
  89. #    cake.h
  90. #    cake_g.y
  91. #    cake_s.l
  92. #    conf.h
  93. #    extern.h
  94. #    list.h
  95. #    macro.h
  96. #    port.h
  97. #    std.h
  98. #    table.h
  99. #    wait.h
  100. # This archive created: Wed Oct 14 21:07:46 1987
  101. export PATH; PATH=/bin:/usr/bin:$PATH
  102. echo shar: "extracting 'README'" '(5454 characters)'
  103. if test -f 'README'
  104. then
  105.     echo shar: "will not over-write existing file 'README'"
  106. else
  107. sed 's/^X//' << \SHAR_EOF > 'README'
  108. XThis is the root directory of the cake distribution.
  109. X
  110. XThis directory contains the sources for the cake command itself.
  111. XIts subdirectories contain sources for commands used by the standard
  112. Xcakefiles (Aux), diffs for a modified version of the lex driver (Lex),
  113. X"standard" cakefiles (Lib), manuals and a paper on cake (Man), and
  114. Xcommands implemented by scripts (Script). Each subdirectory contains
  115. Xits own README file; you should have a look at them. The rest of this
  116. Xfile is just for the cake source.
  117. X
  118. XCake was developed on a 3240 under 4.2BSD Unix, with an early version
  119. Xon a Pyramid 90x (in the Berkeley universe). It has been tested on a
  120. XVAX-11/780 under 4.3BSD, on a Sun under SunOS 3.4, and on an ELXSI 6400
  121. Xunder both 4.2BSD and System V. It should also be portable to other
  122. Xconfigurations. Its parameters are concentrated in the Makefile and
  123. Xin conf.h, but you should have a look at Lex/README *before* you run
  124. X"make install".
  125. X
  126. XMakefile:
  127. X
  128. XThe four make variables you should have a look at and maybe change
  129. Xare DEST, COPTS, CFLAGS, and LDFLAGS. DEST and CFLAGS should be
  130. Xself-explanatory. LDFLAGS as it is just sets the max stack size
  131. Xon the 3240 (a segmented non-paged machine) - on other machines
  132. Xan empy LDFLAGS should do just fine. The macros you can choose from
  133. Xfor COPTS are:
  134. X
  135. XATT is for AT&T variants of Unix. Cake has not been tested extensively
  136. Xfor these, but it has been in use for a while now on an Elxsi 6400 
  137. Xrunning Enix, a System V port. Defining ATT shortens variable names
  138. Xto ensure that all are unique in the first six characters (see port.h)
  139. Xand that no two variable names differ only in case. This effect depends
  140. Xon the C preprocessor being able to handle long case-sensitive variable
  141. Xnames, even if the compiler/loader can't handle them. Defining ATT makes
  142. Xcake call System V system calls instead of Berkeley ones, and does a few
  143. Xother things as well. It may or may not work for System III.
  144. X
  145. XCAKEDEBUG, when defined, enables cake to output debugging information
  146. Xof various kinds, either on abnormal termination or in response to
  147. Xdebugging options (see main.c). The option -Y requires YYDEBUG
  148. Xto debug the parser actions.
  149. X
  150. XCAREFUL is a safety feature. It prevents cake from removing user files,
  151. Xeven when its semantics call for it (see the -G option). It moves files
  152. Xto /tmp instead. This can slow cake down, so if you think it is not
  153. Xnecessary (e.g. because you have used cake long enough to be confident
  154. Xthat it will not delete files it should not delete or because you do
  155. Xfrequent backups) you should not define CAREFUL.
  156. X
  157. XEXTRACHECK is another safety feature - it enables extra internal
  158. Xconsistency checks. These are fairly cheap, so you may keep them
  159. Xunless you are hurting for CPU time. The one specific instance you
  160. Xmay want to delete is the one in mem.c which checks the aligment
  161. Xof malloc returns.
  162. X
  163. XIf you are concerned about memory usage, you may want to define MEMUSED,
  164. Xwithout which cake never free()s space. However, the opportunities for
  165. Xsavings are minimal (really!); and you should also keep in mind that
  166. Xcake has never been tested with MEMUSED.
  167. X
  168. Xconf.h:
  169. X
  170. XCast should be a type to which all kinds of pointers can be converted
  171. Xforward and back without loss. On most machines int will do.
  172. X
  173. XSLIB is the directory containing the "standard" systemwide library
  174. X(which is in the Lib subdirectory in the distribution), while ULIB
  175. Xis the suffix (after $HOME) of people's own cake library.
  176. X
  177. XCPP is the command to invoke the C preprocessor.
  178. X
  179. XSTATS_FILE is the name of the file in which each invocation of cake
  180. Xputs statistics. If you don't define STATS_FILE, cake does not keep
  181. Xany stats. If you do, the stats are reported (nicely formatted)
  182. Xby Script/{cs,ccs}.
  183. X
  184. XCake parses and execs normal (non-script) actions by itself if they
  185. Xdon't contain any chars from the macro METACHARS. If they do, cake
  186. Xcalls SYSTEM_CMD, while it calls SCRIPT_CMD for scripts. The arg
  187. Xto SYSTEM_CMD is the command itself, while the arg to SCRIPT_CMD
  188. Xis the name of a file (in /tmp) which contains the script. To convert
  189. Xto the Bourne shell, change csh to sh and delete the -f flags.
  190. XFor other shells, you will have to find out how to get equivalent
  191. Xbehaviour, but keep in mind that Unix restricts you to zero or one
  192. Xarguments.
  193. X
  194. XFor ATT systems, TIMERES is the resulotion of the times() system call,
  195. Xbut this is used only for stats.
  196. X
  197. XGENESIS is just a time() value used internally for time when there is
  198. Xnone applicable. It doesn't really matter what it is, as long as it
  199. Xprecedes all valid values.
  200. X
  201. XCHASEROOT is also a name used only internally - it too could be anything
  202. Xas long as it does not conflict with real filenames.
  203. X
  204. XThe other macros in conf.h define the (maximum) sizes of various kinds
  205. Xof things. You need to check only CHARSETSIZE, which should be 512 for
  206. X9-bit byte systems. You should enlarge the others when somebody gets
  207. Xa bounds exceeded message.
  208. X
  209. XConditions:
  210. X
  211. XThe copying conditions for the cake distribution are in the file
  212. XCOPYING. It is patterned after the copying conditions of GNU,
  213. Xin particular GNU Emacs. Basically, you can do anything with it
  214. Xexcept prevent other people from getting access to it. This
  215. Xmeans that you can't sell it. For the reasons for these conditions,
  216. Xread Stallman's GNU manifesto.
  217. X
  218. XAuthor:
  219. X
  220. XZoltan Somogyi
  221. X
  222. XDepartment of Computer Science
  223. XUniversity of Melbourne
  224. XParkville, 3052 Victoria, Australia
  225. X
  226. XUUCP:    {uunet,mcvax,ukc}!munnari.oz!zs
  227. XARPA:    zs%munnari.oz@uunet.uu.net
  228. XCSNET:    zs%munnari.oz@australia
  229. SHAR_EOF
  230. if test 5454 -ne "`wc -c < 'README'`"
  231. then
  232.     echo shar: "error transmitting 'README'" '(should have been 5454 characters)'
  233. fi
  234. fi
  235. echo shar: "extracting 'COPYING'" '(2204 characters)'
  236. if test -f 'COPYING'
  237. then
  238.     echo shar: "will not over-write existing file 'COPYING'"
  239. else
  240. sed 's/^X//' << \SHAR_EOF > 'COPYING'
  241. XCake copying permission notice Copyright (C) 1987 Zoltan Somogyi
  242. X
  243. XCake is distributed in the hope that it will be useful, but without any
  244. Xwarranty. No author or distributor accepts responsibility to anyone for
  245. Xthe consequences of using it or for whether it serves any particular purpose
  246. Xor works at all, unless he/she says so in writing.
  247. X
  248. XEveryone is granted permission to copy, modify and redistribute Cake
  249. Xunder the following conditions:
  250. X
  251. X    Permission is granted to anyone to make or distribute verbatim copies
  252. X    of Cake source code as received, in any medium, provided that all
  253. X    copyright notices and permission and nonwarranty notices are preserved,
  254. X    and that the distributor grants the recipient permission for further
  255. X    redistribution as permitted by this document, and gives him/her and
  256. X    points out to him/her an exact copy of this document to inform him/her
  257. X    of his/her rights.
  258. X
  259. X    Permission is granted to distribute modified versions of Cake source
  260. X    code, or of portions of it, under the above conditions, provided also
  261. X    that all changed files carry prominent notices stating who last changed
  262. X    them and that all the Cake-derived material, including everything
  263. X    packaged together with it and not independently usable, is distributed
  264. X    under the conditions stated in this document.
  265. X
  266. X    Permission is granted to distribute Cake in compiled or executable form
  267. X    under the same conditions applying for source code, provided that either
  268. X
  269. X    A    it is accompanied by the corresponding machine-readable source
  270. X        code, or
  271. X    B    it is accompanied by a written offer, with no time limit, to
  272. X        give anyone a machine-readable copy of the corresponding source
  273. X        code in return for reimbursement of the cost of distribution.
  274. X        This written offer must permit verbatim duplication by anyone.
  275. X    C    it is distributed by someone who received only the executable
  276. X        form, and is accompanied by a copy of the written offer of
  277. X        source code which he/she received along with it.
  278. X
  279. XIn other words, you are welcome to use, share and improve Cake.
  280. XYou are forbidden to forbid anyone else to use, share and improve
  281. Xwhat you give them. Help stamp out software-hoarding!
  282. X
  283. XThis copyright notice was adapted from the one supplied with GNU Emacs.
  284. SHAR_EOF
  285. if test 2204 -ne "`wc -c < 'COPYING'`"
  286. then
  287.     echo shar: "error transmitting 'COPYING'" '(should have been 2204 characters)'
  288. fi
  289. fi
  290. echo shar: "extracting 'Makefile'" '(1943 characters)'
  291. if test -f 'Makefile'
  292. then
  293.     echo shar: "will not over-write existing file 'Makefile'"
  294. else
  295. sed 's/^X//' << \SHAR_EOF > 'Makefile'
  296. X#    Makefile for Cake
  297. X#
  298. X#    $Header: /mip/zs/src/sys/cake/RCS/Makefile,v 1.15 87/10/05 20:13:19 zs Exp $
  299. X
  300. XHDR   =    cake.h conf.h port.h
  301. XSRC   =    act.c chase.c entry.c error.c expand.c file.c \
  302. X    list.c main.c make.c mem.c pat.c print.c proc.c \
  303. X    sym.c sys.c table.c test.c trail.c
  304. XOBJ   =    act.o chase.o entry.o error.o expand.o file.o \
  305. X    list.o main.o make.o mem.o pat.o print.o proc.o \
  306. X    sym.o sys.o table.o test.o trail.o
  307. XGEN   =    cake_g.y cake_s.l
  308. XGHDR  =    cake_g.h
  309. XGSRC  =    cake_g.c cake_s.c
  310. XGOBJ  =    cake_g.o cake_s.o
  311. XDEST  = /mip/usr/bin
  312. XCOPTS = -DCAKEDEBUG -DYYDEBUG -DCAREFUL
  313. XCFLAGS= $(COPTS)
  314. XLDFLAGS=-k 64k
  315. X
  316. Xcake:        $(OBJ) $(GOBJ)
  317. X        $(CC) $(LDFLAGS) $(CFLAGS) -o cake $(OBJ) $(GOBJ)
  318. X        -/bin/rm fake
  319. X        ln cake fake
  320. X
  321. Xall:        cake lint tags defs
  322. X
  323. Xinstall:    cake
  324. X        mv $(DEST)/cake /tmp/Oldcake
  325. X        cp cake $(DEST)/cake
  326. X        strip $(DEST)/cake
  327. X
  328. X$(OBJ):        $(HDR)
  329. X$(GOBJ):    $(HDR)
  330. X
  331. Xcake_g.c:    cake_g.y
  332. X        yacc -dv cake_g.y
  333. X        @mv y.tab.h cake_g.h
  334. X        @mv y.tab.c cake_g.c
  335. X        @mv y.output cake_g.t
  336. X
  337. Xcake_s.c:    cake_s.l
  338. X        lex cake_s.l
  339. X        @mv lex.yy.c cake_s.c
  340. X
  341. Xvar:        $(SRC) $(GSRC)
  342. X        var -DATT $(COPTS) $(SRC) $(GSRC) > Var
  343. X
  344. Xplint:        $(SRC) $(GSRC)
  345. X        lint -acpx $(COPTS) $(SRC) $(GSRC) > Lint_errs
  346. X
  347. Xulint:        $(SRC) $(GSRC)
  348. X        lint -v $(COPTS) $(SRC) $(GSRC) > Lint_errs
  349. X
  350. Xlint:        $(SRC) $(GSRC)
  351. X        lint -v $(COPTS) $(SRC) $(GSRC) > Lint_errs
  352. X        @gred yy Lint_errs
  353. X        @gred malloc Lint_errs
  354. X        @gred strcpy Lint_errs
  355. X        @gred strcat Lint_errs
  356. X        @gred printf Lint_errs
  357. X        @gred flsbuf Lint_errs
  358. X        @gred setbuf Lint_errs
  359. X        @gred rcs_id Lint_errs
  360. X        @gred longjmp Lint_errs
  361. X        @gred sbrk Lint_errs
  362. X
  363. Xcchk:        $(SRC)
  364. X        cchk $(SRC) > Cchk_errs
  365. X
  366. Xtags:        $(SRC) $(GSRC)
  367. X        ctags $(SRC) $(GSRC)
  368. X
  369. Xdefs:        $(SRC) $(GSRC)
  370. X        defn $(SRC) $(GSRC) > defs
  371. X
  372. Xcxref:        $(SRC)
  373. X        cxref -C $(SRC) > Cxref
  374. X
  375. Xssize:
  376. X        ssize $(SRC) $(GEN)
  377. X
  378. Xasize:
  379. X        ssize $(SRC) $(GEN) $(GSRC)
  380. X
  381. Xclean:        
  382. X        /bin/rm    cake_g.h cake_g.t \
  383. X            Make_errs Lint_errs Cchk_errs core \
  384. X            $(OBJ) $(GOBJ) $(GSRC)
  385. X
  386. Xgclean:        
  387. X        /bin/rm $(GSRC) $(GHDR)
  388. SHAR_EOF
  389. if test 1943 -ne "`wc -c < 'Makefile'`"
  390. then
  391.     echo shar: "error transmitting 'Makefile'" '(should have been 1943 characters)'
  392. fi
  393. fi
  394. echo shar: "extracting 'cake.h'" '(2721 characters)'
  395. if test -f 'cake.h'
  396. then
  397.     echo shar: "will not over-write existing file 'cake.h'"
  398. else
  399. sed 's/^X//' << \SHAR_EOF > 'cake.h'
  400. X/*
  401. X**    Cake definitions.
  402. X**
  403. X**    $Header: /mip/zs/src/sys/cake/RCS/cake.h,v 1.15 87/10/05 20:13:40 zs Exp $
  404. X*/
  405. X
  406. X#include    <sys/types.h>
  407. X#include    <stdio.h>
  408. X#include    "std.h"
  409. X#include    "conf.h"
  410. X#include    "wait.h"
  411. X#include    "list.h"
  412. X#include    "table.h"
  413. X
  414. X#define    nf_NONVOL    0x0001
  415. X#define    nf_PRECIOUS    0x0002
  416. X#define    nf_PSEUDO    0x0004
  417. X#define    nf_REDUNDANT    0x0008
  418. X#define    nf_WHEN        0x0010
  419. X#define    nf_DEPNONVOL    0x0020
  420. X#define    nf_NODELETE    0x0040
  421. X#define    nf_NEWFILE    0x0080
  422. X#define    nf_EXIST    0x0100
  423. X#define    nf_BUSY        0x0200
  424. X#define    nf_ERR        0x0400
  425. X#define    nf_TRACED    0x0800
  426. X#define    nf_WARNED    0x1000
  427. X#define    nf_ORIG        0x2000
  428. X
  429. X#define    af_SILENT    0x0001
  430. X#define    af_IGNORE    0x0002
  431. X#define    af_MINUSN    0x0004
  432. X#define    af_SYSTEM    0x0008
  433. X#define    af_SCRIPT    0x0010
  434. X
  435. X/* type of internal patterns */
  436. Xtypedef    struct    s_pat
  437. X{
  438. X    char    *p_str;
  439. X    short    p_flag;
  440. X    short    p_cmd;
  441. X} Pat;
  442. X
  443. X/* type of internal actions */
  444. Xtypedef    struct    s_act
  445. X{
  446. X    char    *a_str;
  447. X    short    a_flag;
  448. X} Act;
  449. X
  450. X/* kinds of actions */
  451. Xtypedef    enum
  452. X{
  453. X    Exec, System, Script
  454. X} A_kind;
  455. X
  456. X/* kinds of tests */
  457. Xtypedef    enum
  458. X{
  459. X    t_TRUE, t_FALSE, t_AND, t_OR, t_NOT,
  460. X    t_CMD, t_MATCH, t_LIST, t_EXIST, t_CANDO, t_OK
  461. X} T_kind;
  462. X
  463. X/* type of tests */
  464. Xtypedef    struct    s_test
  465. X{
  466. X    T_kind        t_kind;
  467. X    Pat        *t_pat;
  468. X    List        *t_list;    /* of Pat(L), char(M)    */
  469. X    char        *t_cmd;
  470. X    struct    s_test    *t_left;
  471. X    struct    s_test    *t_right;
  472. X} Test;
  473. X
  474. X/* type of substitution variables */
  475. Xtypedef    struct    s_var
  476. X{
  477. X    char    *v_val;
  478. X    bool    v_bound;
  479. X} Var;
  480. X
  481. X#define    NOVAR        10
  482. X#define    MAXVAR        11
  483. X
  484. X/* type of substitution environments */
  485. Xtypedef    Var    Env[MAXVAR];
  486. X
  487. X/* type of entries */
  488. Xtypedef    struct    s_entry
  489. X{
  490. X    char    *e_file;
  491. X    List    *e_new;                /* of Pat    */
  492. X    List    *e_old;                /* of Pat    */
  493. X    List    *e_when;            /* of Pat    */
  494. X    List    *e_act;                /* of Act    */
  495. X    Test    *e_cond;
  496. X    bool    e_dblc;
  497. X} Entry;
  498. X
  499. Xtypedef    enum
  500. X{
  501. X    n_OK, n_CANDO, n_NOWAY
  502. X} N_kind;
  503. X
  504. X/* type of nodes in the dependency graph */
  505. Xtypedef    struct    s_node
  506. X{
  507. X    char    *n_name;    /* name of the node        */
  508. X    N_kind    n_kind;        /* current status of the chase    */
  509. X    int    n_flag;        /* the applicable nf_[A-Z]*    */
  510. X    time_t    n_rtime;    /* Real modify time if exist    */
  511. X    time_t    n_stime;    /* Saved copy of n_rtime    */
  512. X    time_t    n_utime;    /* last ancestor Update time    */
  513. X    List    *n_new;        /* left side or rule, of Node    */
  514. X    List    *n_old;        /* right side of rule, of Node    */
  515. X    List    *n_when;    /* starred right side, of Pat    */
  516. X    List    *n_act;        /* the actions, of Act        */
  517. X#if 0    /* N must be 1 for the time being */
  518. X    int    n_pid;        /* current update process    */
  519. X    char    *n_file;    /* name of output file        */
  520. X#endif
  521. X    char    *n_msg;        /* error message, if nf_ERR    */
  522. X    List    *n_badguys;    /* error causes, if nf_ERR    */
  523. X} Node;
  524. X
  525. Xtypedef    struct    s_proc
  526. X{
  527. X    int    pr_pid;
  528. X    bool    pr_run;
  529. X    Wait    pr_stat;
  530. X    int    (*pr_func)();
  531. X    List    *pr_args;
  532. X    Node    *pr_node;
  533. X} Proc;
  534. X
  535. X#include    "extern.h"
  536. X#include    "macro.h"
  537. SHAR_EOF
  538. if test 2721 -ne "`wc -c < 'cake.h'`"
  539. then
  540.     echo shar: "error transmitting 'cake.h'" '(should have been 2721 characters)'
  541. fi
  542. fi
  543. echo shar: "extracting 'cake_g.y'" '(3523 characters)'
  544. if test -f 'cake_g.y'
  545. then
  546.     echo shar: "will not over-write existing file 'cake_g.y'"
  547. else
  548. sed 's/^X//' << \SHAR_EOF > 'cake_g.y'
  549. X%{
  550. X/*
  551. X**    Grammar for Cakefiles
  552. X*/
  553. X
  554. Xstatic    char
  555. Xrcs_id[] = "$Header: /mip/zs/src/sys/cake/RCS/cake_g.y,v 1.15 87/10/05 20:13:45 zs Exp $";
  556. X
  557. X#include    "cake.h"
  558. X#include    <ctype.h>
  559. X
  560. Xextern    List    *set_flag();
  561. Xextern    int    yylineno;
  562. Xextern    char    *yyfile;
  563. X%}
  564. X
  565. X%start        file
  566. X
  567. X%union
  568. X{
  569. X    int    Uint;
  570. X    char    *Ustr;
  571. X    List    *Ulist;
  572. X    Entry    *Uent;
  573. X    Test    *Utest;
  574. X    Act    *Uact;
  575. X    Pat    *Upat;
  576. X}
  577. X
  578. X%token        NL EMPTYLINE
  579. X%token        NONVOL PRECIOUS REDUNDANT PSEUDO WHEN
  580. X%token        IF IN MATCH EXIST CANDO OK
  581. X%token        LPAREN RPAREN
  582. X%token    <Ustr>    COLON PAT PATCMD TESTCMD
  583. X%token    <Uact>    BEGIN_ACT ACT END_ACT
  584. X%token        GARBAGE
  585. X%left        OR
  586. X%left        AND
  587. X%left        NOT
  588. X
  589. X%type    <Uent>    rule
  590. X%type    <Utest>    cond test
  591. X%type    <Upat>    basepat
  592. X%type    <Uact>    act
  593. X%type    <Uint>    flag flag_el
  594. X%type    <Ulist>    pat
  595. X%type    <Ulist>    rule_l ACT_el act_el pat_el pat_l
  596. X
  597. X%%
  598. X
  599. X/**********************************************************************/
  600. X/*        Entries                              */
  601. X
  602. Xfile    :    empty_el ent_esl empty_el
  603. X    ;
  604. X
  605. Xentry    :    rule_l act_el
  606. X        {    new_entry($1, $2);        }
  607. X    ;
  608. X
  609. Xrule    :    pat_l COLON pat_el cond NL
  610. X        {    $$ = make_dep($1, $3, $4, new_name(yyfile), $2);    }
  611. X    ;
  612. X
  613. Xcond    :    IF test
  614. X        {    $$ = $2;            }
  615. X    |    /* empty */
  616. X        {    $$ = (Test *) NULL;        }
  617. X    ;
  618. X
  619. Xtest    :    basepat IN pat_l
  620. X        {    $$ = make_test_l($1, $3);    }
  621. X    |    basepat MATCH basepat
  622. X        {    $$ = make_test_m($1, (Pat *) NULL, $3);}
  623. X    |    basepat MATCH basepat basepat
  624. X        {    $$ = make_test_m($1, $3, $4);    }
  625. X    |    EXIST basepat
  626. X        {    $$ = make_test_s(t_EXIST, $2);    }
  627. X    |    CANDO basepat
  628. X        {    $$ = make_test_s(t_CANDO, $2);    }
  629. X    |    OK basepat
  630. X        {    $$ = make_test_s(t_OK, $2);    }
  631. X    |    TESTCMD
  632. X        {    $$ = make_test_c($1);        }
  633. X    |    test AND test
  634. X        {    $$ = make_test_b(t_AND, $1, $3);}
  635. X    |    test OR test
  636. X        {    $$ = make_test_b(t_OR, $1, $3);    }
  637. X    |    NOT test
  638. X        {    $$ = make_test_u(t_NOT, $2);    }
  639. X    |    LPAREN test RPAREN
  640. X        {    $$ = $2;            }
  641. X    ;
  642. X
  643. Xact    :    ACT
  644. X        {    $$ = $1;            }
  645. X    |    BEGIN_ACT ACT_el END_ACT
  646. X        {    $$ = prep_script($1, $2, $3);    }
  647. X    ;
  648. X
  649. Xbasepat    :    PAT
  650. X        {    $$ = make_pat($1, FALSE, 0);    }
  651. X    |    PATCMD
  652. X        {    $$ = make_pat($1, TRUE, 0);    }
  653. X    ;
  654. X
  655. Xpat    :    basepat flag_el
  656. X        {    $$ = set_flag(makelist($1), $2);}
  657. X    |    LPAREN pat_l RPAREN flag_el
  658. X        {    $$ = set_flag($2, $4);        }
  659. X    ;
  660. X
  661. Xflag    :    NONVOL
  662. X        {    $$ = nf_NONVOL;            }
  663. X    |    PRECIOUS
  664. X        {    $$ = nf_PRECIOUS;        }
  665. X    |    REDUNDANT
  666. X        {    $$ = nf_REDUNDANT;        }
  667. X    |    PSEUDO
  668. X        {    $$ = nf_PSEUDO;            }
  669. X    |    WHEN
  670. X        {    $$ = nf_WHEN;            }
  671. X    ;
  672. X
  673. X/* From here on, the grammar is JUNK                      */
  674. X/**********************************************************************/
  675. X/*        Lists                              */
  676. X
  677. Xent_esl    :    entry
  678. X    |    ent_esl empty_l entry
  679. X    ;
  680. X
  681. Xrule_l    :    rule
  682. X        {    $$ = makelist($1);        }
  683. X    |    rule_l rule
  684. X        {    $$ = addtail($1, $2);        }
  685. X    ;
  686. X
  687. XACT_el    :    /* empty */
  688. X        {    $$ = makelist0();        }
  689. X    |    ACT_el ACT
  690. X        {    $$ = addtail($1, $2);        }
  691. X    ;
  692. X
  693. Xact_el    :    /* empty */
  694. X        {    $$ = makelist0();        }
  695. X    |    act_el act
  696. X        {    $$ = addtail($1, $2);        }
  697. X    ;
  698. X
  699. Xpat_el    :    /* empty */
  700. X        {    $$ = makelist0();        }
  701. X    |    pat_l
  702. X        {    $$ = $1;            }
  703. X    ;
  704. X
  705. Xpat_l    :    pat
  706. X        {    $$ = $1;            }
  707. X    |    pat_l pat
  708. X        {    $$ = addlist($1, $2);        }
  709. X    ;
  710. X
  711. Xflag_el    :    /* empty */
  712. X        {    $$ = 0;                }
  713. X    |    flag_el flag
  714. X        {    $$ = $1 | $2;            }
  715. X    ;
  716. X
  717. Xempty_el:    /* empty */
  718. X    |    empty_l
  719. X    ;
  720. X
  721. Xempty_l    :    EMPTYLINE
  722. X    |    empty_l EMPTYLINE
  723. X    ;
  724. X
  725. X%%
  726. X
  727. Xyyerror(s)
  728. Xchar    *s;
  729. X{
  730. X    extern    int    yyleng;
  731. X    extern    char    yytext[];
  732. X    char        buf[80];
  733. X
  734. X    if (yychar <= 0)
  735. X    {
  736. X        sprintf(buf, "premature EOF");
  737. X        yylineno--;
  738. X    }
  739. X    or (yytext[0] == '\n' || yytext[0] == '\f')
  740. X        sprintf(buf, "%s at end of line", s);
  741. X    or (isprint(yytext[0]))
  742. X        sprintf(buf, "%s at symbol %s", s, yytext);
  743. X    else
  744. X        sprintf(buf, "%s at \\%o", s, yytext[0]);
  745. X    
  746. X    if (cakedebug)
  747. X        printf("%s, %d: %s, token %d\n", yyfile, yylineno, buf, yychar);
  748. X    else
  749. X        printf("%s, %d: %s\n", yyfile, yylineno, buf);
  750. X}
  751. SHAR_EOF
  752. if test 3523 -ne "`wc -c < 'cake_g.y'`"
  753. then
  754.     echo shar: "error transmitting 'cake_g.y'" '(should have been 3523 characters)'
  755. fi
  756. fi
  757. echo shar: "extracting 'cake_s.l'" '(6441 characters)'
  758. if test -f 'cake_s.l'
  759. then
  760.     echo shar: "will not over-write existing file 'cake_s.l'"
  761. else
  762. sed 's/^X//' << \SHAR_EOF > 'cake_s.l'
  763. X%{
  764. X/*
  765. X**    Scanner for Cake
  766. X*/
  767. X
  768. Xstatic    char
  769. Xrcs_id[] = "$Header: /mip/zs/src/sys/cake/RCS/cake_s.l,v 1.15 87/10/05 20:13:49 zs Exp $";
  770. X
  771. X#include    "cake.h"
  772. X#include    "cake_g.h"
  773. X#include    <ctype.h>
  774. X
  775. X#ifdef    CAKEDEBUG
  776. X#define    ret(x)    if (lexdebug) printf("lex: x\n"); return x
  777. X#else
  778. X#define    ret(x)    return x
  779. X#endif
  780. X
  781. X/* YYLMAX must be defined here; it can't be defined in conf.h */
  782. X#undef    YYLMAX
  783. X#define    YYLMAX        MAXLEXBUF
  784. X
  785. X#define    LATE_CATCH
  786. X#define    LATE_RECOVERY    printf("cake: token '%s' is too long\n", yytext); \
  787. X            exit(1);
  788. X
  789. X#define    LBRACE    '{'
  790. X#define    RBRACE    '}'
  791. X
  792. Xextern    char    *yysquare();
  793. Xextern    char    *yycurly();
  794. X
  795. Xextern    int    lexdebug;
  796. Xchar        *yyfile = "no input file";
  797. Xbool        afterifdef = FALSE;
  798. X%}
  799. X
  800. X%a    2500
  801. X%o    5000
  802. X
  803. X%start    edge middle
  804. X
  805. Xpat    [a-zA-Z_0-9/%+-.,]
  806. Xsp    [ \t]
  807. Xnl    [\n\f]
  808. Xnonl    [^\n\f]
  809. Xenonl    ({nonl}|\\{nl})
  810. X
  811. X%%
  812. X
  813. X"if"            { BEGIN middle;    ret(IF);        }
  814. X"and"            { BEGIN middle;    ret(AND);        }
  815. X"or"            { BEGIN middle;    ret(OR);        }
  816. X"not"            { BEGIN middle;    ret(NOT);        }
  817. X"in"            { BEGIN middle;    ret(IN);        }
  818. X"match"            { BEGIN middle;    ret(MATCH);        }
  819. X"exist"            { BEGIN middle;    ret(EXIST);        }
  820. X"cando"            { BEGIN middle;    ret(CANDO);        }
  821. X"ok"            { BEGIN middle;    ret(OK);        }
  822. X
  823. X"("            { BEGIN middle;    ret(LPAREN);        }
  824. X")"            { BEGIN middle;    ret(RPAREN);        }
  825. X
  826. X"@"            { BEGIN middle;    ret(NONVOL);        }
  827. X"!"            { BEGIN middle;    ret(PRECIOUS);        }
  828. X"&"            { BEGIN middle;    ret(PSEUDO);        }
  829. X"^"            { BEGIN middle;    ret(REDUNDANT);        }
  830. X"*"            { BEGIN middle;    ret(WHEN);        }
  831. X
  832. X":"            |
  833. X"::"            {
  834. X                BEGIN middle;
  835. X                yylval.Ustr = new_name(yytext);
  836. X                ret(COLON);
  837. X            }
  838. X
  839. X({pat}|\\{nonl})+    {
  840. X                BEGIN middle;
  841. X                yylval.Ustr = new_name(yytext);
  842. X                ret(PAT);
  843. X            }
  844. X
  845. X\"([^"]|\\\")*\"    {
  846. X                BEGIN middle;
  847. X                /* strip off quotes */
  848. X                yytext[yyleng-1] = '\0';
  849. X                yylval.Ustr = new_name(yytext+1);
  850. X                ret(PAT);
  851. X            }
  852. X
  853. X"[["            {
  854. X                BEGIN middle;
  855. X                yylval.Ustr = yysquare();
  856. X                ret(PATCMD);
  857. X            }
  858. X
  859. X"{{"            {
  860. X                BEGIN middle;
  861. X                yylval.Ustr = yycurly();
  862. X                ret(TESTCMD);
  863. X            }
  864. X
  865. X<middle>({sp}|\\{nl})*    { BEGIN middle;            }
  866. X
  867. X<edge>[@!+-]*"{"{enonl}*{nl}    |
  868. X<edge>[@!+-]*"}"{enonl}*{nl}    |
  869. X<edge>{sp}+{enonl}+{nl}    {
  870. X                BEGIN edge;
  871. X                afterifdef  = FALSE;
  872. X                yylval.Uact = prep_act(yytext);
  873. X
  874. X                /* comment out check_actlen if  */
  875. X                /* have a lex driver with CATCH */
  876. X                check_actlen();
  877. X
  878. X                /* braces around ret ARE needed */
  879. X                /* as ret expands to an if stmt */
  880. X                if (yylval.Uact->a_str[0] == LBRACE)
  881. X                {
  882. X                    ret(BEGIN_ACT);
  883. X                }
  884. X                or (yylval.Uact->a_str[0] == RBRACE)
  885. X                {
  886. X                    ret(END_ACT);
  887. X                }
  888. X                else
  889. X                {
  890. X                    ret(ACT);
  891. X                }
  892. X            }
  893. X
  894. X<edge>"set"{nonl}*{nl}    {
  895. X                BEGIN edge;
  896. X                if (lexdebug)
  897. X                    printf("set line\n");
  898. X                yyset(yytext);
  899. X            }
  900. X
  901. X<edge>#{nonl}*{nl}    {
  902. X                BEGIN edge;
  903. X                if (lexdebug)
  904. X                    printf("hash line\n");
  905. X                yyhash(yytext);
  906. X                if (! afterifdef)
  907. X                    ret(EMPTYLINE);
  908. X            }
  909. X
  910. X<edge>{sp}*{nl}        {
  911. X                BEGIN edge;
  912. X                if (lexdebug)
  913. X                    printf("empty line\n");
  914. X                if (! afterifdef)
  915. X                    ret(EMPTYLINE);
  916. X            }
  917. X
  918. X<middle>{nl}        {
  919. X                BEGIN edge;
  920. X                afterifdef = FALSE;
  921. X                ret(NL);
  922. X            }
  923. X
  924. X{nonl}             { BEGIN middle;    ret(GARBAGE);    }
  925. X
  926. X"$"{nonl}*{nl}        { BEGIN edge;            }
  927. X
  928. X%%
  929. X
  930. Xyyinit()
  931. X{
  932. X    BEGIN edge;
  933. X}
  934. X
  935. Xyywrap()
  936. X{
  937. X    return 1;
  938. X}
  939. X
  940. Xyyset(text)
  941. Xreg    char    text[];
  942. X{
  943. X    reg    char    *s;
  944. X    int        setc;
  945. X    char        *setv[MAXARGS];
  946. X
  947. X    for (s = text+4; *s != '\0' && isspace(*s); s++)
  948. X        ;
  949. X
  950. X    setc = parse_args(s, setv);
  951. X    process_args(setv, &setc, 0);
  952. X    if (setc > 0)
  953. X        printf("cake: non-options on parameter line ignored\n");
  954. X}
  955. X
  956. Xyyhash(text)
  957. Xreg    char    text[];
  958. X{
  959. X    reg    char    *oldfile = yyfile;
  960. X    reg    char    *s, *t;
  961. X
  962. X    afterifdef = TRUE;    /* assume so until proven otherwise */
  963. X    if (sscanf(text+1, "%d", &yylineno) != 1)
  964. X        return;
  965. X
  966. X    text[strlen(text)-1] = '\0';    /* clobber the newline */
  967. X    for (s = text; *s != '\0' && *s != '"' && !isalpha(*s); s++)
  968. X        ;
  969. X
  970. X    if (*s == '\0')
  971. X        return;
  972. X    
  973. X    if (*s != '"')
  974. X        yyfile = new_name(s);
  975. X    else
  976. X    {
  977. X        for (t = s+strlen(s)-1; t != s && *t != '"'; t--)
  978. X            ;
  979. X        
  980. X        if (t != s)
  981. X            *t = '\0';
  982. X
  983. X        yyfile = new_name(s+1);
  984. X    }
  985. X
  986. X    if (yyfile != oldfile)
  987. X    {
  988. X        afterifdef = FALSE;
  989. X        return;
  990. X    }
  991. X}
  992. X
  993. X/*
  994. X**    Read in a PATCMD, which is [[.*PATCMD?.*]]
  995. X**    (or a matched set of double brackets with other stuff.
  996. X**    Note that PATCMD cannot be described by a REAL regular
  997. X**    expression; the one above cheats by using recursion.
  998. X**    yysquare returns the PATCMD brackets and all.
  999. X*/
  1000. X
  1001. Xchar *
  1002. Xyysquare()
  1003. X{
  1004. X    char        buf[MAXSIZE];
  1005. X    reg    int    c, c1;
  1006. X    reg    int    i;
  1007. X    reg    int    n;    /* number of outstanding levels */
  1008. X
  1009. X    n = 1;
  1010. X    i = 0;
  1011. X    buf[i++] = '[';
  1012. X    buf[i++] = '[';
  1013. X    for (c = input(); c != '\0' && c != '\n' && c != '\f'; c = input())
  1014. X    {
  1015. X        buf[i++] = c;
  1016. X        if (c == ']')
  1017. X        {
  1018. X            if ((c1 = input()) != ']')
  1019. X            {
  1020. X                /* for the next iteration */
  1021. X                unput(c1);
  1022. X                continue;
  1023. X            }
  1024. X
  1025. X            buf[i++] = c1;
  1026. X            if (--n > 0)
  1027. X                continue;
  1028. X
  1029. X            buf[i] = '\0';
  1030. X            if (strlen(buf) >= MAXSIZE)
  1031. X            {
  1032. X                fprintf(stderr, "cake internal error: buffer overflow in yysquare\n");
  1033. X                exit_cake(FALSE);
  1034. X            }
  1035. X
  1036. X            if (lexdebug)
  1037. X                printf("yysquare: %s\n", buf);
  1038. X
  1039. X            fflush(stdout);
  1040. X            return new_name(buf);
  1041. X        }
  1042. X        or (c == '[')
  1043. X        {
  1044. X            if ((c1 = input()) != '[')
  1045. X            {
  1046. X                /* for the next iteration */
  1047. X                unput(c1);
  1048. X                continue;
  1049. X            }
  1050. X
  1051. X            buf[i++] = c1;
  1052. X            n++;
  1053. X        }
  1054. X        or (c == '\\')
  1055. X        {
  1056. X            /* don't check next char */
  1057. X            if ((c1 = input()) != '\0')
  1058. X                buf[i++] = c1;
  1059. X        }
  1060. X    }
  1061. X
  1062. X    if (c == '\0')
  1063. X        fprintf(stderr, "%s, %d: premature EOF\n", yyfile, yylineno);
  1064. X    else
  1065. X        fprintf(stderr, "%s, %d: unescaped newline inside a command\n", yyfile, yylineno);
  1066. X
  1067. X    exit_cake(FALSE);
  1068. X}
  1069. X
  1070. X/*
  1071. X**    Read in a TESTCMD, which is {{.*}}. Strip the brackets.
  1072. X*/
  1073. X
  1074. Xchar *
  1075. Xyycurly()
  1076. X{
  1077. X    char        buf[MAXSIZE];
  1078. X    reg    int    c, c1;
  1079. X    reg    int    i;
  1080. X
  1081. X    i = 0;
  1082. X    for (c = input(); c != '\0' && c != '\n' && c != '\f'; c = input())
  1083. X    {
  1084. X        buf[i++] = c;
  1085. X        if (c == RBRACE)
  1086. X        {
  1087. X            if ((c1 = input()) != RBRACE)
  1088. X            {
  1089. X                /* for the next iteration */
  1090. X                unput(c1);
  1091. X                continue;
  1092. X            }
  1093. X
  1094. X            /* overwrite first RBRACE */
  1095. X            buf[--i] = '\0';
  1096. X            if (strlen(buf) >= MAXSIZE)
  1097. X            {
  1098. X                fprintf(stderr, "cake internal error: buffer overflow in yycurly\n");
  1099. X                exit_cake(FALSE);
  1100. X            }
  1101. X
  1102. X            if (lexdebug)
  1103. X                printf("yycurly: %s\n", buf);
  1104. X
  1105. X            fflush(stdout);
  1106. X            return new_name(buf);
  1107. X        }
  1108. X        or (c == '\\')
  1109. X        {
  1110. X            /* don't check next char */
  1111. X            if ((c1 = input()) != '\0')
  1112. X                buf[i++] = c1;
  1113. X        }
  1114. X    }
  1115. X
  1116. X    if (c == '\0')
  1117. X        fprintf(stderr, "%s, %d: premature EOF\n", yyfile, yylineno);
  1118. X    else
  1119. X        fprintf(stderr, "%s, %d: unescaped newline inside a command\n", yyfile, yylineno);
  1120. X
  1121. X    exit_cake(FALSE);
  1122. X}
  1123. X
  1124. Xcheck_actlen()
  1125. X{
  1126. X    if (strlen(yytext) >= YYLMAX)
  1127. X    {
  1128. X        printf("cake: action '%s' too long\n", yytext);
  1129. X        exit_cake(FALSE);
  1130. X    }
  1131. X}
  1132. SHAR_EOF
  1133. if test 6441 -ne "`wc -c < 'cake_s.l'`"
  1134. then
  1135.     echo shar: "error transmitting 'cake_s.l'" '(should have been 6441 characters)'
  1136. fi
  1137. fi
  1138. echo shar: "extracting 'conf.h'" '(1401 characters)'
  1139. if test -f 'conf.h'
  1140. then
  1141.     echo shar: "will not over-write existing file 'conf.h'"
  1142. else
  1143. sed 's/^X//' << \SHAR_EOF > 'conf.h'
  1144. X/*
  1145. X**    Cake configuration parameters.
  1146. X**
  1147. X**    $Header: /mip/zs/src/sys/cake/RCS/conf.h,v 1.15 87/10/05 20:14:08 zs Exp $
  1148. X*/
  1149. X
  1150. X/* type used when type is not known */
  1151. Xtypedef    int    Cast;
  1152. X
  1153. X/* location of the systemwide cake library */
  1154. X#define    SLIB        "/u/pgrad/zs/lib/cake"
  1155. X
  1156. X/* suffix (after $HOME) of personal libraries */
  1157. X#define    ULIB        "/lib/cake"
  1158. X
  1159. X/* command to invoke the C preprocessor */
  1160. X#define    CPP        "/lib/cpp"
  1161. X
  1162. X/* location of the statistics file - if not defined, no stats kept */
  1163. X#define    STATS_FILE    "/u/pgrad/zs/lib/cake_stats"
  1164. X
  1165. X/* characters always requiring shell attention */
  1166. X#define    METACHARS    "*?!&|;<>()[]{}'`\"%$~#"
  1167. X
  1168. X/* default command to execute non-script shell actions */
  1169. X#define    SYSTEM_CMD    "/bin/csh -cf"
  1170. X
  1171. X/* default command to execute shell scripts */
  1172. X#define    SCRIPT_CMD    "/bin/csh -f"
  1173. X
  1174. X/*    System V compatibility            */
  1175. X#ifdef    ATT
  1176. X/* the resolution of the times(2) system call */
  1177. X#ifdef    exlsi
  1178. X#define    TIMERES        100
  1179. X#else
  1180. X#define    TIMERES        60
  1181. X#endif
  1182. X
  1183. X#include        "port.h"
  1184. X
  1185. X#define    vfork()        fork()
  1186. X#define    index(s, c)    strchr(s, c)
  1187. X#define    rindex(s, c)    strrchr(s, c)
  1188. X#endif
  1189. X
  1190. X#define    MAXARGS        64
  1191. X#define    MAXGSTACK    128
  1192. X#define    MAXARGSIZE    128
  1193. X#define    MAXPATSIZE    512
  1194. X#define    MAXLEXBUF    2048
  1195. X#define    MAXSIZE        2048
  1196. X#define    MAXSCRIPT    16384
  1197. X#define    MAXNEST        8
  1198. X#define    SIZE        97        /* size of tables */
  1199. X#define    CHARSETSIZE    256
  1200. X#define    GENESIS        (time_t) 42    /* something distinctive */
  1201. X#define    CHASEROOT    "!MAINCAKE!"
  1202. SHAR_EOF
  1203. if test 1401 -ne "`wc -c < 'conf.h'`"
  1204. then
  1205.     echo shar: "error transmitting 'conf.h'" '(should have been 1401 characters)'
  1206. fi
  1207. fi
  1208. echo shar: "extracting 'extern.h'" '(1540 characters)'
  1209. if test -f 'extern.h'
  1210. then
  1211.     echo shar: "will not over-write existing file 'extern.h'"
  1212. else
  1213. sed 's/^X//' << \SHAR_EOF > 'extern.h'
  1214. X/*
  1215. X**    External definitions for Cake.
  1216. X**
  1217. X**    $Header: /mip/zs/src/sys/cake/RCS/extern.h,v 1.15 87/10/05 20:14:30 zs Exp $
  1218. X*/
  1219. X
  1220. X/* library functions */
  1221. Xextern    char    *malloc();
  1222. X#ifdef    ATT
  1223. Xextern    char    *strchr();
  1224. Xextern    char    *strrchr();
  1225. X#else
  1226. Xextern    char    *index();
  1227. Xextern    char    *rindex();
  1228. X#endif
  1229. X
  1230. X/* memory management */
  1231. Xextern    Cast    newmem();
  1232. Xextern        oldmem();
  1233. X
  1234. X/* make routines */
  1235. Xextern    Node    *make_node();
  1236. Xextern    Entry    *make_dep();
  1237. Xextern    Test    *make_test_mm();
  1238. Xextern    Test    *make_test_m();
  1239. Xextern    Test    *make_test_c();
  1240. Xextern    Test    *make_test_s();
  1241. Xextern    Test    *make_test_l();
  1242. Xextern    Test    *make_test_b();
  1243. Xextern    Test    *make_test_u();
  1244. Xextern    Pat    *make_pat();
  1245. Xextern    Act    *make_act();
  1246. X
  1247. Xextern    Act    *prep_act();
  1248. Xextern    Act    *prep_script();
  1249. X
  1250. X/* table handling routines */
  1251. Xextern        init_sym();
  1252. Xextern    char    *new_name();
  1253. X
  1254. X/* printout routines */
  1255. Xextern    char    scratchbuf[];
  1256. Xextern        print_pat();
  1257. Xextern        print_test();
  1258. Xextern        print_entry();
  1259. Xextern        print_node();
  1260. X
  1261. X/* flags */
  1262. Xextern    int    Gflag;
  1263. Xextern    int    Lflag;
  1264. Xextern    int    Rflag;
  1265. Xextern    int    Xflag;
  1266. Xextern    int    bflag;
  1267. Xextern    int    cflag;
  1268. Xextern    int    dflag;
  1269. Xextern    int    gflag;
  1270. Xextern    int    iflag;
  1271. Xextern    int    kflag;
  1272. Xextern    int    nflag;
  1273. Xextern    int    qflag;
  1274. Xextern    int    rflag;
  1275. Xextern    int    sflag;
  1276. Xextern    int    tflag;
  1277. Xextern    int    vflag;
  1278. Xextern    int    wflag;
  1279. Xextern    int    xflag;
  1280. Xextern    int    zflag;
  1281. X
  1282. Xextern    int    cakedebug;
  1283. Xextern    int    entrydebug;
  1284. Xextern    int    patdebug;
  1285. Xextern    int    lexdebug;
  1286. X
  1287. X/* misc global vars */
  1288. Xextern    char    *cakefile;
  1289. Xextern    int    maxprocs;
  1290. X
  1291. X/* misc functions */
  1292. Xextern    char    *get_newname();
  1293. Xextern        put_trail();
  1294. Xextern        get_trail();
  1295. SHAR_EOF
  1296. if test 1540 -ne "`wc -c < 'extern.h'`"
  1297. then
  1298.     echo shar: "error transmitting 'extern.h'" '(should have been 1540 characters)'
  1299. fi
  1300. fi
  1301. echo shar: "extracting 'list.h'" '(1206 characters)'
  1302. if test -f 'list.h'
  1303. then
  1304.     echo shar: "will not over-write existing file 'list.h'"
  1305. else
  1306. sed 's/^X//' << \SHAR_EOF > 'list.h'
  1307. X/*
  1308. X**    Definitions for the list module.
  1309. X**
  1310. X**    $Header: /mip/zs/src/sys/cake/RCS/list.h,v 1.15 87/10/05 20:14:45 zs Exp $
  1311. X*/
  1312. X
  1313. Xtypedef    struct    s_list
  1314. X{
  1315. X    Cast        l_data;
  1316. X    struct    s_list    *l_prev;
  1317. X    struct    s_list    *l_next;
  1318. X} List;
  1319. X
  1320. X#define    next(ptr)    (ptr)->l_next
  1321. X#define    prev(ptr)    (ptr)->l_prev
  1322. X#define    ldata(ptr)    (ptr)->l_data
  1323. X#define    first_ptr(list)    ((list)->l_next)
  1324. X#define    last_ptr(list)    ((list)->l_prev)
  1325. X#define    first(list)    ((list)->l_next->l_data)
  1326. X#define    last(list)    ((list)->l_prev->l_data)
  1327. X
  1328. X#define    for_list(p, l)    for (p = (l? next(l): NULL); p != l && p != NULL; p = next(p))
  1329. X#define    for_2list(p1, p2, l1, l2)    for \
  1330. X            (p1 = (l1? next(l1): NULL), p2 = (l2? next(l2): NULL); \
  1331. X            p1 != l1 && p1 != NULL && p2 != l2 && p2 != NULL; \
  1332. X            p1 = next(p1), p2 = next(p2))
  1333. X#define    end_list(p, l)    (p == l || p == NULL)
  1334. X
  1335. X#define    makelist(d)        _makelist((Cast) d)
  1336. X#define    addhead(l, d)        _addhead(l, (Cast) d)
  1337. X#define    addtail(l, d)        _addtail(l, (Cast) d)
  1338. X#define    insert_before(l, w, d)    _insert_before(l, w, (Cast) d)
  1339. X#define    insert_after(l, w, d)    _insert_after(l, w, (Cast) d)
  1340. X
  1341. Xextern    List    *makelist0();
  1342. Xextern    List    *_makelist();
  1343. Xextern    List    *_addhead();
  1344. Xextern    List    *_addtail();
  1345. Xextern    List    *addlist();
  1346. Xextern        delete();
  1347. SHAR_EOF
  1348. if test 1206 -ne "`wc -c < 'list.h'`"
  1349. then
  1350.     echo shar: "error transmitting 'list.h'" '(should have been 1206 characters)'
  1351. fi
  1352. fi
  1353. echo shar: "extracting 'macro.h'" '(1029 characters)'
  1354. if test -f 'macro.h'
  1355. then
  1356.     echo shar: "will not over-write existing file 'macro.h'"
  1357. else
  1358. sed 's/^X//' << \SHAR_EOF > 'macro.h'
  1359. X/*
  1360. X**    Common macros for Cake
  1361. X**
  1362. X**    $Header: /mip/zs/src/sys/cake/RCS/macro.h,v 1.15 87/10/05 20:14:48 zs Exp $
  1363. X*/
  1364. X
  1365. X#define    checkpatlen(p)    if (strlen(p) > MAXPATSIZE) \
  1366. X            printf("Pattern %s too long\n", p), exit_cake(FALSE)
  1367. X#define    cdebug        if (cakedebug) printf
  1368. X
  1369. X#ifndef    CAKEDEBUG
  1370. X#define    put_trail(func, event)
  1371. X#define    get_trail(fp)
  1372. X#endif
  1373. X
  1374. X/*    Flag handling                */
  1375. X
  1376. X#define    on_node(n, f)        ((n)->n_flag & (f))
  1377. X#define    off_node(n, f)        (!((n)->n_flag & (f)))
  1378. X#define    set_node(n, f)        (n)->n_flag |= (f)
  1379. X#define    reset_node(n, f)    (n)->n_flag &= ~(f)
  1380. X
  1381. X#define    on_pat(p, f)        ((p)->p_flag & (f))
  1382. X#define    off_pat(p, f)        (!((p)->p_flag & (f)))
  1383. X#define    set_pat(p, f)        (p)->p_flag |= (f)
  1384. X#define    reset_pat(p, f)        (p)->p_flag &= ~(f)
  1385. X
  1386. X#define    on_act(a, f)        ((a)->a_flag & (f))
  1387. X#define    off_act(a, f)        (!((a)->a_flag & (f)))
  1388. X#define    set_act(a, f)        (a)->a_flag |= (f)
  1389. X#define    reset_act(a, f)        (a)->a_flag &= ~(f)
  1390. X
  1391. X#define    is_ok(n)        ((n)->n_kind == n_OK)
  1392. X#define    is_cando(n)        ((n)->n_kind == n_CANDO)
  1393. X#define    is_noway(n)        ((n)->n_kind == n_NOWAY)
  1394. SHAR_EOF
  1395. if test 1029 -ne "`wc -c < 'macro.h'`"
  1396. then
  1397.     echo shar: "error transmitting 'macro.h'" '(should have been 1029 characters)'
  1398. fi
  1399. fi
  1400. echo shar: "extracting 'port.h'" '(2793 characters)'
  1401. if test -f 'port.h'
  1402. then
  1403.     echo shar: "will not over-write existing file 'port.h'"
  1404. else
  1405. sed 's/^X//' << \SHAR_EOF > 'port.h'
  1406. X/*
  1407. X**    Cake portability aids.
  1408. X**
  1409. X**    $Header: /mip/zs/src/sys/cake/RCS/port.h,v 1.15 87/10/05 20:15:28 zs Exp $
  1410. X*/
  1411. X
  1412. X/* too long names */
  1413. X#define    cake_abort    c_abort
  1414. X#define    cake_error    c_error
  1415. X#define    cake_exec    c_exec
  1416. X#define    cake_finish    c_finish
  1417. X#define    cake_gettime    c_gettime
  1418. X#define    cake_pclose    c_pclose
  1419. X#define    cake_popen    c_popen
  1420. X#define    cake_remove    c_remove
  1421. X#define    cake_script    c_script
  1422. X#define    cake_system    c_system
  1423. X#define    cake_utimes    c_utimes
  1424. X#define    cake_wait    c_wait
  1425. X#define    chase        chs
  1426. X#define    chase_node    chs_node
  1427. X#define    cppargc        cppcarg
  1428. X#define    cppargv        cppvarg
  1429. X#define    deref        drf
  1430. X#define    deref_entry    drf_entry
  1431. X#define    dir_finish    dr_finish
  1432. X#define    dir_setup    dr_setup
  1433. X#define    dir_start    dr_start
  1434. X#define    entry_anay    en_nay
  1435. X#define    entry_ayea    en_yea
  1436. X#define    expand_cmds    ex_cmds
  1437. X#define    find_path    fd_path
  1438. X#define    find_process    fd_proc
  1439. X#define    found_incl    fnd_incl
  1440. X#define    found_main    fnd_main
  1441. X#define    get_allnodes    g_allnodes
  1442. X#define    get_cmd_result    gc_result
  1443. X#define    get_cmd_status    gc_status
  1444. X#define    get_newname    g_newname
  1445. X#define    get_output    g_output
  1446. X#define    get_savename    g_savename
  1447. X#define    get_utime    g_utime
  1448. X#define    get_youngest    g_youngest
  1449. X#define    goal_stackp    gs_p
  1450. X#define    ground        gr
  1451. X#define    ground_entry    gr_entry
  1452. X#define    ground_test    gr_test
  1453. X#define    init_chase    i_chase
  1454. X#define    init_entry    i_entry
  1455. X#define    init_sym    i_sym
  1456. X#define    make_act    m_act
  1457. X#define    make_cmd    m_cmd
  1458. X#define    make_dep    m_dep
  1459. X#define    make_node    m_node
  1460. X#define    make_pat    m_pat
  1461. X#define    make_test_b    m_btest
  1462. X#define    make_test_c    m_ctest
  1463. X#define    make_test_l    m_ltest
  1464. X#define    make_test_m    m_mtest
  1465. X#define    make_test_mm    m_mmtest
  1466. X#define    make_test_s    m_stest
  1467. X#define    make_test_u    m_utest
  1468. X#define    makelist0    m_0list
  1469. X#define    miss_anay    ms_nay
  1470. X#define    miss_ayea    ms_yea
  1471. X#define    mutex_lock    mx_lock
  1472. X#define    mutex_unlock    mx_unlock
  1473. X#define    name_equal    nm_equal
  1474. X#define    name_key    nm_key
  1475. X#define    new_cmd        nw_cmd
  1476. X#define    new_name    nw_name
  1477. X#define    node_resetstat    nd_resetstat
  1478. X#define    node_setstat    nd_setstat
  1479. X#define    node_stat    nd_stats
  1480. X#define    picked_time    pck_time
  1481. X#define    prep_act    pp_act
  1482. X#define    prep_entries    pp_entries
  1483. X#define    prep_script    pp_script
  1484. X#define    print_act    pr_act
  1485. X#define    print_entry    pr_entry
  1486. X#define    print_node    pr_node
  1487. X#define    print_pat    pr_pat
  1488. X#define    print_test    pr_test
  1489. X#define    print_time    pr_time
  1490. X#define    script_filename    scr_fn
  1491. X#define    set_buddies    st_buddies
  1492. X#define    set_flag    st_flag
  1493. X#define    shell_cmd    sh_cmd
  1494. X#define    shell_opt    sh_opt
  1495. X#define    shell_path    sh_path
  1496. X#define    signalint    sg_int
  1497. X#define    signalquit    sg_quit
  1498. X#define    spawn_finish    sp_finish
  1499. X#define    spawn_start    sp_start
  1500. X#define    stat_tried    st_tried
  1501. X#define    str_aflag    s_aflag
  1502. X#define    str_nkind    s_nkind
  1503. X#define    str_pflag    s_pflag
  1504. X#define    warn_equal    w_equal
  1505. X#define    warn_key    w_key
  1506. X
  1507. X/* case sensitive variable names */
  1508. X#define    Gflag        ggflag
  1509. X#define    Lflag        llflag
  1510. X#define    Rflag        rrflag
  1511. X#define    Xflag        xxflag
  1512. SHAR_EOF
  1513. if test 2793 -ne "`wc -c < 'port.h'`"
  1514. then
  1515.     echo shar: "error transmitting 'port.h'" '(should have been 2793 characters)'
  1516. fi
  1517. fi
  1518. echo shar: "extracting 'std.h'" '(942 characters)'
  1519. if test -f 'std.h'
  1520. then
  1521.     echo shar: "will not over-write existing file 'std.h'"
  1522. else
  1523. sed 's/^X//' << \SHAR_EOF > 'std.h'
  1524. X/*
  1525. X**    Standard definitions for C
  1526. X**
  1527. X**    $Header: /mip/zs/src/sys/cake/RCS/std.h,v 1.15 87/10/05 20:16:04 zs Exp $
  1528. X*/
  1529. X
  1530. X#define    or        else if
  1531. X#define    when        break;case
  1532. X#define    otherwise    break;default
  1533. X#define    loop        for(;;)
  1534. X#define    until(expr)    while(!(expr))
  1535. X#ifndef    reg
  1536. X#define    reg        register
  1537. X#endif
  1538. X#ifndef    bool
  1539. X#define    bool        char
  1540. X#endif
  1541. X
  1542. X#define    max(a, b)    ((a) > (b) ? (a) : (b))
  1543. X#define    min(a, b)    ((a) < (b) ? (a) : (b))
  1544. X
  1545. X#define streq(s1, s2)        (strcmp(s1, s2) == 0)
  1546. X#define strdiff(s1, s2)        (strcmp(s1, s2) != 0)
  1547. X#define strneq(s1, s2, n)    (strncmp(s1, s2, n) == 0)
  1548. X#define strndiff(s1, s2, n)    (strncmp(s1, s2, n) != 0)
  1549. X
  1550. X#define    ungetchar(c)        ungetc(c, stdin)
  1551. X#define make(type)        ((type *) newmem(sizeof(type)))
  1552. X#define make_many(type, count)    ((type *) newmem(count * sizeof(type)))
  1553. X
  1554. X#ifndef    TRUE
  1555. X#define    TRUE        1
  1556. X#endif
  1557. X#ifndef    FALSE
  1558. X#define    FALSE        0
  1559. X#endif
  1560. X#ifndef    NULL
  1561. X#define    NULL        0
  1562. X#endif
  1563. X
  1564. X#define    CNULL        (char *) 0
  1565. X#define    LNULL        (List *) 0
  1566. SHAR_EOF
  1567. if test 942 -ne "`wc -c < 'std.h'`"
  1568. then
  1569.     echo shar: "error transmitting 'std.h'" '(should have been 942 characters)'
  1570. fi
  1571. fi
  1572. echo shar: "extracting 'table.h'" '(837 characters)'
  1573. if test -f 'table.h'
  1574. then
  1575.     echo shar: "will not over-write existing file 'table.h'"
  1576. else
  1577. sed 's/^X//' << \SHAR_EOF > 'table.h'
  1578. X/*
  1579. X**    Definitions for the table module.
  1580. X**
  1581. X**    $Header: /mip/zs/src/sys/cake/RCS/table.h,v 1.14 86/07/19 12:24:13 zs Exp $
  1582. X*/
  1583. X
  1584. Xtypedef    struct    s_table
  1585. X{
  1586. X    int    ta_size;    /* the size of the store    */
  1587. X    List    **ta_store;    /* the store, an array of lists    */
  1588. X    Cast    (*ta_key)();    /* applied to entries        */
  1589. X    int    (*ta_hash)();    /* applied to keys        */
  1590. X    bool    (*ta_equal)();    /* applied to two keys        */
  1591. X} Table;
  1592. X
  1593. X#define    init_table(t)        _init_table(&t)
  1594. X#define    lookup_table(t, k)    _lookup_table(&t, (Cast) k)
  1595. X#define    insert_table(t, e)    _insert_table(&t, (Cast) e)
  1596. X#define    contents_table(t)    _contents_table(&t)
  1597. X
  1598. X#define    tablekey(table)        (*(table->ta_key))
  1599. X#define    tablehash(table)    (*(table->ta_hash))
  1600. X#define    tableequal(table)    (*(table->ta_equal))
  1601. X
  1602. Xextern        _init_table();
  1603. Xextern    Cast    _lookup_table();
  1604. Xextern    bool    _insert_table();
  1605. Xextern    List    *_contents_table();
  1606. SHAR_EOF
  1607. if test 837 -ne "`wc -c < 'table.h'`"
  1608. then
  1609.     echo shar: "error transmitting 'table.h'" '(should have been 837 characters)'
  1610. fi
  1611. fi
  1612. echo shar: "extracting 'wait.h'" '(2707 characters)'
  1613. if test -f 'wait.h'
  1614. then
  1615.     echo shar: "will not over-write existing file 'wait.h'"
  1616. else
  1617. sed 's/^X//' << \SHAR_EOF > 'wait.h'
  1618. X/*
  1619. X**    Compatibility for ATT versions of Unix
  1620. X**    with Berkeley's wait system calls.
  1621. X**
  1622. X**    $Header: /mip/zs/src/sys/cake/RCS/wait.h,v 1.14 86/07/19 12:24:22 zs Exp $
  1623. X*/
  1624. X
  1625. X#ifdef    ATT
  1626. X/*
  1627. X * Copyright (c) 1982 Regents of the University of California.
  1628. X * All rights reserved.  The Berkeley software License Agreement
  1629. X * specifies the terms and conditions for redistribution.
  1630. X *
  1631. X *    @(#)wait.h    6.2 (Berkeley) 6/8/85
  1632. X */
  1633. X
  1634. X/*
  1635. X * This file holds definitions relevent to the wait system call.
  1636. X * Some of the options here are available only through the ``wait3''
  1637. X * entry point; the old entry point with one argument has more fixed
  1638. X * semantics, never returning status of unstopped children, hanging until
  1639. X * a process terminates if any are outstanding, and never returns
  1640. X * detailed information about process resource utilization (<vtimes.h>).
  1641. X */
  1642. X
  1643. X/*
  1644. X * Structure of the information in the first word returned by both
  1645. X * wait and wait3.  If w_stopval==WSTOPPED, then the second structure
  1646. X * describes the information returned, else the first.  See WUNTRACED below.
  1647. X */
  1648. Xunion wait    {
  1649. X    int    w_status;        /* used in syscall */
  1650. X    /*
  1651. X     * Terminated process status.
  1652. X     */
  1653. X    struct {
  1654. X        unsigned short    w_Termsig:7;    /* termination signal */
  1655. X        unsigned short    w_Coredump:1;    /* core dump indicator */
  1656. X        unsigned short    w_Retcode:8;    /* exit code if w_termsig==0 */
  1657. X    } w_T;
  1658. X    /*
  1659. X     * Stopped process status.  Returned
  1660. X     * only for traced children unless requested
  1661. X     * with the WUNTRACED option bit.
  1662. X     */
  1663. X    struct {
  1664. X        unsigned short    w_Stopval:8;    /* == W_STOPPED if stopped */
  1665. X        unsigned short    w_Stopsig:8;    /* signal that stopped us */
  1666. X    } w_S;
  1667. X};
  1668. X#define    w_termsig    w_T.w_Termsig
  1669. X#define w_coredump    w_T.w_Coredump
  1670. X#define w_retcode    w_T.w_Retcode
  1671. X#define w_stopval    w_S.w_Stopval
  1672. X#define w_stopsig    w_S.w_Stopsig
  1673. X
  1674. X
  1675. X#define    WSTOPPED    0177    /* value of s.stopval if process is stopped */
  1676. X
  1677. X/*
  1678. X * Option bits for the second argument of wait3.  WNOHANG causes the
  1679. X * wait to not hang if there are no stopped or terminated processes, rather
  1680. X * returning an error indication in this case (pid==0).  WUNTRACED
  1681. X * indicates that the caller should receive status about untraced children
  1682. X * which stop due to signals.  If children are stopped and a wait without
  1683. X * this option is done, it is as though they were still running... nothing
  1684. X * about them is returned.
  1685. X */
  1686. X#define WNOHANG        1    /* dont hang in wait */
  1687. X#define WUNTRACED    2    /* tell about stopped, untraced children */
  1688. X
  1689. X#define WIFSTOPPED(x)    ((x).w_stopval == WSTOPPED)
  1690. X#define WIFSIGNALED(x)    ((x).w_stopval != WSTOPPED && (x).w_termsig != 0)
  1691. X#define WIFEXITED(x)    ((x).w_stopval != WSTOPPED && (x).w_termsig == 0)
  1692. X#else
  1693. X#include    <sys/wait.h>
  1694. X
  1695. X#define mask(s)    (1 << ((s)-1))
  1696. X#endif
  1697. X
  1698. Xtypedef    union wait    Wait;
  1699. SHAR_EOF
  1700. if test 2707 -ne "`wc -c < 'wait.h'`"
  1701. then
  1702.     echo shar: "error transmitting 'wait.h'" '(should have been 2707 characters)'
  1703. fi
  1704. fi
  1705. exit 0
  1706. #    End of shell archive
  1707.