targets.mk 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. .EXPORT_ALL_VARIABLES:
  2. .NOTPARALLEL: .PHONY
  3. # Additional distribution files
  4. DISTFILES_extra= Makefile request-assign-future.txt contrib etc
  5. LISPDIRS = lisp
  6. OTHERDIRS = doc etc
  7. CLEANDIRS = contrib 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 := $(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 cleanaddcontrib \
  38. cleanlisp cleandoc cleandocs cleantest \
  39. compile compile-dirty uncompiled \
  40. config config-test config-exe config-all config-eol config-version \
  41. vanilla
  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. $(info ========= Additional files from contrib/lisp)
  55. $(info $(notdir \
  56. $(wildcard \
  57. $(addsuffix .el, \
  58. $(addprefix contrib/lisp/, \
  59. $(basename \
  60. $(notdir $(ORG_ADD_CONTRIB))))))))
  61. config-test config-all::
  62. $(info )
  63. $(info ========= Test configuration)
  64. $(foreach var,$(CONF_TEST),$(info $(var) = $($(var))$(EOL)))
  65. config-exe config-all::
  66. $(info )
  67. $(info ========= Executables used by make)
  68. $(foreach var,$(CONF_EXEC),$(info $(var) = $($(var))$(EOL)))
  69. config-cmd config-all::
  70. $(info )
  71. $(info ========= Commands used by make)
  72. $(foreach var,$(CONF_CALL),$(info $(var) = $($(var))$(EOL)))
  73. config config-test config-exe config-all config-version::
  74. $(info ========= Org version)
  75. $(info make: Org mode version $(ORGVERSION) ($(GITVERSION) => $(lispdir)))
  76. @echo ""
  77. oldorg: compile info # what the old makefile did when no target was specified
  78. uncompiled: cleanlisp autoloads # for developing
  79. refcard: card
  80. update update2:: up0 all
  81. single: ORGCM=single
  82. single: compile
  83. .PRECIOUS: local.mk
  84. local.mk:
  85. $(info ======================================================)
  86. $(info = Invoke "make help" for a synopsis of make targets. =)
  87. $(info = Created a default local.mk template. =)
  88. $(info = Setting "oldorg" as the default target. =)
  89. $(info = Please adapt local.mk to your local setup! =)
  90. $(info ======================================================)
  91. -@$(MAKE_LOCAL_MK)
  92. all compile::
  93. $(foreach dir, doc lisp, $(MAKE) -C $(dir) clean;)
  94. compile compile-dirty::
  95. $(MAKE) -C lisp $@
  96. all clean-install::
  97. $(foreach dir, $(SUBDIRS), $(MAKE) -C $(dir) $@;)
  98. vanilla:
  99. -@$(NOBATCH) &
  100. check test:: compile
  101. check test test-dirty::
  102. -$(MKDIR) $(testdir)
  103. TMPDIR=$(testdir) $(BTEST)
  104. ifeq ($(TEST_NO_AUTOCLEAN),) # define this variable to leave $(testdir) around for inspection
  105. $(MAKE) cleantest
  106. endif
  107. up0:: cleanaddcontrib
  108. up0 up1 up2::
  109. git checkout $(GIT_BRANCH)
  110. git remote update
  111. git pull
  112. up1 up2:: all
  113. $(MAKE) test-dirty
  114. up2 update2::
  115. $(SUDO) $(MAKE) install
  116. install: $(INSTSUB)
  117. install-info: install-doc
  118. doc docs: $(ORG_MAKE_DOC)
  119. info html pdf card:
  120. $(MAKE) -C doc $@
  121. $(INSTSUB):
  122. $(MAKE) -C $(@:install-%=%) install
  123. autoloads: lisp
  124. $(MAKE) -C $< $@
  125. cleandirs:
  126. $(foreach dir, $(SUBDIRS), $(MAKE) -C $(dir) cleanall;)
  127. clean: cleanlisp cleandoc
  128. cleanall: cleandirs cleantest cleanaddcontrib
  129. -$(FIND) . \( -name \*~ -o -name \*# -o -name .#\* \) -exec $(RM) {} +
  130. -$(FIND) $(CLEANDIRS) \( -name \*~ -o -name \*.elc \) -exec $(RM) {} +
  131. $(CLEANDIRS:%=clean%):
  132. -$(FIND) $(@:clean%=%) \( -name \*~ -o -name \*.elc \) -exec $(RM) {} +
  133. cleanelc:
  134. $(MAKE) -C lisp $@
  135. cleanaddcontrib:
  136. -$(RM) $(wildcard $(addprefix lisp/,$(notdir $(wildcard contrib/lisp/*.el))))
  137. cleanlisp: cleanaddcontrib
  138. cleanlisp cleandoc:
  139. $(MAKE) -C $(@:clean%=%) clean
  140. cleandocs:
  141. $(MAKE) -C doc clean
  142. -$(FIND) doc -name \*~ -exec $(RM) {} \;
  143. cleantest:
  144. # git-annex creates non-writable directories so that the files within
  145. # them can't be removed; if rm fails, try to recover by making all
  146. # directories writable
  147. -$(RMR) $(testdir) || { \
  148. $(FIND) $(testdir) -type d -exec $(CHMOD) u+w {} + && \
  149. $(RMR) $(testdir) ; \
  150. }