targets.mk 4.6 KB

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