From c830ae13ccd7373b5478e10382a57d497ebc6a40 Mon Sep 17 00:00:00 2001 From: simonmar Date: Thu, 20 Jan 2005 14:22:33 +0000 Subject: [PATCH] [project @ 2005-01-20 14:22:19 by simonmar] Fill in the haddock-interfaces and haddock-html fields in the package.conf files. To do this I had to make some changes: - haddock-interfaces requires the value of $(datadir). We can't just plug this in, because $(datadir) might change at install-time (eg. a Windows installer can be placed anywhere, as can a Unix binary .tar.gz distribution). The current trick is for the compiler to splice in the value of $libdir in package.conf at runtime. So we could extend this mechanism and tell the compiler the value of $datadir via a command-line option, but that seems ugly. On Windows, $datadir==$libdir, so we don't need any changes: package.conf still uses $libdir, and a Windows installation is independent of its absolute location. Even 'make install' on Windows should have this property. On Unix: - for 'make install' and in-place execution, we just use absolute paths in package.conf - for a binary dist, we generate a package.conf that refers to $libdir and $datadir, and splice in the values at install-time (distrib/Makefile-bin.in). - Also, I renamed $libdir to $topdir to more closely reflect its actual meaning. This is somewhat malicious in that it will flush out all those clients using $libdir when they really shouldn't be :-) --- Makefile | 1 + distrib/Makefile-bin.in | 10 ++++- ghc/compiler/main/Packages.lhs | 6 +-- ghc/compiler/main/SysTools.lhs | 4 +- ghc/mk/config.mk.in | 1 + ghc/utils/ghc-pkg/Main.hs | 6 +-- mk/package.mk | 84 +++++++++++++++++++++++++++++++++------- 7 files changed, 90 insertions(+), 22 deletions(-) diff --git a/Makefile b/Makefile index 098146b..0bfbf0e 100644 --- a/Makefile +++ b/Makefile @@ -267,6 +267,7 @@ binary-dist:: echo "PACKAGE_SH_SCRIPTS = $($(Project)BinDistShScripts)" >> $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in echo "PACKAGE_PRL_SCRIPTS = $($(Project)BinDistPrlScripts)" >> $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in echo "PACKAGE_LIB_PRL_SCRIPTS = $($(Project)BinDistLibPrlScripts)" >> $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in + echo "PACKAGE_LIB_SPLICED_FILES = $($(Project)BinDistLibSplicedFiles)" >> $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in echo "PACKAGE_BINS = $($(Project)BinDistBins)" >> $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in echo "PACKAGE_LINKS = $($(Project)BinDistLinks)" >> $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in cat $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile-bin.in >> $(BIN_DIST_TMPDIR)/$(BIN_DIST_NAME)/Makefile.in diff --git a/distrib/Makefile-bin.in b/distrib/Makefile-bin.in index 4372ea9..09b6d66 100644 --- a/distrib/Makefile-bin.in +++ b/distrib/Makefile-bin.in @@ -166,10 +166,18 @@ config-pkgs :: echo "Done."; \ fi; \ done + @for i in $(PACKAGE_LIB_SPLICED_FILES) ""; do \ + if test "$$i"; then \ + echo "Creating a configured version of $$i .."; \ + if [ -f lib/$(platform)/$$i ]; then $(MV) lib/$(platform)/$$i lib/$(platform)/$$i.bak; fi; \ + $(SED) -e "s|\$$libdir|$(libdir)|g \ + s|\$$datadir|$(datadir)|g" lib/$(platform)/$$i; \ + fi; \ + done in-place :: $(MAKE) $(MFLAGS) config-pkgs bindir=`pwd`/bin/$(platform) libdir=`pwd`/lib/$(platform) datadir=`pwd`/share - if test -x "./post-inplace-script" ; then \ + @if test -x "./post-inplace-script" ; then \ echo "Running project-specific post-inplace script ..." ; \ ./post-inplace-script $(platform) `pwd` \ $(package)-$(version); \ diff --git a/ghc/compiler/main/Packages.lhs b/ghc/compiler/main/Packages.lhs index 93a8856..4b758b2 100644 --- a/ghc/compiler/main/Packages.lhs +++ b/ghc/compiler/main/Packages.lhs @@ -234,8 +234,8 @@ readPackageConfig dflags pkg_map conf_file = do mungePackagePaths :: String -> [PackageConfig] -> [PackageConfig] --- Replace the string "$libdir" at the beginning of a path --- with the current libdir (obtained from the -B option). +-- Replace the string "$topdir" at the beginning of a path +-- with the current topdir (obtained from the -B option). mungePackagePaths top_dir ps = map munge_pkg ps where munge_pkg p = p{ importDirs = munge_paths (importDirs p), @@ -246,7 +246,7 @@ mungePackagePaths top_dir ps = map munge_pkg ps munge_paths = map munge_path munge_path p - | Just p' <- maybePrefixMatch "$libdir" p = top_dir ++ p' + | Just p' <- maybePrefixMatch "$topdir" p = top_dir ++ p' | otherwise = p diff --git a/ghc/compiler/main/SysTools.lhs b/ghc/compiler/main/SysTools.lhs index e37683f..787222f 100644 --- a/ghc/compiler/main/SysTools.lhs +++ b/ghc/compiler/main/SysTools.lhs @@ -27,7 +27,7 @@ module SysTools ( -- Command-line override setDryRun, - getTopDir, -- IO String -- The value of $libdir + getTopDir, -- IO String -- The value of $topdir getPackageConfigPath, -- IO String -- Where package.conf is getUsageMsgPaths, -- IO (String,String) @@ -166,7 +166,7 @@ Package {name = "tools", import_dirs = [], source_dirs = [], library_dirs = [], hs_libraries = [], extra_libraries = [], include_dirs = [], c_includes = [], package_deps = [], - extra_ghc_opts = ["-pgmc/usr/bin/gcc","-pgml${libdir}/bin/unlit", ... etc.], + extra_ghc_opts = ["-pgmc/usr/bin/gcc","-pgml${topdir}/bin/unlit", ... etc.], extra_cc_opts = [], extra_ld_opts = []} Which would have the advantage that we get to collect together in one diff --git a/ghc/mk/config.mk.in b/ghc/mk/config.mk.in index b121518..2a787ca 100644 --- a/ghc/mk/config.mk.in +++ b/ghc/mk/config.mk.in @@ -21,6 +21,7 @@ GhcBinDistPrlScripts = GhcBinDistLibPrlScripts = ghc-asm ghc-split GhcBinDistBins = hp2ps ghcprof GhcBinDistLinks = ghc ghci ghc-pkg +GhcBinDistLibSplicedFiles = package.conf # ----------------------------------------------------------------------------- # GHC-specific configuration settings diff --git a/ghc/utils/ghc-pkg/Main.hs b/ghc/utils/ghc-pkg/Main.hs index e57a383..477028c 100644 --- a/ghc/utils/ghc-pkg/Main.hs +++ b/ghc/utils/ghc-pkg/Main.hs @@ -543,8 +543,8 @@ checkDuplicates db_stack pkg update = do checkDir :: Bool -> String -> IO () checkDir force d - | "$libdir" `isPrefixOf` d = return () - -- can't check this, because we don't know what $libdir is + | "$topdir" `isPrefixOf` d = return () + -- can't check this, because we don't know what $topdir is | otherwise = do there <- doesDirectoryExist d when (not there) @@ -579,7 +579,7 @@ checkHSLib dirs auto_ghci_libs force lib = do doesLibExistIn :: String -> String -> IO Bool doesLibExistIn lib d - | "$libdir" `isPrefixOf` d = return True + | "$topdir" `isPrefixOf` d = return True | otherwise = doesFileExist (d ++ '/':lib) checkGHCiLib :: [String] -> String -> String -> String -> Bool -> IO () diff --git a/mk/package.mk b/mk/package.mk index 93fed76..7cdd6cd 100644 --- a/mk/package.mk +++ b/mk/package.mk @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# $Id: package.mk,v 1.43 2005/01/14 08:01:27 wolfgang Exp $ +# $Id: package.mk,v 1.44 2005/01/20 14:22:31 simonmar Exp $ ifneq "$(PACKAGE)" "" @@ -12,8 +12,58 @@ endif endif # ----------------------------------------------------------------------------- +# Directory layouts, installation etc. + +# Here Windows & Unix differ. On Windows, the value of $(prefix) is known +# to the compiler, and spliced into package.conf in place of $topdir at +# runtime. +# +# On Unix, we only use absolute paths in package.conf, except that when +# building a binary distribution we use $libdir and $datadir in package.conf +# which are then replaced by the correct values at install time. +# + +ifeq "$(Windows)" "YES" + +PKG_LIBDIR = $$topdir +PKG_DATADIR = $$topdir + +else + +ifeq "$(BIN_DIST)" "" +PKG_LIBDIR = $(libdir) +PKG_DATADIR = $(datadir) +else +PKG_LIBDIR = $$libdir +PKG_DATADIR = $$datadir +endif + +endif # Unix + +IMPORT_DIR_INSTALLED = $(PKG_LIBDIR)/imports +IMPORT_DIR_INPLACE = $(FPTOOLS_TOP_ABS)/libraries/$(PACKAGE) + +INCLODE_DIR_INSTALLED = +INCLUDE_DIR_INPLACE = $(FPTOOLS_TOP_ABS)/libraries/$(PACKAGE)/include + +LIB_DIR_INSTALLED = $(PKG_LIBDIR) +LIB_DIR_INPLACE = $(FPTOOLS_TOP_ABS)/libraries/$(PACKAGE) + +DATA_DIR_INSTALLED = $(PKG_DATADIR) +DATA_DIR_INPLACE = $(FPTOOLS_TOP_ABS)/libraries/$(PACKAGE) + +HTML_DIR_INPLACE = $(FPTOOLS_TOP_ABS)/libraries/$(PACKAGE)/html +HTML_DIR_INSTALLED = $(PKG_DATADIR)/html/libraries/$(PACKAGE) + +HADDOCK_IFACE_INPLACE = $(HTML_DIR_INPLACE)/$(PACKAGE).haddock +HADDOCK_IFACE_INSTALLED = $(HTML_DIR_INSTALLED)/$(PACKAGE).haddock + +# ----------------------------------------------------------------------------- # Build the package configuration file and tell the compiler about it. +# We want to build two versions of the package configuration: one for use +# in the + ifeq "$(way)" "" ifeq "$(STANDALONE_PACKAGE)" "NO" @@ -25,16 +75,18 @@ endif PACKAGE_CPP_OPTS += -DPACKAGE=${PACKAGE} PACKAGE_CPP_OPTS += -DVERSION=${VERSION} -IMPORT_DIR_INSTALLED = $$libdir/imports -IMPORT_DIR_INPLACE = $$libdir/libraries/$(PACKAGE) - -LIB_DIR_INSTALLED = $$libdir -LIB_DIR_INPLACE = $$libdir/libraries/$(PACKAGE) +PACKAGE_CPP_OPTS += -DPKG_LIBDIR='"$(PKG_LIBDIR)"' +PACKAGE_CPP_OPTS += -DPKG_DATADIR='"$(PKG_DATADIR)"' package.conf.inplace : package.conf.in $(CPP) $(RAWCPP_FLAGS) -P \ -DIMPORT_DIR='"$(IMPORT_DIR_INPLACE)"' \ -DLIB_DIR='"$(LIB_DIR_INPLACE)"' \ + -DINCLUDE_DIR='"$(INCLUDE_DIR_INPLACE)"' \ + -DDATA_DIR='"$(DATA_DIR_INPLACE)"' \ + -DHTML_DIR='"$(HTML_DIR_INPLACE)"' \ + -DHADDOCK_IFACE='"$(HADDOCK_IFACE_INPLACE)"' \ + -DFPTOOLS_TOP_ABS=\"${FPTOOLS_TOP_ABS}\" \ -x c $(PACKAGE_CPP_OPTS) $< | \ grep -v '^#pragma GCC' | \ sed -e 's/""//g' -e 's/:[ ]*,/: /g' >$@ @@ -43,6 +95,10 @@ package.conf.installed : package.conf.in $(CPP) $(RAWCPP_FLAGS) -P -DINSTALLING \ -DIMPORT_DIR='"$(IMPORT_DIR_INSTALLED)"' \ -DLIB_DIR='"$(LIB_DIR_INSTALLED)"' \ + -DINCLUDE_DIR='"$(INCLUDE_DIR_INSTALLED)"' \ + -DDATA_DIR='"$(DATA_DIR_INSTALLED)"' \ + -DHTML_DIR='"$(HTML_DIR_INSTALLED)"' \ + -DHADDOCK_IFACE='"$(HADDOCK_IFACE_INSTALLED)"' \ -x c $(PACKAGE_CPP_OPTS) $< | \ grep -v '^#pragma GCC' | \ sed -e 's/""//g' -e 's/:[ ]*,/: /g' >$@ @@ -68,8 +124,8 @@ boot all :: $(STAMP_PKG_CONF) endif $(STAMP_PKG_CONF) : package.conf.inplace package.conf.installed - $(GHC_PKG_INPLACE) --update-package