X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rules%2Fbuild-prog.mk;h=99b24de5cdd1a6d8464dc1deeb1d0ba2be30d6a4;hb=5bde27949bdda22c9d5dac254a3c783eb0f6839f;hp=4121ca34b138a547986a384028473813587de404;hpb=a68ffce3fa1871c21ed51b0414404c365df3aabf;p=ghc-hetmet.git diff --git a/rules/build-prog.mk b/rules/build-prog.mk index 4121ca3..99b24de 100644 --- a/rules/build-prog.mk +++ b/rules/build-prog.mk @@ -48,45 +48,106 @@ define build-prog-helper # $2 = distdir # $3 = GHC stage to use (0 == bootstrapping compiler) -$(call all-target,$1,all_$1_$2) - ifeq "$$($1_USES_CABAL)" "YES" $1_$2_USES_CABAL = YES endif +$(call package-config,$1,$2,$3) + +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) +else +$1_$2_INPLACE = +endif +else +# Where do we install the inplace version? +ifeq "$$($1_$2_SHELL_WRAPPER) $$(Windows)" "YES NO" +$1_$2_INPLACE = $$(INPLACE_LIB)/$$($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 +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" ifneq "$$(NO_INCLUDE_PKGDATA)" "YES" include $1/$2/package-data.mk endif endif -$(call package-config,$1,$2,$3) - -ifeq "$$($1_$2_USES_CABAL)$$($1_$2_VERSION)" "YES" -$1_$2_DISABLE = YES +# 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 -ifeq "$$($1_$2_DISABLE)" "YES" +else ifeq "$$(phase_$$($1_$2_CONFIGURE_PHASE)_or_later)" "YES" ifeq "$$(DEBUG)" "YES" -$$(warning $1/$2 disabled) +$$(warning $1/$2 build phase) endif -# The following code to build the package all depends on settings -# obtained from package-data.mk. If we don't have package-data.mk -# yet, then don't try to do anything else with this package. Make will -# try to build package-data.mk, then restart itself and we'll be in business. +ifeq "$$($1_$2_USES_CABAL)" "YES" +ifneq "$$(NO_INCLUDE_PKGDATA)" "YES" +include $1/$2/package-data.mk +ifeq "$$($1_$2_VERSION)" "" +$$(error No version for $1_$2 found) +endif +endif +endif -$(call all-target,$1_$2,$1/$2/package-data.mk) +$(call all-target,$1,all_$1_$2) +$(call all-target,$1_$2,$1/$2/build/tmp/$$($1_$2_PROG)) -# We have a rule for package-data.mk only when the package is -# disabled, because we want the build to fail if we haven't run phase 0. -ifneq "$$(BINDIST)" "YES" -$(call build-package-data,$1,$2,$3) +# INPLACE_BIN might be empty if we're distcleaning +ifeq "$(findstring clean,$(MAKECMDGOALS))" "" +ifneq "$$($1_$2_INSTALL_INPLACE)" "NO" +$$($1_$2_INPLACE) : $1/$2/build/tmp/$$($1_$2_PROG) | $$$$(dir $$$$@)/. + "$$(CP)" -p $$< $$@ + touch $$@ +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 @@ -123,13 +184,25 @@ $1_$2_LINK_WITH_GCC = NO ifeq "$$(BootingFromHc)" "YES" $1_$2_LINK_WITH_GCC = YES endif + ifeq "$$($1_$2_v_HS_OBJS)" "" -$1_$2_LINK_WITH_GCC = YES +# We don't want to link the GHC RTS into C-only programs. There's no +# point, and it confuses the test that all GHC-compiled programs +# were compiled with the right GHC. +$1_$2_GHC_LD_OPTS = -no-auto-link-packages -no-hs-main +endif + +# 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 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_HC)" -o $$@ $$($1_$2_v_ALL_HC_OPTS) $$(LD_OPTS) $$($1_$2_v_HS_OBJS) $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS) $$($1_$2_OTHER_OBJS) $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES)) + "$$($1_$2_HC)" -o $$@ $$($1_$2_v_ALL_HC_OPTS) $$(LD_OPTS) $$($1_$2_GHC_LD_OPTS) $$($1_$2_v_HS_OBJS) $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS) $$($1_$2_OTHER_OBJS) $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES)) else $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 $$$$@)/. "$$(CC)" -o $$@ $$($1_$2_v_ALL_CC_OPTS) $$(LD_OPTS) $$($1_$2_v_HS_OBJS) $$($1_$2_v_C_OBJS) $$($1_$2_v_S_OBJS) $$($1_$2_OTHER_OBJS) $$($1_$2_v_EXTRA_CC_OPTS) $$(addprefix -l,$$($1_$2_EXTRA_LIBRARIES)) @@ -149,37 +222,15 @@ endif $1/$2/build/tmp/$$($1_$2_PROG) : $$(ALL_STAGE1_LIBS) $$(ALL_RTS_LIBS) $$(OTHER_LIBS) endif endif -endif - -ifeq "$$($1_$2_INSTALL_INPLACE)" "NO" -$(call all-target,$1_$2,$1/$2/build/tmp/$$($1_$2_PROG)) -else -# Where do we install the inplace version? -ifeq "$$($1_$2_SHELL_WRAPPER) $$(Windows)" "YES NO" -$1_$2_INPLACE = $$(INPLACE_LIB)/$$($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 -endif +ifneq "$$($1_$2_INSTALL_INPLACE)" "NO" $(call all-target,$1_$2,$$($1_$2_INPLACE)) -$(call clean-target,$1,$2_inplace,$$($1_$2_INPLACE)) - -# INPLACE_BIN might be empty if we're distcleaning -ifeq "$(findstring clean,$(MAKECMDGOALS))" "" -$$($1_$2_INPLACE) : $1/$2/build/tmp/$$($1_$2_PROG) | $$$$(dir $$$$@)/. - "$$(CP)" -p $$< $$@ - touch $$@ endif +$(call clean-target,$1,$2_inplace,$$($1_$2_INPLACE)) # touch is necessary; cp doesn't update the file time. endif -$(call shell-wrapper,$1,$2) - ifeq "$$($1_$2_INSTALL)" "YES" ifeq "$$($1_$2_TOPDIR)" "YES" INSTALL_TOPDIRS += $1/$2/build/tmp/$$($1_$2_PROG)