Add support for LOCAL_MODULE_SYMLINKS

Specifying LOCAL_MODULE_SYMLINKS will create symlinks to the installed
module in the same directory.

Change-Id: Idecb2b75f0c9999eb000eed9a79a989244ccf6c2
diff --git a/core/definitions.mk b/core/definitions.mk
index 11caedf..a1df134 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -2605,6 +2605,24 @@
   $(hide) mkdir -p $(dir $(3)/$(s)); cp -Rf $(t) $(3)/$(s)$(newline))
 endef
 
+# Define a rule to create a symlink to a file.
+# $(1): full path to source
+# $(2): source (may be relative)
+# $(3): full path to destination
+define symlink-file
+$(eval $(_symlink-file))
+endef
+
+# Order-only dependency because make/ninja will follow the link when checking
+# the timestamp, so the file must exist
+define _symlink-file
+$(3): | $(1)
+	@echo "Symlink: $$@ -> $(2)"
+	@mkdir -p $(dir $$@)
+	@rm -rf $$@
+	$(hide) ln -sf $(2) $$@
+endef
+
 ###########################################################
 ## Commands to call Proguard
 ###########################################################