Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 1 | # Copyright 2009 The Android Open Source Project |
| 2 | |
| 3 | LOCAL_PATH := $(call my-dir) |
| 4 | |
| 5 | updater_src_files := \ |
| 6 | install.c \ |
| 7 | updater.c |
| 8 | |
| 9 | # |
Doug Zongker | ad3db09 | 2009-06-26 13:38:55 -0700 | [diff] [blame] | 10 | # Build a statically-linked binary to include in OTA packages |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 11 | # |
| 12 | include $(CLEAR_VARS) |
| 13 | |
Doug Zongker | ad3db09 | 2009-06-26 13:38:55 -0700 | [diff] [blame] | 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.) |
| 17 | LOCAL_MODULE_TAGS := eng |
| 18 | |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 19 | LOCAL_SRC_FILES := $(updater_src_files) |
| 20 | |
Koushik Dutta | b5a36a0 | 2010-09-13 14:33:15 -0700 | [diff] [blame^] | 21 | ifdef BOARD_USES_BMLUTILS |
| 22 | LOCAL_CFLAGS += -DBOARD_USES_BMLUTILS |
| 23 | LOCAL_STATIC_LIBRARIES += libbmlutils |
| 24 | endif |
| 25 | |
Koushik Dutta | e5678e9 | 2010-09-13 13:25:11 -0700 | [diff] [blame] | 26 | LOCAL_STATIC_LIBRARIES += $(TARGET_RECOVERY_UPDATER_LIBS) $(TARGET_RECOVERY_UPDATER_EXTRA_LIBS) |
Doug Zongker | 2b0fdc6 | 2009-06-19 11:22:06 -0700 | [diff] [blame] | 27 | LOCAL_STATIC_LIBRARIES += libapplypatch libedify libmtdutils libminzip libz |
Doug Zongker | 8edb00c | 2009-06-11 17:21:44 -0700 | [diff] [blame] | 28 | LOCAL_STATIC_LIBRARIES += libmincrypt libbz |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 29 | LOCAL_STATIC_LIBRARIES += libcutils libstdc++ libc |
| 30 | LOCAL_C_INCLUDES += $(LOCAL_PATH)/.. |
| 31 | |
Doug Zongker | 2b0fdc6 | 2009-06-19 11:22:06 -0700 | [diff] [blame] | 32 | # Each library in TARGET_RECOVERY_UPDATER_LIBS should have a function |
| 33 | # named "Register_<libname>()". Here we emit a little C function that |
| 34 | # gets #included by updater.c. It calls all those registration |
| 35 | # functions. |
| 36 | |
| 37 | # Devices can also add libraries to TARGET_RECOVERY_UPDATER_EXTRA_LIBS. |
| 38 | # These libs are also linked in with updater, but we don't try to call |
| 39 | # any sort of registration function for these. Use this variable for |
| 40 | # any subsidiary static libraries required for your registered |
| 41 | # extension libs. |
| 42 | |
| 43 | inc := $(call intermediates-dir-for,PACKAGING,updater_extensions)/register.inc |
| 44 | |
| 45 | # During the first pass of reading the makefiles, we dump the list of |
| 46 | # extension libs to a temp file, then copy that to the ".list" file if |
| 47 | # it is different than the existing .list (if any). The register.inc |
| 48 | # file then uses the .list as a prerequisite, so it is only rebuilt |
| 49 | # (and updater.o recompiled) when the list of extension libs changes. |
| 50 | |
| 51 | junk := $(shell mkdir -p $(dir $(inc));\ |
| 52 | echo $(TARGET_RECOVERY_UPDATER_LIBS) > $(inc).temp;\ |
| 53 | diff -q $(inc).temp $(inc).list || cp -f $(inc).temp $(inc).list) |
| 54 | |
| 55 | $(inc) : libs := $(TARGET_RECOVERY_UPDATER_LIBS) |
| 56 | $(inc) : $(inc).list |
| 57 | $(hide) mkdir -p $(dir $@) |
| 58 | $(hide) echo "" > $@ |
| 59 | $(hide) $(foreach lib,$(libs),echo "extern void Register_$(lib)(void);" >> $@) |
| 60 | $(hide) echo "void RegisterDeviceExtensions() {" >> $@ |
| 61 | $(hide) $(foreach lib,$(libs),echo " Register_$(lib)();" >> $@) |
| 62 | $(hide) echo "}" >> $@ |
| 63 | |
| 64 | $(call intermediates-dir-for,EXECUTABLES,updater)/updater.o : $(inc) |
| 65 | LOCAL_C_INCLUDES += $(dir $(inc)) |
| 66 | |
Doug Zongker | 9931f7f | 2009-06-10 14:11:53 -0700 | [diff] [blame] | 67 | LOCAL_MODULE := updater |
| 68 | |
| 69 | LOCAL_FORCE_STATIC_EXECUTABLE := true |
| 70 | |
| 71 | include $(BUILD_EXECUTABLE) |
Koushik Dutta | ada3f3b | 2010-05-01 21:30:55 -0700 | [diff] [blame] | 72 | |
| 73 | |
| 74 | file := $(PRODUCT_OUT)/utilities/update-binary |
| 75 | ALL_PREBUILT += $(file) |
| 76 | $(file) : $(TARGET_OUT)/bin/updater | $(ACP) |
| 77 | $(transform-prebuilt-to-target) |