Makefile 744 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #
  2. # Do a parallel build with multiple jobs, based on the number of CPUs online
  3. # in this system: 'make -j8' on a 8-CPU system, etc.
  4. #
  5. # (To override it, run 'make JOBS=1' and similar.)
  6. #
  7. ifeq ($(JOBS),)
  8. JOBS := $(shell grep -c ^processor /proc/cpuinfo 2>/dev/null)
  9. ifeq ($(JOBS),)
  10. JOBS := 1
  11. endif
  12. endif
  13. export JOBS
  14. define print_msg
  15. @printf ' BUILD: Doing '\''make \033[33m-j'$(JOBS)'\033[m'\'' parallel build\n'
  16. endef
  17. define make
  18. @$(MAKE) -f Makefile.perf --no-print-directory -j$(JOBS) $@
  19. endef
  20. #
  21. # Needed if no target specified:
  22. #
  23. all:
  24. $(print_msg)
  25. $(make)
  26. #
  27. # The clean target is not really parallel, don't print the jobs info:
  28. #
  29. clean:
  30. $(make)
  31. #
  32. # All other targets get passed through:
  33. #
  34. %:
  35. $(print_msg)
  36. $(make)