home *** CD-ROM | disk | FTP | other *** search
/ Frozen Fish 1: Amiga / FrozenFish-Apr94.iso / bbs / alib / d1xx / d179 / dmake.lha / Dmake / dmake.doc < prev    next >
Text File  |  1989-02-25  |  11KB  |  326 lines

  1.  
  2.                  DMAKE.DOC
  3.  
  4.                BETA RELEASE V0.5 6-Jan-1989
  5.  
  6.                 *BETA* *BETA* *BETA*
  7.  
  8.     DMake (c)Copyright 1989 by Matthew Dillon, All Rights Reserved
  9.  
  10.  
  11.     NOTE!!    This is an beta version.  I have yet to add all the features
  12.     I will eventually want (like \ line continuation).  In fact, that's
  13.     the whole point of saying 'beta' above ... only people interesting
  14.     in exploring and testing the radical features of DMake should be
  15.     using this release.
  16.  
  17.     You MUST be familar with 'make' to understand these instructions.
  18.     Please read the bug list at the end.
  19.  
  20.     The default file is 'DMakefile'.  Options are:
  21.  
  22.     -a            force all time comparisons to fail
  23.     -f filename        use this instead of DMakefile
  24.     -n            don't actually execute the lines
  25.     -v    (debugging, have fun)
  26.     -d    (debugging, have lots of fun)
  27.     -s            silent .. don't display startup copyright notice
  28.  
  29.                    RADICAL FEATURES
  30.  
  31.     We are all familar with the UNIX make utility.  We all hate it.
  32.     This program is the beginnings of my solution to the problem.
  33.  
  34.     (1) Multiple dependancies on the left:
  35.  
  36.     ram:a.o ram:b.o ram:c.o : a.c b.c c.c
  37.         cc %(right) -o %(left)
  38.  
  39.     (2) Wildcards with virtual reverse mapping (I just made that word
  40.     up).  In the example below, a directory search is used to
  41.     resolve the *.c wildcard in the line "ram:*.o : *.c".  The left
  42.     side is then replaced with the resolved list changing the order
  43.     according to the wildcard specification ( *.c -> ram:*.o ).
  44.     NOTE that the two wildcard specifications have to contain the
  45.     same wildcards in the same order.  NO directory search is made
  46.     for the objects ... the names are generated from the source.
  47.  
  48.     Finally, note the line 'ram:*.o : *.asm'... note that this
  49.     combined with 'ram:*.o : *.c' specifies a joinin of the two
  50.     specs ... the 'ram:*.o' spec in the linker line will contain
  51.     ALL the objects.
  52.  
  53.     $(EXE) : ram:symbols.m ram:*.o
  54.         ln +Q %(ram:*.o) -o $(EXE)
  55.  
  56.     ram:*.o :   *.c
  57.         cc +Iram:symbols.m %(right) -o %(left)
  58.  
  59.     ram:*.o :   *.asm
  60.         as %(right) -o %(left)
  61.  
  62.     ram:symbols.m : include:symbols.m
  63.         copy %(right) %(left)
  64.  
  65.     (3) $ and % variables.  $(SYMBOL) is the standard way to specify
  66.     a symbol name.    %(symbol) is used to macro-insert wildcard
  67.     symbols that appear on the right.  Two special %
  68.     symbols exist:    %(left) contains the stuff on the left and
  69.     %(right) contains the stuff on the right.
  70.  
  71.     Note the difference between these two lines:
  72.  
  73.     all:    ram:*.o
  74.         ln %(ram:*.o) -o c:blah
  75.  
  76.     ram:*.o : *.c
  77.         cc %(*.c) -o %(left)
  78.  
  79.     The difference is that the symbol in the linker line contains
  80.     ALL the objects while the symbol in the compiler line contains
  81.     only the CURRENT .c file being compiled.  The reason is explained
  82.     below, but it ought to be obvious.
  83.  
  84.     Note that only variables on the right of the ':' may be
  85.     specified via their name in a %() macro.  You can refer to
  86.     the left side with %(left), or the entire right side with
  87.     %(right).
  88.  
  89.     (4) Another form that might be useful is this:
  90.  
  91.     ram:*.o : *.c *.h
  92.         cc %(*.c) -o %(left)
  93.  
  94.     Carefully now:    Each .O file is dependant on its .C file.
  95.     Each .O file depends on ALL OF THE .H FILES.  Note that here
  96.     we cannot say cc %(right) because that would include all the
  97.     .h files.
  98.  
  99.  
  100.  
  101.             SPECIFICATION OF DEPENDANCIES
  102.  
  103.  
  104.     The specification of dependancies might seem a bit confusing to
  105.     you.  Lets take a general example:
  106.  
  107.     a b c d  : r s t u
  108.  
  109.     WARNING:    If more than one argument exists on the left, the colon
  110.     usually must be delimited by spaces on both sides a : b instead of a: b
  111.  
  112.     The rule is as follows:  UNTIL one side is exhausted, one item on
  113.     the left is dependant on one item on the right.  That is, a : r,
  114.     b : s, c : t  etc....
  115.  
  116.     If there are EXTRA arguments on the right, each argument is applied
  117.     to ALL THE ARGUMENTS ON THE LEFT.  If I had a 'v' above it would be
  118.     equivalent to  a : v, b : v, c : v, d : v.
  119.  
  120.     EXTRA arguments on the left are disalloweds except for two cases:
  121.  
  122.     blah :            - blah depends on nothing
  123.     a b c d e : x        - a : x, b : x, c : x , d : x, etc....
  124.     *.c : *.h            - WRONG THIS DOES NOT SPECIFY ALL THE
  125.                   .C FILES DEPENDANT ON THE .H FILES!!!
  126.  
  127.     *.o : *.c *.h        - This does, as well as saying that each
  128.                   object depends on its associated .C file
  129.  
  130.     Everything is eventually broken down into four types of dependancies:
  131.  
  132.     wild : wild     the wild on the right is directory searched (unless
  133.             already resolved previously) and a new set of
  134.             dependancies are created matching a single resolved
  135.             file name on the right with its equivalent on the
  136.             left.
  137.  
  138.     wild : single    The wild on the left is directory searched (unless
  139.             already resolved previously) and a new set of
  140.             dependancies are created matching a single resolved
  141.             file name on the left with the single specification
  142.             on the right.
  143.  
  144.     single : wild    The wild on the right is directory searched (unless
  145.             already resolved previously) and a new set of
  146.             dependancies are created matching the single item
  147.             on the left with each resolved name on the right.
  148.  
  149.             NOTE:    ALL of the generated dependancies will be
  150.             resolved before the associated command is run.    The
  151.             associated command is run just once with the
  152.             conglomerate right side stuck together in one line
  153.             (see a sample linker line)
  154.  
  155.     single : single    obvious
  156.  
  157.  
  158.          Common problems:
  159.  
  160.     ram:*.o ram:*.o : /dir2/*.c *.c                RIGHT
  161.         cc %(right) -o %(left)
  162.  
  163.     ram:*.o ram:library.o : /dir2/*.c library.c         RIGHT
  164.         cc %(right) -o %(left)
  165.  
  166.     ram:*.o ram:*.o : /dir2/*.c library.c            WRONG
  167.         cc %(right) -o %(left)
  168.  
  169.     Specifically, a wild : wild dependancy is broken down into many
  170.     single_file : single_file dependancies (after directory searching the
  171.     right hand side), while a  wild : nonwild dependancy means "each of the
  172.     left hand sides depend on the right hand side".. the left hand sides
  173.     will be directory searched and expanded, which is NOT what you want
  174.     here.
  175.  
  176.  
  177.  
  178.  
  179.               EXECUTION ORDER & VARIABLES
  180.  
  181.  
  182.     Whenever possible, a depth first execution order will be taken:
  183.  
  184.     all:    ram:symbols.m   $(OBJS)
  185.     ln "%(OBJS)" -o c:blah
  186.  
  187.     $(OBJS): *.c
  188.     cc +Iram:symbols.m %(right) -o %(left)
  189.  
  190.     ram:symbols.m : include:symbols.m
  191.     copy %(right) %(left)
  192.  
  193.     Here, the symbols are guarenteed to be copied before the objects
  194.     are compiled.  Variables work somewhat like the normal make.  You
  195.     can create variables with '=':
  196.  
  197.     SRCS =  a.c b.c c.c
  198.     OBJS =  $(SRCS:"*.c":"ram:*.o")             (i.e. ram:a.o, ram:b.o ...)
  199.  
  200.     When used in the Makefile, use $(SYMBOL) to get an exact replacement,
  201.     %(SYMBOL) to get an indirect replacement.  $(ENVIROMENTVAR) may be
  202.     used to retrieve an enviroment variable, %(ENVIROMENTVAR) an indirect
  203.     replacement via in enviroment variable:
  204.  
  205.     OBJS = ram:*.o
  206.  
  207.     all: $(OBJS)
  208.     ln %(OBJS) ...
  209.  
  210.     Here, %(OBJS) finds "ram:*.o" then re-applies it to %, giving you
  211.     the object list.  That is:    $(OBJS) -> %(ram:*.o) -> "ram:a.o ram:b.o ..."
  212.  
  213.     The other little item you just saw is global name replacement on
  214.     symbol inclusion:
  215.  
  216.     $(SYMNAME:"oldwild":"newwild")      -if the symbol is a list of
  217.                          files and not a wildcard
  218.  
  219.     %(SYMNAME:"oldwild":"newwild")      -if the symbol is a wildcard
  220.                          on the righthand side of
  221.                          the dependancy.
  222.  
  223.     Causes the symbol to be parsed (space delimits) and each filename
  224.     rung through the grinder.  Each filename is matched with the left
  225.     wildcard and then modified according to the right wildcard.  Here
  226.     are two common DMakefiles:
  227.  
  228.     SRCS =  a.c b.c c.c d.c e.c
  229.     OBJS =  $(SRCS:"*.c":"ram:*.o")
  230.  
  231.     all: $(OBJS)
  232.     ln $(OBJS) -o c:blah
  233.  
  234.     $(OBJS) : $(SRCS)
  235.     cc %(right) -o %(left)
  236.  
  237.                 ---
  238.  
  239.     SRCS =  *.c
  240.     OBJS =  ram:*.o
  241.  
  242.     # note, in the line below you must specify $(SRCS) on the right
  243.     # hand side of you want %(SRCS) to expand properly
  244.  
  245.     all: $(OBJS) $(SRCS)
  246.     ln %(OBJS) -o c:blah
  247.     Echo "%(SRCS)"
  248.  
  249.     $(OBJS) : $(SRCS)
  250.     cc %(right) -o %(left)
  251.  
  252.     arc: $(SRCS) c:blah
  253.     -delete ram:x.arc
  254.     arc a ram:x %(right)
  255.  
  256.     Referencing multiple segments separately is relatively easy.  In some
  257.     cases you cannot use the %(right) symbol because it contains too much:
  258.  
  259.     all: symbols *.o *.lib libraries blah
  260.     ln %(*.o) -l %(*.lib)
  261.  
  262.     Here, %(right) would be "symbols a.o b.o ... x.lib y.lib ... libraries blah"
  263.     To access just the .o's you may specify a % variable containing the
  264.     EXACT wildcard on the right hand side of the dependancy.
  265.  
  266.  
  267.                 ALPHA 'TO-DO'
  268.  
  269.  
  270.     There are probably lots of bugs.  The bigest one now is the lack
  271.     of error detection in dependancies and other sequences ... like
  272.     referencing variables which do not exist.  It won't kill you but
  273.     it might make a mess.
  274.  
  275.     You *can* ^C dmake though ... no problem (I hope), though the
  276.     current directory might change.
  277.  
  278.     DMake is currently somewhat slow due to the amount of computation
  279.     it must do.  You will notice the slowness for a large number of
  280.     sources.  I am not releasing source yet (cause it's a mess and
  281.     might have some commercial value).  You just wouldn't BELIEVE what
  282.     I had to go through!
  283.  
  284.     DMake currently uses Execute() to run commands.  Error codes are
  285.     ignored.  However, you *can* 'cd' ... this is handled internally.
  286.     The original directory can be returned to via 'cd' with no argument.
  287.  
  288.     Since Execute() is used, command lines that are too long get
  289.     chopped.  Eventually there will be no limit (for non BCPL program).
  290.     But, since 'cd' is internal, you can sometimes shorten the link
  291.     line.  In the example below we use the wildcard modification
  292.     feature to modify ram:*.o to just *.o in the link line after having
  293.     CD'd to ram:
  294.  
  295.     OBJS = ram:*.o
  296.     SRCS = *.c
  297.  
  298.     $(EXE): $(OBJS)
  299.         cd ram:
  300.         ln %(right:"ram:*":"*") -lc32 -o $(EXE)
  301.         cd
  302.  
  303.     $(OBJS): $(SRCS)
  304.         cc %(right) -o %(left)
  305.  
  306.     ** TOO LONG LINES:  DMake internally has a limit of 4K for an
  307.     internally generated line (for example, the linker line after
  308.     all the variables have been expanded).    Each file name may be
  309.     up to 128 chars long.  Note that Execute() cannot handle such
  310.     huge lines so if your linker line (the one that is liable to be
  311.     too big) becomes too large, I suggest you generate a link file
  312.     from DMakefile somehow (I usually shell -c echo *.o >blah or use
  313.     various features of LIST .. .giving them an (unexpanded) wildcard
  314.     and letting them do a directory scan to create a file full of
  315.     arguments.  You must be careful in this case of leaving other
  316.     unrelated object modules lying around in your temporary directory.
  317.     I suggest you make a special purpose directory to hold the objects
  318.     (in ram:blah or whereever) to prevent the shell/LIST from picking
  319.     up unwanted files when they do a directory scan.
  320.  
  321.     This solves a basic problem in many make files.  (1) getting back
  322.     to your original directory, (2) putting sources and objects wherever
  323.     you want to without creating a mess of the makefile.
  324.  
  325.  
  326.