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
21BIONIC_TESTS_ZIPALIGN := $(HOST_OUT_EXECUTABLES)/bionic_tests_zipalign
22
23include $(CLEAR_VARS)
24
25LOCAL_MODULE_CLASS := NATIVE_TESTS
26LOCAL_MODULE := libdlext_test_zip_zipaligned
27LOCAL_MODULE_SUFFIX := .zip
28LOCAL_MODULE_PATH := $($(bionic_2nd_arch_prefix)TARGET_OUT_DATA_NATIVE_TESTS)/bionic-loader-test-libs/libdlext_test_zip
29LOCAL_2ND_ARCH_VAR_PREFIX := $(bionic_2nd_arch_prefix)
30
31include $(BUILD_SYSTEM)/base_rules.mk
32
33my_shared_libs := \
34  $(call intermediates-dir-for,SHARED_LIBRARIES,libdlext_test_zip,,,$(bionic_2nd_arch_prefix))/libdlext_test_zip.so \
35  $(call intermediates-dir-for,SHARED_LIBRARIES,libatest_simple_zip,,,$(bionic_2nd_arch_prefix))/libatest_simple_zip.so \
36  $(call intermediates-dir-for,NATIVE_TESTS,exec_linker_helper,,,$(bionic_2nd_arch_prefix))/exec_linker_helper \
37  $(call intermediates-dir-for,SHARED_LIBRARIES,exec_linker_helper_lib,,,$(bionic_2nd_arch_prefix))/exec_linker_helper_lib.so
38
39$(LOCAL_BUILT_MODULE): PRIVATE_SHARED_LIBS := $(my_shared_libs)
40$(LOCAL_BUILT_MODULE): $(my_shared_libs) $(BIONIC_TESTS_ZIPALIGN)
41	@echo "Aligning zip: $@"
42	$(hide) rm -rf $@.unaligned $@ $(dir $@)/zipdir && mkdir -p $(dir $@)/zipdir/libdir
43	$(hide) cp $(PRIVATE_SHARED_LIBS) $(dir $@)/zipdir/libdir
44	$(hide) touch $(dir $@)/zipdir/empty_file.txt
45	$(hide) (cd $(dir $@)/zipdir && zip -qrD0 ../$(notdir $@).unaligned .)
46	$(hide) $(BIONIC_TESTS_ZIPALIGN) 4096 $@.unaligned $@
47
48include $(CLEAR_VARS)
49
50LOCAL_MODULE_CLASS := NATIVE_TESTS
51LOCAL_MODULE := libdlext_test_runpath_zip_zipaligned
52LOCAL_MODULE_SUFFIX := .zip
53LOCAL_MODULE_PATH := $($(bionic_2nd_arch_prefix)TARGET_OUT_DATA_NATIVE_TESTS)/bionic-loader-test-libs/libdlext_test_runpath_zip
54LOCAL_2ND_ARCH_VAR_PREFIX := $(bionic_2nd_arch_prefix)
55
56include $(BUILD_SYSTEM)/base_rules.mk
57lib_d := $(call intermediates-dir-for,SHARED_LIBRARIES,libtest_dt_runpath_d_zip,,,$(bionic_2nd_arch_prefix))/libtest_dt_runpath_d_zip.so
58lib_a := $(call intermediates-dir-for,SHARED_LIBRARIES,libtest_dt_runpath_a,,,$(bionic_2nd_arch_prefix))/libtest_dt_runpath_a.so
59lib_b := $(call intermediates-dir-for,SHARED_LIBRARIES,libtest_dt_runpath_b,,,$(bionic_2nd_arch_prefix))/libtest_dt_runpath_b.so
60lib_c := $(call intermediates-dir-for,SHARED_LIBRARIES,libtest_dt_runpath_c,,,$(bionic_2nd_arch_prefix))/libtest_dt_runpath_c.so
61lib_x := $(call intermediates-dir-for,SHARED_LIBRARIES,libtest_dt_runpath_x,,,$(bionic_2nd_arch_prefix))/libtest_dt_runpath_x.so
62lib_y := $(call intermediates-dir-for,SHARED_LIBRARIES,libtest_dt_runpath_y,,,$(bionic_2nd_arch_prefix))/libtest_dt_runpath_y.so
63
64$(LOCAL_BUILT_MODULE) : PRIVATE_LIB_D := $(lib_d)
65$(LOCAL_BUILT_MODULE) : PRIVATE_LIB_A := $(lib_a)
66$(LOCAL_BUILT_MODULE) : PRIVATE_LIB_B := $(lib_b)
67$(LOCAL_BUILT_MODULE) : PRIVATE_LIB_C := $(lib_c)
68$(LOCAL_BUILT_MODULE) : PRIVATE_LIB_X := $(lib_x)
69$(LOCAL_BUILT_MODULE) : PRIVATE_LIB_Y := $(lib_y)
70ifeq ($(TARGET_IS_64_BIT),true)
71  ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
72    $(LOCAL_BUILT_MODULE) : PRIVATE_LIB_OR_LIB64 := $(if $(LOCAL_2ND_ARCH_VAR_PREFIX),lib/$(TARGET_2ND_ARCH),lib64)
73  else
74    $(LOCAL_BUILT_MODULE) : PRIVATE_LIB_OR_LIB64 := $(if $(LOCAL_2ND_ARCH_VAR_PREFIX),lib,lib64)
75  endif
76else
77  ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
78    $(LOCAL_BUILT_MODULE) : PRIVATE_LIB_OR_LIB64 := $(if $(LOCAL_2ND_ARCH_VAR_PREFIX),lib/$(TARGET_2ND_ARCH),lib)
79  else
80    $(LOCAL_BUILT_MODULE) : PRIVATE_LIB_OR_LIB64 := lib
81  endif
82endif
83$(LOCAL_BUILT_MODULE) : $(lib_d) $(lib_a) $(lib_b) $(lib_c) $(lib_x) $(lib_y) $(BIONIC_TESTS_ZIPALIGN)
84	@echo "Aligning zip: $@"
85	$(hide) rm -rf $@.unaligned $@ $(dir $@)/zipdir && mkdir -p $(dir $@)/zipdir/libdir && \
86    mkdir -p $(dir $@)/zipdir/libdir/dt_runpath_a && mkdir -p $(dir $@)/zipdir/libdir/dt_runpath_b_c_x && \
87    mkdir -p $(dir $@)/zipdir/libdir/dt_runpath_y/$(PRIVATE_LIB_OR_LIB64)
88	$(hide) cp $(PRIVATE_LIB_D) $(dir $@)/zipdir/libdir
89	$(hide) cp $(PRIVATE_LIB_A) $(dir $@)/zipdir/libdir/dt_runpath_a
90	$(hide) cp $(PRIVATE_LIB_B) $(dir $@)/zipdir/libdir/dt_runpath_b_c_x
91	$(hide) cp $(PRIVATE_LIB_C) $(dir $@)/zipdir/libdir/dt_runpath_b_c_x
92	$(hide) cp $(PRIVATE_LIB_X) $(dir $@)/zipdir/libdir/dt_runpath_b_c_x
93	$(hide) cp $(PRIVATE_LIB_Y) $(dir $@)/zipdir/libdir/dt_runpath_y/$(PRIVATE_LIB_OR_LIB64)
94	$(hide) touch $(dir $@)/zipdir/empty_file.txt
95	$(hide) (cd $(dir $@)/zipdir && zip -qrD0 ../$(notdir $@).unaligned .)
96	$(hide) $(BIONIC_TESTS_ZIPALIGN) 4096 $@.unaligned $@
97
98