.PHONY: $(REALGOALS)
$(REALGOALS) all: mk/config.mk.old mk/project.mk.old compiler/ghc.cabal.old
@echo "===--- building phase 0"
- $(MAKE) -r --no-print-directory -f ghc.mk phase=0 all
+ $(MAKE) -r --no-print-directory -f ghc.mk phase=0 phase_0_builds
ifneq "$(OMIT_PHASE_1)" "YES"
@echo "===--- building phase 1"
- $(MAKE) -r --no-print-directory -f ghc.mk phase=1 all
-endif
-ifneq "$(OMIT_PHASE_2)" "YES"
- @echo "===--- building phase 2"
- $(MAKE) -r --no-print-directory -f ghc.mk phase=2 all
-endif
-ifneq "$(OMIT_PHASE_3)" "YES"
- @echo "===--- building phase 3"
- $(MAKE) -r --no-print-directory -f ghc.mk phase=3 all
+ $(MAKE) -r --no-print-directory -f ghc.mk phase=1 phase_1_builds
endif
@echo "===--- building final phase"
$(MAKE) -r --no-print-directory -f ghc.mk $@
# Building dependencies
include rules/build-dependencies.mk
+include rules/include-dependencies.mk
# -----------------------------------------------------------------------------
# Build package-data.mk files
$(patsubst %, libraries/%, $(PACKAGES_STAGE2))
endif
-# -----------------------------------------------------------------------------
-# Phase handling
-
-phase_0_or_later = YES
-ifeq "$(findstring $(phase),0)" ""
-phase_0_done = YES
-phase_1_or_later = YES
-endif
-ifeq "$(findstring $(phase),0 1)" ""
-phase_1_done = YES
-phase_2_or_later = YES
-endif
-ifeq "$(findstring $(phase),0 1 2)" ""
-phase_2_done = YES
-phase_3_or_later = YES
-endif
-ifeq "$(findstring $(phase),0 1 2 3)" ""
-phase_3_done = YES
-endif
-
-includes_dist-derivedconstants_CONFIGURE_PHASE = 0
-includes_dist-ghcconstants_CONFIGURE_PHASE = 0
-
-# We do these first, as making the sources for some later
-# packages needs them, and we need the sources before we can
-# work out dependencies
-utils/hsc2hs_dist_CONFIGURE_PHASE = 0
-utils/unlit_dist_CONFIGURE_PHASE = 0
-utils/genprimopcode_dist_CONFIGURE_PHASE = 0
-
-# Then the bootlibs
-$(foreach lib,$(STAGE0_PACKAGES),$(eval \
- libraries/$(lib)_dist-boot_CONFIGURE_PHASE = 1))
-compiler_stage1_CONFIGURE_PHASE = 1
-ghc_stage1_CONFIGURE_PHASE = 1
-driver/ghc_dist_CONFIGURE_PHASE = 1
-driver/ghci_dist_CONFIGURE_PHASE = 1
-driver/haddock_dist_CONFIGURE_PHASE = 1
-utils/touchy_dist_CONFIGURE_PHASE = 1
-
-# In phase 2, the phase 1 things actually get built
-
-# Finally, the stage1 compiler is used to make the dependencies for
-# everything else, so we can now build the rest.
-compiler_stage2_CONFIGURE_PHASE = 3
-compiler_stage3_CONFIGURE_PHASE = 3
-ghc_stage2_CONFIGURE_PHASE = 3
-ghc_stage3_CONFIGURE_PHASE = 3
-
-$(foreach lib,$(PACKAGES) $(PACKAGES_STAGE2),$(eval \
- libraries/$(lib)_dist-install_CONFIGURE_PHASE = 3))
-
-utils/hp2ps_dist_CONFIGURE_PHASE = 3
-utils/genapply_dist_CONFIGURE_PHASE = 3
-utils/haddock_dist_CONFIGURE_PHASE = 3
-utils/hsc2hs_dist-install_CONFIGURE_PHASE = 3
-utils/ghc-pkg_dist-install_CONFIGURE_PHASE = 3
-utils/hpc_dist_CONFIGURE_PHASE = 3
-utils/runghc_dist_CONFIGURE_PHASE = 3
-utils/ghctags_dist_CONFIGURE_PHASE = 3
-utils/ghc-pwd_dist_CONFIGURE_PHASE = 3
-utils/ghc-cabal_dist-install_CONFIGURE_PHASE = 3
-utils/mkUserGuidePart_dist_CONFIGURE_PHASE = 3
-utils/compare_sizes_dist_CONFIGURE_PHASE = 3
-
# ----------------------------------------------
# Actually include all the sub-ghc.mk's
.DELETE_ON_ERROR:
+# -----------------------------------------------------------------------------
+# Numbered phase targets
+
+.PHONY: phase_0_builds
+phase_0_builds: $(utils/hsc2hs_dist_depfile_haskell)
+phase_0_builds: $(utils/hsc2hs_dist_depfile_c_asm)
+phase_0_builds: $(utils/genprimopcode_dist_depfile_haskell)
+phase_0_builds: $(utils/genprimopcode_dist_depfile_c_asm)
+
+.PHONY: phase_1_builds
+phase_1_builds: $(PACKAGE_DATA_MKS)
+
# Note sed magic above: mkdependC can't do -odir stuff, so we have to
# munge the dependencies it generates to refer to the correct targets.
-# Seems as good a place as any to attach the unlit dependency
-$$($1_$2_depfile_haskell) : $$(UNLIT)
-
-ifneq "$$(NO_INCLUDE_DEPS)" "YES"
-ifneq "$$(strip $$($1_$2_HS_SRCS) $$($1_$2_HS_BOOT_SRCS))" ""
-ifneq "$$(NO_STAGE$3_DEPS)" "YES"
-include $$($1_$2_depfile_haskell)
-endif
-endif
-include $$($1_$2_depfile_c_asm)
-else
-ifeq "$$(DEBUG)" "YES"
-$$(warning not building dependencies in $1)
-endif
-endif
-
endef
# This comment is outside the "define addCFileDeps" as that definition
$1_$2_CONFIGURE_OPTS += $$(BOOT_PKG_CONSTRAINTS)
endif
+ifneq "$$(BINDIST)" "YES"
$1/$2/inplace-pkg-config : $1/$2/package-data.mk
$1/$2/build/autogen/cabal_macros.h : $1/$2/package-data.mk
"$$($1_$2_GHC_PKG)" update --force $$($1_$2_GHC_PKG_OPTS) $1/$2/inplace-pkg-config
endif
endif
+endif
+
+PACKAGE_DATA_MKS += $1/$2/package-data.mk
endef
$1_$2_WAYS_DASHED = $$(subst $$(space),,$$(patsubst %,-%,$$(strip $$($1_$2_WAYS))))
$1_$2_depfile_base = $1/$2/build/.depend$$($1_$2_WAYS_DASHED)
-########################################
-ifeq "$$($1_$2_CONFIGURE_PHASE)" ""
-$$(error No configure phase for $1_$2)
-else ifeq "$$($1_$2_CONFIGURE_PHASE)" "$$(phase)"
-
-ifeq "$$(DEBUG)" "YES"
-$$(warning $1/$2 configure phase)
-endif
-
-ifneq "$$(BINDIST)" "YES"
$(call build-package-data,$1,$2,$3)
-endif
-
ifneq "$$(NO_INCLUDE_PKGDATA)" "YES"
+ifeq "$3" "0"
include $1/$2/package-data.mk
-endif
-
-else ifeq "$$(phase_$$($1_$2_CONFIGURE_PHASE)_or_later)" "YES"
-
-ifeq "$$(DEBUG)" "YES"
-$$(warning $1/$2 build phase)
-endif
-
-ifneq "$$(NO_INCLUDE_PKGDATA)" "YES"
+else ifeq "$(phase)" ""
include $1/$2/package-data.mk
-ifeq "$$($1_$2_VERSION)" ""
-$$(error No version for $1_$2 found)
endif
endif
-$(call all-target,$1,all_$1_$2)
-
+# We don't bother splitting the bootstrap packages (built with stage 0)
+ifeq "$$($1_$2_SplitObjs)" ""
+ifeq "$$(SplitObjs) $3" "YES 1"
+$1_$2_SplitObjs = YES
else
-
-ifeq "$$(DEBUG)" "YES"
-$$(warning $1/$2 disabled phase)
-endif
-
+$1_$2_SplitObjs = NO
endif
-########################################
-
-# We don't install things compiled by stage 0, so no need to put them
-# in the bindist.
-ifneq "$$(BINDIST) $3" "YES 0"
-
-# This give us things like
-# all_libraries: all_libraries/base_dist-install
-ifneq "$$($1_$2_GROUP)" ""
-all_$$($1_$2_GROUP): all_$1_$2
endif
-ifneq "$$(CHECKED_$1)" "YES"
-CHECKED_$1 = YES
-check_packages: check_$1
-.PHONY: check_$1
-check_$1: $$(GHC_CABAL_INPLACE)
- $$(GHC_CABAL_INPLACE) check $1
-endif
-
-ifeq "$$(phase_$$($1_$2_CONFIGURE_PHASE)_done)" "YES"
-
$(call hs-sources,$1,$2)
$(call c-sources,$1,$2)
$(call includes-sources,$1,$2)
# --- DEPENDENCIES
-
+# We always have the dependency rules available, as we need to know
+# how to build hsc2hs's dependency file in phase 0
$(call build-dependencies,$1,$2,$3)
-
-# --- BUILDING
-
-# We don't bother splitting the bootstrap packages (built with stage 0)
-ifeq "$$($1_$2_SplitObjs)" ""
-ifeq "$$(SplitObjs) $3" "YES 1"
-$1_$2_SplitObjs = YES
-else
-$1_$2_SplitObjs = NO
+ifneq "$(phase)" "0"
+# From phase 1 we actually include the dependency files for the
+# bootstrapping stuff
+ifeq "$3" "0"
+$(call include-dependencies,$1,$2,$3)
+else ifeq "$(phase)" ""
+# In the final phase, we also include the dependency files for
+# everything else
+$(call include-dependencies,$1,$2,$3)
endif
endif
-# C and S files are possibly built the "dyn" way.
-ifeq "$$(BuildSharedLibs)" "YES"
-$(call c-objs,$1,$2,dyn)
-$(call c-suffix-rules,$1,$2,dyn,YES)
-endif
-
# Now generate all the build rules for each way in this directory:
$$(foreach way,$$($1_$2_WAYS),$$(eval \
$$(call c-objs,$1,$2,$$(way)) \
- $$(call c-suffix-rules,$1,$2,$$(way),YES) \
+ $$(call c-suffix-rules,$1,$2,$$(way),YES) \
$$(call cmm-objs,$1,$2,$$(way)) \
$$(call cmm-suffix-rules,$1,$2,$$(way)) \
$$(call build-package-way,$1,$2,$$(way),$3) \
))
-$(call haddock,$1,$2)
+# C and S files are possibly built the "dyn" way.
+ifeq "$$(BuildSharedLibs)" "YES"
+$(call c-objs,$1,$2,dyn)
+$(call c-suffix-rules,$1,$2,dyn,YES)
+endif
-endif # package-data.mk exists
+$(call all-target,$1,all_$1_$2)
+# This give us things like
+# all_libraries: all_libraries/base_dist-install
+ifneq "$$($1_$2_GROUP)" ""
+all_$$($1_$2_GROUP): all_$1_$2
+endif
+
+ifneq "$$(CHECKED_$1)" "YES"
+CHECKED_$1 = YES
+check_packages: check_$1
+.PHONY: check_$1
+check_$1: $$(GHC_CABAL_INPLACE)
+ $$(GHC_CABAL_INPLACE) check $1
+endif
+
+$(call haddock,$1,$2)
# Don't put bootstrapping packages in the bindist
ifneq "$3" "0"
BINDIST_EXTRAS += $$($1_$2_INSTALL_INCLUDES_SRCS)
endif
-endif
-
endef
$1_$2_INPLACE = $$(INPLACE_BIN)/$$($1_$2_PROG)
endif
-ifeq "$$(phase_1_or_later)" "YES"
$(call all-target,$1_$2,$$($1_$2_INPLACE))
-endif
$(call clean-target,$1,$2,$1/$2 $$($1_$2_INPLACE))
.PHONY: clean_$1
endif
endif
-########################################
-ifeq "$$($1_$2_CONFIGURE_PHASE)" ""
-$$(error No configure phase for $1_$2)
-else ifeq "$$($1_$2_CONFIGURE_PHASE)" "$$(phase)"
-
-ifeq "$$(DEBUG)" "YES"
-$$(warning $1/$2 configure phase)
-endif
-
-ifneq "$$(BINDIST)" "YES"
-$(call build-package-data,$1,$2,$3)
-endif
-
ifeq "$$($1_$2_USES_CABAL)" "YES"
+$(call build-package-data,$1,$2,$3)
ifneq "$$(NO_INCLUDE_PKGDATA)" "YES"
+ifeq "$3" "0"
include $1/$2/package-data.mk
-endif
-endif
-
-# INPLACE_BIN might be empty if we're distcleaning
-ifeq "$(findstring clean,$(MAKECMDGOALS))" ""
-ifneq "$$($1_$2_INSTALL_INPLACE)" "NO"
-$$($1_$2_INPLACE) :
- $$(error $1_$2 is configuring, but trying to build $$($1_$2_INPLACE)")
-endif
-endif
-
-else ifeq "$$(phase_$$($1_$2_CONFIGURE_PHASE)_or_later)" "YES"
-
-ifeq "$$(DEBUG)" "YES"
-$$(warning $1/$2 build phase)
-endif
-
-ifeq "$$($1_$2_USES_CABAL)" "YES"
-ifneq "$$(NO_INCLUDE_PKGDATA)" "YES"
+else ifeq "$(phase)" ""
include $1/$2/package-data.mk
-ifeq "$$($1_$2_VERSION)" ""
-$$(error No version for $1_$2 found)
endif
endif
endif
endif
endif
-else
-
-ifeq "$$(DEBUG)" "YES"
-$$(warning $1/$2 disabled phase)
-endif
-
-# INPLACE_BIN might be empty if we're distcleaning
-ifeq "$(findstring clean,$(MAKECMDGOALS))" ""
-ifneq "$$($1_$2_INSTALL_INPLACE)" "NO"
-$$($1_$2_INPLACE) :
- $$(error $1_$2 is disabled, but trying to build $$($1_$2_INPLACE)")
-endif
-endif
-
-endif
-########################################
-
$(call shell-wrapper,$1,$2)
-ifeq "$$(phase_$$($1_$2_CONFIGURE_PHASE)_done)" "YES"
-
-ifneq "$$(BINDIST)" "YES"
$1_$2_WAYS = v
$(call hs-sources,$1,$2)
$(call c-sources,$1,$2)
-# --- DEPENDENCIES
-
-$(call build-dependencies,$1,$2,$3)
-
# --- IMPLICIT RULES
# Just the 'v' way for programs
$1_$2_GHC_LD_OPTS = -no-auto-link-packages -no-hs-main
endif
+ifneq "$$(BINDIST)" "YES"
# The quadrupled $'s here are because the _v_LIB variables aren't
# necessarily set when this part of the makefile is read
$1/$2/build/tmp/$$($1_$2_PROG) : \
$1/$2/build/tmp/$$($1_$2_PROG) : $$(ALL_STAGE1_LIBS) $$(ALL_RTS_LIBS) $$(OTHER_LIBS)
endif
endif
+endif
ifneq "$$($1_$2_INSTALL_INPLACE)" "NO"
$(call all-target,$1_$2,$$($1_$2_INPLACE))
endif
$(call clean-target,$1,$2_inplace,$$($1_$2_INPLACE))
-# touch is necessary; cp doesn't update the file time.
-endif
-
ifeq "$$($1_$2_INSTALL)" "YES"
ifeq "$$($1_$2_TOPDIR)" "YES"
INSTALL_TOPDIRS += $1/$2/build/tmp/$$($1_$2_PROG)
endif
endif
-endif # package-data.mk exists
+# --- DEPENDENCIES
+# We always have the dependency rules available, as we need to know
+# how to build hsc2hs's dependency file in phase 0
+$(call build-dependencies,$1,$2,$3)
+ifneq "$(phase)" "0"
+# From phase 1 we actually include the dependency files for the
+# bootstrapping stuff
+ifeq "$3" "0"
+$(call include-dependencies,$1,$2,$3)
+else ifeq "$(phase)" ""
+# In the final phase, we also include the dependency files for
+# everything else
+$(call include-dependencies,$1,$2,$3)
+endif
+endif
endef
# $3 = way
# $4 = use GHC (YES/NO)
+ifneq "$$(BINDIST)" "YES"
+
# UseGhcForCc is only relevant when not booting from HC files.
ifeq "$4 $$(BootingFromHc)" "YES NO"
endif
+endif
+
endef
# Preprocessing Haskell source
+ifneq "$$(BINDIST)" "YES"
+
ifneq "$$(BootingFromHc)" "YES"
$1/$2/build/%.hs : $1/$4/%.ly | $$$$(dir $$$$@)/.
@:
endif
+endif
+
endef
define hs-suffix-rules # args: $1 = dir, $2 = distdir, $3 = way
+ifneq "$$(BINDIST)" "YES"
ifneq "$$(BootingFromHc)" "YES"
$1/$2/build/%.$$($3_hcsuf) : $1/$2/build/%.hs $$($1_$2_HC_DEP)
"$$($1_$2_HC)" $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
endif
+endif
endef # hs-suffix-rules
--- /dev/null
+# -----------------------------------------------------------------------------
+#
+# (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
+#
+# -----------------------------------------------------------------------------
+
+define include-dependencies
+$(call trace, include-dependencies($1,$2,$3))
+# $1 = dir
+# $2 = distdir
+# $3 = GHC stage to use (0 == bootstrapping compiler)
+
+ifneq "$$(NO_INCLUDE_DEPS)" "YES"
+ifneq "$$(strip $$($1_$2_HS_SRCS) $$($1_$2_HS_BOOT_SRCS))" ""
+ifneq "$$(NO_STAGE$3_DEPS)" "YES"
+include $$($1_$2_depfile_haskell)
+endif
+endif
+include $$($1_$2_depfile_c_asm)
+else
+ifeq "$$(DEBUG)" "YES"
+$$(warning not building dependencies in $1)
+endif
+endif
+
+endef
+