Changes between Version 21 and Version 22 of Attic/Building/BuildSystem/New


Ignore:
Timestamp:
Jan 13, 2009 3:44:06 PM (7 years ago)
Author:
simonpj
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Attic/Building/BuildSystem/New

    v21 v22  
    7474just part of the system.  When working on GHC itself, we might want to
    7575build just the compiler, for example.  In the recursive '''make''' system we
    76 would do `cd ghc` and then `make`.  In the non-recursive system we can
     76would do `cd ghc` and then `make`.  In the non-recursive system we could
    7777still achieve this by specifying the target with something like `make
    7878ghc/stage1/build/ghc`, but that's not so convenient.
    7979
    80 Our second idiom therefore is to have a tiny stub `Makefile` in each
     80Our second idiom therefore supports the `cd ghc; make` idiom, just as
     81with recursive make. To achieve this we put tiny stub `Makefile` in each
    8182directory whose job it is to invoke the main `Makefile` specifying the
    8283appropriate target(s) for that directory.  These stub `Makefiles`
     
    8990}}}
    9091
    91 where `mk/sub-makefile.mk` knows how to recursively invoke the giant top-level '''make'''.  This in turn includes the `ghc.mk` from each sub-directory (including the one where you invoked the original `make`).
    92 
    93 We want an `all` target that builds everything, but we also want a way to build individual components (say, everything in `rts/`).  This is achieved by having a separate `all` target for each directory, named `all_`''directory''.  For example in `rts/ghc.mk` we might have this:
     92where `mk/sub-makefile.mk` knows how to recursively invoke the giant top-level '''make'''.  This in turn includes the `ghc.mk` from all sub-directories, presumably including the one where you invoked the original `make`.
     93
     94We want an `all` target that builds everything, but we also want a way to build individual components (say, everything in `rts/`).  This is achieved by having a separate "all" target for each directory, named `all_`''directory''.  For example in `rts/ghc.mk` we might have this:
    9495
    9596{{{
    9697all : all_rts
    9798.PHONY all_rts
    98 all_rts : ...
    99 }}}
    100 
    101 So you can say
     99all_rts : ..dependencies...
     100   ...how to build all_rts...
     101}}}
     102When the top level '''make''' includes all these `ghc.mk` files, it will see that target `all` depends on `all_rts, all_ghc, ...etc...`; so `make all` will make all of these.  But the individual targets are still available.  In particular, you can say
    102103  * `make all_rts` (anywhere) to build everything in the RTS directory
    103104  * `make all` (anywhere) to build everything
    104   * `make`, with no explicit target, makes the default target in the stub `Makefile`,
    105      which in turn makes the target `all_`''dir'', when you are in directory ''dir''.
     105  * `make`, with no explicit target, makes the default target in the current directory's stub `Makefile`, which in turn makes the target `all_`''dir'', where ''dir'' is the current directory.
    106106
    107107Other standard targets such as `clean`, `install`, and so on use the same technique.  There are pre-canned macros to define your "all" and "clean" targets, take a look in `rules/all-target.mk` and `rules/clean-target.mk`.