• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (C) 2008 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15
16# this turns off the suffix rules built into make
17.SUFFIXES:
18
19# this turns off the RCS / SCCS implicit rules of GNU Make
20% : RCS/%,v
21% : RCS/%
22% : %,v
23% : s.%
24% : SCCS/s.%
25
26# If a rule fails, delete $@.
27.DELETE_ON_ERROR:
28
29# shared definitions
30ifeq ($(strip $(SHOW)),)
31define pretty
32@echo $1
33endef
34hide := @
35else
36define pretty
37endef
38hide :=
39endif
40
41define my-dir
42.
43endef
44
45# return the directory containing the intermediate files for a given
46# kind of executable
47# $1 = type (EXECUTABLES or STATIC_LIBRARIES)
48# $2 = module name
49# $3 = ignored
50#
51define intermediates-dir-for
52$(OBJS_DIR)/intermediates/$(2)
53endef
54
55# Generate the full path of a given static library
56define library-path
57$(OBJS_DIR)/libs/$(1).a
58endef
59
60define executable-path
61$(OBJS_DIR)/$(1)$(EXE)
62endef
63
64# Compile a C source file
65#
66define  compile-c-source
67SRC:=$(1)
68OBJ:=$$(LOCAL_OBJS_DIR)/$$(SRC:%.c=%.o)
69LOCAL_OBJECTS += $$(OBJ)
70DEPENDENCY_DIRS += $$(dir $$(OBJ))
71$$(OBJ): PRIVATE_CFLAGS := $$(CFLAGS) $$(LOCAL_CFLAGS) -I$$(LOCAL_PATH) -I$$(LOCAL_OBJS_DIR)
72$$(OBJ): PRIVATE_CC     := $$(LOCAL_CC)
73$$(OBJ): PRIVATE_OBJ    := $$(OBJ)
74$$(OBJ): PRIVATE_MODULE := $$(LOCAL_MODULE)
75$$(OBJ): PRIVATE_SRC    := $$(SRC_PATH)/$$(SRC)
76$$(OBJ): PRIVATE_SRC0   := $$(SRC)
77$$(OBJ): $$(SRC_PATH)/$$(SRC)
78	@mkdir -p $$(dir $$(PRIVATE_OBJ))
79	@echo "Compile: $$(PRIVATE_MODULE) <= $$(PRIVATE_SRC0)"
80	$(hide) $$(PRIVATE_CC) $$(PRIVATE_CFLAGS) -c -o $$(PRIVATE_OBJ) -MMD -MP -MF $$(PRIVATE_OBJ).d.tmp $$(PRIVATE_SRC)
81	$(hide) $$(BUILD_SYSTEM)/mkdeps.sh $$(PRIVATE_OBJ) $$(PRIVATE_OBJ).d.tmp $$(PRIVATE_OBJ).d
82endef
83
84# Compile a C++ source file
85#
86define  compile-cxx-source
87SRC:=$(1)
88OBJ:=$$(LOCAL_OBJS_DIR)/$$(SRC:%$(LOCAL_CPP_EXTENSION)=%.o)
89LOCAL_OBJECTS += $$(OBJ)
90DEPENDENCY_DIRS += $$(dir $$(OBJ))
91$$(OBJ): PRIVATE_CFLAGS := $$(CFLAGS) $$(LOCAL_CFLAGS) -I$$(LOCAL_PATH) -I$$(LOCAL_OBJS_DIR)
92$$(OBJ): PRIVATE_CXX    := $$(LOCAL_CC)
93$$(OBJ): PRIVATE_OBJ    := $$(OBJ)
94$$(OBJ): PRIVATE_MODULE := $$(LOCAL_MODULE)
95$$(OBJ): PRIVATE_SRC    := $$(SRC_PATH)/$$(SRC)
96$$(OBJ): PRIVATE_SRC0   := $$(SRC)
97$$(OBJ): $$(SRC_PATH)/$$(SRC)
98	@mkdir -p $$(dir $$(PRIVATE_OBJ))
99	@echo "Compile: $$(PRIVATE_MODULE) <= $$(PRIVATE_SRC0)"
100	$(hide) $$(PRIVATE_CXX) $$(PRIVATE_CFLAGS) -c -o $$(PRIVATE_OBJ) -MMD -MP -MF $$(PRIVATE_OBJ).d.tmp $$(PRIVATE_SRC)
101	$(hide) $$(BUILD_SYSTEM)/mkdeps.sh $$(PRIVATE_OBJ) $$(PRIVATE_OBJ).d.tmp $$(PRIVATE_OBJ).d
102endef
103
104# Compile an Objective-C source file
105#
106define  compile-objc-source
107SRC:=$(1)
108OBJ:=$$(LOCAL_OBJS_DIR)/$$(notdir $$(SRC:%.m=%.o))
109LOCAL_OBJECTS += $$(OBJ)
110DEPENDENCY_DIRS += $$(dir $$(OBJ))
111$$(OBJ): PRIVATE_CFLAGS := $$(CFLAGS) $$(LOCAL_CFLAGS) -I$$(LOCAL_PATH) -I$$(LOCAL_OBJS_DIR)
112$$(OBJ): PRIVATE_CC     := $$(LOCAL_CC)
113$$(OBJ): PRIVATE_OBJ    := $$(OBJ)
114$$(OBJ): PRIVATE_MODULE := $$(LOCAL_MODULE)
115$$(OBJ): PRIVATE_SRC    := $$(SRC_PATH)/$$(SRC)
116$$(OBJ): PRIVATE_SRC0   := $$(SRC)
117$$(OBJ): $$(SRC_PATH)/$$(SRC)
118	@mkdir -p $$(dir $$(PRIVATE_OBJ))
119	@echo "Compile: $$(PRIVATE_MODULE) <= $$(PRIVATE_SRC0)"
120	$(hide) $$(PRIVATE_CC) $$(PRIVATE_CFLAGS) -c -o $$(PRIVATE_OBJ) -MMD -MP -MF $$(PRIVATE_OBJ).d.tmp $$(PRIVATE_SRC)
121	$(hide) $$(BUILD_SYSTEM)/mkdeps.sh $$(PRIVATE_OBJ) $$(PRIVATE_OBJ).d.tmp $$(PRIVATE_OBJ).d
122endef
123
124# Compile a generated C source files#
125#
126define compile-generated-c-source
127SRC:=$(1)
128OBJ:=$$(LOCAL_OBJS_DIR)/$$(notdir $$(SRC:%.c=%.o))
129LOCAL_OBJECTS += $$(OBJ)
130DEPENDENCY_DIRS += $$(dir $$(OBJ))
131$$(OBJ): PRIVATE_CFLAGS := $$(CFLAGS) $$(LOCAL_CFLAGS) -I$$(LOCAL_PATH) -I$$(LOCAL_OBJS_DIR)
132$$(OBJ): PRIVATE_CC     := $$(LOCAL_CC)
133$$(OBJ): PRIVATE_OBJ    := $$(OBJ)
134$$(OBJ): PRIVATE_MODULE := $$(LOCAL_MODULE)
135$$(OBJ): PRIVATE_SRC    := $$(SRC)
136$$(OBJ): PRIVATE_SRC0   := $$(SRC)
137$$(OBJ): $$(SRC)
138	@mkdir -p $$(dir $$(PRIVATE_OBJ))
139	@echo "Compile: $$(PRIVATE_MODULE) <= $$(PRIVATE_SRC0)"
140	$(hide) $$(PRIVATE_CC) $$(PRIVATE_CFLAGS) -c -o $$(PRIVATE_OBJ) -MMD -MP -MF $$(PRIVATE_OBJ).d.tmp $$(PRIVATE_SRC)
141	$(hide) $$(BUILD_SYSTEM)/mkdeps.sh $$(PRIVATE_OBJ) $$(PRIVATE_OBJ).d.tmp $$(PRIVATE_OBJ).d
142endef
143
144# Install a file
145#
146define install-target
147SRC:=$(1)
148DST:=$(2)
149$$(DST): PRIVATE_SRC := $$(SRC)
150$$(DST): PRIVATE_DST := $$(DST)
151$$(DST): PRIVATE_DST_NAME := $$(notdir $$(DST))
152$$(DST): PRIVATE_SRC_NAME := $$(SRC)
153$$(DST): $$(SRC)
154	@mkdir -p $$(dir $$(PRIVATE_DST))
155	@echo "Install: $$(PRIVATE_DST_NAME) <= $$(PRIVATE_SRC_NAME)"
156	$(hide) cp -f $$(PRIVATE_SRC) $$(PRIVATE_DST)
157install: $$(DST)
158endef
159
160# for now, we only use prebuilt SDL libraries, so copy them
161define copy-prebuilt-lib
162_SRC := $(1)
163_SRC1 := $$(notdir $$(_SRC))
164_DST := $$(LIBS_DIR)/$$(_SRC1)
165LIBRARIES += $$(_DST)
166$$(_DST): PRIVATE_DST := $$(_DST)
167$$(_DST): PRIVATE_SRC := $$(_SRC)
168$$(_DST): $$(_SRC)
169	@mkdir -p $$(dir $$(PRIVATE_DST))
170	@echo "Prebuilt: $$(PRIVATE_DST)"
171	$(hide) cp -f $$(PRIVATE_SRC) $$(PRIVATE_DST)
172endef
173
174define  create-dir
175$(1):
176	mkdir -p $(1)
177endef
178
179define transform-generated-source
180@echo "Generated: $(PRIVATE_MODULE) <= $<"
181@mkdir -p $(dir $@)
182$(hide) $(PRIVATE_CUSTOM_TOOL)
183endef
184
185