Preserve strictness when floating coercions
[ghc-hetmet.git] / rules / build-dependencies.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 build-dependencies # args: $1 = dir, $2 = distdir
15
16 ifeq "$$($1_$2_ghc_ge_609)" "YES"
17 $1_$2_MKDEPENDHS_FLAGS = -include-pkg-deps -dep-makefile $$($1_$2_depfile) $$(foreach way,$$(filter-out v,$$($1_$2_WAYS)),-dep-suffix $$(way))
18 else
19 $1_$2_MKDEPENDHS_FLAGS = -optdep--include-pkg-deps -optdep-f -optdep$$($1_$2_depfile) $$(foreach way,$$(filter-out v,$$($1_$2_WAYS)),-optdep-s -optdep$$(way))
20 endif
21
22 ifneq "$$($1_$2_NO_BUILD_DEPS)" "YES"
23
24 $$($1_$2_depfile) : $$(MKDEPENDC) $$($1_$2_HS_SRCS) $$($1_$2_HS_BOOT_SRCS) $$($1_$2_HC_MK_DEPEND_DEP) $$($1_$2_C_FILES) $$($1_$2_S_FILES) | $$$$(dir $$$$@)/.
25         "$$(RM)" $$(RM_OPTS) $$@.tmp
26         touch $$@.tmp
27 ifneq "$$($1_$2_C_SRCS)$$($1_$2_S_SRCS)" ""
28         "$$(MKDEPENDC)" -f $$($1_$2_depfile).tmp $$($1_MKDEPENDC_OPTS) $$(foreach way,$$($1_WAYS),-s $$(way)) -- $$($1_$2_v_ALL_CC_OPTS) -- $$($1_$2_C_FILES) $$($1_$2_S_FILES)
29         sed -e "s|$1/\([^ :]*o[ :]\)|$1/$2/build/\1|g" -e "s|$$(TOP)/||" -e "s|$2/build/$2/build|$2/build|g" <$$($1_$2_depfile).tmp >$$($1_$2_depfile)
30 endif
31 ifneq "$$($1_$2_HS_SRCS)" ""
32         "$$($1_$2_HC_MK_DEPEND)" -M $$($1_$2_MKDEPENDHS_FLAGS) \
33             $$(filter-out -split-objs, $$($1_$2_v_ALL_HC_OPTS)) \
34             $$($1_$2_HS_SRCS)
35 endif
36         echo "$1_$2_depfile_EXISTS = YES" >> $$@
37 ifneq "$$($1_$2_SLASH_MODS)" ""
38         for dir in $$(sort $$(foreach mod,$$($1_$2_SLASH_MODS),$1/$2/build/$$(dir $$(mod)))); do \
39                 if test ! -d $$$$dir; then mkdir -p $$$$dir; fi \
40         done
41 endif
42
43 endif # $1_$2_NO_BUILD_DEPS
44
45 # Note sed magic above: mkdependC can't do -odir stuff, so we have to
46 # munge the dependencies it generates to refer to the correct targets.
47
48 # Seems as good a place as any to attach the unlit dependency
49 $$($1_$2_depfile) : $$(UNLIT)
50
51 ifneq "$$(NO_INCLUDE_DEPS)" "YES"
52 include $$($1_$2_depfile)
53 else
54 ifeq "$$(DEBUG)" "YES"
55 $$(warning not building dependencies in $1)
56 endif
57 endif
58
59 endef