1 # -----------------------------------------------------------------------------
2 # $Id: Makefile,v 1.38 2003/06/04 15:18:30 panne Exp $
5 include $(TOP)/mk/boilerplate.mk
7 CURRENT_DIR=ghc/utils/hsc2hs
8 INCLUDE_DIR=ghc/includes
13 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
14 HS_PROG = hsc2hs$(exeext)
16 ifeq "$(HOSTPLATFORM)" "i386-unknown-cygwinw32"
17 HS_PROG = hsc2hs$(exeext)
20 ghc_ge_504 = $(shell if (test $(GhcCanonVersion) -ge 504); then echo YES; else echo NO; fi)
22 ifeq "$(ghc_ge_504)" "NO"
23 SRC_HC_OPTS += -package util
28 ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
29 INSTALLED_SCRIPT_PROG = hsc2hs
31 INPLACE_SCRIPT_PROG = hsc2hs-inplace
33 ifeq "$(INSTALLING)" "1"
35 SCRIPT_PROG = $(INSTALLED_SCRIPT_PROG)
37 TOP_PWD := $(FPTOOLS_TOP_ABS)
38 SCRIPT_PROG = $(INPLACE_SCRIPT_PROG)
41 ifeq "$(INSTALLING)" "1"
42 ifeq "$(BIN_DIST)" "1"
43 HSC2HS_BINDIR=$$\"\"libexecdir
44 HSC2HS_DIR=$$\"\"libdir
47 HSC2HS_BINDIR=$(libexecdir)
49 HSC2HS_EXTRA=--cc=$(bindir)/ghc-$(ProjectVersion)
52 HSC2HS_BINDIR=$(FPTOOLS_TOP_ABS)/$(CURRENT_DIR)
53 HSC2HS_DIR=$(FPTOOLS_TOP_ABS_PLATFORM)/$(CURRENT_DIR)
55 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
56 extra_flags=$(addprefix --cflag=,$(filter-out -O,$(SRC_CC_OPTS)))
59 HSC2HS_EXTRA="--cc=$(CC) --ld=$(CC) $(extra_flags) --cflag=-D__GLASGOW_HASKELL__=$(ProjectVersionInt) -I$(FPTOOLS_TOP_ABS_PLATFORM)/$(INCLUDE_DIR)"
62 $(SCRIPT_PROG) : Makefile
63 $(INSTALLED_SCRIPT_PROG) : $(TOP)/mk/config.mk
65 SCRIPT_SUBST_VARS = HSC2HS_BINDIR HSC2HS_DIR HS_PROG HSC2HS_EXTRA
70 ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
71 INSTALL_SCRIPTS += $(SCRIPT_PROG)
72 INSTALL_LIBEXECS += $(HS_PROG)
74 INSTALL_PROGS += $(HS_PROG)
77 override datadir=$(libdir)
78 INSTALL_DATAS += template-hsc.h
80 # -----------------------------------------------------------------------------
81 # Create driver configuration
84 CLEAN_FILES += $(CONFIG_HS)
85 EXTRA_SRCS += $(CONFIG_HS)
89 $(CONFIG_HS) : $(FPTOOLS_TOP)/mk/config.mk Makefile
90 @$(RM) -f $(CONFIG_HS)
91 @echo -n "Creating $(CONFIG_HS) ... "
92 @echo "module Config where" >>$(CONFIG_HS)
93 @echo "cDEFAULT_TMPDIR = \"$(DEFAULT_TMPDIR)\"" >> $(CONFIG_HS)
94 @echo "cGCC = \"$(WhatGccIsCalled)\"" >> $(CONFIG_HS)
95 @echo "progNameSuffix = \"$(exeext)\"" >> $(CONFIG_HS)
96 ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
97 @echo "pathSep = '/'" >> $(CONFIG_HS)
99 @echo "pathSep = (toEnum 92 :: Char)" >> $(CONFIG_HS)
103 # -----------------------------------------------------------------------------
104 # don't recurse on 'make install'
106 ifeq "$(INSTALLING)" "1"
108 $(MAKE) INSTALLING=0 BIN_DIST=0 $(MFLAGS) $@
110 clean distclean maintainer-clean ::
111 $(MAKE) INSTALLING=0 BIN_DIST=0 $(MFLAGS) $@
114 include $(TOP)/mk/target.mk