Support LOCAL_MODULE_RELATIVE_PATH

Most users of LOCAL_MODULE_PATH are setting a subdirectory of the
normal install path, for example to install HALs into system/lib/hw.
This is problematic for multiarch builds, where the install location
depends on the arch.  Allow modules to specify LOCAL_MODULE_RELATIVE_PATH.
HALs will generally use:
LOCAL_MODULE_RELATIVE_PATH := hw

Dan: Fixed conflicts due to upstream variable renaming

Change-Id: I4e4ceec61d026bbe74ba604554c06104bde42e5e
(cherry picked from AOSP commit 639c336dc15c49daa27c118d10cef586ffa2633a)
Reviewed-on: http://git-master/r/360817
Reviewed-by: Dan Willemsen <dwillemsen@nvidia.com>
Tested-by: Dan Willemsen <dwillemsen@nvidia.com>
Support arch-specific LOCAL_ variables

With those variables, you can set up different values for TARGET_ARCH
and TARGET_2ND_ARCH.
Also fixed a couple of variables.

Dan: This has been stripped down significantly from the AOSP version, as
we're not supporting multi-arch on this tree, but we do want to use the
same makefiles.

Bug: 11654773
Change-Id: I4c7684a562cd5877d18f67d4f848b8df07d0103b
(cherry-picked from AOSP commit b8e01854893f7390f23e6df82744b2bd3d0572c4)
Reviewed-on: http://git-master/r/362658
Reviewed-by: Dan Willemsen <dwillemsen@nvidia.com>
Tested-by: Dan Willemsen <dwillemsen@nvidia.com>
Support arch-specific LOCAL_C_INCLUDES.

Dan: This has been stripped down from the AOSP version, as we're not
supporting multi-arch on this tree, but we do want to use the same
makefiles.

Bug: 11654773
Change-Id: I89c7ce7ff8bea15cb81f9cd9b0188b54beed3422
(cherry-picked from AOSP commit dbdafdb865e3e3d819a61542cc56e9224c8dcc04)
Reviewed-on: http://git-master/r/362659
Reviewed-by: Dan Willemsen <dwillemsen@nvidia.com>
Tested-by: Dan Willemsen <dwillemsen@nvidia.com>
add new gen/ directory for generated sources

Allow modules to generate source into $OUT/gen, which will then
be copied into $OUT/obj and $OUT/obj_$(TARGET_2ND_ARCH) as
necessary.  This allows a single build rule invocation that includes
generated source to build for the first and second architectures.

Modules will need to change calls to local-intermediates-dir into
local-generated-sources-dir.

Change-Id: I62504bad9454b3d9fde7b84ab9f0a487a2ecf0bf
(cherry picked from AOSP commit d826264621a2c3d27228b395bc36edf5510bcc49)
Reviewed-on: http://git-master/r/362660
Reviewed-by: Dan Willemsen <dwillemsen@nvidia.com>
Tested-by: Dan Willemsen <dwillemsen@nvidia.com>
build: support LOCAL_*_32 and LOCAL_*_64

Support the following new variables based on whether the current multilib
target is 32 bit or 64 bit:
LOCAL_CFLAGS_32
LOCAL_CFLAGS_64
LOCAL_LDFLAGS_32
LOCAL_LDFLAGS_64
LOCAL_ASFLAGS_32
LOCAL_ASFLAGS_64
LOCAL_C_INCLUDES_32
LOCAL_C_INCLUDES_64

Dan: This is simplified to only use the 32 bit versions, since that's
all we support on this tree. The only reason this is here is for
makefile compatibility.

Change-Id: Ia868d56dff114be301bf8297eec768675f186927
(cherry picked from commit 44a752659cbcc56ed340375ec005771bcadcaa3a)
Reviewed-on: http://git-master/r/362661
Reviewed-by: Dan Willemsen <dwillemsen@nvidia.com>
Tested-by: Dan Willemsen <dwillemsen@nvidia.com>
add support for more LOCAL_*_arch variables

Add support for:
LOCAL_SHARED_LIBRARIES_arch
LOCAL_STATIC_LIBRARIES_arch
LOCAL_WHOLE_STATIC_LIBRARIES_arch
LOCAL_GENERATED_SOURCES_arch
LOCAL_REQUIRED_MODULES_arch

Dan: We don't support the 2ND arch in this branch, so this change is
simpler and just for makefile compatiblity.

Change-Id: Iad91702e140d8dba7dcaee13f236c77b1e626a34
(cherry picked from commit 90353fe86f300af281017100b33a4cb929d3145f)
Reviewed-on: http://git-master/r/368469
Reviewed-by: Dan Willemsen <dwillemsen@nvidia.com>
Tested-by: Dan Willemsen <dwillemsen@nvidia.com>
Refine module name resolving in multilib build

Dan: This is limitted to just stripping the :32 and :64 suffixes off of
modules in PRODUCT_PACKAGES. That's needed for product makefile
compatibility.

-- Added TARGET_PREFER_32_BIT, which sets LOCAL_32_BIT_ONLY for an
   executable, if LOCAL_NO_2ND_ARCH is not true.

Name resolving in 64-bit multilib build:
-- Name resolving in PRODUCT_PACKAGES:
   foo:32 resolves to foo_32;
   foo:64 resolves to foo;
   foo resolves to both foo and foo_32 (if foo_32 is defined).

-- Name resolving for LOCAL_REQUIRED_MODULES:
   If a module is built for 2nd arch, its required module resolves to
   32-bit variant, if it exits;
   Otherwise for executable and shared library, a required module
   resolves to the default 64-bit variant; for other module classes,
   required module foo resolves to both foo and foo_32 (if foo_32 is
   defined)

Bug: 12898862
Change-Id: I5fda1a77f58814097b10b5ad2743ee25adfaecc4
(cherry picked from commit 14a6cbd9026659b30f63c31e112d6cce9b47a9d6)
Reviewed-on: http://git-master/r/368470
Reviewed-by: Dan Willemsen <dwillemsen@nvidia.com>
Tested-by: Dan Willemsen <dwillemsen@nvidia.com>
add support for module supported or unsupported target architectures

Add four new variables for module makefiles:

LOCAL_MODULE_TARGET_ARCH specifies that a module is only supported for
one or more architectures.  Any architecture not in the list will be
not attempt to build the module.  The expected use case is prebuilts
that are only suitable for a single architecture, or modules like llvm
that need per-architecture support.

LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH specifies that a module cannot be
built for one or more architectures.

LOCAL_MODULE_TARGET_ARCH_WARN and LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH_WARN
are the same, but warn that the arch is not supported, which is useful
for modules that are critical but not yet working.

The logic for whether or not to build an architecture is fairly
complicated, so this patch consolidates it into module_arch_supported.mk

Dan: Simplified for a branch that doesn't support two architectures

Change-Id: I120caf4a375f484e1fd6017b60c2f53882ae01e6
(cherry picked from commit 8e4041271dcee2aff001ac1f98527c5057415183)
Reviewed-on: http://git-master/r/368471
Reviewed-by: Dan Willemsen <dwillemsen@nvidia.com>
Tested-by: Dan Willemsen <dwillemsen@nvidia.com>
don't use LOCAL_*_arch for host builds

The LOCAL_*_$(TARGET_ARCH) variables don't make sense for host
modules, only append use them for target modules.

Also complete the list of LOCAL_*_arch and LOCAL_*_32/64 to be
consistent.

Dan: Simplified for a branch that doesn't support 64-bit

Change-Id: I00c83e5c4e08ed9a844f9f99a79ce4bcc3f0bf11
(cherry picked from commit f4f2fbe220da4f2af6f2507575e1a2554c8a32ba)
Reviewed-on: http://git-master/r/368472
Reviewed-by: Dan Willemsen <dwillemsen@nvidia.com>
Tested-by: Dan Willemsen <dwillemsen@nvidia.com>