Make TWRP compile for arm64

-Remove dosfstools for arm64 until we can make it compile
-Fix TW_USE_TOOLBOX flag to work again
-Fix symlinking and handling of sh when using mksh
-Fix legacy properties to find futex_wake function
-Fix libcrecovery to not use bsd_signal anymore
-Fix rules for building with regards to libcrecovery
-Update toolbox_recovery rules to compile tools in lollipop
-Fix a few compile errors specific to arm64

Testers report that TWRP does not boot on Nexus 9 and we fail to
get a shell for adb shell. At least it compiles without errors.

Change-Id: I286be8628defb60cc527b8a548c0bdfcb0ebb574
diff --git a/bmlutils/Android.mk b/bmlutils/Android.mk
index 7c6676b..7216775 100644
--- a/bmlutils/Android.mk
+++ b/bmlutils/Android.mk
@@ -3,6 +3,7 @@
 include $(CLEAR_VARS)
 
 BOARD_RECOVERY_DEFINES := BOARD_BML_BOOT BOARD_BML_RECOVERY
+LOCAL_STATIC_LIBRARY := libcrecovery
 
 $(foreach board_define,$(BOARD_RECOVERY_DEFINES), \
   $(if $($(board_define)), \
@@ -10,9 +11,6 @@
   ) \
   )
 
-LOCAL_STATIC_LIBRARIES := libcrecovery
-LOCAL_C_INCLUDES := $(commands_recovery_local_path)/libcrecovery
-
 LOCAL_SRC_FILES := bmlutils.c
 LOCAL_MODULE := libbmlutils
 LOCAL_MODULE_TAGS := eng
@@ -22,6 +20,7 @@
 include $(CLEAR_VARS)
 
 BOARD_RECOVERY_DEFINES := BOARD_BML_BOOT BOARD_BML_RECOVERY
+LOCAL_SHARED_LIBRARIES := libcrecovery
 
 $(foreach board_define,$(BOARD_RECOVERY_DEFINES), \
   $(if $($(board_define)), \
diff --git a/bmlutils/bmlutils.c b/bmlutils/bmlutils.c
index d59475e..4c7c49d 100644
--- a/bmlutils/bmlutils.c
+++ b/bmlutils/bmlutils.c
@@ -22,50 +22,7 @@
 
 #include <bmlutils.h>
 
-#undef _PATH_BSHELL
-#define _PATH_BSHELL "/sbin/sh"
-
-int __system(const char *command)
-{
-  pid_t pid;
-	sig_t intsave, quitsave;
-	sigset_t mask, omask;
-	int pstat;
-	char *argp[] = {"sh", "-c", NULL, NULL};
-
-	if (!command)		/* just checking... */
-		return(1);
-
-	argp[2] = (char *)command;
-
-	sigemptyset(&mask);
-	sigaddset(&mask, SIGCHLD);
-	sigprocmask(SIG_BLOCK, &mask, &omask);
-	switch (pid = vfork()) {
-	case -1:			/* error */
-		sigprocmask(SIG_SETMASK, &omask, NULL);
-		return(-1);
-	case 0:				/* child */
-		sigprocmask(SIG_SETMASK, &omask, NULL);
-		execve(_PATH_BSHELL, argp, environ);
-    _exit(127);
-  }
-
-	intsave = (sig_t)  bsd_signal(SIGINT, SIG_IGN);
-	quitsave = (sig_t) bsd_signal(SIGQUIT, SIG_IGN);
-	pid = waitpid(pid, (int *)&pstat, 0);
-	sigprocmask(SIG_SETMASK, &omask, NULL);
-	(void)bsd_signal(SIGINT, intsave);
-	(void)bsd_signal(SIGQUIT, quitsave);
-	return (pid == -1 ? -1 : pstat);
-}
-
-static struct pid {
-	struct pid *next;
-	FILE *fp;
-	pid_t pid;
-} *pidlist;
-
+#include "../libcrecovery/common.h"
 
 static int restore_internal(const char* bml, const char* filename)
 {