Makefile.include 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. ifneq ($(O),)
  2. ifeq ($(origin O), command line)
  3. dummy := $(if $(shell test -d $(O) || echo $(O)),$(error O=$(O) does not exist),)
  4. ABSOLUTE_O := $(shell cd $(O) ; pwd)
  5. OUTPUT := $(ABSOLUTE_O)/$(if $(subdir),$(subdir)/)
  6. COMMAND_O := O=$(ABSOLUTE_O)
  7. ifeq ($(objtree),)
  8. objtree := $(O)
  9. endif
  10. endif
  11. endif
  12. # check that the output directory actually exists
  13. ifneq ($(OUTPUT),)
  14. OUTDIR := $(shell cd $(OUTPUT) && /bin/pwd)
  15. $(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist))
  16. endif
  17. #
  18. # Include saner warnings here, which can catch bugs:
  19. #
  20. EXTRA_WARNINGS := -Wbad-function-cast
  21. EXTRA_WARNINGS += -Wdeclaration-after-statement
  22. EXTRA_WARNINGS += -Wformat-security
  23. EXTRA_WARNINGS += -Wformat-y2k
  24. EXTRA_WARNINGS += -Winit-self
  25. EXTRA_WARNINGS += -Wmissing-declarations
  26. EXTRA_WARNINGS += -Wmissing-prototypes
  27. EXTRA_WARNINGS += -Wnested-externs
  28. EXTRA_WARNINGS += -Wno-system-headers
  29. EXTRA_WARNINGS += -Wold-style-definition
  30. EXTRA_WARNINGS += -Wpacked
  31. EXTRA_WARNINGS += -Wredundant-decls
  32. EXTRA_WARNINGS += -Wshadow
  33. EXTRA_WARNINGS += -Wstrict-prototypes
  34. EXTRA_WARNINGS += -Wswitch-default
  35. EXTRA_WARNINGS += -Wswitch-enum
  36. EXTRA_WARNINGS += -Wundef
  37. EXTRA_WARNINGS += -Wwrite-strings
  38. EXTRA_WARNINGS += -Wformat
  39. ifneq ($(CC), clang)
  40. EXTRA_WARNINGS += -Wstrict-aliasing=3
  41. endif
  42. # Hack to avoid type-punned warnings on old systems such as RHEL5:
  43. # We should be changing CFLAGS and checking gcc version, but this
  44. # will do for now and keep the above -Wstrict-aliasing=3 in place
  45. # in newer systems.
  46. # Needed for the __raw_cmpxchg in tools/arch/x86/include/asm/cmpxchg.h
  47. ifneq ($(filter 3.%,$(MAKE_VERSION)),) # make-3
  48. EXTRA_WARNINGS += -fno-strict-aliasing
  49. endif
  50. ifneq ($(findstring $(MAKEFLAGS), w),w)
  51. PRINT_DIR = --no-print-directory
  52. else
  53. NO_SUBDIR = :
  54. endif
  55. ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
  56. silent=1
  57. endif
  58. #
  59. # Define a callable command for descending to a new directory
  60. #
  61. # Call by doing: $(call descend,directory[,target])
  62. #
  63. descend = \
  64. +mkdir -p $(OUTPUT)$(1) && \
  65. $(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1) $(2)
  66. QUIET_SUBDIR0 = +$(MAKE) $(COMMAND_O) -C # space to separate -C and subdir
  67. QUIET_SUBDIR1 =
  68. ifneq ($(silent),1)
  69. ifneq ($(V),1)
  70. QUIET_CC = @echo ' CC '$@;
  71. QUIET_CC_FPIC = @echo ' CC FPIC '$@;
  72. QUIET_AR = @echo ' AR '$@;
  73. QUIET_LINK = @echo ' LINK '$@;
  74. QUIET_MKDIR = @echo ' MKDIR '$@;
  75. QUIET_GEN = @echo ' GEN '$@;
  76. QUIET_SUBDIR0 = +@subdir=
  77. QUIET_SUBDIR1 = ;$(NO_SUBDIR) \
  78. echo ' SUBDIR '$$subdir; \
  79. $(MAKE) $(PRINT_DIR) -C $$subdir
  80. QUIET_FLEX = @echo ' FLEX '$@;
  81. QUIET_BISON = @echo ' BISON '$@;
  82. descend = \
  83. +@echo ' DESCEND '$(1); \
  84. mkdir -p $(OUTPUT)$(1) && \
  85. $(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1) $(2)
  86. QUIET_CLEAN = @printf ' CLEAN %s\n' $1;
  87. QUIET_INSTALL = @printf ' INSTALL %s\n' $1;
  88. endif
  89. endif