summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2009-06-11 13:40:57 +0000
committerIan Lynagh <igloo@earth.li>2009-06-11 13:40:57 +0000
commitacf18dd9725b011450ae9098a501abf0ff9e93c7 (patch)
tree54bdd4a965b2b60e08ce67183a4085901d1cc7cb
parent96fff1ba94bd3a21da3fa797816bd6e82e4148ba (diff)
downloadhaskell-acf18dd9725b011450ae9098a501abf0ff9e93c7.tar.gz
Add rules for building .cmm files in libraries
-rw-r--r--ghc.mk6
-rw-r--r--rts/ghc.mk42
-rw-r--r--rules/build-package-way.mk8
-rw-r--r--rules/build-package.mk3
-rw-r--r--rules/cmm-objs.mk16
-rw-r--r--rules/cmm-suffix-rules.mk54
-rw-r--r--utils/ghc-cabal/ghc-cabal.hs1
7 files changed, 84 insertions, 46 deletions
diff --git a/ghc.mk b/ghc.mk
index b6f0267da4..d23ee24760 100644
--- a/ghc.mk
+++ b/ghc.mk
@@ -202,6 +202,7 @@ include rules/c-sources.mk
include rules/includes-sources.mk
include rules/hs-objs.mk
include rules/c-objs.mk
+include rules/cmm-objs.mk
# -----------------------------------------------------------------------------
# Suffix rules
@@ -226,6 +227,11 @@ $(foreach way,$(ALL_WAYS),\
include rules/c-suffix-rules.mk
+#-----------------------------------------------------------------------------
+# CMM-related suffix rules
+
+include rules/cmm-suffix-rules.mk
+
endif
# -----------------------------------------------------------------------------
diff --git a/rts/ghc.mk b/rts/ghc.mk
index 7db99764a1..3074160ea9 100644
--- a/rts/ghc.mk
+++ b/rts/ghc.mk
@@ -83,48 +83,6 @@ rts/libs.depend : $(GHC_PKG_INPLACE)
#-----------------------------------------------------------------------------
# Building one way
-define cmm-suffix-rules
-# $1 = dir
-# $2 = distdir
-# $3 = way
-
-# .cmm files depend on all the .h files, to a first approximation.
-
-ifneq "$$(CLEANING)" "YES"
-
-ifneq "$$(BootingFromHc)" "YES"
-
-$1/$2/build/%.$$($3_way_)o : $1/%.cmm $$(rts_H_FILES) $$($1_$2_HC)
- "$$($1_$2_HC)" $$($1_$2_$3_MOST_HC_OPTS) -c $$< -o $$@
-
-$1/$2/build/%.$$($3_way_)o : $1/$2/build/%.cmm $$(rts_H_FILES) $$($1_$2_HC)
- "$$($1_$2_HC)" $$($1_$2_$3_MOST_HC_OPTS) -c $$< -o $$@
-
-$1/$2/build/%.$$($3_way_)hc : $1/%.cmm $$(rts_H_FILES) $$($1_$2_HC)
- "$$($1_$2_HC)" $$($1_$2_$3_MOST_HC_OPTS) -c $$< -o $$@
-
-$1/$2/build/%.$$($3_way_)hc : $1/$2/build/%.cmm $$(rts_H_FILES) $$($1_$2_HC)
- "$$($1_$2_HC)" $$($1_$2_$3_MOST_HC_OPTS) -c $$< -o $$@
-
-$1/$2/build/%.$$($3_way_)s : $1/%.cmm $$(rts_H_FILES) $$($1_$2_HC)
- "$$($1_$2_HC)" $$($1_$2_$3_MOST_HC_OPTS) -c $$< -o $$@
-
-$1/$2/build/%.$$($3_way_)s : $1/$2/build/%.cmm $$(rts_H_FILES) $$($1_$2_HC)
- "$$($1_$2_HC)" $$($1_$2_$3_MOST_HC_OPTS) -c $$< -o $$@
-
-endif
-
-$1/$2/build/%.$$($3_way_)o : $1/%.hc
- "$$(CC)" $$($1_$2_$3_ALL_CC_OPTS) -Iincludes -x c -c $$< -o $$@
-
-$1/$2/build/%.$$($3_way_)o : $1/$2/build/%.hc
- "$$(CC)" $$($1_$2_$3_ALL_CC_OPTS) -Iincludes -x c -c $$< -o $$@
-
-endif
-
-endef
-
-
define build-rts-way # args: $1 = way
# The per-way CC_OPTS
diff --git a/rules/build-package-way.mk b/rules/build-package-way.mk
index d2b8499086..8a5b07bbc5 100644
--- a/rules/build-package-way.mk
+++ b/rules/build-package-way.mk
@@ -50,13 +50,13 @@ $$($1_$2_$3_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_dyn_C_OBJS) $$($1_$2_dyn_S_OBJS
else
# Build the ordinary .a library
ifeq "$$($1_$2_SplitObjs)" "YES"
-$$($1_$2_$3_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS)
+$$($1_$2_$3_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_v_CMM_OBJS) $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS)
"$$(RM)" $$(RM_OPTS) $$@
- (echo $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS) `$$($1_$2_$3_MKSTUBOBJS)`; find $$(patsubst %.$$($3_osuf),%_split,$$($1_$2_$3_HS_OBJS)) -name '*.$$($3_osuf)' -print) | $$(XARGS) $$(AR) $$(EXTRA_AR_ARGS) $$@ || "$$(RM)" $$(RM_OPTS) $$@
+ (echo $$($1_$2_v_CMM_OBJS) $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS) `$$($1_$2_$3_MKSTUBOBJS)`; find $$(patsubst %.$$($3_osuf),%_split,$$($1_$2_$3_HS_OBJS)) -name '*.$$($3_osuf)' -print) | $$(XARGS) $$(AR) $$(EXTRA_AR_ARGS) $$@ || "$$(RM)" $$(RM_OPTS) $$@
else
-$$($1_$2_$3_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS)
+$$($1_$2_$3_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_v_CMM_OBJS) $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS)
"$$(RM)" $$(RM_OPTS) $$@
- echo $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS) $$($1_$2_$3_HS_OBJS) `$$($1_$2_$3_MKSTUBOBJS)` | $$(XARGS) $$(AR) $$(EXTRA_AR_ARGS) $$@ || "$$(RM)" $$(RM_OPTS) $$@
+ echo $$($1_$2_v_CMM_OBJS) $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS) $$($1_$2_$3_HS_OBJS) `$$($1_$2_$3_MKSTUBOBJS)` | $$(XARGS) $$(AR) $$(EXTRA_AR_ARGS) $$@ || "$$(RM)" $$(RM_OPTS) $$@
endif
endif
diff --git a/rules/build-package.mk b/rules/build-package.mk
index 67d1831eb4..a25a3d2d1e 100644
--- a/rules/build-package.mk
+++ b/rules/build-package.mk
@@ -136,6 +136,9 @@ $(call c-objs,$1,$2,dyn)
$(call c-suffix-rules,$1,$2,dyn,YES)
endif
+$(call cmm-objs,$1,$2,v)
+$(call cmm-suffix-rules,$1,$2,v)
+
# Now generate all the build rules for each way in this directory:
$$(foreach way,$$($1_$2_WAYS),$$(eval $$(call build-package-way,$1,$2,$$(way),$3)))
diff --git a/rules/cmm-objs.mk b/rules/cmm-objs.mk
new file mode 100644
index 0000000000..3b1d1d1378
--- /dev/null
+++ b/rules/cmm-objs.mk
@@ -0,0 +1,16 @@
+# -----------------------------------------------------------------------------
+#
+# (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 cmm-objs # args: $1 = dir, $2 = distdir, $3 = way
+
+$1_$2_$3_CMM_OBJS = $$(patsubst %.cmm,$1/$2/build/%.$$($3_osuf),$$($1_$2_CMM_SRCS))
+endef
diff --git a/rules/cmm-suffix-rules.mk b/rules/cmm-suffix-rules.mk
new file mode 100644
index 0000000000..6eb9616dad
--- /dev/null
+++ b/rules/cmm-suffix-rules.mk
@@ -0,0 +1,54 @@
+# -----------------------------------------------------------------------------
+#
+# (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 cmm-suffix-rules
+# $1 = dir
+# $2 = distdir
+# $3 = way
+
+# .cmm files depend on all the .h files, to a first approximation.
+
+ifneq "$$(CLEANING)" "YES"
+
+ifneq "$$(BootingFromHc)" "YES"
+
+$1/$2/build/%.$$($3_way_)o : $1/%.cmm $$(rts_H_FILES) $$($1_$2_HC)
+ "$$(MKDIRHIER)" $$(dir $$@)
+ "$$($1_$2_HC)" $$($1_$2_$3_MOST_HC_OPTS) -c $$< -o $$@
+
+$1/$2/build/%.$$($3_way_)o : $1/$2/build/%.cmm $$(rts_H_FILES) $$($1_$2_HC)
+ "$$(MKDIRHIER)" $$(dir $$@)
+ "$$($1_$2_HC)" $$($1_$2_$3_MOST_HC_OPTS) -c $$< -o $$@
+
+$1/$2/build/%.$$($3_way_)hc : $1/%.cmm $$(rts_H_FILES) $$($1_$2_HC)
+ "$$(MKDIRHIER)" $$(dir $$@)
+ "$$($1_$2_HC)" $$($1_$2_$3_MOST_HC_OPTS) -c $$< -o $$@
+
+$1/$2/build/%.$$($3_way_)hc : $1/$2/build/%.cmm $$(rts_H_FILES) $$($1_$2_HC)
+ "$$(MKDIRHIER)" $$(dir $$@)
+ "$$($1_$2_HC)" $$($1_$2_$3_MOST_HC_OPTS) -c $$< -o $$@
+
+$1/$2/build/%.$$($3_way_)s : $1/%.cmm $$(rts_H_FILES) $$($1_$2_HC)
+ "$$(MKDIRHIER)" $$(dir $$@)
+ "$$($1_$2_HC)" $$($1_$2_$3_MOST_HC_OPTS) -c $$< -o $$@
+
+$1/$2/build/%.$$($3_way_)s : $1/$2/build/%.cmm $$(rts_H_FILES) $$($1_$2_HC)
+ "$$(MKDIRHIER)" $$(dir $$@)
+ "$$($1_$2_HC)" $$($1_$2_$3_MOST_HC_OPTS) -c $$< -o $$@
+
+endif
+
+endif
+
+endef
+
diff --git a/utils/ghc-cabal/ghc-cabal.hs b/utils/ghc-cabal/ghc-cabal.hs
index b5463c503a..bd4efc4aa8 100644
--- a/utils/ghc-cabal/ghc-cabal.hs
+++ b/utils/ghc-cabal/ghc-cabal.hs
@@ -230,6 +230,7 @@ generate config_args distdir directory
variablePrefix ++ "_EXTRA_LIBRARIES = " ++ unwords (extraLibs bi),
variablePrefix ++ "_EXTRA_LIBDIRS = " ++ unwords (extraLibDirs bi),
variablePrefix ++ "_C_SRCS = " ++ unwords (cSources bi),
+ variablePrefix ++ "_CMM_SRCS = $(addprefix cbits/,$(notdir $(wildcard " ++ directory ++ "/cbits/*.cmm)))",
-- XXX This includes things it shouldn't, like:
-- -odir dist-bootstrapping/build
variablePrefix ++ "_HC_OPTS = " ++ escape (unwords