1# Copyright 2009 The Android Open Source Project
2
3LOCAL_PATH := $(call my-dir)
4
5updater_src_files := \
6	install.c \
7	updater.c
8
9#
10# Build a statically-linked binary to include in OTA packages
11#
12include $(CLEAR_VARS)
13
14# Build only in eng, so we don't end up with a copy of this in /system
15# on user builds.  (TODO: find a better way to build device binaries
16# needed only for OTA packages.)
17LOCAL_MODULE_TAGS := eng
18
19LOCAL_SRC_FILES := $(updater_src_files)
20
21ifeq ($(TARGET_USERIMAGES_USE_EXT4), true)
22LOCAL_CFLAGS += -DUSE_EXT4
23LOCAL_C_INCLUDES += system/extras/ext4_utils
24LOCAL_STATIC_LIBRARIES += libext4_utils libz
25endif
26
27ifeq ($(HAVE_SELINUX), true)
28LOCAL_C_INCLUDES += external/libselinux/include
29LOCAL_STATIC_LIBRARIES += libselinux
30LOCAL_CFLAGS += -DHAVE_SELINUX
31endif # HAVE_SELINUX
32
33LOCAL_STATIC_LIBRARIES += $(TARGET_RECOVERY_UPDATER_LIBS) $(TARGET_RECOVERY_UPDATER_EXTRA_LIBS)
34LOCAL_STATIC_LIBRARIES += libapplypatch libedify libmtdutils libminzip libz
35LOCAL_STATIC_LIBRARIES += libmincrypt libbz
36LOCAL_STATIC_LIBRARIES += libminelf
37LOCAL_STATIC_LIBRARIES += libcutils libstdc++ libc
38LOCAL_C_INCLUDES += $(LOCAL_PATH)/..
39
40# Each library in TARGET_RECOVERY_UPDATER_LIBS should have a function
41# named "Register_<libname>()".  Here we emit a little C function that
42# gets #included by updater.c.  It calls all those registration
43# functions.
44
45# Devices can also add libraries to TARGET_RECOVERY_UPDATER_EXTRA_LIBS.
46# These libs are also linked in with updater, but we don't try to call
47# any sort of registration function for these.  Use this variable for
48# any subsidiary static libraries required for your registered
49# extension libs.
50
51inc := $(call intermediates-dir-for,PACKAGING,updater_extensions)/register.inc
52
53# During the first pass of reading the makefiles, we dump the list of
54# extension libs to a temp file, then copy that to the ".list" file if
55# it is different than the existing .list (if any).  The register.inc
56# file then uses the .list as a prerequisite, so it is only rebuilt
57# (and updater.o recompiled) when the list of extension libs changes.
58
59junk := $(shell mkdir -p $(dir $(inc));\
60	        echo $(TARGET_RECOVERY_UPDATER_LIBS) > $(inc).temp;\
61	        diff -q $(inc).temp $(inc).list 2>/dev/null || cp -f $(inc).temp $(inc).list)
62
63$(inc) : libs := $(TARGET_RECOVERY_UPDATER_LIBS)
64$(inc) : $(inc).list
65	$(hide) mkdir -p $(dir $@)
66	$(hide) echo "" > $@
67	$(hide) $(foreach lib,$(libs),echo "extern void Register_$(lib)(void);" >> $@;)
68	$(hide) echo "void RegisterDeviceExtensions() {" >> $@
69	$(hide) $(foreach lib,$(libs),echo "  Register_$(lib)();" >> $@;)
70	$(hide) echo "}" >> $@
71
72$(call intermediates-dir-for,EXECUTABLES,updater)/updater.o : $(inc)
73LOCAL_C_INCLUDES += $(dir $(inc))
74
75LOCAL_MODULE := updater
76
77LOCAL_FORCE_STATIC_EXECUTABLE := true
78
79include $(BUILD_EXECUTABLE)
80