Reorganisation of the source tree
[ghc-hetmet.git] / docs / comm / genesis / makefiles.html
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3   <head>
4     <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
5     <title>The GHC Commentary - Mindboggling Makefiles</title>
6   </head>
7
8   <body BGCOLOR="FFFFFF">
9     <h1>The GHC Commentary - Mindboggling Makefiles</h1>
10     <p>
11       The size and structure of GHC's makefiles makes it quite easy to scream
12       out loud - in pain - during the process of tracking down problems in the
13       make system or when attempting to alter it.  GHC's <a
14         href="http://haskell.cs.yale.edu/ghc/docs/latest/building/building-guide.html">Building
15         Guide</a> has valuable information on <a
16         href="http://haskell.cs.yale.edu/ghc/docs/latest/building/sec-makefile-arch.html">the
17         makefile architecture.</a>
18
19     <h4>A maze of twisty little passages, all alike</h4>
20     <p>
21       The <code>fptools/</code> toplevel and the various project directories
22       contain not only a <code>Makefile</code> each, but there are
23       subdirectories of name <code>mk/</code> at various levels that contain
24       rules, targets, and so on specific to a project - or, in the case of the
25       toplevel, the default rules for the whole system.  Each <code>mk/</code>
26       directory contains a file <code>boilerplate.mk</code> that ties the
27       various other makefiles together.  Files called <code>target.mk</code>,
28       <code>paths.mk</code>, and <code>suffix.mk</code> contain make targets,
29       definitions of variables containing paths, and suffix rules,
30       respectively.
31     <p>
32       One particularly nasty trick used in this hierarchy of makefiles is the
33       way in which the variable <code>$(TOP)</code> is used.  AFAIK,
34       <code>$(TOP)</code> always points to a directory containing an
35       <code>mk/</code> subdirectory; however, it not necessarily points to the
36       toplevel <code>fptools/</code> directory.  For example, within the GHC
37       subtree, <code>$(TOP)</code> points to <code>fptools/ghc/</code>.
38       However, some of the makefiles in <code>fptools/ghc/mk/</code> will then
39       <em>temporarily</em> redefine <code>$(TOP)</code> to point a level
40       higher (i.e., to <code>fptools/</code>) while they are including the
41       toplevel boilerplate.  After that <code>$(TOP)</code> is redefined to
42       whatever value it had before including makefiles from higher up in the
43       hierarchy. 
44
45     <p><small>
46 <!-- hhmts start -->
47 Last modified: Wed Aug 22 16:46:33 GMT Daylight Time 2001
48 <!-- hhmts end -->
49     </small>
50   </body>
51 </html>