Add a dependency of program modules on GHC.TopHandler
authorIan Lynagh <ian@well-typed.com>
Tue, 5 Feb 2013 17:38:43 +0000 (17:38 +0000)
committerIan Lynagh <igloo@earth.li>
Tue, 5 Feb 2013 18:05:11 +0000 (18:05 +0000)
If you were unlucky, the build could fail, e.g.:

utils\mkUserGuidePart\Main.hs:1:1:
    Failed to load interface for `GHC.TopHandler'
    There are files missing in the `base' package,
    try running 'ghc-pkg check'.
    Use -v to see a list of the files searched for.
utils/mkUserGuidePart/ghc.mk:18: recipe for target `utils/mkUserGuidePart/dist/build/Main.o' failed

ghc.mk
rules/add-dependency.mk [new file with mode: 0644]
rules/build-prog.mk

diff --git a/ghc.mk b/ghc.mk
index 8957e60..8bd7859 100644 (file)
--- a/ghc.mk
+++ b/ghc.mk
@@ -155,6 +155,7 @@ endif
 include rules/prof.mk
 include rules/trace.mk
 include rules/library-path.mk
+include rules/add-dependency.mk
 include rules/make-command.mk
 include rules/pretty_commands.mk
 
diff --git a/rules/add-dependency.mk b/rules/add-dependency.mk
new file mode 100644 (file)
index 0000000..d1d8562
--- /dev/null
@@ -0,0 +1,15 @@
+# -----------------------------------------------------------------------------
+#
+# (c) 2010 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 add-dependency
+$1: $2
+endef
index 4111e17..0419c3b 100644 (file)
@@ -246,4 +246,12 @@ endif
 
 $(call dependencies,$1,$2,$3)
 
+# The Main module of a program implicitly depends on GHC.TopHandler
+# so we need to add a dependency for that. As we don't know which
+# module contains Main, we just make all modules in the program
+# depend on it.
+ifneq "$3" "0"
+$$(foreach o,$$($1_$2_$$($1_$2_PROGRAM_WAY)_HS_OBJS),$$(eval $$(call add-dependency,$$o,libraries/base/dist-install/build/GHC/TopHandler.$$($$($1_$2_PROGRAM_WAY)_osuf))))
+endif
+
 endef