targets.mk 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. .EXPORT_ALL_VARIABLES:
  2. .NOTPARALLEL: .PHONY
  3. # Additional distribution files
  4. DISTFILES_extra= Makefile request-assign-future.txt etc
  5. LISPDIRS = lisp
  6. OTHERDIRS = doc etc
  7. CLEANDIRS = testing mk
  8. SUBDIRS = $(OTHERDIRS) $(LISPDIRS)
  9. INSTSUB = $(SUBDIRS:%=install-%)
  10. ORG_MAKE_DOC ?= info html pdf
  11. ifneq ($(wildcard .git),)
  12. ORGVERSION ?= $(subst release_,,$(shell git describe --match release\* --abbrev=0 HEAD))
  13. ifeq ($(ORGVERSION),)
  14. # In elpa.git, there are no tags available. Fall back to using
  15. # the org.el header.
  16. ORGVERSION := $(patsubst %-dev,%,$(shell $(BATCH) --eval "(require 'lisp-mnt)" \
  17. --visit lisp/org.el --eval '(princ (lm-header "version"))'))
  18. GITVERSION ?= $(ORGVERSION)-g$(shell git rev-parse --short=6 HEAD)
  19. else
  20. GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
  21. endif
  22. GITSTATUS ?= $(shell git status -uno --porcelain)
  23. else
  24. -include mk/version.mk
  25. GITVERSION ?= N/A
  26. ORGVERSION ?= N/A
  27. endif
  28. DATE = $(shell date +%Y-%m-%d)
  29. YEAR = $(shell date +%Y)
  30. ifneq ($(GITSTATUS),)
  31. GITVERSION := $(GITVERSION:.dirty=).dirty
  32. endif
  33. .PHONY: all oldorg update update2 up0 up1 up2 single $(SUBDIRS) \
  34. check test install $(INSTSUB) \
  35. info html pdf card refcard doc docs \
  36. autoloads cleanall clean $(CLEANDIRS:%=clean%) \
  37. clean-install cleanelc cleandirs \
  38. cleanlisp cleandoc cleandocs cleantest \
  39. compile compile-dirty uncompiled \
  40. config config-test config-exe config-all config-eol config-version \
  41. vanilla repro
  42. CONF_BASE = EMACS DESTDIR ORGCM ORG_MAKE_DOC
  43. CONF_DEST = lispdir infodir datadir testdir
  44. CONF_TEST = BTEST_PRE BTEST_POST BTEST_OB_LANGUAGES BTEST_EXTRA BTEST_RE
  45. CONF_EXEC = CP MKDIR RM RMR FIND CHMOD SUDO PDFTEX TEXI2PDF TEXI2HTML MAKEINFO INSTALL_INFO
  46. CONF_CALL = BATCH BATCHL ELC ELCDIR NOBATCH BTEST MAKE_LOCAL_MK MAKE_ORG_INSTALL MAKE_ORG_VERSION
  47. config-eol:: EOL = \#
  48. config-eol:: config-all
  49. config config-all::
  50. $(info )
  51. $(info ========= Emacs executable and Installation paths)
  52. $(foreach var,$(CONF_BASE),$(info $(var) = $($(var))$(EOL)))
  53. $(foreach var,$(CONF_DEST),$(info $(var) = $(DESTDIR)$($(var))$(EOL)))
  54. config-test config-all::
  55. $(info )
  56. $(info ========= Test configuration)
  57. $(foreach var,$(CONF_TEST),$(info $(var) = $($(var))$(EOL)))
  58. config-exe config-all::
  59. $(info )
  60. $(info ========= Executables used by make)
  61. $(foreach var,$(CONF_EXEC),$(info $(var) = $($(var))$(EOL)))
  62. config-cmd config-all::
  63. $(info )
  64. $(info ========= Commands used by make)
  65. $(foreach var,$(CONF_CALL),$(info $(var) = $($(var))$(EOL)))
  66. config config-test config-exe config-all config-version::
  67. $(info ========= Org version)
  68. $(info make: Org mode version $(ORGVERSION) ($(GITVERSION) => $(lispdir)))
  69. @echo ""
  70. oldorg: compile info # what the old makefile did when no target was specified
  71. uncompiled: cleanlisp autoloads # for developing
  72. refcard: card
  73. update update2:: up0 all
  74. single: ORGCM=single
  75. single: compile
  76. .PRECIOUS: local.mk
  77. local.mk:
  78. $(info ======================================================)
  79. $(info = Invoke "make help" for a synopsis of make targets. =)
  80. $(info = Created a default local.mk template. =)
  81. $(info = Setting "oldorg" as the default target. =)
  82. $(info = Please adapt local.mk to your local setup! =)
  83. $(info ======================================================)
  84. -@$(MAKE_LOCAL_MK)
  85. all compile::
  86. $(foreach dir, doc lisp, $(MAKE) -C $(dir) clean;)
  87. compile compile-dirty::
  88. $(MAKE) -C lisp $@
  89. all clean-install::
  90. $(foreach dir, $(SUBDIRS), $(MAKE) -C $(dir) $@;)
  91. vanilla:
  92. -@$(NOBATCH) &
  93. check test:: compile
  94. check test test-dirty::
  95. -$(MKDIR) $(testdir)
  96. TMPDIR=$(testdir) $(BTEST)
  97. ifeq ($(TEST_NO_AUTOCLEAN),) # define this variable to leave $(testdir) around for inspection
  98. $(MAKE) cleantest
  99. endif
  100. up0 up1 up2::
  101. git checkout $(GIT_BRANCH)
  102. git remote update
  103. git pull
  104. up1 up2:: all
  105. $(MAKE) test-dirty
  106. up2 update2::
  107. $(SUDO) $(MAKE) install
  108. install: $(INSTSUB)
  109. install-info: install-doc
  110. doc docs: $(ORG_MAKE_DOC)
  111. info html pdf card:
  112. $(MAKE) -C doc $@
  113. $(INSTSUB):
  114. $(MAKE) -C $(@:install-%=%) install
  115. autoloads: lisp
  116. $(MAKE) -C $< $@
  117. repro: cleanall autoloads
  118. -@$(REPRO) &
  119. cleandirs:
  120. $(foreach dir, $(SUBDIRS), $(MAKE) -C $(dir) cleanall;)
  121. clean: cleanlisp cleandoc
  122. cleanall: cleandirs cleantest
  123. -$(FIND) . \( -name \*~ -o -name \*# -o -name .#\* \) -exec $(RM) {} +
  124. -$(FIND) $(CLEANDIRS) \( -name \*~ -o -name \*.elc \) -exec $(RM) {} +
  125. $(CLEANDIRS:%=clean%):
  126. -$(FIND) $(@:clean%=%) \( -name \*~ -o -name \*.elc \) -exec $(RM) {} +
  127. cleanelc:
  128. $(MAKE) -C lisp $@
  129. cleanlisp cleandoc:
  130. $(MAKE) -C $(@:clean%=%) clean
  131. cleandocs:
  132. $(MAKE) -C doc clean
  133. -$(FIND) doc -name \*~ -exec $(RM) {} \;
  134. cleantest:
  135. # git-annex creates non-writable directories so that the files within
  136. # them can't be removed; if rm fails, try to recover by making all
  137. # directories writable
  138. -$(RMR) $(testdir) || { \
  139. $(FIND) $(testdir) -type d -exec $(CHMOD) u+w {} + && \
  140. $(RMR) $(testdir) ; \
  141. }