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

Mar 31, 2009 9:54:06 AM (8 years ago)



  • Building/Architecture/Idiom/NonRecursiveMake

    v1 v1  
     3= Idiom: non-recursive make =
     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[ Recursive Make Considered Harmful]. 
     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`.
     18This gives us the following advantages:
     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.
     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.
     31Doesn't this sacrifice modularity?  No - we can still split the build
     32system into separate files, using GNU '''make''''s `include`.
     34Specific notes related to this idiom:
     36 * Individual directories usually have a `` file which
     37   contains the build instructions for that directory.
     39 * Other parts of the build system are in `mk/*.mk` and `rules/*.mk`.
     41 * The top-level `` file includes all the other `*.mk` files in
     42   the tree.  The top-level `Makefile` invokes '''make''' on ``
     43   (this is the only recursive invocation of '''make'''; see the "phase
     44   ordering" idiom below).