Makefile 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 grep -c ^processor /proc/cpuinfo 2>/dev/null)
  25. ifeq ($(JOBS),)
  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))
  34. endif
  35. define print_msg
  36. @printf ' BUILD: Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build\n'
  37. endef
  38. define make
  39. @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(FULL_O) $@
  40. endef
  41. #
  42. # Needed if no target specified:
  43. #
  44. all:
  45. $(print_msg)
  46. $(make)
  47. #
  48. # The clean target is not really parallel, don't print the jobs info:
  49. #
  50. clean:
  51. $(make)
  52. #
  53. # All other targets get passed through:
  54. #
  55. %:
  56. $(print_msg)
  57. $(make)