-stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: %/setup/Setup
- -$(RM) -f stamp/configure.library.*.$*
- cd $* && setup/Setup configure \
- $(CONFIGURE_OPTS) \
- --prefix=$(prefix) \
- --with-compiler=../../compiler/ghc-inplace \
- --with-hc-pkg=../../utils/ghc-pkg/ghc-pkg-inplace \
- --datasubdir=ghc \
- --haddock-args="--use-contents=../index.html --use-index=../doc-index.html"
- touch $@
-
+stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: cabal-bin
+ -$(RM) -f stamp/configure.library.*.$* $*/unbuildable
+ $(MKDIRHIER) `dirname $@`
+ ( cd $* && $(CABAL) 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.
+# This is particularly important for bootlibs, where failure means the
+# build dies!
+
+# Build the library using 'make'
+# We re-run 'setup makefile' each time, just in case any preprocessing
+# 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)):\
+make.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
+ cabal-bin ifBuildable/ifBuildable
+ if $(IFBUILDABLE) $*; then \
+ cd $* && \
+ cmp -s $(MAKEFILE_LOCAL) Makefile.local || cp $(MAKEFILE_LOCAL) .; \
+ mv GNUmakefile GNUmakefile.tmp; \
+ $(CABAL) makefile -f GNUmakefile; \
+ cmp -s GNUmakefile GNUmakefile.tmp && mv GNUmakefile.tmp GNUmakefile; \
+ $(MAKE) $(MFLAGS) && \
+ $(CABAL) register --inplace; \
+ fi
+
+MAKEFILE_LOCAL = $(FPTOOLS_TOP_ABS)/libraries/Makefile.local
+
+# Build the library using 'setup build' (not the default)