GHC new build system megapatch
[ghc.git] / rules / hs-suffix-rules-srcdir.mk
1
2 define hs-suffix-rules-srcdir
3 # args: $1 = dir, $2 = distdir, $3 = way, $4 = srcdir
4
5 # Preprocessing Haskell source
6
7 $1/$2/build/%.hs : $1/$4/%.ly $$(MKDIRHIER)
8 $$(MKDIRHIER) $$(dir $$@)
9 $$(HAPPY) $$($1_$2_$3_ALL_HAPPY_OPTS) $$< -o $$@
10
11 $1/$2/build/%.hs : $1/$4/%.y $$(MKDIRHIER)
12 $$(MKDIRHIER) $$(dir $$@)
13 $$(HAPPY) $$($1_$2_$3_ALL_HAPPY_OPTS) $$< -o $$@
14
15 $1/$2/build/%.hs : $1/$4/%.x $$(MKDIRHIER)
16 $$(MKDIRHIER) $$(dir $$@)
17 $$(ALEX) $$($1_$2_$3_ALL_ALEX_OPTS) $$< -o $$@
18
19 $1/$2/build/%_hsc.c $1/$2/build/%_hsc.h $1/$2/build/%.hs : $1/$4/%.hsc $$(HSC2HS_INPLACE)
20 $$(MKDIRHIER) $$(dir $$@)
21 $$(HSC2HS_INPLACE) $$($1_$2_$3_ALL_HSC2HS_OPTS) $$< -o $$@
22 touch $$(patsubst %.hsc,%_hsc.c,$$<)
23
24 # Compiling Haskell source
25
26 $1/$2/build/%.$$($3_osuf) : $1/$4/%.hs $$($1_$2_HC_DEP)
27 $$($1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
28
29 $1/$2/build/%.$$($3_osuf) : $1/$4/%.lhs $$($1_$2_HC_DEP)
30 $$($1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
31
32 $1/$2/build/%.$$($3_hcsuf) : $1/$4/%.hs $$($1_$2_HC_DEP)
33 $$($1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -C $$< -o $$@
34
35 $1/$2/build/%.$$($3_hcsuf) : $1/$4/%.lhs $$($1_$2_HC_DEP)
36 $$($1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -C $$< -o $$@
37
38 # XXX: for some reason these get used in preference to the direct
39 # .hs->.o rule, I don't know why --SDM
40
41 # $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.$$($3_way_)hc
42 # $$($1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
43 #
44 # $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.hc
45 # $$($1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
46 #
47 # $1/$2/build/%.$$($3_way_)s : $1/$2/build/%.$$($3_way_)hc
48 # $$($1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -S $$< -o $$@
49
50 # Now the rules for hs-boot files.
51
52 $1/$2/build/%.hs-boot : $1/$4/%.hs-boot
53 $$(CP) $$< $$@
54
55 $1/$2/build/%.lhs-boot : $1/$4/%.lhs-boot
56 $$(CP) $$< $$@
57
58 $1/$2/build/%.$$($3_way_)o-boot : $1/$4/%.hs-boot $$($1_$2_HC_DEP)
59 $$($1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
60
61 $1/$2/build/%.$$($3_way_)o-boot : $1/$4/%.lhs-boot $$($1_$2_HC_DEP)
62 $$($1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
63
64 # stubs are automatically generated and compiled by GHC
65
66 $1/$2/build/%_stub.$$($3_osuf): $1/$2/build/%.$$($3_osuf)
67 @:
68
69 endef
70