From b802bbad8dc2a401c131264cbd08620179f8999b Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Wed, 20 Jun 2007 12:20:09 +0000 Subject: [PATCH] Use setup makefile + make by default to build libraries The advantages of this are (a) it's a step closer to getting -j working again (make -j works in an individual library, but not in libraries/ yet). (b) it's easier to hack on libraries: make dist/build/Foo.o (c) it's a step closer to getting HC bootstrapping again The build system creates /GNUmakefile as part of 'make boot'. This was chosen so as not to interfere with existing Makefiles, but it's a bit of a hack. (previously I used CabalMakefile, but that means adding -f CabalMakefile each time you run make, and that's a pain). --- libraries/Makefile | 30 ++++++++++++++++++++---------- libraries/Makefile.local | 19 +++++++++++++++++++ 2 files changed, 39 insertions(+), 10 deletions(-) create mode 100644 libraries/Makefile.local diff --git a/libraries/Makefile b/libraries/Makefile index 63f852a..0ef78d8 100644 --- a/libraries/Makefile +++ b/libraries/Makefile @@ -8,7 +8,7 @@ # To rebuild a particular library : # # make clean.library. -# make build.library. +# make make.library. # # or the following is equivalent: # @@ -18,7 +18,7 @@ # # darcs get http://darcs.haskell.org/packages/foo # [ -e foo/configure.ac ] && ( cd foo && autoreconf ) -# make build.library.foo +# make make.library.foo .PHONY: default_target @@ -117,6 +117,7 @@ subdirs: boot: $(BOOTSTRAP_STAMPS) ifBuildable/ifBuildable \ $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/setup/Setup) \ + $(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/GNUmakefile) \ installPackage/installPackage # We build the Setup program in a setup subdirectory to stop it trying @@ -165,15 +166,16 @@ endif .PHONY: rebuild.library.% $(foreach SUBDIR,$(SUBDIRS),rebuild.library.$(SUBDIR)):\ -rebuild.library.%: clean.library.% build.library.% +rebuild.library.%: clean.library.% make.library.% -build: $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR)) +build: $(foreach SUBDIR,$(SUBDIRS),make.library.$(SUBDIR)) build: installPackage/installPackage configure: $(foreach SUBDIR,$(SUBDIRS), \ stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).$(SUBDIR)) .PHONY: build.library.% +.PHONY: make.library.% # We should depend on %/%.cabal here (and in other rules), but make # makes that difficult. @@ -216,19 +218,27 @@ stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).%: %/setup/Setup # This is particularly important for corelibs, where failure means the # build dies! +# Build the library using 'make' +$(foreach SUBDIR,$(SUBDIRS),make.library.$(SUBDIR)):\ +make.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \ + %/GNUmakefile \ + %/setup/Setup ifBuildable/ifBuildable + ifBuildable/ifBuildable $* $(MAKE) + ifBuildable/ifBuildable $* setup/Setup register --inplace + +# Build the library using 'setup build' (not the default) $(foreach SUBDIR,$(SUBDIRS),build.library.$(SUBDIR)):\ build.library.%: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \ %/setup/Setup ifBuildable/ifBuildable ifBuildable/ifBuildable $* setup/Setup build \ $(addprefix --ghc-option=,$(GhcLibHcOpts)) - ifBuildable/ifBuildable $* setup/Setup register --inplace -$(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/CabalMakefile):\ -%/CabalMakefile: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \ +$(foreach SUBDIR,$(SUBDIRS),$(SUBDIR)/GNUmakefile):\ +%/GNUmakefile: stamp/configure.library.build$(CONFIGURE_STAMP_EXTRAS).% \ %/setup/Setup ifBuildable/ifBuildable - $(RM) $*/CabalMakefile - ifBuildable/ifBuildable $* setup/Setup makefile -f CabalMakefile \ - $(addprefix --ghc-option=,$(GhcLibHcOpts)) + $(RM) $*/GNUmakefile + cp Makefile.local $* + ifBuildable/ifBuildable $* setup/Setup makefile -f GNUmakefile .PHONY: doc diff --git a/libraries/Makefile.local b/libraries/Makefile.local new file mode 100644 index 0000000..ec84d6e --- /dev/null +++ b/libraries/Makefile.local @@ -0,0 +1,19 @@ +# Local GHC-build-tree customization for Cabal makefiles. We want to build +# libraries using flags that the user has put in build.mk. + +# Careful here: including boilerplate.mk breaks things, because paths.mk and +# opts.mk overrides some of the variable settings in the Cabal Makefile, so +# we just include config.mk and build.mk. +TOP=../.. +SAVE_GHC := $(GHC) +SAVE_AR := $(AR) +SAVE_LD := $(LD) +include $(TOP)/mk/config.mk +include $(TOP)/mk/build.mk +GHC := $(SAVE_GHC) +AR := $(SAVE_AR) +LD := $(SAVE_LD) + +# Now add flags from the GHC build system to the Cabal build: +GHC_OPTS += $(SRC_HC_OPTS) +GHC_OPTS += $(GhcLibHcOpts) -- 1.7.10.4