Fix cross-reference in lispref/packaging.texi
[sxemacs] / info / lispref / packaging.texi
1 @c -*-texinfo-*-
2 @c This is part of the XEmacs Lisp Reference Manual.
3 @c Copyright (C) 2001 Free Software Foundation, Inc.
4 @c See the file lispref.texi for copying conditions.
5
6 @setfilename ../../info/packaging.info
7
8 @c Macro to make formatting of the XEmacs pms name consistent.
9 @c Maybe @sc looks OK in HTML?  If so, condition on Info.
10 @iftex
11 @macro xpms
12 XE@sc{macs} Packaging System
13 @end macro
14 @end iftex
15 @ifnottex
16 @macro xpms
17 XEmacs Packaging System
18 @end macro
19 @end ifnottex
20
21 @node Packaging, Lisp Data Types, Introduction, Top
22 @chapter The @xpms{}
23 @cindex package
24 @cindex packaging
25
26 The XEmacs distribution, starting with version 21, comes only with a
27 very basic set of built-in modes and libraries.  Most of the libraries
28 that were part of the distribution of earlier versions of XEmacs are now
29 available separately.  The user as well as the system administrator can
30 choose which packages to install; the actual installation process is
31 easy.  This gives an installer the ability to tailor an XEmacs
32 installation for local needs with safe removal of unnecessary code.
33
34 This chapter describes how to package Lisp libraries for use with the
35 @xpms{}.
36
37 @emph{Please note carefully} that the term @dfn{package} as used in
38 XEmacs refers to an aggregation of Lisp code and/or data distributed as
39 a unit.  It does not, as it does in many Lisps, refer to a way of
40 creating separate name spaces.  XEmacs has no facility for providing
41 separate name spaces.  (If we ever do get separate name spaces, we'll
42 probably regret overloading the nomenclature in this way, but it's
43 become established.)
44
45 @menu
46 Introduction:
47 * Package Overview::            Lisp Libraries and Packages.
48
49 Packaging Lisp Libraries:
50 * Package Terminology::         Basic stuff.
51 * Building Packages::           Turn packaged source into a tarball.
52 * Makefile Targets::            Package @file{Makefile} targets
53 * Local.rules File::            Tell the @xpms{} about your host.
54 * Creating Packages::           Tell the @xpms{} about your package.
55 * Documenting Packages::        Explain your package to users and hackers.
56 @c * History::                     History of the @xpms{}
57 @c * Installation::                Installing the @xpms{} with your (X)Emacs.
58 @c * Configuration::               Configuring the @xpms{} for use.
59 @c * Usage::                       An overview of the operation of the @xpms{}.
60 @c * Bug Reports::                 Reporting Bugs and Problems
61 @c * Frequently Asked Questions::  Questions and answers from the mailing list.
62
63 Internals and Package Release Engineering:
64 * Issues::
65 @end menu
66
67 @node Package Overview, Package Terminology, , Packaging
68 @chapter An overview of the @xpms{}
69
70 The @xpms{} is a system for administering the installation, upgrade, and
71 removal of Lisp libraries.  For the end user, it provides facilities for
72 determining availability of packages and which versions at remote
73 sites.  It will download and automatically install a package, ensuring
74 that any old files from previous versions of the package are removed
75 first.  By providing a standard set of hierarchies for installation, it
76 makes configuration of XEmacs simpler.  Furthermore, packages normally
77 provide ancillary auto-autoloads and custom-loads libraries, which are
78 automatically detected and loaded by XEmacs upon startup.  This means
79 that once installed, all facilities of package, including autoloading
80 the library upon invocation of a command provided by the library and
81 convenient configuration and customization, are automatically available
82 to the user.  There is no need to add autoloads or keybindings to in the
83 init file, and structured configuration of the package is available
84 through the Customize system even before the libraries are loaded.
85
86 All of this convenience comes at a cost.  The cost of administration at
87 the package level is negligible compared to the benefits, of course.
88 However, the requirement that XEmacs find and load auto-autoloads and
89 custom-loads libraries comes at a fairly large cost in startup time.  In
90 order to reduce this cost, XEmacs imposes fairly strict conditions on
91 the structure of an installed package.
92
93 Meeting these requirements, as well as simply providing the
94 auto-autoloads and the information about availability and so on does
95 impose some costs on the library maintainer.  The @xpms{} also provides
96 structure and utilities to the library maintainer to make these tasks
97 easier.  This manual documents the requirements and the tools that the
98 @xpms{} provides to ensure that a package satisfies them.
99
100 @menu
101 * The User View::
102 * The Library Maintainer View::
103 * The Package Release Engineer View::
104 @end menu
105
106
107 @node The User View, The Library Maintainer View, , Package Overview
108 @section The User View
109
110 @strong{N.B.}  Much of the discussion in this section undoubtedly
111 belongs elsewhere, @ref{Packages,,,xemacs}.
112
113 From the user's point of view, an XEmacs binary package is simply a
114 standard tarball (usually gzipped) containing Lisp sources, compiled
115 Lisp, documentation, and possibly data files or supporting executables.
116 The tarball is unpacked using standard tools such as GNU tar and gzip.
117 The package system does impose certain requirements for automatic
118 configuration to work.
119
120 Here the main consideration is that the tarball ``expects'' to be
121 unpacked from the top of a package hierarchy.  A @dfn{package hierarchy}
122 is basically an image of a classic Emacs ``run-in-place'' tree, with
123 @file{lisp}, @file{etc}, @file{info}, @file{man}, @file{lib-src}, and
124 @file{pkginfo} subdirectories of the top.  The @file{pkginfo}
125 subdirectory is for use by the @xpms{} administration tools, and
126 currently contains a @file{MANIFEST.@var{package-name}} file for each
127 package to ensure that no cruft remains when a package is removed or
128 updated.  The @file{lisp}, @file{etc}, and @file{lib-src} subdirectories
129 are further subdivided, with a subdirectory for each package.  The
130 @file{info} directory obeys the usual conventions.
131 @emph{I.e.}, the @file{info} directory is flat
132 with a(n) (optional) @file{dir} file and one (set of) info file(s) per
133 package.  The @file{man} subdirectory typically contains documentation
134 sources, separated by package.  (It does not contain @file{man(1)}
135 pages, as Emacs provides very few of them.)
136
137 There are several standard package hierarchies, and administrators can
138 configure others at build time, while users can configure others at
139 run time.  The standard system hierarchies are all subdirectories of
140 @file{$@{PREFIX@}/share/sxemacs/}.  These are the @file{site-packages},
141 @file{xemacs-packages}, @file{mule-packages},
142 @file{infodock-packages}, and @file{sxemacs-packages} hierarchies.
143 Each has the structure described above, but the purposes differ.  The
144 @file{xemacs-packages} is the normal place for installing ``official''
145 packages and many third-party libraries.  Unfortunately, it is not yet
146 quite possible to read libraries containing international characters
147 with a non-Mule SXEmacs, so such libraries are sequestered in the
148 @file{mule-packages} hierarchy.  Some packages are compatible only
149 with the Infodock development environment, and they will be installed
150 in the @file{infodock-packages} hierarchy.  The @file{site-packages}
151 hierarchy is for packages not distributed by XEmacs.org, typically
152 locally developed.
153
154 @c Really don't think this is right --SY
155 @c Packages are in principle supposed to be XEmacs version-independent, but
156 @c if such dependencies are unavoidable, additional standard package
157 @c hierarchies may be installed under version directories, @emph{e.g.}
158 @c @file{/usr/local/lib/xemacs-21.4.6/}.
159
160 Users who do not have sufficient privilege to install packages in the
161 system hierarchies may install package hierarchies under
162 @file{@var{$XDG_DATA_HOME}/sxemacs}.  At present only the
163 @file{site-packages}, @file{xemacs-packages}, @file{mule-packages},
164 and @file{sxemacs-packages} hierarchies are supported, but it might
165 make sense to extend this to support @file{infodock-packages}
166 hierarchies in the future.
167
168 The package hierarchies are not searched directly for libraries to be
169 loaded; this would be very costly.  Instead, the hierarchies are ordered
170 according to certain rules, and searched for package lisp directories at
171 invocation.  These directories are added to the general
172 @code{load-path}.  As usual, it is @code{load-path} that is searched at
173 run-time.  This approach is somewhat costly at initialization, but
174 results in a very ``clean'' @code{load-path}.
175
176 The order of search can be changed at build time by specifying the
177 @samp{--with-package-path} option to @file{configure}, or at run-time by
178 specifying the @code{EMACSPACKAGEPATH} environment variable.
179 @xref{Packages,,,sxemacs}
180 Also, the location for @code{early-packages} may be set via the
181 @code{-user-pkgs-directory} command line argument (@pxref{Command Switches,,,sxemacs}).
182
183 @c #### The following description is quite possibly inaccurate.
184 @c Please, Michael, write some specs up!
185 The default order of search is hierarchically determined.  There are 3
186 ``categories'' of lisp hierarchies in SXEmacs, well, actually there are
187 4, but we'll get to that in a moment.  In order, they are:
188 @code{early-packages}, @code{late-packages}, and @dfn{core}.
189
190 The @code{early-packages} are the user's local packages, stored
191 under their @var{$HOME}.  Typically, these packages will be in
192 @file{@var{$XDG_DATA_HOME}/sxemacs}.  The @code{late-packages} are the
193 ``system-wide'' packages, typically installed in
194 @file{@var{$PREFIX}/share/sxemacs}, and @dfn{core} is the lisp that is
195 shipped with SXEmacs and installed to
196 @file{@var{$PREFIX}/share/sxemacs-@var{$version}}.
197
198 The @code{early-packages} and @code{late-packages} are further split
199 into @dfn{package types}.  These types are (in search order):
200 @file{site-packages}, @file{sxemacs-packages},
201 @file{infodock-packages}, @file{mule-packages}, and
202 @file{xemacs-packages}.
203
204 The @dfn{core} lisp is also sub-divided into @file{mule}, @file{ffi},
205 and ``normal'', and searched in that order.
206
207 Oh, that 4th category I spoke of earlier, those are the
208 @file{last-packages}.  By default, SXEmacs does not have a
209 pre-configured @dfn{last} package hierarchy.  Last hierarchies are
210 primarily for using package hierarchies of outdated versions of XEmacs
211 as a fallback option.  For example, it is possible to run SXEmacs with
212 the XEmacs 20.4 package hierarchy as a last hierarchy.
213
214 In each hierarchy there should be a @file{lisp} subdirectory, containing
215 directories named for the packages.  Each package's Lisp libraries thus
216 are contained in a directory of the form
217 @var{category}/@var{type}/lisp/@var{package}/.  The 3 directories that
218 make up the @dfn{core lisp} are, in search order@dots{}
219
220 @smallexample
221 @var{$PREFIX}/share/sxemacs-@var{version}/lisp/mule
222 @var{$PREFIX}/share/sxemacs-@var{version}/lisp/ffi
223 @var{$PREFIX}/share/sxemacs-@var{version}/lisp
224 @end smallexample
225
226 With such a complex search algorithm, the possibility of libraries being
227 shadowed by another library with the same name is quite real.  There are
228 two considerations here.  First, every SXEmacs package contains certain
229 libraries with constant names.  These are
230
231 @table @file
232 @item _pkg.el
233 Lisp code to inform the package administration system about the package
234
235 @item auto-autoloads.el
236 Lisp code to set up autoloaded functions and variables that may be
237 needed at load time
238
239 @item custom-load.el
240 definitions of configuration variables for use with the Customize
241 system.
242 @end table
243
244 They are special-cased, because the way they are used prevents shadowing
245 from being an issue.
246
247 Second, it is possible that multiple copies of some library, or
248 different libraries with the same name, are installed in various places
249 in the hierarchies.  To detect such shadows, use
250 @code{list-load-path-shadows}.
251
252 Finally, note that most basic Emacs functionality, including most of the
253 Lisp API, is implemented in Lisp libraries.  Because they use internal
254 reserved APIs that are subject to change according the needs of the
255 developers, these libraries are distributed with the XEmacs binary, and
256 are called @dfn{core Lisp libraries}.  Most core Lisp libraries are
257 ``preloaded'' into the Emacs binary and in normal usage are never
258 explicitly loaded.  However, they can be explicitly loaded, and if so
259 they are searched on @code{load-path}.
260 @c #### Is this correct?  It is not for C-h f, for example.
261 Furthermore, functions such as @code{locate-library} will also search on
262 the @code{load-path}.  The searching takes place under somewhat
263 different rules from those used for packaged Lisp.  It is probably
264 easiest to think of the package hierarchy searching algorithm as
265 receiving a @code{load-path} initialized to the core Lisp directories.
266
267
268 @node The Library Maintainer View, The Package Release Engineer View, The User View, Package Overview
269 @section The Library Maintainer View
270
271 From the library maintainer's viewpoint, the advantages to the @xpms{}
272 stem from the convenience to the user of installation and upgrade.
273 Since an installed package automatically registers its entry points via
274 autoload and its configuration variables with the Customize system,
275 configuration FAQs are reduced.  When it's easy to upgrade, users learn
276 to try @samp{Tools | Packages | Update Installed Packages} before
277 posting a FAQ whose answer is ``long since fixed, please upgrade.''
278
279 This comes at some cost, as the library maintainer needs to arrange that
280 the package be installed in a directory structure that satisfies the
281 requirements of the @xpms{}.  Autoload cookies and defcustoms must also
282 be added to existing libraries.  The @xpms{} provides infrastructure to
283 assure that all of these annoyances need only be dealt with once.  The
284 autoload cookies and defcustoms are beyond the scope of this chapter, but
285 most maintainers of modern packages are already familiar with these
286 mechanisms.
287
288 The @xpms{} may be divided into the @dfn{infrastructure} common to all
289 packages, and the package-specific @dfn{control files}.  The
290 infrastructure supports global builds, installation, and generation of
291 the ``sumo'' bundles of packages, as well as generation of individual
292 packages.  The package control files describe the structure of the
293 package's source tree and provide administrative information.
294
295 @menu
296 * Infrastructure::              Global Makefiles and common rules.
297 * Control Files::               Package-specific Makefiles and administrative files.
298 * Obtaining::                   Obtaining the @xpms{} and required utilities.
299 @end menu
300
301 @node Infrastructure, Control Files, , The Library Maintainer View
302 @subsection Infrastructure
303
304 In order to get the greatest benefit from the @xpms{}, a library
305 maintainer should place the package sources in an appropriate place in
306 the XEmacs source package hierarchy, and arrange to have the source
307 package imported into the XEmacs CVS repository.
308 @c #### the parenthetical remark should go to "issues."
309 (We realize that the
310 latter requirement can be quite burdensome.  We are working on ways to
311 remove this requirement, but for the present it remains necessary.)  The
312 library maintainer must also keep sources for any packages his/her
313 package requires.  This requirement is somewhat burdensome, but unlikely
314 to be relaxed because of the implementation of compilation of macros in
315 Emacs Lisp.  Macros cannot be called by compiled Lisp (the macro
316 expansion, which is always known at compile time, is inlined), so the
317 source of the macro must be loaded before compiling the called function.
318
319 The source package hierarchy may be rooted anywhere.  The CVS module is
320 called ``packages,'' so we will refer to the top directory of the source
321 package hierarchy as ``the @file{packages} directory.''  The
322 @file{packages} directory contains two source subdirectories,
323 @file{xemacs-packages} and @file{mule-packages} (for convenience in
324 segregating the packages which depend on Mule, as they will cause
325 load-time errors in a non-Mule XEmacs).  Each subdirectory contains many
326 package source directories, whose internal structure is not specified.
327 That structure is left up to the convenience of the library maintainers.
328 The requirements on the top directory of an individual package source
329 tree are given below, @ref{Control Files}.
330
331 The @file{packages} directory contains some auxiliary Lisp libraries
332 used in the compilation and packaging process.  The content of these
333 libraries is of interest primarily to the packaging engineers, @ref{The
334 Package Release Engineer View}.
335
336 Finally, the @file{packages}, @file{packages/xemacs-packages}, and
337 @file{packages/mule-packages} directories contain @file{Makefile}s and
338 include files to control the package creation process.  The
339 @file{Makefile}s in @file{packages/xemacs-packages} and
340 @file{packages/mule-packages} simply define the default sets of known
341 packages and include @file{../iterate.rules}, which implements recursive
342 building of all target packages.
343
344 The @samp{make} infrastructure in @file{packages} includes
345
346 @table @file
347 @item Makefile
348 controls building of individual packages, local installation, and
349 bundling of ``sumo'' tarballs
350
351 @item iterate.rules
352 controls recursive builds of multiple packages
353
354 @item meta-iterate.rules
355 This is used by higher-level subdirectories that do not directly
356 contain packages.  Subdirectories directly containing packages should
357 use iterate.rules instead.
358
359 @item XEmacs.rules
360 provides the rules for building and packaging.  Included by all package
361 @file{Makefile}s.
362
363 @item Local.rules
364 provides local configuration, such as installation targets and staging
365 directories, as well as a number of kludges (many now obsolete) required
366 for building packages on the Windows platform.
367
368 @item Local.rules.template
369 a template for Local.rules, liberally commented
370
371 @item Local.rules.mk
372 consistency checking for @file{Local.rules}, included by both the
373 top-level @file{Makefile} and by @file{XEmacs.rules}.
374
375 @item Local.rules.inc
376 a file to @code{include} in package @file{Makefile}s to be able to get
377 at variables in @file{Local.rules} @emph{before} including
378 @file{XEmacs.rules}.
379
380 @c #### Add to "issues"
381 @item package-compile.el
382 compile environment (@emph{e.g.}, load-path) setup.
383 @end table
384
385 Of these, only @file{Local.rules} and @file{package-compile.el} need to
386 be modified by the library maintainer.  The changes to Local.rules
387 affect only your environment.  This should need to be done only once
388 when first preparing the source environment.  The necessary
389 modifications to @file{package-compile.el} need to be done for each
390 package and are discussed in the next section, @ref{Control Files}.
391
392
393 @node Control Files, Obtaining, Infrastructure, The Library Maintainer View
394 @subsection Control Files
395
396 Each package source must contain a number of control files in the
397 top-level directory.  These files in general can be created and then
398 ignored, except for a few variables that need to be updated when new
399 versions are released.  In most cases even adding, renaming, and
400 removing library source files can be handled by generic rules.
401
402 The package control files include
403
404 @table @file
405 @item Makefile
406 Must set a few @file{make} variables used by the administrative
407 utilities, and defines a couple of package-building targets to depend on
408 appropriate targets defined generically in @file{XEmacs.rules}.  It may
409 also provide various variables and rules to transform the source tree
410 structure into that expected by the run-time system.
411
412 @item package-info.in
413 Provides a template for package information to be provided to the
414 administrative utilities.  Static variables that are rarely changed
415 (such as the package's name) are entered as literals.  Some variables
416 are generated by the build process (build dates and MD5 checksums) and
417 are automatically filled in.  Finally, some variables that change
418 irregularly (dependences and even version numbers) are set as
419 @file{make} variables in the @file{Makefile}.
420
421 @item ChangeLog
422 Not strictly required, but normally a ChangeLog will be added by the
423 XEmacs package maintainer if different from the upstream maintainer.
424
425 @item _pkg.el
426 Generated.  Simply does a @code{package-provide} for the package.
427
428 @item auto-autoloads.el
429 Generated.  Read when XEmacs is initialized, and provides autoloads for
430 defuns and other forms in the sources that are marked with an
431 @dfn{autoload cookie} (@samp{;;;###autoload}.
432
433 @item custom-loads.el
434 Generated.  Read when XEmacs is initialized, and informs the Customize
435 subsystem how to find the defcustom forms needed to create Customization
436 forms for the usre configuration variables of the package.
437 @end table
438
439
440 @node Obtaining, , Control Files, The Library Maintainer View
441 @subsection Obtaining the @xpms{} and Required Utilities
442
443 Currently both the infrastructure for creating XEmacs packages and the
444 package sources themselves are available only by CVS.  See
445 @uref{http://www.xemacs.org/Develop/cvsaccess.html} for more
446 intformation.
447
448 The @xpms{} currently requires GNU @file{make}, and XEmacs, to build
449 packages.
450
451
452 @node The Package Release Engineer View, , The Library Maintainer View, Package Overview
453 @subsection The Package Release Engineer View
454
455 The XEmacs Package Release Engineer is responsible for keeping the
456 system coherent.  The changes to @file{packages/package-compile.el} and
457 @file{packages/xemacs-packages/Makefile} required to make the package
458 available to others, and for building SUMO tarballs, @emph{etc}, are
459 done by the Package Release Engineer, not individual library
460 maintainers.
461
462 The Package Release Engineer also maintains assorted infrastructure for
463 actually making releases.  These are generally available for inspection
464 in the @code{xemacs-builds} module in the CVS repository.
465
466 @c #### To be completed.
467
468
469 @node Package Terminology, Building Packages, Package Overview, Packaging
470 @comment  node-name,  next,  previous,  up
471 @heading Package Terminology:
472
473 @subsection Libraries and Packages
474 @cindex library
475 @cindex package
476
477 A Lisp @dfn{library} is a single loadable file containing Lisp code.  It
478 may be in source or byte-compiled form.  A Lisp @dfn{package} is a set
479 of one or more libraries, usually related to each other in some way,
480 bundled with administrative information for convenient distribution.
481
482 @subsection Package Flavors
483
484 There are two main flavors of packages.
485
486 @table @strong
487 @item Regular Packages
488 @cindex regular package
489 A regular package is a set of Lisp libraries design to cooperate with
490 one another.  A very complex example is Gnus.  One may not in general
491 safely remove any of the component libraries.
492
493 @item Single-File Packages
494 @cindex single-file package
495 A single-file package is a collection of thematically related but
496 otherwise independent Lisp libraries.  These libraries are bundled
497 together for convenience of the maintainers.  Usually individual
498 libraries may be deleted at will without any loss of functionality of
499 other libraries in the package.  However, we would recommend that you
500 follow this rule of thumb: "When in doubt, don't delete".  If it's
501 really that big a deal, request that the maintainers split the package
502 into smaller aggregations.
503 @end table
504
505 @subsection Package Distributions
506 @cindex package distributions
507 @cindex binary packages
508 @cindex source packages
509 XEmacs Lisp packages are distributed in two ways.  @dfn{Binary packages}
510 are used by system administrators and end users.  They are packaged in a
511 form convenient for direct installation into an XEmacs package
512 hierarchy.  @dfn{Source packages} are for developers and include all
513 files necessary for rebuilding byte-compiled lisp and creating tarballs
514 for distribution or installation.  This is all of the package author's
515 source code plus all of the files necessary to build distribution
516 tarballs (Unix Tar format files, gzipped for space savings).
517 (Occasionally sources that are not relevant to XEmacs are usually
518 renamed to @file{file.upstream}.)
519
520 Currently, source packages are only available via CVS.  See
521 @url{http://www.xemacs.org/Develop/cvsaccess.html} for details.
522
523 The package distributions are also split according to major features
524 required in XEmacs to support them.  At present there are @dfn{generic}
525 packages, which can be loaded by @emph{any} XEmacs, and @dfn{Mule}
526 packages, which @emph{require} Mule support or they will cause errors
527 when loaded.  Note that there is no guarantee that a generic package
528 will have any useful functionality in a minimally configured XEmacs.  As
529 long as any XEmacs can successfully load the package's libraries
530 (perhaps given other required Lisp libraries), it will be classified as
531 generic.  At the present time only Mule packages need be treated
532 specially, and even those only if they contain multibyte characters.
533
534
535 @node Building Packages, Makefile Targets, Package Terminology, Packaging
536 @comment  node-name,  next,  previous,  up
537 @cindex building packages
538 @cindex package building
539 @heading Building Packages:
540 Currently, source packages are only available via anonymous CVS.  See
541 @url{http://www.xemacs.org/Develop/cvsaccess.html} for details of
542 checking out the @file{packages} module.
543
544 @subsection Prerequisites for Building Source Packages
545
546 @table @code
547 @item GNU cp
548 @item GNU install
549 (or a BSD compatible install program).
550 @item GNU make
551 (3.79 or later preferred).
552 @item makeinfo
553 (4.2 from texinfo-4.2)
554 @item GNU tar
555 (or equivalent).
556 @item GNU gzip
557 (or equivalent).
558 @item A properly configured @file{Local.rules} file.
559 @ref{Local.rules File}.
560 @end table
561
562 And of course, XEmacs, 21.0 or higher.
563
564 @section What You Can Do With Source Packages
565
566 The packages CVS sources are most useful for creating XEmacs package
567 tarballs for installation into your own XEmacs installations or for
568 distributing to others.
569
570 It should be noted that most of the package @file{Makefile}s do
571 @emph{not} need to contain @emph{any} target rules.  Everything is
572 handled from the @file{XEmacs.rules} file, located in the toplevel
573 directory of the packages source tree.
574
575
576 @node Makefile Targets, Local.rules File, Building Packages, Packaging
577 @cindex package makefile targets
578 @chapter @file{Makefile} targets
579 The following targets can be used when running @code{make} to build the
580 packages:
581
582 @table @samp
583 @item mostlyclean
584 Removes any documentation files that have been processed by @TeX{}.
585
586 @item clean
587 Does a @code{mostlyclean}, plus removes generated postscript and dvi
588 files.  Also removes any generated .elc files, along with the normal
589 .elc files in the package and HTML and .info files.
590
591 @item distclean
592 Use this when preparing a distribution.  It kills anything that can be
593 rebuilt.
594
595 @item extraclean
596 Does a @code{distclean} and also removes any backup files (@file{*~})
597 and @file{core} files.
598
599 @item package-info
600 Creates the @file{package-info} file from the @file{package-info.in} and
601 writes an entry in the @file{package-index} file.
602
603 @item bindist
604 Builds the package, including any Texinfo documentation (info format),
605 writes an entry into the @file{package-index} file and builds a tarball
606 of the package.  Also writes an entry into @file{setup-packages.ini}
607 which is later used in the creation of netinstaller's @file{setup.ini}.
608
609 @item install
610 Builds and installs a package
611
612 @item install-only
613 Doesn't build anything, just installs it.
614
615 @item autoloads
616 Generate the package's @file{auto-autoloads.el} file.
617
618 @item binkit
619 Creates the directories needed for installation and copies the files
620 there.  Basically this is an alias for @code{install-only}.
621
622 @item html
623 Builds the HTML versions of the documentation.
624
625 @item compile
626 Does most of the work.  Builds the elcs, infos at a minimum.
627 @end table
628
629 @section The targets that most people would be interested in would be:
630
631 @itemize @bullet
632 @item @code{all}
633 @item @code{bindist}
634 @item @code{html}
635 @item @code{install}
636 @item @code{install-only}
637 @item @code{clean}
638 @item @code{distclean}
639 @end itemize
640
641
642 @node Local.rules File, Creating Packages, Makefile Targets, Packaging
643 @comment  node-name,  next,  previous,  up
644 @cindex local.rules
645 @heading The Local.rules File:
646 This file in @file{packages} provides the @xpms{} with information about
647 the local configuration and environment.  To create @file{Local.rules},
648 simply copy @file{Local.rules.template} from that directory to
649 @file{Local.rules} and edit it to suit your needs.
650
651 These are the variables in @file{Local.rules} that you may need to
652 provide values for:
653
654 @table @samp
655 @item XEMACS
656 The name (and path if needed) of the XEmacs binary to use for building
657 the packages.  The default is @code{xemacs}.
658
659 @item XEMACS_21_5
660 This will enable some, as yet, unimplemented features in XEmacs 21.5 and
661 above.  For now leave this blank (the default) regardless of the XEmacs
662 version you are using.
663
664 @item BUILD_WITHOUT_MULE
665 Set this to @samp{t} if you are using a non-Mule XEmacs.  The default is
666 that this variable is not set (blank) which means to build @emph{with}
667 Mule.
668
669 @item XEMACS_NATIVE_NT
670 Set this to @samp{t} if you are using a native Microsoft Windows build
671 of XEmacs (not a Cygwin build) to build the packages.
672 @strong{N.B.} To Windows users, you still need the Cygwin environment to
673 actually build the packages.
674
675 @item XEMACS_INSTALLED_PACKAGES_ROOT
676 Set this to the root of where you want the packages to be installed.
677 Under this directory will hang @file{xemacs-packages} and
678 @file{mule-packages}.  See @var{NONMULE_INSTALLED_PACKAGES_ROOT} and
679 @var{MULE_INSTALLED_PACKAGES_ROOT}.  The default for this is
680 @file{/usr/local/lib/xemacs}.  Which may not be what you want if you are
681 developing XEmacs.  To quote the comments in
682 @file{Local.rules.template}:
683
684 @quotation
685 If you are developing XEmacs, you probably don't want to install the
686 packages under /usr/local, which is where the stable, released version
687 of XEmacs goes.  Instead, we suggest a layout as described in the base
688 README file of recent versions of XEmacs.  In a nutshell, we suggest
689 you put your source under /src/xemacs, and under this put the package
690 sources in package-src/, and the installed packages in xemacs-packages/
691 and mule-packages/.  If you do everything this way, you might want to
692 set things as follows:
693
694 XEMACS_INSTALLED_PACKAGES_ROOT = $@{XEMACS_PACKAGES_BASE@}/..
695
696 which puts the xemacs-packages/ and mule-packages/ directories as sisters
697 of the package-src/ directory, and you have to tell configure the location
698 of the installed packages using `--package-path', something like
699
700 configure --package-path=/src/xemacs/xemacs-packages;/src/xemacs/mule-packages
701 @end quotation
702
703 @item symlink
704 The default is unset (blank).  If you set this to @samp{t} then
705 @code{make install} will create a @dfn{symlink farm} of the installed
706 packages under @var{XEMACS_INSTALLED_PACKAGES_ROOT}.  Obviously, for
707 this to work, your system has to support symbolic links.  This is as
708 close as you can get to @dfn{running in place} for the packages.
709
710 @item NONMULE_INSTALLED_PACKAGES_ROOT
711 This is where the non-Mule packages get installed to.  The default is
712 @file{$@{XEMACS_INSTALLED_PACKAGES_ROOT@}/xemacs-packages}.
713
714 @item MULE_INSTALLED_PACKAGES_ROOT
715 This is where the Mule packages get installed to.  The default is
716 @file{$@{XEMACS_INSTALLED_PACKAGES_ROOT@}/mule-packages}.
717
718 @item NONMULE_PACKAGES
719 A whitespace separated list of non-Mule packages to build/install.
720
721 @example
722 NONMULE_PACKAGES = bbdb gnus xemacs-base prog-modes
723 @end example
724
725 The value for this variable can also be the symbol
726 @samp{xemacs-packages}, which means to build/install @emph{all} of the
727 non-Mule packages.  The default is @samp{xemacs-packages}.
728
729 @item MULE_PACKAGES
730 A whitespace separated list of Mule packages to build/install.
731
732 @example
733 MULE_PACKAGES = mule-base leim locale
734 @end example
735
736 The value for this variable can also be the symbol
737 @samp{mule-packages}, which means to build/install @emph{all} of the
738 Mule packages.  The default is @samp{mule-packages}.
739
740 @item PACKAGE_INDEX
741 The name of the package-index file.  The default is @file{package-index}
742 and you probably don't need to worry about changing it.
743
744 @item INSTALL
745 The path to a BSD compatible install program.  The default is
746 @code{install -c}.
747
748 @item TAR
749 The path to GNU/tar.  The default is @code{tar}.
750
751 @item BZIP2
752 The path to the bzip2 compression program.  The default is unset
753 (blank).  If this is set @file{.tar.bz2} archives will be built
754 @emph{in addition to} the @file{.tar.gz} archives.
755
756 @item EXCLUDES
757 For things that you @emph{don't} want to go into the package tarballs.
758 It takes the same format as GNU/tar's @code{--exclude} option.  The
759 default is:
760
761 @example
762 EXCLUDES =                                      \
763         --exclude 'CVS'                         \
764         --exclude 'RCS'                         \
765         --exclude 'SCCS'                        \
766         --exclude '*~'                          \
767         --exclude '*.orig'                      \
768         --exclude '*.rej'                       \
769         --exclude '.\#*'
770 @end example
771
772 @item VANILLA
773 Set to the XEmacs command line option that forces running in
774 @dfn{vanilla} mode.  The default is @samp{-vanilla}.  You wouldn't ever
775 need to alter this.
776
777 @item BATCH
778 How to put XEmacs into @dfn{batch} mode.  It also sets a couple of other
779 things and in the normal course of events you wouldn't need to alter
780 this from the default which is:
781
782 @example
783 BATCH = $(VANILLA) -batch -eval \
784         '(setq stack-trace-on-error t \
785                load-always-display-messages t \
786                load-ignore-out-of-date-elc-files t \
787                load-show-full-path-in-messages t)'
788 @end example
789
790 @item MAKEINFO
791 The path to @code{makeinfo}.  The default is @samp{makeinfo}
792
793 @item INSTALL_HTML
794 Set this to @samp{t} if you want to install HTML versions of the Texinfo
795 documentation.  The default is unset (blank).
796
797 @item TEXI2HTML
798 The path to the program that can convert Texinfo source to HTML.  The
799 default is @code{texi2html}.
800
801 @item TEXI2DVI
802 The path to the program that can convert Texinfo source to DVI.  The
803 default is @code{texi2dvi}
804
805 @item DVIPS
806 The path to the program that can convert DVI to Postscript.  The default
807 is @code{dvips}
808
809 @item TEXI2PDF
810 The path to the program that can convert Texinfo source to PDF format.
811 The default is @code{texi2pdf}.
812
813 @item TEX
814 The path to @TeX{}.  The default is @code{tex}
815
816 @item MSGFMT
817 The path to msgfmt.  The default is @code{msgfmt}
818
819 @item RCOPY
820 The path to your copy command (GNU cp).  The default is dependent on
821 whether or not @var{symlink} is set (@samp{t}).
822
823 If @var{symlink} is unset (blank), @var{RCOPY}'s default is
824 @code{cp -af}.  If @var{symlink} is set (@samp{t}), @var{RCOPY}'s
825 default is @code{cp --force --recursive --symbolic-link}.
826 @end table
827
828 It should be noted that in most cases the defaults should be fine.  Most
829 people will probably only need to alter:
830
831 @itemize @bullet
832 @item @var{XEMACS_INSTALLED_PACKAGES_ROOT}
833 @item @var{NONMULE_INSTALLED_PACKAGES_ROOT}
834 @item @var{MULE_INSTALLED_PACKAGES_ROOT}
835 @item @var{NONMULE_PACKAGES}
836 @item @var{MULE_PACKAGES}
837 @end itemize
838
839 @node Creating Packages, Documenting Packages, Local.rules File, Packaging
840 @comment  node-name,  next,  previous,  up
841 @cindex creating packages
842 @chapter Creating Packages:
843 Creating a package from an existing Lisp library is not very difficult.
844
845 In addition to the Lisp libraries themselves, you need a
846 @ref{package-info.in} file and a simple @ref{Makefile}.  The rest is
847 done by @file{XEmacs.rules}, part of the packaging system
848 infrastructure.
849
850 @menu
851 * package-info.in::             package-info.in
852 * Makefile::                    @file{Makefile}
853 @end menu
854
855 @node package-info.in, Makefile,,Creating Packages
856 @chapter package-info.in
857 @cindex package-info.in
858 @cindex package-info
859 @file{package-info.in} contains information that gets injected into the
860 @file{package-index} file when @code{make bindist} is run.  Here is a
861 real world example from the xemacs-base package (a description of each
862 field follows the example):
863
864 @example
865 (xemacs-base
866   (standards-version 1.1
867    version VERSION
868    author-version AUTHOR_VERSION
869    date DATE
870    build-date BUILD_DATE
871    maintainer MAINTAINER
872    distribution xemacs
873    priority high
874    category CATEGORY
875    dump nil
876    description "Fundamental XEmacs support, you almost certainly need this."
877    filename FILENAME
878    md5sum MD5SUM
879    size SIZE
880    provides (add-log advice-preload advice annotations assoc case-table chistory comint-xemacs comint compile debug ebuff-menu echistory edmacro ehelp electric enriched env facemenu ffap helper imenu iso-syntax macros novice outline passwd pp regexp-opt regi ring shell skeleton sort thing time-stamp timezone tq xbm-button xpm-button)
881    requires (REQUIRES)
882    type regular
883 ))
884 @end example
885
886 @subheading Description of the Fields in @file{package-info.in}:
887 @table @samp
888 @item NAME
889 The name of the package.  In the case of the example it is
890 @samp{xemacs-base}.
891
892 @item standards-version
893 Part of the internal package infrastructure, its value should always be
894 @samp{1.1}.  Do not change this.
895
896 @item version
897 This is the XEmacs package version number of the package.  It is set
898 from the @file{Makefile} variable @var{VERSION}.  This is something that
899 the XEmacs Package Release Engineer deals with so there is no need for a
900 package maintainer to touch it.  In @file{package-info.in} just put the
901 place-marker, @samp{VERSION} here.
902
903 @item author-version
904 This is the package's internal, or @samp{upstream} version number if it
905 has one.  It is set from the @file{Makefile} variable
906 @var{AUTHOR_VERSION}.
907
908 @item date
909 This is the date of the last change made to the package.  It is
910 auto-generated at build time, taken from the package's toplevel
911 @file{ChangeLog}.
912
913 @item build-date
914 The date the package was built.  It is auto-generated.
915
916 @item maintainer
917 This is the name and email address of the package's maintainer.  It is
918 taken from the @file{Makefile} variable @var{MAINTAINER}.
919
920 @item distribution
921 An unused field, leave as @samp{xemacs}
922
923 @item priority
924 An unused field, can be any of @samp{high}, @samp{medium}, or
925 @samp{low}.
926
927 @item category
928 The @samp{category} of the package.  It is taken from the
929 @file{Makefile} variable @var{CATEGORY} and can be either
930 @samp{standard} for non-Mule packages, or @samp{mule} for Mule
931 packages.  The is also provision for @samp{unsupported} in this field
932 which would be for packages that XEmacs.org do not distribute.
933
934 @strong{N.B.} As yet, the @xpms{} does @emph{not} support this type of
935 package.  It will in the future.
936
937 @item dump
938 Unused.  Always @samp{nil}
939
940 @item description
941 A free form short description of the package.
942
943 @item filename
944 The file name of the package's binary tarball.  It is generated at build
945 time by @code{make bindist}.
946
947 @item md5sum
948 The MD5 message digest of the package's binary tarball.  Generated at
949 build time by @code{make bindist}.
950
951 @item size
952 The size in bytes of the package's binary tarball.  Generated at build
953 time.
954
955 @item provides
956 A whitespace separated list of @emph{all} the features the package
957 provides.  Surround the list with parens.
958
959 @item requires
960 Taken from the @file{Makefile} variable @var{REQUIRES}.  It is a list of
961 all the package's dependencies, including any macros and defstructs that
962 need to be inlined.
963
964 @samp{REQUIRES} cannot be correctly computed from the calls to
965 @code{require} in the package's library sources.  @samp{REQUIRES} is
966 used to ensure that all macro and defstruct definitions used by the
967 package are available at build time.  This is not merely a matter of
968 efficiency, to get the expansions inlined.  In fact, it is
969 @emph{impossible} to call a macro by name in byte-compiled Emacs Lisp
970 code.  Thus, if the macro expansion is not inlined, the call will result
971 in an error at run-time!  Thus, packages providing libraries that would
972 be loaded because of autoload definitions must also be included.
973
974 @item type
975 Can either be @samp{regular} for a regular package, or
976 @samp{single-file} for a single file package.
977
978 @strong{N.B.} This doesn't refer to the number of lisp files in a
979 package.  A single-file package can have multiple lisp files in it.
980 @xref{Package Terminology}.
981 @end table
982
983 The fields in @file{package-info.in} that need to be changed directly
984 are:
985
986 @itemize @bullet
987 @item NAME
988 @item description
989 @item provides
990 @item type
991 @end itemize
992
993 Everything else is either set from the appropriate @file{Makefile}
994 variable, is auto-generated at build time, or is static.
995
996 @node Makefile,,package-info.in,Creating Packages
997 @chapter @file{Makefile}
998 @cindex Makefile, package
999 @cindex package Makefile
1000 The @file{Makefile} is quite stylized.  The idea is similar to an
1001 @file{Imakefile} or an @code{automake} file: the complexity is hidden in
1002 generic rules files, in this case the @file{XEmacs.rules} include file
1003 in the top directory of the packages hierarchy.
1004
1005 It is important to note that the XEmacs used to compile packages is
1006 the bare minimum: it is called with the @samp{-no-autoloads}.  This
1007 means that anything not dumped into XEmacs by default needs to be
1008 specified in the @samp{REQUIRES} variable (for packaged Lisp) or in
1009 some cases the @samp{PRELOADS} (autoloads used in libraries mentioned
1010 in @samp{PRELOADS}).
1011
1012 There isn't much to an @xpms{} @file{Makefile}, basically it just
1013 contains a few @file{Makefile} variables and that's it.  See the
1014 example.
1015
1016 Here is a real world example, from the @samp{build} package:
1017
1018 @example
1019 # Makefile for build lisp code
1020
1021 # This file is part of XEmacs.
1022
1023 # XEmacs is free software; you can redistribute it and/or modify it
1024 # under the terms of the GNU General Public License as published by the
1025 # Free Software Foundation; either version 2, or (at your option) any
1026 # later version.
1027
1028 # XEmacs is distributed in the hope that it will be useful, but WITHOUT
1029 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1030 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1031 # for more details.
1032
1033 # You should have received a copy of the GNU General Public License
1034 # along with XEmacs; see the file COPYING.  If not, write to
1035 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1036 # Boston, MA 02111-1307, USA.
1037
1038 # For the time being, remove MULE_ELCS from the all dependencies if
1039 # building without Mule.
1040
1041 VERSION = 1.10
1042 AUTHOR_VERSION = 2.02
1043 MAINTAINER = Adrian Aichner <adrian@@xemacs.org>
1044 PACKAGE = build
1045 PKG_TYPE = regular
1046 REQUIRES = xemacs-base pcl-cvs dired w3 prog-modes
1047 CATEGORY = standard
1048
1049 ELCS = build.elc build-report.elc
1050
1051 STANDARD_DOCS = t
1052
1053 include ../../XEmacs.rules
1054 @end example
1055
1056 Most packages don't need any more than what you see above.  It is
1057 usually @emph{not} necessary to specify any special @file{Makefile}
1058 rules.  Everything is handled from the @file{*.rules} files in the
1059 toplevel of the package source hierarchy.
1060
1061 Of course, with that said, there are always exceptions to the rule.  If
1062 you think that your package will need some special @file{Makefile}
1063 hackery contact the @email{xemacs-beta@@xemacs.org, XEmacs developers}.
1064 We distribute over 100 packages so the chances are good that you won't
1065 be the first to need such hackery and it is probably already catered
1066 for.
1067
1068 @subheading @file{Makefile} Variables Explained:
1069 A number of @file{make} variables are defined by the @xpms{}.  Some are
1070 required, others are optional.  Of course your @file{Makefile} may
1071 define other variables for private use, but you should be careful not to
1072 choose names that conflict with variables defined and used by the
1073 @xpms{}.
1074
1075 The required variables are described in the table below.
1076 The corresponding field names for @file{package-info.in}, where
1077 relevant, are given in parentheses.
1078
1079 @c This is the canonical place for this information.  If there is
1080 @c unnecessary duplication with package-info.in documentation, shorten
1081 @c that and leave this full-length.
1082 @table @samp
1083 @item VERSION
1084 (version)
1085 The version of the XEmacs package, a numeric literal (a decimal
1086 fixed-point number with two-places of precision).  The only person who
1087 ever needs to touch this is the XEmacs Packages Release Engineer.
1088
1089 @item AUTHOR_VERSION
1090 (author-version)
1091 The upstream author's version, an uninterpreted literal.
1092
1093 @item MAINTAINER
1094 (maintainer)
1095 A literal containing the XEmacs package's maintainer and his/her email
1096 address.
1097
1098 @item PACKAGE
1099 The name of the package, a literal
1100
1101 @item PKG_TYPE
1102 The type of package, a literal containing either @samp{regular} for
1103 regular packages, or @samp{single-file} for single-file packages.  This
1104 should feed the @samp{type} field in @file{package-info.in}, but
1105 currently it doesn't.
1106
1107 @strong{N.B.} @samp{single-file} here does @emph{not} refer to the
1108 number of lisp files in a package. @xref{Package Terminology}.
1109
1110 @item CATEGORY
1111 (category)
1112 A literal, either @samp{standard} or @samp{mule}.  The non-Mule packages
1113 are @samp{standard} and the Mule packages are, you guessed it,
1114 @samp{mule}.  This field is used at package installation time as part of
1115 the process of determining where a package should be installed to.
1116
1117 @item REQUIRES
1118 (requires)
1119 A list of packages required to correctly build this package.
1120
1121 Note that the usual form in @file{package-info.in} already has the
1122 parentheses, so the @file{make} variable should be set to a
1123 space-separated list of package names @emph{not} enclosed in
1124 parentheses.
1125
1126 The list is of @emph{packages}, not @emph{libraries}, as would
1127 ordinarily be provided to the Lisp @code{require} function.
1128
1129 @samp{REQUIRES} cannot be correctly computed from the calls to
1130 @code{require} in the package's library sources.  @samp{REQUIRES} is
1131 used to ensure that all macro and defstruct definitions used by the
1132 package are available at build time.  This is not merely a matter of
1133 efficiency, to get the expansions inlined.  In fact, it is
1134 @emph{impossible} to call a macro by name in byte-compiled Emacs Lisp
1135 code.  Thus, if the macro expansion is not inlined, the call will result
1136 in an error at run-time!  Thus, packages providing libraries that would
1137 be loaded because of autoload definitions must also be included.
1138
1139 @item ELCS
1140 The list of the byte-compiled Lisp files used by the package.  These
1141 files and their @file{.el} versions will be included in the binary
1142 package.  This variable determines which libraries will be
1143 byte-compiled.  These libraries are also deleted by @samp{make clean}.
1144
1145 Note there is no sanity-checking done on this variable.  If you put
1146 @samp{.el} files in here, they will not be compiled and they @emph{will}
1147 be deleted by @samp{make clean}.  You would surely be very distressed if
1148 that happened, so be very careful.  If this variable is left empty, none
1149 of your Lisp code will be compiled or packaged.  This would be a less
1150 than amusing surprise, too.
1151
1152 We don't consider this a feature, of course.  Please do submit code to
1153 do sanity checking to @email{xemacs-patches@@xemacs.org}.
1154 @end table
1155
1156 Optional, but commonly used variables are explained below.
1157
1158 @table @samp
1159 @item ELCS_1
1160 A list of extra byte-compiled Lisp files used by the package to be
1161 installed in a subdirectory of the package's lisp directory.  The same
1162 care should be taken with this as with @var{ELCS} in regard to
1163 @code{make clean}.
1164
1165 @item ELCS_1_DEST
1166 The name of the subdirectory for the @var{ELCS_1} files to be installed
1167 to.  Be sure to include @samp{$(PACKAGE)/} as part of the name.
1168
1169 @example
1170 ELCS_1_DEST = $(PACKAGE)/extra
1171 @end example
1172
1173 Would put the @var{ELCS_1} files for the package, @samp{foo} into
1174 @file{xemacs-packages/lisp/foo/extra/}.
1175
1176 @item EARLY_GENERATED_LISP
1177 For additional @file{.el} files that will be generated before any
1178 byte-compiling happens.  Use this for @samp{autoload-type} files.  You
1179 must write @file{Makefile} rules to build these files.
1180
1181 @item GENERATED_LISP
1182 For additional @file{.el} files that will be generated at
1183 byte-compilation time.  You must write @file{Makefile} rules to build
1184 these files.
1185
1186 @item PRELOADS
1187 This is used if you need to pass extra command line arguments to
1188 XEmacs to build the package.  For instance, a specification for
1189 loading libraries containing macros before compiling the Lisp in the
1190 package.  This is spliced directly into the invocation of XEmacs for
1191 byte-compilation, so it must contain the @samp{-l} flag for XEmacs:
1192
1193 @example
1194 PRELOADS=-l ./apackage-macros.el -l ../bpackage/lisp/bpackage-macros.el
1195 @end example
1196
1197 Preloads are loaded before @file{package-compile.el}, so the
1198 @var{load-path} is minimal.  Therefore @samp{PRELOADS} must specify a
1199 full path to packaged Lisp.  The base @var{load-path} does include the
1200 core Lisp directory, so core libraries are found.
1201
1202 @item AUTOLOAD_PATH
1203 The subdirectory in the package's source tree where the @file{.el} files
1204 reside.  This is where the @file{auto-autoloads.el} file will be placed.
1205
1206 @strong{N.B.} There is no need to use this variable if the @file{.el}
1207 files are in the package's toplevel directory.  @var{AUTOLOAD_PATH}
1208 defaults to @samp{.}.
1209
1210 @item PACKAGE_SUPPRESS
1211 Place calls to @code{package-suppress} here to indicate Lisp libraries
1212 that should only be available to particular versions of XEmacs.  For
1213 example:
1214
1215 @example
1216 PACKAGE_SUPPRESS = \
1217  (package-suppress 'xemacs-base \"regexp-opt\" '(emacs-version>= 21 5 11)) \
1218  (package-suppress 'xemacs-base \"easy-mmode\" '(emacs-version>= 21 5 11))
1219 @end example
1220
1221 @c Change this when Ben has committed the WS that implements
1222 @c `package-suppress' --SY.
1223 @strong{N.B.} This feature has not yet been implemented in XEmacs yet.
1224 It will appear in an upcoming version of XEmacs 21.5.
1225
1226 @item STANDARD_DOCS
1227 Set this to @samp{t} if your package's Texinfo source file is located in
1228 the package's toplevel directory @emph{and} is named
1229 @file{$(PACKAGE).texi}.
1230
1231 @item EXPLICIT_DOCS
1232 Use this to explicitly list Texinfo sources that @emph{aren't} in the
1233 package's toplevel directory.  For example:
1234
1235 @example
1236 EXPLICIT_DOCS = texi/$(PACKAGE).texi
1237 @end example
1238
1239 See @var{DOCS_TXI_EXTENSION} and @var{DOCS_TEXINFO_EXTENSION} if you
1240 don't use the @file{.texi} file extension on your Texinfo sources.
1241
1242 @item EXTRA_TEXI_FILES
1243 List here extra Texinfo source files needed to build your
1244 documentation.  Whatever is listed here is passed on to @code{makeinfo}
1245 as a dependency.
1246
1247 @item EXTRA_HTML_FILES
1248 Use this to specify extra @file{.html} files to output.
1249
1250 @item DOCS_TEXINFO_EXTENSION
1251 Set this to @samp{t} if your Texinfo source files have a @samp{.texinfo}
1252 extension.
1253
1254 @item DOCS_TXI_EXTENSION
1255 Set this to @samp{t} if your Texinfo source files have a @samp{.txi}
1256 extension.
1257
1258 @item EXTRA_DOC_FILES
1259 Files listed here will be installed to @file{.../man/$(PACKAGE)/}.  For
1260 example, you might want to list @TeX{} files or @file{.eps} files here.
1261
1262 @item EXTRA_SOURCES
1263 Other files (such as extra Lisp sources or an upstream @file{Makefile})
1264 that are normally placed in the installed Lisp directory, but not
1265 byte-compiled.  These files are @emph{preserved} by the @samp{clean}
1266 targets.
1267
1268 @item LIBSRC_FILES
1269 For files that need to be installed to @file{lib-src/$(PACKAGE)/}.  If
1270 the files listed here need to be built you will have to write
1271 @file{Makefile} rules to do so.
1272
1273 @item DATA_FILES
1274 Any data files, such as pixmaps, READMEs, and ChangeLogs.  These must be
1275 paths relative to the root of the package's source tree.  These files
1276 will be copied to @samp{$(DATA_DEST)} for installation.  Any directory
1277 component of the path for a file will be stripped, so that the
1278 file ends up in @samp{$(DATA_DEST)}, not in a subdiredtory.
1279
1280 @item DATA_DEST
1281 The directory where the files in @var{DATA_FILES} are installed to.  It
1282 is a subdirectory of the installed @file{etc/} directory.  Be sure to
1283 prefix this value with @samp{$(PACKAGE)}, for example:
1284
1285 @example
1286 DATA_DEST = $(PACKAGE)/foo
1287 @end example
1288
1289 Would put files into @file{.../etc/$(PACKAGE)/foo/}.
1290
1291 @item DATA_1_FILES ... DATA_35_FILES
1292 For data files that need to go into a different directory from
1293 @var{DATA_DEST}.
1294
1295 @item DATA_1_DEST ... DATA_35_DEST
1296 The name of the subdirectory for files specified in @var{DATA_n_FILES}.
1297 And like @var{DATA_DEST}, be sure to prefix @samp{$(PACKAGE)} to the
1298 value of these variables.
1299
1300 @item EXTRA_DEPENDENCIES
1301 For additional files to build that aren't appropriate to place in any
1302 other @file{Makefile} variable.  You will need to write @file{Makefile}
1303 rules to build these files.
1304 @end table
1305
1306 @section @file{package-compile.el}
1307 @cindex package-compile.el
1308 @cindex compiling packages
1309 The @xpms{} does not automatically become aware of your package simply
1310 because there is a new subtree.  If any package, including your own,
1311 requires any of your files, it must be explicitly added to the compile
1312 environment or loads/requires that search load-path will fail.  The
1313 changes that need to be made are
1314
1315 @table @strong
1316 @item an entry in @code{package-directory-map}
1317 This tells the @xpms{} which distribution (currently
1318 @samp{xemacs-packages} or @samp{mule-packages}) your package is found
1319 in.  It then looks in the distribution subdirectory whose name is the
1320 same as the package's.
1321
1322 @item an entry in the @code{cond} in @code{package-name-to-directory}
1323 This is optional; it is necessary only if you keep your Lisp code
1324 somewhere other than the top-level directory of the package's source
1325 tree, eg, in @file{packages/xemacs-packages/@var{PACKAGE}/lisp}.
1326 @end table
1327
1328 This only needs to be done once, when the package is first added to the
1329 @xpms{}.  (Well, when you randomly change the subdirectory layout, too.)
1330 Your changes to @file{package-compile.el} must be cleared and checked in
1331 by the XEmacs Package Release Engineer before your package will build
1332 correctly from a fresh checkout.
1333
1334 This is unfortunate; it works pretty well once set up, but can cause
1335 confusion when first building a package in the @xpms{} context.  In
1336 particular, if the @code{package-directory-map} entry for a required
1337 package, including the package itself, is not found, the necessary
1338 requires will not be executed by @file{package-compile.el}.  If
1339 required functions are executed (under @code{eval-when-compile}),
1340 they won't be found and the compile will fail.  If required function
1341 is actually a macro, the byte compiler will not recognize that,
1342 compile a function call to the macro.  This will cause a run-time
1343 error because the byte-code interpreter does not know how to execute
1344 macros.  (Macros can always be expanded at compile-time, and this is
1345 more efficient.)
1346
1347 If your package keeps some or all Lisp code somewhere other than the top
1348 directory, then an entry in @code{package-name-to-directory} is also
1349 necessary, or requires will fail, leading to the problems just described.
1350
1351 @node Documenting Packages, Issues, Creating Packages, Packaging
1352 @comment  node-name,  next,  previous,  up
1353 @cindex documenting packages
1354 @heading Documenting Packages:
1355
1356 @c #### Add a documentation section to Internals, and xref here.
1357 Some random notes on documenting your package.
1358
1359 Do write a Texinfo file.  It's not that hard to do basically, and even
1360 using the more advanced features of Texinfo soon become natural.  For a
1361 start, just grab the template @file{Samples/package.texi} from the
1362 @xpms{} source tree, and drop your current README into the Top node.  At
1363 least this way your documentation will be accessible from the standard
1364 Info readers.  Next, try to add lots of cross-referencing and logical
1365 markup, and then node structure.
1366
1367 Address both end users and developer issues.  You may not be the
1368 maintainer forever.
1369
1370 If you are maintaining a package that is part of the GNU Emacs
1371 distribution, you'll likely find that you occasionally synchronize your
1372 package with the GNU Emacs sources.  When you synch a file,
1373 conventionally you should place a comment just above the standard
1374 @code{;;; Code} comment that looks like this:
1375
1376 @example
1377 ;; Synched with:
1378 ;; GNU Emacs 21.1, 2002-02-08, Stephen Turnbull <stephen@@xemacs.org>
1379 @end example
1380
1381 This comment is a status flag; the ChangeLog doesn't really give the
1382 same information.
1383
1384 Do maintain a detailed ChangeLog.
1385
1386 @node Issues, , Documenting Packages, Packaging
1387 @section Issues
1388
1389 To be completed.