Add a header to all build system files:
[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 $1/$2/build/%.hs : $1/$4/%.ly $$(MKDIRHIER)
20 $$(MKDIRHIER) $$(dir $$@)
21 $$(HAPPY) $$($1_$2_$3_ALL_HAPPY_OPTS) $$< -o $$@
22
23 $1/$2/build/%.hs : $1/$4/%.y $$(MKDIRHIER)
24 $$(MKDIRHIER) $$(dir $$@)
25 $$(HAPPY) $$($1_$2_$3_ALL_HAPPY_OPTS) $$< -o $$@
26
27 $1/$2/build/%.hs : $1/$4/%.x $$(MKDIRHIER)
28 $$(MKDIRHIER) $$(dir $$@)
29 $$(ALEX) $$($1_$2_$3_ALL_ALEX_OPTS) $$< -o $$@
30
31 $1/$2/build/%_hsc.c $1/$2/build/%_hsc.h $1/$2/build/%.hs : $1/$4/%.hsc $$(HSC2HS_INPLACE)
32 $$(MKDIRHIER) $$(dir $$@)
33 $$(HSC2HS_INPLACE) $$($1_$2_$3_ALL_HSC2HS_OPTS) $$< -o $$@
34 touch $$(patsubst %.hsc,%_hsc.c,$$<)
35
36 # Compiling Haskell source
37
38 $1/$2/build/%.$$($3_osuf) : $1/$4/%.hs $$($1_$2_HC_DEP)
39 $$($1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
40
41 $1/$2/build/%.$$($3_osuf) : $1/$4/%.lhs $$($1_$2_HC_DEP)
42 $$($1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
43
44 $1/$2/build/%.$$($3_hcsuf) : $1/$4/%.hs $$($1_$2_HC_DEP)
45 $$($1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -C $$< -o $$@
46
47 $1/$2/build/%.$$($3_hcsuf) : $1/$4/%.lhs $$($1_$2_HC_DEP)
48 $$($1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -C $$< -o $$@
49
50 # XXX: for some reason these get used in preference to the direct
51 # .hs->.o rule, I don't know why --SDM
52
53 # $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.$$($3_way_)hc
54 # $$($1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
55 #
56 # $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.hc
57 # $$($1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
58 #
59 # $1/$2/build/%.$$($3_way_)s : $1/$2/build/%.$$($3_way_)hc
60 # $$($1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -S $$< -o $$@
61
62 # Now the rules for hs-boot files.
63
64 $1/$2/build/%.hs-boot : $1/$4/%.hs-boot
65 $$(CP) $$< $$@
66
67 $1/$2/build/%.lhs-boot : $1/$4/%.lhs-boot
68 $$(CP) $$< $$@
69
70 $1/$2/build/%.$$($3_way_)o-boot : $1/$4/%.hs-boot $$($1_$2_HC_DEP)
71 $$($1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
72
73 $1/$2/build/%.$$($3_way_)o-boot : $1/$4/%.lhs-boot $$($1_$2_HC_DEP)
74 $$($1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
75
76 # stubs are automatically generated and compiled by GHC
77
78 $1/$2/build/%_stub.$$($3_osuf): $1/$2/build/%.$$($3_osuf)
79 @:
80
81 endef
82