ghc.mk 4.12 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
# -----------------------------------------------------------------------------
#
# (c) 2009 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
#
# -----------------------------------------------------------------------------

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

16
utils/ghc-pkg_dist_PROG = ghc-pkg$(exeext)
Ian Lynagh's avatar
Ian Lynagh committed
17

18 19 20 21 22 23
ifeq "$(BootingFromHc)" "YES"

inplace/bin/ghc-pkg : utils/ghc-pkg/dist-install/build/tmp/$(utils/ghc-pkg_dist_PROG)$(exeext)
ifeq "$(Windows)" "YES"
	cp $< $@
else
24
	$(call removeFiles,$@)
25 26
	echo "#!/bin/sh" >>$@
	echo "PKGCONF=$(TOP)/$(INPLACE_PACKAGE_CONF)" >>$@
27
	echo '$(TOP)/$< --global-package-db $$PKGCONF $${1+"$$@"}' >> $@
28 29 30 31 32
	chmod +x $@
endif

else

33
$(GHC_PKG_INPLACE) : utils/ghc-pkg/dist/build/tmp/$(utils/ghc-pkg_dist_PROG)$(exeext) | $$(dir $$@)/. $(INPLACE_PACKAGE_CONF)/.
34
	$(call removeFiles,$(wildcard $(INPLACE_PACKAGE_CONF)/*))
Ian Lynagh's avatar
Ian Lynagh committed
35 36 37
ifeq "$(Windows)" "YES"
	cp $< $@
else
38
	$(call removeFiles,$@)
Ian Lynagh's avatar
Ian Lynagh committed
39 40
	echo "#!/bin/sh" >>$@
	echo "PKGCONF=$(TOP)/$(INPLACE_PACKAGE_CONF)" >>$@
41
	echo '$(TOP)/$< --global-package-db $$PKGCONF $${1+"$$@"}' >> $@
Ian Lynagh's avatar
Ian Lynagh committed
42 43 44
	chmod +x $@
endif

45 46
endif

47 48 49
# depend on ghc-cabal, otherwise we build Cabal twice when building in parallel.
# (ghc-cabal is an order-only dependency, we don't need to rebuild ghc-pkg
# if ghc-cabal is newer).
50
# The binary package is not warning-clean, so we need a few -fno-warns here.
Simon Marlow's avatar
Simon Marlow committed
51 52 53
#
# ToDo: we might want to do this using ghc-cabal instead.
#
54
utils/ghc-pkg/dist/build/tmp/$(utils/ghc-pkg_dist_PROG)$(exeext): utils/ghc-pkg/Main.hs utils/ghc-pkg/Version.hs | bootstrapping/. $$(dir $$@)/. $(GHC_CABAL_INPLACE) 
55
	"$(GHC)" $(SRC_HC_OPTS) --make utils/ghc-pkg/Main.hs -o $@ \
56
	       -no-user-$(GHC_PACKAGE_DB_FLAG) \
57
	       -Wall -fno-warn-unused-imports -fno-warn-warnings-deprecations \
Ian Lynagh's avatar
Ian Lynagh committed
58
	       $(SRC_HC_WARNING_OPTS) \
Ian Lynagh's avatar
Ian Lynagh committed
59
	       -DCABAL_VERSION=$(CABAL_VERSION) \
60
	       -DBOOTSTRAPPING \
Ian Lynagh's avatar
Ian Lynagh committed
61 62 63 64
	       -odir  bootstrapping \
	       -hidir bootstrapping \
               -iutils/ghc-pkg \
	       -XCPP -XExistentialQuantification -XDeriveDataTypeable \
65
	       -ilibraries/Cabal/Cabal \
Ian Lynagh's avatar
Ian Lynagh committed
66
	       -ilibraries/filepath \
67 68
	       -ilibraries/hpc \
	       -ilibraries/binary/src \
69
	       -ilibraries/bin-package-db
70

Ian Lynagh's avatar
Ian Lynagh committed
71

72
utils/ghc-pkg/Version.hs: mk/project.mk
73
	$(call removeFiles,$@)
Ian Lynagh's avatar
Ian Lynagh committed
74 75 76 77 78 79 80 81 82 83 84
	echo "module Version where"                    >> $@
	echo "version, targetOS, targetARCH :: String" >> $@
	echo "version    = \"$(ProjectVersion)\""      >> $@
	echo "targetOS   = \"$(TargetOS_CPP)\""        >> $@
	echo "targetARCH = \"$(TargetArch_CPP)\""      >> $@

$(eval $(call clean-target,utils/ghc-pkg,dist,\
   utils/ghc-pkg/dist \
   utils/ghc-pkg/Version.hs))

# -----------------------------------------------------------------------------
85 86
# Cross-compile case: Install our dist version
# Normal case: Build ghc-pkg with stage 1
Ian Lynagh's avatar
Ian Lynagh committed
87

88 89 90 91 92 93 94
ifeq "$(BuildingCrossCompiler)" "YES"
GHC_PKG_DISTDIR=dist
else
GHC_PKG_DISTDIR=dist-install
endif

utils/ghc-pkg_$(GHC_PKG_DISTDIR)_USES_CABAL = YES
95 96
utils/ghc-pkg_PACKAGE = ghc-pkg

97 98 99 100 101
utils/ghc-pkg_$(GHC_PKG_DISTDIR)_PROG = ghc-pkg
utils/ghc-pkg_$(GHC_PKG_DISTDIR)_SHELL_WRAPPER = YES
utils/ghc-pkg_$(GHC_PKG_DISTDIR)_INSTALL_SHELL_WRAPPER = YES
utils/ghc-pkg_$(GHC_PKG_DISTDIR)_INSTALL_SHELL_WRAPPER_NAME = ghc-pkg-$(ProjectVersion)
utils/ghc-pkg_$(GHC_PKG_DISTDIR)_INSTALL_INPLACE = NO
Ian Lynagh's avatar
Ian Lynagh committed
102

103 104 105 106
ifeq "$(BootingFromHc)" "YES"
utils/ghc-pkg_dist-install_OTHER_OBJS += $(ALL_STAGE1_LIBS) $(ALL_STAGE1_LIBS) $(ALL_STAGE1_LIBS) $(ALL_RTS_LIBS) $(libffi_STATIC_LIB)
endif

107 108 109
ifeq "$(BuildingCrossCompiler)" "YES"
$(eval $(call shell-wrapper,utils/ghc-pkg,dist))
else
Ian Lynagh's avatar
Ian Lynagh committed
110
$(eval $(call build-prog,utils/ghc-pkg,dist-install,1))
111
endif
Ian Lynagh's avatar
Ian Lynagh committed
112 113 114 115

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

116
.PHONY: install_utils/ghc-pkg_link
Ian Lynagh's avatar
Ian Lynagh committed
117
install_utils/ghc-pkg_link: 
118
	$(call INSTALL_DIR,"$(DESTDIR)$(bindir)")
119
	$(call removeFiles,"$(DESTDIR)$(bindir)/ghc-pkg")
120
	$(LN_S) $(CrossCompilePrefix)ghc-pkg-$(ProjectVersion) "$(DESTDIR)$(bindir)/$(CrossCompilePrefix)ghc-pkg"
Ian Lynagh's avatar
Ian Lynagh committed
121 122
endif