EasyPG -- Tidy up and Release.
[packages] / XEmacs.rules
1 # Common Makefile material for package Makefiles
2 # Copyright (C) 1997 Free Software Foundation Inc.
3 # Copyright (C) 2002, 2003, 2005 Ben Wing.
4
5 # This file is part of XEmacs.
6
7 # XEmacs is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by the
9 # Free Software Foundation; either version 2, or (at your option) any
10 # later version.
11
12 # XEmacs is distributed in the hope that it will be useful, but WITHOUT
13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
15 # for more details.
16
17 # You should have received a copy of the GNU General Public License
18 # along with XEmacs; see the file COPYING.  If not, write to
19 # the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 # Boston, MA 02110-1301, USA.
21
22 # Requires XEmacs 21.0-beta19 or greater and GNU Make 3.78 or greater.
23
24 # Settings that a Makefile can specify (all settings need to be done
25 # BEFORE including XEmacs.rules; if you need something from Local.rules
26 # in order to determine the settings properly -- e.g. BUILD_WITHOUT_MULE --
27 # include Local.rules.inc at the top of your Makefile):
28 #
29 # At the top of every Makefile:
30 # -----------------------------
31 #
32 # VERSION = 1.10
33 # MAINTAINER = Joe Shmoe <joe@shmoe.org>, or
34 # MAINTAINER = XEmacs Development Team <xemacs-beta@xemacs.org>
35 # PACKAGE = my-package
36 # PKG_TYPE = regular or single-file (each file is a separate package)
37 # REQUIRES = list of packages that must be available to compile the .elcs
38 # CATEGORY = standard, mule, or unsupported
39 #
40 # Optionally:
41 # -----------
42 #
43 # AUTHOR_VERSION = 1.4.9
44 # PACKAGE_SUPPRESS = calls to `package-suppress' to indicate packages that
45 #  should be available only in particular versions of XEmacs, e.g.:
46 #
47 # PACKAGE_SUPPRESS = \
48 #  (package-suppress 'xemacs-base \"regexp-opt\" '(emacs-version>= 21 5 11)) \
49 #  (package-suppress 'xemacs-base \"easy-mmode\" '(emacs-version>= 21 5 11))
50 #
51 #
52 # Lisp files:
53 # -----------
54 #
55 # ELCS = .elc files to compile
56 # ELCS_1 = more .elc files to compile, to be installed in a subdirectory of
57 #   lisp/
58 # ELCS_1_DEST = name of subdirectory to install them into; include
59 #   $(PACKAGE) in the name
60 # EARLY_GENERATED_LISP = additional .el files that will be generated before
61 #   any byte-compilation (use this for autoloads-type files); rules must be
62 #   given to build them.  XEmacs.rules will automatically add auto-autoloads,
63 #   custom-load, and custom-defines to this list, so don't include them.
64 # GENERATED_LISP = additional .el files that will be generated at
65 #   byte-compilation time; rules must be given to build them
66 # PRELOADS = additional command-line arguments needed when compiling .elcs
67 # AUTOLOAD_PATH = subdirectory in source tree where .elcs are located (this
68 #   is where auto-autoloads.el, etc. will be placed)
69 #
70 # Doc files (see below):
71 # ----------------------
72 #
73 # (1) The preferred way:
74 #
75 # EXPLICIT_DOCS, STANDARD_DOCS, EXTRA_TEXI_FILES, EXTRA_HTML_FILES,
76 #   DOCS_TEXINFO_EXTENSION, DOCS_TXI_EXTENSION
77 #
78 # (2) The hard way:
79 #
80 # TEXI_FILES, INFO_FILES, INFO_DEP, HTML_FILES, HTML_DEP
81 #
82 # Also: EXTRA_DOC_FILES
83 #
84 # Other files to build:
85 # ---------------------
86 #
87 # EXTRA_DEPENDENCIES = additional files to build; rules must be given to
88 #   build them
89 #
90 # Files to install, besides the .elcs, docs, ChangeLog and _pkg.el:
91 # -----------------------------------------------------------------
92 #
93 # EXTRA_SOURCES = files installed under lisp/$(PACKAGE)
94 # LIBSRC_FILES = files installed under lib-src/
95 # DATA_FILES, DATA_DEST = files installed under a subdirectory of etc/; include
96 #   $(PACKAGE) in the name
97 # DATA_1_FILES, DATA_1_DEST ... DATA_35_FILES, DATA_35_DEST = files to be
98 #   installed in other subdirectories of etc/
99
100 XEMACS_PACKAGES_BASE := $(shell while [ ! -f XEmacs.rules ]; do \
101                                     cd ..;      \
102                                 done;           \
103                                 pwd)
104
105 include ${XEMACS_PACKAGES_BASE}/Local.rules.inc
106
107 # Ensure vanilla locale when building
108 override LANG := C
109
110 # Only in rare cases will you need to override this
111 ifeq ($(AUTOLOAD_PATH),)
112 AUTOLOAD_PATH = .
113 endif
114
115 # Set this in the package Makefile if necessary (BEFORE including this file)
116 EARLY_GENERATED_LISP := $(AUTOLOAD_PATH)/auto-autoloads.el \
117         $(AUTOLOAD_PATH)/custom-load.el $(EARLY_GENERATED_LISP)
118 ifeq ($(or $(XEMACS_21_5),$(BUILD_WITH_SXEMACS)),t)
119 EARLY_GENERATED_LISP += $(AUTOLOAD_PATH)/custom-defines.el
120 endif
121
122 EARLY_GENERATED_ELCS = $(EARLY_GENERATED_LISP:.el=.elc)
123 GENERATED_ELCS = $(GENERATED_LISP:.el=.elc)
124
125 # SOURCE_FILES_TO_COPY = *.el*
126 SOURCE_FILES_TO_COPY = $(ELCS) $(ELCS:.elc=.el) \
127         $(MULE_ELCS) $(MULE_ELCS:.elc=.el) \
128         $(EARLY_GENERATED_ELCS) $(EARLY_GENERATED_LISP) \
129         $(GENERATED_ELCS) $(GENERATED_LISP) $(AUTOLOAD_PATH)/_pkg.el
130
131 # Non configurable portion follows
132
133 # Old XEmacs ChangeLog
134 CHANGELOG_XEMACS = $(wildcard ChangeLog.XEmacs)
135
136 MANIFEST = pkginfo/MANIFEST.$(PACKAGE)
137 # This might be a sublevel PWD; that is intentional.  Use
138 # ${XEMACS_PACKAGES_BASE} for the toplevel directory.
139 PWD      := $(shell pwd)
140
141 .SUFFIXES:
142 .SUFFIXES: .html .info .txi .texi .texinfo .dvi .ps .pdf .elc .el
143
144 # STAGING is the top of the directory tree where a particular package's
145 # files are installed, or where tarballs are installed using `make bindist'.
146
147 # 'make bindist' needs STAGING to be set to NONMULE_INSTALLED_PACKAGES_ROOT
148 # if we are building a Mule package so we don't end up with 2 package-index
149 # files. 
150
151 ifeq ('$(MAKECMDGOALS)','bindist')
152 STAGING:= $(NONMULE_INSTALLED_PACKAGES_ROOT)
153 else
154  ifeq ('$(CATEGORY)','mule')
155 STAGING:= $(MULE_INSTALLED_PACKAGES_ROOT)
156  else
157 STAGING:= $(NONMULE_INSTALLED_PACKAGES_ROOT)
158  endif
159 endif
160
161 # We should strive to use XEMACS_BATCH_CLEAN as much as possible, so we have
162 # no possible contamination from outside packages.  We should rewrite the
163 # others to load the appropriate autoloads from our own built package tree.
164
165 ifeq ($(BUILD_WITHOUT_MULE),t)
166 LISP_DIRECTORIES= (list lisp-directory)
167 else
168 LISP_DIRECTORIES= (list (expand-file-name "mule" lisp-directory) lisp-directory)
169 endif
170 XEMACS_BATCH_CLEAN = $(XEMACS) -no-autoloads $(BATCH) -eval '(setq load-path $(LISP_DIRECTORIES))'
171 # The following works more or less the same and with less fuss, but only in
172 # 21.5 and above
173 # XEMACS_BATCH_CLEAN = $(XEMACS) -no-autoloads $(BATCH) -no-packages
174 XEMACS_BATCH_DIRTY = $(XEMACS) $(BATCH)
175 LOAD_AUTOLOADS= -eval '(packages-load-package-auto-autoloads load-path)'
176
177 #####################################
178 #            Handle docs            #
179 #####################################
180
181 # If something goes wrong and $(STAGING) is blank, the commands below will
182 # attempt to install files into absolute paths /lisp/* and /etc/* -- not
183 # a good idea at all.
184
185 check-staging:
186 ifeq ($(STAGING),)
187         $(error STAGING is not set; potential major filesystem trashing!  Fix this)
188 endif
189
190 check-mule:
191 ifeq ($(CATEGORY),mule)
192 ifneq ($(BUILD_WITHOUT_MULE),)
193         $(error This package needs Mule support in order to be compiled)
194 endif
195 endif
196
197 # Possibilities for building the docs:
198 #
199 # (1) EXPLICIT_DOCS = <texi files>
200 #     Build the specified .texi files.  Info and HTML files automatically
201 #     computed from the .texi files.
202 # (2) STANDARD_DOCS = t
203 #     Same as EXPLICIT_DOCS = $(PACKAGE).texi
204 # (3) Manual: Specify TEXI_FILES, INFO_FILES, INFO_DEP, HTML_FILES, and
205 #     HTML_DEP by yourself.  Do not explicitly add any doc targets to
206 #     compile::.
207 #
208 # When EXPLICIT_DOCS or STANDARD_DOCS is given:
209 #
210 # (1) you can specify other .texi files included in the files specified in
211 #     EXPLICIT_DOCS using EXTRA_TEXI_FILES (they will be listed as
212 #     dependencies of the info and html files)
213 # (2) you can specify extra .html output files using EXTRA_HTML_FILES
214 # (3) you can use `DOCS_TEXINFO_EXTENSION = t' to indicate that the
215 #     explicitly specified docs have .texinfo as the extension instead of
216 #    .texi.  Similarly for `DOCS_TXI_EXTENSION = t'.
217 #
218 # You can also specify EXTRA_DOC_FILES in all cases to indicate extra files
219 # to be copied into the man/ directory at installation time.
220
221 ifeq ($(STANDARD_DOCS),t)
222 EXPLICIT_DOCS = $(PACKAGE).texi
223 endif
224
225 ifneq ($(EXPLICIT_DOCS),)
226 ifeq ($(DOCS_TEXINFO_EXTENSION),t)
227 EXPLICIT_DOCS_AS_TEXI=$(EXPLICIT_DOCS:%.texinfo=%.texi)
228 else
229 ifeq ($(DOCS_TXI_EXTENSION),t)
230 EXPLICIT_DOCS_AS_TEXI=$(EXPLICIT_DOCS:%.txi=%.texi)
231 else
232 EXPLICIT_DOCS_AS_TEXI=$(EXPLICIT_DOCS)
233 endif
234 endif
235
236 # Ensure the correct setting of $TEXI_FILES. --SY.
237 TEXI_FILES = $(EXPLICIT_DOCS)
238 ifeq ($(DOCS_TEXINFO_EXTENSION),t)
239   TEXI_FILES = $(EXPLICIT_DOCS_AS_TEXI:%.texi=%.texinfo)
240 endif
241 ifeq ($(DOCS_TXI_EXTIONSION),t)
242   TEXI_FILES = $(EXPLICIT_DOCS_AS_TEXI:%.texi=%.txi)
243 endif
244
245 TEXI_FILES += $(EXTRA_TEXI_FILES)
246 INFO_FILES = $(EXPLICIT_DOCS_AS_TEXI:%.texi=%.info*)
247 INFO_DEP = $(EXPLICIT_DOCS_AS_TEXI:%.texi=%.info)
248
249 $(INFO_DEP): $(EXTRA_TEXI_FILES)
250
251 mostlyclean::
252         rm -f $(EXPLICIT_DOCS_AS_TEXI:%.texi=%.toc) \
253         $(EXPLICIT_DOCS_AS_TEXI:%.texi=%.aux) \
254         $(EXPLICIT_DOCS_AS_TEXI:%.texi=%.oaux) \
255         $(EXPLICIT_DOCS_AS_TEXI:%.texi=%.log) \
256         $(EXPLICIT_DOCS_AS_TEXI:%.texi=%.cp) \
257         $(EXPLICIT_DOCS_AS_TEXI:%.texi=%.cps) \
258         $(EXPLICIT_DOCS_AS_TEXI:%.texi=%.fn) \
259         $(EXPLICIT_DOCS_AS_TEXI:%.texi=%.fns) \
260         $(EXPLICIT_DOCS_AS_TEXI:%.texi=%.tp) \
261         $(EXPLICIT_DOCS_AS_TEXI:%.texi=%.tps) \
262         $(EXPLICIT_DOCS_AS_TEXI:%.texi=%.vr) \
263         $(EXPLICIT_DOCS_AS_TEXI:%.texi=%.vrs) \
264         $(EXPLICIT_DOCS_AS_TEXI:%.texi=%.pg) \
265         $(EXPLICIT_DOCS_AS_TEXI:%.texi=%.pgs) \
266         $(EXPLICIT_DOCS_AS_TEXI:%.texi=%.ky) \
267         $(EXPLICIT_DOCS_AS_TEXI:%.texi=%.kys)
268
269 clean::
270         rm -f $(EXPLICIT_DOCS_AS_TEXI:%.texi=%.dvi) \
271         $(EXPLICIT_DOCS_AS_TEXI:%.texi=%.ps)
272
273 HTML_FILES = $(EXPLICIT_DOCS_AS_TEXI:%.texi=%*.html) $(EXTRA_HTML_FILES)
274 HTML_DEP = $(EXPLICIT_DOCS_AS_TEXI:%.texi=%_toc.html)
275
276 $(HTML_DEP): $(EXTRA_TEXI_FILES)
277
278 endif
279
280 html: $(HTML_DEP)
281
282 XEMACS_BATCH_PREPARE_FOR_TEXINFO = $(XEMACS_BATCH_CLEAN) -eval '(setq load-path (append (list "$(XEMACS_PACKAGES_BASE)/xemacs-packages/texinfo" "$(XEMACS_PACKAGES_BASE)/xemacs-packages/text-modes" "$(XEMACS_PACKAGES_BASE)/xemacs-packages/xemacs-base") load-path))' $(LOAD_AUTOLOADS)
283
284 ifeq ($(XEMACS_21_5),t)
285 INFO_ENCODING = utf-8
286 else
287 INFO_ENCODING = iso-2022-7
288 endif
289
290 FORMAT_INFO_USING_XEMACS_ARGS = -l informat -l texinfmt -f texinfo-format-buffer
291
292 FORMAT_INFO_USING_XEMACS = \
293         $(XEMACS_BATCH_PREPARE_FOR_TEXINFO) -insert $< \
294         $(FORMAT_INFO_USING_XEMACS_ARGS) -f save-buffer
295
296 FORMAT_MULE_INFO_USING_XEMACS = \
297         $(XEMACS_BATCH_PREPARE_FOR_TEXINFO) -insert $< \
298                 -eval '(unless (featurep (quote mule)) (kill-emacs 0))' \
299                 -eval '(cd "$(<D)")' \
300                 $(FORMAT_INFO_USING_XEMACS_ARGS) \
301                 -eval '(setq file-coding-system (quote $(INFO_ENCODING)))' \
302                 -eval '(save-buffer 0)'
303
304 # makeinfo doesn't seem able to handle Mule-formatted files correctly, so
305 # we need to use the texinfo package. #### Switch to UTF-8 and this should
306 # go away.
307 ifeq ($(COMPILE_INFO_AS_MULE),t)
308 FORMAT_INFO = $(FORMAT_MULE_INFO_USING_XEMACS)
309 else
310 FORMAT_INFO = cd $(@D) && $(MAKEINFO) $(MAKEINFO_FLAGS) -o $(@F) $(<F)
311 endif
312
313 %-ja.info: %-ja.texi
314         $(FORMAT_MULE_INFO_USING_XEMACS)
315
316 %.info: %.txi
317         $(FORMAT_INFO)
318 %.info: %.texi
319         $(FORMAT_INFO)
320 %.info: %.texinfo
321         $(FORMAT_INFO)
322
323 ## Make sure to cd into the directory before running texi2html because it
324 ## puts its results in the current directory, not the directory of the
325 ## source file.
326
327 ifeq ($(COMPILE_INFO_AS_MULE),t)
328 ifeq ($(XEMACS_21_5),t)
329 PREPARE_MULE_UCS =
330 else
331 PREPARE_MULE_UCS = -eval '(setq load-path (append (list "$(XEMACS_PACKAGES_BASE)/mule-packages/mule-base" "$(XEMACS_PACKAGES_BASE)/mule-packages/mule-ucs/lisp" "$(XEMACS_PACKAGES_BASE)/mule-packages/latin-euro-standards") load-path))' $(LOAD_AUTOLOADS) -l tae -l un-define
332 endif
333 RUN_TEXI2HTML = for fil in $< $(EXTRA_TEXI_FILES); do \
334         $(XEMACS_BATCH_PREPARE_FOR_TEXINFO) $(PREPARE_MULE_UCS) \
335         -eval '(unless (featurep (quote mule)) (kill-emacs 0))' \
336         -eval "(find-file \"$$fil\")" \
337         -eval '(setq file-coding-system (quote utf-8))' \
338         -eval '(progn (goto-char (point-min)) (when (search-forward "@setfilename" nil t) (forward-line) (insert "@documentencoding UTF-8\n")))' \
339         -eval '(save-buffer 16)'; done && \
340         pushd $(@D) && $(TEXI2HTML) $(TEXI2HTML_FLAGS) $(<F) && popd && \
341         for fil in $< $(EXTRA_TEXI_FILES); do mv -f $$fil~ $$fil; done
342 else
343 RUN_TEXI2HTML = cd $(@D) && $(TEXI2HTML) $(TEXI2HTML_FLAGS) $(<F)
344 endif
345
346 %_toc.html: %.txi
347         $(RUN_TEXI2HTML)
348 %_toc.html: %.texi
349         $(RUN_TEXI2HTML)
350 %_toc.html: %.texinfo
351         $(RUN_TEXI2HTML)
352
353 # #### I'm not sure if this is correct.  xslt-process seems to think it
354 # needs to be run twice.
355 ifneq ($(TEXI2DVI),)
356 RUN_TEXI2DVI = cd $(@D) && $(TEXI2DVI) $(<F) && $(TEXI2DVI) $(<F)
357 else
358 RUN_TEXI2DVI = -
359 endif
360
361 %.dvi: %.txi
362         $(RUN_TEXI2DVI)
363 %.dvi: %.texi
364         $(RUN_TEXI2DVI)
365 %.dvi: %.texinfo
366         $(RUN_TEXI2DVI)
367
368 ifneq ($(TEXI2PDF),)
369 RUN_TEXI2PDF = cd $(@D) && $(TEXI2PDF) $(<F)
370 else
371 RUN_TEXI2PDF = -
372 endif
373
374 %.pdf: %.txi
375         $(RUN_TEXI2PDF)
376 %.pdf: %.texi
377         $(RUN_TEXI2PDF)
378 %.pdf: %.texinfo
379         $(RUN_TEXI2PDF)