Always do 'setup makefile' before building each library
authorSimon Marlow <simonmar@microsoft.com>
Tue, 20 Nov 2007 10:33:29 +0000 (10:33 +0000)
committerSimon Marlow <simonmar@microsoft.com>
Tue, 20 Nov 2007 10:33:29 +0000 (10:33 +0000)
This forces preprocessing to happen, which is necessary if any of the
.hsc files have been modified.  Without this change, a 'setup
makefile' would be required by hand after a .hsc file changed.
Fortunately 'setup makefile' isn't much extra work, and I've made it
not overwrite GNUmakefile if it hasn't changed, which avoids
recalculating the dependencies each time.

libraries/Makefile

index ea574e1..7cf8238 100644 (file)
@@ -250,12 +250,19 @@ stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: %/setup/Setup
 # 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).% \
-               %/GNUmakefile \
                 %/setup/Setup ifBuildable/ifBuildable
        if ifBuildable/ifBuildable $*; then \
          cd $* && \
+         cmp -s ../Makefile.local Makefile.local || cp ../Makefile.local .; \
+         mv GNUmakefile GNUmakefile.tmp; \
+         setup/Setup makefile -f GNUmakefile; \
+         cmp -s GNUmakefile GNUmakefile.tmp && mv GNUmakefile.tmp GNUmakefile; \
          $(MAKE) $(MFLAGS) && \
          setup/Setup register --inplace; \
        fi
@@ -269,15 +276,6 @@ build.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
          setup/Setup build $(addprefix --ghc-option=,$(GhcLibHcOpts)); \
        fi
 
-$(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/GNUmakefile):\
-%/GNUmakefile: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \
-                 %/setup/Setup ifBuildable/ifBuildable
-       $(RM) $*/GNUmakefile
-       cp Makefile.local $*
-       if ifBuildable/ifBuildable $*; then \
-          cd $* && setup/Setup makefile -f GNUmakefile; \
-       fi
-
 .PHONY: doc html
 
 html: doc