1# Copyright 2009 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
17tune2fs_static_libraries := \
18    libext2_com_err \
19    libext2_blkid \
20    libext2_quota \
21    libext2_uuid \
22    libext2_e2p \
23    libext2fs
24
25updater_common_static_libraries := \
26    libapplypatch \
27    libbootloader_message \
28    libbspatch \
29    libedify \
30    libotautil \
31    libext4_utils \
32    libdm \
33    libfec \
34    libfec_rs \
35    libavb \
36    libverity_tree \
37    libgtest_prod \
38    liblog \
39    liblp \
40    libselinux \
41    libsparse \
42    libsquashfs_utils \
43    libbrotli \
44    libbz \
45    libziparchive \
46    libz \
47    libbase \
48    libcrypto_static \
49    libcrypto_utils \
50    libcutils \
51    libutils
52
53
54# Each library in TARGET_RECOVERY_UPDATER_LIBS should have a function
55# named "Register_<libname>()".  Here we emit a little C function that
56# gets #included by updater.cpp.  It calls all those registration
57# functions.
58# $(1): the path to the register.inc file
59# $(2): a list of TARGET_RECOVERY_UPDATER_LIBS
60define generate-register-inc
61    $(hide) mkdir -p $(dir $(1))
62    $(hide) echo "" > $(1)
63    $(hide) $(foreach lib,$(2),echo "extern void Register_$(lib)(void);" >> $(1);)
64    $(hide) echo "void RegisterDeviceExtensions() {" >> $(1)
65    $(hide) $(foreach lib,$(2),echo "  Register_$(lib)();" >> $(1);)
66    $(hide) echo "}" >> $(1)
67endef
68
69
70# updater (static executable)
71# ===============================
72include $(CLEAR_VARS)
73
74LOCAL_MODULE := updater
75
76LOCAL_SRC_FILES := \
77    updater_main.cpp
78
79LOCAL_C_INCLUDES := \
80    $(LOCAL_PATH)/include
81
82LOCAL_CFLAGS := \
83    -Wall \
84    -Werror
85
86LOCAL_STATIC_LIBRARIES := \
87    libupdater_device \
88    libupdater_core \
89    $(TARGET_RECOVERY_UPDATER_LIBS) \
90    $(TARGET_RECOVERY_UPDATER_EXTRA_LIBS) \
91    $(updater_common_static_libraries) \
92    libfs_mgr \
93    libtune2fs \
94    $(tune2fs_static_libraries)
95
96LOCAL_MODULE_CLASS := EXECUTABLES
97inc := $(call local-generated-sources-dir)/register.inc
98
99# Devices can also add libraries to TARGET_RECOVERY_UPDATER_EXTRA_LIBS.
100# These libs are also linked in with updater, but we don't try to call
101# any sort of registration function for these.  Use this variable for
102# any subsidiary static libraries required for your registered
103# extension libs.
104$(inc) : libs := $(TARGET_RECOVERY_UPDATER_LIBS)
105$(inc) :
106	$(call generate-register-inc,$@,$(libs))
107
108LOCAL_GENERATED_SOURCES := $(inc)
109
110inc :=
111
112LOCAL_FORCE_STATIC_EXECUTABLE := true
113
114include $(BUILD_EXECUTABLE)
115