Rework the build system a bit
[ghc-hetmet.git] / libraries / Makefile
index 7d4c067..7ac1243 100644 (file)
 # or the following is equivalent:
 #
 #   make rebuild.library.<package>
+#
+# To add a new library to the tree, do
+#
+#   darcs get http://darcs.haskell.org/packages/foo
+#   [ -e foo/configure.ac ] && ( cd foo && autoreconf )
+#   make build.library.foo
 
 .PHONY: default_target
 
@@ -27,7 +33,7 @@ TOP=.
 include $(TOP)/mk/boilerplate.mk
 endif
 
-SUBDIRS = base old-locale old-time directory filepath pretty \
+SUBDIRS = base old-locale old-time directory process filepath pretty \
           template-haskell readline Cabal random haskell98
 
 ifeq "$(GhcLibsWithUnix)" "YES"
@@ -177,7 +183,8 @@ stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: %/setup/Setup
        -$(RM) -f stamp/configure.library.*.$* $*/unbuildable
        ( cd $* && setup/Setup configure \
                   $(CONFIGURE_OPTS) \
-                  --prefix=$(prefix) \
+                  --prefix='$$topdir' \
+                  --libsubdir='$$compiler/lib/$$pkgid' \
                   --with-compiler=../../compiler/ghc-inplace$(dot_bat) \
                   --with-hc-pkg=../../utils/ghc-pkg/ghc-pkg-inplace$(dot_bat) \
                   --with-hsc2hs=../../utils/hsc2hs/hsc2hs-inplace$(dot_bat) \
@@ -200,6 +207,13 @@ build.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
                                        $(addprefix --ghc-option=,$(GhcLibHcOpts))
        ifBuildable/ifBuildable $* setup/Setup register --inplace
 
+$(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/CabalMakefile):\
+%/CabalMakefile: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
+                 %/setup/Setup ifBuildable/ifBuildable
+       $(RM) $*/CabalMakefile
+       ifBuildable/ifBuildable $* setup/Setup makefile -f CabalMakefile \
+                                    $(addprefix --ghc-option=,$(GhcLibHcOpts))
+
 .PHONY: doc
 
 DOC_SUBDIRS = $(filter-out haskell98,$(SUBDIRS))
@@ -214,16 +228,17 @@ doc.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
 
 .PHONY: install install-docs install.library.%
 
-INSTALL_DIR=$(prefix)/share/ghc/doc/html/
+ROOT=$(prefix)/share/ghc/doc/html/
 
 install: $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR))
 ifneq "$(NO_HADDOCK_DOCS)" "YES"
-       $(INSTALL_DATA)   index.html doc-index.html                       $(INSTALL_DIR)
-       $(INSTALL_SCRIPT) gen_contents_index                                      $(INSTALL_DIR)
+       $(INSTALL_DIR)                                            $(ROOT)
+       $(INSTALL_DATA)   index.html doc-index.html               $(ROOT)
+       $(INSTALL_SCRIPT) gen_contents_index                      $(ROOT)
        # Hacks:
-       $(INSTALL_DATA)   $(prefix)/share/ghc/doc/html/base/*.css $(INSTALL_DIR)
-       $(INSTALL_DATA)   $(prefix)/share/ghc/doc/html/base/*.js  $(INSTALL_DIR)
-       $(INSTALL_DATA)   $(prefix)/share/ghc/doc/html/base/*.gif $(INSTALL_DIR)
+       $(INSTALL_DATA)   $(prefix)/share/ghc/doc/html/base/*.css $(ROOT)
+       $(INSTALL_DATA)   $(prefix)/share/ghc/doc/html/base/*.js  $(ROOT)
+       $(INSTALL_DATA)   $(prefix)/share/ghc/doc/html/base/*.gif $(ROOT)
 endif
 
 # Cabal doesn't let us ask to install docs only, so do nothing here
@@ -235,7 +250,7 @@ install-docs:
 # Thus if you install without building then it will just break.
 $(foreach SUBDIR,$(SUBDIRS),install.library.$(SUBDIR)): \
 install.library.%: installPackage/installPackage ifBuildable/ifBuildable
-       ifBuildable/ifBuildable $* ../installPackage/installPackage
+       ifBuildable/ifBuildable $* ../installPackage/installPackage $(prefix) $(bindir)/ghc-pkg
 
 .PHONY: binary-dist binary-dist.library.%