Add rules for building .cmm files in libraries
authorIan Lynagh <igloo@earth.li>
Thu, 11 Jun 2009 13:40:57 +0000 (13:40 +0000)
committerIan Lynagh <igloo@earth.li>
Thu, 11 Jun 2009 13:40:57 +0000 (13:40 +0000)
ghc.mk
rts/ghc.mk
rules/build-package-way.mk
rules/build-package.mk
rules/cmm-objs.mk [new file with mode: 0644]
rules/cmm-suffix-rules.mk [new file with mode: 0644]
utils/ghc-cabal/ghc-cabal.hs

diff --git a/ghc.mk b/ghc.mk
index b6f0267..d23ee24 100644 (file)
--- 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
 
 # -----------------------------------------------------------------------------
index 7db9976..3074160 100644 (file)
@@ -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
index d2b8499..8a5b07b 100644 (file)
@@ -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
 
index 67d1831..a25a3d2 100644 (file)
@@ -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 (file)
index 0000000..3b1d1d1
--- /dev/null
@@ -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 (file)
index 0000000..6eb9616
--- /dev/null
@@ -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
+
index b5463c5..bd4efc4 100644 (file)
@@ -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