minijail: Fix build on non-Linux hosts
Modifies the compiler to refer to the target C library headers (in the
same manner used elsewhere within Android) rather than using the host's,
and uses a portable equivalent of the previous sed expression.
BUG=24112863
Change-Id: I060d869b779405d0c4e07c61790a0437f6043f0c
diff --git a/Android.mk b/Android.mk
index b20a3a4..126b168 100644
--- a/Android.mk
+++ b/Android.mk
@@ -14,8 +14,6 @@
LOCAL_PATH := $(call my-dir)
-ifeq ($(HOST_OS),linux)
-
# Common variables
# ========================================================
@@ -32,7 +30,7 @@
LOCAL_MODULE_CLASS := SHARED_LIBRARIES
intermediates := $(local-generated-sources-dir)
GEN := $(intermediates)/libsyscalls.c
-$(GEN): PRIVATE_CUSTOM_TOOL = $< $(lastword $(CLANG)) $@
+$(GEN): PRIVATE_CUSTOM_TOOL = $< "$(lastword $(CLANG)) -isystem bionic/libc/kernel/uapi/asm-$(TARGET_ARCH)" $@
$(GEN): $(LOCAL_PATH)/gen_syscalls.sh
$(transform-generated-source)
LOCAL_GENERATED_SOURCES += $(GEN)
@@ -49,5 +47,3 @@
LOCAL_SHARED_LIBRARIES := $(minijailCommonSharedLibraries)
LOCAL_EXPORT_C_INCLUDE_DIRS := $(LOCAL_PATH)
include $(BUILD_SHARED_LIBRARY)
-
-endif # HOST_OS == linux
diff --git a/gen_syscalls.sh b/gen_syscalls.sh
index a01d500..78ea89f 100755
--- a/gen_syscalls.sh
+++ b/gen_syscalls.sh
@@ -29,7 +29,8 @@
# { "read", __NR_read },
# #endif
SED_MULTILINE='s/#define __(ARM_)?(NR_)([a-z0-9_]*) (.*)$/#ifdef __\1\2\3\
-{ "\1\3", __\1\2\3 },\n#endif/g p;'
+{ "\1\3", __\1\2\3 },\
+#endif/g p;'
cat <<-EOF > "${OUTFILE}"
/* GENERATED BY MAKEFILE */
@@ -38,7 +39,7 @@
#include "libsyscalls.h"
const struct syscall_entry syscall_table[] = {
$(echo '#include <asm/unistd.h>' | \
- ${CC} -dD - -E | sed -rne "${SED_MULTILINE}")
+ ${CC} -dD - -E | sed -Ene "${SED_MULTILINE}")
{ NULL, -1 },
};
EOF