1 # -----------------------------------------------------------------------------
2 # To compile with nhc98 on unix:
3 # nhc98 -cpp -package base -o hsc2hs-bin Main.hs
6 include $(TOP)/mk/boilerplate.mk
8 CURRENT_DIR=ghc/utils/hsc2hs
9 INCLUDE_DIR=ghc/includes
13 SRC_HC_OPTS += -i$(GHC_LIB_COMPAT_DIR)
14 SRC_LD_OPTS += -L$(GHC_LIB_COMPAT_DIR) -lghccompat
16 # This is required because libghccompat.a must be built with
17 # $(GhcHcOpts) because it is linked to the compiler, and hence
18 # we must also build with $(GhcHcOpts) here:
19 SRC_HC_OPTS += $(GhcHcOpts)
22 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
23 HS_PROG = hsc2hs$(exeext)
25 ifeq "$(HOSTPLATFORM)" "i386-unknown-cygwinw32"
26 HS_PROG = hsc2hs$(exeext)
29 ifeq "$(ghc_ge_504)" "NO"
30 SRC_HC_OPTS += -package util
33 # Note: Somehow we should pass $(exeext) here, but the history of changes used
34 # for calling the C preprocessor via GHC has changed a few times, making a
35 # clean solution impossible. So we revert to a hack in Main.hs...
38 ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
39 INSTALLED_SCRIPT_PROG = hsc2hs
41 INPLACE_SCRIPT_PROG = hsc2hs-inplace
43 ifeq "$(INSTALLING)" "1"
45 SCRIPT_PROG = $(INSTALLED_SCRIPT_PROG)
47 TOP_PWD := $(FPTOOLS_TOP_ABS)
48 SCRIPT_PROG = $(INPLACE_SCRIPT_PROG)
51 ifeq "$(INSTALLING)" "1"
52 ifeq "$(BIN_DIST)" "1"
53 HSC2HS_BINDIR=$$\"\"libexecdir
54 HSC2HS_DIR=$$\"\"libdir
57 HSC2HS_BINDIR=$(libexecdir)
59 HSC2HS_EXTRA=--cc=$(bindir)/ghc-$(ProjectVersion)
62 HSC2HS_BINDIR=$(FPTOOLS_TOP_ABS)/$(CURRENT_DIR)
63 HSC2HS_DIR=$(FPTOOLS_TOP_ABS_PLATFORM)/$(CURRENT_DIR)
65 ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
66 extra_flags=$(addprefix --cflag=,$(filter-out -O,$(SRC_CC_OPTS)))
69 HSC2HS_EXTRA="--cc=$(CC) --ld=$(CC) $(extra_flags) --cflag=-D__GLASGOW_HASKELL__=$(ProjectVersionInt) -I$(FPTOOLS_TOP_ABS_PLATFORM)/$(INCLUDE_DIR)"
72 $(SCRIPT_PROG) : Makefile
73 $(INSTALLED_SCRIPT_PROG) : $(TOP)/mk/config.mk
75 SCRIPT_SUBST_VARS = HSC2HS_BINDIR HSC2HS_DIR HS_PROG HSC2HS_EXTRA
80 ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
81 INSTALL_SCRIPTS += $(SCRIPT_PROG)
82 INSTALL_LIBEXECS += $(HS_PROG)
84 INSTALL_PROGS += $(HS_PROG)
87 override datadir=$(libdir)
88 INSTALL_DATAS += template-hsc.h
90 # This is horrible. We ought to be able to omit the entire directory
92 SRC_MKDEPENDHS_OPTS += \
93 -optdep--exclude-module=Compat.RawSystem \
94 -optdep--exclude-module=Compat.Directory \
95 -optdep--exclude-module=Distribution.Compat.ReadP \
96 -optdep--exclude-module=Distribution.Extension \
97 -optdep--exclude-module=Distribution.GetOpt \
98 -optdep--exclude-module=Distribution.InstalledPackageInfo \
99 -optdep--exclude-module=Distribution.License \
100 -optdep--exclude-module=Distribution.Package \
101 -optdep--exclude-module=Distribution.ParseUtils \
102 -optdep--exclude-module=Distribution.Setup \
103 -optdep--exclude-module=Distribution.Version \
104 -optdep--exclude-module=System.Directory.Internals
106 # -----------------------------------------------------------------------------
107 # don't recurse on 'make install'
109 ifeq "$(INSTALLING)" "1"
111 $(MAKE) INSTALLING=0 BIN_DIST=0 $(MFLAGS) $@
113 clean distclean maintainer-clean ::
114 $(MAKE) INSTALLING=0 BIN_DIST=0 $(MFLAGS) $@
117 include $(TOP)/mk/target.mk