Fix CCACHE handling, and make use of ccache's BASEDIR feature
[coreboot.git] / Makefile
index 25972ffd05b7334190d7a6cfa9986ac8ce2847dd..a5cba2b906574fd871cb9c8a508134d8f715bfd0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -88,7 +88,7 @@ all: config
 
 else
 
-include $(top)/.config
+include $(HAVE_DOTCONFIG)
 
 ifneq ($(INNER_SCANBUILD),y)
 ifeq ($(CONFIG_COMPILER_LLVM_CLANG),y)
@@ -98,10 +98,11 @@ endif
 endif
 
 ifeq ($(CONFIG_CCACHE),y)
-CCACHE:=CCACHE_COMPILERCHECK=content $(wildcard $(addsuffix /ccache,$(subst :, ,$(PATH))))
+CCACHE:=$(wildcard $(addsuffix /ccache,$(subst :, ,$(PATH))))
 ifeq ($(CCACHE),)
 $(error ccache selected, but not found in PATH)
 endif
+CCACHE:=CCACHE_COMPILERCHECK=content CCACHE_BASEDIR=$(top) $(CCACHE)
 CC := $(CCACHE) $(CC)
 HOSTCC := $(CCACHE) $(HOSTCC)
 HOSTCXX := $(CCACHE) $(HOSTCXX)
@@ -287,7 +288,7 @@ INCLUDES += -Isrc/devices/oprom/include
 # abspath is a workaround for romcc
 INCLUDES += -include $(abspath $(obj)/config.h)
 
-CFLAGS = $(INCLUDES) -Os -nostdinc -pipe
+CFLAGS = $(INCLUDES) -Os -nostdinc -pipe -g
 CFLAGS += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes
 CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs
 CFLAGS += -Wstrict-aliasing -Wshadow
@@ -330,6 +331,9 @@ $(obj)/build.h: .xcompile
        printf "#endif\n" >> $(obj)/build.ht
        mv $(obj)/build.ht $(obj)/build.h
 
+cscope:
+       cscope -bR
+
 doxy: doxygen
 doxygen:
        $(DOXYGEN) documentation/Doxyfile.coreboot
@@ -354,7 +358,10 @@ clean-for-update: doxygen-clean
 clean: clean-for-update
        rm -f $(obj)/coreboot* .ccwrap
 
-distclean:
+clean-cscope:
+       rm -f cscope.out
+
+distclean: clean-cscope
        rm -rf $(obj)
        rm -f .config .config.old ..config.tmp .kconfig.d .tmpconfig* .ccwrap .xcompile
 
@@ -368,19 +375,20 @@ include util/kconfig/Makefile
 $(obj)/ldoptions: $(obj)/config.h
        awk '/^#define ([^"])* ([^"])*$$/ {gsub("\\r","",$$3); print $$2 " = " $$3 ";";}' $< > $@
 
-_OS=$(shell uname -o)
+_WINCHECK=$(shell uname -o 2> /dev/null)
 STACK=
-ifeq ($(_OS),Msys)
+ifeq ($(_WINCHECK),Msys)
        STACK=-Wl,--stack,16384000
 endif
-ifeq ($(_OS),Cygwin)
+ifeq ($(_WINCHECK),Cygwin)
        STACK=-Wl,--stack,16384000
 endif
+
 $(objutil)/romcc/romcc: $(top)/util/romcc/romcc.c
        @printf "    HOSTCC     $(subst $(obj)/,,$(@)) (this may take a while)\n"
        @# Note: Adding -O2 here might cause problems. For details see:
        @# http://www.coreboot.org/pipermail/coreboot/2010-February/055825.html
        $(HOSTCC) -g $(STACK) -Wall -o $@ $<
 
-.PHONY: $(PHONY) clean distclean doxygen doxy coreboot .xcompile
+.PHONY: $(PHONY) clean clean-cscope cscope distclean doxygen doxy coreboot .xcompile