From eed437cdefb952e6c70e58012b23d436e74710af Mon Sep 17 00:00:00 2001 From: Ian Lynagh Date: Fri, 18 Jul 2008 11:47:53 +0000 Subject: [PATCH] More build system changes; ghc-pkg is now built with Cabal --- compiler/main/SysTools.lhs | 21 +++--- driver/Makefile | 16 +++-- ghc/Makefile | 15 +--- mk/cabal-flags.mk | 7 +- mk/config.mk.in | 8 +-- utils/Makefile | 35 +++++++--- utils/ghc-pkg/Main.hs | 58 +++++++-------- utils/ghc-pkg/Makefile | 155 +++++++++++------------------------------ utils/ghc-pkg/ghc-pkg.cabal | 32 +++++++++ utils/ghc-pkg/ghc-pkg.wrapper | 4 ++ 10 files changed, 159 insertions(+), 192 deletions(-) create mode 100644 utils/ghc-pkg/ghc-pkg.cabal create mode 100644 utils/ghc-pkg/ghc-pkg.wrapper diff --git a/compiler/main/SysTools.lhs b/compiler/main/SysTools.lhs index 1538b95..c418789 100644 --- a/compiler/main/SysTools.lhs +++ b/compiler/main/SysTools.lhs @@ -163,19 +163,14 @@ initSysTools mbMinusB dflags0 ; let installed, installed_bin :: FilePath -> FilePath installed_bin pgm = top_dir pgm installed file = top_dir file - inplaceUpDirs - | isWindowsHost = 2 - | otherwise = 4 - inplace dir pgm = let real_top_dir = foldr () "" - $ reverse - $ drop inplaceUpDirs - $ reverse - $ splitDirectories top_dir - in real_top_dir dir pgm + real_top_dir + | isWindowsHost = top_dir ".." ".." + | otherwise = top_dir ".." + inplace dir pgm = real_top_dir dir pgm ; let pkgconfig_path | am_installed = installed "package.conf" - | otherwise = inplace cGHC_DRIVER_DIR_REL "package.conf.inplace" + | otherwise = inplace "inplace-datadir" "package.conf" ghc_usage_msg_path | am_installed = installed "ghc-usage.txt" @@ -331,10 +326,10 @@ findTopDir :: Maybe String -- Maybe TopDir path (without the '-B' prefix). findTopDir mbMinusB = do { top_dir <- get_proto -- Discover whether we're running in a build tree or in an installation, - -- by looking for the package configuration file. - ; am_installed <- doesFileExist (top_dir "package.conf") + -- by looking for a file we use for that purpose + ; am_inplace <- doesFileExist (top_dir "inplace") - ; return (am_installed, top_dir) + ; return (not am_inplace, top_dir) } where -- get_proto returns a Unix-format path (relying on getBaseDir to do so too) diff --git a/driver/Makefile b/driver/Makefile index a835209..cf842e4 100644 --- a/driver/Makefile +++ b/driver/Makefile @@ -9,13 +9,15 @@ include $(TOP)/mk/boilerplate.mk SUBDIRS = mangler split ghc ghci -boot all :: package.conf.inplace package.conf - -package.conf.inplace : - echo "[]" > $@ - -package.conf : - echo "[]" > $@ +INPLACE_DATA_DIR = $(FPTOOLS_TOP_ABS)/inplace-datadir +INPLACE_PKG_CONF = $(INPLACE_DATA_DIR)/package.conf +# Used to signal that we are inplace, as opposed to installed: +INPLACE_FILE = $(INPLACE_DATA_DIR)/inplace + +boot all :: + $(MKDIRHIER) $(INPLACE_DATA_DIR) + test -e $(INPLACE_PKG_CONF) || echo "[]" > $(INPLACE_PKG_CONF) + touch $(INPLACE_FILE) override datadir = $(libdir) INSTALL_DATAS += package.conf ghc-usage.txt ghci-usage.txt diff --git a/ghc/Makefile b/ghc/Makefile index 312ab05..f824e3a 100644 --- a/ghc/Makefile +++ b/ghc/Makefile @@ -32,16 +32,8 @@ clean distclean:: $(RM) -rf stage1-inplace $(RM) -rf stage2-inplace -# XXX Eugh, can we do this better? The problem is making extra-gcc-opts -# infdable on both Linux and Windows. I guess this will go away when we -# drop the mangler? -ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32" -SET_DATA_SUBDIR = --datasubdir=. -INPLACE_DATA_DIR = '$$prefix' -else -SET_DATA_SUBDIR = -INPLACE_DATA_DIR = '$$prefix/data' -endif +# XXX This should be defined somewhere more central +INPLACE_DATA_DIR = $(FPTOOLS_TOP_ABS)/inplace-datadir CONFIGURE_FLAGS_STAGE1 += --flags=-ghci @@ -74,7 +66,6 @@ CONFIGURE_FLAGS_STAGE3 += $(USE_STAGE2_CONFIGURE_FLAGS) boot.stage.%: $(CABAL) configure --distpref dist-stage$* \ - $(SET_DATA_SUBDIR) \ $(INSTALL_DIRS_CONFIGURE_FLAGS) \ $(CONFIGURE_FLAGS_STAGE$*) \ $(COMMON_CONFIGURE_FLAGS) @@ -88,7 +79,7 @@ build.stage.%: '$$prefix/lib' \ '$$prefix/libexec' \ '$$prefix/dynlib' \ - $(INPLACE_DATA_DIR) \ + '$(INPLACE_DATA_DIR)' \ '$$prefix/doc' \ '$$prefix/html' \ '$$prefix/haddock' \ diff --git a/mk/cabal-flags.mk b/mk/cabal-flags.mk index c9663aa..4483dc6 100644 --- a/mk/cabal-flags.mk +++ b/mk/cabal-flags.mk @@ -56,12 +56,15 @@ INSTALL_DIRS_CONFIGURE_FLAGS = \ --libdir=$(NONEXISTENT) \ --libexecdir=$(NONEXISTENT) \ --datadir=$(NONEXISTENT) \ + --datasubdir=. \ --docdir=$(NONEXISTENT) \ --haddockdir=$(NONEXISTENT) \ --htmldir=$(NONEXISTENT) INPLACE_DIRS_CONFIGURE_FLAGS = \ - --prefix=`$(TOP)/utils/pwd/pwd forwardslash`/install-inplace + --prefix=`$(FPTOOLS_TOP_ABS)/utils/pwd/pwd forwardslash`/install-inplace \ + --datadir=$(FPTOOLS_TOP_ABS)/inplace-datadir \ + --datasubdir=. USE_BOOT_CONFIGURE_FLAGS = \ --with-compiler=$(GHC) \ @@ -69,7 +72,7 @@ USE_BOOT_CONFIGURE_FLAGS = \ --package-db $(FPTOOLS_TOP_ABS)/libraries/bootstrapping.conf USE_STAGE_CONFIGURE_FLAGS = \ - --with-hc-pkg=$(FPTOOLS_TOP_ABS)/utils/ghc-pkg/ghc-pkg-inplace \ + --with-hc-pkg=$(GHC_PKG_INPLACE) \ $(addprefix --cc-option=,$(MACOSX_DEPLOYMENT_CC_OPTS)) \ $(addprefix --ld-option=,$(MACOSX_DEPLOYMENT_LD_OPTS)) diff --git a/mk/config.mk.in b/mk/config.mk.in index f3a2324..3391f17 100644 --- a/mk/config.mk.in +++ b/mk/config.mk.in @@ -625,10 +625,7 @@ ifacedir = $(libdir) # (NOTE: configure script setting is ignored). libexecdir = $(libdir) -# This is a bit of a lie, as this is a wrapper rather than the program -# itself. However, it means that we don't have to worry about Windows -# and non-Windows having different extensions. -GHC_PKG_PROG = $(FPTOOLS_TOP_ABS)/$(GHC_PKG_DIR_REL)/ghc-pkg-inplace +GHC_PKG_PROG = $(FPTOOLS_TOP_ABS)/$(GHC_PKG_DIR_REL)/install-inplace/bin/ghc-pkg #----------------------------------------------------------------------------- # install configuration @@ -809,7 +806,6 @@ GHC_TOUCHY_PGM = touchy$(exeext) GHC_MANGLER_PGM = ghc-asm GHC_SPLIT_PGM = ghc-split GHC_SYSMAN_PGM = SysMan -GHC_PKG_INPLACE_PGM = ghc-pkg-inplace GHC_GENPRIMOP_PGM = genprimopcode GHC_GENAPPLY_PGM = genapply GHC_MKDEPENDC_PGM = mkdependC @@ -834,7 +830,7 @@ HSC2HS_INPLACE = $(GHC_HSC2HS_DIR)/install-inplace/bin/$(GHC_HSC2HS_INPLACE_PGM MANGLER = $(GHC_MANGLER_DIR)/$(GHC_MANGLER_PGM) SPLIT = $(GHC_SPLIT_DIR)/$(GHC_SPLIT_PGM) SYSMAN = $(GHC_SYSMAN_DIR)/$(GHC_SYSMAN_PGM) -GHC_PKG_INPLACE = $(GHC_PKG_DIR)/$(GHC_PKG_INPLACE_PGM) +GHC_PKG_INPLACE = $(GHC_PKG_PROG) GENPRIMOP = $(GHC_GENPRIMOP_DIR)/$(GHC_GENPRIMOP_PGM) GENAPPLY = $(GHC_GENAPPLY_DIR)/$(GHC_GENAPPLY_PGM) MKDEPENDC = $(GHC_MKDEPENDC_DIR)/$(GHC_MKDEPENDC_PGM) diff --git a/utils/Makefile b/utils/Makefile index 972716f..4ecbd72 100644 --- a/utils/Makefile +++ b/utils/Makefile @@ -3,12 +3,12 @@ include $(TOP)/mk/boilerplate.mk ifeq "$(DOING_BIN_DIST)" "YES" # We're doing a binary-dist, descend into a subset of the dirs. -SUBDIRS = mkdirhier ghc-pkg hasktags hp2ps parallel unlit runghc hpc pwd +SUBDIRS = mkdirhier hasktags hp2ps parallel unlit runghc hpc pwd else ifeq "$(BootingFromHc)" "YES" -SUBDIRS = mkdependC mkdirhier runstdtest genapply genprimopcode ghc-pkg unlit +SUBDIRS = mkdependC mkdirhier runstdtest genapply genprimopcode unlit else -SUBDIRS = mkdependC mkdirhier runstdtest ghc-pkg hasktags hp2ps \ +SUBDIRS = mkdependC mkdirhier runstdtest hasktags hp2ps \ installPackage parallel unlit genprimopcode genapply runghc hpc pwd endif ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32" @@ -53,14 +53,29 @@ boot :: $(MAKE) -C genprimopcode endif -with-bootstrapping-compiler: - $(MAKE) -C hsc2hs with-bootstrapping-compiler +WITH_BOOTSTRAPPING_COMPILER = ghc-pkg hsc2hs +WITH_STAGE1 = ghc-pkg ifneq "$(NO_INSTALL_HSC2HS)" "YES" -with-stage-1: - $(MAKE) -C hsc2hs with-stage-1 - -install :: - $(MAKE) -C hsc2hs install +WITH_STAGE1 += hsc2hs endif +with-bootstrapping-compiler: \ + $(foreach P,$(WITH_BOOTSTRAPPING_COMPILER),with-bootstrapping-compiler.$P) + +with-stage-1: $(foreach P,$(WITH_STAGE1),with-stage-1.$P) + +install:: $(foreach P,$(WITH_STAGE1),install.$P) + +$(foreach P,$(WITH_BOOTSTRAPPING_COMPILER),with-bootstrapping-compiler.$P): \ +with-bootstrapping-compiler.%: + $(MAKE) -C $* with-bootstrapping-compiler + +$(foreach P,$(WITH_STAGE1),with-stage-1.$P): \ +with-stage-1.%: + $(MAKE) -C $* with-stage-1 + +$(foreach P,$(WITH_STAGE1),install.$P): \ +install.%: + $(MAKE) -C $* install + diff --git a/utils/ghc-pkg/Main.hs b/utils/ghc-pkg/Main.hs index f2087b9..7f727d7 100644 --- a/utils/ghc-pkg/Main.hs +++ b/utils/ghc-pkg/Main.hs @@ -364,14 +364,14 @@ allPackagesInStack :: PackageDBStack -> [InstalledPackageInfo] allPackagesInStack = concatMap snd getPkgDatabases :: Bool -> [Flag] -> IO PackageDBStack -getPkgDatabases modify flags = do +getPkgDatabases modify my_flags = do -- first we determine the location of the global package config. On Windows, -- this is found relative to the ghc-pkg.exe binary, whereas on Unix the -- location is passed to the binary using the --global-config flag by the -- wrapper script. let err_msg = "missing --global-conf option, location of global package.conf unknown\n" global_conf <- - case [ f | FlagGlobalConfig f <- flags ] of + case [ f | FlagGlobalConfig f <- my_flags ] of [] -> do mb_dir <- getExecDir "/bin/ghc-pkg.exe" case mb_dir of Nothing -> die err_msg @@ -416,7 +416,7 @@ getPkgDatabases modify flags = do -- This is the database we modify by default. virt_global_conf = last env_stack - let db_flags = [ f | Just f <- map is_db_flag flags ] + let db_flags = [ f | Just f <- map is_db_flag my_flags ] where is_db_flag FlagUser = Just user_conf is_db_flag FlagGlobal = Just virt_global_conf is_db_flag (FlagConfig f) = Just f @@ -440,7 +440,7 @@ getPkgDatabases modify flags = do -- stack, unless any of them are present in the stack -- already. flag_stack = filter (`notElem` env_stack) - [ f | FlagConfig f <- reverse flags ] + [ f | FlagConfig f <- reverse my_flags ] ++ env_stack modifying f @@ -475,8 +475,8 @@ registerPackage :: FilePath -> Bool -- update -> Force -> IO () -registerPackage input flags auto_ghci_libs update force = do - db_stack <- getPkgDatabases True flags +registerPackage input my_flags auto_ghci_libs update force = do + db_stack <- getPkgDatabases True my_flags let db_to_operate_on = my_head "db" db_stack db_filename = fst db_to_operate_on @@ -522,15 +522,15 @@ hidePackage :: PackageIdentifier -> [Flag] -> IO () hidePackage = modifyPackage (\p -> [p{exposed=False}]) unregisterPackage :: PackageIdentifier -> [Flag] -> IO () -unregisterPackage = modifyPackage (\p -> []) +unregisterPackage = modifyPackage (\_ -> []) modifyPackage :: (InstalledPackageInfo -> [InstalledPackageInfo]) -> PackageIdentifier -> [Flag] -> IO () -modifyPackage fn pkgid flags = do - db_stack <- getPkgDatabases True{-modify-} flags +modifyPackage fn pkgid my_flags = do + db_stack <- getPkgDatabases True{-modify-} my_flags let ((db_name, pkgs) : _) = db_stack ps <- findPackages [(db_name,pkgs)] (Id pkgid) let pids = map package ps @@ -545,9 +545,9 @@ modifyPackage fn pkgid flags = do -- Listing packages listPackages :: [Flag] -> Maybe PackageArg -> Maybe (String->Bool) -> IO () -listPackages flags mPackageName mModuleName = do - let simple_output = FlagSimpleOutput `elem` flags - db_stack <- getPkgDatabases False flags +listPackages my_flags mPackageName mModuleName = do + let simple_output = FlagSimpleOutput `elem` my_flags + db_stack <- getPkgDatabases False my_flags let db_stack_filtered -- if a package is given, filter out all other packages | Just this <- mPackageName = map (\(conf,pkgs) -> (conf, filter (this `matchesPkg`) pkgs)) @@ -586,8 +586,8 @@ listPackages flags mPackageName mModuleName = do where doc = text (display (package p)) show_simple db_stack = do - let showPkg = if FlagNamesOnly `elem` flags then display . pkgName - else display + let showPkg = if FlagNamesOnly `elem` my_flags then display . pkgName + else display pkgs = map showPkg $ sortBy compPkgIdVer $ map package (allPackagesInStack db_stack) when (not (null pkgs)) $ @@ -597,8 +597,8 @@ listPackages flags mPackageName mModuleName = do -- Prints the highest (hidden or exposed) version of a package latestPackage :: [Flag] -> PackageIdentifier -> IO () -latestPackage flags pkgid = do - db_stack <- getPkgDatabases False flags +latestPackage my_flags pkgid = do + db_stack <- getPkgDatabases False my_flags ps <- findPackages db_stack (Id pkgid) show_pkg (sortBy compPkgIdVer (map package ps)) where @@ -609,14 +609,14 @@ latestPackage flags pkgid = do -- Describe describePackage :: [Flag] -> PackageArg -> IO () -describePackage flags pkgarg = do - db_stack <- getPkgDatabases False flags +describePackage my_flags pkgarg = do + db_stack <- getPkgDatabases False my_flags ps <- findPackages db_stack pkgarg doDump ps dumpPackages :: [Flag] -> IO () -dumpPackages flags = do - db_stack <- getPkgDatabases False flags +dumpPackages my_flags = do + db_stack <- getPkgDatabases False my_flags doDump (allPackagesInStack db_stack) doDump :: [InstalledPackageInfo] -> IO () @@ -649,8 +649,8 @@ compPkgIdVer p1 p2 = pkgVersion p1 `compare` pkgVersion p2 -- Field describeField :: [Flag] -> PackageArg -> [String] -> IO () -describeField flags pkgarg fields = do - db_stack <- getPkgDatabases False flags +describeField my_flags pkgarg fields = do + db_stack <- getPkgDatabases False my_flags fns <- toFields fields ps <- findPackages db_stack pkgarg let top_dir = takeDirectory (fst (last db_stack)) @@ -715,8 +715,8 @@ strList = show -- Check: Check consistency of installed packages checkConsistency :: [Flag] -> IO () -checkConsistency flags = do - db_stack <- getPkgDatabases True flags +checkConsistency my_flags = do + db_stack <- getPkgDatabases True my_flags -- check behaves like modify for the purposes of deciding which -- databases to use, because ordering is important. let pkgs = map (\p -> (package p, p)) $ allPackagesInStack db_stack @@ -727,7 +727,7 @@ checkConsistency flags = do return (pid, broken_deps) mapM_ (putStrLn . render . show_func) broken_pkgs where - show_func | FlagSimpleOutput `elem` flags = show_simple + show_func | FlagSimpleOutput `elem` my_flags = show_simple | otherwise = show_normal show_simple (pid,deps) = text (display pid) <> colon @@ -747,7 +747,7 @@ missingPackageDeps pkg pkg_map = isBrokenPackage :: InstalledPackageInfo -> [(PackageIdentifier, InstalledPackageInfo)] -> Bool isBrokenPackage pkg pkg_map = not . null $ missingPackageDeps pkg (filter notme pkg_map) - where notme (p,ipi) = package pkg /= p + where notme (p, _ipi) = package pkg /= p -- remove p from the database when we invoke missingPackageDeps, -- because we want mutually recursive groups of package to show up -- as broken. (#1750) @@ -988,7 +988,7 @@ okInModuleName c -- expanding environment variables in the package configuration expandEnvVars :: String -> Force -> IO String -expandEnvVars str force = go str "" +expandEnvVars str0 force = go str0 "" where go "" acc = return $! reverse acc go ('$':'{':str) acc | (var, '}':rest) <- break close str @@ -1039,8 +1039,8 @@ dieForcible :: String -> IO () dieForcible s = die (s ++ " (use --force to override)") my_head :: String -> [a] -> a -my_head s [] = error s -my_head s (x:xs) = x +my_head s [] = error s +my_head _ (x : _) = x ----------------------------------------- -- Cut and pasted from ghc/compiler/main/SysTools diff --git a/utils/ghc-pkg/Makefile b/utils/ghc-pkg/Makefile index 5afb448..6fba1c8 100644 --- a/utils/ghc-pkg/Makefile +++ b/utils/ghc-pkg/Makefile @@ -1,131 +1,60 @@ + TOP=../.. include $(TOP)/mk/boilerplate.mk +include $(TOP)/mk/cabal-flags.mk -# ----------------------------------------------------------------------------- -# ghc-pkg.bin - -# Beyond stage 1, honour any Mac OS X depolyment target options. If we use -# these options in stage 1 we get a linker error if the bootstrap compiler is -# for a more recent OS version -ifeq "$(stage)" "2" -SRC_CC_OPTS += $(MACOSX_DEPLOYMENT_CC_OPTS) -SRC_HC_OPTS += $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS)) -SRC_LD_OPTS += $(addprefix -optl, $(MACOSX_DEPLOYMENT_LD_OPTS)) -endif - -SRC_HC_OPTS += -cpp -Wall -fno-warn-name-shadowing -fno-warn-unused-matches - -SRC_HC_OPTS += $(PACKAGE_CABAL) - -ifeq "$(Windows)" "NO" -SRC_HC_OPTS += -package unix -endif - -ifeq "$(ghc_ge_607)" "YES" -SRC_HC_OPTS += -package containers -endif +SRC_HC_OPTS += -Wall -SRC_HC_OPTS += -package Cabal +# XXX From old Makefile: +# SRC_HC_OPTS += -cpp -Wall -fno-warn-name-shadowing -fno-warn-unused-matches -# 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. -# on Windows, we need to take control of filename globbing ourselves ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32" -HS_PROG = ghc-pkg.exe -INSTALL_PROGS += $(HS_PROG) -EXCLUDE_SRCS += CRT_noglob.c -NOGLOB_O = CRT_noglob.o -else - -# We have two version: the inplace version compiled by the bootstrap compiler -# and the install version compiled by the stage 1 compiler. -# When creating or using bindists we always want the final binary, as built -# by the stage 1 compiler. -ifeq "$(DOING_BIN_DIST)" "YES" -HS_PROG = ghc-pkg.bin -else -ifeq "$(stage)" "2" -HS_PROG = ghc-pkg.bin +INSTALL_FLAGS = else -HS_PROG = ghc-pkg-inplace.bin +INSTALL_FLAGS = --enable-shell-wrappers endif -endif -INSTALL_LIBEXECS += $(HS_PROG) -NOGLOB_O = - -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) +default all: with-bootstrapping-compiler -DIST_CLEAN_FILES += $(VERSION_HS) +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) -# ----------------------------------------------------------------------------- -# ghc-pkg and ghc-pkg-inplace scripts +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) -# 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. +install: + $(INSTALL_PACKAGE) install UNUSED UNUSED '$(DESTDIR)' '$(prefix)' \ + '$(prefix)' '$(bindir)' '$(libdir)' \ + '$(libexecdir)' '$(dynlibdir)' '$(datadir)' \ + '$(docdir)' '$(htmldir)' '$(haddockdir)' + --distpref dist-install \ + $(INSTALL_FLAGS) -INPLACE_HS=ghc-pkg-inplace.hs -INPLACE_PROG=ghc-pkg-inplace -EXCLUDED_SRCS+=$(INPLACE_HS) +clean: distclean -$(INPLACE_HS): Makefile $(FPTOOLS_TOP)/mk/config.mk $(NOGLOB_O) - echo "import System.Cmd; import System.Environment; import System.Exit" > $@ - echo "main = do args <- getArgs; rawSystem \"$(FPTOOLS_TOP_ABS)/$(GHC_PKG_DIR_REL)/$(HS_PROG)\" (\"--global-conf\":\"$(FPTOOLS_TOP_ABS)/driver/package.conf.inplace\":args) >>= exitWith" >> $@ +distclean: + -$(CABAL) clean --distpref dist-inplace + -$(CABAL) clean --distpref dist-install + $(RM) -f Version.hs -$(INPLACE_PROG): $(INPLACE_HS) - $(HC) --make $< -o $@ $(LD_OPTS) $(NOGLOB_O) +# XXX fix binary-dist -all :: $(INPLACE_PROG) - -CLEAN_FILES += $(INPLACE_HS) $(INPLACE_PROG) - -ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32" -LINK = ghc-pkg -LINK_TARGET = $(LINK)-$(ProjectVersion) -INSTALLED_SCRIPT=$(DESTDIR)$(bindir)/$(LINK_TARGET) -install:: - $(INSTALL_DIR) $(DESTDIR)$(bindir) - $(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 -endif +##### Here down is unique to ghc-pkg -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/ +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 diff --git a/utils/ghc-pkg/ghc-pkg.cabal b/utils/ghc-pkg/ghc-pkg.cabal new file mode 100644 index 0000000..90722a6 --- /dev/null +++ b/utils/ghc-pkg/ghc-pkg.cabal @@ -0,0 +1,32 @@ +Name: ghc-pkg +-- XXX Version number +Version: 6.9 +Copyright: XXX +License: BSD3 +-- XXX License-File: LICENSE +Author: XXX +Maintainer: cvs-fptools@haskell.org +Synopsis: XXX +Description: + XXX +Category: Development +build-type: Simple +cabal-version: >=1.2 + +Flag base3 + Description: Choose the new smaller, split-up base package. + +Executable ghc-pkg + Main-Is: Main.hs + Extensions: CPP, ForeignFunctionInterface + if flag(base3) + Build-Depends: base >= 3 && < 4, + directory >= 1 && < 1.1, + process >= 1 && < 1.1, + pretty >= 1 && < 1.1 + else + Build-Depends: base < 3 + Build-Depends: haskell98, filepath, Cabal + if !os(windows) + Build-Depends: unix + diff --git a/utils/ghc-pkg/ghc-pkg.wrapper b/utils/ghc-pkg/ghc-pkg.wrapper new file mode 100644 index 0000000..1c2b5d2 --- /dev/null +++ b/utils/ghc-pkg/ghc-pkg.wrapper @@ -0,0 +1,4 @@ + +PKGCONF=$datadir/package.conf +exec $executablename --global-conf $PKGCONF ${1+"$@"} + -- 1.7.10.4