add a .c --> .s rule
[ghc.git] / rules / c-suffix-rules.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 c-suffix-rules
15 # $1 = dir
16 # $2 = distdir
17 # $3 = way
18 # $4 = use GHC (YES/NO)
19
20 # UseGhcForCc is only relevant when not booting from HC files.
21 ifeq "$4 $$(BootingFromHc)" "YES NO"
22
23 $1/$2/build/%.$$($3_osuf) : $1/%.c $$(MKDIRHIER) $$($1_$2_HC_DEP)
24 $$(RM) $$@
25 $$(MKDIRHIER) $$(dir $$@)
26 $$($1_$2_HC) $$($1_$2_$3_GHC_CC_OPTS) -c $$< -o $$@
27
28 $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.c $$($1_$2_HC_DEP)
29 $$(RM) $$@
30 $$($1_$2_HC) $$($1_$2_$3_GHC_CC_OPTS) -c $$< -o $$@
31
32 $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.$$($3_way_)s $$($1_$2_HC_DEP)
33 $$(RM) $$@
34 $$($1_$2_HC) $$($1_$2_$3_GHC_CC_OPTS) -c $$< -o $$@
35
36 $1/$2/build/%.$$($3_osuf) : $1/%.S $$(MKDIRHIER) $$($1_$2_HC_DEP)
37 $$(RM) $$@
38 $$(MKDIRHIER) $$(dir $$@)
39 $$($1_$2_HC) $$($1_$2_$3_GHC_CC_OPTS) -c $$< -o $$@
40
41 $1/$2/build/%.$$($3_way_)s : $1/$2/build/%.c $$($1_$2_HC_DEP)
42 $$(RM) $$@
43 $$($1_$2_HC) $$($1_$2_$3_GHC_CC_OPTS) -S $$< -o $$@
44
45 $1/$2/build/%.$$($3_way_)s : $1/%.c $$($1_$2_HC_DEP)
46 $$(RM) $$@
47 $$($1_$2_HC) $$($1_$2_$3_GHC_CC_OPTS) -S $$< -o $$@
48
49 else
50
51 $1/$2/build/%.$$($3_osuf) : $1/%.c $$(MKDIRHIER)
52 $$(RM) $$@
53 $$(MKDIRHIER) $$(dir $$@)
54 $$(CC) $$($1_$2_$3_ALL_CC_OPTS) -c $$< -o $$@
55
56 $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.c
57 $$(RM) $$@
58 $$(CC) $$($1_$2_$3_ALL_CC_OPTS) -c $$< -o $$@
59
60 $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.$$($3_way_)s
61 $$(RM) $$@
62 $$(AS) $$($1_$2_$3_ALL_AS_OPTS) -o $$@ $$<
63
64 $1/$2/build/%.$$($3_osuf) : $1/%.S $$(MKDIRHIER)
65 $$(RM) $$@
66 $$(MKDIRHIER) $$(dir $$@)
67 $$(CC) $$($1_$2_$3_ALL_CC_OPTS) -c $$< -o $$@
68
69 $1/$2/build/%.$$($3_way_)s : $1/$2/build/%.c
70 $$(RM) $$@
71 $$(CC) $$($1_$2_$3_ALL_CC_OPTS) -S $$< -o $$@
72
73 endif
74
75 endef
76