X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=utils%2Fghc-pkg%2FMakefile;h=6f62b6398ee97c77d04bc40bedc5659f6b4d772d;hb=51cdf3e142be88be5cf89cc79124f65b032335c4;hp=bb140f56e54caf0bffee9a0d4bd70046f4853657;hpb=c15489181a60a228ce52b945d2523cfdacd5a90b;p=ghc-hetmet.git diff --git a/utils/ghc-pkg/Makefile b/utils/ghc-pkg/Makefile index bb140f5..6f62b63 100644 --- a/utils/ghc-pkg/Makefile +++ b/utils/ghc-pkg/Makefile @@ -1,100 +1,57 @@ + TOP=../.. include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/cabal-flags.mk -# ----------------------------------------------------------------------------- -# ghc-pkg.bin - -SRC_HC_OPTS += -cpp -Wall -fno-warn-name-shadowing -fno-warn-unused-matches - -# This causes libghccompat.a to be used: -include $(GHC_COMPAT_DIR)/compat.mk +SRC_HC_OPTS += -Wall -SRC_HC_OPTS += $(PACKAGE_CABAL) - -# 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) $(GhcStage1HcOpts) - -# 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. ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32" -HS_PROG = ghc-pkg.exe -INSTALL_PROGS += $(HS_PROG) +INSTALL_FLAGS = else -HS_PROG = ghc-pkg.bin -INSTALL_LIBEXECS += $(HS_PROG) -endif - -# ----------------------------------------------------------------------------- -# Create the Version.hs file - -VERSION_HS = Version.hs -EXTRA_SRCS += $(VERSION_HS) - -boot :: $(VERSION_HS) - -Version.hs : Makefile $(TOP)/mk/config.mk - @$(RM) -f $(VERSION_HS) - @echo "Creating $(VERSION_HS) ... " - @echo "module Version where" >>$(VERSION_HS) - @echo "version, targetOS, targetARCH :: String" >>$(VERSION_HS) - @echo "version = \"$(ProjectVersion)\"" >> $(VERSION_HS) - @echo "targetOS = \"$(TargetOS_CPP)\"" >> $(VERSION_HS) - @echo "targetARCH = \"$(TargetArch_CPP)\"" >> $(VERSION_HS) - -DIST_CLEAN_FILES += $(VERSION_HS) - -# ----------------------------------------------------------------------------- -# ghc-pkg and ghc-pkg-inplace scripts - -# ghc-pkg-inplace used to be either a /bin/sh script, or a .bat script -# on Windows. It is now a real binary, compiled from a tiny .hs -# file. The problem with using scripts here was that the .bat script -# cannot be executed by /bin/sh on MSYS (it can on Cygwin), but the -# /bin/sh script cannot be executed by Cabal. So we would have needed -# both. A single binary is therefore simpler. - -INPLACE_HS=ghc-pkg-inplace.hs -INPLACE_PROG=ghc-pkg-inplace - -$(INPLACE_HS): Makefile $(FPTOOLS_TOP)/mk/config.mk - echo "import System.Cmd; import System.Environment" > $@ - echo "main = getArgs >>= \args -> rawSystem \"$(FPTOOLS_TOP_ABS_PLATFORM)/$(GHC_PKG_DIR_REL)/$(HS_PROG)\" (\"--global-conf\":\"$(FPTOOLS_TOP_ABS_PLATFORM)/driver/package.conf.inplace\":args)" >> $@ - -$(INPLACE_PROG): $(INPLACE_HS) - $(GHC) --make $< -o $@ - -all :: $(INPLACE_PROG) - -CLEAN_FILES += $(INPLACE_HS) $(INPLACE_PROG) - -ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32" -LINK = ghc-pkg -LINK_TARGET = $(LINK)-$(ProjectVersion) -INSTALLED_SCRIPT=$(bindir)/$(LINK_TARGET) -install:: - $(RM) -f $(INSTALLED_SCRIPT) - echo "#!$(SHELL)" >> $(INSTALLED_SCRIPT) - echo "GHCPKGBIN=$(libexecdir)/$(HS_PROG)" >> $(INSTALLED_SCRIPT) - echo "PKGCONF=$(libdir)/package.conf" >> $(INSTALLED_SCRIPT) - echo 'exec $$GHCPKGBIN --global-conf $$PKGCONF $${1+"$$@"}' >> $(INSTALLED_SCRIPT) - $(EXECUTABLE_FILE) $(INSTALLED_SCRIPT) -endif - -# ghc-pkg is needed to boot in rts/ and library dirs -# Do a recursive 'make all' after generating dependencies, because this -# will work with 'make -j'. -ifneq "$(BootingFromHc)" "YES" -boot :: depend - $(MAKE) all +INSTALL_FLAGS = --enable-shell-wrappers endif -binary-dist: - $(INSTALL_DIR) $(BIN_DIST_DIR)/utils/ghc-pkg - $(INSTALL_DATA) Makefile $(BIN_DIST_DIR)/utils/ghc-pkg/ - $(INSTALL_PROGRAM) $(HS_PROG) $(BIN_DIST_DIR)/utils/ghc-pkg/ +default all: with-bootstrapping-compiler + +with-bootstrapping-compiler: Version.hs + $(CABAL) configure --distpref dist-inplace \ + $(INPLACE_DIRS_CONFIGURE_FLAGS) \ + $(USE_BOOT_CONFIGURE_FLAGS) \ + $(COMMON_CONFIGURE_FLAGS) + $(CABAL) build --distpref dist-inplace $(BUILD_FLAGS) + $(CABAL) install --distpref dist-inplace $(INSTALL_FLAGS) + +with-stage-1: Version.hs + $(CABAL) configure --distpref dist-install \ + $(INSTALL_DIRS_CONFIGURE_FLAGS) \ + $(USE_STAGE1_CONFIGURE_FLAGS) \ + $(COMMON_CONFIGURE_FLAGS) + $(CABAL) build --distpref dist-install $(BUILD_FLAGS) + +install: + $(INSTALL_PACKAGE) install UNUSED UNUSED '$(DESTDIR)' '$(prefix)' \ + '$(prefix)' '$(bindir)' '$(libdir)' \ + '$(libexecdir)' '$(dynlibdir)' '$(datadir)' \ + '$(docdir)' '$(htmldir)' '$(haddockdir)' + --distpref dist-install \ + $(INSTALL_FLAGS) + +clean: distclean + +distclean: + -$(CABAL) clean --distpref dist-inplace + -$(CABAL) clean --distpref dist-install + $(RM) -f Version.hs + +# XXX fix binary-dist + +##### Here down is unique to ghc-pkg + +Version.hs: Makefile $(TOP)/mk/config.mk + $(RM) -f Version.hs + echo "module Version where" >> Version.hs + echo "version, targetOS, targetARCH :: String" >> Version.hs + echo "version = \"$(ProjectVersion)\"" >> Version.hs + echo "targetOS = \"$(TargetOS_CPP)\"" >> Version.hs + echo "targetARCH = \"$(TargetArch_CPP)\"" >> Version.hs -include $(TOP)/mk/target.mk