Define $(prog)_INPLACE variables automatically, and start using them
authorIan Lynagh <ian@well-typed.com>
Sun, 3 Mar 2013 18:49:23 +0000 (18:49 +0000)
committerIan Lynagh <ian@well-typed.com>
Sun, 3 Mar 2013 19:56:49 +0000 (19:56 +0000)
12 files changed:
compiler/ghc.mk
ghc.mk
mk/config.mk.in
mk/tree.mk
rts/ghc.mk
rules/build-prog.mk
rules/hs-suffix-rules-srcdir.mk
rules/pretty_commands.mk
utils/genapply/ghc.mk
utils/genprimopcode/ghc.mk
utils/ghc-cabal/ghc.mk
utils/touchy/ghc.mk

index f15fc2d..0cceed0 100644 (file)
@@ -246,33 +246,33 @@ compiler/stage$1/build/Parser.y: compiler/parser/Parser.y.pp
 compiler/stage$1/build/primops.txt: compiler/prelude/primops.txt.pp compiler/stage$1/$$(PLATFORM_H)
        $$(CPP) $$(RAWCPP_FLAGS) -P $$(compiler_CPP_OPTS) -Icompiler/stage$1 -x c $$< | grep -v '^#pragma GCC' > $$@
 
-compiler/stage$1/build/primop-data-decl.hs-incl: compiler/stage$1/build/primops.txt $$(GENPRIMOP_INPLACE)
-       "$$(GENPRIMOP_INPLACE)" --data-decl          < $$< > $$@
-compiler/stage$1/build/primop-tag.hs-incl: compiler/stage$1/build/primops.txt $$(GENPRIMOP_INPLACE)
-       "$$(GENPRIMOP_INPLACE)" --primop-tag         < $$< > $$@
-compiler/stage$1/build/primop-list.hs-incl: compiler/stage$1/build/primops.txt $$(GENPRIMOP_INPLACE)
-       "$$(GENPRIMOP_INPLACE)" --primop-list        < $$< > $$@
-compiler/stage$1/build/primop-has-side-effects.hs-incl: compiler/stage$1/build/primops.txt $$(GENPRIMOP_INPLACE)
-       "$$(GENPRIMOP_INPLACE)" --has-side-effects   < $$< > $$@
-compiler/stage$1/build/primop-out-of-line.hs-incl: compiler/stage$1/build/primops.txt $$(GENPRIMOP_INPLACE)
-       "$$(GENPRIMOP_INPLACE)" --out-of-line        < $$< > $$@
-compiler/stage$1/build/primop-commutable.hs-incl: compiler/stage$1/build/primops.txt $$(GENPRIMOP_INPLACE)
-       "$$(GENPRIMOP_INPLACE)" --commutable         < $$< > $$@
-compiler/stage$1/build/primop-code-size.hs-incl: compiler/stage$1/build/primops.txt $$(GENPRIMOP_INPLACE)
-       "$$(GENPRIMOP_INPLACE)" --code-size          < $$< > $$@
-compiler/stage$1/build/primop-can-fail.hs-incl: compiler/stage$1/build/primops.txt $$(GENPRIMOP_INPLACE)
-       "$$(GENPRIMOP_INPLACE)" --can-fail           < $$< > $$@
-compiler/stage$1/build/primop-strictness.hs-incl: compiler/stage$1/build/primops.txt $$(GENPRIMOP_INPLACE)
-       "$$(GENPRIMOP_INPLACE)" --strictness         < $$< > $$@
-compiler/stage$1/build/primop-fixity.hs-incl: compiler/stage$1/build/primops.txt $$(GENPRIMOP_INPLACE)
-       "$$(GENPRIMOP_INPLACE)" --fixity             < $$< > $$@
-compiler/stage$1/build/primop-primop-info.hs-incl: compiler/stage$1/build/primops.txt $$(GENPRIMOP_INPLACE)
-       "$$(GENPRIMOP_INPLACE)" --primop-primop-info < $$< > $$@
+compiler/stage$1/build/primop-data-decl.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
+       "$$(genprimopcode_INPLACE)" --data-decl          < $$< > $$@
+compiler/stage$1/build/primop-tag.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
+       "$$(genprimopcode_INPLACE)" --primop-tag         < $$< > $$@
+compiler/stage$1/build/primop-list.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
+       "$$(genprimopcode_INPLACE)" --primop-list        < $$< > $$@
+compiler/stage$1/build/primop-has-side-effects.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
+       "$$(genprimopcode_INPLACE)" --has-side-effects   < $$< > $$@
+compiler/stage$1/build/primop-out-of-line.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
+       "$$(genprimopcode_INPLACE)" --out-of-line        < $$< > $$@
+compiler/stage$1/build/primop-commutable.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
+       "$$(genprimopcode_INPLACE)" --commutable         < $$< > $$@
+compiler/stage$1/build/primop-code-size.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
+       "$$(genprimopcode_INPLACE)" --code-size          < $$< > $$@
+compiler/stage$1/build/primop-can-fail.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
+       "$$(genprimopcode_INPLACE)" --can-fail           < $$< > $$@
+compiler/stage$1/build/primop-strictness.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
+       "$$(genprimopcode_INPLACE)" --strictness         < $$< > $$@
+compiler/stage$1/build/primop-fixity.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
+       "$$(genprimopcode_INPLACE)" --fixity             < $$< > $$@
+compiler/stage$1/build/primop-primop-info.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
+       "$$(genprimopcode_INPLACE)" --primop-primop-info < $$< > $$@
 
 # Usages aren't used any more; but the generator 
 # can still generate them if we want them back
-compiler/stage$1/build/primop-usage.hs-incl: compiler/stage$1/build/primops.txt $$(GENPRIMOP_INPLACE)
-       "$$(GENPRIMOP_INPLACE)" --usage              < $$< > $$@
+compiler/stage$1/build/primop-usage.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
+       "$$(genprimopcode_INPLACE)" --usage              < $$< > $$@
 
 endef
 
diff --git a/ghc.mk b/ghc.mk
index f4d85ab..5f5f472 100644 (file)
--- a/ghc.mk
+++ b/ghc.mk
@@ -549,8 +549,8 @@ endef
 
 PRIMOPS_TXT_STAGE1 = compiler/stage1/build/primops.txt
 
-libraries/ghc-prim/dist-install/build/GHC/PrimopWrappers.hs : $(GENPRIMOP_INPLACE) $(PRIMOPS_TXT_STAGE1) | $$(dir $$@)/.
-       "$(GENPRIMOP_INPLACE)" --make-haskell-wrappers < $(PRIMOPS_TXT_STAGE1) >$@
+libraries/ghc-prim/dist-install/build/GHC/PrimopWrappers.hs : $$(genprimopcode_INPLACE) $(PRIMOPS_TXT_STAGE1) | $$(dir $$@)/.
+       "$(genprimopcode_INPLACE)" --make-haskell-wrappers < $(PRIMOPS_TXT_STAGE1) >$@
 
 # Required so that Haddock documents the primops.
 libraries/ghc-prim_dist-install_EXTRA_HADDOCK_SRCS = libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs
@@ -655,7 +655,7 @@ BUILD_DIRS += utils/deriveConstants
 BUILD_DIRS += utils/testremove
 BUILD_DIRS += $(MAYBE_GHCTAGS)
 BUILD_DIRS += utils/ghc-pwd
-BUILD_DIRS += $(GHC_CABAL_DIR)
+BUILD_DIRS += utils/ghc-cabal
 BUILD_DIRS += $(MAYBE_HPC)
 BUILD_DIRS += $(MAYBE_RUNGHC)
 BUILD_DIRS += ghc
@@ -767,9 +767,9 @@ $(ghc-prim-$(libraries/ghc-prim_dist-install_VERSION)_HADDOCK_FILE): \
 endif # BINDIST
 
 libraries/ghc-prim/dist-install/build/autogen/GHC/Prim.hs: \
-                            $(PRIMOPS_TXT_STAGE1) $(GENPRIMOP_INPLACE) \
+                            $(PRIMOPS_TXT_STAGE1) $$(genprimopcode_INPLACE) \
                           | $$(dir $$@)/.
-       "$(GENPRIMOP_INPLACE)" --make-haskell-source < $< > $@
+       "$(genprimopcode_INPLACE)" --make-haskell-source < $< > $@
 
 .PHONY: tags
 tags: tags_compiler
index b310e86..c43612f 100644 (file)
@@ -435,24 +435,14 @@ SRC_FLEX_OPTS     += -8
 #      xxx              the executable relative to the current dir
 
 GHC_UNLIT_PGM           = unlit$(exeext)
-GHC_HSC2HS_PGM          = hsc2hs$(exeext)
-GHC_TOUCHY_PGM          = touchy$(exeext)
 GHC_SPLIT_PGM           = ghc-split
-GHC_GENPRIMOP_PGM       = genprimopcode$(exeext)
-GHC_GENAPPLY_PGM        = genapply$(exeext)
-GHC_CABAL_PGM           = ghc-cabal$(exeext)
-GHC_PKG_PGM             = ghc-pkg$(exeext)
-GHC_MKDIRHIER_PGM       = mkdirhier
 
 SPLIT               = $(INPLACE_LIB)/$(GHC_SPLIT_PGM)
 UNLIT               = $(INPLACE_LIB)/$(GHC_UNLIT_PGM)
-TOUCHY              = $(INPLACE_LIB)/$(GHC_TOUCHY_PGM)
-MKDIRHIER           = $(INPLACE_BIN)/$(GHC_MKDIRHIER_PGM)
-GHC_CABAL_INPLACE   = $(INPLACE_BIN)/$(GHC_CABAL_PGM)
-GENAPPLY_INPLACE    = $(INPLACE_BIN)/$(GHC_GENAPPLY_PGM)
-GHC_PKG_INPLACE     = $(INPLACE_BIN)/$(GHC_PKG_PGM)
-HSC2HS_INPLACE      = $(INPLACE_BIN)/$(GHC_HSC2HS_PGM)
-GENPRIMOP_INPLACE   = $(INPLACE_BIN)/$(GHC_GENPRIMOP_PGM)
+TOUCHY              = $(INPLACE_LIB)/touchy$(exeext)
+MKDIRHIER           = $(INPLACE_BIN)/mkdirhier
+GHC_CABAL_INPLACE   = $(INPLACE_BIN)/ghc-cabal$(exeext)
+GHC_PKG_INPLACE     = $(INPLACE_BIN)/ghc-pkg$(exeext)
 
 GENERATED_FILE  = chmod a-w
 EXECUTABLE_FILE = chmod +x
index 1ae45ed..9c2e3da 100644 (file)
@@ -20,8 +20,6 @@ GHC_INCLUDE_DIRS        = includes includes/dist includes/dist-derivedconstants/
 GHC_RTS_DIR             = rts
 GHC_DRIVER_DIR          = driver
 
-GHC_CABAL_DIR           = $(GHC_UTILS_DIR)/ghc-cabal
-
 INPLACE                 = inplace
 INPLACE_BIN             = $(INPLACE)/bin
 INPLACE_LIB             = $(INPLACE)/lib
index a4c7acb..cc22c05 100644 (file)
@@ -57,8 +57,8 @@ endif
 
 rts_AUTO_APPLY_CMM = rts/dist/build/AutoApply.cmm
 
-$(rts_AUTO_APPLY_CMM): $(GENAPPLY_INPLACE)
-       "$(GENAPPLY_INPLACE)" >$@
+$(rts_AUTO_APPLY_CMM): $$(genapply_INPLACE)
+       "$(genapply_INPLACE)" >$@
 
 rts/dist/build/sm/Evac_thr.c : rts/sm/Evac.c | $$(dir $$@)/.
        cp $< $@
index 7fbe789..4bf9ab0 100644 (file)
@@ -87,15 +87,21 @@ else
 $1_$2_INPLACE =
 endif
 else
+ifeq "$(findstring clean,$(MAKECMDGOALS))" ""
+ifneq "$$($$($1_$2_PROG)_INPLACE)" ""
+$$(error $$($1_$2_PROG)_INPLACE defined twice)
+endif
+endif
+ifeq "$$($1_$2_TOPDIR)" "YES"
+$$($1_$2_PROG)_INPLACE = $$(INPLACE_TOPDIR)/$$($1_$2_PROG)
+else
+$$($1_$2_PROG)_INPLACE = $$(INPLACE_BIN)/$$($1_$2_PROG)
+endif
 # Where do we install the inplace version?
 ifeq "$$($1_$2_WANT_INPLACE_WRAPPER)" "YES"
 $1_$2_INPLACE = $$(INPLACE_LIB)/bin/$$($1_$2_PROG)
 else
-ifeq "$$($1_$2_TOPDIR)" "YES"
-$1_$2_INPLACE = $$(INPLACE_TOPDIR)/$$($1_$2_PROG)
-else
-$1_$2_INPLACE = $$(INPLACE_BIN)/$$($1_$2_PROG)
-endif
+$1_$2_INPLACE = $$($$($1_$2_PROG)_INPLACE)
 endif
 endif
 
index 8ed72af..d3c932f 100644 (file)
@@ -33,8 +33,8 @@ $1/$2/build/%.hs : $1/$2/build/%.y | $$$$(dir $$$$@)/.
 $1/$2/build/%.hs : $1/$3/%.x | $$$$(dir $$$$@)/.
        $$(call cmd,ALEX) $$($1_$2_ALL_ALEX_OPTS) $$< -o $$@
 
-$1/$2/build/%_hsc.c $1/$2/build/%_hsc.h $1/$2/build/%.hs : $1/$3/%.hsc $$(HSC2HS_INPLACE) | $$$$(dir $$$$@)/.
-       $$(call cmd,HSC2HS_INPLACE) $$($1_$2_ALL_HSC2HS_OPTS) $$< -o $$@
+$1/$2/build/%_hsc.c $1/$2/build/%_hsc.h $1/$2/build/%.hs : $1/$3/%.hsc $$$$(hsc2hs_INPLACE) | $$$$(dir $$$$@)/.
+       $$(call cmd,hsc2hs_INPLACE) $$($1_$2_ALL_HSC2HS_OPTS) $$< -o $$@
 
 # Now the rules for hs-boot files.
 
index cfd7fac..f7576e1 100644 (file)
@@ -6,7 +6,7 @@ endif
 
 label_ALEX=ALEX
 label_HAPPY=HAPPY
-label_HSC2HS_INPLACE=HSC2HS
+label_hsc2hs_INPLACE=HSC2HS
 
 
 
index 805fd6f..cd42cb4 100644 (file)
@@ -11,7 +11,7 @@
 # -----------------------------------------------------------------------------
 
 utils/genapply_dist_MODULES = GenApply
-utils/genapply_dist_PROG    = $(GHC_GENAPPLY_PGM)
+utils/genapply_dist_PROG    = genapply$(exeext)
 utils/genapply_dist_INSTALL_INPLACE = YES
 
 utils/genapply_HC_OPTS += -package pretty
index d119d8d..b4fb6c0 100644 (file)
@@ -11,7 +11,7 @@
 # -----------------------------------------------------------------------------
 
 utils/genprimopcode_dist_MODULES = Lexer Main ParserM Parser Syntax
-utils/genprimopcode_dist_PROG    = $(GHC_GENPRIMOP_PGM)
+utils/genprimopcode_dist_PROG    = genprimopcode$(exeext)
 utils/genprimopcode_dist_HC_OPTS = -package array
 utils/genprimopcode_dist_INSTALL_INPLACE = YES
 
index e95fa62..c72f1a1 100644 (file)
@@ -18,15 +18,15 @@ CABAL_DOTTED_VERSION := $(shell grep "^Version:" libraries/Cabal/Cabal/Cabal.cab
 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) | $$(dir $$@)/.
+$(GHC_CABAL_INPLACE) : utils/ghc-cabal/dist/build/tmp/ghc-cabal$(exeext) | $$(dir $$@)/.
        "$(CP)" $< $@
 
-$(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(wildcard libraries/Cabal/Cabal/Distribution/*/*/*.hs)
-$(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(wildcard libraries/Cabal/Cabal/Distribution/*/*.hs)
-$(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(wildcard libraries/Cabal/Cabal/Distribution/*.hs)
+utils/ghc-cabal/dist/build/tmp/ghc-cabal$(exeext): $(wildcard libraries/Cabal/Cabal/Distribution/*/*/*.hs)
+utils/ghc-cabal/dist/build/tmp/ghc-cabal$(exeext): $(wildcard libraries/Cabal/Cabal/Distribution/*/*.hs)
+utils/ghc-cabal/dist/build/tmp/ghc-cabal$(exeext): $(wildcard libraries/Cabal/Cabal/Distribution/*.hs)
 
-$(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(GHC_CABAL_DIR)/Main.hs $(TOUCH_DEP) | $$(dir $$@)/. bootstrapping/.
-       "$(GHC)" $(SRC_HC_OPTS) --make $(GHC_CABAL_DIR)/Main.hs -o $@ \
+utils/ghc-cabal/dist/build/tmp/ghc-cabal$(exeext): utils/ghc-cabal/Main.hs $(TOUCH_DEP) | $$(dir $$@)/. bootstrapping/.
+       "$(GHC)" $(SRC_HC_OPTS) --make utils/ghc-cabal/Main.hs -o $@ \
               -no-user-$(GHC_PACKAGE_DB_FLAG) \
               -Wall -fno-warn-unused-imports -fno-warn-warnings-deprecations \
               -DCABAL_VERSION=$(CABAL_VERSION) \
@@ -42,21 +42,21 @@ $(GHC_CABAL_DIR)/dist/build/tmp/ghc-cabal$(exeext): $(GHC_CABAL_DIR)/Main.hs $(T
 # touch is required, because otherwise if mkdirhier is newer, we
 # repeatedly rebuild ghc-cabal.
 
-$(eval $(call clean-target,$(GHC_CABAL_DIR),dist,\
-   $(GHC_CABAL_DIR)/dist bootstrapping))
+$(eval $(call clean-target,utils/ghc-cabal,dist,\
+   utils/ghc-cabal/dist bootstrapping))
 
-$(eval $(call all-target,$(GHC_CABAL_DIR),$(GHC_CABAL_INPLACE)))
+$(eval $(call all-target,utils/ghc-cabal,$(GHC_CABAL_INPLACE)))
 
 # -----------------------------------------------------------------------------
 # Now make another copy that goes in bindists. This needs to be built
 # with the in-tree compiler.
 
-$(GHC_CABAL_DIR)_USES_CABAL                   = YES
-$(GHC_CABAL_DIR)_PACKAGE                      = ghc-cabal
-$(GHC_CABAL_DIR)_dist-install_PROG            = ghc-cabal$(exeext)
-$(GHC_CABAL_DIR)_dist-install_INSTALL_INPLACE = NO
-$(GHC_CABAL_DIR)_dist-install_WANT_BINDIST_WRAPPER = YES
-$(GHC_CABAL_DIR)_dist-install_MODULES         = Main
+utils/ghc-cabal_USES_CABAL                   = YES
+utils/ghc-cabal_PACKAGE                      = ghc-cabal
+utils/ghc-cabal_dist-install_PROG            = ghc-cabal$(exeext)
+utils/ghc-cabal_dist-install_INSTALL_INPLACE = NO
+utils/ghc-cabal_dist-install_WANT_BINDIST_WRAPPER = YES
+utils/ghc-cabal_dist-install_MODULES         = Main
 
 $(eval $(call build-prog,utils/ghc-cabal,dist-install,1))
 
index 458f80e..8c316ba 100644 (file)
@@ -11,7 +11,7 @@
 # -----------------------------------------------------------------------------
 
 utils/touchy_dist_C_SRCS          = touchy.c
-utils/touchy_dist_PROG            = $(GHC_TOUCHY_PGM)
+utils/touchy_dist_PROG            = touchy$(exeext)
 utils/touchy_dist_TOPDIR          = YES
 utils/touchy_dist_INSTALL         = YES
 utils/touchy_dist_INSTALL_INPLACE = YES