Makefile 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. define print_msg
  30. @printf ' BUILD: Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build\n'
  31. endef
  32. define make
  33. @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) O=$(O) $@
  34. endef
  35. #
  36. # Needed if no target specified:
  37. #
  38. all:
  39. $(print_msg)
  40. $(make)
  41. #
  42. # The clean target is not really parallel, don't print the jobs info:
  43. #
  44. clean:
  45. $(make)
  46. #
  47. # All other targets get passed through:
  48. #
  49. %:
  50. $(print_msg)
  51. $(make)