First hack at supporting standalone packages.
What this means is that a non-GHC fptools project which sets
$(PACKAGE) in a Makefile should do something reasonable. It works by
testing whether $(ProjectNameShort) == "ghc", and if it isn't, then:
- it turns off all the machinery that deals with installing the
package for use with the in-place compiler and a (future)
installation of GHC.
- instead, it enables a rule that installs the package using
the installed $(GHC_PKG). The configure script still needs
updating to detect this, so 'make install' won't work yet.
- $(GHC) is used instead of $(GHC_INPLACE) for compiling Haskell
code.
Apart from the detection of ghc-pkg in configure, this should be all
that's needed to get source distributions and 'make install' going.
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
-# $Id: package.mk,v 1.25 2003/05/17 00:11:30 ross Exp $
+# $Id: package.mk,v 1.26 2003/05/22 15:36:08 simonmar Exp $
+ifeq "$(ProjectNameShort)" "ghc"
+STANDALONE_PACKAGE = NO
+else
+STANDALONE_PACKAGE = YES
+endif
+
# -----------------------------------------------------------------------------
# Build the package configuration file and tell the compiler about it.
ifeq "$(way)" ""
# -----------------------------------------------------------------------------
# Build the package configuration file and tell the compiler about it.
ifeq "$(way)" ""
+ifeq "$(STANDALONE_PACKAGE)" "NO"
+PKGCONF_CPP_EXTRA_OPTS = -I$(GHC_INCLUDE_DIR)
+else
+PKGCONF_CPP_EXTRA_OPTS =
+endif
+
+ifeq "$(STANDALONE_PACKAGE)" "NO"
package.conf.inplace : package.conf.in
package.conf.inplace : package.conf.in
- $(CPP) $(RAWCPP_FLAGS) -I$(GHC_INCLUDE_DIR) -x c $(PACKAGE_CPP_OPTS) $< \
+ $(CPP) $(RAWCPP_FLAGS) $(PKGCONF_CPP_EXTRA_OPTS) -x c $(PACKAGE_CPP_OPTS) $< \
package.conf.installed : package.conf.in
package.conf.installed : package.conf.in
- $(CPP) $(RAWCPP_FLAGS) -I$(GHC_INCLUDE_DIR) -DINSTALLING -x c $(PACKAGE_CPP_OPTS) $< \
+ $(CPP) $(RAWCPP_FLAGS) $(PKGCONF_CPP_EXTRA_OPTS) -DINSTALLING -x c $(PACKAGE_CPP_OPTS) $< \
| sed 's/^#.*$$//g' >$@
# we could be more accurate here and add a dependency on
| sed 's/^#.*$$//g' >$@
# we could be more accurate here and add a dependency on
# to 'make clean' in ghc without cleaning in libraries too, the packages
# will be correctly re-installed.
#
# to 'make clean' in ghc without cleaning in libraries too, the packages
# will be correctly re-installed.
#
+ifeq "$(STANDALONE_PACKAGE)" "NO"
+
STAMP_PKG_CONF = $(GHC_DRIVER_DIR)/stamp-pkg-conf-$(PACKAGE)
CLEAN_FILES += $(STAMP_PKG_CONF)
STAMP_PKG_CONF = $(GHC_DRIVER_DIR)/stamp-pkg-conf-$(PACKAGE)
CLEAN_FILES += $(STAMP_PKG_CONF)
CLEAN_FILES += package.conf.installed package.conf.inplace
CLEAN_FILES += package.conf.installed package.conf.inplace
+else # $(STANDALONE_PACKAGE) == "YES"
+
+install :: package.conf.installed
+ $(GHC_PKG) --update-package <package.conf.installed
+
+endif # $(STANDALONE_PACKAGE)
+
endif # $(way) == ""
# -----------------------------------------------------------------------------
# Building the static library libHS<pkg>.a
endif # $(way) == ""
# -----------------------------------------------------------------------------
# Building the static library libHS<pkg>.a
+ifeq "$(STANDALONE_PACKAGE)" "NO"
+HC = $(GHC_INPLACE)
+endif
# -----------------------------------------------------------------------------
# Dependencies
# -----------------------------------------------------------------------------
# Dependencies
+ifeq "$(STANDALONE_PACKAGE)" "NO"
MKDEPENDHS = $(GHC_INPLACE)
MKDEPENDHS = $(GHC_INPLACE)
-SRC_MKDEPENDC_OPTS += $(addprefix -I,$(ALL_DIRS)) -I$(GHC_INCLUDE_DIR)
+endif
+
+SRC_MKDEPENDC_OPTS += $(addprefix -I,$(ALL_DIRS))
+
+ifeq "$(STANDALONE_PACKAGE)" "NO"
+SRC_MKDEPENDC_OPTS += -I$(GHC_INCLUDE_DIR)
+endif
--read-interface=../$(pkg),../$(pkg)/$(pkg).haddock)
%.raw-hs : %.lhs
--read-interface=../$(pkg),../$(pkg)/$(pkg).haddock)
%.raw-hs : %.lhs
- $(GHC_INPLACE) $(HC_OPTS) -D__HADDOCK__ -E -cpp $< -o $<.tmp && sed -e 's/^#.*//' <$<.tmp >$@
+ $(GHC) $(HC_OPTS) -D__HADDOCK__ -E -cpp $< -o $<.tmp && sed -e 's/^#.*//' <$<.tmp >$@
- $(GHC_INPLACE) $(HC_OPTS) -D__HADDOCK__ -E -cpp $< -o $<.tmp && sed -e 's/^#.*//' <$<.tmp >$@
+ $(GHC) $(HC_OPTS) -D__HADDOCK__ -E -cpp $< -o $<.tmp && sed -e 's/^#.*//' <$<.tmp >$@
install-docs :: $(HTML_DOC)
@$(INSTALL_DIR) $(datadir)/html/$(PACKAGE)
install-docs :: $(HTML_DOC)
@$(INSTALL_DIR) $(datadir)/html/$(PACKAGE)