distdir.mk revision dcc08f073b6873c69ab891d4f69f7c568e282df7
1#
2# Copyright (C) 2007 The Android Open Source Project
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#      http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15#
16
17# When specifying "dist", the user has asked that we copy the important
18# files from this build into DIST_DIR.
19
20.PHONY: dist
21dist: ;
22
23dist_goal := $(strip $(filter dist,$(MAKECMDGOALS)))
24MAKECMDGOALS := $(strip $(filter-out dist,$(MAKECMDGOALS)))
25ifeq (,$(strip $(filter-out $(INTERNAL_MODIFIER_TARGETS),$(MAKECMDGOALS))))
26# The commandline was something like "make dist" or "make dist showcommands".
27# Add a dependency on a real target.
28dist: $(DEFAULT_GOAL)
29endif
30
31ifdef dist_goal
32
33# $(1): source file
34# $(2): destination file
35# $(3): goals that should copy the file
36#
37define copy-one-dist-file
38$(3): $(2)
39$(2): $(1)
40	@echo "Dist: $$@"
41	$$(copy-file-to-new-target-with-cp)
42endef
43
44# Other parts of the system should use this function to associate
45# certain files with certain goals.  When those goals are built
46# and "dist" is specified, the marked files will be copied to DIST_DIR.
47#
48# $(1): a list of goals  (e.g. droid, sdk, pdk, ndk)
49# $(2): the dist files to add to those goals
50define dist-for-goals
51$(foreach file,$(2), \
52  $(eval \
53      $(call copy-one-dist-file, \
54          $(file), \
55          $(DIST_DIR)/$(notdir $(file)), \
56	  $(1) \
57       ) \
58   ) \
59 )
60endef
61
62else # !dist_goal
63
64# empty definition when not building dist
65define dist-for-goals
66endef
67
68endif # !dist_goal
69