Mention libtool ./configure-regeneration requirement.
[bpt/guile.git] / HACKING
1 -*-text-*-
2 Guile Hacking Guide
3 Copyright (c) 1996, 1997, 1998, 1999, 2000, 2001 Free software Foundation, Inc.
4
5 Permission is granted to anyone to make or distribute verbatim copies
6 of this document as received, in any medium, provided that the
7 copyright notice and permission notice are preserved,
8 and that the distributor grants the recipient permission
9 for further redistribution as permitted by this notice.
10
11 Permission is granted to distribute modified versions
12 of this document, or of portions of it,
13 under the above conditions, provided also that they
14 carry prominent notices stating who last changed them,
15 and that any new or changed statements about the activities
16 of the Free Software Foundation are approved by the Foundation.
17
18
19 What to Hack =========================================================
20
21 You can hack whatever you want, thank GNU.
22
23 However, to see what others have indicated as their interest (and avoid
24 potential wasteful duplication of effort), see file TODO. Note that
25 the version you find may be out of date; a CVS checkout is recommended
26 (see also file SNAPSHOTS).
27
28 It's also a good idea to join the guile-devel@gnu.org mailing list.
29 See http://www.gnu.org/software/guile/mail/mail.html for more info.
30
31
32 Hacking It Yourself ==================================================
33
34 As distributed, Guile needs only an ANSI C compiler and a Unix system
35 to compile. However, Guile's makefiles, configuration scripts, and a
36 few other files are automatically generated, not written by hand. If
37 you want to make changes to the system (which we encourage!) you will
38 find it helpful to have the tools we use to develop Guile. They
39 are the following:
40
41 Autoconf 2.50 --- a system for automatically generating `configure'
42 scripts from templates which list the non-portable features a
43 program would like to use. Available in
44 "ftp://ftp.gnu.org/pub/gnu/autoconf"
45
46 Automake 1.4-p4 --- a system for automatically generating Makefiles that
47 conform to the (rather Byzantine) GNU coding standards. The
48 nice thing is that it takes care of hairy targets like 'make
49 dist' and 'make distclean', and automatically generates
50 Makefile dependencies. Automake is available in
51 "ftp://ftp.gnu.org/pub/gnu/automake"
52
53 Before using automake, you may need to copy `threads.m4' and
54 `guile.m4' from the top directory of the Guile core disty to
55 `/usr/local/share/aclocal'.
56
57 libtool 1.4 --- a system for managing the zillion hairy options needed
58 on various systems to produce shared libraries. Available in
59 "ftp://ftp.gnu.org/pub/gnu/libtool"
60
61 To avoid reported tricky errors during the Guile build: After
62 unpacking the libtool distribution, use autoconf (2.50) to
63 regenerate its ./configure script. Then build and install as
64 usual.
65
66 flex 2.5.4 (or newer) --- a scanner generator. earlier versions will
67 most probably work too.
68
69 You are lost in a little maze of automatically generated files, all
70 different.
71
72
73 Contributing Your Changes ============================================
74
75 - If you have put together a change that meets the coding standards
76 described below, we encourage you to submit it to Guile. The best
77 place to post it is guile-devel@gnu.org. Please don't send it
78 directly to me; I often don't have time to look things over. If you
79 have tested your change, then you don't need to be shy.
80
81 - Please submit patches using either context or unified diffs (diff -c
82 or diff -u). Don't include a patch for ChangeLog; such patches don't
83 apply cleanly, since we've probably changed the top of ChangeLog too.
84 Instead, provide the unaltered text at the top of your patch.
85
86 - For proper credit, also make sure you update the AUTHORS file
87 (for new files for which you've assigned copyright to the FSF), or
88 the THANKS file (for everything else).
89
90 Please don't include patches for generated files like configure,
91 aclocal.m4, or any Makefile.in. Such patches are often large, and
92 we're just going to regenerate those files anyway.
93
94
95 CVS conventions ======================================================
96
97 - We use CVS to manage the Guile sources. The repository lives on
98 subversions.gnu.org, in /cvs; you will need an
99 account on that machine to access the repository. Also, for security
100 reasons, subversions presently only supports CVS connections via the SSH
101 protocol, so you must first install the SSH client. Then, you should
102 set your CVS_RSH environment variable to ssh, and use the following as
103 your CVS root:
104
105 :ext:USER@subversions.gnu.org:/cvs
106
107 Either set your CVSROOT environment variable to that, or give it as
108 the value of the global -d option to CVS when you check out a working
109 directory.
110
111 For more information on SSH, see http://www.cs.hut.fi/ssh.
112
113 The Guile sources live in several modules:
114
115 - guile-core --- the interpreter, QuickThreads, and ice-9
116 - guile-tcltk --- the Guile/Tk interface
117 - guile-tk --- the new Guile/Tk interface, based on STk's modified Tk
118 - guile-rgx-ctax --- the Guile/Rx interface, and the ctax implementation
119 - guile-scsh --- the port of SCSH to guile, talk to Gary Houston
120 - guile-www --- A Guile module for making HTTP requests.
121 - guile-statprof --- an experimental statistical profiler.
122
123 There is a mailing list for CVS commit messages; see README for details.
124
125 - The guile-core tree is now versioned similarly to the Linux kernel.
126 Guile now always uses three numbers to represent the version,
127 i.e. "1.6.5". The first number, 1, is the major version number, the
128 second number, 6, is the minor version number, and the third number,
129 5, is the micro version number. Changes in major version number
130 indicate major changes in Guile.
131
132 Minor version numbers that are even denote stable releases, and odd
133 minor version numbers denote development versions (which may be
134 unstable). The micro version number indicates a minor sub-revision of
135 a given MAJOR.MINOR release.
136
137 - A default CVS checkout will get the current unstable development
138 tree. However, for each stable release, a CVS branch is created so
139 that release (and ongoing maintenance) of the stable version can
140 proceed independent of the development of the next unstable version.
141 To check out a particular stable branch, you just need to specify "-r
142 branch_release-X-Y" to your CVS checkout command (or to any update).
143 For example, if you wanted to check out the 1.6 stable branch, you
144 would specify "-r branch_release-1-6".
145
146 So, for example, during a normal development cycle, work will proceed
147 on an unstable version, say 1.5.X, until it is decided that it's time
148 for a stable release. At that point, a branch named
149 branch_release-1-6 will be created, and the version numbers on the
150 HEAD of the CVS tree (the trunk, i.e. what you get by default), will
151 be changed to reflect the new unstable version 1.7.X. Then unstable
152 development will proceed on the unstable version, while the stable
153 1.5.X branch is fixed up for the eventual 1.6.0 release.
154
155 Anytime you want to yank an existing checked out tree to the stable
156 branch, you can run a command like this:
157
158 cvs -z3 update -r branch_release-1-6 -Pd
159
160 This will yank the working directory over on to the stable release
161 branch. Note that this directory will track that branch from then on
162 unless you do something to yank it back to the main (unstable) trunk.
163
164 To go back to the unstable branch, you can use
165
166 cvs -z3 update -A -Pd
167
168 Note that in either case, you should probably make sure you've
169 commited or removed all local changes before running the commands or
170 you're likely to have some unexpected results.
171
172 Finally note that one approach, should you need to work on both
173 branches, is to keep two trees checked out, one stable, the other
174 unstable and you can work in whichever is appropriate.
175
176 To save some initial bandwidth, you can check out either the stable
177 tree or the unstable tree, and then do something like this:
178
179 cp -a core-unstable core-1.5
180 cd core-1.5
181 cvs -z3 update -r branch_release-1-6 -Pd
182
183 - The stable and unstable CVS trees are distinct, and no changes will
184 automatically propagate between them. If you make changes that need
185 to show up both places, you'll need to apply the changes both places.
186 You *might* be able to do this with a cvs command, but often you'll
187 probably need to apply the changes by hand or risk migrating
188 superfluous modifications between the two versions. This is
189 particularly important when moving a change from the unstable branch
190 to the stable branch.
191
192 - In general, please don't be adventurous with the stable branch. We
193 mostly want bugfixes, documentation improvements, build improvements,
194 etc., though exceptions will doubtless exist.
195
196 - There are a few CVS tagging conventions which follow the Scheme
197 convention that dashes are used to separate words within a single
198 symbol, and so dashes bind more tightly than underscores. This means
199 that foo-bar_baz-bax indicates that foo-bar is somehow separate from
200 baz-bax. The conventions are as follows:
201
202 Branch root tags:
203 -----------------
204 anytime just before you create a branch it's a good
205 idea to create a normal tag so that you can refer to the branch point
206 on the main trunk as well as on the branch. So please use a tag of
207 the form
208
209 branch-root-release-1-X
210
211 or more generally, for other non-release branches:
212
213 branch-root_FOO
214
215 Branch tags:
216 ------------
217 for the branch tag itself please use
218
219 branch_release-1-6
220
221 or more generally, for other non-release branches:
222
223 branch_FOO
224
225 Merge tags:
226 -----------
227 Whenever you're merging a branch back into the trunk (or into another
228 branch repeatedly) you need to tag the branch each time you merge. If
229 you don't do that, you won't be able to merge repeatedly without
230 possibly tedious conflicts. For those tags, we suggest:
231
232 branch-merge_SOME-FOO_to_SOME-BAR_1
233 branch-merge_SOME-FOO_to_SOME-BAR_2
234 ..
235
236 As an example, SOME-BAR might be trunk, or even perhaps another branch
237 like branch-mvo-super-fixes :>
238
239 More mundanely, you might have
240
241 branch-merge_release-1-6_to_trunk_1
242
243 (Merging the stable branch to the trunk like this
244 will probably be much more common, when it happens, than the
245 reverse for the reasons mentioned above.
246
247 Release tags:
248 -------------
249 When releasing a new version of guile, please use:
250
251 release_X-Y-Z
252
253 i.e.
254
255 release_1-6-0
256
257 - If you hack on a stable branch, please apply any relevant patches or
258 fixes to the current unstable version (the main CVS trunk) as well.
259 Similarly, please back-port any important fixes to the unstable CVS
260 tree to the current stable branch.
261
262 - We check Makefile.am and configure.in files into CVS, but the
263 "autogen.sh" script must be run from the top-level to generate the
264 actual "configure" script that then must be run to create the various
265 Makefile-s to build guile. The general rule is that you should be able
266 to check out a working directory of Guile from CVS, and then type
267 "./autogen.sh", then "configure", and finally "make". No
268 automatically generated files should be checked into the CVS
269 repository.
270
271 - The .cvsignore file is contained in the repository, to provide a
272 reasonable list of auto-generated files that should not be checked in.
273 This, however, prohibits one from having local additions to the
274 .cvsignore file (yes, you can modify it and never check it in, but
275 that doesn't seem to be a good solution to me). To get around this
276 problem, you might want to patch your cvs program so that it uses a
277 .cvsignore-local file (say) instead of the one from the repository. A
278 patch for this can be found at the very end of this file.
279
280 - (Automake 1.4 only) Be sure to run automake at the top of the tree
281 with no arguments. Do not use `automake Makefile' to regenerate
282 specific Makefile.in files, and do not trust the Makefile rules to
283 rebuild them when they are out of date. Automake 1.4 will add
284 extraneous rules to the top-level Makefile if you specify specific
285 Makefiles to rebuild on the command line. Running the command
286 `autoreconf --force' should take care of everything correctly.
287
288 - Make sure your changes compile and work, at least on your own
289 machine, before checking them into the main branch of the Guile
290 repository. If you really need to check in untested changes, make a
291 branch.
292
293 - Include each log entry in both the ChangeLog and in the CVS logs.
294 If you're using Emacs, the pcl-cvs interface to CVS has features to
295 make this easier; it checks the ChangeLog, and generates good default
296 CVS log entries from that.
297
298
299 Coding standards =====================================================
300
301 - Before contributing larger amounts of code to Guile, please read the
302 documents in `guile-core/devel/policy' in the CVS source tree.
303
304 - As for any part of Project GNU, changes to Guile should follow the
305 GNU coding standards. The standards are available via anonymous FTP
306 from prep.ai.mit.edu, as /pub/gnu/standards/standards.texi and
307 make-stds.texi.
308
309 - The Guile tree should compile without warnings under the following
310 GCC switches, which are the default in the current configure script:
311
312 -O2 -Wall -Wpointer-arith -Wmissing-prototypes
313
314 To make sure of this, you can use the --enable-error-on-warning option
315 to configure. This option will make GCC fail if it hits a warning.
316
317 Note that the warnings generated vary from one version of GCC to the
318 next, and from one architecture to the next (apparently). To provide
319 a concrete common standard, Guile should compile without warnings from
320 GCC 2.7.2.3 in a Red Hat 5.2 i386 Linux machine. Furthermore, each
321 developer should pursue any additional warnings noted by on their
322 compiler. This means that people using more stringent compilers will
323 have more work to do, and assures that everyone won't switch to the
324 most lenient compiler they can find. :)
325
326 Note also that EGCS (as of November 3 1998) doesn't handle the
327 `noreturn' attribute properly, so it doesn't understand that functions
328 like scm_error won't return. This may lead to some silly warnings
329 about uninitialized variables. You should look into these warnings to
330 make sure they are indeed spurious, but you needn't correct warnings
331 caused by this EGCS bug.
332
333 - If you add code which uses functions or other features that are not
334 entirely portable, please make sure the rest of Guile will still
335 function properly on systems where they are missing. This usually
336 entails adding a test to configure.in, and then adding #ifdefs to your
337 code to disable it if the system's features are missing.
338
339 - The normal way of removing a function, macro or variable is to mark
340 it as "deprecated", keep it for a while, and remove it in a later
341 release. If a function or macro is marked as "deprecated" it
342 indicates that people shouldn't use it in new programs, and should try
343 to remove it in old. Make sure that an alternative exists unless it
344 is our purpose to remove functionality. Don't deprecate definitions
345 if it is unclear when they will be removed. (This is to ensure that a
346 valid way of implementing some functionality always exists.)
347
348 When deprecating a definition, always follow this procedure:
349
350 1. Mark the definition using
351
352 #if (SCM_DEBUG_DEPRECATED == 0)
353 ...
354 #endif
355
356 or, for Scheme code, wrap it using
357
358 (begin-deprecated
359 ...)
360
361 2. Make the deprecated code issue a warning when it is used, by using
362 scm_c_issue_deprecation_warning (in C) or issue-deprecation-warning
363 (in Scheme).
364
365 3. Write a comment at the definition explaining how a programmer can
366 manage without the deprecated definition.
367
368 4. Add an entry that the definition has been deprecated in NEWS and
369 explain what do do instead.
370
371 5. In file TODO, there is a list of releases with reminders about what
372 to do at each release. Add a reminder about the removal of the
373 deprecated defintion at the appropriate release.
374
375 - When you make a user-visible change (i.e. one that should be
376 documented, and appear in NEWS, put an asterisk in column zero of the
377 start of the ChangeLog entry, like so:
378
379 Sat Aug 3 01:27:14 1996 Gary Houston <ghouston@actrix.gen.nz>
380
381 * * fports.c (scm_open_file): don't return #f, throw error.
382
383 When you've written a NEWS entry and updated the documentation, go
384 ahead and remove the asterisk. The asterisks are used to find and
385 document changes that haven't been dealt with before a release.
386
387 - Please write log entries for functions written in C under the
388 functions' C names, and write log entries for functions written in
389 Scheme under the functions' Scheme names. Please don't do this:
390
391 * procs.c, procs.h (procedure-documentation): Moved from eval.c.
392
393 Entries like this make it harder to search the ChangeLogs, because you
394 can never tell which name the entry will refer to. Instead, write this:
395
396 * procs.c, procs.h (scm_procedure_documentation): Moved from eval.c.
397
398 Changes like adding this line are special:
399
400 SCM_PROC (s_map_in_order, "map-in-order", 2, 0, 1, scm_map);
401
402 Since the change here is about the name itself --- we're adding a new
403 alias for scm_map that guarantees the order in which we process list
404 elements, but we're not changing scm_map at all --- it's appropriate
405 to use the Scheme name in the log entry.
406
407 - There's no need to keep a change log for documentation files. This
408 is because documentation is not susceptible to bugs that are hard to
409 fix. Documentation does not consist of parts that must interact in a
410 precisely engineered fashion; to correct an error, you need not know
411 the history of the erroneous passage. (This is copied from the GNU
412 coding standards.)
413
414 - Make sure you have papers from people before integrating their
415 changes or contributions. This is very frustrating, but very
416 important to do right. From maintain.texi, "Information for
417 Maintainers of GNU Software":
418
419 When incorporating changes from other people, make sure to follow the
420 correct procedures. Doing this ensures that the FSF has the legal
421 right to distribute and defend GNU software.
422
423 For the sake of registering the copyright on later versions ofthe
424 software you need to keep track of each person who makes significant
425 changes. A change of ten lines or so, or a few such changes, in a
426 large program is not significant.
427
428 *Before* incorporating significant changes, make sure that the person
429 has signed copyright papers, and that the Free Software Foundation has
430 received them.
431
432 If you receive contributions you want to use from someone, let me know
433 and I'll take care of the administrivia. Put the contributions aside
434 until we have the necessary papers.
435
436 Once you accept a contribution, be sure to keep the files AUTHORS and
437 THANKS uptodate.
438
439 - When you make substantial changes to a file, add the current year to
440 the list of years in the copyright notice at the top of the file.
441
442 - When you get bug reports or patches from people, be sure to list
443 them in THANKS.
444
445
446 Naming conventions =================================================
447
448 We use certain naming conventions to structure the considerable number
449 of global identifiers. All identifiers should be either all lower
450 case or all upper case. Syllables are separated by underscores `_'.
451 All non-static identifiers should start with scm_ or SCM_. Then might
452 follow zero or more syllables giving the category of the identifier.
453 The currently used category identifiers are
454
455 t - type name
456
457 c,C - something with a interface suited for C use. This is used
458 to name functions that behave like Scheme primitives but
459 have a more C friendly calling convention.
460
461 i,I - internal to libguile. It is global, but not considered part
462 of the libguile API.
463
464 f - a SCM variable pointing to a Scheme function object.
465
466 F - a bit mask for a flag.
467
468 m - a macro transformer procedure
469
470 n,N - a count of something
471
472 s - a constant C string
473
474 k - a SCM variable pointing to a keyword.
475
476 sym - a SCM variable pointing to a symbol.
477
478 var - a SCM variable pointing to a variable object.
479
480 The follwing syllables also have a technical meaning:
481
482 str - this denotes a zero terminated C string
483
484 mem - a C string with an explicit count
485
486
487 See also the file `devel/names.text'.
488
489
490 Helpful hints ========================================================
491
492 - [From Mikael Djurfeldt] When working on the Guile internals, it is
493 quite often practical to implement a scheme-level procedure which
494 helps you examine the feature you're working on.
495
496 Examples of such procedures are: pt-size, debug-hand and
497 current-pstate.
498
499 I've now put #ifdef GUILE_DEBUG around all such procedures, so that
500 they are not compiled into the "normal" Guile library. Please do the
501 same when you add new procedures/C functions for debugging purpose.
502
503 You can define the GUILE_DEBUG flag by passing --enable-guile-debug to
504 the configure script.
505
506 - You'll see uses of the macro SCM_P scattered throughout the code;
507 those are vestiges of a time when Guile was meant to compile on
508 pre-ANSI compilers. Guile now requires ANSI C, so when you write new
509 functions, feel free to use ANSI declarations, and please provide
510 prototypes for everything. You don't need to use SCM_P in new code.
511
512
513 Jim Blandy, and others
514
515
516 Patches ===========================================================
517
518 This one makes cvs-1.10 consider the file $CVSDOTIGNORE instead of
519 .cvsignore when that environment variable is set.
520
521 === patch start ===
522 diff -r -u cvs-1.10/src/cvs.h cvs-1.10.ignore-hack/src/cvs.h
523 --- cvs-1.10/src/cvs.h Mon Jul 27 04:54:11 1998
524 +++ cvs-1.10.ignore-hack/src/cvs.h Sun Jan 23 12:58:09 2000
525 @@ -516,7 +516,7 @@
526
527 extern int ign_name PROTO ((char *name));
528 void ign_add PROTO((char *ign, int hold));
529 -void ign_add_file PROTO((char *file, int hold));
530 +int ign_add_file PROTO((char *file, int hold));
531 void ign_setup PROTO((void));
532 void ign_dir_add PROTO((char *name));
533 int ignore_directory PROTO((char *name));
534 diff -r -u cvs-1.10/src/ignore.c cvs-1.10.ignore-hack/src/ignore.c
535 --- cvs-1.10/src/ignore.c Mon Sep 8 01:04:15 1997
536 +++ cvs-1.10.ignore-hack/src/ignore.c Sun Jan 23 12:57:50 2000
537 @@ -99,9 +99,9 @@
538 /*
539 * Open a file and read lines, feeding each line to a line parser. Arrange
540 * for keeping a temporary list of wildcards at the end, if the "hold"
541 - * argument is set.
542 + * argument is set. Return true when the file exists and has been handled.
543 */
544 -void
545 +int
546 ign_add_file (file, hold)
547 char *file;
548 int hold;
549 @@ -149,8 +149,8 @@
550 if (fp == NULL)
551 {
552 if (! existence_error (errno))
553 - error (0, errno, "cannot open %s", file);
554 - return;
555 + error (0, errno, "cannot open %s", file);
556 + return 0;
557 }
558 while (getline (&line, &line_allocated, fp) >= 0)
559 ign_add (line, hold);
560 @@ -159,6 +159,7 @@
561 if (fclose (fp) < 0)
562 error (0, errno, "cannot close %s", file);
563 free (line);
564 + return 1;
565 }
566
567 /* Parse a line of space-separated wildcards and add them to the list. */
568 @@ -375,6 +376,7 @@
569 struct stat sb;
570 char *file;
571 char *xdir;
572 + char *cvsdotignore;
573
574 /* Set SUBDIRS if we have subdirectory information in ENTRIES. */
575 if (entries == NULL)
576 @@ -397,7 +399,10 @@
577 if (dirp == NULL)
578 return;
579
580 - ign_add_file (CVSDOTIGNORE, 1);
581 + cvsdotignore = getenv("CVSDOTIGNORE");
582 + if (cvsdotignore == NULL || !ign_add_file (cvsdotignore, 1))
583 + ign_add_file (CVSDOTIGNORE, 1);
584 +
585 wrap_add_file (CVSDOTWRAPPER, 1);
586
587 while ((dp = readdir (dirp)) != NULL)
588 === patch end ===
589
590 This one is for pcl-cvs-2.9.2, so that `i' adds to the local
591 .cvsignore file.
592
593 === patch start ===
594 --- pcl-cvs.el~ Mon Nov 1 12:33:46 1999
595 +++ pcl-cvs.el Tue Jan 25 21:46:27 2000
596 @@ -1177,7 +1177,10 @@
597 "Append the file in FILEINFO to the .cvsignore file.
598 Can only be used in the *cvs* buffer."
599 (save-window-excursion
600 - (set-buffer (find-file-noselect (expand-file-name ".cvsignore" dir)))
601 + (set-buffer (find-file-noselect
602 + (expand-file-name (or (getenv "CVSDOTIGNORE")
603 + ".cvsignore")
604 + dir)))
605 (goto-char (point-max))
606 (unless (zerop (current-column)) (insert "\n"))
607 (insert str "\n")
608 === patch end ===