Add Makefile goop for dph-common
authorBen Lippmeier <benl@ouroborus.net>
Tue, 11 Oct 2011 02:15:18 +0000 (13:15 +1100)
committerBen Lippmeier <benl@ouroborus.net>
Tue, 11 Oct 2011 04:11:44 +0000 (15:11 +1100)
ghc.mk
make/config.mk
make/targets/clean.mk
make/targets/packages.mk

diff --git a/ghc.mk b/ghc.mk
index f0cd294..a5f1d15 100644 (file)
--- a/ghc.mk
+++ b/ghc.mk
@@ -1,12 +1,21 @@
-DPH_DIR = libraries/dph
+DPH_DIR  = libraries/dph
 DPH_WAYS = par seq
-DPH_BASE_PACKAGES = dph-base \
-                   dph-prim-interface \
-                   dph-prim-seq \
-                   dph-prim-par
-DPH_PACKAGES = $(DPH_BASE_PACKAGES) \
-               $(foreach way, $(DPH_WAYS), dph-$(way))
 
+# Backend packages that are only compiled in one way.
+DPH_BASE_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"
@@ -16,12 +25,14 @@ $(DPH_DIR)/dph-$1/dph-$1.cabal : $(DPH_DIR)/dph-common/ghc.mk $(DPH_DIR)/dph-com
        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
+       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/ghc.mk      : $(DPH_DIR)/dph-$1/dph-$1.cabal
 $(DPH_DIR)/dph-$1/GNUmakefile : $(DPH_DIR)/dph-$1/dph-$1.cabal
 endif
 endif
@@ -30,6 +41,8 @@ endef
 
 $(foreach way, $(DPH_WAYS), $(eval $(call dph_create,$(way))))
 
+
+# -----------------------------------------------------------------------------
 .PHONY: all_$(DPH_DIR)
 all_$(DPH_DIR) : $(foreach pkg, $(DPH_PACKAGES), all_$(DPH_DIR)/$(pkg))
 
@@ -50,6 +63,8 @@ endef
 $(foreach pkg, $(DPH_PACKAGES), $(eval $(call dph_package,$(pkg))))
 
 
+
+# -----------------------------------------------------------------------------
 # 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
@@ -62,7 +77,7 @@ libraries/dph/dph-$2/dist-install/build/Data/Array/Parallel/Lifted/TH/Repr.$$($1
 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}
 endif
 
-# HACKS ***********************************************************************
+# 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
index aacd3e0..1fb4d3c 100644 (file)
@@ -9,11 +9,11 @@ GHC_PKG         = ghc-pkg
 GHC_FRAMEWORK   = ghc
 
 # -- Backend ------------------------------------------------------------------
-# What unlifted backend to use when compiling the dph-common libraries.
+# What unlifted backend to use when compiling in-place.
 # Options are {par, seq}
 BACKEND         = par
 
-# What lifted frontend to use for vectorised code.
+# What lifted frontend to use when compiling in-place.
 # Options are {copy, vseg}
 FRONTEND        = vseg
 
index c3db440..bad4616 100644 (file)
@@ -27,6 +27,5 @@ clean :
        @rm -Rf dph-lifted-copy-par
        @rm -Rf dph-lifted-vseg-seq
        @rm -Rf dph-lifted-vseg-par
-       
 
        @echo
index 676c55b..c031214 100644 (file)
@@ -8,19 +8,22 @@ dph_packages_backend = \
        dph-prim-par
        
 dph_packages_frontend = \
-       dph-lifted-copy-seq \
-       dph-lifted-copy-par \
+       dph-seq \
+       dph-par \
        dph-lifted-vseg-seq \
        dph-lifted-vseg-par
 
+dph_packages = \
+       $(dph_packages_backend) \
+       $(dph_packages_frontend)
        
-dph_packages_backend_dbs = \
-       $(patsubst %,%/dist/package.conf.inplace,$(dph_packages_backend))
+dph_packages_dbs = \
+       $(patsubst %,%/dist/package.conf.inplace,$(dph_packages))
        
 
 # Build all the packages
 .PHONY            : packages
-packages   : $(dph_packages_backend_dbs)
+packages   : $(dph_packages_dbs)
 
 
 # Unregister all the DPH packages
@@ -31,8 +34,6 @@ unregister :
        done
 
 
-
-
 # Build the backend packages   
 %/dist/package.conf.inplace : %
        @cd $(patsubst %/dist/package.conf.inplace,%,$@) ; \
@@ -45,9 +46,11 @@ unregister :
 
 
 # -- Front end package stubs --------------------------------------------------
-# Create a front-end build package
+# Create a front-end build package stub
 #   Both front-end source packages can be compiled against both backend packages,
-#   for a total of four possible ways.
+#   for a total of four possible ways. We build these by copying the common
+#   cabal file out to a new directory, and setting the source dir field in 
+#   that cabal file to point to the location of the original sources.
 define dph_create_frontend_build
 dph-lifted-$1-$2 :
        @echo "* Creating frontend package $$@"
@@ -61,11 +64,27 @@ dph-lifted-$1-$2 :
        @mv dph-lifted-$1-$2.tmp dph-lifted-$1-$2
 endef
 
-$(eval $(call dph_create_frontend_build,copy,seq))
-$(eval $(call dph_create_frontend_build,copy,par))
 $(eval $(call dph_create_frontend_build,vseg,seq))
 $(eval $(call dph_create_frontend_build,vseg,par))
 
 
+define dph_create_frontend_common
+dph-$1 : dph-common/Setup.hs dph-common/LICENSE dph-common/dph-common.cabal
+       @echo "* Creating frontend package $$@"
+       @rm    -Rf dph-$1 dph-$1.tmp
+       @mkdir -p  dph-$1.tmp
+       @cp dph-common/Setup.hs dph-$1.tmp/Setup.hs
+       @cp dph-common/LICENSE  dph-$1.tmp/LICENSE
+       
+       @sed "s/DPHWAY/$1/g" dph-common/dph-common.cabal \
+               > dph-$1.tmp/dph-$1.cabal
+
+       @mv dph-$1.tmp dph-$1
+endef
+
+$(eval $(call dph_create_frontend_common,seq))
+$(eval $(call dph_create_frontend_common,par))
+
+
 .PHONY : front
 front  : $(dph_packages_frontend)