Commit 1da6975a authored by ian@well-typed.com's avatar ian@well-typed.com

Define $(prog)_INPLACE variables automatically, and start using them

parent 5d0801da
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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 $< $@
......
......@@ -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
......
......@@ -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.
......
......@@ -6,7 +6,7 @@ endif
label_ALEX=ALEX
label_HAPPY=HAPPY
label_HSC2HS_INPLACE=HSC2HS
label_hsc2hs_INPLACE=HSC2HS
......
......@@ -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
......
......@@ -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
......
......@@ -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))
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment