Makefile 3.12 KB
Newer Older
1
2
3
TOP=../..
include $(TOP)/mk/boilerplate.mk

4
5
6
7
8
9
# hack for ghci-inplace script, see below
INSTALLING=1

# -----------------------------------------------------------------------------
# ghc-pkg.bin

10
SRC_HC_OPTS += -cpp -Wall -fno-warn-name-shadowing -fno-warn-unused-matches
11

12
# This causes libghccompat.a to be used:
13
include $(GHC_COMPAT_DIR)/compat.mk
sof's avatar
sof committed
14

15
16
17
18
19
# 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)

20
21
22
ifeq "$(ghc_ge_504)" "NO"
SRC_HC_OPTS +=  -package lang -package util -package text
endif
23

24
25
26
27
# On Windows, ghc-pkg is a standalone program
# ($bindir/ghc-pkg.exe), whereas on Unix it needs a wrapper script
# to pass the appropriate flag to the real binary
# ($libexecdir/ghc-pkg.bin) so that it can find package.conf.
sof's avatar
sof committed
28
ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
rrt's avatar
rrt committed
29
HS_PROG           = ghc-pkg.exe
rrt's avatar
rrt committed
30
INSTALL_PROGS    += $(HS_PROG)
31
32
33
else
HS_PROG           = ghc-pkg.bin
INSTALL_LIBEXECS += $(HS_PROG)
rrt's avatar
rrt committed
34
35
endif

Simon Marlow's avatar
Simon Marlow committed
36
# -----------------------------------------------------------------------------
37
38
39
40
41
42
43
# Create the Version.hs file

VERSION_HS = Version.hs
EXTRA_SRCS += $(VERSION_HS)

boot :: $(VERSION_HS)

44
Version.hs : Makefile $(TOP)/mk/config.mk
45
46
47
	@$(RM) -f $(VERSION_HS)
	@echo "Creating $(VERSION_HS) ... "
	@echo "module Version where" >>$(VERSION_HS)
48
	@echo "version, targetOS, targetARCH :: String" >>$(VERSION_HS)
49
50
51
	@echo "version    = \"$(ProjectVersion)\"" >> $(VERSION_HS)
	@echo "targetOS   = \"$(TargetOS_CPP)\"" >> $(VERSION_HS)
	@echo "targetARCH = \"$(TargetArch_CPP)\"" >> $(VERSION_HS)
52

53
54
DIST_CLEAN_FILES += $(VERSION_HS)

55
56
# -----------------------------------------------------------------------------
# ghc-pkg script
57

58
59
ifeq "$(INSTALLING)" "1"
ifeq "$(BIN_DIST)"   "1"
60
GHCPKGBIN=$$\"\"libexecdir/$(HS_PROG)
61
62
PKGCONF=$$\"\"libdir/package.conf
else
63
GHCPKGBIN=$(libexecdir)/$(HS_PROG)
64
65
66
PKGCONF=$(libdir)/package.conf
endif # BIN_DIST
else
67
68
GHCPKGBIN=$(FPTOOLS_TOP_ABS)/utils/ghc-pkg/$(HS_PROG)
PKGCONF=$(FPTOOLS_TOP_ABS_PLATFORM)/driver/package.conf.inplace
69
70
endif

sof's avatar
sof committed
71
ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
72
INSTALLED_SCRIPT_PROG  = ghc-pkg-$(ProjectVersion)
rrt's avatar
rrt committed
73
endif
74
75
76
77
78
INPLACE_SCRIPT_PROG    = ghc-pkg-inplace

SCRIPT_OBJS	  = ghc-pkg.sh
INTERP		  = $(SHELL)
SCRIPT_SUBST_VARS = GHCPKGBIN PKGCONFOPT
sof's avatar
sof committed
79
ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
80
INSTALL_SCRIPTS  += $(SCRIPT_PROG)
rrt's avatar
rrt committed
81
endif
82
PKGCONFOPT 	  = --global-conf $(PKGCONF)
83
84
85

ifeq "$(INSTALLING)" "1"
SCRIPT_PROG 	=  $(INSTALLED_SCRIPT_PROG)
sof's avatar
sof committed
86
ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
87
LINK 		=  ghc-pkg
rrt's avatar
rrt committed
88
endif
89
90
91
92
93
94
95
96
else
SCRIPT_PROG 	=  $(INPLACE_SCRIPT_PROG)
endif

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

103
# ghc-pkg is needed to boot in rts/ and library dirs
104
105
106
107
108
109
110
# Do a recursive 'make all' after generating dependencies, because this
# will work with 'make -j'.
ifneq "$(BootingFromHc)" "YES"
boot :: depend
	$(MAKE) all
endif

111
include $(TOP)/mk/target.mk