Merge branch 'maint'
[org-mode.git] / mk / targets.mk
blob0ccb6eafb8f018de85de68ee4ce62e0be72d8ae9
1 .EXPORT_ALL_VARIABLES:
2 .NOTPARALLEL: .PHONY
3 # Additional distribution files
4 DISTFILES_extra= Makefile request-assign-future.txt contrib etc
6 LISPDIRS = lisp
7 OTHERDIRS = doc etc
8 CLEANDIRS = contrib testing mk
9 SUBDIRS = $(OTHERDIRS) $(LISPDIRS)
10 INSTSUB = $(SUBDIRS:%=install-%)
11 ORG_MAKE_DOC ?= info html pdf
13 ifneq ($(wildcard .git),)
14 GITVERSION ?= $(shell git describe --match release\* --abbrev=6 HEAD)
15 ORGVERSION ?= $(subst release_,,$(shell git describe --match release\* --abbrev=0 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 ifneq ($(GITSTATUS),)
24 GITVERSION := $(GITVERSION:.dirty=).dirty
25 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 cleanaddcontrib \
32 cleanlisp cleandoc cleandocs cleantest \
33 compile compile-dirty uncompiled \
34 config config-test config-exe config-all config-eol config-version \
35 vanilla
37 CONF_BASE = EMACS DESTDIR ORGCM ORG_MAKE_DOC
38 CONF_DEST = lispdir infodir datadir testdir
39 CONF_TEST = BTEST_PRE BTEST_POST BTEST_OB_LANGUAGES BTEST_EXTRA BTEST_RE
40 CONF_EXEC = CP MKDIR RM RMR FIND CHMOD SUDO PDFTEX TEXI2PDF TEXI2HTML MAKEINFO INSTALL_INFO
41 CONF_CALL = BATCH BATCHL ELC ELCDIR NOBATCH 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 $(notdir \
51 $(wildcard \
52 $(addsuffix .el, \
53 $(addprefix contrib/lisp/, \
54 $(basename \
55 $(notdir $(ORG_ADD_CONTRIB))))))))
56 config-test config-all::
57 $(info )
58 $(info ========= Test configuration)
59 $(foreach var,$(CONF_TEST),$(info $(var) = $($(var))$(EOL)))
60 config-exe config-all::
61 $(info )
62 $(info ========= Executables used by make)
63 $(foreach var,$(CONF_EXEC),$(info $(var) = $($(var))$(EOL)))
64 config-cmd config-all::
65 $(info )
66 $(info ========= Commands used by make)
67 $(foreach var,$(CONF_CALL),$(info $(var) = $($(var))$(EOL)))
68 config config-test config-exe config-all config-version::
69 $(info ========= Org version)
70 $(info make: Org-mode version $(ORGVERSION) ($(GITVERSION) => $(lispdir)))
71 @echo ""
73 oldorg: compile info # what the old makefile did when no target was specified
74 uncompiled: cleanlisp autoloads # for developing
75 refcard: card
76 update update2:: up0 all
78 single: ORGCM=single
79 single: compile
81 .PRECIOUS: local.mk
82 local.mk:
83 $(info ======================================================)
84 $(info = Invoke "make help" for a synopsis of make targets. =)
85 $(info = Created a default local.mk template. =)
86 $(info = Setting "oldorg" as the default target. =)
87 $(info = Please adapt local.mk to your local setup! =)
88 $(info ======================================================)
89 -@$(MAKE_LOCAL_MK)
91 all compile::
92 $(foreach dir, doc lisp, $(MAKE) -C $(dir) clean;)
93 compile compile-dirty::
94 $(MAKE) -C lisp $@
95 all clean-install::
96 $(foreach dir, $(SUBDIRS), $(MAKE) -C $(dir) $@;)
98 vanilla:
99 -@$(NOBATCH) &
101 check test:: compile
102 check test test-dirty::
103 -$(MKDIR) $(testdir)
104 TMPDIR=$(testdir) $(BTEST)
105 ifeq ($(TEST_NO_AUTOCLEAN),) # define this variable to leave $(testdir) around for inspection
106 $(MAKE) cleantest
107 endif
109 up0:: cleanaddcontrib
110 up0 up1 up2::
111 git checkout $(GIT_BRANCH)
112 git remote update
113 git pull
114 up1 up2:: all
115 $(MAKE) test-dirty
116 up2 update2::
117 $(SUDO) $(MAKE) install
119 install: $(INSTSUB)
121 install-info: install-doc
123 doc docs: $(ORG_MAKE_DOC)
125 info html pdf card:
126 $(MAKE) -C doc $@
128 $(INSTSUB):
129 $(MAKE) -C $(@:install-%=%) install
131 autoloads: lisp
132 $(MAKE) -C $< $@
134 cleandirs:
135 $(foreach dir, $(SUBDIRS), $(MAKE) -C $(dir) cleanall;)
137 clean: cleanlisp cleandoc
139 cleanall: cleandirs cleantest cleanaddcontrib
140 -$(FIND) . \( -name \*~ -o -name \*# -o -name .#\* \) -exec $(RM) {} +
141 -$(FIND) $(CLEANDIRS) \( -name \*~ -o -name \*.elc \) -exec $(RM) {} +
143 $(CLEANDIRS:%=clean%):
144 -$(FIND) $(@:clean%=%) \( -name \*~ -o -name \*.elc \) -exec $(RM) {} +
146 cleanelc:
147 $(MAKE) -C lisp $@
149 cleanaddcontrib:
150 -$(RM) $(wildcard $(addprefix lisp/,$(notdir $(wildcard contrib/lisp/*.el))))
152 cleanlisp: cleanaddcontrib
153 cleanlisp cleandoc:
154 $(MAKE) -C $(@:clean%=%) clean
156 cleandocs:
157 $(MAKE) -C doc clean
158 -$(FIND) doc -name \*~ -exec $(RM) {} \;
160 cleantest:
161 # git-annex creates non-writable directories so that the files within
162 # them can't be removed; if rm fails, try to recover by making all
163 # directories writable
164 -$(RMR) $(testdir) || { \
165 $(FIND) $(testdir) -type d -exec $(CHMOD) u+w {} + && \
166 $(RMR) $(testdir) ; \