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 define hs-suffix-rules-srcdir
15 # args: $1 = dir, $2 = distdir, $3 = way, $4 = srcdir
17 # Preprocessing Haskell source
19 ifneq "$$(BootingFromHc)" "YES"
21 $1/$2/build/%.hs : $1/$4/%.ly | $$$$(dir $$$$@)/.
22 "$$(HAPPY)" $$($1_$2_$3_ALL_HAPPY_OPTS) $$< -o $$@
24 $1/$2/build/%.hs : $1/$4/%.y | $$$$(dir $$$$@)/.
25 "$$(HAPPY)" $$($1_$2_$3_ALL_HAPPY_OPTS) $$< -o $$@
27 $1/$2/build/%.hs : $1/$4/%.x | $$$$(dir $$$$@)/.
28 "$$(ALEX)" $$($1_$2_$3_ALL_ALEX_OPTS) $$< -o $$@
30 $1/$2/build/%_hsc.c $1/$2/build/%_hsc.h $1/$2/build/%.hs : $1/$4/%.hsc $$(HSC2HS_INPLACE) | $$$$(dir $$$$@)/.
31 "$$(HSC2HS_INPLACE)" $$($1_$2_$3_ALL_HSC2HS_OPTS) $$< -o $$@
33 # Compiling Haskell source
35 $1/$2/build/%.$$($3_osuf) : $1/$4/%.hs $$($1_$2_HC_DEP)
36 "$$($1_$2_HC)" $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
38 $1/$2/build/%.$$($3_osuf) : $1/$4/%.lhs $$($1_$2_HC_DEP)
39 "$$($1_$2_HC)" $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
41 $1/$2/build/%.$$($3_hcsuf) : $1/$4/%.hs $$($1_$2_HC_DEP)
42 "$$($1_$2_HC)" $$($1_$2_$3_ALL_HC_OPTS) -C $$< -o $$@
44 $1/$2/build/%.$$($3_hcsuf) : $1/$4/%.lhs $$($1_$2_HC_DEP)
45 "$$($1_$2_HC)" $$($1_$2_$3_ALL_HC_OPTS) -C $$< -o $$@
49 # XXX: for some reason these get used in preference to the direct
50 # .hs->.o rule, I don't know why --SDM
52 $1/$2/build/%.$$($3_osuf) : $1/$4/%.hc includes/ghcautoconf.h includes/ghcplatform.h | $$$$(dir $$$$@)/.
53 "$$(CC)" $$($1_$2_$3_ALL_CC_OPTS) -Iincludes -x c -c $$< -o $$@
55 $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.hc includes/ghcautoconf.h includes/ghcplatform.h
56 "$$(CC)" $$($1_$2_$3_ALL_CC_OPTS) -Iincludes -x c -c $$< -o $$@
58 # $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.$$($3_way_)hc
59 # "$$($1_$2_HC)" $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
61 # $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.hc
62 # "$$($1_$2_HC)" $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
64 # $1/$2/build/%.$$($3_way_)s : $1/$2/build/%.$$($3_way_)hc
65 # "$$($1_$2_HC)" $$($1_$2_$3_ALL_HC_OPTS) -S $$< -o $$@
67 # Now the rules for hs-boot files.
69 $1/$2/build/%.hs-boot : $1/$4/%.hs-boot
72 $1/$2/build/%.lhs-boot : $1/$4/%.lhs-boot
75 $1/$2/build/%.$$($3_way_)o-boot : $1/$4/%.hs-boot $$($1_$2_HC_DEP)
76 "$$($1_$2_HC)" $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
78 $1/$2/build/%.$$($3_way_)o-boot : $1/$4/%.lhs-boot $$($1_$2_HC_DEP)
79 "$$($1_$2_HC)" $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
81 ifneq "$$(BootingFromHc)" "YES"
82 # stubs are automatically generated and compiled by GHC
84 $1/$2/build/%_stub.$$($3_osuf): $1/$2/build/%.$$($3_osuf)