targets.mk 4.4 KB

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