[project @ 2005-01-20 14:22:19 by simonmar]
authorsimonmar <unknown>
Thu, 20 Jan 2005 14:22:33 +0000 (14:22 +0000)
committersimonmar <unknown>
Thu, 20 Jan 2005 14:22:33 +0000 (14:22 +0000)
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
distrib/Makefile-bin.in
ghc/compiler/main/Packages.lhs
ghc/compiler/main/SysTools.lhs
ghc/mk/config.mk.in
ghc/utils/ghc-pkg/Main.hs
mk/package.mk

index 098146b..0bfbf0e 100644 (file)
--- 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
index 4372ea9..09b6d66 100644 (file)
@@ -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.bak >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); \
index 93a8856..4b758b2 100644 (file)
@@ -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
 
 
index e37683f..787222f 100644 (file)
@@ -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
index b121518..2a787ca 100644 (file)
@@ -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
index e57a383..477028c 100644 (file)
@@ -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 ()
index 93fed76..7cdd6cd 100644 (file)
@@ -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 <package.conf.inplace
-       $(GHC_PKG_INPLACE)  -f $(GHC_DRIVER_DIR)/package.conf --update-package <package.conf.installed
+       $(GHC_PKG_INPLACE) --force --update-package <package.conf.inplace
+       $(GHC_PKG_INPLACE)  -f $(GHC_DRIVER_DIR)/package.conf --force --update-package <package.conf.installed
        @touch $(STAMP_PKG_CONF)
 
 CLEAN_FILES += package.conf.installed package.conf.inplace 
@@ -79,7 +135,6 @@ else # $(STANDALONE_PACKAGE) == "YES"
 PACKAGE_CPP_OPTS += -DPACKAGE_DEPS='$(subst " ","$(comma) ",$(patsubst %,"%",$(PACKAGE_DEPS)))'
 PACKAGE_CPP_OPTS += -DLIBRARY=\"HS$(PACKAGE)\"
 PACKAGE_CPP_OPTS += -DLIBDIR=\"$(libdir)\"
-PACKAGE_CPP_OPTS += -DFPTOOLS_TOP_ABS=\"${FPTOOLS_TOP_ABS}\"
 
 # Let the package configuration file refer to $(libdir) as
 # ${pkglibdir}.  Note we can't use ${libdir} because ghc-pkg already
@@ -308,13 +363,16 @@ CLEAN_FILES += $(PACKAGE).haddock
 %.raw-hs : %.hs
        $(HC) $(HC_OPTS) -D__HADDOCK__ -E -optP-P $< -o $@
 
+HTML_INSTALL_DIR = $(datadir)/html/libraries/$(PACKAGE)
+#  NOT the same as HTML_DIR_INSTALLED when BIN_DIST is on
+
 install-docs :: $(HTML_DOC)
-       @$(INSTALL_DIR) $(datadir)/html/libraries/$(PACKAGE)
+       @$(INSTALL_DIR) $(HTML_INSTALL_DIR)
        @for i in $(HTML_DIR)/*; do \
-          echo $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(datadir)/html/libraries/$(PACKAGE); \
-          $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(datadir)/html/libraries/$(PACKAGE); \
+          echo $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(HTML_INSTALL_DIR); \
+          $(INSTALL_DATA) $(INSTALL_OPTS) $$i $(HTML_INSTALL_DIR); \
        done
-       $(INSTALL_DATA) $(INSTALL_OPTS) $(PACKAGE).haddock $(datadir)/html/libraries/$(PACKAGE)
+       $(INSTALL_DATA) $(INSTALL_OPTS) $(PACKAGE).haddock $(HTML_INSTALL_DIR)
 
 endif # HS_PPS
 endif # NO_HADDOCK_DOCS