prebuilt: allow user to move binaries to /vendor/bin/hw in ramdisk

Change-Id: Id6c17f2efcb1490d473311f3aa61ba3d652c6607
diff --git a/prebuilt/Android.mk b/prebuilt/Android.mk
index ec39880..d611f4a 100755
--- a/prebuilt/Android.mk
+++ b/prebuilt/Android.mk
@@ -282,6 +282,9 @@
 ifneq ($(TW_RECOVERY_ADDITIONAL_RELINK_LIBRARY_FILES),)
     RECOVERY_LIBRARY_SOURCE_FILES += $(TW_RECOVERY_ADDITIONAL_RELINK_LIBRARY_FILES)
 endif
+ifneq ($(TW_RECOVERY_ADDITIONAL_RELINK_VENDOR_HW_BINARY_FILES),)
+    RECOVERY_VENDOR_HW_BINARY_FILES += $(TW_RECOVERY_ADDITIONAL_RELINK_VENDOR_HW_BINARY_FILES)
+endif
 ifneq ($(wildcard external/pcre/Android.mk),)
     RECOVERY_LIBRARY_SOURCE_FILES += $(TARGET_OUT_SHARED_LIBRARIES)/libpcre.so
 endif
@@ -391,6 +394,17 @@
 LOCAL_REQUIRED_MODULES += $(TARGET_BINARY_RELINK_FILES)
 include $(BUILD_PHONY_PACKAGE)
 
+include $(CLEAR_VARS)
+LOCAL_MODULE := relink_vendor_hw_binaries
+LOCAL_MODULE_TAGS := optional
+LOCAL_MODULE_CLASS := EXECUTABLES
+LOCAL_MODULE_PATH := $(TARGET_RECOVERY_ROOT_OUT)/
+LOCAL_POST_INSTALL_CMD += $(RELINK) $(TARGET_RECOVERY_ROOT_OUT)/vendor/bin/hw $(RECOVERY_VENDOR_HW_BINARY_FILES)
+TARGET_VENDOR_BINARY_RELINK_FILES := $(notdir $(RECOVERY_VENDOR_HW_BINARY_FILES))
+LOCAL_REQUIRED_MODULES += $(TARGET_VENDOR_BINARY_RELINK_FILES)
+$(warning vendor_hw: $(LOCAL_POST_INSTALL_CMD))
+include $(BUILD_PHONY_PACKAGE)
+
 #build out TWRP ramdisk
 include $(CLEAR_VARS)
 LOCAL_MODULE := twrp_ramdisk
diff --git a/prebuilt/relink.sh b/prebuilt/relink.sh
index 063f445..5917114 100755
--- a/prebuilt/relink.sh
+++ b/prebuilt/relink.sh
@@ -12,6 +12,7 @@
       src=$2.tmp
     fi
 
+    mkdir -p $1
     cp $src $dst
     if [[ -e $2.tmp ]]; then rm -f $2.tmp; fi
 }