default to installing runhaskell and hsc2hs again, but provide knobs to turn them off
[ghc-hetmet.git] / utils / hsc2hs / Makefile
index d4f5b6c..70d027f 100644 (file)
@@ -33,22 +33,18 @@ INPLACE_HS=hsc2hs-inplace.hs
 INPLACE_PROG=hsc2hs-inplace
 EXCLUDED_SRCS+=$(INPLACE_HS)
 
-# FPTOOLS_TOP_ABS platform uses backslashes, at least on Cygwin, but that
-# will go wrong when we use it in a Haskell string below.
-TOP_ABS=$(subst \\,/,$(FPTOOLS_TOP_ABS_PLATFORM))
-
 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
-extra_flags=--template=$(TOP_ABS)/$(GHC_HSC2HS_DIR_REL)/template-hsc.h $(addprefix --cflag=,$(filter-out -O,$(SRC_CC_OPTS)))
+extra_flags=$(addprefix --cflag=,$(filter-out -O,$(SRC_CC_OPTS)))
 else
 extra_flags=
 endif
 
 $(INPLACE_HS): Makefile $(FPTOOLS_TOP)/mk/config.mk
        echo "import System.Cmd; import System.Environment; import System.Exit" > $@
-       echo "main = getArgs >>= \args -> rawSystem \"$(TOP_ABS)/$(GHC_HSC2HS_DIR_REL)/$(HS_PROG)\" (\"--cc=$(CC)\":\"--ld=$(CC)\"$(patsubst %,:\"%\",$(extra_flags)):\"--cflag=-D__GLASGOW_HASKELL__=$(ProjectVersionInt)\":\"-I$(TOP_ABS)/$(GHC_INCLUDE_DIR_REL)\":args) >>= exitWith" >> $@
+       echo "main = do args <- getArgs; rawSystem \"$(FPTOOLS_TOP_ABS)/$(GHC_HSC2HS_DIR_REL)/$(HS_PROG)\" (\"--template=$(FPTOOLS_TOP_ABS)/$(GHC_HSC2HS_DIR_REL)/template-hsc.h\":\"--cc=$(CC)\":\"--ld=$(CC)\"$(patsubst %,:\"%\",$(extra_flags)):\"--cflag=-D__GLASGOW_HASKELL__=$(ProjectVersionInt)\":\"-I$(FPTOOLS_TOP_ABS)/$(GHC_INCLUDE_DIR_REL)\":\"-I$(FPTOOLS_TOP_ABS)/gmp/gmpbuild\":args) >>= exitWith" >> $@
 
 $(INPLACE_PROG): $(INPLACE_HS)
-       $(GHC) --make $< -o $@
+       $(HC) --make $< -o $@
 
 all :: $(INPLACE_PROG)
 
@@ -58,9 +54,9 @@ 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=$(bindir)/$(LINK_TARGET)
+INSTALLED_SCRIPT=$(DESTDIR)$(bindir)/$(LINK_TARGET)
 install::
        $(RM) -f $(INSTALLED_SCRIPT)
        echo "#!$(SHELL)"                  >> $(INSTALLED_SCRIPT)
@@ -70,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
 
 # -----------------------------------------------------------------------------