[commit: ghc] master: Separate the non-way-specific hs-suffix rules (f136805)

Ian Lynagh igloo at earth.li
Thu Feb 21 17:52:27 CET 2013


Repository : ssh://darcs.haskell.org//srv/darcs/ghc

On branch  : master

http://hackage.haskell.org/trac/ghc/changeset/f1368057296b00dbf7100b4308c8fa3c6844d797

>---------------------------------------------------------------

commit f1368057296b00dbf7100b4308c8fa3c6844d797
Author: Ian Lynagh <ian at well-typed.com>
Date:   Thu Feb 21 15:32:46 2013 +0000

    Separate the non-way-specific hs-suffix rules
    
    This means we don't define them multiple times

>---------------------------------------------------------------

 ghc.mk                              |    1 +
 rules/build-package.mk              |    2 +
 rules/build-prog.mk                 |    2 +
 rules/hs-suffix-rules-srcdir.mk     |   50 +++++++++++++++++++++++++++++++++++
 rules/hs-suffix-way-rules-srcdir.mk |   26 ------------------
 5 files changed, 55 insertions(+), 26 deletions(-)

diff --git a/ghc.mk b/ghc.mk
index 8517b31..c8f9a90 100644
--- a/ghc.mk
+++ b/ghc.mk
@@ -227,6 +227,7 @@ include rules/cmm-objs.mk
 # so we don't make any when cleaning.
 ifneq "$(CLEANING)" "YES"
 
+include rules/hs-suffix-rules-srcdir.mk
 include rules/hs-suffix-way-rules-srcdir.mk
 include rules/hs-suffix-way-rules.mk
 include rules/hi-rule.mk
diff --git a/rules/build-package.mk b/rules/build-package.mk
index 7ee4dd3..46150e3 100644
--- a/rules/build-package.mk
+++ b/rules/build-package.mk
@@ -131,6 +131,8 @@ ifeq "$$(BuildSharedLibs)" "YES"
 $(call c-objs,$1,$2,dyn)
 $(call c-suffix-rules,$1,$2,dyn,YES)
 endif
+$$(foreach dir,$$($1_$2_HS_SRC_DIRS),\
+  $$(eval $$(call hs-suffix-rules-srcdir,$1,$2,$$(dir))))
 
 $(call all-target,$1,all_$1_$2)
 # This give us things like
diff --git a/rules/build-prog.mk b/rules/build-prog.mk
index 1321eac..160ccb1 100644
--- a/rules/build-prog.mk
+++ b/rules/build-prog.mk
@@ -155,6 +155,8 @@ $(call c-suffix-rules,$1,$2,$$($1_$2_PROGRAM_WAY),NO)
 endif
 endif
 
+$$(foreach dir,$$($1_$2_HS_SRC_DIRS),\
+  $$(eval $$(call hs-suffix-rules-srcdir,$1,$2,$$(dir))))
 $(call hs-suffix-way-rules,$1,$2,$$($1_$2_PROGRAM_WAY))
 
 $(call c-objs,$1,$2,$$($1_$2_PROGRAM_WAY))
diff --git a/rules/hs-suffix-rules-srcdir.mk b/rules/hs-suffix-rules-srcdir.mk
new file mode 100644
index 0000000..8ed72af
--- /dev/null
+++ b/rules/hs-suffix-rules-srcdir.mk
@@ -0,0 +1,50 @@
+# -----------------------------------------------------------------------------
+#
+# (c) 2009 The University of Glasgow
+#
+# This file is part of the GHC build system.
+#
+# To understand how the build system works and how to modify it, see
+#      http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture
+#      http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying
+#
+# -----------------------------------------------------------------------------
+
+
+define hs-suffix-rules-srcdir
+# args: $1 = dir,  $2 = distdir, $3 = srcdir
+
+# Preprocessing Haskell source
+
+ifneq "$$(BINDIST)" "YES"
+
+$1/$2/build/%.hs : $1/$3/%.ly | $$$$(dir $$$$@)/.
+	$$(call cmd,HAPPY) $$($1_$2_ALL_HAPPY_OPTS) $$< -o $$@
+
+$1/$2/build/%.hs : $1/$3/%.y | $$$$(dir $$$$@)/.
+	$$(call cmd,HAPPY) $$($1_$2_ALL_HAPPY_OPTS) $$< -o $$@
+
+$1/$2/build/%.hs : $1/$2/build/%.ly | $$$$(dir $$$$@)/.
+	$$(call cmd,HAPPY) $$($1_$2_ALL_HAPPY_OPTS) $$< -o $$@
+
+$1/$2/build/%.hs : $1/$2/build/%.y | $$$$(dir $$$$@)/.
+	$$(call cmd,HAPPY) $$($1_$2_ALL_HAPPY_OPTS) $$< -o $$@
+
+$1/$2/build/%.hs : $1/$3/%.x | $$$$(dir $$$$@)/.
+	$$(call cmd,ALEX) $$($1_$2_ALL_ALEX_OPTS) $$< -o $$@
+
+$1/$2/build/%_hsc.c $1/$2/build/%_hsc.h $1/$2/build/%.hs : $1/$3/%.hsc $$(HSC2HS_INPLACE) | $$$$(dir $$$$@)/.
+	$$(call cmd,HSC2HS_INPLACE) $$($1_$2_ALL_HSC2HS_OPTS) $$< -o $$@
+
+# Now the rules for hs-boot files.
+
+$1/$2/build/%.hs-boot : $1/$3/%.hs-boot
+	"$$(CP)" $$< $$@
+
+$1/$2/build/%.lhs-boot : $1/$3/%.lhs-boot
+	"$$(CP)" $$< $$@
+
+endif
+
+endef
+
diff --git a/rules/hs-suffix-way-rules-srcdir.mk b/rules/hs-suffix-way-rules-srcdir.mk
index bbdd093..5868d23 100644
--- a/rules/hs-suffix-way-rules-srcdir.mk
+++ b/rules/hs-suffix-way-rules-srcdir.mk
@@ -14,28 +14,8 @@
 define hs-suffix-way-rules-srcdir
 # args: $1 = dir,  $2 = distdir, $3 = way, $4 = srcdir
 
-# Preprocessing Haskell source
-
 ifneq "$$(BINDIST)" "YES"
 
-$1/$2/build/%.hs : $1/$4/%.ly | $$$$(dir $$$$@)/.
-	$$(call cmd,HAPPY) $$($1_$2_ALL_HAPPY_OPTS) $$< -o $$@
-
-$1/$2/build/%.hs : $1/$4/%.y | $$$$(dir $$$$@)/.
-	$$(call cmd,HAPPY) $$($1_$2_ALL_HAPPY_OPTS) $$< -o $$@
-
-$1/$2/build/%.hs : $1/$2/build/%.ly | $$$$(dir $$$$@)/.
-	$$(call cmd,HAPPY) $$($1_$2_ALL_HAPPY_OPTS) $$< -o $$@
-
-$1/$2/build/%.hs : $1/$2/build/%.y | $$$$(dir $$$$@)/.
-	$$(call cmd,HAPPY) $$($1_$2_ALL_HAPPY_OPTS) $$< -o $$@
-
-$1/$2/build/%.hs : $1/$4/%.x | $$$$(dir $$$$@)/.
-	$$(call cmd,ALEX) $$($1_$2_ALL_ALEX_OPTS) $$< -o $$@
-
-$1/$2/build/%_hsc.c $1/$2/build/%_hsc.h $1/$2/build/%.hs : $1/$4/%.hsc $$(HSC2HS_INPLACE) | $$$$(dir $$$$@)/.
-	$$(call cmd,HSC2HS_INPLACE) $$($1_$2_ALL_HSC2HS_OPTS) $$< -o $$@
-
 # Compiling Haskell source
 
 $1/$2/build/%.$$($3_osuf) : $1/$4/%.hs $$(LAX_DEPS_FOLLOW) $$($1_$2_HC_DEP) $$($1_$2_PKGDATA_DEP)
@@ -70,12 +50,6 @@ $1/$2/build/%.$$($3_osuf) : $1/$2/build/%.hc includes/ghcautoconf.h includes/ghc
 
 # Now the rules for hs-boot files.
 
-$1/$2/build/%.hs-boot : $1/$4/%.hs-boot
-	"$$(CP)" $$< $$@
-
-$1/$2/build/%.lhs-boot : $1/$4/%.lhs-boot
-	"$$(CP)" $$< $$@
-
 $1/$2/build/%.$$($3_way_)o-boot : $1/$4/%.hs-boot $$(LAX_DEPS_FOLLOW) $$($1_$2_HC_DEP) $$($1_$2_PKGDATA_DEP)
 	$$(call cmd,$1_$2_HC) $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
 





More information about the ghc-commits mailing list