makefile.include 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. # -*- coding: utf-8; mode: makefile-gmake -*-
  2. ifeq (,$(wildcard /.lxcenv.mk))
  3. PHONY += lxc-activate
  4. lxc-activate:
  5. @$(MAKE) -s -f /share/searx/utils/makefile.lxc lxc-activate
  6. else
  7. include /.lxcenv.mk
  8. endif
  9. ifeq (,$(wildcard /.lxcenv.mk))
  10. make-help:
  11. else
  12. make-help: lxc-help
  13. endif
  14. @echo ' make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build'
  15. @echo ' make V=2 [targets] 2 => give reason for rebuild of target'
  16. quiet_cmd_common_clean = CLEAN $@
  17. cmd_common_clean = \
  18. find . -name '*.orig' -exec rm -f {} + ;\
  19. find . -name '*.rej' -exec rm -f {} + ;\
  20. find . -name '*~' -exec rm -f {} + ;\
  21. find . -name '*.bak' -exec rm -f {} + ;\
  22. FMT = cat
  23. ifeq ($(shell which fmt >/dev/null 2>&1; echo $$?), 0)
  24. FMT = fmt
  25. endif
  26. # MS-Windows
  27. #
  28. # For a minimal *make-environment*, I'am using the gnu-tools from:
  29. #
  30. # - GNU MCU Eclipse Windows Build Tools, which brings 'make', 'rm' etc.
  31. # https://github.com/gnu-mcu-eclipse/windows-build-tools/releases
  32. #
  33. # - git for Windows, which brings 'find', 'grep' etc.
  34. # https://git-scm.com/download/win
  35. # normpath
  36. #
  37. # System-dependent normalization of the path name
  38. #
  39. # usage: $(call normpath,/path/to/file)
  40. normpath = $1
  41. ifeq ($(OS),Windows_NT)
  42. normpath = $(subst /,\,$1)
  43. endif
  44. # stolen from linux/Makefile
  45. #
  46. ifeq ("$(origin V)", "command line")
  47. KBUILD_VERBOSE = $(V)
  48. endif
  49. ifndef KBUILD_VERBOSE
  50. KBUILD_VERBOSE = 0
  51. endif
  52. ifeq ($(KBUILD_VERBOSE),1)
  53. quiet =
  54. Q =
  55. else
  56. quiet=quiet_
  57. Q = @
  58. endif
  59. # stolen from linux/scripts/Kbuild.include
  60. #
  61. # Convenient variables
  62. comma := ,
  63. quote := "
  64. #" this comment is only for emacs highlighting
  65. squote := '
  66. #' this comment is only for emacs highlighting
  67. empty :=
  68. space := $(empty) $(empty)
  69. space_escape := _-_SPACE_-_
  70. # Find any prerequisites that is newer than target or that does not exist.
  71. # PHONY targets skipped in both cases.
  72. any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
  73. #
  74. ###
  75. # why - tell why a a target got build
  76. # enabled by make V=2
  77. # Output (listed in the order they are checked):
  78. # (1) - due to target is PHONY
  79. # (2) - due to target missing
  80. # (3) - due to: file1.h file2.h
  81. # (4) - due to command line change
  82. # (5) - due to missing .cmd file
  83. # (6) - due to target not in $(targets)
  84. # (1) PHONY targets are always build
  85. # (2) No target, so we better build it
  86. # (3) Prerequisite is newer than target
  87. # (4) The command line stored in the file named dir/.target.cmd
  88. # differed from actual command line. This happens when compiler
  89. # options changes
  90. # (5) No dir/.target.cmd file (used to store command line)
  91. # (6) No dir/.target.cmd file and target not listed in $(targets)
  92. # This is a good hint that there is a bug in the kbuild file
  93. ifeq ($(KBUILD_VERBOSE),2)
  94. why = \
  95. $(if $(filter $@, $(PHONY)),- due to target is PHONY, \
  96. $(if $(wildcard $@), \
  97. $(if $(strip $(any-prereq)),- due to: $(any-prereq), \
  98. $(if $(arg-check), \
  99. $(if $(cmd_$@),- due to command line change, \
  100. $(if $(filter $@, $(targets)), \
  101. - due to missing .cmd file, \
  102. - due to $(notdir $@) not in $$(targets) \
  103. ) \
  104. ) \
  105. ) \
  106. ), \
  107. - due to target missing \
  108. ) \
  109. )
  110. echo-why = $(call escsq, $(strip $(why)))
  111. endif
  112. #
  113. ###
  114. # Escape single quote for use in echo statements
  115. escsq = $(subst $(squote),'\$(squote)',$1)
  116. #
  117. # echo command.
  118. # Short version is used, if $(quiet) equals `quiet_', otherwise full one.
  119. echo-cmd = $(if $($(quiet)cmd_$(1)),echo '$(call escsq,$($(quiet)cmd_$(1)))$(echo-why)';)
  120. #
  121. # printing commands
  122. cmd = @$(echo-cmd) $(cmd_$(1))
  123. .PHONY: $(PHONY)