summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Lynagh <igloo@earth.li>2008-07-03 00:13:00 +0000
committerIan Lynagh <igloo@earth.li>2008-07-03 00:13:00 +0000
commit79b4f894215ae098c26cfe8fb7bc7f89008e8420 (patch)
treeaf265304f2e5d118b9495bb1b47e97972f09416f
parenta8d57b05e71ad859eb0024704b216fe1de9f362a (diff)
downloadhaskell-79b4f894215ae098c26cfe8fb7bc7f89008e8420.tar.gz
Teach cabal-bin how to build Setup programs
We now build a copy of Cabal and put it in a bootstrapping package.conf. We also make boot in libraries much earlier in the build process, so we can use cabal-bin for more stuff in the future.
-rw-r--r--Makefile2
-rw-r--r--libraries/Makefile36
-rw-r--r--libraries/cabal-bin.hs19
3 files changed, 39 insertions, 18 deletions
diff --git a/Makefile b/Makefile
index 23c0a74f90..c4ff13cfca 100644
--- a/Makefile
+++ b/Makefile
@@ -98,6 +98,7 @@ endif
endif
stage1 : $(GCC_LIB_DEP) check-packages
+ $(MAKE) -C libraries boot
$(MAKE) -C utils/mkdependC boot
@case '${MFLAGS}' in *-[ik]*) x_on_err=0;; *-r*[ik]*) x_on_err=0;; *) x_on_err=1;; esac; \
for i in $(SUBDIRS_BUILD); do \
@@ -116,7 +117,6 @@ stage1 : $(GCC_LIB_DEP) check-packages
$(MAKE) --no-print-directory -C $$i $(MFLAGS) all; \
if [ $$? -eq 0 -o $$x_on_err -eq 0 ] ; then true; else exit 1; fi; \
done
- $(MAKE) -C libraries boot
$(MAKE) -C libraries all
# When making distributions (i.e., whether with binary-dist or using the
diff --git a/libraries/Makefile b/libraries/Makefile
index b58777db51..e3cb6347b4 100644
--- a/libraries/Makefile
+++ b/libraries/Makefile
@@ -158,14 +158,11 @@ DEPLOYMENT_OPTS = $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS)) \
subdirs:
@echo $(SUBDIRS)
-.PHONY: boot
-
-boot: ifBuildable/ifBuildable cabal-bin ghc-prim/Setup
-
HERE_ABS=$(FPTOOLS_TOP_ABS)/libraries
IFBUILDABLE=ifBuildable/ifBuildable $(HERE_ABS)/boot-packages
-CABAL=$(HERE_ABS)/cabal-bin
+CABAL=$(HERE_ABS)/cabal-bin $(GHC) $(BOOTSTRAPPING_CONF)
+BOOTSTRAPPING_CONF=$(HERE_ABS)/bootstrapping.conf
CABAL_GHC_FLAGS = -Wall
ifeq "$(ghc_ge_605)" "NO"
@@ -174,16 +171,24 @@ endif
BOOTSTRAPPING_FLAGS = $(CABAL_GHC_FLAGS) -DCABAL_VERSION=1,3 -odir $(HERE_ABS)/bootstrapping -hidir $(HERE_ABS)/bootstrapping -i$(HERE_ABS)/Cabal -i$(HERE_ABS)/filepath
-# We use -main-is so that GHC doesn't get confused and think
-# Main.hi/Main.o from cabal belongs to ghc-prim/Setup, or vice-versa.
-cabal-bin: cabal-bin.hs
- $(GHC) $(BOOTSTRAPPING_FLAGS) --make cabal-bin -o cabal-bin -main-is Cabal
+.PHONY: boot
+
+boot: ifBuildable/ifBuildable cabal-bin $(BOOTSTRAPPING_CONF)
-# ghc-prim/Setup doesn't really depend on cabal-bin, but pretending that it
-# does sequentialises building the two of them, which is nice given
-# they're sharing -odir and -hidir.
-ghc-prim/Setup: ghc-prim/Setup.hs cabal-bin
- cd ghc-prim && $(GHC) $(BOOTSTRAPPING_FLAGS) --make Setup -o Setup
+cabal-bin: cabal-bin.hs
+ $(GHC) $(BOOTSTRAPPING_FLAGS) --make cabal-bin -o cabal-bin
+
+$(BOOTSTRAPPING_CONF): cabal-bin
+ echo "[]" > $@.tmp
+ -cd filepath && $(CABAL) clean --distpref=dist-bootstrapping
+ cd filepath && $(CABAL) configure --distpref=dist-bootstrapping --with-compiler=$(GHC) --package-db=$@.tmp
+ cd filepath && $(CABAL) build --distpref=dist-bootstrapping
+ cd filepath && $(CABAL) install --distpref=dist-bootstrapping --inplace
+ -cd Cabal && $(CABAL) clean --distpref=dist-bootstrapping
+ cd Cabal && $(CABAL) configure --distpref=dist-bootstrapping --with-compiler=$(GHC) --package-db=$@.tmp
+ cd Cabal && $(CABAL) build --distpref=dist-bootstrapping
+ cd Cabal && $(CABAL) install --distpref=dist-bootstrapping --inplace
+ mv $@.tmp $@
installPackage/installPackage: installPackage.hs
-$(RM) -rf installPackage
@@ -349,6 +354,8 @@ distclean: clean
clean: $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR))
$(RM) -rf bootstrapping/*
+ $(RM) -f bootstrapping.conf bootstrapping.conf.old
+ $(RM) -f bootstrapping.conf.tmp bootstrapping.conf.tmp.old
$(RM) -f cabal-bin
$(RM) -rf ifBuildable
$(RM) -rf installPackage
@@ -362,6 +369,7 @@ $(foreach SUBDIR,$(SUBDIRS),clean.library.$(SUBDIR)): \
clean.library.%:
$(RM) -f stamp/configure.library.*.$* $*/unbuildable
-cd $* && $(CABAL) clean
+ -cd $* && $(CABAL) clean --distpref=dist-bootstrapping
$(RM) -f $*/Setup $*/Setup.exe $*/Setup.hi $*/Setup.o
$(RM) $*/GNUmakefile $*/Makefile.local
endif
diff --git a/libraries/cabal-bin.hs b/libraries/cabal-bin.hs
index ad93a37dcb..1ecba50a3d 100644
--- a/libraries/cabal-bin.hs
+++ b/libraries/cabal-bin.hs
@@ -1,5 +1,5 @@
-module Cabal (main) where
+module Main (main) where
import Data.Maybe
import Distribution.PackageDescription
@@ -19,9 +19,16 @@ setupProg = "./Setup"
main :: IO ()
main = do
+ unprocessedArgs <- getArgs
let verbosity = verbose
+ case unprocessedArgs of
+ ghc : packageConf : args ->
+ doit verbosity ghc packageConf args
+ _ -> die "Bad args"
+
+doit :: Verbosity -> FilePath -> FilePath -> [String] -> IO ()
+doit verbosity ghc packageConf args = do
exists <- doesFileExist setupProg
- args <- getArgs
if exists then rawSystemExit verbosity setupProg args
else do
gpdFile <- defaultPackageDesc verbosity
@@ -34,5 +41,11 @@ main = do
_ | packageName pd == PackageName "Cabal" ->
-- Cabal is special...*sigh*
Simple.defaultMainArgs args
- | otherwise -> die "Don't know what to do!"
+ | otherwise -> runSetup verbosity ghc packageConf args
+
+runSetup :: Verbosity -> FilePath -> FilePath -> [String] -> IO ()
+runSetup verbosity ghc packageConf args = do
+ rawSystemExit verbosity ghc ["-package-conf", packageConf,
+ "--make", "Setup", "-o", "Setup"]
+ rawSystemExit verbosity "./Setup" args