Makefile 3.51 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
SRC_HC_OPTS += $(PACKAGE_CABAL)

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:
20
SRC_HC_OPTS += $(GhcHcOpts) $(GhcStage1HcOpts)
21

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

26
27
28
29
# 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
30
ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
rrt's avatar
rrt committed
31
HS_PROG           = ghc-pkg.exe
rrt's avatar
rrt committed
32
INSTALL_PROGS    += $(HS_PROG)
33
34
35
else
HS_PROG           = ghc-pkg.bin
INSTALL_LIBEXECS += $(HS_PROG)
rrt's avatar
rrt committed
36
37
endif

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

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

boot :: $(VERSION_HS)

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

55
56
DIST_CLEAN_FILES += $(VERSION_HS)

57
58
# -----------------------------------------------------------------------------
# ghc-pkg script
59

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

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

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

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

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

105
106
107
ifeq "$(INSTALLING)$(HOSTPLATFORM)" "0i386-unknown-mingw32"
all :: $(INPLACE_SCRIPT_PROG).bat

108
# See "MSys Note 3" in compiler/Makefile
109
$(INPLACE_SCRIPT_PROG).bat :
110
	echo '@call $(subst /,\,$(FPTOOLS_TOP_ABS_PLATFORM)/utils/ghc-pkg/$(HS_PROG)) --global-conf $(PKGCONF) %*' >> $@
111
	chmod 755 $@
112
113

CLEAN_FILES += $(INPLACE_SCRIPT_PROG).bat
114
115
endif

116
# ghc-pkg is needed to boot in rts/ and library dirs
117
118
119
120
121
122
123
# Do a recursive 'make all' after generating dependencies, because this
# will work with 'make -j'.
ifneq "$(BootingFromHc)" "YES"
boot :: depend
	$(MAKE) all
endif

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