Define CABAL in mk/cabal-flags.mk, rather than everywhere we use it
[ghc-hetmet.git] / utils / hsc2hs / Makefile
index 7c34bba..2971779 100644 (file)
@@ -1,98 +1,43 @@
-# -----------------------------------------------------------------------------
-# To compile with nhc98 on unix:
-#     nhc98 -cpp -package base -o hsc2hs-bin Main.hs
 
 TOP=../..
 include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/cabal-flags.mk
 
-INSTALLING=1
+# XXX We would like to turn this on, but Cabal generates paths files
+#     that are not -Wall clean!
+# SRC_HC_OPTS      += -Wall
 
-# This causes libghccompat.a to be used:
-include $(GHC_COMPAT_DIR)/compat.mk
-
-# This is required because libghccompat.a must be built with
-# $(GhcHcOpts) because it is linked to the compiler, and hence
-# we must also build with $(GhcHcOpts) here:
-SRC_HC_OPTS += $(GhcHcOpts) $(GhcStage1HcOpts)
-
-HS_PROG           = hsc2hs-bin
 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
-HS_PROG           = hsc2hs$(exeext)
-endif
-ifeq "$(HOSTPLATFORM)" "i386-unknown-cygwinw32"
-HS_PROG           = hsc2hs$(exeext)
-endif
-
-ifeq "$(ghc_ge_504)" "NO"
-SRC_HC_OPTS +=  -package util
-endif
-
-# Note: Somehow we should pass $(exeext) here, but the history of changes used
-# for calling the C preprocessor via GHC has changed a few times, making a
-# clean solution impossible. So we revert to a hack in Main.hs...
-SRC_HC_OPTS      += -Wall
-
-ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
-INSTALLED_SCRIPT_PROG  = hsc2hs
-endif
-INPLACE_SCRIPT_PROG    = hsc2hs-inplace
-
-ifeq "$(INSTALLING)" "1"
-TOP_PWD        := $(prefix)
-SCRIPT_PROG    =  $(INSTALLED_SCRIPT_PROG)
+INSTALL_FLAGS =
 else
-TOP_PWD        := $(FPTOOLS_TOP_ABS)
-SCRIPT_PROG    =  $(INPLACE_SCRIPT_PROG)
+INSTALL_FLAGS = --enable-shell-wrappers
 endif
 
-ifeq "$(INSTALLING)" "1"
-ifeq "$(BIN_DIST)"   "1"
-HSC2HS_BINDIR=$$\"\"libexecdir
-HSC2HS_DIR=$$\"\"libdir
-HSC2HS_EXTRA=
-else
-HSC2HS_BINDIR=$(libexecdir)
-HSC2HS_DIR=$(libdir)
-HSC2HS_EXTRA=--cc=$(bindir)/ghc-$(ProjectVersion)
-endif # BIN_DIST
-else
-HSC2HS_BINDIR=$(FPTOOLS_TOP_ABS)/$(GHC_HSC2HS_DIR_REL)
-HSC2HS_DIR=$(FPTOOLS_TOP_ABS_PLATFORM)/$(GHC_HSC2HS_DIR_REL)
+boot:
+       $(CABAL) configure --distpref dist-inplace $(INPLACE_CONFIGURE_FLAGS)
+       $(CABAL) build     --distpref dist-inplace $(BUILD_FLAGS)
+       $(CABAL) install   --distpref dist-inplace $(INSTALL_FLAGS)
 
-ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
-extra_flags=$(addprefix --cflag=,$(filter-out -O,$(SRC_CC_OPTS)))
+ifneq "$(NO_INSTALL_HSC2HS)" "YES"
+# XXX
+#all:
+#      $(CABAL) configure --distpref dist-install $(INSTALL_CONFIGURE_FLAGS)
+#      $(CABAL) build     --distpref dist-install $(BUILD_FLAGS)
 endif
 
-HSC2HS_EXTRA="--cc=$(CC) --ld=$(CC) $(extra_flags) --cflag=-D__GLASGOW_HASKELL__=$(ProjectVersionInt) -I$(FPTOOLS_TOP_ABS_PLATFORM)/$(GHC_INCLUDE_DIR_REL)"
-endif
-
-$(SCRIPT_PROG) : Makefile
-$(INSTALLED_SCRIPT_PROG) : $(TOP)/mk/config.mk
-
-SCRIPT_SUBST_VARS = HSC2HS_BINDIR HSC2HS_DIR HS_PROG HSC2HS_EXTRA
+all:
 
-SCRIPT_OBJS=hsc2hs.sh
-INTERP=$(SHELL)
+clean: distclean
 
-ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
-INSTALL_SCRIPTS  += $(SCRIPT_PROG)
-INSTALL_LIBEXECS += $(HS_PROG)
-else
-INSTALL_PROGS    += $(HS_PROG)
-endif
-
-override datadir=$(libdir)
-INSTALL_DATAS += template-hsc.h
+distclean:
+       -$(CABAL) clean --distpref dist-inplace
+       -$(CABAL) clean --distpref dist-install
 
-# -----------------------------------------------------------------------------
-# don't recurse on 'make install'
-#
-ifeq "$(INSTALLING)" "1"
-all :: $(HS_PROG)
-       $(MAKE) INSTALLING=0 BIN_DIST=0 $(MFLAGS) $@
-
-clean distclean maintainer-clean :: 
-       $(MAKE) INSTALLING=0 BIN_DIST=0 $(MFLAGS) $@
-endif
+# XXX fix:
+#binary-dist:
+#      $(INSTALL_DIR)                      $(BIN_DIST_DIR)/utils/hsc2hs
+#      $(INSTALL_DATA)    Makefile         $(BIN_DIST_DIR)/utils/hsc2hs/
+#      $(INSTALL_DATA)    hsc2hs.sh        $(BIN_DIST_DIR)/utils/hsc2hs/
+#      $(INSTALL_DATA)    $(INSTALL_DATAS) $(BIN_DIST_DIR)/utils/hsc2hs/
+#      $(INSTALL_PROGRAM) $(HS_PROG)       $(BIN_DIST_DIR)/utils/hsc2hs/
 
-include $(TOP)/mk/target.mk