Merge branch 'master' of http://darcs.haskell.org/ghc
[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 "$$(BINDIST)" "YES"
20
21 ifneq "$$(BootingFromHc)" "YES"
22
23 $1/$2/build/%.hs : $1/$4/%.ly | $$$$(dir $$$$@)/.
24 $$(call cmd,HAPPY) $$($1_$2_$3_ALL_HAPPY_OPTS) $$< -o $$@
25
26 $1/$2/build/%.hs : $1/$4/%.y | $$$$(dir $$$$@)/.
27 $$(call cmd,HAPPY) $$($1_$2_$3_ALL_HAPPY_OPTS) $$< -o $$@
28
29 $1/$2/build/%.hs : $1/$2/build/%.ly | $$$$(dir $$$$@)/.
30 $$(call cmd,HAPPY) $$($1_$2_$3_ALL_HAPPY_OPTS) $$< -o $$@
31
32 $1/$2/build/%.hs : $1/$2/build/%.y | $$$$(dir $$$$@)/.
33 $$(call cmd,HAPPY) $$($1_$2_$3_ALL_HAPPY_OPTS) $$< -o $$@
34
35 $1/$2/build/%.hs : $1/$4/%.x | $$$$(dir $$$$@)/.
36 $$(call cmd,ALEX) $$($1_$2_$3_ALL_ALEX_OPTS) $$< -o $$@
37
38 $1/$2/build/%_hsc.c $1/$2/build/%_hsc.h $1/$2/build/%.hs : $1/$4/%.hsc $$(HSC2HS_INPLACE) | $$$$(dir $$$$@)/.
39 $$(call cmd,HSC2HS_INPLACE) $$($1_$2_$3_ALL_HSC2HS_OPTS) $$< -o $$@
40
41 # Compiling Haskell source
42
43 $1/$2/build/%.$$($3_osuf) : $1/$4/%.hs $$(LAX_DEPS_FOLLOW) $$($1_$2_HC_DEP) $$($1_$2_PKGDATA_DEP)
44 $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
45
46 $1/$2/build/%.$$($3_osuf) : $1/$4/%.lhs $$(LAX_DEPS_FOLLOW) $$($1_$2_HC_DEP) $$($1_$2_PKGDATA_DEP)
47 $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
48
49 $1/$2/build/%.$$($3_hcsuf) : $1/$4/%.hs $$(LAX_DEPS_FOLLOW) $$($1_$2_HC_DEP) $$($1_$2_PKGDATA_DEP)
50 $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -C $$< -o $$@
51
52 $1/$2/build/%.$$($3_hcsuf) : $1/$4/%.lhs $$(LAX_DEPS_FOLLOW) $$($1_$2_HC_DEP) $$($1_$2_PKGDATA_DEP)
53 $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -C $$< -o $$@
54
55 endif
56
57 # XXX: for some reason these get used in preference to the direct
58 # .hs->.o rule, I don't know why --SDM
59
60 $1/$2/build/%.$$($3_osuf) : $1/$4/%.hc includes/ghcautoconf.h includes/ghcplatform.h | $$$$(dir $$$$@)/.
61 $$(call cmd,$1_$2_CC) $$($1_$2_$3_ALL_CC_OPTS) $$(addprefix -I,$$(GHC_INCLUDE_DIRS)) -x c -c $$< -o $$@
62
63 $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.hc includes/ghcautoconf.h includes/ghcplatform.h
64 $$(call cmd,$1_$2_CC) $$($1_$2_$3_ALL_CC_OPTS) $$(addprefix -I,$$(GHC_INCLUDE_DIRS)) -x c -c $$< -o $$@
65
66 # $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.$$($3_way_)hc
67 # $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
68 #
69 # $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.hc
70 # $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
71 #
72 # $1/$2/build/%.$$($3_way_)s : $1/$2/build/%.$$($3_way_)hc
73 # $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -S $$< -o $$@
74
75 # Now the rules for hs-boot files.
76
77 $1/$2/build/%.hs-boot : $1/$4/%.hs-boot
78 "$$(CP)" $$< $$@
79
80 $1/$2/build/%.lhs-boot : $1/$4/%.lhs-boot
81 "$$(CP)" $$< $$@
82
83 $1/$2/build/%.$$($3_way_)o-boot : $1/$4/%.hs-boot $$(LAX_DEPS_FOLLOW) $$($1_$2_HC_DEP) $$($1_$2_PKGDATA_DEP)
84 $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
85
86 $1/$2/build/%.$$($3_way_)o-boot : $1/$4/%.lhs-boot $$(LAX_DEPS_FOLLOW) $$($1_$2_HC_DEP) $$($1_$2_PKGDATA_DEP)
87 $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
88
89 ifneq "$$(BootingFromHc)" "YES"
90 # stubs are automatically generated and compiled by GHC
91
92 $1/$2/build/%_stub.$$($3_osuf): $1/$2/build/%.$$($3_osuf)
93 @:
94 endif
95
96 endif
97
98 endef
99