• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#
2# Copyright (C) 2008 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# Assemble the Native Development Kit
18# Assembled using the generic build by default.
19# (set in device/config/product_config.make)
20
21# A macro to make rules to copy all newer files in a directory tree matching an
22# optional find filter and add the files to a list variable for dependencies.
23# Designed after copy_headers.make: Create a rule to copy each file;
24# copy-one-file defines the actual rule.
25# $(1): source directory tree root
26# $(2): destination directory tree root
27# $(3): list variable to append destination files to
28# $(4): optional find(1) arguments
29define define-tree-copy-rules
30  $(eval _src_files := $(shell find $(1) -type f $(4))) \
31  $(foreach _src, $(_src_files), \
32    $(eval _dest := $(patsubst $(1)%,$(2)%,$(_src))) \
33    $(eval $(3) := $($(3)) $(_dest)) \
34    $(eval $(call copy-one-file,$(_src),$(_dest))) \
35   )
36endef
37
38#-------------------------------------------------------------------------------
39# Install all the files needed to build the pndk.
40#   We build three versions of the pndk
41#       (1) The full version, with source.
42#       (2) The full version, without source.
43#       (3) A JNI-only version, with source.
44#
45#   We make five sets of trees:
46#		(A) Common files used in all versions of the pndk
47#   (B) Common files used in the full versions of the pndk
48#		(C) Files used in the standard pndk (no source files included)
49#		(D) Files used in both the JNI-only and full-with-source version
50#		(E) Files used in just the full-with-source version
51#
52#   Each pndk version is created by combining the appropriate trees:
53#
54#            (A)   (B)  (C)  (D)  (E)
55#       (1)  yes   yes       yes  yes
56#       (2)  yes   yes  yes
57#       (3)  yes             yes
58#
59# Source is provided for partners who want to recompile our libraries for optimization.
60# The JNI-only version is provided for partners that want to create shared
61# libraries that can be packaged with APK files and called from Java code.
62
63LOCAL_PATH := $(call my-dir)
64
65# Source trees for the pndk
66samples_src_dir := $(LOCAL_PATH)/samples
67sample_src_dir := $(samples_src_dir)/sample
68samplejni_src_dir := $(samples_src_dir)/samplejni
69config_src_dir := $(LOCAL_PATH)/config
70kernel_common_src_dir := $(KERNEL_HEADERS_COMMON)
71kernel_arch_src_dir := $(KERNEL_HEADERS_ARCH)
72bionic_src_dir := bionic
73jni_src_dir := $(JNI_H_INCLUDE)
74
75# Workspace directory
76pndk_intermediates := $(call intermediates-dir-for,PACKAGING,pndk)
77
78# Common destination trees for the pndk
79pndk_common_tree := $(pndk_intermediates)/common
80pndk_common_dest_dir := $(pndk_common_tree)/pndk
81samplejni_dest_dir := $(pndk_common_dest_dir)/samples/samplejni
82config_dest_dir := $(pndk_common_dest_dir)/config
83kernel_dest_dir := $(pndk_common_dest_dir)/include/kernel/include
84gcc_dest_dir := $(pndk_common_dest_dir)/toolchain
85jni_dest_dir := $(pndk_common_dest_dir)/include/nativehelper
86
87# Common-full destination trees for the pndk
88pndk_common_full_tree := $(pndk_intermediates)/common_full
89pndk_common_full_dest_dir := $(pndk_common_full_tree)/pndk
90sample_dest_dir := $(pndk_common_full_dest_dir)/samples/sample
91
92# Destination trees without source for the standard pndk (without source)
93pndk_no_src_tree := $(pndk_intermediates)/no_src
94pndk_no_src_dest_dir := $(pndk_no_src_tree)/pndk
95bionic_no_src_dest_dir := $(pndk_no_src_dest_dir)/include/bionic
96
97# Destination trees including source for the pndk with source
98pndk_src_tree := $(pndk_intermediates)/with_src
99pndk_src_dest_dir := $(pndk_src_tree)/pndk
100bionic_src_dest_dir := $(pndk_src_dest_dir)/include/bionic
101
102# Destinations of all common files (not picked up by tree rules below)
103pndk_common_dest_files := $(pndk_common_dest_dir)/Android_PNDK_README.html \
104		$(pndk_common_dest_dir)/config/armelf.x \
105		$(pndk_common_dest_dir)/config/armelflib.x \
106		$(pndk_common_dest_dir)/lib/crtbegin_dynamic.o \
107		$(pndk_common_dest_dir)/lib/crtend_android.o \
108		$(pndk_common_dest_dir)/lib/libc.so \
109		$(pndk_common_dest_dir)/lib/libm.so
110
111# Destinations of files used by the full, non-jni-only configurations
112pndk_common_full_dest_files := \
113		$(pndk_common_full_dest_dir)/lib/libdl.so \
114		$(pndk_common_full_dest_dir)/lib/libstdc++.so
115
116# Install common files outside common trees
117$(pndk_common_dest_dir)/Android_PNDK_README.html: $(LOCAL_PATH)/Android_PNDK_README.html | $(ACP)
118	@echo "pndk Android_PNDK_README.html: from $? to $@"
119	$(copy-file-to-target)
120
121$(pndk_common_dest_dir)/config/armelf.x: $(BUILD_SYSTEM)/armelf.x | $(ACP)
122	@echo "pndk config: $@"
123	$(copy-file-to-target)
124
125$(pndk_common_dest_dir)/config/armelflib.x: $(BUILD_SYSTEM)/armelflib.x | $(ACP)
126	@echo "pndk config: $@"
127	$(copy-file-to-target)
128
129$(pndk_common_dest_dir)/lib/%: $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/% | $(ACP)
130	@echo "pndk lib: $@"
131	$(copy-file-to-target)
132
133# Install common_full files outside common trees
134$(pndk_common_full_dest_dir)/lib/%: $(TARGET_OUT_INTERMEDIATE_LIBRARIES)/% | $(ACP)
135	@echo "pndk lib full: $@"
136	$(copy-file-to-target)
137
138# Install files in common trees
139listvar := pndk_common_dest_files
140$(call define-tree-copy-rules,$(samplejni_src_dir),$(samplejni_dest_dir),$(listvar))
141$(call define-tree-copy-rules,$(config_src_dir),$(config_dest_dir),$(listvar))
142$(call define-tree-copy-rules,$(kernel_common_src_dir),$(kernel_dest_dir),$(listvar))
143$(call define-tree-copy-rules,$(kernel_arch_src_dir),$(kernel_dest_dir),$(listvar))
144$(call define-tree-copy-rules,$(jni_src_dir),$(jni_dest_dir),$(listvar), -name jni.h)
145
146# Install files common to the full builds but not the JNI build
147listvar := pndk_common_full_dest_files
148$(call define-tree-copy-rules,$(sample_src_dir),$(sample_dest_dir),$(listvar))
149
150# Install files without sources
151listvar := pndk_no_src_dest_files
152$(call define-tree-copy-rules,$(bionic_src_dir),$(bionic_no_src_dest_dir),$(listvar),-name '*.h')
153
154# Install files including sources
155listvar := pndk_with_src_dest_files
156$(call define-tree-copy-rules,$(bionic_src_dir),$(bionic_src_dest_dir),$(listvar))
157
158
159#-------------------------------------------------------------------------------
160# Create the multiple versions of the pndk:
161# pndk_no_src           all files without source
162# pndk_with_source      all files with source
163# pndk_jni_with_source  just files for building JNI shared libraries with source.
164
165# Name the tar files
166name := android_pndk-$(TARGET_PRODUCT)
167ifeq ($(TARGET_BUILD_TYPE),debug)
168  name := $(name)_debug
169endif
170name := $(name)-$(BUILD_NUMBER)
171pndk_tarfile := $(pndk_intermediates)/$(name).tar
172pndk_tarfile_zipped := $(pndk_tarfile).gz
173pndk_with_src_tarfile := $(pndk_intermediates)/$(name)-src.tar
174pndk_with_src_tarfile_zipped := $(pndk_with_src_tarfile).gz
175pndk_jni_with_src_tarfile := $(pndk_intermediates)/$(name)-jni-src.tar
176pndk_jni_with_src_tarfile_zipped := $(pndk_jni_with_src_tarfile).gz
177
178.PHONY: pndk pndk_with_src pndk_no_src pndk_jni_with_src pndk_debug
179
180pndk: pndk_no_src pndk_with_src pndk_jni_with_src
181pndk_no_src: $(pndk_tarfile_zipped)
182pndk_with_src: $(pndk_with_src_tarfile_zipped)
183pndk_jni_with_src: $(pndk_jni_with_src_tarfile_zipped)
184
185# Put the pndk zip files in the distribution directory
186$(call dist-for-goals,pndk,$(pndk_tarfile_zipped))
187$(call dist-for-goals,pndk,$(pndk_with_src_tarfile_zipped))
188$(call dist-for-goals,pndk,$(pndk_jni_with_src_tarfile_zipped))
189
190# zip up tar files
191%.tar.gz: %.tar
192	@echo "pndk: zipped $<"
193	$(hide) gzip -cf $< > $@
194
195# tar up the files without our sources to make the pndk.
196$(pndk_tarfile): $(pndk_common_dest_files) $(pndk_common_full_dest_files) $(pndk_no_src_dest_files)
197	@echo "pndk: $@"
198	@mkdir -p $(dir $@)
199	@rm -f $@
200	$(hide) tar rf $@ -C $(pndk_common_tree) pndk
201	$(hide) tar rf $@ -C $(pndk_common_full_tree) pndk
202	$(hide) tar rf $@ -C $(pndk_no_src_tree) pndk
203
204# tar up the full sources to make the pndk with sources.
205$(pndk_with_src_tarfile): $(pndk_common_dest_files) $(pndk_common_full_dest_files) $(pndk_with_src_dest_files) $(pndk_full_with_src_dest_files)
206	@echo "pndk: $@"
207	@mkdir -p $(dir $@)
208	@rm -f $@
209	$(hide) tar rf $@ -C $(pndk_common_tree) pndk
210	$(hide) tar rf $@ -C $(pndk_common_full_tree) pndk
211	$(hide) tar rf $@ -C $(pndk_src_tree) pndk
212
213# tar up the sources to make the pndk with JNI support.
214$(pndk_jni_with_src_tarfile): $(pndk_common_dest_files) $(pndk_with_src_dest_files)
215	@echo "pndk: $@"
216	@mkdir -p $(dir $@)
217	@rm -f $@
218	$(hide) tar rf $@ -C $(pndk_common_tree) pndk
219	$(hide) tar rf $@ -C $(pndk_src_tree) pndk
220
221# Debugging reporting can go here, add it as a target to get output.
222pndk_debug: pndk
223	@echo "You are here: $@"
224	@echo "pndk tar file:          $(pndk_tarfile_zipped)"
225	@echo "pndk_with_src tar file: $(pndk_with_src_tarfile_zipped)"
226	@echo "pndk_jni_with_src tar file: $(pndk_jni_with_src_tarfile_zipped)"
227	@echo "pndk_files:             $(pndk_no_src_dest_files)"
228	@echo "pndk_with_src files:    $(pndk_with_src_dest_files)"
229	@echo "pndk_full_with_src files:    $(pndk_full_with_src_dest_files)"
230	@echo "pndk_common_files:      $(pndk_common_dest_files)"
231	@echo "pndk_common_full_dest_files:      $(pndk_common_full_dest_files)"
232
233