-HASKELL_SPLIT_PRE= \
- $(RM) $@ ; if [ ! -d $(basename $@) ]; then mkdir $(basename $@); else \
- find $(basename $@) -name '*.$(way_)o' -print | xargs $(RM) __rm_food ; fi
-HASKELL_SPLIT_POST= touch $@
-HASKELL_PRE_COMPILE=$(patsubst %,$(HASKELL_SPLIT_PRE),$(filter -split-objs,$(HC_OPTS)))
-HASKELL_POST_COMPILE=$(patsubst %,$(HASKELL_SPLIT_POST),$(filter -split-objs,$(HC_OPTS)))
-
-%.$(way_)o : %.hs
- $(HASKELL_PRE_COMPILE)
- $(HC) $(HC_OPTS) -c $< -o $@ -osuf $(subst .,,$(suffix $@))
- $(HASKELL_POST_COMPILE)
-
-%.$(way_)o : %.lhs
- $(HASKELL_PRE_COMPILE)
- $(HC) $(HC_OPTS) -c $< -o $@ -osuf $(subst .,,$(suffix $@))
- $(HASKELL_POST_COMPILE)
-
-%.$(way_)hc : %.lhs
+# Turn off all the Haskell suffix rules if we're booting from .hc
+# files. The file bootstrap.mk contains alternative suffix rules in
+# this case.
+ifneq "$(BootingFromHc)" "YES"
+
+# The $(odir) support is for building GHC, where we need to build three
+# different versions from the same sources. See ghc/compiler/Makefile.
+ifneq "$(odir)" ""
+odir_ = $(odir)/
+else
+odir_ =
+endif
+
+$(odir_)%.$(way_)o : %.hs
+ $(HC_PRE_OPTS)
+ $(HC) $(HC_OPTS) -c $< -o $@ -ohi $(basename $@).$(way_)hi
+ $(HC_POST_OPTS)
+
+$(odir_)%.$(way_)o : %.lhs
+ $(HC_PRE_OPTS)
+ $(HC) $(HC_OPTS) -c $< -o $@ -ohi $(basename $@).$(way_)hi
+ $(HC_POST_OPTS)
+
+$(odir_)%.$(way_)hc : %.lhs