1#
2# Copyright (C) 2014 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# -----------------------------------------------------------------------------
18# Library used by dlext tests - zipped and aligned
19# -----------------------------------------------------------------------------
20
21include $(CLEAR_VARS)
22
23LOCAL_MODULE_CLASS := SHARED_LIBRARIES
24LOCAL_MODULE := libdlext_test_fd_zipaligned
25LOCAL_MODULE_SUFFIX := .zip
26LOCAL_MODULE_TAGS := tests
27LOCAL_MODULE_PATH := $($(bionic_2nd_arch_prefix)TARGET_OUT_DATA_NATIVE_TESTS)/libdlext_test_fd
28LOCAL_2ND_ARCH_VAR_PREFIX := $(bionic_2nd_arch_prefix)
29
30include $(BUILD_SYSTEM)/base_rules.mk
31
32my_shared_libs := \
33  $($(bionic_2nd_arch_prefix)TARGET_OUT_INTERMEDIATE_LIBRARIES)/libdlext_test_fd.so
34
35$(LOCAL_BUILT_MODULE): PRIVATE_ALIGNMENT := 4096 # PAGE_SIZE
36$(LOCAL_BUILT_MODULE) : $(my_shared_libs) | $(ZIPALIGN)
37	@echo "Zipalign $(PRIVATE_ALIGNMENT): $@"
38	$(hide) rm -rf $(dir $@) && mkdir -p $(dir $@)/libdir
39	$(hide) cp $^ $(dir $@)/libdir
40	$(hide) (cd $(dir $@) && touch empty_file.txt && zip -rD0 $(notdir $@).unaligned empty_file.txt libdir/*.so)
41	$(hide) $(ZIPALIGN) $(PRIVATE_ALIGNMENT) $@.unaligned $@
42