summaryrefslogtreecommitdiff
path: root/utils/ghc-pkg/ghc.mk
blob: a179ae7940f3fba91cc5f39cf2c5c9ef527b98ed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# -----------------------------------------------------------------------------
#
# (c) 2009-2012 The University of Glasgow
#
# This file is part of the GHC build system.
#
# To understand how the build system works and how to modify it, see
#      http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture
#      http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying
#
# -----------------------------------------------------------------------------

# -----------------------------------------------------------------------------
# Bootstrapping ghc-pkg

utils/ghc-pkg/dist/build/Version.hs \
utils/ghc-pkg/dist-install/build/Version.hs: mk/project.mk | $$(dir $$@)/.
	$(call removeFiles,$@)
	echo "module Version where"                    >> $@
	echo "version, targetOS, targetARCH :: String" >> $@
	echo "version    = \"$(ProjectVersion)\""      >> $@
	echo "targetOS   = \"$(TargetOS_CPP)\""        >> $@
	echo "targetARCH = \"$(TargetArch_CPP)\""      >> $@

utils/ghc-pkg_PACKAGE = ghc-pkg

# -----------------------------------------------------------------------------
# Cross-compile case: install our dist version

ifeq "$(Stage1Only)" "YES"

utils/ghc-pkg_dist_INSTALL = YES
utils/ghc-pkg_dist_SHELL_WRAPPER = YES
utils/ghc-pkg_dist_INSTALL_SHELL_WRAPPER_NAME = ghc-pkg-$(ProjectVersion)
utils/ghc-pkg_dist_WANT_INSTALLED_WRAPPER = YES

INSTALL_LIBEXECS += utils/ghc-pkg/dist/build/tmp/$(utils/ghc-pkg_dist_PROG)

$(eval $(call shell-wrapper,utils/ghc-pkg,dist))

endif

utils/ghc-pkg_dist_USES_CABAL = YES
utils/ghc-pkg_dist_PROG = ghc-pkg$(exeext)
utils/ghc-pkg_dist_SHELL_WRAPPER = YES
utils/ghc-pkg_dist_INSTALL_INPLACE = YES

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

$(GHC_PKG_INPLACE) : | $(INPLACE_PACKAGE_CONF)/.

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

# -----------------------------------------------------------------------------
# Normal case: Build ghc-pkg with stage 1 and install it

ifneq "$(Stage1Only)" "YES"

utils/ghc-pkg_dist-install_USES_CABAL = YES

utils/ghc-pkg_dist-install_PROG = ghc-pkg
utils/ghc-pkg_dist-install_SHELL_WRAPPER = YES
utils/ghc-pkg_dist-install_INSTALL = YES
utils/ghc-pkg_dist-install_INSTALL_SHELL_WRAPPER_NAME = ghc-pkg-$(ProjectVersion)
utils/ghc-pkg_dist-install_INSTALL_INPLACE = NO

$(eval $(call build-prog,utils/ghc-pkg,dist-install,1))

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

endif

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

ifeq "$(Windows)" "NO"
install: install_utils/ghc-pkg_link

.PHONY: install_utils/ghc-pkg_link
install_utils/ghc-pkg_link: 
	$(call INSTALL_DIR,"$(DESTDIR)$(bindir)")
	$(call removeFiles,"$(DESTDIR)$(bindir)/$(CrossCompilePrefix)ghc-pkg")
	$(LN_S) $(CrossCompilePrefix)ghc-pkg-$(ProjectVersion) "$(DESTDIR)$(bindir)/$(CrossCompilePrefix)ghc-pkg"
endif