Commit 295016c3 authored by Ian Lynagh's avatar Ian Lynagh

Simplify the build system, and remove 2 phases

From
    http://hackage.haskell.org/trac/ghc/wiki/Building/Architecture/Idiom/PhaseOrdering

Phase 0:
    Includes: package-data.mk files for things built by the
              bootstrapping compiler.
    Builds:   the dependency files for hsc2hs and genprimopcode. We need
              to do this now, as hsc2hs needs to be buildable in phase 1's
              includes (so that we can make the hpc library's .hs source
              files, which in turn is necessary for making its dependency
              files), and genprimopcode needs to be buildable in phase 1's
              includes (so that we can make the primop-*.hs-incl files,
              which are sources for the stage1 compiler library, and thus
              necessary for making its dependency files).
Phase 1:
    Includes: dependency files for things built by the bootstrapping
              compiler.
    Builds:   package-data.mk files for everything else. Note that this
              requires configuring the packages, which means telling cabal
              which ghc to use, and thus the stage1 compiler gets built
              during this phase. 
Phase "":
    Includes: dependency files for everything else.
    Builds:   Everything else. 
parent d17afd1e
......@@ -61,18 +61,10 @@ REALGOALS=$(filter-out binary-dist binary-dist-prep bootstrapping-files framewor
.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 $@
......
......@@ -222,6 +222,7 @@ include rules/package-config.mk
# Building dependencies
include rules/build-dependencies.mk
include rules/include-dependencies.mk
# -----------------------------------------------------------------------------
# Build package-data.mk files
......@@ -603,71 +604,6 @@ BUILD_DIRS += \
$(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
......@@ -1256,3 +1192,15 @@ bootstrapping-files: includes/GHCConstants.h
.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)
......@@ -68,22 +68,6 @@ endif # $1_$2_NO_BUILD_DEPS
# 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
......
......@@ -62,6 +62,7 @@ ifeq "$3" "0"
$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
......@@ -75,5 +76,8 @@ ifneq "$$($1_$2_REGISTER_PACKAGE)" "NO"
"$$($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
......@@ -76,104 +76,75 @@ endif
$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"
......@@ -181,7 +152,5 @@ BINDIST_EXTRAS += $1/*.cabal $$(wildcard $1/*.buildinfo) $1/$2/setup-config $1/L
BINDIST_EXTRAS += $$($1_$2_INSTALL_INCLUDES_SRCS)
endif
endif
endef
......@@ -29,9 +29,7 @@ else
$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
......
......@@ -75,44 +75,13 @@ endif
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
......@@ -129,37 +98,13 @@ $$($1_$2_INPLACE) : $1/$2/build/tmp/$$($1_$2_PROG) | $$$$(dir $$$$@)/.
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
......@@ -192,6 +137,7 @@ ifeq "$$($1_$2_v_HS_OBJS)" ""
$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) : \
......@@ -225,15 +171,13 @@ endif
$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)
......@@ -242,6 +186,20 @@ INSTALL_BINS += $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
......@@ -17,6 +17,8 @@ define c-suffix-rules
# $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"
......@@ -57,5 +59,7 @@ $1/$2/build/%.$$($3_way_)s : $1/$2/build/%.c
endif
endif
endef
......@@ -16,6 +16,8 @@ define hs-suffix-rules-srcdir
# Preprocessing Haskell source
ifneq "$$(BINDIST)" "YES"
ifneq "$$(BootingFromHc)" "YES"
$1/$2/build/%.hs : $1/$4/%.ly | $$$$(dir $$$$@)/.
......@@ -85,5 +87,7 @@ $1/$2/build/%_stub.$$($3_osuf): $1/$2/build/%.$$($3_osuf)
@:
endif
endif
endef
......@@ -13,6 +13,7 @@
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)
......@@ -28,6 +29,7 @@ $1/$2/build/%.$$($3_osuf) : $1/$2/build/autogen/%.hs $$($1_$2_HC_DEP)
"$$($1_$2_HC)" $$($1_$2_$3_ALL_HC_OPTS) -c $$< -o $$@
endif
endif
endef # hs-suffix-rules
# -----------------------------------------------------------------------------
#
# (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
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