1# Copyright (C) 2015 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
15LOCAL_PATH := $(call my-dir)
16
17# Common variables
18# ========================================================
19trunksCppExtension := .cc
20trunksCFlags := \
21  -Wall -Werror \
22  -Wno-unused-parameter \
23  -DUSE_BINDER_IPC \
24  -fvisibility=hidden
25trunksIncludes := $(LOCAL_PATH)/..
26trunksSharedLibraries := \
27  libbinder \
28  libbinderwrapper \
29  libbrillo \
30  libbrillo-binder \
31  libchrome \
32  libchrome-crypto \
33  libcrypto \
34  libprotobuf-cpp-lite \
35  libutils
36
37# libtrunks_generated
38# ========================================================
39include $(CLEAR_VARS)
40LOCAL_MODULE := libtrunks_generated
41LOCAL_MODULE_CLASS := STATIC_LIBRARIES
42LOCAL_CPP_EXTENSION := $(trunksCppExtension)
43LOCAL_CFLAGS := $(trunksCFlags)
44LOCAL_CLANG := true
45proto_include := $(call local-generated-sources-dir)/proto/$(LOCAL_PATH)/..
46aidl_include := $(call local-generated-sources-dir)/aidl-generated/include
47LOCAL_C_INCLUDES := $(proto_include) $(aidl_include) $(trunksIncludes)
48LOCAL_EXPORT_C_INCLUDE_DIRS := $(proto_include) $(aidl_include)
49LOCAL_SHARED_LIBRARIES := $(trunksSharedLibraries)
50LOCAL_SRC_FILES := \
51  interface.proto \
52  aidl/android/trunks/ITrunks.aidl \
53  aidl/android/trunks/ITrunksClient.aidl
54LOCAL_AIDL_INCLUDES := $(LOCAL_PATH)/aidl
55include $(BUILD_STATIC_LIBRARY)
56
57# libtrunks_common
58# ========================================================
59include $(CLEAR_VARS)
60LOCAL_MODULE := libtrunks_common
61LOCAL_CPP_EXTENSION := $(trunksCppExtension)
62LOCAL_CFLAGS := $(trunksCFlags)
63LOCAL_CLANG := true
64LOCAL_C_INCLUDES := $(trunksIncludes)
65LOCAL_SHARED_LIBRARIES := $(trunksSharedLibraries)
66LOCAL_STATIC_LIBRARIES := libtrunks_generated
67LOCAL_SRC_FILES := \
68  background_command_transceiver.cc \
69  blob_parser.cc \
70  error_codes.cc \
71  hmac_authorization_delegate.cc \
72  hmac_session_impl.cc \
73  password_authorization_delegate.cc \
74  policy_session_impl.cc \
75  scoped_key_handle.cc \
76  session_manager_impl.cc \
77  tpm_generated.cc \
78  tpm_state_impl.cc \
79  tpm_utility_impl.cc \
80  trunks_factory_impl.cc
81include $(BUILD_STATIC_LIBRARY)
82
83# trunksd
84# ========================================================
85include $(CLEAR_VARS)
86LOCAL_MODULE := trunksd
87LOCAL_CPP_EXTENSION := $(trunksCppExtension)
88LOCAL_CFLAGS := $(trunksCFlags)
89ifeq ($(BRILLOEMULATOR),true)
90LOCAL_CFLAGS += -DUSE_SIMULATOR
91endif
92LOCAL_CLANG := true
93ifeq ($(BRILLOEMULATOR),true)
94LOCAL_INIT_RC := trunksd-simulator.rc
95else
96LOCAL_INIT_RC := trunksd.rc
97endif
98LOCAL_C_INCLUDES := $(trunksIncludes)
99LOCAL_SHARED_LIBRARIES := \
100  $(trunksSharedLibraries) \
101  libbrillo-minijail \
102  libminijail
103ifeq ($(BRILLOEMULATOR),true)
104LOCAL_SHARED_LIBRARIES += libtpm2
105endif
106LOCAL_STATIC_LIBRARIES := \
107  libtrunks_generated \
108  libtrunks_common
109LOCAL_REQUIRED_MODULES := \
110  trunksd-seccomp.policy
111LOCAL_SRC_FILES := \
112  resource_manager.cc \
113  tpm_handle.cc \
114  tpm_simulator_handle.cc \
115  trunks_binder_service.cc \
116  trunksd.cc
117include $(BUILD_EXECUTABLE)
118
119# trunksd-seccomp.policy
120# ========================================================
121include $(CLEAR_VARS)
122LOCAL_MODULE := trunksd-seccomp.policy
123LOCAL_MODULE_CLASS := ETC
124LOCAL_MODULE_PATH := $(TARGET_OUT)/usr/share/policy/
125LOCAL_SRC_FILES := trunksd-seccomp-$(TARGET_ARCH).policy
126include $(BUILD_PREBUILT)
127
128# libtrunks
129# ========================================================
130include $(CLEAR_VARS)
131LOCAL_MODULE := libtrunks
132LOCAL_CPP_EXTENSION := $(trunksCppExtension)
133LOCAL_CFLAGS := $(trunksCFlags)
134LOCAL_CLANG := true
135LOCAL_C_INCLUDES := $(trunksIncludes)
136LOCAL_SHARED_LIBRARIES := $(trunksSharedLibraries)
137LOCAL_WHOLE_STATIC_LIBRARIES := \
138  libtrunks_common \
139  libtrunks_generated
140LOCAL_SRC_FILES := \
141  trunks_binder_proxy.cc
142LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)/..
143include $(BUILD_SHARED_LIBRARY)
144
145# trunks_client
146# ========================================================
147include $(CLEAR_VARS)
148LOCAL_MODULE := trunks_client
149LOCAL_CPP_EXTENSION := $(trunksCppExtension)
150LOCAL_CFLAGS := $(trunksCFlags)
151LOCAL_CLANG := true
152LOCAL_C_INCLUDES := $(trunksIncludes)
153LOCAL_SHARED_LIBRARIES := $(trunksSharedLibraries) libtrunks
154LOCAL_SRC_FILES := \
155  trunks_client.cc \
156  trunks_client_test.cc
157include $(BUILD_EXECUTABLE)
158
159# libtrunks_test
160# ========================================================
161include $(CLEAR_VARS)
162LOCAL_MODULE := libtrunks_test
163LOCAL_MODULE_TAGS := eng
164LOCAL_CPP_EXTENSION := $(trunksCppExtension)
165LOCAL_CFLAGS := $(trunksCFlags)
166LOCAL_CLANG := true
167LOCAL_C_INCLUDES := $(trunksIncludes)
168LOCAL_SHARED_LIBRARIES := $(trunksSharedLibraries)
169LOCAL_SRC_FILES := \
170  mock_authorization_delegate.cc \
171  mock_blob_parser.cc \
172  mock_command_transceiver.cc \
173  mock_hmac_session.cc \
174  mock_policy_session.cc \
175  mock_session_manager.cc \
176  mock_tpm.cc \
177  mock_tpm_state.cc \
178  mock_tpm_utility.cc \
179  trunks_factory_for_test.cc
180LOCAL_STATIC_LIBRARIES := \
181  libgmock
182include $(BUILD_STATIC_LIBRARY)
183
184# Target unit tests
185# ========================================================
186include $(CLEAR_VARS)
187LOCAL_MODULE := trunks_test
188LOCAL_MODULE_TAGS := eng
189LOCAL_CPP_EXTENSION := $(trunksCppExtension)
190LOCAL_CFLAGS := $(trunksCFlags)
191LOCAL_CLANG := true
192LOCAL_C_INCLUDES := $(trunksIncludes)
193LOCAL_SHARED_LIBRARIES := $(trunksSharedLibraries)
194LOCAL_SRC_FILES := \
195  background_command_transceiver_test.cc \
196  hmac_authorization_delegate_test.cc \
197  hmac_session_test.cc \
198  password_authorization_delegate_test.cc \
199  policy_session_test.cc \
200  resource_manager.cc \
201  resource_manager_test.cc \
202  scoped_key_handle_test.cc \
203  session_manager_test.cc \
204  tpm_generated_test.cc \
205  tpm_state_test.cc \
206  tpm_utility_test.cc
207LOCAL_STATIC_LIBRARIES := \
208  libBionicGtestMain \
209  libgmock \
210  libtrunks_common \
211  libtrunks_generated \
212  libtrunks_test
213include $(BUILD_NATIVE_TEST)
214