Shift Stream module from dph-base into dph-prim-seq
[packages/dph.git] / ghc.mk
1
2 DPH_DIR = libraries/dph
3
4 # -----------------------------------------------------------------------------
5 # Backend packages.
6 #
7 # These are the packages that we want to compile and install by default.
8 # This doesn't include the dph-examples, dph-test or dph-buildbot, as most
9 # end users won't want these.
10 #
11 DPH_PACKAGES = \
12 dph-base \
13 dph-prim-interface \
14 dph-prim-seq \
15 dph-prim-par \
16 dph-lifted-base \
17 dph-lifted-boxed \
18 dph-lifted-copy \
19 dph-lifted-vseg
20
21
22 # -----------------------------------------------------------------------------
23 # Cleaning rules.
24 #
25 # Generate rules to clean each of the DPH_PACKAGES.
26 #
27 .PHONY: all_$(DPH_DIR)
28 all_$(DPH_DIR) : $(foreach pkg, $(DPH_PACKAGES), all_$(DPH_DIR)/$(pkg))
29
30 clean : clean_$(DPH_DIR)
31 .PHONY: clean_$(DPH_DIR)
32 clean_$(DPH_DIR) : $(foreach pkg, $(DPH_PACKAGES), clean_$(DPH_DIR)/$(pkg))
33 distclean : clean_$(DPH_DIR)
34
35 define dph_package
36 # $1 = package name
37 ifneq "$(CLEANING)" "YES"
38 .PHONY: $(DPH_DIR)/$1
39 $(DPH_DIR)/$1 : all_$(DPH_DIR)/$1
40 endif
41 endef
42
43 $(foreach pkg, $(DPH_PACKAGES), $(eval $(call dph_package,$(pkg))))
44
45
46 # -----------------------------------------------------------------------------
47 # Template Haskell dependencies.
48 #
49 # The dph-lifted-copy package contains some Template Haskell code in TH.Repr.
50 # When compiling modules that use TH.Repr, we will try to run some TH,
51 # which means using the vanilla TH.Repr object files. If we are not
52 # building in the vanilla way then we need to be sure that the vanilla
53 # object files exist. These deps take care of that for us.
54 #
55 define dph_th_deps
56 # $1 = way
57 ifneq "$1" "v"
58 libraries/dph/dph-lifted-copy/dist-install/build/Data/Array/Parallel/Lifted/TH/Repr.$$($1_osuf): libraries/dph/dph-lifted-copy/dist-install/build/Data/Array/Parallel/Lifted/TH/Repr.o
59 libraries/dph/dph-lifted-copy/dist-install/build/Data/Array/Parallel/Lifted/PArray.$${$1_osuf} : libraries/dph/dph-lifted-copy/dist-install/build/Data/Array/Parallel/Lifted/PArray.$${v_osuf}
60 endif
61
62 # The following modules use Template Haskell, or contain ANN pragmas. Both of
63 # these features use compile-time evaluation. During this evaluation we may
64 # need to load the dph-prim-* packages, but if they haven't been build yet the
65 # compilation will die. This results in a build race, where the compilation
66 # will succeed or not depending on whether another make thread has already
67 # completed building the dph-prim-* packages.
68 #
69 # Note that the GHC build system does NOT respect the package dependencies
70 # present in .cabal files. Even though the dph-lifted-*.cabal files list
71 # the dph-prim-* packages as dependencies, these dependencies are silently
72 # ignored.
73 #
74 # The hack-around is to add the following explicit dependencies:
75 # The .o for every module that uses Template Haskell or annotations must
76 # must depend on the dph-prim-* GHCI libraries, so that they can be
77 # loaded at compile time.
78 #
79 # If the dependencies are wrong you will get a build race that can result in
80 # the following error:
81 #
82 # "inplace/bin/ghc-stage2" ... -o .../Data/Array/Parallel/Lifted/PArray.dyn_o
83 # Loading package dph-prim-seq-0.4.0 ... linking ... done.
84 # Loading package dph-prim-par-0.4.0 ... <command line>: can't load .so/.DLL for: HSdph-prim-par-0.4.0-ghc6.13.20091222
85 # (libHSdph-prim-seq-0.4.0-ghc6.13.20091222.so: cannot open shared object file: No such file or directory)
86 #
87
88 # -- modules with TH or ANN in dph-lifted-copy
89 libraries/dph/dph-lifted-copy/dist-install/build/Data/Array/Parallel/Lifted/TH/Repr.$$($1_osuf): \
90 $$(libraries/dph/dph-base_dist-install_GHCI_LIB) \
91 $$(libraries/dph/dph-prim-par_dist-install_GHCI_LIB) \
92 $$(libraries/dph/dph-prim-seq_dist-install_GHCI_LIB) \
93 $$(libraries/dph/dph-prim-interface_dist-install_GHCI_LIB)
94
95 libraries/dph/dph-lifted-copy/dist-install/build/Data/Array/Parallel/PArray/PData.$${$1_osuf} : \
96 $$(libraries/dph/dph-base_dist-install_GHCI_LIB) \
97 $$(libraries/dph/dph-prim-par_dist-install_GHCI_LIB) \
98 $$(libraries/dph/dph-prim-seq_dist-install_GHCI_LIB) \
99 $$(libraries/dph/dph-prim-interface_dist-install_GHCI_LIB)
100
101 libraries/dph/dph-lifted-copy/dist-install/build/Data/Array/Parallel/PArray/Base.$${$1_osuf} : \
102 $$(libraries/dph/dph-base_dist-install_GHCI_LIB) \
103 $$(libraries/dph/dph-prim-par_dist-install_GHCI_LIB) \
104 $$(libraries/dph/dph-prim-seq_dist-install_GHCI_LIB) \
105 $$(libraries/dph/dph-prim-interface_dist-install_GHCI_LIB)
106
107 # -- modules with TH or ANN in dph-lifted-vseg
108 libraries/dph/dph-lifted-vseg/dist-install/build/Data/Array/Parallel/PArray/PData/Base.$${$1_osuf} : \
109 $$(libraries/dph/dph-base_dist-install_GHCI_LIB) \
110 $$(libraries/dph/dph-prim-par_dist-install_GHCI_LIB) \
111 $$(libraries/dph/dph-prim-seq_dist-install_GHCI_LIB) \
112 $$(libraries/dph/dph-prim-interface_dist-install_GHCI_LIB) \
113 $$(libraries/dph/dph-lifted-base_dist-install_GHCI_LIB)
114
115 ifeq "$$(libraries/dph/dph-base_dist-install_GHCI_LIB)" ""
116 $$(error dph_th_deps($1): libraries/dph/dph-base_dist-install_GHCI_LIB not defined!)
117 endif
118
119 endef
120
121 # Instantiate the above dph_th_deps definition for each build way.
122 ifneq "$(CLEANING)" "YES"
123 $(foreach way, $(GhcLibWays), $(eval $(call dph_th_deps,$(way))))
124 endif