summaryrefslogtreecommitdiffstats
path: root/core/distdir.mk
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2008-10-21 07:00:00 -0700
committerThe Android Open Source Project <initial-contribution@android.com>2008-10-21 07:00:00 -0700
commitb6c1cf6de79035f58b512f4400db458c8401379a (patch)
tree68979db37c85b499bc384e4ac337ed1424baab51 /core/distdir.mk
downloadbuild-b6c1cf6de79035f58b512f4400db458c8401379a.zip
build-b6c1cf6de79035f58b512f4400db458c8401379a.tar.gz
build-b6c1cf6de79035f58b512f4400db458c8401379a.tar.bz2
Initial Contribution
Diffstat (limited to 'core/distdir.mk')
-rw-r--r--core/distdir.mk77
1 files changed, 77 insertions, 0 deletions
diff --git a/core/distdir.mk b/core/distdir.mk
new file mode 100644
index 0000000..f169de0
--- /dev/null
+++ b/core/distdir.mk
@@ -0,0 +1,77 @@
+#
+# Copyright (C) 2007 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# HACK HACK HACK
+# *** Do not use any of the following as an example for anything else ***
+
+# TODO: remove this hack once the build machine no longer needs "user-dist"
+user-dist: user
+ifneq (,$(filter user-dist,$(MAKECMDGOALS)))
+ MAKECMDGOALS := $(patsubst user-dist,user dist,$(MAKECMDGOALS))
+endif
+
+# When specifying "dist", the user has asked that we copy the important
+# files from this build into DIST_DIR.
+
+.PHONY: dist
+dist: ;
+
+dist_goal := $(strip $(filter dist,$(MAKECMDGOALS)))
+MAKECMDGOALS := $(strip $(filter-out dist,$(MAKECMDGOALS)))
+ifeq (,$(strip $(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS))))
+# The commandline was something like "make dist" or "make dist showcommands".
+# Add a dependency on a real target.
+dist: $(DEFAULT_TARGET)
+endif
+
+ifdef dist_goal
+
+# $(1): source file
+# $(2): destination file
+# $(3): goals that should copy the file
+#
+define copy-one-dist-file
+$(3): $(2)
+$(2): $(1)
+ @echo "Dist: $$@"
+ $$(copy-file-to-new-target-with-cp)
+endef
+
+# Other parts of the system should use this function to associate
+# certain files with certain goals. When those goals are built
+# and "dist" is specified, the marked files will be copied to DIST_DIR.
+#
+# $(1): a list of goals (e.g., "user all")
+# $(2): the dist files to add to those goals
+define dist-for-goals
+$(foreach file,$(2), \
+ $(eval \
+ $(call copy-one-dist-file, \
+ $(file), \
+ $(DIST_DIR)/$(notdir $(file)), \
+ $(1) \
+ ) \
+ ) \
+ )
+endef
+
+else # !dist_goal
+
+# empty definition when not building dist
+define dist-for-goals
+endef
+
+endif # !dist_goal