Makefile.include 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. ifeq ($(origin O), command line)
  2. dummy := $(if $(shell test -d $(O) || echo $(O)),$(error O=$(O) does not exist),)
  3. ABSOLUTE_O := $(shell cd $(O) ; pwd)
  4. OUTPUT := $(ABSOLUTE_O)/$(if $(subdir),$(subdir)/)
  5. COMMAND_O := O=$(ABSOLUTE_O)
  6. ifeq ($(objtree),)
  7. objtree := $(O)
  8. endif
  9. endif
  10. ifneq ($(OUTPUT),)
  11. # check that the output directory actually exists
  12. OUTDIR := $(shell cd $(OUTPUT) && /bin/pwd)
  13. $(if $(OUTDIR),, $(error output directory "$(OUTPUT)" does not exist))
  14. endif
  15. #
  16. # Include saner warnings here, which can catch bugs:
  17. #
  18. EXTRA_WARNINGS := -Wbad-function-cast
  19. EXTRA_WARNINGS += -Wdeclaration-after-statement
  20. EXTRA_WARNINGS += -Wformat-security
  21. EXTRA_WARNINGS += -Wformat-y2k
  22. EXTRA_WARNINGS += -Winit-self
  23. EXTRA_WARNINGS += -Wmissing-declarations
  24. EXTRA_WARNINGS += -Wmissing-prototypes
  25. EXTRA_WARNINGS += -Wnested-externs
  26. EXTRA_WARNINGS += -Wno-system-headers
  27. EXTRA_WARNINGS += -Wold-style-definition
  28. EXTRA_WARNINGS += -Wpacked
  29. EXTRA_WARNINGS += -Wredundant-decls
  30. EXTRA_WARNINGS += -Wshadow
  31. EXTRA_WARNINGS += -Wstrict-aliasing=3
  32. EXTRA_WARNINGS += -Wstrict-prototypes
  33. EXTRA_WARNINGS += -Wswitch-default
  34. EXTRA_WARNINGS += -Wswitch-enum
  35. EXTRA_WARNINGS += -Wundef
  36. EXTRA_WARNINGS += -Wwrite-strings
  37. EXTRA_WARNINGS += -Wformat
  38. ifneq ($(findstring $(MAKEFLAGS), w),w)
  39. PRINT_DIR = --no-print-directory
  40. else
  41. NO_SUBDIR = :
  42. endif
  43. #
  44. # Define a callable command for descending to a new directory
  45. #
  46. # Call by doing: $(call descend,directory[,target])
  47. #
  48. descend = \
  49. +mkdir -p $(OUTPUT)$(1) && \
  50. $(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1) $(2)
  51. QUIET_SUBDIR0 = +$(MAKE) $(COMMAND_O) -C # space to separate -C and subdir
  52. QUIET_SUBDIR1 =
  53. ifneq ($(findstring $(MAKEFLAGS),s),s)
  54. ifndef V
  55. QUIET_CC = @echo ' ' CC $@;
  56. QUIET_AR = @echo ' ' AR $@;
  57. QUIET_LINK = @echo ' ' LINK $@;
  58. QUIET_MKDIR = @echo ' ' MKDIR $@;
  59. QUIET_GEN = @echo ' ' GEN $@;
  60. QUIET_SUBDIR0 = +@subdir=
  61. QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
  62. $(MAKE) $(PRINT_DIR) -C $$subdir
  63. QUIET_FLEX = @echo ' ' FLEX $@;
  64. QUIET_BISON = @echo ' ' BISON $@;
  65. descend = \
  66. @echo ' ' DESCEND $(1); \
  67. mkdir -p $(OUTPUT)$(1) && \
  68. $(MAKE) $(COMMAND_O) subdir=$(if $(subdir),$(subdir)/$(1),$(1)) $(PRINT_DIR) -C $(1) $(2)
  69. endif
  70. endif