Changes between Initial Version and Version 1 of Building/Architecture/Idiom/NonRecursiveMake


Ignore:
Timestamp:
Mar 31, 2009 9:54:06 AM (5 years ago)
Author:
simonmar
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Building/Architecture/Idiom/NonRecursiveMake

    v1 v1  
     1 
     2 
     3= Idiom: non-recursive make = 
     4 
     5Build systems for large projects often use the technique commonly 
     6known as "recursive make", where there is a separate `Makefile` in 
     7each directory that is capable of building that part of the system. 
     8The `Makefile`s may share some common infrastructure and configuration 
     9by using GNU '''make''''s `include` directive; this is exactly what the 
     10previous GHC build system did.  However, this design has a number of 
     11flaws, as described in Peter Miller's 
     12[http://miller.emu.id.au/pmiller/books/rmch/ Recursive Make Considered Harmful].   
     13 
     14The GHC build system adopts the non-recursive '''make''' idiom.  That is, we 
     15never invoke '''make''' from inside a `Makefile`, and the whole build system 
     16is effectively a single giant `Makefile`. 
     17 
     18This gives us the following advantages: 
     19 
     20 * Specifying dependencies between different parts of the tree is 
     21   easy.  In this way, we can accurately specify many dependencies 
     22   that we could not in the old recursive-make system.  This makes it much more likely that when you say "make" 
     23   after modifying parts of the tree or pulling new patches, 
     24   the build system will bring everything up-to-date in the correct order, and leave you with a working 
     25   system. 
     26 
     27 * More parallelism: dependencies are more fine-grained, and there 
     28   is no need to build separate parts of the system in sequence, so 
     29   the overall effect is that we have more parallelism in the build. 
     30 
     31Doesn't this sacrifice modularity?  No - we can still split the build 
     32system into separate files, using GNU '''make''''s `include`. 
     33 
     34Specific notes related to this idiom: 
     35 
     36 * Individual directories usually have a `ghc.mk` file which 
     37   contains the build instructions for that directory. 
     38 
     39 * Other parts of the build system are in `mk/*.mk` and `rules/*.mk`. 
     40 
     41 * The top-level `ghc.mk` file includes all the other `*.mk` files in 
     42   the tree.  The top-level `Makefile` invokes '''make''' on `ghc.mk` 
     43   (this is the only recursive invocation of '''make'''; see the "phase 
     44   ordering" idiom below).