targets.mk 4.5 KB

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