next up previous
Next: Configuration File Syntax Up: No Title Previous: Introduction

How It Works

Consider a directory in which a file called etc.config exists in the directory $AST_ROOT/dev/etc. How does GEN_make go about creating a Makefile? To get it started the user types,

   % GEN_make etc.config
The file extension may be omitted. GEN_make then follows the following algorithm,
  1. The class is derived from the name of the configuration file. In this case it is etc.

  2. GEN_make clears its token substitution array. It defines a number of standard tokens which are available for use by all proto-make files. They are listed below (without their delimiting colons), with their values in parentheses where relevant,
    CLASS
    The name of the class ( etc)
    ROOT
    The relative file specification to get to $AST_ROOT ( ../..)
    HERE
    The location of the Makefile relative to $AST_ROOT. ( dev/etc)
    SUBSYS
    The is full name of the subsystem. Same as the HERE token, but with slashes converted to underscores. ( dev_etc)
    MODULE
    The leftmost directory name in the HERE list ( dev)
    MODSUB
    The rightmost directory name in the HERE list ( etc)
    DATE
    The date in 14 Jul 1789 format
    CREATOR
    The version of GEN_make used to create the Makefile
    HOST
    The machine on which the Makefile was made ( xun9)
    PKG
    The package name. Hardwired at the moment ( ASTERIX)
    INDENT
    A joker this one. Essentially a string of spaces whose length is . Useful for formatting recursive Makefile text.

  3. GEN_make loads the value of the AST_MAKE_PATH variable. This is a colon separated list of the directories which will be searched for proto-make files.

  4. The script checks that the class.make and class.base_config files exist somewhere in $AST_MAKE_PATH.

  5. The token translations in the files global.base_config, class.base_config and class.config files are loaded in that order. See the next section for a discussion of the format.

  6. The proto-make file is processed to remove all #include directives -- the file name argument following the #include specifies a file which must lie somewhere in the $AST_MAKE_PATH directory list. This file flattening process is performed for speed's sake for a C tool which lives in the kernel called at_strm.

  7. GEN_make now reads this flattened file looking for occurrances of its tokens. When it finds one it substitutes the token value defined by the configuration files and/or its built in tokens. This process continues until each line is free of tokens. The only further complication is the #foreach directive. This is a control structure within the proto-make file for generating multiple copies of the same bit of make text. An example is,

      #foreach &X& :TASKS:
      $(BIN)/&x&: &x&.f
          alink $? `ast_link_adam`
          mv &x& $@
    	
      #end
    
    This directive expands zero or more times, depending on the number of space separated values in the translation of the token specified as the second argument. The first argument is the loop variable name -- it must be enclosed in ampersands. This apparently silly choice of ampersands and colons was done deliberately to make GEN_make stuff stand out from normal Makefile text, and ensure make will break if you leave any such tokens untranslated. Upper case instances of the loop variable expand to upper case copies of the elements of the second and subsequent arguments, and lower to lower case copies.

    The utility of this directive can only be appreciated after a thorough understanding of the differences of OSF, Solaris and Linux `make' syntax. The above text of a good example of why it useful. The final target is in another directory and we only want to rebuild it if it is out of date with respect to its source code.

    The (entirely) blank line before the #end marker is required to generate correct Makefile source if there is more than one repetition of the directive.

    The #foreach directives cannot be nested.

  8. The output file is renamed to be Makefile. Any pre-existing file of that name is deleted.


next up previous
Next: Configuration File Syntax Up: No Title Previous: Introduction



Asterix
Tue Oct 7 12:02:39 BST 1997