Makefile 2.94 KB
Newer Older
1
# -----------------------------------------------------------------------------
sof's avatar
sof committed
2
# $Id: Makefile,v 1.29 2002/01/21 19:56:20 sof Exp $
3
4
5
6
7

TOP=../..
include $(TOP)/mk/boilerplate.mk

CURRENT_DIR=ghc/utils/hsc2hs
8
INCLUDE_DIR=ghc/includes
9
10
11

INSTALLING=1

rrt's avatar
rrt committed
12
ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
13
HS_PROG           = hsc2hs-bin
rrt's avatar
rrt committed
14
else
sof's avatar
sof committed
15
HS_PROG           = hsc2hs$(exeext)
rrt's avatar
rrt committed
16
endif
rrt's avatar
rrt committed
17
18
SRC_HC_OPTS      += -package util -cpp
ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
sof's avatar
sof committed
19
SRC_HC_OPTS      += -package win32 '-\#include <process.h>'
rrt's avatar
rrt committed
20
endif 
21

rrt's avatar
rrt committed
22
ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
23
INSTALLED_SCRIPT_PROG  = hsc2hs
rrt's avatar
rrt committed
24
endif
25
26
27
28
29
30
31
32
33
34
35
36
INPLACE_SCRIPT_PROG    = hsc2hs-inplace

ifeq "$(INSTALLING)" "1"
TOP_PWD 	:= $(prefix)
SCRIPT_PROG 	=  $(INSTALLED_SCRIPT_PROG)
else
TOP_PWD 	:= $(FPTOOLS_TOP_ABS)
SCRIPT_PROG 	=  $(INPLACE_SCRIPT_PROG)
endif

ifeq "$(INSTALLING)" "1"
ifeq "$(BIN_DIST)"   "1"
37
HSC2HS_BINDIR=$$\"\"libexecdir
38
39
40
HSC2HS_DIR=$$\"\"libdir
HSC2HS_EXTRA=
else
41
HSC2HS_BINDIR=$(libexecdir)
42
HSC2HS_DIR=$(libdir)
43
HSC2HS_EXTRA=--cc=$(bindir)/ghc-$(ProjectVersion)
44
45
endif # BIN_DIST
else
46
HSC2HS_BINDIR=$(FPTOOLS_TOP_ABS)/$(CURRENT_DIR)
47
HSC2HS_DIR=$(FPTOOLS_TOP_ABS)/$(CURRENT_DIR)
rrt's avatar
rrt committed
48
ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
49
HSC2HS_EXTRA="--cc=$(CC) --cflag=-D__GLASGOW_HASKELL__=$(ProjectVersionInt) -I$(FPTOOLS_TOP_ABS)/$(INCLUDE_DIR)"
rrt's avatar
rrt committed
50
else
sof's avatar
sof committed
51
52
extra_flags=$(addprefix --cflag=,$(filter-out -O,$(SRC_CC_OPTS)))
HSC2HS_EXTRA="--cc=$(CC) $(extra_flags) --cflag=-D__GLASGOW_HASKELL__=$(ProjectVersionInt) -I$(FPTOOLS_TOP_ABS)/$(INCLUDE_DIR)"
rrt's avatar
rrt committed
53
endif
54
55
56
endif

$(SCRIPT_PROG) : Makefile
57
$(INSTALLED_SCRIPT_PROG) : $(TOP)/mk/config.mk
58

59
SCRIPT_SUBST_VARS = HSC2HS_BINDIR HSC2HS_DIR HS_PROG HSC2HS_EXTRA
60
61
62
63

SCRIPT_OBJS=hsc2hs.sh
INTERP=$(SHELL)

rrt's avatar
rrt committed
64
ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
65
66
INSTALL_SCRIPTS  += $(SCRIPT_PROG)
INSTALL_LIBEXECS += $(HS_PROG)
rrt's avatar
rrt committed
67
68
69
else
INSTALL_PROGS    += $(HS_PROG)
endif
70
71
72
73

override datadir=$(libdir)
INSTALL_DATAS += template-hsc.h

rrt's avatar
rrt committed
74
75
76
77
# -----------------------------------------------------------------------------
# Create driver configuration

CONFIG_HS = Config.hs
sof's avatar
sof committed
78

rrt's avatar
rrt committed
79
80
boot :: $(CONFIG_HS)

sof's avatar
sof committed
81
82
all :: $(CONFIG_HS)

rrt's avatar
rrt committed
83
84
85
86
87
$(CONFIG_HS) : $(FPTOOLS_TOP)/mk/config.mk Makefile
	@$(RM) -f $(CONFIG_HS)
	@echo -n "Creating $(CONFIG_HS) ... "
	@echo "module Config where" >>$(CONFIG_HS)
	@echo "cDEFAULT_TMPDIR       = \"$(DEFAULT_TMPDIR)\"" >> $(CONFIG_HS)
88
	@echo "cGCC                  = \"$(WhatGccIsCalled)\"" >> $(CONFIG_HS)
sof's avatar
sof committed
89
90
91
92
	@echo "progNameSuffix        = \"$(exeext)\"" >> $(CONFIG_HS)
ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
	@echo "pathSep               = '/'" >> $(CONFIG_HS)
else
sof's avatar
sof committed
93
	@echo "pathSep               = '\\\\'" >> $(CONFIG_HS)
sof's avatar
sof committed
94
endif
rrt's avatar
rrt committed
95
96
97
98
	@echo done.

CLEAN_FILES += $(CONFIG_HS)

99
100
101
# don't recurse on 'make install'
#
ifeq "$(INSTALLING)" "1"
102
all clean distclean maintainer-clean ::
103
104
105
	$(MAKE) INSTALLING=0 BIN_DIST=0 $(MFLAGS) $@
endif

sof's avatar
sof committed
106
107
108
109
MKDEPENDHS_SRCS += $(CONFIG_HS)

include $(TOP)/mk/target.mk

110
# hsc2hs-inplace is needed to boot in ghc/lib/std...
111
ifneq "$(BootingFromHc)" "YES"
112
boot :: all
113
endif