Allow a device to generically define its own headers

We have a few cases of devices including specific versions of projects
just because of modified headers (msm_mdp.h comes to mind), and I just
had enough of ifdeffing header files for specific cases (the P990 needs
a lot of these).
Now... if a target defines a TARGET_SPECIFIC_HEADER_PATH, any headers in
there will take precedence over the standard ones; for example, on the
p990, I have

TARGET_SPECIFIC_HEADER_PATH := device/lge/p990/include

which makes, for example, the
device/lge/p990/include/hardware_legacy/AudioHardwareInterface.h be
used instead of
hardware/libhardware_legacy/include/hardware_legacy/AudioHardwareInterface.h
whenever a source file uses <hardware_legacy/AudioHardwareInterface.h>

Change-Id: I41b62668b60e3f62a6ebd3738d8d2675103a81e6a

build: fix target header overlay

LOCAL_C_INCLUDES as defined by the makefile should be put AFTER
the overlay includes so the overlay always takes precedence.

Change-Id: I489b2aab6dbacd9122d834f85e07b63ed1271f07
build: Inline kernel building as a buildtime task

Kernel image integration is now done in the build system. The
"one true way" of doing this is to download the kernel source
into kernel/TARGET_BOOTLOADER_NAME (by usage of the cm.dependencies
mechanism or otherwise), and defining the TARGET_KERNEL_CONFIG
variable in the device's BoardConfig makefile

If the kernel's location doesn't match the automagic location
(multi-device kernel source, for instance), TARGET_KERNEL_SOURCE
can be used to specify a kernel path (i.e.,
"TARGET_KERNEL_SOURCE := kernel/shared-whatever")

If the device requires out-of-kernel-tree modules to be built,
the TARGET_KERNEL_MODULES variable can be used, pointing to a
_make target_ that will build and install such modules. Definition
of such a target is the device author's responsibility, the only
restriction is that it is a normal makefile recipe (example
below)

Optionally (or as an alternative), a prebuilt binary can also be
defined at BoardConfig, by usage of the TARGET_PREBUILT_KERNEL
variable. This binary will be used if the kernel source is absent
(or undefined).

A minimal BoardConfig.mk should look something like this:

TARGET_KERNEL_CONFIG := cyanogenmod_<device>_defconfig
TARGET_PREBUILT_KERNEL := device/<vendor>/<device>/kernel

To include, for example, the TI WLAN modules, this can be used:

-----------------------------
TIWLAN_MODULES:
       make -C hardware/ti/wlan/wl1283/platforms/os/linux/ KERNEL_DIR=$(KERNEL_OUT) ARCH="arm" CROSS_COMPILE="arm-eabi-" TNETW=1273 RANDOM_MAC=n REPORT_LOG=n
       mv hardware/ti/wlan/wl1283/platforms/os/linux/tiwlan_drv.ko $(KERNEL_MODULES_OUT)
       make -C hardware/ti/wlan/wl1283_softAP/platforms/os/linux/ KERNEL_DIR=$(KERNEL_OUT) ARCH="arm" CROSS_COMPILE="arm-eabi-" TNETW=1273 REPORT_LOG=n
       mv hardware/ti/wlan/wl1283_softAP/platforms/os/linux/tiap_drv.ko $(KERNEL_MODULES_OUT)

TARGET_KERNEL_MODULES := TIWLAN_MODULES
---------------------------

Change-Id: I8634fa4c788a42dc6f62e62ca170825b66db126a

build: Fix kernel module building on Darwin/OSX

Darwin/OSX build host does not have module-init-tools which is
required to generated modules.dep file. Switch to modules.order
file marker which is always generated instead.

Change-Id: I20c0fccd905fa668202c3e7284a8778db3728a65

kernel: Change path to kernel/<vendor>/<device>

Derive the kernel path from the device's own path (just replace "device"
with "kernel")

Change-Id: Idd44a0489e1ce280adf5ec4d9cfe2385c75dd115

kernel: Improve support for non-arm architectures

Remove hardwired references to the ARM arch and toolchains, and replace
them with the respective android build variables

Change-Id: Iae3eb548ca1d58ac808b5fa430d415283a809106

kernel: Fix ARM building

The default android ARM compiler, arm-androideabi-, does NOT work
for the Linux kernel. Special-case the ARM architecture to target
the ARM_EABI_TOOLCHAIN path directly

Change-Id: Ib672c99f114cb89d5fda3343d4dc68810d042d35

kernel: allow TARGET_KERNEL_MODULES to overwrite kernel modules

This is necessary to use compat-wireless since it needs to build a newer
version of cfg80211 (and sometimes mac80211) than the kernel sources version.
There are probably other instances of this type of need.

Change-Id: Ib5bf818286bc20987d8b9f9480a43f3e7690e239

kernel.mk: make use of ccache when requested

Change-Id: I9b6e28711bd5f590a76ac2b62a50b1d2de014e3e

kernel: Fix ccache inclusion logic

Builds were broken when CCACHE was missing from the environment
Change-Id: Ie8d6048f4600f1dc9c298593a50e37af04b96438

build: show accurate information on inline kernel warnings/errors

Having the variables on AndroidBoard as suggested causes errors
with mm/mmm, whereas having them on BoardConfig doesn't. Adjust
the warnings to reflect this.

Change-Id: I554c1f1073df678d36521f73bc236a1f4b02212e

This is causing generic_armv5-userdebug builds to fail. Commenting out for now to fix recovery build servers. Will fix properly later.

Change-Id: Ibe1cda8cd2b4c1914dfa3b8a29724c9069e047a6

kernel.mk: Also search PRODUCT_COPY_FILES for the kernel copy, as that is how AOSP does it now.

Change-Id: Id2d1cf079694d1996d4a85d8435c2e4562e5d444

kernel.mk: fix compiled kernel copy

Change-Id: Ifb2a3d4968e56eed236eaa2db9258cd0b8865fda

kernel.mk: workaround to fix kernel builds on darwin until the prebuilts/gcc is checked in by upstream.

Change-Id: I6321fb7f6814b207c821d974766d945351b3f546

build: fix ccache usage when building kernels

Change-Id: Id4edd4d85d9ba3ef42575f5fdebf22ed14957a99

kernel.mk: set KERNEL_OUT properly

It was hardcoded to $(ANDROID_BUILD_TOP)/$(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ
which wouldn't exist if OUT_DIR_COMMON_BASE was set to use another dir
(e.g. ramdisk)

Fix it so that it now points to $(TARGET_OUT_INTERMEDIATES)/KERNEL_OBJ
if OUT_DIR is not out

Change-Id: I1bf767d86548e41270d9cbb8f0c00512708501c5

build: add support for uncompressed kernels

build: kernel: remove hard coded darwin toolchain.

* Use latest kernel toolchain from $(ARM_EABI_TOOLCHAIN) variable.

Change-Id: I3b43408937dd5f193fcba19c034f868272de8963

envsetup: set OUT_DIR to an absolute path always

OUT_DIR was set to $(TOPDIR)out previously,
but $(TOPDIR) was null, so it was a relative path.
This broke releasetools, inline kernel building, etc
since they require absolute paths.
Fix it so that it is set to $(shell readlink -f .)/out
if $(TOPDIR) is null.

Also remove hacks which checked if (OUT_DIR) was out
and changed it to $(ANDROID_BUILD_TOP)/out to workaround
the aforementioned problem.

Change-Id: I459a3b1325a1bbea0565cd73f6acf160d4ed9b39

build: add strip on kernel modules

kernel modules are huge for prima wlan and we need to strip them
unstriped size 40mb
striped size 2mb

Change-Id: Iefd572732cad0a6f608439618673068a3586fcd5

kernel: Ignore errors with module building

Let kernel fully disable loadable modules

Change-Id: Ia37ec927b092c041ee4c68bf9fd0f28b7339c8ca

build: Add support for extra kernel build variables

 * This allows specifying a variant defconfig, and an selinux defconfig
   which are simply configuration fragments.

Change-Id: I97882ae3b8c2e16ff6a7dce8dd3a70d70f8aa866

s/cyanogenmod.com/cyanogenmod.org/

* And fixup a wiki link while I'm at it.

Change-Id: I0355b9a47eac1becc07e81659fbb2d11b14ece36

Fixes for Xcode 5 and OSX 10.9.
kernel.mk: Put elf.h into the include path on Darwin builds.

Change-Id: I7069b956965d27caac3b2e4c3cc2e8b4c1da7a82

Make the kernel image format parametric instead of a chain of if/elses

Change-Id: I54bfcdecb8647f7bcf744e72b2de19fcf4e4e7ac

build: Add "dtbs" target when building the kernel

 * This is needed for 3.10

Change-Id: I4044ea9e67017452efc25097a3327141a6627c24
ota: Remove cruft we don't care about

Skip the date check (downgrade to your content), and don't include
recovery in otapackages.
5.0.0 update: We want the recovery patchstuff back
fix up ota_from_target_files symlink detection.
envsetup: cmremote,cmgerrit,cmrebase,mka,reposync

    Add the cm specific functions (cmremote, cmgerrit, cmrebase,
    mka, reposync) that are present in the gingerbread branch

Change-Id: If28a5a206b8bb9ead5242c60f6c1e6af27141b57
make bacon and custom releasetool (for squished zips)

Change-Id: I4f61b6a6b9b8bab8582fa5423c4134c07af17606
add support for overriding build.prop settings.

Change-Id: Ie4224d608b7bcb0c2087bd77bc954f8f5f9b6495
add support for custom releasetools
build: Preliminary support for AOKP product builds

If building a aokp_* product, skip crawling the filesystem for
AndroidProduct makefiles (and, of course, parsing their contents)
and aim directly for the device/<product>/aokp.mk device configuration

Change how we search for AOKP makefiles.

build: Fix fastpath code for AOKP_BUILD

 * We need to adjust to the new validations

build: Fix aokp builds

the setup variable wasn't exported, and was being missed by part
of the scripts

Change-Id: Ie41c87e7412e75285505cb3115047f9a74025717
Signed-off-by: Arnav Gupta <championswimmer@aokp.co>
Add otapackage support for backuptool

Change-Id: I512554c579d444067cd3ccbb0e6946a5eb6bc964a
Squashed commit of breakfast/brunch commands

Add a CM-specific breakfast menu

We usually don't wan't all the devices in the lunch menu, so
we can now choose to pick up breakfast or brunch and get a
smaller selection of devices (i.e., those we support)

Make brunch more nutritious

* "breakfast device-name" will set up the environment, just like lunch.
* "brunch device-name" will actually do the whole setup and build :)

brunch: add a lazier mode

Since all of CM's targets have a predictable PRODUCT_NAME and BUILD_VARIANT
(i.e., "cyanogen_$(PRODUCT_DEVICE)-eng"), brunch can now be invoked passing
just the PRODUCT_DEVICE ("brunch passion" for the N1 setup+build, for
example).
The "classic" long form of $(PRODUCT_NAME)-$(BUILD_VARIANT) can still be used
if desired ("brunch cyanogen_passion-eng" still works).

breakfast in bed

breakfast in bed (aliased to "bib") is the baconless friend of lazy
brunch.
You can now use "breakfast passion", or "bib passion", to setup the
corresponding CM build without actually building it

Fix breakfast for the undecided

The menu presentation (i.e., giving no arguments to breakfast
or brunch) was broken, so if you didn't know the name of your
target you weren't given a list to choose from, just an error.

Change-Id: I85b8217daa2d511c16a1e82c700e1b0fadbb36ac
CyanogenNom: Now moar helpful!
Allow override of device asserts, including multi-device support.

Set in board file with TARGET_OTA_ASSERT_DEVICE.
(cherry-picked from commit 0f452f21fc9323b9d1fe746161761cf40aaa5030)

Change-Id: I3d06bdc0e3e26bde0c0e646accd050364f9713b9
build: Run squisher for the bacon target

Change-Id: If33402a5eb1661345c7d37ec1778742096449c70

TARGET_CUSTOM_RELEASETOOL is a squisher replacement

Change-Id: I9c7126d6bbe0303c1d35bb54ec2f0c9187b131e0

Fix tabs, sorry bad commit --amend :p

Change-Id: Ia981edb520d7b5f91e0717f6b4d8180386c8a20d
build in colors: Install outputs in blue/yellow [basic ics version]

"target prefix:" in yellow
"Install: file" in cyan

should be in a single command line else there are sync problems
in multithread (-j X)

These colors can be tuned in core/Makefile if you use a white terminal.
can be disabled with "export BUILD_WITH_COLORS=0"

Only the most important output is colored to reduce ics merge problems

Change-Id: I0e585079fde6900799ef209367a523d94a51cda5

Colors: add more colors to final build steps

also fix releasetool echo and visible recovery echos

Change-Id: Icf5d88468572f935610c544bf1d5d356ec9870d3

build in colors: host C/C++

Change-Id: Ic415cab53a2efa104c9d4b31ddbe8c8eb74e493d
build-with-colors: moar colors

- rename CL_PFX and CL_INS to better match the
  colors they show.
- add more colors.

Output of:
- most host stuff is yellow
- most target stuff is green
- installing/copying files is cyan
- import/export includes and notice files is cyan
- bootimage/recoveryimage is cyan
- and some more colors in many places ;)

Change-Id: I5532afa4ba608e0a7c408516dc9f912f9ca389f7
Disable dataroaming by default

The property is removed so that the property in vendor/cm can
take effect

Change-Id: Iefadc1a6e71cbf92ecb7363c953f4b5a82064446
eat: Automated install of fresh builds

Needs:
1 - a build
2 - a connected device

Change-Id: I24820b984e79430b7af7ccedc171fc69269c0a32

envsetup: eat safely

Change-Id: I2d8b52206213d8f4d8dcce3518cadb2be59e78d8

eat more safely, if there is something to eat

Check for zip file presence before trying to eat

Change-Id: I7913be619d189bbd723263edad878d6d05b8a5a7

Fixed eat not waiting for device if adb server was not started

$(adb get-state) returned unexpected starting server message
causing the if statement to fail. Calling "adb start-server"
beforehand remedies that.

Patch Set 2:
$(adb get-state) returns 'unknown' if Clockwork recovery is running on the device
look for /sbin/recovery and 'pass' the state test
also
adb wait-for-device
will result in endless loop, replace with until loop using with get-state OR 'recovery' tests

Patch Set 3:
fix the initial adb state test, use AND instead of OR

Patch Set 4:
Rebased and prevent "device not found" message from spamming the screen by
redirecting error output to null

Change-Id: I2d41b8853567cde80bf7fc08b5e4f0ad5ba1fdf5
Signed-off-by: Firerat <firer4t@googlemail.com>

Updated for CM9 variables

eat: Adapt to new file naming scheme

Change-Id: I101e333918bc215bebcc594c97bdd68307c90aaa

eat: Adapt to new storage paths

Change-Id: Ic060304275c2d19858636c84740b3f60dfdc6193

envsetup: Make eat restart adbd as root before pushing the recovery command

Without adbd running as root we can't write to /cache/recovery and
eat fails with a permission denied.

Change-Id: I015b50f29c001605cdc1a0088f68296b62809b56

Eat: Option to specify directory of zip in recovery mode

It pushes to /mnt/sdcard0, which may be /emmc/ in recovery. Now the user
can specify another path other than /sdcard/ where the zip is

Change-Id: Ie39615132ae39d9f6b304a3049b2395b2a2af182

fix "eat"

Assume user 0 is the active one when flashing...

Change-Id: Ibdc28ef49f8023e786ee82c9e42c221409dfd6bb

eat: Use /cache if possible

 * Check the size of /cache and use it if possible.

Change-Id: I72fecf3f8d2311c04e63fe81a7ca9a8a6a40419d
Modular backuptool.sh.  Executes backup and restore methods defined in arbitrary /system/addon.d/*.sh scripts.

* Copy backuptool.functions alongside backuptool.sh.
* Delete both from /system/bin as they are not useful there.

Patch Series
============
http://review.cyanogenmod.com/#change,13265
CyanogenMod/android_build
  * edify generator
http://review.cyanogenmod.com/#change,13266
CyanogenMod/android_system_core
  * permissions on /system/addon.d
http://review.cyanogenmod.com/#change,13267
CyanogenMod/android_vendor_cm
  * 50-cm.sh reference backup script
  * modular backuptool.sh
  * support backuptool.functions used by /system/addon.d/*.sh scripts

Change-Id: I26b4907d28f49c69627699d2accd2f0fa2d1b112
build: Stop installing the sample APN list

 * Sample APN list is always being installed, we don't want this in CM.

Change-Id: I74b97f3af545c4a7568d3001e1435c63cfbc7de8
env: implement the repodiff command

 sample usage:
   repodiff ics
   repodiff github/ics --numstat
   repodiff android-4.0.4_r1.2 android-4.0.4_r2

Change-Id: Id1c1e504c75676707e59f051fd5ff9ce748d4297
Signed-off-by: Tanguy Pruvot <tanguy.pruvot@gmail.com>