X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=utils%2Fghc-cabal%2Fghc.mk;h=b238db91ba6f878031e7aba61be56a51f268a6dc;hb=f4b727487a65e6b611bbaafbd2207bd63a8df706;hp=c0fd0f336d7930f134e90d9e07bff89bb7c8fab3;hpb=34cc75e1a62638f2833815746ebce0a9114dc26b;p=ghc-hetmet.git diff --git a/utils/ghc-cabal/ghc.mk b/utils/ghc-cabal/ghc.mk index c0fd0f3..b238db9 100644 --- a/utils/ghc-cabal/ghc.mk +++ b/utils/ghc-cabal/ghc.mk @@ -1,4 +1,15 @@ # ----------------------------------------------------------------------------- +# +# (c) 2009 The University of Glasgow +# +# This file is part of the GHC build system. +# +# To understand how the build system works and how to modify it, see +# http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture +# http://hackage.haskell.org/trac/ghc/wiki/Building/Modifying +# +# ----------------------------------------------------------------------------- + # Bootstrapping ghc-cabal # Euch, hideous hack: @@ -7,14 +18,15 @@ CABAL_DOTTED_VERSION := $(shell grep "^Version:" libraries/Cabal/Cabal.cabal | s CABAL_VERSION := $(subst .,$(comma),$(CABAL_DOTTED_VERSION)) CABAL_CONSTRAINT := --constraint="Cabal == $(CABAL_DOTTED_VERSION)" -$(GHC_CABAL_INPLACE) : $(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext) - $(MKDIRHIER) $(dir $@) - $(CP) $< $@ +$(GHC_CABAL_INPLACE) : $(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext) | $$(dir $$@)/. + "$(CP)" $< $@ + +$(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(wildcard libraries/Cabal/Distribution/*/*/*.hs) +$(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(wildcard libraries/Cabal/Distribution/*/*.hs) +$(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(wildcard libraries/Cabal/Distribution/*.hs) -$(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(GHC_CABAL_DIR)/ghc-cabal.hs $(MKDIRHIER) - $(MKDIRHIER) bootstrapping - $(MKDIRHIER) $(dir $@) - $(GHC) --make $(GHC_CABAL_DIR)/ghc-cabal.hs -o $@ \ +$(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(GHC_CABAL_DIR)/ghc-cabal.hs | $$(dir $$@)/. bootstrapping/. + "$(GHC)" $(SRC_HC_OPTS) --make $(GHC_CABAL_DIR)/ghc-cabal.hs -o $@ \ -Wall $(WERROR) \ -DCABAL_VERSION=$(CABAL_VERSION) \ -odir bootstrapping \ @@ -42,10 +54,35 @@ $(eval $(call all-target,$(GHC_CABAL_DIR),$(GHC_CABAL_INPLACE))) $(GHC_CABAL_DIR)_dist-dummy-ghc_MODULES = dummy-ghc $(GHC_CABAL_DIR)_dist-dummy-ghc_PROG = dummy-ghc$(exeext) -$(GHC_CABAL_DIR)/dist-dummy-ghc/build/dummy-ghc.hs : $(GHC_CABAL_DIR)/ghc.mk $(MKDIRHIER) - $(MKDIRHIER) $(dir $@) - echo "import System.Environment; import System.Cmd; import System.Exit" >$@ - echo "main = do args <- getArgs; if args == [\"--numeric-version\"] then putStrLn \"$(ProjectVersion)\" else do e <- rawSystem \"$(GHC_STAGE0)\" args; exitWith e" >>$@ +# depend on project.mk, so we pick up the new version number if it changes. +$(GHC_CABAL_DIR)/dist-dummy-ghc/build/dummy-ghc.hs : $(GHC_CABAL_DIR)/ghc.mk $(MKDIRHIER) mk/project.mk compiler/main/DynFlags.hs + "$(MKDIRHIER)" $(dir $@) + "$(RM)" $(RM_OPTS) $@ + echo 'import System.Environment' >> $@ + echo 'import System.Cmd' >> $@ + echo 'import System.Exit' >> $@ + echo 'main :: IO ()' >> $@ + echo 'main = do args <- getArgs' >> $@ + echo ' case args of' >> $@ + echo ' ["--numeric-version"] ->' >> $@ + echo ' putStrLn "$(ProjectVersion)"' >> $@ + echo ' ["--supported-languages"] ->' >> $@ + echo ' mapM_ putStrLn extensions' >> $@ + echo ' _ ->' >> $@ + echo ' do e <- rawSystem "$(GHC_STAGE0)" args' >> $@ + echo ' exitWith e' >> $@ +# This unpleasant sed script grabs the lines between the +# xFlags :: +# line and the +# ] +# line of compiler/main/DynFlags.hs, and if they look like +# ( "PostfixOperators", ... +# then it translates them into +# ["PostfixOperators"] ++ + echo 'extensions :: [String]' >> $@ + echo 'extensions =' >> $@ + '$(SED)' '/^xFlags/,/]/s/^[[:space:]]*([[:space:]]*\("[^"]*"\)[^"]*/ [\1] ++/p;d' compiler/main/DynFlags.hs >> $@ + echo ' []' >> $@ # We don't build dummy-ghc with Cabal, so we need to pass -package # flags manually