annotate man/emodules.texi @ 5482:384423af8fb5 first-gplv3 r21-5-31

Update CHANGES-beta.
author Stephen J. Turnbull <stephen@xemacs.org>
date Sat, 30 Apr 2011 12:50:14 +0900
parents bb6a375da086
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 \input texinfo @c -*-texinfo-*-
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 @c %**start of header
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 @setfilename ../info/emodules.info
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 @settitle Extending Emacs using C Modules
721
f72a191f8ecf [xemacs-hg @ 2002-01-02 20:56:32 by adrian]
adrian
parents: 625
diff changeset
6 @direntry
f72a191f8ecf [xemacs-hg @ 2002-01-02 20:56:32 by adrian]
adrian
parents: 625
diff changeset
7 * Emodules: (emodules). XEmacs dynamically loadable module support.
f72a191f8ecf [xemacs-hg @ 2002-01-02 20:56:32 by adrian]
adrian
parents: 625
diff changeset
8 @end direntry
f72a191f8ecf [xemacs-hg @ 2002-01-02 20:56:32 by adrian]
adrian
parents: 625
diff changeset
9 @c footnotestyle separate
f72a191f8ecf [xemacs-hg @ 2002-01-02 20:56:32 by adrian]
adrian
parents: 625
diff changeset
10 @c paragraphindent 2
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 @c %**end of header
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 @c
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 @c Use some macros so that we can format for either XEmacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 @c or (shudder) GNU Emacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 @c
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 @ifset XEMACS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 @set emacs XEmacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 @clear EMACS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 @set HAVE-EMACS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 @end ifset
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 @ifset EMACS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 @set emacs Emacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 @clear XEMACS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 @set HAVE-EMACS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 @end ifset
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 @ifclear HAVE-EMACS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 @set XEMACS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 @set emacs XEmacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 @end ifclear
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34
5007
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
35 @c TODO: Merge the info-only and TeX-only license text, since they are
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
36 @c identical.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 @ifinfo
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 This file documents the module loading technology of @value{emacs}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 Copyright @copyright{} 1998 J. Kean Johnston.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 Permission is granted to make and distribute verbatim copies of this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 manual provided the copyright notice and this permission notice are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 preserved on all copies.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45
5007
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
46 This file is part of XEmacs.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47
5007
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
48 XEmacs is free software; you can redistribute it and/or modify it
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
49 under the terms of the GNU General Public License as published by the
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
50 Free Software Foundation; either version 2, or (at your option) any
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
51 later version.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52
5007
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
53 XEmacs is distributed in the hope that it will be useful, but WITHOUT
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
54 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
55 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
56 for more details.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57
5007
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
58 You should have received a copy of the GNU General Public License
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
59 along with XEmacs; see the file COPYING. If not, write to
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
60 the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
61 Boston, MA 02110-1301, USA.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 @end ifinfo
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64 @c Combine indices.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 @syncodeindex fn cp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 @syncodeindex vr cp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 @syncodeindex ky cp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 @syncodeindex pg cp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 @syncodeindex tp cp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 @setchapternewpage odd
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 @finalout
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 @titlepage
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 @title Extending @value{emacs} using C and C++
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76 @subtitle Version 1.0, September 1998
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 @author J. Kean Johnston
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 @page
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 @vskip 0pt plus 1fill
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 @noindent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 Copyright @copyright{} 1998 J. Kean Johnston. @*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 @sp 2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 Version 1.0 @*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 September, 1998.@*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88
5007
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
89 This file is part of XEmacs.
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
90
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
91 XEmacs is free software; you can redistribute it and/or modify it
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
92 under the terms of the GNU General Public License as published by the
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
93 Free Software Foundation; either version 2, or (at your option) any
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
94 later version.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95
5007
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
96 XEmacs is distributed in the hope that it will be useful, but WITHOUT
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
97 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
98 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
99 for more details.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100
5007
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
101 You should have received a copy of the GNU General Public License
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
102 along with XEmacs; see the file COPYING. If not, write to
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
103 the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
bb6a375da086 Relicense J. Kean Johnston's emodules.texi as GPL v2 or later. See
Jerry James <james@xemacs.org>
parents: 4953
diff changeset
104 Boston, MA 02110-1301, USA.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 @end titlepage
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 @page
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 @ifinfo
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 @node Top, Introduction, (dir), (dir)
721
f72a191f8ecf [xemacs-hg @ 2002-01-02 20:56:32 by adrian]
adrian
parents: 625
diff changeset
110 This Info file contains v1.0 of the @value{emacs} dynamically loadable
f72a191f8ecf [xemacs-hg @ 2002-01-02 20:56:32 by adrian]
adrian
parents: 625
diff changeset
111 module support documentation.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 @menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 * Introduction:: Introducing Emacs Modules
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
114 * Anatomy of a Module:: Basic module layout and technology
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 * Using ellcc:: How to use the module compiler
2972
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
116 * Distribution with XEmacs:: Adding your module to the distribution
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 * Defining Functions:: Creating new Lisp primitives
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 * Defining Variables:: Creating new Lisp variables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 * Index:: Concept Index
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 --- The Detailed Node Listing ---
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
123 Anatomy of a Module
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 * Required Header File:: Always include <emodules.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 * Required Functions:: Functions you must always provide
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 * Required Variables:: Variables whose values you must provide
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
128 * Loading other Modules:: How to load dependent modules
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 Using @code{ellcc}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 * Compile Mode:: Compiling modules using ellcc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133 * Initialization Mode:: Generating documentation and variables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 * Link Mode:: Creating the final loadable module
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 * Other ellcc options:: Other useful options
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 * Environment Variables:: How to control ellcc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 Defining Functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140 * Using DEFUN:: Using the DEFUN macro to define functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 * Declaring Functions:: Declaring functions to the Lisp reader
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 @end menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 @end ifinfo
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
146 @node Introduction, Anatomy of a Module, Top, Top
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 @chapter Introduction
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 @value{emacs} is a powerful, extensible editor. The traditional way of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 extending the functionality of @value{emacs} is to use its built-in Lisp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 language (called Emacs Lisp, or Elisp for short). However, while Elisp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 is a full programming language and capable of extending @value{emacs} in more
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 ways than you can imagine, it does have its short-comings.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 Firstly, Elisp is an interpreted language, and this has serious speed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 implications. Like all other interpreted languages (like Java), Elisp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 is often suitable only for certain types of application or extension.
440
8de8e3f6228a Import from CVS: tag r21-2-28
cvs
parents: 428
diff changeset
158 So although Elisp is a general purpose language, and very high level,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
159 there are times when it is desirable to descend to a lower level compiled
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 language for speed purposes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 Secondly, Elisp (or Lisp in general) is not a very common language any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163 more, except for certain circles in the computer industry. C is a far
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
164 more commonly known language, and because it is compiled, more suited to
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 a wider range of applications, especially those that require low level
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 access to a system or need to be as quick as possible.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 @cindex Emacs Modules
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 @cindex DLL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 @cindex DSO
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 @cindex shared object
721
f72a191f8ecf [xemacs-hg @ 2002-01-02 20:56:32 by adrian]
adrian
parents: 625
diff changeset
172 This manual describes a new way of extending @value{emacs}, by using
f72a191f8ecf [xemacs-hg @ 2002-01-02 20:56:32 by adrian]
adrian
parents: 625
diff changeset
173 dynamically loadable modules (also known as dynamically loadable
f72a191f8ecf [xemacs-hg @ 2002-01-02 20:56:32 by adrian]
adrian
parents: 625
diff changeset
174 libraries (DLLs), dynamic shared objects (DSOs) or just simply shared
f72a191f8ecf [xemacs-hg @ 2002-01-02 20:56:32 by adrian]
adrian
parents: 625
diff changeset
175 objects), which can be written in C or C++ and loaded into @value{emacs}
f72a191f8ecf [xemacs-hg @ 2002-01-02 20:56:32 by adrian]
adrian
parents: 625
diff changeset
176 at any time. I sometimes refer to this technology as @dfn{CEmacs},
f72a191f8ecf [xemacs-hg @ 2002-01-02 20:56:32 by adrian]
adrian
parents: 625
diff changeset
177 which is short for @dfn{C Extensible Emacs}.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 @value{emacs} modules are configured into and installed with @value{emacs} by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 default on all systems that support loading of shared objects. From a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 users perspective, the internals of @value{emacs} modules are irrelevant.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 All a user will ever need to know about shared objects is the name of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 the shared object when they want to load a given module. From a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 developers perspective though, a lot more is provided.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 @itemize @bullet
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 @pindex ellcc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 @cindex compiler
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 @cindex linker
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 Of primary interest is the @code{ellcc} program. This program is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 created during compile time, and is intended to abstract compiler
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 specific characteristics from the developer. This program is called to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 compile and link all objects that will make up the final shared object,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 and accepts all common C compiler flags. @code{ellcc} also sets up the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 correct environment for compiling modules by enabling any special
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
197 compiler modes (such as PIC mode), setting the correct include paths for
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 the location of @value{emacs} internal header files etc. The program will also
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 invoke the linker correctly to created the final shared object which is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 loaded into @value{emacs}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 @cindex header files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 CEmacs also makes all of the relevant @value{emacs} internal header files
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
205 available for module authors to use. This is often required to get data
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 structure definitions and external variable declarations. The header
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 files installed include the module specific header file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 @file{emodules.h}. Due to the nature of dynamic modules, most of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 internals of @value{emacs} are exposed.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
210 @xref{Top,,,internals,@value{emacs} Internals Manual}, for a
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
211 more complete discussion on how to extend and understand @value{emacs}. All of
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 the rules for C modules are discussed there.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 @cindex samples
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 Part of the @value{emacs} distribution is a set of sample modules. These are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 not installed when @value{emacs} is, but remain in the @value{emacs} source tree.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 These modules live in the directory @file{modules}, which is a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 sub-directory of the main @value{emacs} source code directory. Please look at
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220 the samples carefully, and maybe even use them as a basis for making
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 your own modules. Most of the concepts required for writing extension
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 modules are covered in the samples.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 @cindex documentation
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 @cindex help
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227 Last, but not least is this manual. This can be viewed from within
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 @value{emacs}, and it can be printed out as well. It is the intention of this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 document that it will describe everything you need to know about
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 extending @value{emacs} in C. If you do not find this to be the case, please
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 contact the author(s).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 @end itemize
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234 The rest of this document will discuss the actual mechanics of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 @value{emacs} modules and work through several of the samples. Please be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 sure that you have read the @value{emacs} Internals Manual and understand
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 everything in it. The concepts there apply to all modules. This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 document may have some overlap, but it is the internals manual which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 should be considered the final authority. It will also help a great
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240 deal to look at the actual @value{emacs} source code to see how things are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 done.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
243 @node Anatomy of a Module, Using ellcc, Introduction, Top
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
244 @chapter Anatomy of a Module
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
245 @cindex anatomy
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 @cindex module skeleton
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247 @cindex skeleton, module
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 @cindex module format
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 @cindex format, module
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
251 Each dynamically loadable @value{emacs} extension (hereafter referred to as a
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
252 module) has a certain compulsory format, and must contain several
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
253 pieces of information and several mandatory functions. This chapter
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 describes the basic layout of a module, and provides a very simple
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 sample. The source for this sample can be found in the file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256 @file{modules/simple/sample.c} in the main @value{emacs} source code tree.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 @menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 * Required Header File:: Always include <emodules.h>
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 * Required Functions:: Functions you must always provide
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261 * Required Variables:: Variables whose values you must provide
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
262 * Loading other Modules:: How to load dependent modules
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 @end menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
265 @node Required Header File, Required Functions, Anatomy of a Module, Anatomy of a Module
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 @section Required Header File
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 @cindex required header
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268 @cindex include files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 @cindex emodules.h
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 @cindex config.h
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 Every module must include the file @file{<emodules.h>}. This
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
273 will include several other @value{emacs} internal header files, and will set up
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 certain vital macros. One of the most important files included by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 @file{emodules.h} is the generated @file{config.h} file, which contains
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 all of the required system abstraction macros and definitions. Most
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 modules will probably require some pre-processor conditionals based on
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278 constants defined in @file{config.h}. Please read that file to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 familiarize yourself with the macros defined there.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
281 Depending on exactly what your module will be doing, you will probably
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 need to include one or more of the @value{emacs} internal header files. When
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
283 you @code{#include <emodules.h>}, you will get a few of the most important
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 @value{emacs} header files included automatically for you. The files included
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 are:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287 @table @file
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 @item lisp.h
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
289 This file contains most of the macros required for declaring Lisp object
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 types, macros for accessing Lisp objects, and global variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291 declarations.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 @item sysdep.h
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
294 All system dependent declarations and abstraction macros live here. You
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 should never call low level system functions directly. Rather, you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 should use the abstraction macros provided in this header file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 @item window.h
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299 This header file defines the window structures and Lisp types, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 provides functions and macros for manipulating multiple @value{emacs} windows.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 @item buffer.h
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303 All macros and function declarations for manipulating internal and user
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 visible buffers appear in this file.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 @item insdel.h
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 This header provides the information required for performing text
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 insertion and deletion.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 @item frame.h
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 Provides the required structure, macro and function definitions for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 manipulating @value{emacs} frames.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
315 @node Required Functions, Required Variables, Required Header File, Anatomy of a Module
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 @section Required Functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 @cindex initialization
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318 @cindex functions, required
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 @cindex required functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 Every module requires several initialization functions. It is the
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
322 responsibility of these functions to load in any dependent modules, and to
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
323 declare all variables and functions which are to be made visible to the
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 @value{emacs} Lisp reader. Each of these functions performs a very specific
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 task, and they are executed in the correct order by @value{emacs}. All of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 these functions are @code{void} functions which take no arguments.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327 Here, briefly, are the required module functions. Note that the actual
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 function names do not end with the string @code{_module}, but rather
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 they end with the abbreviated module name by which the module is known.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 More on the module name and its importance later. Just bear in mind
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 that the text @code{_module} in the functions below is simply a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 place-holder, not an actual function name.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334 @table @code
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 @item syms_of_module
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 @findex syms_of_module
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
337 This required function is responsible for introducing to the Lisp reader
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 all functions that you have defined in your module using
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 @code{DEFUN()}. Note that @emph{only} functions are declared here, using
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 the @code{DEFSUBR()} macro. No variables are declared.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342 @item vars_of_module
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 @findex vars_of_module
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 This required function contains calls to macros such as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345 @code{DEFVAR_LISP()}, @code{DEFVAR_BOOL()} etc, and its purpose is to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 declare and initialize all and any variables that your module defines.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 They syntax for declaring variables is identical to the syntax used for
450
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
348 all internal @value{emacs} source code. If the module is intended to be
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
349 usable statically linked into XEmacs, the actions of this function are
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
350 severely restricted. @xref{General Coding Rules,,,internals,
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
351 @value{emacs} Internals Manual}. Also see the comments in
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
352 @file{src/emacs.c} (@code{main_1}). Modules which perform
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
353 initializations not permitted by these rules will probably work, but
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
354 dual-use (dynamic loading and static linking) modules will require very
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
355 careful, and possibly fragile, coding.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357 @item modules_of_module
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 @findex modules_of_module
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 This optional function should be used to load in any modules which your
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
360 module depends on. The @value{emacs} module loading code makes sure that the
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 same module is not loaded twice, so several modules can safely call the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362 module load function for the same module. Only one copy of each module
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 (at a given version) will ever be loaded.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365 @item docs_of_module
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 @findex docs_of_module
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 This is a required function, but not one which you need ever write.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 This function is created automatically by @code{ellcc} when the module
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 initialization code is produced. It is required to document all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 functions and variables declared in your module.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
373 @node Required Variables, Loading other Modules, Required Functions, Anatomy of a Module
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374 @section Required Variables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 @cindex initialization
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 @cindex variables, required
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 @cindex required variables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 Not only does a module need to declare the initialization functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 mentioned above, it is also required to provide certain variables which
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
381 the module loading code searches for in order to determine the viability
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 of a module. You are @emph{not} required to provide these variables in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383 your source files. They are automatically set up in the module
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 initialization file by the @code{ellcc} compiler. These variables are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 discussed here simply for the sake of completeness.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 @table @code
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 @item emodules_compiler
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389 This is a variable of type @code{long}, and is used to indicate the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 version of the @value{emacs} loading technology that was used to produce the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 module being loaded. This version number is completely unrelated to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 the @value{emacs} version number, as a given module may quite well work
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
393 regardless of the version of @value{emacs} that was installed at the time the
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 module was created.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 The @value{emacs} modules version is used to differentiate between major
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 changes in the module loading technology, not versions of @value{emacs}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 @item emodules_name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 This is a short (typically 10 characters or less) name for the module,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 and it is used as a suffix for all of the required functions. This is
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
402 also the name by which the module is recognized when loading dependent
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 modules. The name does not necessarily have to be the same as the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 physical file name, although keeping the two names in sync is a pretty
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
405 good idea. The name must not be empty, and it must be a valid part of a
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
406 C function name. The value of this variable is appended to the function
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 names @code{syms_of_}, @code{vars_of_}, @code{modules_of_} and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 @code{docs_of_} to form the actual function names that the module
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 loading code looks for when loading a module.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 This variable is set by the @code{--mod-name} argument to @code{ellcc}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 @item emodules_version
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 This string variable is used to load specific versions of a module.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 Rarely will two or more versions of a module be left lying around, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 just in case this does happen, this variable can be used to control
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 exactly which module should be loaded. See the Lisp function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418 @code{load-module} for more details. This variable is set by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 @code{--mod-version} argument to @code{ellcc}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 @item emodules_title
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 This is a string which describes the module, and can contain spaces or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423 other special characters. It is used solely for descriptive purposes,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 and does not affect the loading of the module. The value is set by the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 @code{--mod-title} argument to @code{ellcc}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
428 @node Loading other Modules, , Required Variables, Anatomy of a Module
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 @section Loading other Modules
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
430 @cindex dependencies
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 @findex modules_of_module
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432 @findex emodules_load
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 During the loading of a module, it is the responsibility of the function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 @code{modules_of_module} to load in any modules which the current module
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 depends on. If the module is stand-alone, and does not depend on other
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 modules, then this function can be left empty or even undeclared.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
438 However, if it does have dependencies, it must call
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 @code{emodules_load}:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 @cartouche
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
443 int emodules_load (const char *module,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
444 const char *modname,
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
445 const char *modver)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 @end cartouche
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
449 The first argument @var{module} is the name of the actual shared object
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 or DLL. You can omit the @file{.so}, @file{.ell} or @file{.dll}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 extension of you wish. If you do not specify an absolute path name,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 then the same rules as apply to loading Lisp modules are applied when
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453 searching for the module. If the module cannot be found in any of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 standard places, and an absolute path name was not specified,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
455 @code{emodules_load} will signal an error and loading of the module
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 will stop.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 The second argument (@var{modname}) is the module name to load, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 must match the contents of the variable @var{emodule_name} in the
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
460 module to be loaded. A mis-match will cause the module load to fail. If
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 this parameter is @code{NULL} or empty, then no checks are performed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 against the target module's @var{emodule_name} variable.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464 The last argument, @var{modver}, is the desired version of the module
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 to load, and is compared to the target module's
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 @var{emodule_version} value. If this parameter is not @code{NULL}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 or empty, and the match fails, then the load of the module will fail.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 @code{emodules_load} can be called recursively. If, at any point
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
470 during the loading of modules a failure is encountered, then all modules
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 that were loaded since the top level call to @code{emodules_load}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 will be unloaded. This means that if any child modules fail to load,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 then their parents will also fail to load. This does not include
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 previous successful calls to @code{emodules_load} at the top level.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475
880
beddd25fe24a [xemacs-hg @ 2002-06-24 22:00:17 by youngs]
youngs
parents: 775
diff changeset
476 @strong{Warning:} Modules are @emph{not} loaded with the
beddd25fe24a [xemacs-hg @ 2002-06-24 22:00:17 by youngs]
youngs
parents: 775
diff changeset
477 @code{RTLD_GLOBAL} flag. The practical upshot is that individual
beddd25fe24a [xemacs-hg @ 2002-06-24 22:00:17 by youngs]
youngs
parents: 775
diff changeset
478 modules do not have access to each other's C symbols. One module cannot
beddd25fe24a [xemacs-hg @ 2002-06-24 22:00:17 by youngs]
youngs
parents: 775
diff changeset
479 make a C function call to a function defined in another module, nor can
beddd25fe24a [xemacs-hg @ 2002-06-24 22:00:17 by youngs]
youngs
parents: 775
diff changeset
480 it read or set a C variable in another module. All interaction between
beddd25fe24a [xemacs-hg @ 2002-06-24 22:00:17 by youngs]
youngs
parents: 775
diff changeset
481 modules must, therefore, take place at the Lisp level. This is by
beddd25fe24a [xemacs-hg @ 2002-06-24 22:00:17 by youngs]
youngs
parents: 775
diff changeset
482 design. Other projects have attempted to use @code{RTLD_GLOBAL}, only
beddd25fe24a [xemacs-hg @ 2002-06-24 22:00:17 by youngs]
youngs
parents: 775
diff changeset
483 to find that spurious symbol name clashes were the result. Helper
beddd25fe24a [xemacs-hg @ 2002-06-24 22:00:17 by youngs]
youngs
parents: 775
diff changeset
484 functions often have simple names, increasing the probability of such a
beddd25fe24a [xemacs-hg @ 2002-06-24 22:00:17 by youngs]
youngs
parents: 775
diff changeset
485 clash. If you really need to share symbols between modules, create a
beddd25fe24a [xemacs-hg @ 2002-06-24 22:00:17 by youngs]
youngs
parents: 775
diff changeset
486 shared library containing those symbols, and link your modules with
beddd25fe24a [xemacs-hg @ 2002-06-24 22:00:17 by youngs]
youngs
parents: 775
diff changeset
487 that library. Otherwise, interactions between modules must take place
beddd25fe24a [xemacs-hg @ 2002-06-24 22:00:17 by youngs]
youngs
parents: 775
diff changeset
488 via Lisp function calls and Lisp variables accesses.
beddd25fe24a [xemacs-hg @ 2002-06-24 22:00:17 by youngs]
youngs
parents: 775
diff changeset
489
2972
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
490 @node Using ellcc, Distribution with XEmacs, Anatomy of a Module, Top
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 @chapter Using @code{ellcc}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 @cindex @code{ellcc}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 @cindex module compiler
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 Before discussing the anatomy of a module in greater detail, you should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 be aware of the steps required in order to correctly compile and link a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 module for use within @value{emacs}. There is little difference between
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 compiling normal C code and compiling a module. In fact, all that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 changes is the command used to compile the module, and a few extra
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 arguments to the compiler.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 @value{emacs} now ships with a new user utility, called @code{ellcc}. This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503 is the @dfn{Emacs Loadable Library C Compiler}. This is a wrapper
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 program that will invoke the real C compiler with the correct arguments
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505 to compile and link your module. With the exception of a few command
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 line options, this program can be considered a replacement for your C
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 compiler. It accepts all of the same flags and arguments that your C
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 compiler does, so in many cases you can simply set the @code{make}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 variable @code{CC} to @code{ellcc} and your code will be compiled as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 an Emacs module rather than a static C object.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512 @code{ellcc} has three distinct modes of operation. It can be run in
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
513 compile, link or initialization mode. These modes are discussed in more
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514 detail below. If you want @code{ellcc} to show the commands it is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 executing, you can specify the option @code{--mode=verbose} to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 @code{ellcc}. Specifying this option twice will enable certain extra
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 debugging messages to be displayed on the standard output.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 @menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 * Compile Mode:: Compiling modules using ellcc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 * Initialization Mode:: Generating documentation and variables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 * Link Mode:: Creating the final loadable module
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 * Other ellcc options:: Other useful options
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 * Environment Variables:: How to control ellcc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 @end menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 @node Compile Mode, Initialization Mode, Using ellcc, Using ellcc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 @section Compile Mode
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529 @cindex compiling
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 By default, @code{ellcc} is in @dfn{compile} mode. This means that it
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
532 assumes that all of the command line arguments are C compiler arguments,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 and that you want to compile the specified source file or files. You
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534 can force compile mode by specifying the @code{--mode=compile} argument
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 to @code{ellcc}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 In this mode, @code{ellcc} is simply a front-end to the same C compiler
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 that was used to create the @value{emacs} binary itself. All @code{ellcc}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 does in this mode is insert a few extra command line arguments before
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 the arguments you specify to @code{ellcc} itself. @code{ellcc} will
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541 then invoke the C compiler to compile your module, and will return the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 same exit codes and messages that your C compiler does.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544 By far the easiest way to compile modules is to construct a
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
545 @file{Makefile} as you would for a normal program, and simply insert, at
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546 some appropriate place something similar to:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 @cartouche
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 CC=ellcc --mode=compile
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 .c.o:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553 $(CC) $(CFLAGS) -c $<
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 @end cartouche
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557 After this, all you need to do is provide simple @code{make} rules for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 compiling your module source files. Since modules are most useful when
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 they are small and self-contained, most modules will have a single
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 source file, aside from the module specific initialization file (see
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 below for details).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563 @node Initialization Mode, Link Mode, Compile Mode, Using ellcc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 @section Initialization Mode
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 @cindex initialization
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566 @cindex documentation
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 @value{emacs} uses a rather bizarre way of documenting variables and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 functions. Rather than have the documentation for compiled functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 and variables passed as static strings in the source code, the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571 documentation is included as a C comment. A special program, called
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 @file{make-docfile}, is used to scan the source code files and extract
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
573 the documentation from these comments, producing the @value{emacs} @file{DOC}
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 file, which the internal help engine scans when the documentation for a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 function or variable is requested.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 Due to the internal construction of Lisp objects, subrs and other such
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578 things, adding documentation for a compiled function or variable in a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 compiled module, at any time after @value{emacs} has been @dfn{dumped} is
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
580 somewhat problematic. Fortunately, as a module writer you are insulated
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 from the difficulties thanks to your friend @code{ellcc} and some
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582 internal trickery in the module loading code. This is all done using
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 the @dfn{initialization} mode of @code{ellcc}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 The result of running @code{ellcc} in initialization mode is a C source
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 file which you compile with (you guessed it) @code{ellcc} in compile
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 mode. Initialization mode is where you set the module name, version,
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
588 title and gather together all of the documentation strings for the
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
589 functions and variables in your module. There are several options that
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 you are required to pass @code{ellcc} in initialization mode, the first
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 of which is the mode switch itself, @code{--mode=init}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 Next, you need to specify the name of the C source code file that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 @code{ellcc} will produce, and you specify this using the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 @code{--mod-output=FILENAME} argument. @var{FILENAME} is the name of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 the C source code file that will contain the module variables and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 @code{docs_of_module} function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 As discussed previously, each module requires a short @dfn{handle} or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 module name. This is specified with the @code{--mod-name=NAME} option,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 where @var{NAME} is the abbreviated module name. This @var{NAME} must
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 consist only of characters that are valid in C function and variable
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 names.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 The module version is specified using @code{--mod-version=VERSION}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 argument, with @var{VERSION} being any arbitrary version string. This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 version can be passed as an optional second argument to the Lisp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 function @code{load-module}, and as the third argument to the internal
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 module loading command @code{emodules_load}. This version string is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610 used to distinguish between different versions of the same module, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 to ensure that the module is loaded at a specific version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 Last, but not least, is the module title. Specified using the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 @code{--mod-title=TITLE} option, the specified @var{TITLE} is used when
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615 the list of loaded modules is displayed. The module title serves no
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 purpose other than to inform the user of the function of the module.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 This string should be brief, as it has to be formatted to fit the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 screen.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 Following all of these parameters, you need to provide the list of all
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
621 source code modules that make up your module. These are the files which
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
622 are scanned by @file{make-docfile}, and provide the information required
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 to populate the @code{docs_of_module} function. Below is a sample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 @file{Makefile} fragment which indicates how all of this is used.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 @cartouche
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 CC=ellcc --mode=compile
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629 LD=ellcc --mode=link
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 MODINIT=ellcc --mode=init
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 CFLAGS=-O2 -DSOME_STUFF
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 .c.o:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 $(CC) $(CFLAGS) -c $<
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 MODNAME=sample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 MODVER=1.0.0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 MODTITLE="Small sample module"
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640 SRCS=modfile1.c modfile2.c modfile3.c
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 OBJS=$(SRCS:.c=.o)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 all: sample.ell
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644 clean:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 rm -f $(OBJS) sample_init.o sample.ell
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 install: all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 mkdir `ellcc --mod-location`/mymods > /dev/null
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649 cp sample.ell `ellcc --mod-location`/mymods/sample.ell
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651 sample.ell: $(OBJS) sample_init.o
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 $(LD) --mod-output=$@ $(OBJS) sample_init.o
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 sample_init.o: sample_init.c
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 sample_init.c: $(SRCS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 $(MODINIT) --mod-name=$(MODNAME) --mod-version=$(MODVER) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657 --mod-title=$(MODTITLE) --mod-output=$@ $(SRCS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 @end cartouche
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 The above @file{Makefile} is, in fact, complete, and would compile the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 sample module, and optionally install it. The @code{--mod-location}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663 argument to @code{ellcc} will produce, on the standard output, the base
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 location of the @value{emacs} module directory. Each sub-directory of that
625
33f0f28b945c [xemacs-hg @ 2001-07-02 20:45:03 by adrian]
adrian
parents: 450
diff changeset
665 directory is automatically searched for modules when they are loaded with
33f0f28b945c [xemacs-hg @ 2001-07-02 20:45:03 by adrian]
adrian
parents: 450
diff changeset
666 @code{load-module}. An alternative location would be
33f0f28b945c [xemacs-hg @ 2001-07-02 20:45:03 by adrian]
adrian
parents: 450
diff changeset
667 @file{/usr/local/lib/xemacs/site-modules}. That path can change depending
33f0f28b945c [xemacs-hg @ 2001-07-02 20:45:03 by adrian]
adrian
parents: 450
diff changeset
668 on the options the person who compiled @value{emacs} chose, so you can
33f0f28b945c [xemacs-hg @ 2001-07-02 20:45:03 by adrian]
adrian
parents: 450
diff changeset
669 always determine the correct site location using the
33f0f28b945c [xemacs-hg @ 2001-07-02 20:45:03 by adrian]
adrian
parents: 450
diff changeset
670 @code{--mod-site-location} option. This directory is treated the same way
33f0f28b945c [xemacs-hg @ 2001-07-02 20:45:03 by adrian]
adrian
parents: 450
diff changeset
671 as the main module directory. Each sub-directory within it is searched for
33f0f28b945c [xemacs-hg @ 2001-07-02 20:45:03 by adrian]
adrian
parents: 450
diff changeset
672 a given module when the user attempts to load it. The valid extensions that
33f0f28b945c [xemacs-hg @ 2001-07-02 20:45:03 by adrian]
adrian
parents: 450
diff changeset
673 the loader attempts to use are @file{.so}, @file{.ell} and @file{.dll}. You
33f0f28b945c [xemacs-hg @ 2001-07-02 20:45:03 by adrian]
adrian
parents: 450
diff changeset
674 can use any of these extensions, although @file{.ell} is the preferred
33f0f28b945c [xemacs-hg @ 2001-07-02 20:45:03 by adrian]
adrian
parents: 450
diff changeset
675 extension.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677 @node Link Mode, Other ellcc options, Initialization Mode, Using ellcc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 @section Link Mode
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 @cindex linking
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 Once all of your source code files have been compiled (including the
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
682 generated init file) you need to link them all together to create the
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 loadable module. To do this, you invoke @code{ellcc} in link mode, by
450
98528da0b7fc Import from CVS: tag r21-2-40
cvs
parents: 442
diff changeset
684 passing the @code{--mode=link} option. You need to specify the final
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
685 output file using the @code{--mod-output=NAME} option, but other than
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 that all other arguments are passed on directly to the system compiler
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687 or linker, along with any other required arguments to create the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 loadable module.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 The module has complete access to all symbols that were present in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 dumped @value{emacs}, so you do not need to link against libraries that were
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692 linked in with the main executable. If your library uses some other
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 extra libraries, you will need to link with those. There is nothing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 particularly complicated about link mode. All you need to do is make
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 sure you invoke it correctly in the @file{Makefile}. See the sample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696 @file{Makefile} above for an example of a well constructed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 @file{Makefile} that invoked the linker correctly.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 @node Other ellcc options, Environment Variables, Link Mode, Using ellcc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700 @section Other @code{ellcc} options
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 @cindex paths
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703 Aside from the three main @code{ellcc} modes described above,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 @code{ellcc} can accept several other options. These are typically used
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
705 in a @file{Makefile} to determine installation paths. @code{ellcc} also
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 allows you to over-ride several of its built-in compiler and linker
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707 options using environment variables. Here is the complete list of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 options that @code{ellcc} accepts.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 @table @code
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 @item --mode=compile
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712 Enables compilation mode. Use this to compile source modules.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 @item --mode=link
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 Enabled link edit mode. Use this to create the final module.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 @item --mode=init
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718 Used to create the documentation function and to initialize other
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
719 required variables. Produces a C source file that must be compiled with
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 @code{ellcc} in compile mode before linking the final module.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722 @item --mode=verbose
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 Enables verbose mode. This will show you the commands that are being
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
724 executed, as well as the version number of @code{ellcc}. If you specify
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725 this option twice, then some extra debugging information is displayed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 @item --mod-name=NAME
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
728 Sets the short internal module @var{NAME} to the string specified,
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729 which must consist only of valid C identifiers. Required during
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 initialization mode.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 @item --mod-version=VERSION
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 Sets the internal module @var{VERSION} to the specified string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 Required during initialization mode.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736 @item --mod-title=TITLE
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 Sets the module descriptive @var{TITLE} to the string specified. This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 string can contain any printable characters, but should not be too
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 long. It is required during initialization mode.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 @item --mod-output=FILENAME
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742 Used to control the output file name. This is used during
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 initialization mode to set the name of the C source file that will be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 created to @var{FILENAME}. During link mode, it sets the name of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745 final loadable module to @var{FILENAME}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 @item --mod-location
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
748 This will print the name of the standard module installation path on the
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749 standard output and immediately exit @code{ellcc}. Use this option to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 determine the directory prefix of where you should install your modules.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752 @item --mod-site-location
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 This will print the name of the site specific module location and exit.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 @item --mod-archdir
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
756 Prints the name of the root of the architecture-dependent directory that
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
757 @value{emacs} searches for architecture-dependent files.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 @item --mod-config
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
760 Prints the name of the configuration for which @value{emacs} and @code{ellcc}
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 were compiled.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 @node Environment Variables, , Other ellcc options, Using ellcc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 @section Environment Variables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 @cindex environment variables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 During its normal operation, @code{ellcc} uses the compiler and linker
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769 flags that were determined at the time @value{emacs} was configured. In
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
770 certain rare circumstances you may wish to over-ride the flags passed to
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 the compiler or linker, and you can do so using environment variables.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
772 The table below lists all of the environment variables that @code{ellcc}
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
773 recognizes.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 @table @code
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 @item ELLCC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 @cindex @code{ELLCC}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778 This is used to over-ride the name of the C compiler that is invoked by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 @code{ellcc}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 @item ELLLD
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 @cindex @code{ELLLD}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 Sets the name of the link editor to use to created the final module.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 @item ELLCFLAGS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786 @cindex @code{ELLCFLAGS}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 Sets the compiler flags passed on when compiling source modules. This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 only sets the basic C compiler flags. There are certain hard-coded
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 flags that will always be passed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 @item ELLLDFLAGS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 @cindex @code{ELLLDFLAGS}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 Sets the flags passed on to the linker. This does @strong{not} include
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 the flags for enabling PIC mode. This just sets basic linker flags.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 @item ELLDLLFLAGS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797 @cindex @code{ELLDLLFLAGS}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 Sets the flags passed to the linker that are required to created shared
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 and loadable objects.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801 @item ELLPICFLAGS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 @cindex @code{ELLPICFLAGS}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 Sets the C compiler option required to produce an object file that is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804 suitable for including in a shared library. This option should turn on
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 PIC mode, or the moral equivalent thereof on the target system.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 @item ELLMAKEDOC
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 @cindex @code{ELLMAKEDOC}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 Sets the name of the @file{make-docfile} program to use. Usually
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810 @code{ellcc} will use the version that was compiled and installed with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 @value{emacs}, but this option allows you to specify an alternative path.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 Used during the compile phase of @value{emacs} itself.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814
2972
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
815 @node Distribution with XEmacs, Defining Functions, Using ellcc, Top
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
816 @chapter Adding Modules to the XEmacs Distribution
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
817 @cindex XEmacs integration
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
818 @cindex integration, XEmacs
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
819 @cindex modules and configure.ac
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
820 @cindex configure.ac, modules and
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
821 @cindex modules and Makefiles
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
822 @cindex Makefiles, modules and
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
823
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
824 #### This section needs to be filled out.
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
825
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
826 @strong{Warning: The procedure described in the section is subject to
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
827 change, as it is very stylized and thus a good candidate for further
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
828 automation.}
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
829
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
830 Modules distributed with XEmacs are placed in the @file{modules}
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
831 subdirectory of the root of the source tree. Each module's code is
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
832 placed in a separate subdirectory. The build infrastructure for a
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
833 module consists of a @file{Makefile.in.in}, a @file{configure.ac}, and
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
834 @file{install-sh}. @file{install-sh} is a constant, and may simply be
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
835 copied from an existing module.
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
836
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
837 Most of the job of building a module is encapsulated in
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
838 @file{modules/common/Makefile.common} and in @file{ellcc}. The module's
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
839 @file{Makefile.in.in} normally needs only to define module name and
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
840 version information, and include @file{modules/common/Makefile.common}.
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
841 The @file{configure.ac} is very module-specific, and little can be said
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
842 about its contents. However, since no logic that depends on XEmacs
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
843 itself or other modules needs to be present, it is easier to write and
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
844 maintain than if it were contained in the XEmacs distribution's
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
845 @file{configure.ac}.
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
846
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
847 Modules can usually be trivially built in to the XEmacs binary. To make
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
848 this work, you need to duplicate the detection logic for any resources
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
849 the module requires in the top-level @file{configure.ac}. Since module
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
850 objects may be linked into modules or into @file{xemacs}, instead of
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
851 adding library path and library information directly to some
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
852 @file{@var{subsystem}_libs} variable, you should add them to a
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
853 @file{@var{module}_libs} variable, which in turn must be added to
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
854 @code{ld_libs_module} in the section ``Compute SUBST-itutable variables.''
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
855
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
856 Furthermore, in @file{src/Makefile.in.in} you add rules to build the
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
857 object without the module wrapper, and conditionalize these and the
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
858 addition of the object to @code{objs} on @code{HAVE_SHLIB}. The right
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
859 way to do this is somewhat indirect. Study the integration of LDAP and
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
860 PostgreSQL for the details.
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
861
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
862
2b58b7fd831c [xemacs-hg @ 2005-10-04 17:00:32 by stephent]
stephent
parents: 880
diff changeset
863 @node Defining Functions, Defining Variables, Distribution with XEmacs, Top
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864 @chapter Defining Functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 @cindex defining functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867 One of the main reasons you would ever write a module is to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 provide one or more @dfn{functions} for the user or the editor to use.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
869 The term
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 @dfn{function} is a bit overloaded here, as it refers to both a C
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 function and the way it appears to Lisp, which is a @dfn{subroutine}, or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 simply a @dfn{subr}. A Lisp subr is also known as a Lisp primitive, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 that term applies less to dynamic modules. @xref{Writing Lisp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874 Primitives,,,internals,@value{emacs} Internals Manual}, for details on how to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 declare functions. You should familiarize yourself with the
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
876 instructions there. The format of the function declaration is identical
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877 in modules.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
879 Normal Lisp primitives document the functions they defining by including
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 the documentation as a C comment. During the build process, a program
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 called @file{make-docfile} is run, which will extract all of these
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 comments, build up a single large documentation file, and will store
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 pointers to the start of each documentation entry in the dumped @value{emacs}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 This, of course, will not work for dynamic modules, as they are loaded
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885 long after @value{emacs} has been dumped. For this reason, we require a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 special means for adding documentation for new subrs. This is what the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 macro @code{CDOCSUBR} is used for, and this is used extensively during
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 @code{ellcc} initialization mode.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 When using @code{DEFUN} in normal @value{emacs} C code, the sixth
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 ``parameter'' is a C comment which documents the function. For a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 dynamic module, we of course need to convert the C comment to a usable
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
893 string, and we need to set the documentation pointer of the subr to this
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 string. As a module programmer, you don't actually need to do any work
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 for this to happen. It is all taken care of in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 @code{docs_of_module} function created by @code{ellcc}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 @menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 * Using DEFUN:: Using the DEFUN macro to define functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 * Declaring Functions:: Declaring functions to the Lisp reader
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 @end menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 @node Using DEFUN, Declaring Functions, Defining Functions, Defining Functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 @section Using @code{DEFUN}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905 @cindex subrs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 @findex DEFUN
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 @cindex functions, Lisp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908 @cindex functions, defining
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909
775
7d972c3de90a [xemacs-hg @ 2002-03-14 11:50:12 by stephent]
stephent
parents: 721
diff changeset
910 The full syntax of a function declaration is discussed in the
7d972c3de90a [xemacs-hg @ 2002-03-14 11:50:12 by stephent]
stephent
parents: 721
diff changeset
911 @value{emacs} internals manual in greater depth. @ref{Writing Lisp
7d972c3de90a [xemacs-hg @ 2002-03-14 11:50:12 by stephent]
stephent
parents: 721
diff changeset
912 Primitives,,,internals,@value{emacs} Internals Manual}. What follows is
7d972c3de90a [xemacs-hg @ 2002-03-14 11:50:12 by stephent]
stephent
parents: 721
diff changeset
913 a brief description of how to define and implement a new Lisp primitive
7d972c3de90a [xemacs-hg @ 2002-03-14 11:50:12 by stephent]
stephent
parents: 721
diff changeset
914 in a module. This is done using the @code{DEFUN} macro. Here is a
7d972c3de90a [xemacs-hg @ 2002-03-14 11:50:12 by stephent]
stephent
parents: 721
diff changeset
915 small example:
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
917 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
918 @cartouche
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
919 DEFUN ("my-function", Fmy_function, 1, 1, "FFile name: ", /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
920 Sample Emacs primitive function.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
921
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
922 The specified FILE is frobnicated before it is fnozzled.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
923 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
924 (file))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
925 @{
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
926 char *filename;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
927
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
928 if (NILP(file))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
929 return Qnil;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
930
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
931 filename = (char *)XSTRING_DATA(file);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
932 frob(filename);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
933 return Qt;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
934 @}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
935 @end cartouche
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
936 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
937
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
938 The first argument is the name of the function as it will appear to the
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
939 Lisp reader. This must be provided as a string. The second argument is
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
940 the name of the actual C function that will be created. This is
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
941 typically the Lisp function name with a preceding capital @code{F}, with
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
942 hyphens converted to underscores. This must be a valid C function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
943 name. Next come the minimum and maximum number of arguments,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
944 respectively. This is used to ensure that the correct number of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
945 arguments are passed to the function. Next is the @code{interactive}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
946 definition. If this function is meant to be run by a user
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
947 interactively, then you need to specify the argument types and prompts
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
948 in this string. Please consult the @value{emacs} Lisp manual for more
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
949 details. Next comes a C comment that is the documentation for this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
950 function. This comment @strong{must} exist. Last comes the list of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
951 function argument names, if any.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
952
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
953 @node Declaring Functions, , Using DEFUN, Defining Functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
954 @section Declaring Functions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
955 @findex DEFSUBR
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
956 @cindex functions, declaring
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
957
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
958 Simply writing the code for a function is not enough to make it
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
959 available to the Lisp reader. You have to, during module
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
960 initialization, let the Lisp reader know about the new function. This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
961 is done by calling @code{DEFSUBR} with the name of the function. This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
962 is the sole purpose of the initialization function
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
963 @code{syms_of_module}. @xref{Required Functions}, for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
964
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
965 Each call to @code{DEFSUBR} takes as its only argument the name of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
966 function, which is the same as the second argument to the call to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
967 @code{DEFUN}. Using the example function above, you would insert the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
968 following code in the @code{syms_of_module} function:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
969
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
970 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
971 @cartouche
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
972 DEFSUBR(Fmy_function);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
973 @end cartouche
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
974 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
975
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
976 This call will instruct @value{emacs} to make the function visible to the Lisp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
977 reader and will prepare for the insertion of the documentation into
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
978 the right place. Once this is done, the user can call the Lisp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
979 function @code{my-function}, if it was defined as an interactive
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
980 function (which in this case it was).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
981
4312
1094d6d400fb Spelling fixes.
"Ville Skyttä <scop@xemacs.org>"
parents: 2972
diff changeset
982 That's all there is to defining and announcing new functions. The rules
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
983 for what goes inside the functions, and how to write good modules, is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
984 beyond the scope of this document. Please consult the @value{emacs}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
985 internals manual for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
986
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
987 @node Defining Variables, Index, Defining Functions, Top
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
988 @chapter Defining Variables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
989 @cindex defining variables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
990 @cindex defining objects
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
991 @findex DEFVAR_LISP
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
992 @findex DEFVAR_BOOL
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
993 @findex DEFVAR_INT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
994 @cindex variables, Lisp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
995 @cindex variables, defining
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
996 @cindex objects, defining
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
997 @cindex objects, Lisp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
998
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
999 Rarely will you write a module that only contains functions. It is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1000 common to also provide variables which can be used to control the
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1001 behavior of the function, or store the results of the function being
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1002 executed. The actual C variable types are the same for modules
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1003 and internal @value{emacs} primitives, and the declaration of the variables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1004 is identical.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1005
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1006 @xref{Adding Global Lisp Variables,,,internals,XEmacs Internals Manual},
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1007 for more information on variables and naming conventions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1008
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1009 Once your variables are defined, you need to initialize them and make
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1010 the Lisp reader aware of them. This is done in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1011 @code{vars_of_module} initialization function using special @value{emacs}
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1012 macros such as @code{DEFVAR_LISP}, @code{DEFVAR_BOOL}, @code{DEFVAR_INT}
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1013 etc. The best way to see how to use these macros is to look at existing
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1014 source code, or read the internals manual.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1015
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1016 One @emph{very} important difference between @value{emacs} variables and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1017 module variables is how you use pure space. Simply put, you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1018 @strong{never} use pure space in @value{emacs} modules. The pure space
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 440
diff changeset
1019 storage is of a limited size, and is initialized properly during the
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1020 dumping of @value{emacs}. Because variables are being added dynamically to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1021 an already running @value{emacs} when you load a module, you cannot use pure
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1022 space. Be warned: @strong{do not use pure space in modules. Repeat, do
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1023 not use pure space in modules.} Once again, to remove all doubts:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1024 @strong{DO NOT USE PURE SPACE IN MODULES!!!}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1025
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1026 Below is a small example which declares and initializes two
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1027 variables. You will note that this code takes into account the fact
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1028 that this module may very well be compiled into @value{emacs} itself. This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1029 is a prudent thing to do.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1030
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1031 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1032 @cartouche
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1033 Lisp_Object Vsample_string;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1034 int sample_boolean;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1035
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1036 void
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1037 vars_of_module()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1038 @{
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1039 DEFVAR_LISP ("sample-string", &Vsample_string /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1040 This is a sample string, declared in a module.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1041
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1042 Nothing magical about it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1043 */);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1044
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1045 DEFVAR_BOOL("sample-boolean", &sample_boolean /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1046 *Sample user-settable boolean.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1047 */);
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1048
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1049 sample_boolean = 0;
4953
304aebb79cd3 function renamings to track names of char typedefs
Ben Wing <ben@xemacs.org>
parents: 4312
diff changeset
1050 Vsample_string = build_ascstring ("My string");
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1051 @}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1052 @end cartouche
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1053 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1054
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1055 @c Print the tables of contents
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1056 @contents
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1057 @c That's all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1058
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1059 @node Index, , Defining Variables, Top
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1060 @unnumbered Index
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1061
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1062 @printindex cp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1063
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1064 @bye
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1065