ghc.mk 4.37 KB
Newer Older
1
2
# -----------------------------------------------------------------------------
#
3
# (c) 2009-2012 The University of Glasgow
4
5
6
7
#
# This file is part of the GHC build system.
#
# To understand how the build system works and how to modify it, see
8
9
#      http://ghc.haskell.org/trac/ghc/wiki/Building/Architecture
#      http://ghc.haskell.org/trac/ghc/wiki/Building/Modifying
10
11
12
#
# -----------------------------------------------------------------------------

Ian Lynagh's avatar
Ian Lynagh committed
13
14
15
# -----------------------------------------------------------------------------
# Bootstrapping ghc-pkg

16
utils/ghc-pkg/dist/build/Version.hs \
ian@well-typed.com's avatar
ian@well-typed.com committed
17
utils/ghc-pkg/dist-install/build/Version.hs: mk/project.mk | $$(dir $$@)/.
18
	$(call removeFiles,$@)
Ian Lynagh's avatar
Ian Lynagh committed
19
20
21
22
23
24
	echo "module Version where"                    >> $@
	echo "version, targetOS, targetARCH :: String" >> $@
	echo "version    = \"$(ProjectVersion)\""      >> $@
	echo "targetOS   = \"$(TargetOS_CPP)\""        >> $@
	echo "targetARCH = \"$(TargetArch_CPP)\""      >> $@

25
utils/ghc-pkg_PACKAGE = ghc-pkg
Ian Lynagh's avatar
Ian Lynagh committed
26

27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Note [Why build certain utils twice?]
#
# We build certain utils twice: once with stage0, and once with stage1.
# Examples are ghc-pkg and hsc2hs.
#
# These tools are needed during the bootstrapping process, so we have to use
# stage0 to build them at first (stage1 doesn't exist yet). (side note: they're
# also used later in the build process). We install them inplace.
#
# But we can't install these copies when you run 'make install'. The reason is
# that when DYNAMIC_GHC_PROGRAMS=YES, we want to install copies that are
# dynamically linked. But the stage0 copies are either statically linked, or
# linked against libraries on the build machine.
#
# Therefore we build fresh copies, using the stage1 compiler, and install them
# when you run 'make install'. They are not used for any other purpose.

Ian Lynagh's avatar
Ian Lynagh committed
44
# -----------------------------------------------------------------------------
45
46
47
48
49
50
# Build ghc-pkg with the stage0 compiler in the dist directory, and install
# inplace. This is the copy we use during in-tree development.
utils/ghc-pkg_dist_USES_CABAL = YES
utils/ghc-pkg_dist_PROGNAME = ghc-pkg
utils/ghc-pkg_dist_SHELL_WRAPPER = YES
utils/ghc-pkg_dist_INSTALL_INPLACE = YES
Ian Lynagh's avatar
Ian Lynagh committed
51

52
53
54
55
56
57
# When cross-built ghc-stage2 is installed 'make install' needs to call
# native ghc-pkg (not the cross-built one) to register installed packages
# 'ghc-pkg_DIST_BINARY' variable only refer to native binary.
ghc-pkg_DIST_BINARY_NAME = ghc-pkg$(exeext0)
ghc-pkg_DIST_BINARY = utils/ghc-pkg/dist/build/tmp/$(ghc-pkg_DIST_BINARY_NAME)

58
# See Note [Stage1Only vs stage=1] in mk/config.mk.in.
Simon Marlow's avatar
Simon Marlow committed
59
ifeq "$(Stage1Only)" "YES"
60
61
# Install the copy of ghc-pkg from the dist directory when running 'make
# install' (it's the only copy we have at this stage).
62
63
utils/ghc-pkg_dist_INSTALL = YES
utils/ghc-pkg_dist_INSTALL_SHELL_WRAPPER_NAME = ghc-pkg-$(ProjectVersion)
64
65
endif

66
67
68
69
ifeq "$(WITH_TERMINFO)" "NO"
utils/ghc-pkg_dist-install_CONFIGURE_OPTS += -f-terminfo
endif

70
71
$(eval $(call build-prog,utils/ghc-pkg,dist,0))

72
$(ghc-pkg_INPLACE) : | $(INPLACE_PACKAGE_CONF)/.
73
74
75
76

utils/ghc-pkg/dist/package-data.mk: \
    utils/ghc-pkg/dist/build/Version.hs

77
# -----------------------------------------------------------------------------
78
79
80
81
82
# Build another copy of ghc-pkg with the stage1 compiler in the dist-install
# directory. Don't install it inplace (we use the dist copy there), but do
# install it when running 'make install'.
#
# See Note [Why build certain utils twice?].
83

84
# See Note [Stage1Only vs stage=1] in mk/config.mk.in.
85
86
ifneq "$(Stage1Only)" "YES"
utils/ghc-pkg_dist-install_USES_CABAL = YES
87
utils/ghc-pkg_dist-install_PROGNAME = ghc-pkg
88
utils/ghc-pkg_dist-install_SHELL_WRAPPER = YES
89
utils/ghc-pkg_dist-install_INSTALL_INPLACE = NO
90
91
92
utils/ghc-pkg_dist-install_INSTALL = YES
utils/ghc-pkg_dist-install_INSTALL_SHELL_WRAPPER_NAME = ghc-pkg-$(ProjectVersion)

Ian Lynagh's avatar
Ian Lynagh committed
93
94
$(eval $(call build-prog,utils/ghc-pkg,dist-install,1))

95
96
utils/ghc-pkg/dist-install/package-data.mk: \
    utils/ghc-pkg/dist-install/build/Version.hs
97
98
99
100
101
endif

# -----------------------------------------------------------------------------
# Link ghc-pkg to ghc-pkg-$(ProjectVersion) when installing

102
ifeq "$(Windows_Host)" "NO"
Ian Lynagh's avatar
Ian Lynagh committed
103
104
install: install_utils/ghc-pkg_link

105
.PHONY: install_utils/ghc-pkg_link
Ian Lynagh's avatar
Ian Lynagh committed
106
install_utils/ghc-pkg_link: 
thomie's avatar
thomie committed
107
	$(INSTALL_DIR) "$(DESTDIR)$(bindir)"
108
	$(call removeFiles,"$(DESTDIR)$(bindir)/$(CrossCompilePrefix)ghc-pkg")
109
	$(LN_S) $(CrossCompilePrefix)ghc-pkg-$(ProjectVersion) "$(DESTDIR)$(bindir)/$(CrossCompilePrefix)ghc-pkg"
Ian Lynagh's avatar
Ian Lynagh committed
110
endif