Update GHC build system goop
authorBen Lippmeier <benl@ouroborus.net>
Fri, 11 Nov 2011 06:34:38 +0000 (17:34 +1100)
committerBen Lippmeier <benl@ouroborus.net>
Fri, 11 Nov 2011 06:34:38 +0000 (17:34 +1100)
dph-lifted-boxed/ghc-stage [new file with mode: 0644]
dph-lifted-copy/dph-lifted-copy.cabal [moved from dph-lifted-copy/dph-common.cabal with 84% similarity]
dph-lifted-vseg/ghc-stage [new file with mode: 0644]
ghc-packages
ghc-packages2
ghc.mk

diff --git a/dph-lifted-boxed/ghc-stage b/dph-lifted-boxed/ghc-stage
new file mode 100644 (file)
index 0000000..0cfbf08
--- /dev/null
@@ -0,0 +1 @@
+2
similarity index 84%
rename from dph-lifted-copy/dph-common.cabal
rename to dph-lifted-copy/dph-lifted-copy.cabal
index 3f8b163..a35fda5 100644 (file)
@@ -1,4 +1,4 @@
-Name:           dph-DPHWAY
+Name:           dph-lifted-copy
 Version:        0.5.2.0
 License:        BSD3
 License-File:   LICENSE
@@ -12,11 +12,6 @@ Cabal-Version:  >= 1.6
 Build-Type:     Simple
 
 Library
-  -- This Cabal file is CPPed,
-  --   then put in ../build/dph-lifted-copy-par and ../build/dph-lifted-copy-seq
-  -- We therefore need to point back at the original location for where to find the sources
-  HS-Source-Dirs: ../dph-common
-
   Exposed-Modules:
         Data.Array.Parallel
         Data.Array.Parallel.Lifted
@@ -61,6 +56,4 @@ Library
         random           == 1.0.*,
         template-haskell == 2.6.*,
         dph-base         == 0.5.*,
-        dph-prim-DPHWAY  == 0.5.*
-
-  GHC-Options: -package-name dph-DPHWAY
+        dph-prim-par     == 0.5.*
diff --git a/dph-lifted-vseg/ghc-stage b/dph-lifted-vseg/ghc-stage
new file mode 100644 (file)
index 0000000..0cfbf08
--- /dev/null
@@ -0,0 +1 @@
+2
index a4bb9e2..0ead831 100644 (file)
@@ -2,5 +2,8 @@ dph-base
 dph-prim-interface
 dph-prim-seq
 dph-prim-par
-dph-common
+dph-lifted-boxed
+dph-lifted-copy
+dph-lifted-vseg
+
 
index 86b80dc..c43ddd0 100644 (file)
@@ -2,6 +2,7 @@ dph-base
 dph-prim-interface
 dph-prim-seq
 dph-prim-par
-dph-seq
-dph-par
+dph-lifted-boxed
+dph-lifted-copy
+dph-lifted-vseg
 
diff --git a/ghc.mk b/ghc.mk
index a5f1d15..bde84d2 100644 (file)
--- a/ghc.mk
+++ b/ghc.mk
@@ -1,59 +1,38 @@
+
 DPH_DIR  = libraries/dph
-DPH_WAYS = par seq
 
-# Backend packages that are only compiled in one way.
-DPH_BASE_PACKAGES = \
+# -----------------------------------------------------------------------------
+# Backend packages.
+#
+# These are the packages that we want to compile and install by default.
+# This doesn't include the dph-examples, dph-test or dph-buildbot, as most
+# end users won't want these.
+#
+DPH_PACKAGES = \
        dph-base \
        dph-prim-interface \
        dph-prim-seq \
-       dph-prim-par
-
-# Frontend packages are compiled multiple times against the different backend packages.
-DPH_PACKAGES = \
-       $(DPH_BASE_PACKAGES) \
-        $(foreach way, $(DPH_WAYS), dph-lifted-copy-$(way))
-
-
-# -----------------------------------------------------------------------------
-# Create stubs for the front-end packages.
-define dph_create
-
-ifneq "$(BINDIST)" "YES"
-ifneq "$(CLEANING)" "YES"
-$(DPH_DIR)/dph-$1/dph-$1.cabal : $(DPH_DIR)/dph-common/ghc.mk $(DPH_DIR)/dph-common/GNUmakefile $(DPH_DIR)/dph-common/dph-common.cabal
-       $$(RM) $$(RM_OPTS_REC) $(DPH_DIR)/dph-$1 $(DPH_DIR)/dph-$1.tmp
-       mkdir $(DPH_DIR)/dph-$1.tmp
-       cp $(DPH_DIR)/dph-common/Setup.hs $(DPH_DIR)/dph-$1.tmp/Setup.hs
-       cp $(DPH_DIR)/dph-common/LICENSE $(DPH_DIR)/dph-$1.tmp/LICENSE
-
-       sed "s/DPHWAY/$1/g" $(DPH_DIR)/dph-common/dph-common.cabal > $(DPH_DIR)/dph-$1.tmp/dph-$1.cabal
-       sed "s/common/$1/g" $(DPH_DIR)/dph-common/ghc.mk           > $(DPH_DIR)/dph-$1.tmp/ghc.mk
-       sed "s/common/$1/g" $(DPH_DIR)/dph-common/GNUmakefile      > $(DPH_DIR)/dph-$1.tmp/GNUmakefile
-
-       mv $(DPH_DIR)/dph-$1.tmp $(DPH_DIR)/dph-$1
-
-$(DPH_DIR)/dph-$1/ghc.mk      : $(DPH_DIR)/dph-$1/dph-$1.cabal
-$(DPH_DIR)/dph-$1/GNUmakefile : $(DPH_DIR)/dph-$1/dph-$1.cabal
-endif
-endif
-
-endef
-
-$(foreach way, $(DPH_WAYS), $(eval $(call dph_create,$(way))))
+       dph-prim-par \
+       dph-lifted-boxed \
+       dph-lifted-copy \
+       dph-lifted-vseg 
 
 
 # -----------------------------------------------------------------------------
+# Cleaning rules.
+#
+# Generate rules to clean each of the DPH_PACKAGES.
+#
 .PHONY: all_$(DPH_DIR)
-all_$(DPH_DIR) : $(foreach pkg, $(DPH_PACKAGES), all_$(DPH_DIR)/$(pkg))
+all_$(DPH_DIR)   : $(foreach pkg, $(DPH_PACKAGES), all_$(DPH_DIR)/$(pkg))
 
 clean : clean_$(DPH_DIR)
 .PHONY: clean_$(DPH_DIR)
-clean_$(DPH_DIR) : $(foreach pkg, $(DPH_BASE_PACKAGES), clean_$(DPH_DIR)/$(pkg))
-       $(RM) $(RM_OPTS_REC) $(foreach way, $(DPH_WAYS), $(DPH_DIR)/dph-$(way))
-
-distclean : clean_$(DPH_DIR)
+clean_$(DPH_DIR) : $(foreach pkg, $(DPH_PACKAGES), clean_$(DPH_DIR)/$(pkg))
+distclean        : clean_$(DPH_DIR)
 
 define dph_package
+# $1 = package name
 ifneq "$(CLEANING)" "YES"
 .PHONY: $(DPH_DIR)/$1
 $(DPH_DIR)/$1 : all_$(DPH_DIR)/$1
@@ -63,21 +42,22 @@ endef
 $(foreach pkg, $(DPH_PACKAGES), $(eval $(call dph_package,$(pkg))))
 
 
-
 # -----------------------------------------------------------------------------
+# Template Haskell dependencies.
+# 
+# The dph-lifted-copy package contains some Template Haskell code in TH.Repr.
 # When compiling modules that use TH.Repr, we will try to run some TH,
 # which means using the vanilla TH.Repr object files. If we are not
 # building in the vanilla way then we need to be sure that the vanilla
 # object files exist. These deps take care of that for us.
 #
 define dph_th_deps
-# $1 = way  $2 = par/seq
+# $1 = way
 ifneq "$1" "v"
-libraries/dph/dph-$2/dist-install/build/Data/Array/Parallel/Lifted/TH/Repr.$$($1_osuf): libraries/dph/dph-$2/dist-install/build/Data/Array/Parallel/Lifted/TH/Repr.o
-libraries/dph/dph-$2/dist-install/build/Data/Array/Parallel/Lifted/PArray.$${$1_osuf} : libraries/dph/dph-$2/dist-install/build/Data/Array/Parallel/Lifted/PArray.$${v_osuf}
+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
+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}
 endif
 
-# HACKS -----------------------------------------------------------------------
 # The following modules use Template Haskell, or contain ANN pragmas. Both of
 # these features use compile-time evaluation. During this evaluation we may
 # need to load the dph-prim-* packages, but if they haven't been build yet the
@@ -86,14 +66,14 @@ endif
 # completed building the dph-prim-* packages.
 #
 # Note that the GHC build system does NOT respect the package dependencies
-# present in .cabal files. Even though the dph-common.cabal file lists
+# present in .cabal files. Even though the dph-lifted-*.cabal files list
 # the dph-prim-* packages as dependencies, these dependencies are silently
 # ignored.
 #
 # The hack-around is to add the following explicit dependencies:
-#   The .o for every module that uses Template Haskell or annotations must
-#   must depend on the dph-prim-* GHCI libraries, so that they can be 
-#   loaded at compile time.
+# The .o for every module that uses Template Haskell or annotations must
+# must depend on the dph-prim-* GHCI libraries, so that they can be 
+# loaded at compile time.
 # 
 # If the dependencies are wrong you will get a build race that can result in 
 # the following error:
@@ -103,31 +83,40 @@ endif
 #    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
 #       (libHSdph-prim-seq-0.4.0-ghc6.13.20091222.so: cannot open shared object file: No such file or directory)
 #
-libraries/dph/dph-$2/dist-install/build/Data/Array/Parallel/Lifted/TH/Repr.$$($1_osuf): \
+
+# -- modules with TH or ANN in dph-lifted-copy
+libraries/dph/dph-lifted-copy/dist-install/build/Data/Array/Parallel/Lifted/TH/Repr.$$($1_osuf): \
+       $$(libraries/dph/dph-base_dist-install_GHCI_LIB) \
+       $$(libraries/dph/dph-prim-par_dist-install_GHCI_LIB) \
+       $$(libraries/dph/dph-prim-seq_dist-install_GHCI_LIB) \
+       $$(libraries/dph/dph-prim-interface_dist-install_GHCI_LIB)
+
+libraries/dph/dph-lifted-copy/dist-install/build/Data/Array/Parallel/PArray/PData.$${$1_osuf} : \
        $$(libraries/dph/dph-base_dist-install_GHCI_LIB) \
        $$(libraries/dph/dph-prim-par_dist-install_GHCI_LIB) \
        $$(libraries/dph/dph-prim-seq_dist-install_GHCI_LIB) \
        $$(libraries/dph/dph-prim-interface_dist-install_GHCI_LIB)
 
-libraries/dph/dph-$2/dist-install/build/Data/Array/Parallel/PArray/PData.$${$1_osuf} : \
+libraries/dph/dph-lifted-copy/dist-install/build/Data/Array/Parallel/PArray/Base.$${$1_osuf} : \
        $$(libraries/dph/dph-base_dist-install_GHCI_LIB) \
        $$(libraries/dph/dph-prim-par_dist-install_GHCI_LIB) \
        $$(libraries/dph/dph-prim-seq_dist-install_GHCI_LIB) \
        $$(libraries/dph/dph-prim-interface_dist-install_GHCI_LIB)
 
-libraries/dph/dph-$2/dist-install/build/Data/Array/Parallel/PArray/Base.$${$1_osuf} : \
+# -- modules with TH or ANN in dph-lifted-vseg
+libraries/dph/dph-lifted-vseg/dist-install/build/Data/Array/Parallel/PArray/PData/Base.$${$1_osuf} : \
        $$(libraries/dph/dph-base_dist-install_GHCI_LIB) \
        $$(libraries/dph/dph-prim-par_dist-install_GHCI_LIB) \
        $$(libraries/dph/dph-prim-seq_dist-install_GHCI_LIB) \
        $$(libraries/dph/dph-prim-interface_dist-install_GHCI_LIB)
 
 ifeq "$$(libraries/dph/dph-base_dist-install_GHCI_LIB)" ""
-$$(error dph_th_deps($1,$2): libraries/dph/dph-base_dist-install_GHCI_LIB not defined!)
+$$(error dph_th_deps($1): libraries/dph/dph-base_dist-install_GHCI_LIB not defined!)
 endif
 
 endef
 
+# Instantiate the above dph_th_deps definintion for each build way.
 ifneq "$(CLEANING)" "YES"
-$(foreach way, $(GhcLibWays), $(eval $(call dph_th_deps,$(way),seq)))
-$(foreach way, $(GhcLibWays), $(eval $(call dph_th_deps,$(way),par)))
+$(foreach way, $(GhcLibWays), $(eval $(call dph_th_deps,$(way))))
 endif