default to installing runhaskell and hsc2hs again, but provide knobs to turn them off
authorSimon Marlow <simonmar@microsoft.com>
Thu, 25 Oct 2007 08:42:22 +0000 (08:42 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Thu, 25 Oct 2007 08:42:22 +0000 (08:42 +0000)
ghc.spec.in
mk/config.mk.in
utils/hsc2hs/Makefile
utils/runghc/Makefile

index 331fdd4..5d3fa1f 100644 (file)
@@ -84,6 +84,12 @@ needed.
 %build
 test -f configure || sh boot
 ./configure --prefix=%{_prefix} --mandir=%{_mandir}
+
+# Don't install these tools, we'll use update-alternatives below.
+touch mk/build.mk
+echo "NO_INSTALL_RUNHASKELL=YES" >>mk/build.mk
+echo "NO_INSTALL_HSC2HS=YES" >>mk/build.mk
+
 make %{?jobs:-j%jobs}
 make html
 # Alas, we don't pass make options/arguments down to "libraries", so let's redo make here...
index eaefe4a..3c0b312 100644 (file)
@@ -641,6 +641,19 @@ INSTALL_HEADER  = $(INSTALL) -m 644
 INSTALL_MAN     = $(INSTALL) -m 644
 INSTALL_DIR     = $(MKDIRHIER)
 
+#
+# runhaskell and hsc2hs are special, in that other compilers besides
+# GHC might provide them.  Systems with a package manager often come
+# with tools to manage this kind of clash, e.g. RPM's
+# update-alternatives.  When building a distribution for such a system,
+# we recommend setting both of the following to 'YES'.
+#
+# NO_INSTALL_RUNHASKELL = YES
+# NO_INSTALL_HSC2HS     = YES
+#
+# NB. we use negative tests here because for binary-distributions we cannot
+# test build-time variables at install-time, so they must default to on.
+
 # -----------------------------------------------------------------------------
 # Utilities programs: flags 
 
index b9bcaf1..70d027f 100644 (file)
@@ -54,7 +54,7 @@ ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
 INSTALL_PROGS    += $(HS_PROG)
 else
 INSTALL_LIBEXECS += $(HS_PROG)
-LINK = hsc2hs
+LINK = hsc2hs-ghc
 LINK_TARGET = $(LINK)-$(ProjectVersion)
 INSTALLED_SCRIPT=$(DESTDIR)$(bindir)/$(LINK_TARGET)
 install::
@@ -66,6 +66,11 @@ install::
        echo "HSC2HS_EXTRA="               >> $(INSTALLED_SCRIPT)
        cat hsc2hs.sh                      >> $(INSTALLED_SCRIPT)
        $(EXECUTABLE_FILE) $(INSTALLED_SCRIPT)
+
+ifneq "$(NO_INSTALL_HSC2HS)" "YES"
+install::
+       $(CP) $(INSTALLED_SCRIPT) $(DESTDIR)/$(bindir)/hsc2hs
+endif
 endif
 
 # -----------------------------------------------------------------------------
index 7ea6c09..16e9724 100644 (file)
@@ -16,9 +16,22 @@ include $(GHC_COMPAT_DIR)/compat.mk
 SRC_HC_OPTS += $(GhcHcOpts) $(GhcStage1HcOpts)
 SRC_HC_OPTS += -Wall
 
-binary-dist:
+RUNHASKELL_PROG = runhaskell$(exeext)
+all :: $(RUNHASKELL_PROG)
+
+$(RUNHASKELL_PROG) : $(HS_PROG)
+       $(CP) $< $(RUNHASKELL_PROG)
+
+CLEAN_FILES += $(RUNHASKELL_PROG)
+
+ifneq "$(NO_INSTALL_RUNHASKELL)" "YES"
+INSTALL_PROGS += $(RUNHASKELL_PROG)
+endif
+
+binary-dist::
        $(INSTALL_DIR)                $(BIN_DIST_DIR)/utils/runghc
        $(INSTALL_DATA)    Makefile   $(BIN_DIST_DIR)/utils/runghc/
        $(INSTALL_PROGRAM) $(HS_PROG) $(BIN_DIST_DIR)/utils/runghc/
+       $(INSTALL_PROGRAM) $(RUNHASKELL_PROG) $(BIN_DIST_DIR)/utils/runghc/
 
 include $(TOP)/mk/target.mk