define build-prog
$(call trace, build-prog($1,$2,$3))
+$(call profStart, build-prog($1,$2,$3))
# $1 = dir
# $2 = distdir
# $3 = GHC stage to use (0 == bootstrapping compiler)
ifneq "$$($1_$2_NOT_NEEDED)" "YES"
$$(eval $$(call build-prog-helper,$1,$2,$3))
endif
+$(call profEnd, build-prog($1,$2,$3))
endef
$(call package-config,$1,$2,$3)
+$1_$2_depfile_base = $1/$2/build/.depend
+
ifeq "$$($1_$2_INSTALL_INPLACE)" "NO"
ifeq "$(findstring clean,$(MAKECMDGOALS))" ""
$1_$2_INPLACE = $$(error $1_$2 should not be installed inplace, but INPLACE var evaluated)
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
-
-$1_$2_depfile_base = $1/$2/build/.depend
-
-$(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
-ifeq "$3" "0"
-$1/$2/build/tmp/$$($1_$2_PROG) : $$(foreach dep,$$($1_$2_DEP_NAMES),$$$$(libraries/$$(dep)_dist-boot_v_LIB))
-else
-$1/$2/build/tmp/$$($1_$2_PROG) : $$(foreach dep,$$($1_$2_DEP_NAMES),$$$$(libraries/$$(dep)_dist-install_v_LIB))
-endif
+$1/$2/build/tmp/$$($1_$2_PROG) : \
+ $$(foreach dep,$$($1_$2_DEP_NAMES),\
+ $$(if $$(filter ghc,$$(dep)),\
+ $(if $(filter 0,$3),$$(compiler_stage1_v_LIB),\
+ $(if $(filter 1,$3),$$(compiler_stage2_v_LIB),\
+ $(if $(filter 2,$3),$$(compiler_stage2_v_LIB),\
+ $$(error Bad build stage)))),\
+ $$$$(libraries/$$(dep)_dist-$(if $(filter 0,$3),boot,install)_v_LIB)))
ifeq "$$($1_$2_LINK_WITH_GCC)" "NO"
$1/$2/build/tmp/$$($1_$2_PROG) : $$($1_$2_v_HS_OBJS) $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS) $$($1_$2_OTHER_OBJS) | $$$$(dir $$$$@)/.
$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