Move the register-inplace special-case stuff into the ghc-prim package
[ghc-hetmet.git] / libraries / Makefile
index 5af0f7e..6a38e3d 100644 (file)
@@ -12,7 +12,7 @@
 #
 # or the following is equivalent:
 #
-#   make rebuild.library.<package>
+#   make remake.library.<package>
 #
 # To add a new library to the tree, do
 #
@@ -38,15 +38,15 @@ show:
 TOP=..
 include $(TOP)/mk/boilerplate.mk
 
-SUBDIRS  = base array packedstring containers bytestring
-SUBDIRS += old-locale old-time filepath directory
+SUBDIRS  = ghc-prim $(INTEGER_LIBRARY) base array packedstring
+SUBDIRS += containers bytestring old-locale old-time filepath directory
 ifeq "$(GhcLibsWithUnix)" "YES"
 SUBDIRS += unix
 endif
 ifeq "$(Windows)" "YES"
 SUBDIRS += $(wildcard Win32)
 endif
-SUBDIRS += process pretty hpc template-haskell readline Cabal random haskell98
+SUBDIRS += process pretty hpc template-haskell editline Cabal random haskell98
 
 # Set GhcBootLibs=YES from the command line to work with just the libraries
 # needed to bootstrap GHC.
@@ -163,12 +163,15 @@ boot: $(BOOTSTRAP_STAMPS) ifBuildable/ifBuildable \
 
 # We ought to be depending on %/Setup.*hs, but make makes that difficult.
 
+# -fffi is only needed for GHC 6.4 at the time of writing
+CABAL_GHC_FLAGS = -Wall -cpp -fffi
+
 $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup): \
 %/setup/Setup: $(BOOTSTRAP_STAMPS)
        -$(RM) -rf $*/setup
        mkdir $*/setup
        $(CP) $*/Setup.*hs $*/setup
-       cd $*/setup && $(GHC) -Wall -cpp --make Setup.*hs -o Setup \
+       cd $*/setup && $(GHC) $(CABAL_GHC_FLAGS) --make Setup.*hs -o Setup \
                              $(BOOTSTRAP_INC_2_UP)
 
 installPackage/installPackage: installPackage.hs $(BOOTSTRAP_STAMPS)
@@ -176,11 +179,11 @@ installPackage/installPackage: installPackage.hs $(BOOTSTRAP_STAMPS)
        mkdir installPackage
        $(CP) installPackage.hs installPackage/
 ifeq "$(stage)" "2"
-       cd installPackage && ../$(HC) -Wall -cpp \
+       cd installPackage && ../$(HC) $(CABAL_GHC_FLAGS) \
                                    --make installPackage -o installPackage \
                                    $(BOOTSTRAP_INC_1_UP) $(DEPLOYMENT_OPTS)
 else
-       cd installPackage && $(GHC) -Wall -cpp \
+       cd installPackage && $(GHC) $(CABAL_GHC_FLAGS) \
                                    --make installPackage -o installPackage \
                                    $(BOOTSTRAP_INC_1_UP)
 endif
@@ -215,9 +218,13 @@ all: doc
 endif
 
 .PHONY: rebuild.library.%
+.PHONY: remake.library.%
 
 $(foreach SUBDIR,$(SUBDIRS),rebuild.library.$(SUBDIR)):\
-rebuild.library.%: clean.library.% make.library.%
+rebuild.library.%: clean.library.% build.library.%
+
+$(foreach SUBDIR,$(SUBDIRS),remake.library.$(SUBDIR)):\
+remake.library.%: clean.library.% make.library.%
 
 # NB. we're depending on make chasing dependencies from left to right here.
 # This bit goes wrong with 'make -j'.
@@ -242,21 +249,23 @@ FLAGGED_CONFIGURE_ARGS = $(subst $(space)',\
                                  $(space)--configure-option=',\
                                  $(space)$(CONFIGURE_ARGS))
 
-$(foreach SUBDIR,$(SUBDIRS), \
-                 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR)): \
-stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: %/setup/Setup
-       -$(RM) -f stamp/configure.library.*.$* $*/unbuildable
-       ( cd $* && setup/Setup configure \
+ifeq "$(Windows)" "YES"
+NONEXISTENT=c:/NONEXISTENT
+else
+NONEXISTENT=/NONEXISTENT
+endif
+
+ALL_CONFIGURE_FLAGS = \
                   $(CONFIGURE_OPTS) \
-                  --prefix=/NONEXISTANT \
-                  --bindir=/NONEXISTANT \
-                  --libdir=/NONEXISTANT \
+                  --prefix=$(NONEXISTENT) \
+                  --bindir=$(NONEXISTENT) \
+                  --libdir=$(NONEXISTENT) \
                   --libsubdir='$$pkgid' \
-                  --libexecdir=/NONEXISTANT \
-                  --datadir=/NONEXISTANT \
-                  --docdir=/NONEXISTANT \
-                          --haddockdir=/NONEXISTANT \
-                  --htmldir=/NONEXISTANT \
+                  --libexecdir=$(NONEXISTENT) \
+                  --datadir=$(NONEXISTENT) \
+                  --docdir=$(NONEXISTENT) \
+                          --haddockdir=$(NONEXISTENT) \
+                  --htmldir=$(NONEXISTENT) \
                   --with-compiler=../../compiler/stage1/ghc-inplace \
                   --with-hc-pkg=../../utils/ghc-pkg/ghc-pkg-inplace \
                   --with-hsc2hs=../../utils/hsc2hs/hsc2hs-inplace \
@@ -264,7 +273,13 @@ stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: %/setup/Setup
                   --haddock-options="--use-contents=../index.html \
                                   --use-index=../doc-index.html" \
                   $(FLAGGED_CONFIGURE_ARGS) \
-                  --configure-option=--with-cc=$(CC) ) \
+                  --configure-option=--with-cc=$(CC)
+
+$(foreach SUBDIR,$(SUBDIRS), \
+                 stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR)): \
+stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: %/setup/Setup
+       -$(RM) -f stamp/configure.library.*.$* $*/unbuildable
+       ( cd $* && setup/Setup configure $(ALL_CONFIGURE_FLAGS) ) \
              && touch $@ || touch $*/unbuildable
 # We don't touch $@ if configure failed as we would prefer to try
 # configuring it next time round, rather than assuming it'll still fail.
@@ -276,7 +291,9 @@ stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: %/setup/Setup
 # needs to be done.  However, we're careful not to overwrite GNUmakefile
 # if it hasn't changed, so that dependency-generation isn't forced
 # every time.
-$(foreach SUBDIR,$(SUBDIRS),make.library.$(SUBDIR)):\
+# I doubt that the makefile way will work with ndp, so filter it out and use
+# a rule below to call build.library.ndp instead
+$(foreach SUBDIR,$(filter-out ndp,$(SUBDIRS)),make.library.$(SUBDIR)):\
 make.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
                 %/setup/Setup ifBuildable/ifBuildable installPackage/installPackage
        if ifBuildable/ifBuildable $*; then \
@@ -286,9 +303,12 @@ make.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
          setup/Setup makefile -f GNUmakefile; \
          cmp -s GNUmakefile GNUmakefile.tmp && mv GNUmakefile.tmp GNUmakefile; \
          $(MAKE) $(MFLAGS) && \
-         ../installPackage/installPackage register --inplace; \
+         setup/Setup register --inplace; \
        fi
 
+# Hack for ndp, as described above
+make.library.ndp: build.library.ndp
+
 # Build the library using 'setup build' (not the default)
 $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR)):\
 build.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
@@ -296,6 +316,7 @@ build.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
        if ifBuildable/ifBuildable $*; then \
          cd $* && \
          setup/Setup build $(addprefix --ghc-option=,$(GhcLibHcOpts)); \
+         setup/Setup register --inplace; \
        fi
 
 .PHONY: doc html
@@ -318,7 +339,9 @@ doc.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
                                       $(CABAL_HADDOCK_FLAGS); \
        fi
 ifneq "$(HSCOLOUR)" ""
-       if ifBuildable/ifBuildable $*; then cp hscolour.css $*/dist/doc/html/$*/src/; fi
+# We use */src rather than $*/src due to the $(INTEGER_LIBRARY)/integer
+# mismatch
+       if ifBuildable/ifBuildable $*; then cp hscolour.css $*/dist/doc/html/*/src/; fi
 endif
 
 .PHONY: distclean clean clean.library.%