ioctlsort can run on the host.

Upstream has changed how all this stuff works in support of being able
to say:

  ioctl(1, TCGETS, {B38400 opost isig icanon echo ...}) = 0

instead of the usual:

  ioctl(1, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon echo ...}) = 0

The problem for us is that they now do their ioctlsort stuff at build
time, rather than have the maintainer do it once. In case we have to
follow suit, this at least removes the need to run code on the target!

Change-Id: I94a9a07c8969d9b228846faa491fdef02e545206
diff --git a/Android.mk b/Android.mk
index 6943d38..efefcc3 100644
--- a/Android.mk
+++ b/Android.mk
@@ -275,27 +275,28 @@
 	# Build the generated .h files needed by ioctlsort from the current bionic uapi headers.
 	cd external/strace; ./linux/ioctlent.sh ../../bionic/libc/kernel/uapi/
 	# Build the ioctlsort tool.
-	ONE_SHOT_MAKEFILE=external/strace/Android.mk make -f build/core/main.mk $(TARGET_OUT_EXECUTABLES)/ioctlsort
+	ONE_SHOT_MAKEFILE=external/strace/Android.mk make -f build/core/main.mk $(HOST_OUT_EXECUTABLES)/ioctlsort
 	# Remove the generated .h files now we've built ioctlsort.
 	rm external/strace/ioctls.h external/strace/ioctldefs.h
-	# Run the ioctlsort tool on the target to generate the one file we do want to check in.
-	adb sync
-	adb shell ioctlsort | tr -d '\r' | sed 's/^\([[:space:]]*{\)"[^"]\+",[[:space:]]*/\1/' | sort -u -k2,2 -k1,1 > external/strace/linux/ioctlent.h
+	# Run the ioctlsort tool to generate the one file we do want to check in.
+	ioctlsort | tr -d '\r' | sed 's/^\([[:space:]]*{\)"[^"]\+",[[:space:]]*/\1/' | sort -u -k2,2 -k1,1 > external/strace/linux/ioctlent.h
 	# Rebuild strace with the new "ioctlent.h".
-	ONE_SHOT_MAKEFILE=external/strace/Android.mk make -f build/core/main.mk
+	ONE_SHOT_MAKEFILE=external/strace/Android.mk make -f build/core/main.mk $(TARGET_OUT_OPTIONAL_EXECUTABLES)/strace
 
 # We don't build ioctlsort unless really necessary, because we don't check
 # in the temporary files needed to build it. This tool is only necessary
 # when updating strace's list of ioctls.
-ifneq (,$(filter $(TARGET_OUT_EXECUTABLES)/ioctlsort,$(MAKECMDGOALS)))
+ifneq (,$(filter $(HOST_OUT_EXECUTABLES)/ioctlsort,$(MAKECMDGOALS)))
 include $(CLEAR_VARS)
 LOCAL_SRC_FILES := ioctlsort.c
-LOCAL_CFLAGS += -include asm/types.h -include linux/ashmem.h
+# As long as ashmem isn't in glibc, we need the bionic header.
+# Unfortunately, it uses __u32 without pulling in a definition, so we need asm/types.h too.
+LOCAL_CFLAGS += -include asm/types.h -include bionic/libc/kernel/uapi/linux/ashmem.h
 LOCAL_CFLAGS += -Wno-unused-parameter
 LOCAL_MODULE := ioctlsort
 LOCAL_MODULE_TAGS := optional
 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
-include $(BUILD_EXECUTABLE)
+include $(BUILD_HOST_EXECUTABLE)
 endif
 
 # -------------------------------------------------------------------------