






       .














				   Cook

			 A File Construction Tool




				User Guide







			       Peter Miller

			4mpmiller@opensource.org.au0m

































       .












       This document describes Cook version 2.34
       and was prepared 11 November 2026.






       This  document  describing  the	Cook  program, and the Cook
       program itself, are
       Copyright (C) 1988, 1989,  1990,	 1991,	1992,  1993,  1994,
       1995,  1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
       2005, 2006, 2007, 2008, 2009, 2010 Peter Miller

       This program is	free  software;	 you  can  redistribute	 it
       and/or  modify  it under the terms of the GNU General Public
       License as published by the Free Software Foundation; either
       version 3 of the License, or  (at  your	option)	 any  later
       version.

       This  program  is  distributed  in  the hope that it will be
       useful, but WITHOUT ANY WARRANTY; without even  the  implied
       warranty	 of  MERCHANTABILITY  or  FITNESS  FOR A PARTICULAR
       PURPOSE.	 See  the  GNU	General	 Public	 License  for  more
       details.

       You  should  have  received a copy of the GNU General Public
       License	 along	 with	this   program.	  If	not,	see
       <http://www.gnu.org/licenses/>.




















       Cook						 User Guide



       4m1.24m	4mIntroduction0m

       This document describes 1mcook22m, a maintenance tool designed to
       construct  files.   1mCook 22mmay be used to maintain consistency
       between executable files and  the  associated  source  files
       that   are  used	 to  generate  them.   The  consistency	 is
       designated by the relative last‐modified times of files	and
       is  thus	 automatically adjusted each time a file is edited,
       compiled	 or  otherwise	modified.    1mCook   22mvalidates   the
       consistency  of	a system of files and executes all commands
       necessary to maintain that consistency.

       1mCook 22mis a tool for constructing files.  It is given a set of
       files to create, and instructions detailing how to construct
       them.   In   any	  non‐trivial	program	  there	  will	 be
       prerequisites   to   performing	the  actions  necessary	 to
       creating any file, such as extraction from a  source‐control
       system.	1mCook 22mprovides a mechanism to define these.

       When  a	program	 is  being  developed  or  maintained,	the
       programmer will typically change one file of  several  which
       comprise the program.  1mCook 22mexamines the last‐modified times
       of  the	files  to see when the prerequisites of a file have
       changed, implying that the file needs to be recreated as	 it
       is logically out of date.

       1mCook 22malso provides a facility for implicit recipes, allowing
       users to specify how to form a file with a given suffix from
       a  file	with  a	 different  suffix.  For example, to create
       4mfilename24m1m.o 22mfrom 4mfilename24m1m.c0m

       4m1.124m	 4mWhy24m 4mYou24m 4mWant24m 4mTo24m 4mUse24m 4mCook0m

	  • Cook is a replacement for the traditional 4mmake24m(1) tool.

	  • There  is  a  4mmake2cook24m   utility   included	in   the
	    distribution to help convert makefiles into cookbooks.

	  • Cook is more powerful than the traditional 4mmake24m tool.

	  • Cook has true variables, not simple macros.

	  • Cook has a simple but powerful string‐based description
	    language  with  many  built‐in  functions.	This allows
	    sophisticated filename specification  and  manipulation
	    without loss of readability or performance.

	  • Cook has user defined functions.

	  • Cook can build in parallel.





       Peter Miller					     Page 1






       Cook						 User Guide



	  • Cook can distribute builds across your LAN.

	  • Cook  is  able  to	build  your  project  with multiple
	    parallel threads, with support for rules which must	 be
	    single threaded.  It is possible to distribute parallel
	    builds over your LAN, allowing you to turn your network
	    into a virtual parallel build engine.

	  • Cook  is  able  to	use fingerprints to supplement file
	    modification times.	  This	allows	build  optimization
	    without contorted rules.

	  • Cook can be configured with an explicit list of primary
	    source  files.   This  allow the dependency graph to be
	    constructed faster by not going  down  dead	 ends,	and
	    also  allows better error messages when the graph can’t
	    be constructed.  This requires an accurate source  file
	    manifest.

	  • In	addition  to walking the dependency graph, Cook can
	    turn the input rules into a	 shell	script,	 or  a	web
	    page.

	  • Cook   has	 special   4mcascade24m	 dependencies,	allowing
	    powerful  include  dependency  specification,   amongst
	    other things.

	  • And	 Cook  doesn’t interpret tab differently to 8 space
	    characters!

       If you are putting together a source‐code  distribution	and
       planning	 to  write  a makefile, consider writing a cookbook
       instead.	 Although Cook takes a day or two to learn,  it	 is
       much  more  powerful  and  a  bit  more	intuitive  than the
       traditional 4mmake24m(1) tool.

       4m1.224m	 4mHow24m 4mto24m 4mUse24m 4mthis24m 4mManual0m

       This manual is divided into two parts.

       The first part is tutorial introduction to 1mcook22m.  This  part
       runs from chapter 4 to chapter 5.

       The  second  part is for reference and details precisely how
       1mcook 22mworks.	 This part runs from chapter 6 to chapter 14.

       Users familiar with  other  programs  similar  to  1mcook  22mare
       advised	to  skim  the  tutorial part before diving into the
       reference part.

       4m1.324m	 4mAncient24m 4mHistory0m




       Peter Miller					     Page 2






       Cook						 User Guide



       1mCook 22mwas originally developed because I was marooned  on  an
       operating  system  without  anything even vaguely resembling
       4mmake24m(1).  This was in 1988.	 Since I had to write my own,  I
       added  a	 few  improvements.  When I finally escaped back to
       UNIX, in 1990, it  took	only  two  days	 to  port  1mcook  22mto
       SystemV.	  I  have  since deleted all code for that original
       operating system, although clues to its identity	 are  still
       present.

       After I had 1mcook 22mup on UNIX, the progress the world had made
       caught  up  with	 me.   It  was	gratifying that many of the
       features other make‐oid authors had thought  necessary  were
       either already present, or easily and seamlessly added.

       1mCook  22mwas  written	with portability in mind.  This does not
       means it is entirely portable, but it comes close.  1mCook 22mhas
       been tested on numerous UNIX flavors.  This  was	 made  much
       simpler	in  1994  when	I  started  using  the GNU Autoconf
       utility.	 This means that when you obtain  the  sources	for
       Cook,  all  you	have  to  do  is  run  the 4mconfigure24m script
       included in the distribution and Cook will be configured for
       your  system.   See  the	 BUILDING  file	  in   the   source
       distribution for more information.

       In 1996 Cook had internationalization support added, so that
       users  could  have  error  messages  and	 other	warning and
       informational messages printed  in  their  native  language.
       This was made possible by the GNU Gettext utilities.

       In 1997 Cook had a major re‐write of significant portions of
       its inference engine.  This enabled the addition of parallel
       processing   support,  and  simplified  adding  user‐defined
       functions to the cookbook language.






















       Peter Miller					     Page 3






       Cook						 User Guide



       4m2.24m	4mCook24m 4mfrom24m 4mthe24m 4mOutside0m

       This chapter is part of the tutorial on how to use the  1mcook0m
       program.	  It focuses on how to use 1mcook22m, without needing to
       know how 1mcook 22mworks internally.

       4m2.124m	 4mWhat24m 4mcan24m 4mcook24m 4mdo24m 4mfor24m 4mme?0m

       By far the most common use of cook, by experts and beginners
       alike, is to issue the command
	    cook
       and cook will consult its cookbook to see what needs  to	 be
       done.

       In  general, 1mcook 22mis used to take a set of files and chew on
       them in some way to produce another set of  files;  such	 as
       the  source  files  for a program, and how to turn them into
       the executable program  file.   In  order  for  1mcook  22mto  do
       anything	 useful, it needs to know what to do.  "What to do"
       is contained  in	 a  file  called  4mHowto.cook24m  in  the  same
       directory  as the files it is going to work on.	You need to
       execute the  cook command in the same directory	as  all	 of
       the files.

       4m2.224m	 4mWhat24m 4mis24m 4mcook24m 4mdoing?0m

       The 4mHowto.cook24m file was written by the same person who wrote
       the  source  files.   It	 contains a set of recipes; each of
       which, among other  things,  contain  commands  for  how	 to
       manipulate  the	files.	 The 1mcook 22mprogram echos each of the
       commands it is about to execute, so that you can watch  what
       it is doing as it goes.

       If the 4mHowto.cook24m file contained only commands, you would be
       better  off  using  a  shell  script.   In  addition  to the
       commands is information telling 1mcook 22mwhich files need to  be
       constructed  before  other  files  can  be,  and	 from  this
       information 1mcook 22mdetermines the order in  which  to	 execute
       the  commands.	Also,  1mcook  22mexamines  other information to
       determine  which	 commands  it  need  not  do,  because	the
       associated files are already up‐to‐date.

       4m2.324m	 4mWhat24m 4mcan24m 4mcook24m 4malways24m 4mdo?0m

       If  you	are  in a directory with a 4mHowto.cook24m file, you can
       expect a few common requests to work

       cook clobber																																											       This
																																													       command
																																													       can
																																													       be
																																													       expected



       Peter Miller					     Page 4






       Cook						 User Guide



																																													       to
																																													       remove
																																													       any
																																													       files
																																													       from
																																													       the
																																													       directory
																																													       which
																																													       1mcook0m
																																													       is
																																													       able
																																													       to
																																													       reconstruct.

       cook all																																												       This
																																													       is
																																													       the
																																													       default
																																													       action,
																																													       and
																																													       so
																																													       can
																																													       be
																																													       obtained
																																													       by
																																													       a
																																													       simple
																																													       cook
																																													       request.
																																													       It
																																													       causes
																																													       1mcook0m
																																													       to
																																													       construct
																																													       some
																																													       specific
																																													       file
																																													       or
																																													       set
																																													       of
																																													       files.

       cook clean																																											       This
																																													       is
																																													       similar
																																													       to
																																													       "cook
																																													       clobber"
																																													       above,
																																													       but
																																													       it
																																													       only



       Peter Miller					     Page 5






       Cook						 User Guide



																																													       removes
																																													       intermediate
																																													       files,
																																													       and
																																													       not
																																													       not
																																													       the
																																													       final
																																													       file
																																													       or
																																													       files
																																													       which
																																													       "cook
																																													       all"
																																													       constructs.

       In addition to the above, many 4mHowto.cook24m  files  will  also
       define

       cook install																																											       If
																																													       a
																																													       program
																																													       or
																																													       library
																																													       or
																																													       document
																																													       is
																																													       constructed
																																													       in
																																													       the
																																													       directory,
																																													       the
																																													       this
																																													       command
																																													       will
																																													       install
																																													       it
																																													       into
																																													       the
																																													       correct
																																													       place
																																													       in
																																													       the
																																													       system.

       cook uninstall																																											       The
																																													       reverse
																																													       of
																																													       the
																																													       above,
																																													       it
																																													       removes



       Peter Miller					     Page 6






       Cook						 User Guide



																																													       something
																																													       from
																																													       the
																																													       system.

       4m2.424m	 4mIf24m 4msomething24m 4mgoes24m 4mwrong0m

       Most  errors  while  1mcook 22mis constructing file are caused by
       errors in the source files, and not the 4mHowto.cook24m file.  In
       general, you can fix the problems in the source	files,	and
       execute	the  1mcook  22mcommand again, and 1mcook 22mwill resume from
       the command which incurred the error.

       To help you while editing the files with	 the  errors,  1mcook0m
       keeps  a	 listing  file of all the commands it executed, and
       any output of those commands, in a file called 4mHowto.list24m in
       the current directory.

       You may want 1mcook 22mto find all the errors it can  before  you
       do any editing, do do this, use the 1m‐Continue 22moption (it may
       be abbreviated to 1m‐c 22mfor convenience).

       4m2.524m	 4mThe24m 4mReference24m 4mManual0m

       For  more  information  about the command line arguments and
       options	of  the	 various  commands  mentioned,	you  should
       consult the on‐line manual pages.  The Cook Reference Manual
       is  also a good source of this information, and is available
       from the same place as you obtained this manual.


























       Peter Miller					     Page 7






       Cook						 User Guide



       4m3.24m	4mCook24m 4mfrom24m 4ma24m 4mCookbook0m

       This  chapter  describes	 the  contents	and  meaning  of  a
       cookbook, a file which contains information 1mcook 22mneeds to do
       its  job.   It  focuses	on  what a cookbook looks like, and
       touches on a few areas of how 1mcook 22mworks does its job.

       4m3.124m	 4mWhat24m 4mdoes24m 4mCook24m 4mdo?0m

       The basic building block	 for  1mcook  22mis  the  concept  of  a
       4mrecipe24m.  A recipe has three parts:

	 1. one or more files which the recipe constructs, known as
	    the 4mtargets24m of the recipe

	 2. zero  or  more  files  which  are used by the recipe to
	    construct the target, known as the 4mingredients24m	 of  the
	    recipe

	 3. one	 or  more  commands  to execute which construct the
	    targets from the ingredients, known as the 4mbody24m of  the
	    recipe.

       When  a	number	of  recipes  are  given,  some	recipes may
       describe how to cook the ingredients of other recipes.  When
       1mcook  22mis  asked  to	 construct  a	particular   target   it
       automatically  determines  the  correct order to perform the
       recipe bodies to cook the requested target.

       1mCook 22mwould not be especially  useful  if  you  had	to  give
       explicit	 recipes  for how to cook every little thing.  As a
       result, 1mcook 22mhas the concept  of  an  4mimplicit24m	 recipe.   An
       implicit	 recipe	 is  very  similar  to	an explicit recipe,
       except that the targets and ingredients of  the	recipe	are
       4mpatterns24m  to  be matched to file names, rather than explicit
       file names.  This means it is possible to  write	 a  recipe,
       for  example  which constructs a files with a name ending in
       ‘1m.o22m’ from a file of the same name, but ending in ‘1m.c22m’ rather
       than ‘1m.o22m’.

       In addition to recipes, 1mcook 22mneeds to know 4mwhen24m to construct
       targets from ingredients.  1mCook 22mhas been designed to cook as
       little as possible.  "As little as possible"  is	 determined
       by  examining  when  each  file	was last modified, and only
       constructing targets when that are  out	of  date  with	the
       ingredients.


       4m3.1.124m  4mWhen24m 4mis24m 4mCook24m 4museful?0m
       From  the above description, 1mcook 22mmay be described as a tool
       for maintaining consistency of sets of files.




       Peter Miller					     Page 8






       Cook						 User Guide



       4m3.1.224m  4mWhen24m 4mis24m 4mCook24m 4mnot24m 4museful?0m
       Cook is not useful for maintaining consistency  of  sets	 of
       things  which  are  4mwithin24m	files and thus 1mcook 22mis unable to
       determine when they were modified.  For example, 1mcook 22mis not
       useful for maintaining consistency of sets of records within
       a database.


       4m3.224m	 4mHow24m 4mdo24m 4mI24m 4mtell24m 4mCook24m 4mwhat24m 4mto24m 4mdo?0m

       Sets of recipes are gathered together into cookbooks.   When
       1mcook  22mis  executed	it  looks  for	a  cookbook  of the name
       4mHowto.cook24m in the current directory.  If you did not name  a
       file to be constructed on the command line, the first target
       in the cookbook will be constructed.

       The  best  way  to  understand  how  to	write recipes is an
       example.	 In this example, a  program, 4mprog24m, is composed  of
       three  files:  4mfoo.c24m,  4mbar.c24m  and  4mbaz.c24m.	 To inform 1mcook 22mof
       this, the cookbook
	    #include "c"

	    prog: foo.o bar.o baz.o
	    {
		    cc ‐o prog foo.o bar.o baz.o;
	    }
       is sufficient for 4mprog24m to be constructed.

       This cookbook has two parts.  The line
	    #include "c"
       tells 1mcook 22mto refer to a system  cookbook  which  tells  it,
       among other things, how to construct a 4msomething24m1m.o 22mfile from
       a 4msomething24m1m.c 22mfile.

       The second part is a recipe.  The first line of this recipe
	    prog: foo.o bar.o baz.o
		...
       names  the  target,  4mprog24m, and the ingredients, 4mfoo.o24m, 4mbar.o0m
       and 4mbaz.o24m.

       The next three lines
	    ...
	    {
		    cc ‐o prog foo.o bar.o baz.o;
	    }
       are the recipe  body,  which  consists  of  a  single  4mcc24m(1)
       command	to  be executed.  Recipe bodies are always within 1m{0m
       curly braces 1m}22m, and commands always	 end  with  a  semicolon
       (1m;22m).

       Thus, to update 4mprog24m after any of the source files have been
       edited, it is only necessary to issue the command



       Peter Miller					     Page 9






       Cook						 User Guide



	    cook prog
       This could be simplified further, because 1mcook 22mwill cook the
       targets of the first recipe by default; in this case, 4mprog24m.

       The  power  of cook becomes more apparent when include files
       are considered.	If the files 4mfoo.c24m and  4mbaz.c24m	 include  the
       file  4mdefs.h24m,  this would automatically be detected by 1mcook22m.
       If 4mdefs.h24m were to be  edited,  and	1mcook	22mre‐executed,	 this
       would  cause  1mcook  22mto  recompile  both 4mfoo.c24m and 4mbaz.c24m, and
       relink 4mprog.24m  The information about how  to	 turn  1m.c  22mfiles
       into  1m.o  22mfiles  came  from the ‘‘#include "c"’’ line, which
       read in the C recipes distributed with Cook.

       4m3.2.124m  4mThe24m 4mcommon24m 4mprogram24m 4mcase0m
       The above example may be simplified even	 further.   If	the
       four  files  4mfoo.c24m, 4mbar.c24m, 4mbaz.c24m and 4mdefs.h24m all resided in a
       directory  with	a  path	 of  4m/some/where/prog24m,   then   the
       4mHowto.cook24m file in that directory need only contain
	    #include "c"
	    #include "program"
       for  4mprog24m  to  be  cooked.	 This  is  because the "program"
       cookbook looks for all  of  the	4msomething24m1m.c  22mfiles  in  the
       current	directory, compiles them all, and links them into a
       program named after the current directory.

       The default target in the "program" cookbook is called  4mall24m.
       The ingredient of 4mall24m is the program named after the current
       directory.  Two other targets are supplied by this cookbook:

       clean														       removes
															       all
															       of
															       the
															       4msomething24m1m.o0m
															       files
															       from
															       the
															       current
															       directory.

       clobber														       removes
															       the
															       program
															       named
															       after
															       the
															       current
															       directory,
															       and
															       also
															       removes
															       all



       Peter Miller					    Page 10






       Cook						 User Guide



															       of
															       the
															       4msomething24m1m.o0m
															       files
															       from
															       the
															       current
															       directory.

       4m3.324m	 4mCreating24m 4ma24m 4mCookbook0m

       To  use	1mcook 22myou will usually need to define a cookbook, by
       creating a file, usually called 4mHowto.cook24m	in  the	 current
       directory, with your favorite text editor.

       This  file  has	a  specific  format.   The  format has been
       designed to be easy to learn,  even  for	 the  casual  user.
       Much  of	 the  power  of	 1mcook 22mis contained in how it works,
       without complicating the format of the cookbook.

       Example	of  what  a  cookbook  looks  like  are	  scattered
       throughout  this	 document.   The  following  example is the
       entire cookbook for many programs, some quite large:
	    #include "c"
	    #include "yacc"
	    #include "usr.local"
	    #include "program"
       As you can see, even for many complex programs, the cookbook
       is remarkably simple.


























       Peter Miller					    Page 11






       Cook						 User Guide



       4m4.24m	4mCooking24m 4min24m 4mParallel0m

       Cook is able  to	 use  the  dependency  information  in	the
       cookbook	 to  schedule  more  than  one recipe body at once,
       where they are  independent.   In  large	 projects  this	 is
       almost always possible.

       Parallel	 processing  is	 of  most  use	on  multi‐processor
       systems.	 There are cases, however, when running two jobs at
       once on a workstation can take advantage of disk or  network
       latencies.

       Parallel	 processing requires more resources than the simple
       case.  Because  more  commands  are  running,  more  CPU	 is
       required,  but  also  more virtual memory and more temporary
       file space.  You need to be sure that cooking in parallel is
       a sensible thing to be doing.

       4m4.124m	 4mCommand24m 4mLine24m 4mOption0m

       The ‐PARallel option is used to tell Cook to run the  recipe
       bodies  in  parallel.   By  default, 4 jobs run in parallel.
       You may specify the number of jobs after	 the  option  (4me.g.0m
       ‐‐par=2) if you wish.

       4m4.224m	 4mCookbook24m 4mVariable0m

       It  is  also  possible to set the number of jobs from within
       the cookbook by using the parallel_jobs variable.  This	can
       be  used	 to  automate  the selection of the number of jobs,
       based on the current host name:
	    if [not [defined parallel_jobs]] then
	    {
		    host = [os node];
		    if [in [host] cerberus] then
			    parallel_jobs = 3;
		    else if [in [host] zaphod] then
			    parallel_jobs = 2;
		    else if [in [host] hydra] then
			    parallel_jobs = 8;
	    }
       In this way, the number of jobs will  be	 set  appropriately
       for  each  machine,  provided  the  number  of  jobs was not
       already set by the command line option.

       4m4.324m	 4mRecipe24m 4mWriting0m

       Most recipes run in  parallel  without  difficulty,  however
       some  will  require  special  treatment.	 The problems arise
       from conflict for resources − usually temporary files.





       Peter Miller					    Page 12






       Cook						 User Guide



       The  simplest  example  of  this	 is  4myacc24m(1).   The  output
       filenames are hard‐coded, even when you write a more general
       recipe:
	    %.c: %.y
		    single‐thread yy.tab.c
	    {
		    [yacc] [yacc_flags] %.y;
		    sed "’s/[yY][yY]/%_/g’" yy.tab.c > [target];
		    rm yy.tab.c;
	    }
       Replacing  the  YY  is a common method for getting more than
       one yacc grammar into a program.	 We run into  trouble  with
       the  yy.tab.c  file  because  every one of the yacc grammars
       will need to use the same temporary file name.

       The single‐thread clause tells cook to find  something  else
       to  do  if it discovers that it wants do two of these at the
       same time.

       The temporary file name may not be so evident as in the yacc
       case.  The GNU Autoconf utilities use a number of  temporary
       files  in  the current directory, but none of them appear in
       the text of the recipes.
	    %: %.in: config.status
		    single‐thread conftest.subs
	    {
		    CONFIG_FILES\=[target] CONFIG_HEADERS\= config.status;
	    }
       It is common, if your project uses GNU Autoconf, to generate
       several files in this way.  Once the config.status script is
       produced, all of these files will  then	be  candidates	for
       cook to generate − but they can only be done one at a time.

       Other  resources, such as tape drives, can also be described
       in the single‐thread clause.  You can do this by device name
       (4me.g.24m /dev/rmt/0) or by some descriptive string.  The single
       threading is performed by mutually  exclusive  string  sets,
       not by inode.

       4m4.3.124m  4mConcurrent24m 4mExecution24m 4mThreads0m
       Each  recipe,  when  its	 actions  are executed, is executed
       within an execution thread.  Execution threads share  almost
       everything  in  common;	this includes all of the variables,
       the state of the ‘‘set’’ statement, the stat cache, 4metc24m.

       If you need to create  variable	names,	or  temporary  file
       names,  which  are  unique  to a thread, use the [thread‐id]
       variable.  This variable has a unique value for the life	 of
       a  thread.   No	other  concurrent thread will have the same
       value.

       Note, however, that  the	 [thread‐id]  values  of  completed



       Peter Miller					    Page 13






       Cook						 User Guide



       threads	will  be re‐used; this ensures that when it is used
       to construct variable names, the variables will be  re‐used.
       This prevents memory bloat when cooking large projects.

       4m4.424m	 4mFile24m 4mLocking0m

       The  above  discussion applies to utilities which perform no
       file locking, and thus cannot detect  or	 sequence  multiple
       accesses to a resource.	Other programs, such as those which
       access  databases,  may	have  quite  capable  file  locking
       mechanisms and are able to manage multiple parallel  updates
       on  their  own,	obviating  the	need  for the single‐thread
       clause.

       4m4.524m	 4mVirtual24m 4mMachine0m

       It is possible to simulate a parallel machine if you are	 on
       a network.  Cook is able to distribute tasks to computers on
       a network, if it is given sufficient information.

       The first information Cook requires is the list of machines.
       This  is	 done using the parallel_hosts variable.  1mNote: 22mThe
       tasks will be distributed amongst these machines independent
       of the setting of the parallel_jobs variable.  4mi.e.24m even  if
       you are not doing parallel processing.
	    parallel_hosts = larry curly moe;
       If  you	want  to  give	one machine more weighting than the
       others (say, because it is twice as fast) you simply name it
       more than once.	Cook will use these  names  in	round‐robin
       fashion.

       4m4.5.124m  4mRemote24m 4mShell24m 4mCommand0m
       Cook  uses  the Berkeley 4mrsh24m(1) command to invoke the remote
       command.	 You can set the command, or the command  and  some
       options, using the parallel_rsh variable.  The default value
       is
	    parallel_rsh = rsh;
       In   order  to  work  in	 a  useful  way,  Cook	makes  some
       assumptions about your environment and your account:

	  • That your system administrators allow 4mrsh24m(1) to be used
	    on your network.

	  • That your account name is  the  same  on  4mall24m	machines
	    (otherwise	not  even the rsh ‐l 4mlogin‐name24m option will
	    help).

	  • That the /etc/hosts.equiv file, or your ˜/.rhosts file,
	    is set on 4mall24m machines so that you don’t need to give a
	    password.





       Peter Miller					    Page 14






       Cook						 User Guide



	  • That all of the necessary  files  and  directories	are
	    mounted  in	 exactly  the  same  place  on	all  of the
	    machines; and that they  are  4mthe24m  4msame24m  4mfiles24m  on  all
	    machines,  via  NFS	 or similar.  Automounters can make
	    this especially messy.

	  • That your account start‐up scripts	set  the  necessary
	    environment settings, 4me.g.24m command search PATH, without
	    any intervention required.

	  • That  all of the machines are of the same architecture,
	    or that the architecture doesn’t matter.

	  • That the system time is synchronized on  all  machines,
	    using 4mrdate24m(1) from 4mcron24m(8), or using NTP, or similar.

       4m4.5.224m  4mLimitations0m
       There are some inherent limitations in the 4mrsh24m(1) protocol.

	  • Your  current  environment	variable  settings  are not
	    transferred across.	 Neither are 4mulimit24m settings,  4metc24m.
	    If any are important, you need to write the cookbook to
	    explicitly replicate them.

	  • The	 exit  status of the remote command is not reported
	    in the exit status of the 4mrsh24m(1) command[1].  There are
	    internal contortions used by Cook to  obtain  the  exit
	    status;  error  about  mysteriously named files usually
	    indicate that one or more of the above  assumptions	 is
	    being broken.

       4m4.5.324m  4mSecure24m 4mShell0m
       It  is  possible	 to  use  the Secure Shell (ssh) instead of
       Remote Shell (rsh).  This  gives	 you  fully  authenticated,
       fully  encrypted	 sessions, both over your intranet and even
       over  the  Internet.   Once  you	 have  it   installed	and
       configured  correctly, you simply replace the 4mrsh24m command in
       the above examples with the 4mssh24m command.

       This is accomplished by setting
	    parallel_rsh = "ssh";
       Somewhere near the top of your cookbook.

       4m4.5.424m  4mHost24m 4mBinding0m
       In some cases, such as licensing conditions,  some  commands
       will  only  run	on  a  limited	set  of hosts.	Rather than

       ————————————————————

       1. The  Berkeley	 sources certainly don’t contain code to do
	  this.	  Do  any  other  vendors  have	  a   more   useful
	  implementation?



       Peter Miller					    Page 15






       Cook						 User Guide



       perform all commands on those hosts, it is possible to  bind
       recipes	to  specific  hosts.   This  binding  overrides the
       parallel_hosts variable.
	    %.c: %.esql
		    host‐binding shylock
	    {
		    esql %.esql > [target];
	    }
       This example says that the embedded SQL preprocessor is only
       to  be  run  on	the  database  server  called  ‘‘shylock’’,
       probably	 due  to usurious licensing fees.  However, you may
       want to perform your other development  activities  on  more
       lightly	loaded	machines;  this clause only applies to this
       one recipe, other recipes behave as normal.

       The host‐binding clause may have more than one  host  named,
       and  they  will	be  used in round‐robin fashion.  This is a
       recipe‐level variant of the parallel_hosts variable.

       The  host‐binding  clause  will	apply  independent  of	the
       setting	of  the	 settings  parallel_jobs and parallel_hosts
       variables.

       The recipe level host‐binding overrides the  cookbook  level
       parallel_hosts when determining which remote hosts should be
       used.

       If  the	list  of  hosts given to the host‐binding clause is
       empty, the local host will be used (normal recipe  execution
       will occur).

       If  you	need  to include the local host in the round robin,
       use localhost or [os node], however this will behave exactly
       the same as for a remote host.	You  should  also  consider
       hard  coding the name, that way you get the same behavior no
       mater which of the machines in  the  round  robin  the  Cook
       command is executed on.

       4m4.5.524m  4mLoad24m 4mBalancing0m
       It   is	 possible  to  use  4mhost‐binding24m  to  perform  load
       balancing.  This is accomplished by using 4mrup24m(1) to discover
       which hosts are least busy, and then using this	information
       to invoke the system’s 4mrsh24m(1).

       This may be accomplished by using
	    parallel_rsh = "cook_rsh";
       somewhere  near the top of your cookbook (or 4mcook_rsh24m 4m−s24m for
       secure shell).  You then give classes of hosts to the  4mhost‐0m
       4mbinding24m  clause  of	 the  recipes, rather than specific host
       names.  See 4mcook_rsh24m(1) for more information  about	 setting
       up classes of hosts.




       Peter Miller					    Page 16






       Cook						 User Guide



       If  you	still  need  to	 give  specific	 host names to some
       recipes, 4mcook_rsh24m(1) will cope with this, too.

       4m4.624m	 4mVirtual24m 4mMachine,24m 4mRevisited0m

       It is also possible to have Cook run multiple  processes	 in
       parallel without having to know what machines are available.
       This  method  puts  control  of the network resources in the
       hands of an  external  program,	one  example  of  which	 is
       cook_rsh, distributed with Cook.

       Once you have such a virtual network defined it becomes very
       easy   to   build   projects   for   multiple  platforms	 or
       architectures in the same  build.   It  also  allows  easily
       adding  new machines, or disabling machines for maintenance.
       The virtual network can	be  changed  at	 any  time  without
       disturbing ongoing development.

       The  following examples will have the form allowing multiple
       architecture builds, but of course they will work for single
       architecture as well.

       4m4.6.124m  4mcook_rsh0m
       The  cook_rsh  system  is  just	one  way  of  defining	the
       capabilities  of	 a  given  network  in	a way that a single
       program can make the best choice of machine for a given job.
       It does so in a way that is reliable and does a	decent	job
       of  balancing  loads  across  available	machines, even with
       multiple developers doing builds at the same time.

       Each job that requested via cook_rsh picks  the	appropriate
       machine	from  those  able  to do the job at that instant in
       time.  In contrast to parallel_hosts or	host‐binding  hostA
       hostB etc, it does not work from a list which was current at
       the  time  a  cook  process  was	 started.   Thus it is less
       vulnerable to machines going off line or becoming overloaded
       as time passes.

       Currently cook_rsh uses rsh to actually execute the job,	 so
       requires	 the  same network setup.  The next version may use
       multicast instead for even finer control and reliability.

       There are minor differences in the  setup  to  use  cook_rsh
       control.	  The  first is that Cook no longer requires a list
       of machines.  It is not necessary to set the  parallel_hosts
       variable.  The parallel_rsh variable is set as:
	    parallel_rsh = cook_rsh ‐v;
       The  ‐v	option	produces information as to what machine was
       actually picked for each job.






       Peter Miller					    Page 17






       Cook						 User Guide



       4m4.6.224m  4mHost24m 4mBinding0m
       All recipe bodies which should run in parallel need a  host‐
       binding	setting.   Rather than list the hosts to be used we
       form  a	name  which  is	 used  by  cook_rsh  to	 select	 an
       appropriate  machine.  This name may include an architecture
       component and a operation component.
	    %1/%.o: %.c
		    host‐binding %1_C
	    {
		    [%1_cc] ‐o [target] ‐c [resolve %.c];
	    }

	    %1/%2: [addprefix %1/ [%2_objs]]
		    host‐binding %1_L
	    {
		    [%1_ld] ‐o [target] [resolve [need]];
	    }
       This  example  says  that  the  compiles	  for	a   certain
       architecture  should take place on any machine designated as
       a compile host for  that	 architecture.	 And  linking  jobs
       should  go  to  machines	 designated as a link host for that
       architecture.  Of course the same machine could probably	 do
       both  jobs,  but	 you  get  to define it as you see fit, and
       change the designations	from  moment  to  moment.   Current
       designations per architecture are:

       _C   Compile   (Compile source code)
       _L   Link      (link binary programs)
       _T   Test      (run automatic tests)
       _B   Build     (including cooking, or generic jobs)
       And others may be added if necessary by simple extension.

       4m4.6.324m  4mAdministration24m 4mof24m 4mcook_rsh0m
       The  definition	of  the virtual network used by cook_rsh is
       contained in just a two configuration files.  One file lists
       designations,  and  lists   machines   belonging	  to   each
       designation.   The  other  is  an  1mexclude 22mfile, which lists
       machines which should not be used for whatever reason.

       The designations file may be created by hand if desired	but
       a  utility  called  rate_hosts is provided that can generate
       the host_lists.pl file, possibly after being customized	for
       the particular requirements of a given environment.

       The  exclusion  file  lists  machines  that  should never be
       selected.  The exclusion file can be edited at any time	and
       adding  a  machine  will prevent any further jobs from going
       its way.	 Removing the name will again  allow  selection	 of
       that  machine.	How  soon a job actually goes there depends
       greatly on the network utilization.  The exclude_hosts  file
       contains	 machine  names	 and optional comments.	 An example
       exclude_hosts file might contain:



       Peter Miller					    Page 18






       Cook						 User Guide



	    # list of hosts to exclude from arch_hosts lists
	    # for whatever reason.
	    monolith	    # not a development machine ‐ the FTP host
	    namshub	    # developer test station
	    tiamat	    # unreliable configuration
	    locutus	    # Being upgraded
       This is handy for maintenance on machines.  If a	 particular
       machine	needs to be brought down you simply add its name to
       the exclusion file.  Checking its  process  list	 will  tell
       when any currently running remove jobs are done.	 After that
       it  can	safely be brought down without affecting any active
       builds.











































       Peter Miller					    Page 19






       Cook						 User Guide



       4m5.24m	4mInclude24m 4mFile24m 4mDependencies0m

       A significant factor in a cookbook accurately describing the
       dependencies in a program are the include file dependencies.
       There are three methods for doing this in Cook.	 The  first
       is  easily  understandable  but	is too slow to use on large
       projects, the second is a little harder to  understand,	but
       works  well  for large projects.	 The third method is rather
       convoluted, but works well for projects with many  thousands
       of  source  files  and  multiple	 simultaneous architectures
       built within the same source tree.

       The recipes here are merely examples  and  starting  points;
       you  will  almost certainly need to enhance them to suit the
       needs of your projects.	Areas  you  will  need	to  address
       include	(a) the existence of cc ‐I4mpath24m options, (b) the use
       of search_list variable and the [resolve] function, and	(c)
       heterogeneous  development.   The  techniques  also apply to
       other languages, such as Fortran, Pascal and Roff, but  each
       requires a language‐specific include scanning program[2].

       4m5.124m	 4mThe24m 4mManual24m 4mMethod0m

       Well,   actually	 there	are  four  methods,  if	 you  count
       maintaining the dependencies manually.  This has the serious
       defect that humans tend to 4mforget24m to  update  the  cookbook.
       On  a large project not all developers are familiar with the
       workings of Cook, and so they shy  away	from  updating	the
       cookbook.   By  finding	ways to automate include dependency
       processing, we reduce the risk that a developer will  forget
       to  update  the	cookbook,  and	we reduce the risk that the
       cookbook’s dependency information is out‐of‐date.

       Automatic include dependency methods  described	below  have
       flaws,  and  can	 never	replace a human for flexibility and
       domain knowledge.  On the other	hand,  humans  have  better
       things  to  do  with their time than grope files for include
       file dependencies (like write neat software).

       4m5.224m	 4mDebugging24m 4mCookbooks0m

       Before we proceed further, it is worth  spending	 some  time
       covering	 some  of  the methods for debugging your cookbook,
       because small mistakes in implementing the methods below can
       become quite difficult to locate.



       ————————————————————

       2. The 4mc_incl24m program understands Roff, you just need to use
	  the −r option.



       Peter Miller					    Page 20






       Cook						 User Guide



       4m5.2.124m  4mCommand24m 4mLocations0m
       Usually Cook will echo all the commands	it  executes,  just
       before executing them.  If you add the line
	    set tell‐position;
       near  the  top  of your cookbook, Cook will add the filename
       and line number within  the  cookbook  to  each	command	 it
       echoes.	 This  can  be	useful in figuring out which recipe
       Cook actually chose to execute.

       4m5.2.224m  4mPrinting24m 4mStuff0m
       Often you will want to have Cook	 print	various	 pieces	 of
       information.   The  wrong  way  to do it is with the shell’s
       "echo" command
	    echo variable "=" [variable];
       because	this  invokes  another	process	 (which	 can   make
       debugging  parallel  cookbooks  harder)	and  because of the
       optional 4mdata24m 4m...24m 4mdataend24m which can follow commands (see the
       command statement in the language definition,  below).	The
       correct method is to call the "print" function, like this
	    function print [__FILE__]: [__LINE__]: variable "=" [variable];
       Note  the  use  of the __FILE__ and __LINE__ builtins, which
       provide you with cookbook position information.

       4m5.2.324m  4mTrigger24m 4mIngredients0m
       Another useful piece of information is the ingredients which
       caused  Cook  to	 invoke	 a  particular	recipe	body.	The
       following function
	    function say‐why =
	    {
		    if [count [@1]] then
			    @1 = [@1];
		    if [count [@2]] then
			    @2 = [@2];
		    local tt = [target];
		    if [defined targets] then
			    tt = [targets];
		    local t = ;
		    if [in [count [younger]] 0 1 2 3] then
		    {
			    function print [@1] [@2]
				    Building [target]
				    because of [younger];
		    }
		    else
		    {
			    function print [@1] [@2]
				    Building [target] because of
				    [wordlist 1 3 [younger]] et al;
		    }
	    }
       can be inserted at the beginning of a recipe
	    %.o: %.c



       Peter Miller					    Page 21






       Cook						 User Guide



	    {
		    function say‐why [__FILE__] [__LINE__];
		    cc ‐c %.c;
	    }
       to  say	why the recipe was invoked.  This will even include
       dependencies automatically determined by all of the  methods
       which follow, not just those named on the right‐hand‐side of
       the recipe itself.

       4m5.324m	 4mTools0m

       All   of	 the  automated	 include  file	dependency  methods
       described below use the 4mc_incl24m(1) program  included	 in  the
       Cook  distribution.  It has a number of options tailored for
       use with Cook.	For  exact  information	 about	the  4mc_incl0m
       command,	 consult  the on‐line 4mman24m(1) system (it should have
       been installed) or the Cook Reference Manual.

       Other tools are available.  The	commonest  is  to  use	the
       gcc‐M  option, which produces a list of include files on the
       standard output.	 Because the gcc‐M output is aimed  at	GNU
       Make,  you  will	 need an 4mawk24m(1) or 4msed24m(1) script to massage
       the output into a format suitable for Cook.

       4m5.424m	 4mThe24m 4mSmall24m 4mMethod0m

       The easiest way to determine a file’s  include  dependencies
       is within the recipe’s ingredients.
	    %.o: %.c: [collect c_incl ‐api %.c]
	    {
		    cc ‐c %.c;
	    }

       Note  the  second colon − the 4msecond24m set of dependencies are
       only evaluated after Cook has chosen to activate the  recipe
       (based  on the first set).  This does not guarantee that the
       file exists yet (it may have  to	 be  generated	by  4mlex24m  or
       4myacc24m),  which  is  why the ‐‐Absent‐Program‐Ignore option is
       required.

       This method has the advantage  of  simplicity.	It  uses  a
       single  recipe which reads the way recipes usually read, and
       does not contain any unusual constructs.

       There are two problems with this method.	 The first is  that
       it  doesn’t  scale  well.   When there are only a few source
       files, the processing burden of running 4mc_incl24m for every  1m.c0m
       file  every  time Cook is invoked is hardly noticeable.	The
       4mc_incl24m program caches the results of its scans, so	that  is
       can  minimize the length of time taken, and this does help a
       little.	However projects  with	hundreds  or  thousands	 of
       files  find  even  the  cached  performance  an unreasonable



       Peter Miller					    Page 22






       Cook						 User Guide



       burden; it is constantly re‐calculating something which	has
       not changed from one run to the next.

       The  second  problem  is that the 4mc_incl24m program is run when
       the dependency graph is being built, not when  it  is  being
       walked.	 This  means  that the 1m.c 22mfile (or a subordinate 1m.h0m
       file) may have been out‐of‐date at the time.  When the graph
       is walked, it will have been regenerated, and the  two  sets
       of  include  files,  those  determined  by  4mc_incl24m	at graph
       building time, and those seen by 4mcc24m at graph  walking  time,
       may not agree − which may result in compile‐time errors.

       4m5.524m	 4mThe24m 4mLarge24m 4mMethod0m

       For  projects  with large numbers of files, hundreds or even
       thousands, it is necessary to re‐calculate the include  file
       dependencies  only  when a 1m.c 22mfile changes, or a subordinate
       1m.h 22mfile.   Ideally,	 Cook  should  access  this  information
       directly,  rather  than running a program to determine it or
       to fetch it.

       The first task is  to  move  the	 information  which  4mc_incl0m
       caches into a format that Cook can access directly; Cook can
       then  read in this information as it scans the cookbook.	 By
       making a separate ‘‘dependency’’ file for each 1m.c  22mfile,  we
       can  use	 existing  Cook	 mechanisms to describe how to keep
       this file up‐to‐date.

       The dependency file is generated and maintained as follows:
	    %.c.d: %.c
	    {
		    c_incl ‐‐no‐cache %.c
			    "‐‐prefix=’%.o "[target]": %.c’"
			    "‐‐suffix=’set nodefault;’"
			    ‐o [target];
	    }

       This recipe generates a file which contains a  mini‐cookbook
       describing   the	  ingredients  of  the	4mobject24m  file.   The
       dependencies are in terms of the object file because if	any
       of  the 1m.h 22mfiles change, it is the object file which is out‐
       of‐date, not the 1m.c 22mfile.  The mini‐cookbook itself is  also
       described,  so  that  if any of the source files change, the
       mini‐cookbook can be brought up‐to‐date again.

       The recipe for the object file is less complicated  than	 in
       the  previous section, because the mini‐cookbooks supplement
       it:
	    %.o: %.c
	    {
		    cc ‐c %.c;
	    }



       Peter Miller					    Page 23






       Cook						 User Guide



       The only thing missing is how to get the information in	the
       mini‐cookbooks into the main cookbook.  This is done with an
       include directive in the cookbook itself, but a special form
       of  it.	 The  names of the mini‐cookbooks can be determined
       the same way as the names of  the  object  files,  and  this
       allows  the  cookbook  fragments such as the following to be
       written:
	    object_files = [fromto %.c %.o [source_files]];
	    dependency_files = [fromto %.c %.c.d [source_files]];

	    #include‐cooked [dependency_files]

       The #include‐cooked directive  says  to	include	 the  named
       files  (there may be more than one) if the file exist.  Once
       the cookbook (and its includes) have been read in, the files
       included with this directive are checked to see if they	are
       up‐to‐date.   If	 they are not, then they are re‐cooked, and
       then Cook starts	 over  again;  this  time  with	 up‐to‐date
       include dependencies.

       The  advantage  of  the	method	is that if the source files
       don’t   change,	 the   dependency   information	  is	not
       recalculated, this can result in significant savings.  Also,
       no  processes are invoked if nothing has changed, Cook reads
       the  information	  directly.    Because	 file	opens	are
       significantly cheaper than process invocations, this results
       in a significant performance improvement.

       The  disadvantage  of  this  method  is that it is harder to
       describe and harder to implement.  To  the  uninitiated	the
       cookbook looks incomplete and overly complex.

       Another	problem is that if you delete an include file, Cook
       will complain that it is unable	to  derive  the	 dependency
       file because the include file is not present.  Simply delete
       the  dependency file and start again.  To avoid the problem,
       remove references to include  files,  and  re‐build,  before
       deleting	 the include files.  This problem is seen from time
       to time, but does not  present  a  huge	problem	 in  normal
       practice.

       4m5.624m	 4mThe24m 4mCascade24m 4mMethod0m

       When  large  numbers of files are involved, it becomes clear
       that the	 more  popular	include	 files	are  being  scanned
       repeatedly.   This can be un‐necessarily time‐consuming when
       a popular include file is touched, as the  dependency  files
       of all .c files which reference it, even indirectly, must be
       re‐calculated.

       There  is  also a problem when you are attempting to perform
       heterogeneous builds for multiple architectures out  of	the



       Peter Miller					    Page 24






       Cook						 User Guide



       same  sources.	This  is  typically  done  by inserting the
       architecture name into the object file path as a	 directory.
       This   presents	another	 problem:  nominating  all  of	the
       architectures  on  the  left‐hand‐side  of  the	regenerated
       dependency recipes.  Especially if you add another one after
       the  fact  ‐  now  all the existing dependency files must be
       recalculated, merely to add the new architecture.

       An alternative is to scan  each	of  the	 source	 files	and
       include	files  once,  and  request  cook  to  combine  them
       together at build time, rather than at dependence scan time.
       This is done using cascade recipes.  These recipes  nominate
       additional  ingredients (on their right‐hand‐size) if any of
       the files on their left‐hand‐size appears in an	ingredients
       list.
	    cascade foo.c = bar.h;
       This  recipe  says  that	 any  recipe which has 4mfoo.c24m for an
       ingredient, also has 4mbar.h24m for an ingredient.

       This takes care of the heterogeneous case, because while the
       recipes remain specified in a simple manner, 4mviz:0m
	    %1/%0%.o: %0%.c
	    {
		    %1‐gcc ‐o [target] ‐c %0%.c;
	    }
       Any and all of them which compile 4mfoo.c24m will depend on 4mbar.h0m
       from the cascade recipe.	 (This example assumes that you are
       using 4mgcc24m(1) in the usual way, and	that  your  architecture
       names match the GNU target names.)

       The  dependency	files  are generated and maintained in much
       the same way as before, except that you need two: one for .c
       files and one for .h files:
	    %0%.c.d: %0%.c
		    set no‐cascade
	    {
		    c_incl ‐‐no‐cache ‐‐no‐recurs %0%.c
			    "‐‐prefix=’cascade %0%.c =’"
			    "‐‐suffix=’;’"
			    ‐o [target];
	    }
	    %0%.h.d: %0%.h
		    set no‐cascade
	    {
		    c_incl ‐‐no‐cache ‐‐no‐recurs %0%.h
			    "‐‐prefix=’cascade %0%.h =’"
			    "‐‐suffix=’;’"
			    ‐o [target];
	    }
       You will also need to add the .h.d files	 to  the  #include‐
       cooked  lines,  to  ensure they are generated.  If there are
       any generated .c or .h  files,  you  will  need	to  mention



       Peter Miller					    Page 25






       Cook						 User Guide



       these, too.

       4m5.724m	 4mDependencies24m 4mon24m 4mDerived24m 4mFiles0m

       If   the	  relationship	between	 a  target  and	 a  derived
       ingredient appears only in a derived cookbook, it is  likely
       that  a	clean build (solely from primary source files) will
       fail.  It is recommended that relationships such as this	 be
       placed  in  a  primary source cookbook.	Cook looks for such
       dependencies, and will warn you about them.

       An example of this is commonly seen when using the ‐d option
       with 4myacc24m(1).  If you have a separate lexical analyzer  (the
       usual  reason  for  using  ‐d)  it  will need to include the
       generated token definition file.

       When you first add the 4myacc24m(1) grammar definition, Cook will
       generate both the  .c  and  .h  file  from  the	usual  yacc
       recipes.	  It  is  only later, when you have cleaned out all
       derived files (including the dependency files) that you	may
       have  problems.	 Where	is  it	recorded that Cook needs to
       regenerate the token definition file before it can determine
       the include dependencies of  the	 lexical  analyzer?   (They
       were in a .d file which was ‘‘cleaned’’ away.)

       Cook  will  detect  this	 situation  at	the  first possible
       moment, and warn you.  But placing the dependency in a  non‐
       derived	cookbook  (4me.g.24m   Howto.cook)  the	 warning will go
       away, and you will be able to do reliable clean builds.

       If you are convinced that Cook is 4malways24m wrong in your case,
       it is possible to suppress this warning.	 Place the line
	    set no‐include‐cooked‐warning;
       in your main cookbook, and the warning will not be issued.

       Suppressing the warning could lead to problems.	It is often
       better to add the ingredients recipe given in the warning to
       the cookbook, even if  you  think  it  is  redundant.   This
       disables	 a  single instance of the warning, rather than all
       of them − subsequent 4mvalid24m instances will still be reported.
       (Implicit ingredients recipes, rather  than  explicit  ones,
       are a useful alternative if you have a consistent pattern.)

       4m5.824m	 4mRenaming24m 4mInclude24m 4mFiles0m

       A  consistent  problem when you have automatically generated
       include dependencies is that when you move an include  file,
       Cook complains that a required ingredient does not exist.

       The  easiest  way to avoid this is to do a few things before
       you build again after moving the include file.




       Peter Miller					    Page 26






       Cook						 User Guide



	  • Move the include file to the new name.

	  • Where the include file was 4mfrom24m, put a file  containing
	    the line
		 #error "I’m not here"
	    to	make  Cook  happy  (the ingredient will exist), but
	    also have the compiler generate an error if you miss  a
	    reference to it.

	  • Edit all the references to the old include file name to
	    reference the new name.  Don’t worry if you miss one or
	    two, the previous step will catch it.

	  • Rebuild  the  program.   Cook  will	 automatically	re‐
	    calculate all  of  the  include  dependences  and  then
	    recompile.

	  • If	you missed one of the include file references, Cook
	    will  not  complain,  but  the  compiler  will.   (This
	    assumes   you   are	  using	 whole‐project	builds,	 as
	    described in the 4mLarge24m 4mProjects24m chapter.)

	  • Once the program builds cleanly, remove  the  fake	old
	    include  file,  because you know for certain that there
	    are no longer any references.






























       Peter Miller					    Page 27






       Cook						 User Guide



       4m6.24m	4mBuilding24m 4mLarge24m 4mProjects0m

       This chapter covers some of the	issues you may come  across
       in building large projects.  It gives a skeleton for how you
       could use Cook to build a medium‐to‐large projects, and even
       covers some heterogeneous build issues.	It is expected that
       you  will  use  this  chapter  as  a guide; your development
       environment, and the shape of each individual project,  mean
       that you will probably change this to suit your own needs.

       The  material  in  this	chapter uses many, many features of
       Cook.  If you are not familiar with Cook, you  may  want	 to
       read  the  rest	of  this  User	Guide to get a good idea of
       Cook’s features and capabilities.  Even if you are  familiar
       with  Cook,  you may need to refer to the language guide and
       built‐in function descriptions from time to time.

       4m6.124m	 4mWhole24m 4mProject24m 4mBuild0m

       The skeleton given here builds the whole project as a single
       Cook invocation, even when  the	project	 consists  of  tens
       thousands of individual source files.  This is distinct from
       a  build	 process which has Cook recursively invoking itself
       in deeper directories, or a  shell  script  doing  much	the
       same.   Some of the advantages of doing whole project builds
       will be discussed  in  a	 later	section.   For	now  it	 is
       sufficient  to say that experience has shown repeatedly that
       this method does scale to significant projects.

       The first thing about a single build pass is that it happens
       relative to a single fixed place.  The logical place is	the
       top of the project source tree[3].  This works well with the
       4msearch_list24m functionality, mentioned below, which simplifies
       the structure of private work areas.

       4m6.1.124m  4mProject24m 4mDirectory24m 4mStructure0m
       In the examples use in this chapter, the following directory






















