How does module dependency work in Android?
android, makefile
Solution
Ok, I got it running by changing the Android.mk:
- name the `$(SU_BINARY)` target differently, ie `$(SU_BINARY)-post`. Better because before, it has the same name as the target defined by the `LOCAL_MODULE` and `BUILD_EXECUTABLE` combination.
- put this target before the `include $(BUILD_EXECUTABLE)`
It looks like:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := su
LOCAL_SRC_FILES := su.c db.c activity.cpp
SU_SHARED_LIBRARIES := liblog libsqlite
ifeq ($(PLATFORM_SDK_VERSION),4)
LOCAL_CFLAGS += -DSU_LEGACY_BUILD
SU_SHARED_LIBRARIES += libandroid_runtime
else
SU_SHARED_LIBRARIES += libcutils libbinder libutils
LOCAL_MODULE_TAGS := eng
endif
LOCAL_C_INCLUDES += external/sqlite/dist
LOCAL_SHARED_LIBRARIES := $(SU_SHARED_LIBRARIES)
LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES)
SU_INSTALL_DIR := $(TARGET_OUT)/xbin
SU_BINARY := $(SU_INSTALL_DIR)/su
# taken from busybox-android
$(SU_BINARY)-post: su
@echo "Setting SUID/GUID to su-binary..."
chmod ug+s $(TARGET_OUT_OPTIONAL_EXECUTABLES)/su
ln -sf $(TARGET_OUT_OPTIONAL_EXECUTABLES)/su $(TARGET_OUT_EXECUTABLES)/su
ALL_DEFAULT_INSTALLED_MODULES += $(SU_BINARY)-post
include $(BUILD_EXECUTABLE)
`ALL_DEFAULT_INSTALLED_MODULES` is a rule coming very late after module installation I think. But I got to dig into it to check if that's the best solution for what I want to do here.
Problem
I made minor changes to su-binary (https://github.com/git-core/su-binary) adding a target to set SUID. The Android.mk I use : http://pastebin.com/N0gMJT4u When running make at the root of Android source tree, things run fine: ``` $ make -j5 [...] system/core/rootdir/Android.mk:42: warning: ignoring old commands for target `out/target/product/panda/root/init.rc' echo "Setting SUID/GUID to su-binary" Setting SUID/GUID to su-binary Installing busybox chmod ug+s out/target/product/panda/system/xbin/su [...] ``` When running `mm -B` in external/su-binary: http://pastebin.com/8HmUJBA0 Same behavior for `mmm external/su-binary` According to https://groups.google.com/forum/#!msg/android-building/dtNZFj5pe1w/PRY2MXADXG4J Apart from "make name-of-module" as suggested by Ying Wang, you can run "mm" inside a directory to build (and install) all modules defined there. However, this will build only those modules, any dependent modules will not be built. Hence, it's only useful for incremental builds of existing trees where you keep track of the dependencies. Tried that: ``` $ rm out/target/product/panda/system/xbin/su $ make external/su-binary [...] make: Nothing to be done for `external/su-binary'. $ rm out/target/product/panda/obj/EXECUTABLES/su_intermediates/su $ make external/su-binary [...] make: Nothing to be done for `external/su-binary`. ``` How does module dependency work in Android?