remove "touch %_hsc.c" - what was it for?
[ghc.git] / rules / hs-suffix-rules-srcdir.mk
1 # -----------------------------------------------------------------------------
2 #
3 # (c) 2009 The University of Glasgow
4 #
5 # This file is part of the GHC build system.
6 #
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
10 #
11 # -----------------------------------------------------------------------------
12
13
14 define hs-suffix-rules-srcdir
15 # args: $1 = dir, $2 = distdir, $3 = way, $4 = srcdir
16
17 # Preprocessing Haskell source
18
19 ifneq "$$(BootingFromHc)" "YES"
20
21 $1/$2/build/%.hs : $1/$4/%.ly $$(MKDIRHIER)
22 "$$(MKDIRHIER)" $$(dir $$@)
23 "$$(HAPPY)" $$($1_$2_$3_ALL_HAPPY_OPTS) $$< -o $$@
24
25 $1/$2/build/%.hs : $1/$4/%.y $$(MKDIRHIER)
26 "$$(MKDIRHIER)" $$(dir $$@)
27 "$$(HAPPY)" $$($1_$2_$3_ALL_HAPPY_OPTS) $$< -o $$@
28
29 $1/$2/build/%.hs : $1/$4/%.x $$(MKDIRHIER)
30 "$$(MKDIRHIER)" $$(dir $$@)
31 "$$(ALEX)" $$($1_$2_$3_ALL_ALEX_OPTS) $$< -o $$@
32
33 $1/$2/build/%_hsc.c $1/$2/build/%_hsc.h $1/$2/build/%.hs : $1/$4/%.hsc $$(HSC2HS_INPLACE)
34 "$$(MKDIRHIER)" $$(dir $$@)
35 "$$(HSC2HS_INPLACE)" $$($1_$2_$3_ALL_HSC2HS_OPTS) $$< -o $$@
36
37 # Compiling Haskell source
38
39 $1/$2/build/%.$$($3_osuf) : $1/$4/%.hs $$($1_$2_HC_DEP)
40 "$$($1_$2_HC)" $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
41
42 $1/$2/build/%.$$($3_osuf) : $1/$4/%.lhs $$($1_$2_HC_DEP)
43 "$$($1_$2_HC)" $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
44
45 $1/$2/build/%.$$($3_hcsuf) : $1/$4/%.hs $$($1_$2_HC_DEP)
46 "$$($1_$2_HC)" $$($1_$2_$3_ALL_HC_OPTS) -C $$< -o $$@
47
48 $1/$2/build/%.$$($3_hcsuf) : $1/$4/%.lhs $$($1_$2_HC_DEP)
49 "$$($1_$2_HC)" $$($1_$2_$3_ALL_HC_OPTS) -C $$< -o $$@
50
51 endif
52
53 # XXX: for some reason these get used in preference to the direct
54 # .hs->.o rule, I don't know why --SDM
55
56 $1/$2/build/%.$$($3_osuf) : $1/$4/%.hc includes/ghcautoconf.h includes/ghcplatform.h $$(MKDIRHIER)
57 "$$(MKDIRHIER)" $$(dir $$@)
58 "$$(CC)" $$($1_$2_$3_ALL_CC_OPTS) -Iincludes -x c -c $$< -o $$@
59
60 $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.hc includes/ghcautoconf.h includes/ghcplatform.h
61 "$$(CC)" $$($1_$2_$3_ALL_CC_OPTS) -Iincludes -x c -c $$< -o $$@
62
63 # $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.$$($3_way_)hc
64 # "$$($1_$2_HC)" $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
65 #
66 # $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.hc
67 # "$$($1_$2_HC)" $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
68 #
69 # $1/$2/build/%.$$($3_way_)s : $1/$2/build/%.$$($3_way_)hc
70 # "$$($1_$2_HC)" $$($1_$2_$3_ALL_HC_OPTS) -S $$< -o $$@
71
72 # Now the rules for hs-boot files.
73
74 $1/$2/build/%.hs-boot : $1/$4/%.hs-boot
75 "$$(CP)" $$< $$@
76
77 $1/$2/build/%.lhs-boot : $1/$4/%.lhs-boot
78 "$$(CP)" $$< $$@
79
80 $1/$2/build/%.$$($3_way_)o-boot : $1/$4/%.hs-boot $$($1_$2_HC_DEP)
81 "$$($1_$2_HC)" $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
82
83 $1/$2/build/%.$$($3_way_)o-boot : $1/$4/%.lhs-boot $$($1_$2_HC_DEP)
84 "$$($1_$2_HC)" $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
85
86 ifneq "$$(BootingFromHc)" "YES"
87 # stubs are automatically generated and compiled by GHC
88
89 $1/$2/build/%_stub.$$($3_osuf): $1/$2/build/%.$$($3_osuf)
90 @:
91 endif
92
93 endef
94