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


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

--

Legend:

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

    v20 v21  
    6868 * Other parts of the build system are in `mk/*.mk` and `rules/*.mk`.
    6969
    70 == Idiom: stub makefiles ==
     70== Idiom: stub makefiles and standard targets (e.g. "all" and "clean") ==
    7171
    7272It's all very well having a single giant `Makefile` that knows how to
     
    8989}}}
    9090
    91 where `mk/sub-makefile.mk` knows how to recursively invoke '''make'''.  How
    92 does it know what to build?  By convention, for each directory there
    93 is a target `all_`''directory'' (e.g. `all_libraries/base`) which
    94 builds every target in that directory (see "Idiom: the "all" target",
    95 below).
     91where `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
     93We 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:
     94
     95{{{
     96all : all_rts
     97.PHONY all_rts
     98all_rts : ...
     99}}}
     100
     101So you can say
     102  * `make all_rts` (anywhere) to build everything in the RTS directory
     103  * `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''.
     106
     107Other 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`.
    96108
    97109== Idiom: stages ==
     
    337349
    338350
    339 == Idiom: the "all" and "clean" targets ==
    340 
    341 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'', e.g.
    342 
    343 {{{
    344 all : all_rts
    345 .PHONY all_rts
    346 all_rts : ...
    347 }}}
    348 
    349 The `all_rts` target is used by the stub makefile (see earlier stub-makefile idiom) when you say `make` in `rts/`.
    350 
    351 Other 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`.
     351
    352352
    353353== Idiom: no double-colon rules ==