Makefile.inc: Export CCACHE_EXTRAFILES and add __BUILD_DIR__ definition

This patch adds the CCACHE_EXTRAFILES variable to the list of exported
environment variables, which can be useful as a target-specific variable
to make ccache aware of extra dependencies that it cannot figure out on
its own. It also adds a CPPFLAGS parameter to define the __BUILD_DIR__
constant for the preprocessor so that the current output build directory
can be referenced in C code if necessary.

Change-Id: I4fdd08842972cfed8ef5e5a61ebf859c0571bcfb
Signed-off-by: Julius Werner <jwerner@chromium.org>
Reviewed-on: https://review.coreboot.org/26451
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
diff --git a/Makefile.inc b/Makefile.inc
index fcdc72c..c40cec8 100644
--- a/Makefile.inc
+++ b/Makefile.inc
@@ -60,6 +60,10 @@
 objgenerated := $(obj)/generated
 COREBOOT_EXPORTS += objgenerated
 
+## CCACHE_EXTRAFILES can be set by individual rules to help CCACHE
+## discover dependencies it might not notice on its own (e.g. asm (".incbin")).
+COREBOOT_EXPORTS += CCACHE_EXTRAFILES
+
 #######################################################################
 # root rule to resolve if in build mode (ie. configuration exists)
 real-target: $(obj)/config.h coreboot files_added
@@ -380,6 +384,7 @@
 CPPFLAGS_common += -I$(VBOOT_SOURCE)/firmware/include
 CPPFLAGS_common += -include $(src)/include/kconfig.h
 CPPFLAGS_common += -I3rdparty
+CPPFLAGS_common += -D__BUILD_DIR__=\"$(obj)\"
 
 CFLAGS_common += -pipe -g -nostdinc -std=gnu11
 CFLAGS_common += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes