1
# -----------------------------------------------------------------------------
3
# (c) 2009 The University of Glasgow
5
# This file is part of the GHC build system.
7
# To understand how the build system works and how to modify it, see
8
# http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture
9
# http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying
11
# -----------------------------------------------------------------------------
14
# Here's an interesting rule!
16
# The .hi file may or may not change when we compile the corresponding
17
# .hs file. If GHC figures out that the .hi file has not changed, it
18
# doesn't touch it. This is a useful optimisation, because it means
19
# some modules may not get recompiled if the .hi files of the modules
20
# they depend on have not changed.
23
# http://hackage.haskell.org/trac/ghc/wiki/Commentary/Compiler/RecompilationAvoidance
25
# So how do we express this dependency to make? The exact form of
26
# this rule is quite fragile. Here are some versions that don't work
30
# @if [ ! -f $@ ] ; then \
31
# echo Panic! $< exists, but $@ does not.; \
35
# This version adds a useful sanity check; but it is also expensive on
36
# Windows where spawning a shell takes a while (about 0.3s). We'd
37
# like to avoid the shell if necessary. This also hides the message
38
# "nothing to be done for 'all'", since make thinks it has actually done
43
# This version doesn't work: GNU make knows it has't done anything to
44
# update the .hi file, so even if the .o file has been updated, it
45
# won't rebuild anything that depends on the .hi file. So you might
46
# think a more correct way is to change the .hs rule:
51
# this says "compiling %.hs updates both %.hi and %.o", but that's not
52
# true, since compiling the .hs file might not update the .hi file, if
53
# the .hi file didn't change. And if we use this version, then make
54
# will keep trying to rebuild %.hi if it is out of date with respect
57
# Using this form seems to be the best compromise:
61
# the ';' at the end signifies an "empty command" (see the GNU make
62
# documentation). An empty command is enough to get GNU make to think
63
# it has updated %.hi, but without actually spawning a shell to do so.
65
define hi-rule # $1 = way
67
%.$$($1_hisuf) : %.$$($1_osuf) ;
69
%.$$($1_way_)hi-boot : %.$$($1_way_)o-boot ;