Makefile 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #
  2. # This is a simple wrapper Makefile that calls the main Makefile.perf
  3. # with a -j option to do parallel builds
  4. #
  5. # If you want to invoke the perf build in some non-standard way then
  6. # you can use the 'make -f Makefile.perf' method to invoke it.
  7. #
  8. #
  9. # Clear out the built-in rules GNU make defines by default (such as .o targets),
  10. # so that we pass through all targets to Makefile.perf:
  11. #
  12. .SUFFIXES:
  13. #
  14. # We don't want to pass along options like -j:
  15. #
  16. unexport MAKEFLAGS
  17. #
  18. # Do a parallel build with multiple jobs, based on the number of CPUs online
  19. # in this system: 'make -j8' on a 8-CPU system, etc.
  20. #
  21. # (To override it, run 'make JOBS=1' and similar.)
  22. #
  23. ifeq ($(JOBS),)
  24. JOBS := $(shell (getconf _NPROCESSORS_ONLN || egrep -c '^processor|^CPU[0-9]' /proc/cpuinfo) 2>/dev/null)
  25. ifeq ($(JOBS),0)
  26. JOBS := 1
  27. endif
  28. endif
  29. #
  30. # Only pass canonical directory names as the output directory:
  31. #
  32. ifneq ($(O),)
  33. FULL_O := $(shell readlink -f $(O) || echo $(O))
  34. endif
  35. #
  36. # Only accept the 'DEBUG' variable from the command line:
  37. #
  38. ifeq ("$(origin DEBUG)", "command line")
  39. ifeq ($(DEBUG),)
  40. override DEBUG = 0
  41. else
  42. SET_DEBUG = "DEBUG=$(DEBUG)"
  43. endif
  44. else
  45. override DEBUG = 0
  46. endif
  47. define print_msg
  48. @printf ' BUILD: Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build\n'
  49. endef
  50. define make
  51. @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(FULL_O) $(SET_DEBUG) $@
  52. endef
  53. #
  54. # Needed if no target specified:
  55. # (Except for tags and TAGS targets. The reason is that the
  56. # Makefile does not treat tags/TAGS as targets but as files
  57. # and thus won't rebuilt them once they are in place.)
  58. #
  59. all tags TAGS:
  60. $(print_msg)
  61. $(make)
  62. #
  63. # Explicitly disable parallelism for the clean target.
  64. #
  65. clean:
  66. $(make) -j1
  67. #
  68. # The build-test target is not really parallel, don't print the jobs info:
  69. #
  70. build-test:
  71. @$(MAKE) SHUF=1 -f tests/make --no-print-directory
  72. #
  73. # All other targets get passed through:
  74. #
  75. %: FORCE
  76. $(print_msg)
  77. $(make)
  78. .PHONY: tags TAGS FORCE Makefile