targets.mk 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
  13. ORGVERSION ?= $(subst release_,,$(shell git describe --match release\* --abbrev=0 HEAD))
  14. GITSTATUS ?= $(shell git status -uno --porcelain)
  15. else
  16. -include mk/version.mk
  17. GITVERSION ?= N/A
  18. ORGVERSION ?= N/A
  19. endif
  20. DATE = $(shell date +%Y-%m-%d)
  21. ifneq ($(GITSTATUS),)
  22. GITVERSION := $(GITVERSION:.dirty=).dirty
  23. endif
  24. .PHONY: all oldorg update update2 up0 up1 up2 single $(SUBDIRS) \
  25. check test install $(INSTSUB) \
  26. info html pdf card refcard doc docs \
  27. autoloads cleanall clean $(CLEANDIRS:%=clean%) \
  28. clean-install cleanelc cleandirs cleanaddcontrib \
  29. cleanlisp cleandoc cleandocs cleantest \
  30. compile compile-dirty uncompiled \
  31. config config-test config-exe config-all config-eol config-version \
  32. vanilla
  33. CONF_BASE = EMACS DESTDIR ORGCM ORG_MAKE_DOC
  34. CONF_DEST = lispdir infodir datadir testdir
  35. CONF_TEST = BTEST_PRE BTEST_POST BTEST_OB_LANGUAGES BTEST_EXTRA BTEST_RE
  36. CONF_EXEC = CP MKDIR RM RMR FIND CHMOD SUDO PDFTEX TEXI2PDF TEXI2HTML MAKEINFO INSTALL_INFO
  37. CONF_CALL = BATCH BATCHL ELC ELCDIR NOBATCH BTEST MAKE_LOCAL_MK MAKE_ORG_INSTALL MAKE_ORG_VERSION
  38. config-eol:: EOL = \#
  39. config-eol:: config-all
  40. config config-all::
  41. $(info )
  42. $(info ========= Emacs executable and Installation paths)
  43. $(foreach var,$(CONF_BASE),$(info $(var) = $($(var))$(EOL)))
  44. $(foreach var,$(CONF_DEST),$(info $(var) = $(DESTDIR)$($(var))$(EOL)))
  45. $(info ========= Additional files from contrib/lisp)
  46. $(info $(notdir \
  47. $(wildcard \
  48. $(addsuffix .el, \
  49. $(addprefix contrib/lisp/, \
  50. $(basename \
  51. $(notdir $(ORG_ADD_CONTRIB))))))))
  52. config-test config-all::
  53. $(info )
  54. $(info ========= Test configuration)
  55. $(foreach var,$(CONF_TEST),$(info $(var) = $($(var))$(EOL)))
  56. config-exe config-all::
  57. $(info )
  58. $(info ========= Executables used by make)
  59. $(foreach var,$(CONF_EXEC),$(info $(var) = $($(var))$(EOL)))
  60. config-cmd config-all::
  61. $(info )
  62. $(info ========= Commands used by make)
  63. $(foreach var,$(CONF_CALL),$(info $(var) = $($(var))$(EOL)))
  64. config config-test config-exe config-all config-version::
  65. $(info ========= Org version)
  66. $(info make: Org-mode version $(ORGVERSION) ($(GITVERSION) => $(lispdir)))
  67. @echo ""
  68. oldorg: compile info # what the old makefile did when no target was specified
  69. uncompiled: cleanlisp autoloads # for developing
  70. refcard: card
  71. update update2:: up0 all
  72. single: ORGCM=single
  73. single: compile
  74. .PRECIOUS: local.mk
  75. local.mk:
  76. $(info ======================================================)
  77. $(info = Invoke "make help" for a synopsis of make targets. =)
  78. $(info = Created a default local.mk template. =)
  79. $(info = Setting "oldorg" as the default target. =)
  80. $(info = Please adapt local.mk to your local setup! =)
  81. $(info ======================================================)
  82. -@$(MAKE_LOCAL_MK)
  83. all compile::
  84. $(foreach dir, doc lisp, $(MAKE) -C $(dir) clean;)
  85. compile compile-dirty::
  86. $(MAKE) -C lisp $@
  87. all clean-install::
  88. $(foreach dir, $(SUBDIRS), $(MAKE) -C $(dir) $@;)
  89. vanilla:
  90. -@$(NOBATCH) &
  91. check test:: compile
  92. check test test-dirty::
  93. -$(MKDIR) $(testdir)
  94. TMPDIR=$(testdir) $(BTEST)
  95. ifeq ($(TEST_NO_AUTOCLEAN),) # define this variable to leave $(testdir) around for inspection
  96. $(MAKE) cleantest
  97. endif
  98. up0:: cleanaddcontrib
  99. up0 up1 up2::
  100. git checkout $(GIT_BRANCH)
  101. git remote update
  102. git pull
  103. up1 up2:: all
  104. $(MAKE) test-dirty
  105. up2 update2::
  106. $(SUDO) $(MAKE) install
  107. install: $(INSTSUB)
  108. install-info: install-doc
  109. doc docs: $(ORG_MAKE_DOC)
  110. info html pdf card:
  111. $(MAKE) -C doc $@
  112. $(INSTSUB):
  113. $(MAKE) -C $(@:install-%=%) install
  114. autoloads: lisp
  115. $(MAKE) -C $< $@
  116. cleandirs:
  117. $(foreach dir, $(SUBDIRS), $(MAKE) -C $(dir) cleanall;)
  118. clean: cleanlisp cleandoc
  119. cleanall: cleandirs cleantest cleanaddcontrib
  120. -$(FIND) . \( -name \*~ -o -name \*# -o -name .#\* \) -exec $(RM) {} +
  121. -$(FIND) $(CLEANDIRS) \( -name \*~ -o -name \*.elc \) -exec $(RM) {} +
  122. $(CLEANDIRS:%=clean%):
  123. -$(FIND) $(@:clean%=%) \( -name \*~ -o -name \*.elc \) -exec $(RM) {} +
  124. cleanelc:
  125. $(MAKE) -C lisp $@
  126. cleanaddcontrib:
  127. -$(RM) $(wildcard $(addprefix lisp/,$(notdir $(wildcard contrib/lisp/*.el))))
  128. cleanlisp: cleanaddcontrib
  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. }