Makefile.include 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. CC_NO_CLANG := $(shell $(CC) -dM -E -x c /dev/null | grep -Fq "__clang__"; echo $$?)
  40. ifeq ($(CC_NO_CLANG), 1)
  41. EXTRA_WARNINGS += -Wstrict-aliasing=3
  42. endif
  43. # Hack to avoid type-punned warnings on old systems such as RHEL5:
  44. # We should be changing CFLAGS and checking gcc version, but this
  45. # will do for now and keep the above -Wstrict-aliasing=3 in place
  46. # in newer systems.
  47. # Needed for the __raw_cmpxchg in tools/arch/x86/include/asm/cmpxchg.h
  48. ifneq ($(filter 3.%,$(MAKE_VERSION)),) # make-3
  49. EXTRA_WARNINGS += -fno-strict-aliasing
  50. endif
  51. ifneq ($(findstring $(MAKEFLAGS), w),w)
  52. PRINT_DIR = --no-print-directory
  53. else
  54. NO_SUBDIR = :
  55. endif
  56. ifneq ($(findstring s,$(filter-out --%,$(MAKEFLAGS))),)
  57. silent=1
  58. endif
  59. #
  60. # Define a callable command for descending to a new directory
  61. #
  62. # Call by doing: $(call descend,directory[,target])
  63. #
  64. descend = \
  65. +mkdir -p $(OUTPUT)$(1) && \
  66. $(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1) $(2)
  67. QUIET_SUBDIR0 = +$(MAKE) $(COMMAND_O) -C # space to separate -C and subdir
  68. QUIET_SUBDIR1 =
  69. ifneq ($(silent),1)
  70. ifneq ($(V),1)
  71. QUIET_CC = @echo ' CC '$@;
  72. QUIET_CC_FPIC = @echo ' CC FPIC '$@;
  73. QUIET_AR = @echo ' AR '$@;
  74. QUIET_LINK = @echo ' LINK '$@;
  75. QUIET_MKDIR = @echo ' MKDIR '$@;
  76. QUIET_GEN = @echo ' GEN '$@;
  77. QUIET_SUBDIR0 = +@subdir=
  78. QUIET_SUBDIR1 = ;$(NO_SUBDIR) \
  79. echo ' SUBDIR '$$subdir; \
  80. $(MAKE) $(PRINT_DIR) -C $$subdir
  81. QUIET_FLEX = @echo ' FLEX '$@;
  82. QUIET_BISON = @echo ' BISON '$@;
  83. descend = \
  84. +@echo ' DESCEND '$(1); \
  85. mkdir -p $(OUTPUT)$(1) && \
  86. $(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1) $(2)
  87. QUIET_CLEAN = @printf ' CLEAN %s\n' $1;
  88. QUIET_INSTALL = @printf ' INSTALL %s\n' $1;
  89. endif
  90. endif