targets.mk 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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. YEAR = $(shell date +%Y)
  22. ifneq ($(GITSTATUS),)
  23. GITVERSION := $(GITVERSION:.dirty=).dirty
  24. endif
  25. .PHONY: all oldorg update update2 up0 up1 up2 single $(SUBDIRS) \
  26. check test install $(INSTSUB) \
  27. info html pdf card refcard doc docs \
  28. autoloads cleanall clean $(CLEANDIRS:%=clean%) \
  29. clean-install cleanelc cleandirs cleanaddcontrib \
  30. cleanlisp cleandoc cleandocs cleantest \
  31. compile compile-dirty uncompiled \
  32. config config-test config-exe config-all config-eol config-version \
  33. vanilla
  34. CONF_BASE = EMACS DESTDIR ORGCM ORG_MAKE_DOC
  35. CONF_DEST = lispdir infodir datadir testdir
  36. CONF_TEST = BTEST_PRE BTEST_POST BTEST_OB_LANGUAGES BTEST_EXTRA BTEST_RE
  37. CONF_EXEC = CP MKDIR RM RMR FIND CHMOD SUDO PDFTEX TEXI2PDF TEXI2HTML MAKEINFO INSTALL_INFO
  38. CONF_CALL = BATCH BATCHL ELC ELCDIR NOBATCH BTEST MAKE_LOCAL_MK MAKE_ORG_INSTALL MAKE_ORG_VERSION
  39. config-eol:: EOL = \#
  40. config-eol:: config-all
  41. config config-all::
  42. $(info )
  43. $(info ========= Emacs executable and Installation paths)
  44. $(foreach var,$(CONF_BASE),$(info $(var) = $($(var))$(EOL)))
  45. $(foreach var,$(CONF_DEST),$(info $(var) = $(DESTDIR)$($(var))$(EOL)))
  46. $(info ========= Additional files from contrib/lisp)
  47. $(info $(notdir \
  48. $(wildcard \
  49. $(addsuffix .el, \
  50. $(addprefix contrib/lisp/, \
  51. $(basename \
  52. $(notdir $(ORG_ADD_CONTRIB))))))))
  53. config-test config-all::
  54. $(info )
  55. $(info ========= Test configuration)
  56. $(foreach var,$(CONF_TEST),$(info $(var) = $($(var))$(EOL)))
  57. config-exe config-all::
  58. $(info )
  59. $(info ========= Executables used by make)
  60. $(foreach var,$(CONF_EXEC),$(info $(var) = $($(var))$(EOL)))
  61. config-cmd config-all::
  62. $(info )
  63. $(info ========= Commands used by make)
  64. $(foreach var,$(CONF_CALL),$(info $(var) = $($(var))$(EOL)))
  65. config config-test config-exe config-all config-version::
  66. $(info ========= Org version)
  67. $(info make: Org mode version $(ORGVERSION) ($(GITVERSION) => $(lispdir)))
  68. @echo ""
  69. oldorg: compile info # what the old makefile did when no target was specified
  70. uncompiled: cleanlisp autoloads # for developing
  71. refcard: card
  72. update update2:: up0 all
  73. single: ORGCM=single
  74. single: compile
  75. .PRECIOUS: local.mk
  76. local.mk:
  77. $(info ======================================================)
  78. $(info = Invoke "make help" for a synopsis of make targets. =)
  79. $(info = Created a default local.mk template. =)
  80. $(info = Setting "oldorg" as the default target. =)
  81. $(info = Please adapt local.mk to your local setup! =)
  82. $(info ======================================================)
  83. -@$(MAKE_LOCAL_MK)
  84. all compile::
  85. $(foreach dir, doc lisp, $(MAKE) -C $(dir) clean;)
  86. compile compile-dirty::
  87. $(MAKE) -C lisp $@
  88. all clean-install::
  89. $(foreach dir, $(SUBDIRS), $(MAKE) -C $(dir) $@;)
  90. vanilla:
  91. -@$(NOBATCH) &
  92. check test:: compile
  93. check test test-dirty::
  94. -$(MKDIR) $(testdir)
  95. TMPDIR=$(testdir) $(BTEST)
  96. ifeq ($(TEST_NO_AUTOCLEAN),) # define this variable to leave $(testdir) around for inspection
  97. $(MAKE) cleantest
  98. endif
  99. up0:: cleanaddcontrib
  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. cleandirs:
  118. $(foreach dir, $(SUBDIRS), $(MAKE) -C $(dir) cleanall;)
  119. clean: cleanlisp cleandoc
  120. cleanall: cleandirs cleantest cleanaddcontrib
  121. -$(FIND) . \( -name \*~ -o -name \*# -o -name .#\* \) -exec $(RM) {} +
  122. -$(FIND) $(CLEANDIRS) \( -name \*~ -o -name \*.elc \) -exec $(RM) {} +
  123. $(CLEANDIRS:%=clean%):
  124. -$(FIND) $(@:clean%=%) \( -name \*~ -o -name \*.elc \) -exec $(RM) {} +
  125. cleanelc:
  126. $(MAKE) -C lisp $@
  127. cleanaddcontrib:
  128. -$(RM) $(wildcard $(addprefix lisp/,$(notdir $(wildcard contrib/lisp/*.el))))
  129. cleanlisp: cleanaddcontrib
  130. cleanlisp cleandoc:
  131. $(MAKE) -C $(@:clean%=%) clean
  132. cleandocs:
  133. $(MAKE) -C doc clean
  134. -$(FIND) doc -name \*~ -exec $(RM) {} \;
  135. cleantest:
  136. # git-annex creates non-writable directories so that the files within
  137. # them can't be removed; if rm fails, try to recover by making all
  138. # directories writable
  139. -$(RMR) $(testdir) || { \
  140. $(FIND) $(testdir) -type d -exec $(CHMOD) u+w {} + && \
  141. $(RMR) $(testdir) ; \
  142. }