+
+SYMLINKS := $(addprefix $(TARGET_OUT)/bin/,su)
+$(SYMLINKS):
+ @echo "Symlink: $@ -> /system/xbin/su"
+ @mkdir -p $(dir $@)
+ @rm -rf $@
+ $(hide) ln -sf ../xbin/su $@
+
+ALL_DEFAULT_INSTALLED_MODULES += $(SYMLINKS)
+
+# We need this so that the installed files could be picked up based on the
+# local module name
+ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
+ $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(SYMLINKS)
+
+ifdef SUPERUSER_EMBEDDED
+
+# make sure init.superuser.rc is imported from
+# init.rc or similar
+
+SUPERUSER_RC := $(TARGET_ROOT_OUT)/init.superuser.rc
+$(SUPERUSER_RC): $(LOCAL_PATH)/init.superuser.rc | $(ACP)
+ $(copy-file-to-new-target)
+
+SUPERUSER_MARKER := $(TARGET_OUT_ETC)/.has_su_daemon
+$(SUPERUSER_MARKER): $(LOCAL_INSTALLED_MODULE)
+ @mkdir -p $(dir $@)
+ @rm -rf $@
+ $(hide) touch $@
+
+ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \
+ $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(SUPERUSER_RC) $(SUPERUSER_MARKER)
+
+endif