Bug 842106 Copy some build files from mozilla-central to fix bustage finding makeutils.mk. r=Callek CLOSED TREE
authorMark Banner <bugzilla@standard8.plus.com>
Mon, 18 Feb 2013 07:51:51 +0000
changeset 14871 bce8262aabcc6bb720ed18ec46b47e1f691be5ca
parent 14870 ef54286ed6520bffa7ce4b73174fe2373661b303
child 14872 c1d9ed13f285b0ca3750633bb8c118320e83736c
push idunknown
push userunknown
push dateunknown
reviewersCallek
bugs842106
Bug 842106 Copy some build files from mozilla-central to fix bustage finding makeutils.mk. r=Callek CLOSED TREE
Makefile.in
config/makefiles/makeutils.mk
config/makefiles/rcs.mk
--- a/Makefile.in
+++ b/Makefile.in
@@ -49,16 +49,18 @@ check mochitest reftest crashtest xpcshe
 	$(MAKE) -C mozilla $@
 
 mochitest-% :: $(SUBMAKEFILES)
 	$(MAKE) -C mozilla $@
 
 check-sync-dirs::
 	@$(PYTHON) $(topsrcdir)/mozilla/js/src/config/check-sync-dirs.py \
 	   $(topsrcdir)/build $(topsrcdir)/mozilla/build
+	@$(PYTHON) $(topsrcdir)/mozilla/js/src/config/check-sync-dirs.py \
+	   $(topsrcdir)/config/makefiles $(topsrcdir)/mozilla/config/makefiles
 
 check:: check-sync-dirs
 
 ifndef MOZ_THUNDERBIRD
 package-tests:: $(SUBMAKEFILES)
 	$(MAKE) -C mozilla $@
 endif
 endif
new file mode 100644
--- /dev/null
+++ b/config/makefiles/makeutils.mk
@@ -0,0 +1,121 @@
+# -*- makefile -*-
+# vim:set ts=8 sw=8 sts=8 noet:
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
+# You can obtain one at http://mozilla.org/MPL/2.0/.
+
+## Identify function argument types
+istype =$(if $(value ${1}),list,scalar)
+isval  =$(if $(filter-out list,$(call istype,${1})),true)
+isvar  =$(if $(filter-out scalar,$(call istype,${1})),true)
+
+# Access up to 9 arguments passed, option needed to emulate $*
+# Inline for function expansion, do not use $(call )
+argv  =$(strip
+argv +=$(if $(1), $(1))$(if $(2), $(2))$(if $(3), $(3))$(if $(4), $(4))
+argv +=$(if $(5), $(5))$(if $(6), $(6))$(if $(7), $(7))$(if $(8), $(8))
+argv +=$(if $(9), $(9))
+argv +=$(if $(10), $(error makeutils.mk::argv can only handle 9 arguments))
+argv +=)
+
+###########################################################################
+## Access function args as a simple list, inline within user functions.
+## Usage: $(info ** $(call banner,$(getargv)))
+##    $(call banner,scalar)
+##    $(call banner,list0 list1 list2)
+##    $(call banner,ref) ; ref=foo bar tans
+## getarglist() would be a more accurate name but is longer to type
+getargv = $(if $(call isvar,$(1)),$($(1)),$(argv))
+
+###########################################################################
+# Strip [n] leading options from an argument list.  This will allow passing
+# extra args to user functions that will not propogate to sub-$(call )'s
+# Usage: $(call subargv,2)
+subargv =$(wordlist $(1),$(words $(getargv)),$(getargv))
+
+###########################################################################
+# Intent: Display a distinct banner heading in the output stream
+# Usage: $(call banner,BUILDING: foo bar tans)
+# Debug:
+#   target-preqs = \
+#     $(call banner,target-preqs-BEGIN) \
+#     foo bar tans \
+#     $(call banner,target-preqs-END) \
+#     $(NULL)
+#   target: $(target-preqs)
+
+banner = \
+$(info ) \
+$(info ***************************************************************************) \
+$(info ** $(getargv)) \
+$(info ***************************************************************************) \
+$(NULL)
+
+#####################################################################
+# Intent: Determine if a string or pattern is contained in a list
+# Usage: strcmp  - $(call if_XinY,clean,$(MAKECMDGOALS))
+#      : pattern - $(call if_XinY,clean%,$(MAKECMDGOALS))
+is_XinY =$(filter $(1),$(call subargv,3,$(getargv)))
+
+#####################################################################
+# Provide an alternate var to support testing
+ifdef MAKEUTILS_UNIT_TEST
+  mcg_goals=TEST_MAKECMDGOALS
+else
+  mcg_goals=MAKECMDGOALS
+endif
+
+# Intent: Conditionals for detecting common/tier target use
+isTargetStem       = $(sort \
+  $(foreach var,$(getargv),\
+    $(foreach pat,$(var)% %$(var),\
+      $(call is_XinY,$(pat),${$(mcg_goals)})\
+  )))
+isTargetStemClean  = $(call isTargetStem,clean)
+isTargetStemExport = $(call isTargetStem,export)
+isTargetStemLibs   = $(call isTargetStem,libs)
+isTargetStemTools  = $(call isTargetStem,tools)
+
+##################################################
+# Intent: Validation functions / unit test helpers
+
+errorifneq =$(if $(subst $(strip $(1)),$(NULL),$(strip $(2))),$(error expected [$(1)] but found [$(2)]))
+
+# Intent: verify function declaration exists
+requiredfunction =$(foreach func,$(1) $(2) $(3) $(4) $(5) $(6) $(7) $(8) $(9),$(if $(value $(func)),$(NULL),$(error required function [$(func)] is unavailable)))
+
+
+
+## http://www.gnu.org/software/make/manual/make.html#Call-Function
+## Usage: o = $(call map,origin,o map $(MAKE))
+map = $(foreach val,$(2),$(call $(1),$(val)))
+
+
+## Disable checking for clean targets
+ifeq (,$(filter %clean clean%,$(MAKECMDGOALS))) #{
+
+# Usage: $(call checkIfEmpty,[error|warning] foo NULL bar)
+checkIfEmpty =$(foreach var,$(wordlist 2,100,$(argv)),$(if $(strip $($(var))),$(NOP),$(call $(1),Variable $(var) does not contain a value)))
+
+# Usage: $(call errorIfEmpty,foo NULL bar)
+errorIfEmpty =$(call checkIfEmpty,error $(argv))
+warnIfEmpty  =$(call checkIfEmpty,warning $(argv))
+
+endif #}
+
+###########################################################################
+## Common makefile library loader
+###########################################################################
+topORerr =$(if $(topsrcdir),$(topsrcdir),$(error topsrcdir is not defined))
+
+ifdef USE_AUTOTARGETS_MK # mkdir_deps
+  include $(topORerr)/config/makefiles/autotargets.mk
+endif
+
+ifdef USE_RCS_MK
+  include $(topORerr)/config/makefiles/rcs.mk
+endif
+
+## copy(src, dst): recursive copy
+copy_dir = (cd $(1)/. && $(TAR) $(TAR_CREATE_FLAGS_QUIET) - .) | (cd $(2)/. && tar -xf -)
new file mode 100644
--- /dev/null
+++ b/config/makefiles/rcs.mk
@@ -0,0 +1,42 @@
+# -*- makefile -*-
+# vim:set ts=8 sw=8 sts=8 noet:
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this file,
+# You can obtain one at http://mozilla.org/MPL/2.0/.
+#
+
+ifdef USE_RCS_MK #{
+
+ifndef INCLUDED_RCS_MK #{
+
+MOZ_RCS_TYPE ?= $(notdir $(wildcard $(topsrcdir)/.hg))
+
+
+###########################################################################
+# HAVE_MERCURIAL_RCS
+###########################################################################
+ifeq (.hg,$(MOZ_RCS_TYPE)) #{
+
+# Intent: Retrieve the http:// repository path for a directory.
+# Usage: $(call getSourceRepo[,repo_dir|args])
+# Args:
+#   path (optional): repository to query.  Defaults to $(topsrcdir)
+getSourceRepo = \
+  $(call FUNC_getSourceRepo,$(if $(1),cd $(1) && hg,hg --repository $(topsrcdir)))
+
+# return: http://hg.mozilla.org/mozilla-central
+FUNC_getSourceRepo = \
+  $(strip \
+    $(patsubst %/,%,\
+    $(patsubst ssh://%,http://%,\
+    $(firstword $(shell $(getargv) showconfig paths.default))\
+    )))
+
+endif #} HAVE_MERCURIAL_RCS
+
+
+INCLUDED_RCS_MK := 1
+endif #}
+
+endif #}