libminijail_generated: Use 32 bit syscalls in compat mode

On 64 bit architectures, 32 and 64 bit versions of libraries are
compiled to support compatibility with processes running in 32 bit
compatibility mode. Currently libminijail_generated.a is being created
with the 64 bit syscalls in both the 32 and 64 bit versions of the
library. Add target for TARGET_2ND_ARCH to use 32 bit syscalls in
the 32 bit libminijail_generated.a.

Change-Id: I34e22257b61a5c50deda2348e9cedc3304da0677
diff --git a/Android.mk b/Android.mk
index 5c671f9..7ccddea 100644
--- a/Android.mk
+++ b/Android.mk
@@ -39,12 +39,25 @@
 $(generated_sources_dir)/libsyscalls.c: PRIVATE_CUSTOM_TOOL = $< "$(lastword $(CLANG)) -isystem bionic/libc/kernel/uapi/asm-$(TARGET_ARCH)" $@
 $(generated_sources_dir)/libsyscalls.c: $(LOCAL_PATH)/gen_syscalls.sh
 	$(transform-generated-source)
-LOCAL_GENERATED_SOURCES += $(generated_sources_dir)/libsyscalls.c
+LOCAL_GENERATED_SOURCES_$(TARGET_ARCH) += $(generated_sources_dir)/libsyscalls.c
 
 $(generated_sources_dir)/libconstants.c: PRIVATE_CUSTOM_TOOL = $< "$(lastword $(CLANG)) -isystem bionic/libc/kernel/uapi/asm-$(TARGET_ARCH)" $@
 $(generated_sources_dir)/libconstants.c: $(LOCAL_PATH)/gen_constants.sh
 	$(transform-generated-source)
-LOCAL_GENERATED_SOURCES += $(generated_sources_dir)/libconstants.c
+LOCAL_GENERATED_SOURCES_$(TARGET_ARCH) += $(generated_sources_dir)/libconstants.c
+
+# For processes running in 32-bit compat mode on 64-bit processors.
+ifdef TARGET_2ND_ARCH
+$(generated_sources_dir)/libsyscalls.c: PRIVATE_CUSTOM_TOOL = $< "$(lastword $(CLANG)) -isystem bionic/libc/kernel/uapi/asm-$(TARGET_2ND_ARCH)" $@
+$(generated_sources_dir)/libsyscalls.c: $(LOCAL_PATH)/gen_syscalls.sh
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES_$(TARGET_2ND_ARCH) += $(generated_sources_dir)/libsyscalls.c
+
+$(generated_sources_dir)/libconstants.c: PRIVATE_CUSTOM_TOOL = $< "$(lastword $(CLANG)) -isystem bionic/libc/kernel/uapi/asm-$(TARGET_2ND_ARCH)" $@
+$(generated_sources_dir)/libconstants.c: $(LOCAL_PATH)/gen_constants.sh
+	$(transform-generated-source)
+LOCAL_GENERATED_SOURCES_$(TARGET_2ND_ARCH) += $(generated_sources_dir)/libconstants.c
+endif
 
 LOCAL_CFLAGS := $(minijailCommonCFlags)
 LOCAL_CLANG := true