libtool.m4: Check for space after -l flag
[libtool.git] / HACKING
blob38401c9cd732b87ba919f18ae774a66b8f1ef521
1 GNU Libtool
2 ***********
4 1. Introduction
5 ===============
7 This file attempts to describe the processes we use to maintain libtool,
8 and is not part of a release distribution.
10 2. Maintenance Notes
11 ====================
13 * If you incorporate a change from somebody on the net:
14   If it is a large change, you must make sure they have signed the
15   appropriate paperwork, and be sure to add their name and email
16   address to THANKS.
18 * If a change fixes a test, mention the test in the git log entry.
20 * If somebody reports a new bug, mention their name in the git log entry
21   and in the test case you write.
23 * The correct response to most actual bugs is to write a new test case
24   that demonstrates the bug.  Then fix the bug, re-run the test suite,
25   and check everything in.
27 * Always run the testsuite after applying a patch:
28     make check syntax-check TESTSUITEFLAGS="--jobs=$(nproc)" -j$(nproc)
30   Ideally also verify the release process doesn't break:
31     make distcheck TESTSUITEFLAGS="--jobs=$(nproc)" -j$(nproc)
32   This will run check & syntax-check from above, but will take longer as
33   builds & tests in different configurations.
35 * Some files in the libtool package are not owned by libtool.  These
36   files should never be edited here.  These files are:
37         COPYING
38         INSTALL
39         doc/
40             + fdl.texi
41         libltdl/
42             + COPYING.LIB
43         libltdl/config/
44             + compile
45             + config.guess
46             + config.sub
47             + depcomp
48             + install-sh
49             + mdate-sh
50             + missing
51             + texinfo.tex
52   The ones that are important for a release can be updated by ensuring
53   gnulib is up-to-date, and running 'bootstrap' to recheck the links are
54   correct.
56 * Changes other than bug fixes must be mentioned in NEWS.
59 3. Test Suite
60 =============
62 * When writing tests, make sure the link invocation (first argument to
63   AT_CHECK) is on a single line so that 'testsuite -x' displays the
64   whole thing.  You can use m4_do or '[... ]dnl' to wrap long lines.
66 * Run tests in parallel with
67     make -k check TESTSUITEFLAGS="--jobs=$(nproc)"
68   liberally, on as many platforms as you can.  Use as many compilers and
69   linkers you can.  To run old and new testsuites separately, use:
70     make check TESTSUITEFLAGS=-V
71     make check-local
73 * The gnulib module also provides some maintainer-focused tests that only
74   work when run from a git checkout.
75     make syntax-check
77 * The new Autotest testsuite uses keywords to denote test features:
78     autoconf            needs Autoconf
79     automake            needs Automake
80     libltdl             exercises the 'libltdl' library
81     libtool             exercises the 'libtool' script
82     libtoolize          exercises the 'libtoolize' script
83     recursive           runs the suite recursively, with a modified
84                         'libtool' script and with '-k libtool'
85     CXX F77 FC GCJ      exercises a language other than C
88 4. Naming
89 =========
91 * We've adopted the convention that exported Autoconf macros should be
92   named with a leading 'LT_' and be documented in the libtool manual.
93   Internal macros begin with '_LT_' if they are visible to aclocal, or
94   potentially part of an AC_DEFUN/AC_REQUIRE path, or else '_lt_' if
95   they are very low level.  This convention was only introduced just
96   before libtool-2.0, so there may still be exceptions in the existing
97   code.  But all new code should use it.
99 * All shell variables used internally by libtool's Autoconf macros
100   should be named with the a leading 'lt_' (not that they cannot clash
101   with the '_lt_' macro namespace).
104 5. Using git
105 ============
107 * ChangeLog is generated from git log messages, so you have to format
108   the git log carefully.  Use --author for the (first, main) author
109   of changesets from others, and sign patches you have reviewed.  If the
110   changeset has additional authors that need to be mentioned in the
111   generated ChangeLog, then add them to the git log message with:
113     Co-authored-by: A U Thor <email@example.com>
115   Similarly, if the ChangeLog will need a '(tiny change)' annotation,
116   then you should indicate that in the git log message with:
118     Copyright-paperwork-exempt: Yes
120   Start the git log message with a short one line summary, then an empty
121   line, then the rest of the log entry.
123   If you forgot to annotate correctly in the git log message, or made
124   any other mistake that needs correcting in the distributed ChangeLog
125   file, make an amendment against the SHA1 of the errored commit in
126   $aux_dir/git-log-fix.
128 * You may find it useful to install the $aux_dir/git-hooks/commit-msg
129   script to .git/hooks in your libtool working directory to help you
130   make the best use of git log message metadata.
132 * Do not ever rewind the public master branch nor any public release
133   branch on savannah, neither any release tags once they have been
134   published.  Other branches and tags may have different rules.
136 * Avoid merge commits on the master branch of the public git repository.
137   For unpublished changes in your development tree, it's easiest to
138   rebase against the current master before applying them, this preserves
139   a linear history.
142 6. Editing '.am' Files
143 ======================
145 * Always use $(...) and not ${...}.
147 * Use ':', not 'true'.  Use 'exit 1', not 'false'.
149 * Use '##' comments liberally.  Comment anything even remotely unusual.
151 * Never use basename or dirname.  Instead use sed.
153 * Do not use 'cd' within back-quotes, use '$(lt__cd)' instead.
154   Otherwise the directory name may be printed, depending on CDPATH.
156 * In general, if a loop is required, it should be silent.  Then the body
157   of the loop itself should print each "important" command it runs.
159 * Use 4 extra spaces to indent continued dependencies.
161 * One needs to remember that for our whole logic for the different
162   libltdl modes to function correctly, the thing we need to ensure
163   *before the client runs libtoolize*, is that the subpackage case is
164   correct (because all files may be symlinked there).  All others can
165   and will be fixed in the 'libtoolize --ltdl --(non)recursive' stage.
168 7. Editing '.m4' Files
169 ======================
171 * Be careful with both 'echo' and '$ECHO'.  As the latter may be one of
172    print -r --
173    printf %s\n
174    func_fallback_echo
175   it may not have more than one argument and its value may not be
176   eval'ed.  However, the argument may start with a '-' and contain
177   backslashes.  As a rule of thumb, use
178    echo ..              for literal (constant) strings without leading
179                         hyphen and no backslashes within,
180    $ECHO ".."           otherwise.
181    func_echo_all        when multiple arguments are present, or when
182                         placed in an eval'ed variable.
184 * The Autoconf manual says that giving an empty parameter is equivalent
185   to not giving it at all.  (In particular, the Autoconf manual doesn't
186   explain that "FOO()" is calling macro FOO with one empty parameter.)
187   To prevent misunderstanding, we should use m4_ifval to check whether
188   a parameter is empty, and not $# to check for the number of parameters.
190 * Any time we add a macro to an older version, lt~obsolete.m4 needs to
191   be updated in all newer versions.
194 8. Abstraction layers in libltdl
195 ================================
197 * The libltdl API uses a layered approach to differentiate internal and
198   external interfaces, among other things.  To keep the abstraction
199   consistent, files in a given layer may only use APIs from files in the
200   lower layers.  The ASCII art boxes below represent this stack, from
201   top to bottom...
203 * But first, outside of the stack, there is a convenience header that
204   defines the internal interfaces (as evidenced by the 'lt__' prefix to
205   the filename!) shared between implementation files in the stack, that
206   are however not exported to libltdl clients:
208         ,-------------.
209         |lt__private.h|
210         `-------------'
212 * The top layer of the stack is the libltdl API proper, which includes
213   the relevant subsystems automatically.  Clients of libltdl need only
214   invoke:
216   #include <ltdl.h>
218         ,------.
219         |ltdl.h|
220         +------+
221         |ltdl.c|
222         `------'
224 * The next layer is comprised of the subsystems of the exported libltdl
225   API, which are implemented by files that are named with a leading 'lt_'
226   (single underscore!):
228         ,------------v---------------.
229         | lt_error.h | lt_dlloader.h |
230         +------------+---------------+
231         | lt_error.c | lt_dlloader.c |
232         `------------^---------------'
234 * The next file is used both by the headers that implement it (in which
235   case its function is to avoid namespace clashes when linking with the
236   GNU C library proper) and is included by code that wants to program
237   against a glibc-like interface, in which case it serves to pull in all
238   the glibc-like functionality used by libltdl with a simple:
240     #include <libltdl/lt__glibc.h>
242   It consists of a single file:
244         ,-----------.
245         |lt__glibc.h|
246         `-----------'
248 * Next to last is the libc abstraction layer, which provides a uniform
249   API to various system libc interfaces that differ between hosts
250   supported by libtool.  Typically, the files that implement this layer
251   begin:
253     #if defined(LT_CONFIG_H)
254     #  include LT_CONFIG_H
255     #else
256     #  include <config.h>
257     #endif
258     #include "lt_system.h"
260   Or if they are installed headers that must work outside the libtool
261   source tree, simply:
263     #include <libltdl/lt_system.h>
265   This layer's interface is defined by files that are usually named with
266   a leading 'lt__':
268         ,--------------v-------------v------------v--------v---------.
269         | lt__dirent.h | lt__alloc.h | lt__strl.h | argz.h | slist.h |
270         +--------------+-------------+------------+--------+---------+
271         | lt__dirent.c | lt__alloc.c | lt__strl.c | argz.c | slist.c |
272         `--------------^-------------^------------^--------^---------'
274   (argz.h and slist.h are used independently of libltdl in other projects)
276 * At the bottom of the stack we have the system abstraction layer,
277   which tries to smooth over the cracks where there are differences
278   between host systems and compilers.  config.h is generated at
279   configure time and is not installed; lt_system.h is an installed
280   file and cannot use macros from config.h:
282         ,-----------.
283         |../config.h|
284         `-----------'
286         ,-----------.
287         |lt_system.h|
288         `-----------'
290 * Tacked on the side of this stack, attached via the lt_dlloader.h
291   definitions are the various implementation modules for run-time module
292   loading: preopen.c, dlopen.c etc.
295 9. Licensing Rules
296 ==================
298 GNU Libtool uses 3 different licenses for the files distributed herein,
299 with several variations on license text.  It is important that you use
300 the correct license text in each new file added.  Here are the texts
301 along with some notes on when each is appropriate.  Appropriate
302 commenting (shell, C etc) and decoration (m4 etc) assumed throughout.
306 9.1. Notice preservation
308 Autoconf macros and files used to generate them need this license, along
309 with files such as HACKING, NEWS, README, README.alpha, TODO and
310 ChangeLogs:
312    Copyright (C) <year list> Free Software Foundation, Inc.
313    Written by <author>, <year>
315 Copying and distribution of this file, with or without modification,
316 are permitted in any medium without royalty provided the copyright
317 notice and this notice are preserved.  This file is offered as-is,
318 without warranty of any kind.
322 9.2. GPL
324 Everything else in the distribution has the following license text
325 unless there is good reason to use one of the other license texts
326 below:
328    Copyright (C) <year list> Free Software Foundation, Inc.
329    Written by <author>, <year>
331    This file is part of GNU Libtool.
333 GNU Libtool is free software; you can redistribute it and/or
334 modify it under the terms of the GNU General Public License as
335 published by the Free Software Foundation; either version 2 of
336 the License, or (at your option) any later version.
338 GNU Libtool is distributed in the hope that it will be useful,
339 but WITHOUT ANY WARRANTY; without even the implied warranty of
340 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
341 GNU General Public License for more details.
343 You should have received a copy of the GNU General Public License
344 along with GNU Libtool; see the file COPYING.  If not, a copy
345 can be downloaded from  http://www.gnu.org/licenses/gpl.html,
346 or obtained by writing to the Free Software Foundation, Inc.,
347 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
351 9.3. GPL with self extracting version
353 Some of the sources built atop the options-parser framework use
354 func_version() to extract their --version output from the copyright
355 block.  Those files also need the --version copyright text paragraph as
356 follows:
358    <program name> (GNU @PACKAGE@) <version number>
359    Written by <author> <email address>.
361    This file is part of <parent package name>.
363 Copyright (C) <year list> Free Software Foundation, Inc.
364 This is free software; see the source for copying conditions.  There is NO
365 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
367 <program name> is free software; you can redistribute it and/or modify
368 it under the terms of the GNU General Public License as published by
369 the Free Software Foundation; either version 2 of the License, or
370 (at your option) any later version.
372 <program name> is distributed in the hope that it will be useful, but
373 WITHOUT ANY WARRANTY; without even the implied warranty of
374 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
375 GNU General Public License for more details.
377 You should have received a copy of the GNU General Public License
378 along with <program name>; see the file COPYING.  If not, a copy
379 can be downloaded from http://www.gnu.org/licenses/gpl.html,
380 or obtained by writing to the Free Software Foundation, Inc.,
381 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
385 9.4. GPL with self extracting version and Libtool exception clause
387 Although the libtool script is generated from 'ltmain.in' according
388 to the rules in the preceding subsection, it also needs the Libtool
389 exception clause so that it can be redistributed by other projects
390 that use libtool:
392   <program name> (GNU @PACKAGE@@TIMESTAMP@) <version number>
393   Written by <author> <email address>.
395   This file is part of GNU Libtool.
397 Copyright (C) <year list> Free Software Foundation, Inc.
398 This is free software; see the source for copying conditions.  There is NO
399 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
401 <program name> is free software; you can redistribute it and/or modify
402 it under the terms of the GNU General Public License as published by
403 the Free Software Foundation; either version 2 of the License, or
404 (at your option) any later version.
406 As a special exception to the GNU General Public License,
407 if you distribute this file as part of a program or library that
408 is built using GNU Libtool, you may include this file under the
409 same distribution terms that you use for the rest of that program.
411 <program name> is distributed in the hope that it will be useful, but
412 WITHOUT ANY WARRANTY; without even the implied warranty of
413 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
414 GNU General Public License for more details.
416 You should have received a copy of the GNU General Public License
417 along with <program name>; see the file COPYING.  If not, a copy
418 can be downloaded from http://www.gnu.org/licenses/gpl.html,
419 or obtained by writing to the Free Software Foundation, Inc.,
420 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
424 9.5. LGPL with Libtool exception clause
426 Finally, not only is Libltdl is LGPLed, but it is routinely
427 redistributed inside projects that use it, so its sources need to use
428 the following license text citing the LGPL along with Libtool's special
429 exception clause:
431    Copyright (C) <year list> Free Software Foundation, Inc.
432    Written by <author>, <year>
434    NOTE: The canonical source of this file is maintained with the
435    GNU Libtool package.  Report bugs to bug-libtool@gnu.org.
437 GNU Libltdl is free software; you can redistribute it and/or
438 modify it under the terms of the GNU Lesser General Public
439 License as published by the Free Software Foundation; either
440 version 2 of the License, or (at your option) any later version.
442 As a special exception to the GNU Lesser General Public License,
443 if you distribute this file as part of a program or library that
444 is built using GNU Libtool, you may include this file under the
445 same distribution terms that you use for the rest of that program.
447 GNU Libltdl is distributed in the hope that it will be useful,
448 but WITHOUT ANY WARRANTY; without even the implied warranty of
449 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
450 GNU Lesser General Public License for more details.
452 You should have received a copy of the GNU Lesser General Public
453 License along with GNU Libltdl; see the file COPYING.LIB.  If not, a
454 copy can be downloaded from  http://www.gnu.org/licenses/lgpl.html,
455 or obtained by writing to the Free Software Foundation, Inc.,
456 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
458 -- 
459   Copyright (C) 2004-2008, 2010-2019, 2021-2024 Free Software
460   Foundation, Inc.
461   Written by Gary V. Vaughan, 2004
463   This file is part of GNU Libtool.
465 Copying and distribution of this file, with or without modification,
466 are permitted in any medium without royalty provided the copyright
467 notice and this notice are preserved.  This file is offered as-is,
468 without warranty of any kind.
470 Local Variables:
471 mode: text
472 fill-column: 72
473 End:
474 vim:tw=72