Make it easier to find modules. New gnulib-tool option '--find'.
[gnulib.git] / doc / gnulib-tool.texi
1 @node Invoking gnulib-tool
2 @chapter Invoking gnulib-tool
3
4 @c Copyright (C) 2005-2010 Free Software Foundation, Inc.
5
6 @c Permission is granted to copy, distribute and/or modify this document
7 @c under the terms of the GNU Free Documentation License, Version 1.3 or
8 @c any later version published by the Free Software Foundation; with no
9 @c Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
10 @c Texts.  A copy of the license is included in the ``GNU Free
11 @c Documentation License'' file as part of this distribution.
12
13 @pindex gnulib-tool
14 @cindex invoking @command{gnulib-tool}
15
16 The @command{gnulib-tool} command is the recommended way to import
17 Gnulib modules.  It is possible to borrow Gnulib modules in a package
18 without using @command{gnulib-tool}, relying only on the
19 meta-information stored in the @file{modules/*} files, but with a
20 growing number of modules this becomes tedious.  @command{gnulib-tool}
21 simplifies the management of source files, @file{Makefile.am}s and
22 @file{configure.ac} in packages incorporating Gnulib modules.
23
24 @file{gnulib-tool} is not installed in a standard directory that is
25 contained in the @code{PATH} variable.  It needs to be run directly in
26 the directory that contains the Gnulib source code.  You can do this
27 either by specifying the absolute filename of @file{gnulib-tool}, or
28 you can also use a symbolic link from a place inside your @code{PATH}
29 to the @file{gnulib-tool} file of your preferred and most up-to-date
30 Gnulib checkout, like this:
31 @smallexample
32 $ ln -s $HOME/gnu/src/gnulib.git/gnulib-tool $HOME/bin/gnulib-tool
33 @end smallexample
34
35 Run @samp{gnulib-tool --help} for information.  To get familiar with
36 @command{gnulib-tool} without affecting your sources, you can also try
37 some commands with the option @samp{--dry-run}; then
38 @code{gnulib-tool} will only report which actions it would perform in
39 a real run without changing anything.
40
41 @menu
42 * Which modules?::              Determining the needed set of Gnulib modules
43 * Initial import::              First import of Gnulib modules.
44 * Modified imports::            Changing the import specification.
45 * Simple update::               Tracking Gnulib development.
46 * Source changes::              Impact of Gnulib on your source files.
47 * gettextize and autopoint::    Caveat: @code{gettextize} and @code{autopoint} users!
48 * Localization::                Handling Gnulib's own message translations.
49 * VCS Issues::                  Integration with Version Control Systems.
50 * Unit tests::                  Bundling the unit tests of the Gnulib modules.
51 @end menu
52
53
54 @node Which modules?
55 @section Finding modules
56 @cindex Finding modules
57
58 There are three ways of finding the names of Gnulib modules that you can use
59 in your package:
60
61 @itemize
62 @item
63 You have the complete module list, sorted according to categories, in
64 @url{http://www.gnu.org/software/gnulib/MODULES.html}.
65
66 @item
67 If you are looking for a particular POSIX header or function replacement,
68 look in the chapters @ref{Header File Substitutes} and
69 @ref{Function Substitutes}.  For headers and functions that are provided by
70 Glibc but not standardized by POSIX, look in the chapters
71 @ref{Glibc Header File Substitutes} and @ref{Glibc Function Substitutes}.
72
73 @item
74 If you have already found the source file in Gnulib and are looking for the
75 module that contains this source file, you can use the command
76 @samp{gnulib-tool --find @var{filename}}.
77 @end itemize
78
79
80 @node Initial import
81 @section Initial import
82 @cindex initial import
83
84 Gnulib assumes your project uses Autoconf and Automake.  Invoking
85 @samp{gnulib-tool --import} will copy source files, create a
86 @file{Makefile.am} to build them, generate a file @file{gnulib-comp.m4} with
87 Autoconf M4 macro declarations used by @file{configure.ac}, and generate
88 a file @file{gnulib-cache.m4} containing the cached specification of how
89 Gnulib is used.
90
91 Our example will be a library that uses Autoconf, Automake and
92 Libtool.  It calls @code{strdup}, and you wish to use gnulib to make
93 the package portable to C89 and C99 (which don't have @code{strdup}).
94
95 @example
96 ~/src/libfoo$ gnulib-tool --import strdup
97 Module list with included dependencies:
98   absolute-header
99   extensions
100   strdup
101   string
102 File list:
103   lib/dummy.c
104   lib/strdup.c
105   lib/string.in.h
106   m4/absolute-header.m4
107   m4/extensions.m4
108   m4/gnulib-common.m4
109   m4/strdup.m4
110   m4/string_h.m4
111 Creating directory ./lib
112 Creating directory ./m4
113 Copying file lib/dummy.c
114 Copying file lib/strdup.c
115 Copying file lib/string.in.h
116 Copying file m4/absolute-header.m4
117 Copying file m4/extensions.m4
118 Copying file m4/gnulib-common.m4
119 Copying file m4/gnulib-tool.m4
120 Copying file m4/strdup.m4
121 Copying file m4/string_h.m4
122 Creating lib/Makefile.am
123 Creating m4/gnulib-cache.m4
124 Creating m4/gnulib-comp.m4
125 Finished.
126
127 You may need to add #include directives for the following .h files.
128   #include <string.h>
129
130 Don't forget to
131   - add "lib/Makefile" to AC_CONFIG_FILES in ./configure.ac,
132   - mention "lib" in SUBDIRS in Makefile.am,
133   - mention "-I m4" in ACLOCAL_AMFLAGS in Makefile.am,
134   - invoke gl_EARLY in ./configure.ac, right after AC_PROG_CC,
135   - invoke gl_INIT in ./configure.ac.
136 ~/src/libfoo$
137 @end example
138
139 By default, the source code is copied into @file{lib/} and the M4
140 macros in @file{m4/}.  You can override these paths by using
141 @code{--source-base=DIRECTORY} and @code{--m4-base=DIRECTORY}.  Some
142 modules also provide other files necessary for building. These files
143 are copied into the directory specified by @samp{AC_CONFIG_AUX_DIR} in
144 @file{configure.ac} or by the @code{--aux-dir=DIRECTORY} option.  If
145 neither is specified, the current directory is assumed.
146
147 @code{gnulib-tool} can make symbolic links instead of copying the
148 source files.  The option to specify for this is @samp{--symlink}, or
149 @samp{-s} for short.  This can be useful to save a few kilobytes of disk
150 space.  But it is likely to introduce bugs when @code{gnulib} is updated;
151 it is more reliable to use @samp{gnulib-tool --update} (see below)
152 to update to newer versions of @code{gnulib}.  Furthermore it requires
153 extra effort to create self-contained tarballs, and it may disturb some
154 mechanism the maintainer applies to the sources.  For these reasons,
155 this option is generally discouraged.
156
157 @code{gnulib-tool} will overwrite any pre-existing files, in
158 particular @file{Makefile.am}.  Unfortunately, separating the
159 generated @file{Makefile.am} content (for building the gnulib library)
160 into a separate file, say @file{gnulib.mk}, that could be included
161 by your handwritten @file{Makefile.am} is not possible, due to how
162 variable assignments are handled by Automake.
163
164 Consequently, it is a good idea to choose directories that are not
165 already used by your projects, to separate gnulib imported files from
166 your own files.  This approach is also useful if you want to avoid
167 conflicts between other tools (e.g., @code{gettextize} that also copy
168 M4 files into your package.  Simon Josefsson successfully uses a source
169 base of @file{gl/}, and a M4 base of @file{gl/m4/}, in several
170 packages.
171
172 After the @samp{--import} option on the command line comes the list of
173 Gnulib modules that you want to incorporate in your package.  The names
174 of the modules coincide with the filenames in Gnulib's @file{modules/}
175 directory.
176
177 Some Gnulib modules depend on other Gnulib modules.  @code{gnulib-tool}
178 will automatically add the needed modules as well; you need not list
179 them explicitly.  @code{gnulib-tool} will also memorize which dependent
180 modules it has added, so that when someday a dependency is dropped, the
181 implicitly added module is dropped as well (unless you have explicitly
182 requested that module).
183
184 If you want to cut a dependency, i.e., not add a module although one of
185 your requested modules depends on it, you may use the option
186 @samp{--avoid=@var{module}} to do so.  Multiple uses of this option are
187 possible.  Of course, you will then need to implement the same interface
188 as the removed module.
189
190 A few manual steps are required to finish the initial import.
191 @code{gnulib-tool} printed a summary of these steps.
192
193 First, you must ensure Autoconf can find the macro definitions in
194 @file{gnulib-comp.m4}.  Use the @code{ACLOCAL_AMFLAGS} specifier in
195 your top-level @file{Makefile.am} file, as in:
196
197 @example
198 ACLOCAL_AMFLAGS = -I m4
199 @end example
200
201 You are now ready to call the M4 macros in @code{gnulib-comp.m4} from
202 @file{configure.ac}.  The macro @code{gl_EARLY} must be called as soon
203 as possible after verifying that the C compiler is working.
204 Typically, this is immediately after @code{AC_PROG_CC}, as in:
205
206 @example
207 ...
208 AC_PROG_CC
209 gl_EARLY
210 ...
211 @end example
212
213 The core part of the gnulib checks are done by the macro
214 @code{gl_INIT}.  Place it further down in the file, typically where
215 you normally check for header files or functions.  It must come after
216 other checks which may affect the compiler invocation, such as
217 @code{AC_MINIX}.  For example:
218
219 @example
220 ...
221 # For gnulib.
222 gl_INIT
223 ...
224 @end example
225
226 @code{gl_INIT} will in turn call the macros related with the
227 gnulib functions, be it specific gnulib macros, like @code{gl_FUNC_ALLOCA}
228 or autoconf or automake macros like @code{AC_FUNC_ALLOCA} or
229 @code{AM_FUNC_GETLINE}.  So there is no need to call those macros yourself
230 when you use the corresponding gnulib modules.
231
232 You must also make sure that the gnulib library is built.  Add the
233 @code{Makefile} in the gnulib source base directory to
234 @code{AC_CONFIG_FILES}, as in:
235
236 @example
237 AC_CONFIG_FILES(... lib/Makefile ...)
238 @end example
239
240 You must also make sure that @code{make} will recurse into the gnulib
241 directory.  To achieve this, add the gnulib source base directory to a
242 @code{SUBDIRS} Makefile.am statement, as in:
243
244 @example
245 SUBDIRS = lib
246 @end example
247
248 or if you, more likely, already have a few entries in @code{SUBDIRS},
249 you can add something like:
250
251 @example
252 SUBDIRS += lib
253 @end example
254
255 Finally, you have to add compiler and linker flags in the appropriate
256 source directories, so that you can make use of the gnulib library.
257 Since some modules (@samp{getopt}, for example) may copy files into
258 the build directory, @file{top_builddir/lib} is needed as well
259 as @file{top_srcdir/lib}.  For example:
260
261 @example
262 ...
263 AM_CPPFLAGS = -I$(top_builddir)/lib -I$(top_srcdir)/lib
264 ...
265 LDADD = lib/libgnu.a
266 ...
267 @end example
268
269 Don't forget to @code{#include} the various header files.  In this
270 example, you would need to make sure that @samp{#include <string.h>}
271 is evaluated when compiling all source code files, that want to make
272 use of @code{strdup}.
273
274 In the usual case where Autoconf is creating a @file{config.h} file,
275 you should include @file{config.h} first, before any other include
276 file.  That way, for example, if @file{config.h} defines
277 @samp{restrict} to be the empty string on a pre-C99 host, or a macro
278 like @samp{_FILE_OFFSET_BITS} that affects the layout of data
279 structures, the definition is consistent for all include files.
280 Also, on some platforms macros like @samp{_FILE_OFFSET_BITS} and
281 @samp{_GNU_SOURCE} may be ineffective, or may have only a limited
282 effect, if defined after the first system header file is included.
283
284 Finally, note that you can not use @code{AC_LIBOBJ} or
285 @code{AC_REPLACE_FUNCS} in your @file{configure.ac} and expect the
286 resulting object files to be automatically added to @file{lib/libgnu.a}.
287 This is because your @code{AC_LIBOBJ} and @code{AC_REPLACE_FUNCS} invocations
288 from @file{configure.ac} augment a variable @code{@@LIBOBJS@@} (and/or
289 @code{@@LTLIBOBJS@@} if using Libtool), whereas @file{lib/libgnu.a}
290 is built from the contents of a different variable, usually
291 @code{@@gl_LIBOBJS@@} (or @code{@@gl_LTLIBOBJS@@} if using Libtool).
292
293
294 @node Modified imports
295 @section Modified imports
296
297 You can at any moment decide to use Gnulib differently than the last time.
298
299 If you only want to use more Gnulib modules, simply invoke
300 @command{gnulib-tool --import @var{new-modules}}.  @code{gnulib-tool}
301 remembers which modules were used last time.  The list of modules that
302 you pass after @samp{--import} is @emph{added} to the previous list of
303 modules.
304
305 For most changes, such as added or removed modules, or even different
306 choices of @samp{--lib}, @samp{--source-base} or @samp{--aux-dir}, there
307 are two ways to perform the change.
308
309 The standard way is to modify manually the file @file{gnulib-cache.m4}
310 in the M4 macros directory, then launch @samp{gnulib-tool --import}.
311
312 The other way is to call @command{gnulib-tool} again, with the changed
313 command-line options.  Note that this doesn't let you remove modules,
314 because as you just learned, the list of modules is always cumulated.
315 Also this way is often impractical, because you don't remember the way
316 you invoked @code{gnulib-tool} last time.
317
318 The only change for which this doesn't work is a change of the
319 @samp{--m4-base} directory.  Because, when you pass a different value of
320 @samp{--m4-base}, @code{gnulib-tool} will not find the previous
321 @file{gnulib-cache.m4} file any more... A possible solution is to manually
322 copy the @file{gnulib-cache.m4} into the new M4 macro directory.
323
324 In the @file{gnulib-cache.m4}, the macros have the following meaning:
325 @table @code
326 @item gl_MODULES
327 The argument is a space separated list of the requested modules, not including
328 dependencies.
329
330 @item gl_AVOID
331 The argument is a space separated list of modules that should not be used,
332 even if they occur as dependencies.  Corresponds to the @samp{--avoid}
333 command line argument.
334
335 @item gl_SOURCE_BASE
336 The argument is the relative file name of the directory containing the gnulib
337 source files (mostly *.c and *.h files).  Corresponds to the
338 @samp{--source-base} command line argument.
339
340 @item gl_M4_BASE
341 The argument is the relative file name of the directory containing the gnulib
342 M4 macros (*.m4 files).  Corresponds to the @samp{--m4-base} command line
343 argument.
344
345 @item gl_TESTS_BASE
346 The argument is the relative file name of the directory containing the gnulib
347 unit test files.  Corresponds to the @samp{--tests-base} command line argument.
348
349 @item gl_LIB
350 The argument is the name of the library to be created.  Corresponds to the
351 @samp{--lib} command line argument.
352
353 @item gl_LGPL
354 The presence of this macro without arguments corresponds to the @samp{--lgpl}
355 command line argument.  The presence of this macro with an argument (whose
356 value must be 2 or 3) corresponds to the @samp{--lgpl=@var{arg}} command line
357 argument.
358
359 @item gl_LIBTOOL
360 The presence of this macro corresponds to the @samp{--libtool} command line
361 argument and to the absence of the @samp{--no-libtool} command line argument.
362 It takes no arguments.
363
364 @item gl_MACRO_PREFIX
365 The argument is the prefix to use for macros in the @file{gnulib-comp.m4}
366 file.  Corresponds to the @samp{--macro-prefix} command line argument.
367 @end table
368
369
370 @node Simple update
371 @section Simple update
372
373 When you want to update to a more recent version of Gnulib, without
374 changing the list of modules or other parameters, a simple call
375 does it:
376
377 @smallexample
378 $ gnulib-tool --import
379 @end smallexample
380
381 @noindent
382 This will create, update or remove files, as needed.
383
384 Note: From time to time, changes are made in Gnulib that are not backward
385 compatible.  When updating to a more recent Gnulib, you should consult
386 Gnulib's @file{NEWS} file to check whether the incompatible changes affect
387 your project.
388
389
390 @node Source changes
391 @section Changing your sources for use with Gnulib
392
393 Gnulib contains some header file overrides.  This means that when building
394 on systems with deficient header files in @file{/usr/include/}, it may create
395 files named @file{string.h}, @file{stdlib.h}, @file{stdint.h} or similar in
396 the build directory.  In the other source directories of your package you
397 will usually pass @samp{-I} options to the compiler, so that these Gnulib
398 substitutes are visible and take precedence over the files in
399 @file{/usr/include/}.
400
401 These Gnulib substitute header files rely on @file{<config.h>} being
402 already included.  Furthermore @file{<config.h>} must be the first include
403 in every compilation unit.  This means that to @emph{all your source files}
404 and likely also to @emph{all your tests source files} you need to add an
405 @samp{#include <config.h>} at the top.  Which source files are affected?
406 Exactly those whose compilation includes a @samp{-I} option that refers to
407 the Gnulib library directory.
408
409 This is annoying, but inevitable: On many systems, @file{<config.h>} is
410 used to set system dependent flags (such as @code{_GNU_SOURCE} on GNU systems),
411 and these flags have no effect after any system header file has been included.
412
413
414 @node gettextize and autopoint
415 @section Caveat: @code{gettextize} and @code{autopoint} users
416
417 @cindex gettextize, caveat
418 @cindex autopoint, caveat
419 The programs @code{gettextize} and @code{autopoint}, part of
420 GNU @code{gettext}, import or update the internationalization infrastructure.
421 Some of this infrastructure, namely ca.@: 20 autoconf macro files and the
422 @file{config.rpath} file, is also contained in Gnulib and may be imported
423 by @code{gnulib-tool}.  The use of @code{gettextize} or @code{autopoint}
424 will therefore overwrite some of the files that @code{gnulib-tool} has
425 imported, and vice versa.
426
427 Avoiding to use @code{gettextize} (manually, as package maintainer) or
428 @code{autopoint} (as part of a script like @code{autoreconf} or
429 @code{autogen.sh}) is not the solution: These programs also import the
430 infrastructure in the @file{po/} and optionally in the @file{intl/} directory.
431
432 The copies of the conflicting files in Gnulib are more up-to-date than
433 the copies brought in by @code{gettextize} and @code{autopoint}.  When a
434 new @code{gettext} release is made, the copies of the files in Gnulib will
435 be updated immediately.
436
437 The solution is therefore:
438
439 @enumerate
440 @item
441 When you run @code{gettextize}, always use the @code{gettextize} from the
442 matching GNU gettext release.  For the most recent Gnulib checkout, this is
443 the newest release found on @url{http://ftp.gnu.org/gnu/gettext/}.  For an
444 older Gnulib snapshot, it is the release that was the most recent release
445 at the time the Gnulib snapshot was taken.  Then, after @code{gettextize},
446 invoke @code{gnulib-tool}.
447
448 @item
449 When a script of yours run @code{autopoint}, invoke @code{gnulib-tool}
450 afterwards.
451
452 @item
453 If you get an error message like
454 @code{*** error: gettext infrastructure mismatch:
455 using a Makefile.in.in from gettext version ...
456 but the autoconf macros are from gettext version ...},
457 it means that a new GNU gettext release was made, and its autoconf macros
458 were integrated into Gnulib and now mismatch the @file{po/} infrastructure.
459 In this case, fetch and install the new GNU gettext release and run
460 @code{gettextize} followed by @code{gnulib-tool}.
461 @end enumerate
462
463
464 @node Localization
465 @section Handling Gnulib's own message translations
466
467 Gnulib provides some functions that emit translatable messages using GNU
468 @code{gettext}.  The @samp{gnulib} domain at the
469 @url{http://translationproject.org/, Translation Project} collects
470 translations of these messages, which you should incorporate into your
471 own programs.
472
473 There are two basic ways to achieve this.  The first, and older, method
474 is to list all the source files you use from Gnulib in your own
475 @file{po/POTFILES.in} file.  This will cause all the relevant
476 translatable strings to be included in your POT file.  When you send
477 this POT file to the Translation Project, translators will normally fill
478 in the translations of the Gnulib strings from their ``translation
479 memory'', and send you back updated PO files.
480
481 However, this process is error-prone: you might forget to list some
482 source files, or the translator might not be using a translation memory
483 and provide a different translation than another translator, or the
484 translation might not be kept in sync between Gnulib and your package.
485 It is also slow and causes substantial extra work, because a human
486 translator must be in the loop for each language and you will need to
487 incorporate their work on request.
488
489 For these reasons, a new method was designed and is now recommended.  If
490 you pass the @code{--po-base=@var{directory}} and @code{--po-domain=@var{domain}}
491 options to @code{gnulib-tool}, then @code{gnulib-tool} will create a
492 separate directory with its own @file{POTFILES.in}, and fetch current
493 translations directly from the Translation Project (using
494 @command{rsync} or @command{wget}, whichever is available).
495 The POT file in this directory will be called
496 @file{@var{domain}-gnulib.pot}, depending on the @var{domain} you gave to the
497 @code{--po-domain} option (typically the same as the package name).
498 This causes these translations to reside in a separate message domain,
499 so that they do not clash either with the translations for the main part
500 of your package nor with those of other packages on the system that use
501 possibly different versions of Gnulib.
502 When you use these options, the functions in Gnulib are built
503 in such a way that they will always use this domain regardless of the
504 default domain set by @code{textdomain}.
505
506 In order to use this method, you must -- in each program that might use
507 Gnulib code -- add an extra line to the part of the program that
508 initializes locale-dependent behavior.  Where you would normally write
509 something like:
510
511 @example
512 @group
513   setlocale (LC_ALL, "");
514   bindtextdomain (PACKAGE, LOCALEDIR);
515   textdomain (PACKAGE);
516 @end group
517 @end example
518
519 @noindent
520 you should add an additional @code{bindtextdomain} call to inform
521 gettext of where the MO files for the extra message domain may be found:
522
523 @example
524 @group
525   bindtextdomain (PACKAGE "-gnulib", LOCALEDIR);
526 @end group
527 @end example
528
529 (This example assumes that the @var{domain} that you specified
530 to @code{gnulib-tool} is the same as the value of the @code{PACKAGE}
531 preprocessor macro.)
532
533 Since you do not change the @code{textdomain} call, the default message
534 domain for your program remains the same and your own use of @code{gettext}
535 functions will not be affected.
536
537
538 @node VCS Issues
539 @section Issues with Version Control Systems
540
541 If a project stores its source files in a version control system (VCS),
542 such as CVS, SVN, or Git, one needs to decide which files to commit.
543
544 All files created by @code{gnulib-tool}, except @file{gnulib-cache.m4},
545 should be treated like generated source files, like for example a
546 @file{parser.c} file is generated from @file{parser.y}.
547
548 @itemize
549
550 @item
551 In projects which commit all source files, whether generated or not, into
552 their VCS, the @code{gnulib-tool} generated files should all be committed.
553 In this case, you also pass the option @samp{--no-vc-files} to
554 @code{gnulib-tool}.
555
556 Gnulib also contains files generated by @command{make} (and removed by
557 @code{make clean}), using information determined by @command{configure}.
558 They should not be checked into the VCS, but instead added to
559 @file{.gitignore} or @file{.cvsignore}.
560 When you have a Gnulib source file of the form @file{lib/foo.in.h}, the
561 corresponding @file{lib/foo.h} is such a file.
562
563 @item
564 In projects which customarily omit from their VCS all files that are generated
565 from other source files, all these files and directories would not be
566 added into the VCS.  The only file that must be added to the VCS is
567 @file{gnulib-cache.m4} in the M4 macros directory.  Also, the script for
568 restoring files not in the VCS, customarily called @file{autogen.sh} or
569 @file{bootstrap.sh}, will typically contain the statement for restoring
570 the omitted files:
571
572 @smallexample
573 $ gnulib-tool --update
574 @end smallexample
575
576 The @samp{--update} option operates much like the @samp{--import} option,
577 but it does not offer the possibility to change the way Gnulib is used.
578 Also it does not report in the ChangeLogs the files that it had to add
579 because they were missing.
580
581 @end itemize
582
583
584 @node Unit tests
585 @section Bundling the unit tests of the Gnulib modules
586
587 You can bundle the unit tests of the Gnulib modules together with your
588 package, through the @samp{--with-tests} option.  Together with
589 @samp{--with-tests}, you also specify the directory for these tests
590 through the @samp{--tests-base} option.  Of course, you need to add this
591 directory to the @code{SUBDIRS} variable in the @code{Makefile.am} of
592 the parent directory.
593
594 The advantage of having the unit tests bundled is that when your program
595 has a problem on a particular platform, running the unit tests may help
596 determine quickly if the problem is on Gnulib's side or on your package's
597 side.  Also, it helps verifying Gnulib's portability, of course.
598
599 The unit tests will be compiled and run when the user runs @samp{make check}.
600 When the user runs only @samp{make}, the unit tests will not be compiled.
601
602 In the @code{SUBDIRS} variable, it is useful to put the Gnulib tests directory
603 after the directory containing the other tests, not before:
604
605 @smallexample
606 SUBDIRS = gnulib-lib src man tests gnulib-tests
607 @end smallexample
608
609 @noindent
610 This will ensure that on platforms where there are test failures in either
611 directory, users will see and report the failures from the tests of your
612 program.
613
614 Note: In packages which use more than one invocation of @code{gnulib-tool}
615 in the scope of the same @code{configure.ac}, you cannot use
616 @samp{--with-tests}.  You will have to use a separate @code{configure.ac}
617 in this case.