Make the build system use -dynamic-too if both way v and dyn are being built
[ghc.git] / rules / hs-suffix-way-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 hs-suffix-way-rules # args: $1 = dir, $2 = distdir, $3 = way
15
16 ifeq "$3 $$($1_$2_DYNAMIC_TOO)" "dyn YES"
17 # We only want this rule to be used for Haskell sources, not for
18 # e.g. C sources, so we depend on the v_hisuf rather than v_osuf.
19 $1/$2/build/%.$$(dyn_osuf): $1/$2/build/%.$$(v_hisuf)
20 @if [ ! -f $$@ ] ; then \
21 echo "Panic! $$< exists, but $$@ does not."; \
22 exit 1; \
23 fi
24
25 $1/$2/build/%.$$(dyn_osuf)-boot: $1/$2/build/%.$$(v_hisuf)-boot
26 @if [ ! -f $$@ ] ; then \
27 echo "Panic! $$< exists, but $$@ does not."; \
28 exit 1; \
29 fi
30 else
31
32 ifneq "$$(BINDIST)" "YES"
33
34 $1/$2/build/%.$$($3_hcsuf) : $1/$2/build/%.hs $$(LAX_DEPS_FOLLOW) $$($1_$2_HC_DEP)
35 $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -C $$< -o $$@
36
37 $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.hs $$(LAX_DEPS_FOLLOW) $$($1_$2_HC_DEP)
38 $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@ $$(if $$(findstring YES,$$($1_$2_DYNAMIC_TOO)),-dyno $$(addsuffix .$$(dyn_osuf),$$(basename $$@)))
39
40 $1/$2/build/%.$$($3_hcsuf) : $1/$2/build/autogen/%.hs $$(LAX_DEPS_FOLLOW) $$($1_$2_HC_DEP)
41 $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -C $$< -o $$@
42
43 $1/$2/build/%.$$($3_osuf) : $1/$2/build/autogen/%.hs $$(LAX_DEPS_FOLLOW) $$($1_$2_HC_DEP)
44 $$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@ $$(if $$(findstring YES,$$($1_$2_DYNAMIC_TOO)),-dyno $$(addsuffix .$$(dyn_osuf),$$(basename $$@)))
45
46 endif
47
48 $$(foreach dir,$$($1_$2_HS_SRC_DIRS),\
49 $$(eval $$(call hs-suffix-way-rules-srcdir,$1,$2,$3,$$(dir))))
50
51 endif
52
53 endef # hs-suffix-way-rules
54