common.mk 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # All makefiles must define TOP, corresponding to the Agda root directory.
  2. ifeq ($(TOP),)
  3. $(error "Makefiles must define the TOP variable to correspond with the Agda source root")
  4. endif
  5. # Standard "as safe as bash can be, which isn't very" flags to eagerly detect
  6. # problems rather than barging on through and possibly executing unsafe
  7. # commands in an unexpected state.
  8. # -E inherits ERR traps on subcommands and subshells.
  9. # -e exits on errors.
  10. # -o pipefail propagates errors through piped sequences.
  11. # -c indicates the start of the command.
  12. SHELL := bash
  13. .SHELLFLAGS := -Eeu -o pipefail -c
  14. # Include the user config makefile, if it exists. That file is .gitignored.
  15. # We could do `-include …` to silently try, but that would not bail on errors.
  16. USER_CONFIG_MK := $(TOP)/mk/config.mk
  17. ifneq ($(wildcard $(USER_CONFIG_MK)),)
  18. include $(USER_CONFIG_MK)
  19. else
  20. # The Agda makefiles prior to PR #4841 would load `mk/parallel-test.mk`,
  21. # which, if existed, would be expected to define the single variable
  22. # `PARALLEL_TESTS`. They did not load `mk/config.mk` or expect that to exist.
  23. #
  24. # It's simpler to maintain a single source of truth for user configuration.
  25. # So: if the new `mk/config.mk` file does not exist, but the old
  26. # `mk/parallel-tests.mk` does, load it and gently nudge them toward putting
  27. # creating a `mk/config.mk`.
  28. #
  29. # We don't create it automatically because this loading phase may not be
  30. # atomic and we don't want to clobber things that aren't build targets.
  31. #
  32. # The following lines should be removed at some point in the mid future.
  33. DEPRECATED_PARALLEL_TESTS_MK := $(TOP)/mk/parallel-tests.mk
  34. ifneq ($(wildcard $(DEPRECATED_PARALLEL_TESTS_MK)),)
  35. ifndef DID_WARN_DEPRECATED_PARALLEL_TESTS_MK
  36. export DID_WARN_DEPRECATED_PARALLEL_TESTS_MK := 1
  37. $(warning Loading deprecated $(DEPRECATED_PARALLEL_TESTS_MK))
  38. $(warning Please put custom makefile options in $(USER_CONFIG_MK) instead.)
  39. $(warning (It can contain the line "include $$(TOP)/mk/parallel-tests.mk", if you want))
  40. endif
  41. include $(DEPRECATED_PARALLEL_TESTS_MK)
  42. endif
  43. endif
  44. # Use gsed on Mac OS instead of sed
  45. ifeq ($(shell uname), Darwin)
  46. SED := gsed
  47. else
  48. SED := sed
  49. endif