summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2008-07-18 11:47:53 +0000
committerIan Lynagh <igloo@earth.li>2008-07-18 11:47:53 +0000
commiteed437cdefb952e6c70e58012b23d436e74710af (patch)
tree712e227f0461bae88a31ab0409e7d6c678cb81e3 /utils
parent249bcf1f34e240a39abbcbb29bd6b97ddece421f (diff)
downloadhaskell-eed437cdefb952e6c70e58012b23d436e74710af.tar.gz
More build system changes; ghc-pkg is now built with Cabal
Diffstat (limited to 'utils')
-rw-r--r--utils/Makefile35
-rw-r--r--utils/ghc-pkg/Main.hs58
-rw-r--r--utils/ghc-pkg/Makefile155
-rw-r--r--utils/ghc-pkg/ghc-pkg.cabal32
-rw-r--r--utils/ghc-pkg/ghc-pkg.wrapper4
5 files changed, 132 insertions, 152 deletions
diff --git a/utils/Makefile b/utils/Makefile
index 972716feb8..4ecbd72b0c 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 f2087b979b..7f727d7966 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 5afb448a22..6fba1c814b 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 0000000000..90722a62f7
--- /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 0000000000..1c2b5d2b75
--- /dev/null
+++ b/utils/ghc-pkg/ghc-pkg.wrapper
@@ -0,0 +1,4 @@
+
+PKGCONF=$datadir/package.conf
+exec $executablename --global-conf $PKGCONF ${1+"$@"}
+