Sat Aug 19 23:11:00 1995 Richard Stallman <rms@mole.gnu.ai.mit.edu>
[make.git] / make-stds.texi
blob3dee87af730d14cf37c0b6e6dde4e63189cbd4fb
1 @comment This file is included by both standards.texi and make.texinfo.
2 @comment It was broken out of standards.texi on 1/6/93 by roland.
4 @node Makefile Conventions
5 @chapter Makefile Conventions
6 @comment standards.texi does not print an index, but make.texinfo does.
7 @cindex makefile, conventions for
8 @cindex conventions for makefiles
9 @cindex standards for makefiles
11 This
12 @ifinfo
13 node
14 @end ifinfo
15 @iftex
16 @ifset CODESTD
17 section
18 @end ifset
19 @ifclear CODESTD
20 chapter
21 @end ifclear
22 @end iftex
23 describes conventions for writing the Makefiles for GNU programs.
25 @menu
26 * Makefile Basics::             General Conventions for Makefiles
27 * Utilities in Makefiles::      Utilities in Makefiles
28 * Command Variables::           Variables for Specifying Commands
29 * Directory Variables::         Variables for Installation Directories
30 * Standard Targets::            Standard Targets for Users
31 @end menu
33 @node Makefile Basics
34 @section General Conventions for Makefiles
36 Every Makefile should contain this line:
38 @example
39 SHELL = /bin/sh
40 @end example
42 @noindent
43 to avoid trouble on systems where the @code{SHELL} variable might be
44 inherited from the environment.  (This is never a problem with GNU
45 @code{make}.)
47 Different @code{make} programs have incompatible suffix lists and
48 implicit rules, and this sometimes creates confusion or misbehavior.  So
49 it is a good idea to set the suffix list explicitly using only the
50 suffixes you need in the particular Makefile, like this:
52 @example
53 .SUFFIXES:
54 .SUFFIXES: .c .o
55 @end example
57 @noindent
58 The first line clears out the suffix list, the second introduces all
59 suffixes which may be subject to implicit rules in this Makefile.
61 Don't assume that @file{.} is in the path for command execution.  When
62 you need to run programs that are a part of your package during the
63 make, please make sure that it uses @file{./} if the program is built as
64 part of the make or @file{$(srcdir)/} if the file is an unchanging part
65 of the source code.  Without one of these prefixes, the current search
66 path is used.
68 The distinction between @file{./} and @file{$(srcdir)/} is important
69 when using the @samp{--srcdir} option to @file{configure}.  A rule of
70 the form:
72 @smallexample
73 foo.1 : foo.man sedscript
74         sed -e sedscript foo.man > foo.1
75 @end smallexample
77 @noindent
78 will fail when the current directory is not the source directory,
79 because @file{foo.man} and @file{sedscript} are not in the current
80 directory.
82 When using GNU @code{make}, relying on @samp{VPATH} to find the source
83 file will work in the case where there is a single dependency file,
84 since the @code{make} automatic variable @samp{$<} will represent the
85 source file wherever it is.  (Many versions of @code{make} set @samp{$<}
86 only in implicit rules.)  A Makefile target like
88 @smallexample
89 foo.o : bar.c
90         $(CC) -I. -I$(srcdir) $(CFLAGS) -c bar.c -o foo.o
91 @end smallexample
93 @noindent
94 should instead be written as
96 @smallexample
97 foo.o : bar.c
98         $(CC) -I. -I$(srcdir) $(CFLAGS) -c $< -o $@@
99 @end smallexample
101 @noindent
102 in order to allow @samp{VPATH} to work correctly.  When the target has
103 multiple dependencies, using an explicit @samp{$(srcdir)} is the easiest
104 way to make the rule work well.  For example, the target above for
105 @file{foo.1} is best written as:
107 @smallexample
108 foo.1 : foo.man sedscript
109         sed -e $(srcdir)/sedscript $(srcdir)/foo.man > $@@
110 @end smallexample
112 Try to make the build and installation targets, at least (and all their
113 subtargets) work correctly with a parallel @code{make}.
115 @node Utilities in Makefiles
116 @section Utilities in Makefiles
118 Write the Makefile commands (and any shell scripts, such as
119 @code{configure}) to run in @code{sh}, not in @code{csh}.  Don't use any
120 special features of @code{ksh} or @code{bash}.
122 The @code{configure} script and the Makefile rules for building and
123 installation should not use any utilities directly except these:
125 @example
126 cat cmp cp echo egrep expr false grep
127 ln mkdir mv pwd rm rmdir sed test touch true
128 @end example
130 Stick to the generally supported options for these programs.  For
131 example, don't use @samp{mkdir -p}, convenient as it may be, because
132 most systems don't support it.
134 The Makefile rules for building and installation can also use compilers
135 and related programs, but should do so via @code{make} variables so that the
136 user can substitute alternatives.  Here are some of the programs we
137 mean:
139 @example
140 ar bison cc flex install ld lex
141 make makeinfo ranlib texi2dvi yacc
142 @end example
144 Use the following @code{make} variables:
146 @example
147 $(AR) $(BISON) $(CC) $(FLEX) $(INSTALL) $(LD) $(LEX)
148 $(MAKE) $(MAKEINFO) $(RANLIB) $(TEXI2DVI) $(YACC)
149 @end example
151 When you use @code{ranlib}, you should make sure nothing bad happens if
152 the system does not have @code{ranlib}.  Arrange to ignore an error
153 from that command, and print a message before the command to tell the
154 user that failure of the @code{ranlib} command does not mean a problem.
155 (The Autoconf @samp{AC_PROG_RANLIB} macro can help with this.)
157 If you use symbolic links, you should implement a fallback for systems
158 that don't have symbolic links.
160 It is ok to use other utilities in Makefile portions (or scripts)
161 intended only for particular systems where you know those utilities
162 exist.
164 @node Command Variables
165 @section Variables for Specifying Commands
167 Makefiles should provide variables for overriding certain commands, options,
168 and so on.
170 In particular, you should run most utility programs via variables.
171 Thus, if you use Bison, have a variable named @code{BISON} whose default
172 value is set with @samp{BISON = bison}, and refer to it with
173 @code{$(BISON)} whenever you need to use Bison.
175 File management utilities such as @code{ln}, @code{rm}, @code{mv}, and
176 so on, need not be referred to through variables in this way, since users
177 don't need to replace them with other programs.
179 Each program-name variable should come with an options variable that is
180 used to supply options to the program.  Append @samp{FLAGS} to the
181 program-name variable name to get the options variable name---for
182 example, @code{BISONFLAGS}.  (The name @code{CFLAGS} is an exception to
183 this rule, but we keep it because it is standard.)  Use @code{CPPFLAGS}
184 in any compilation command that runs the preprocessor, and use
185 @code{LDFLAGS} in any compilation command that does linking as well as
186 in any direct use of @code{ld}.
188 If there are C compiler options that @emph{must} be used for proper
189 compilation of certain files, do not include them in @code{CFLAGS}.
190 Users expect to be able to specify @code{CFLAGS} freely themselves.
191 Instead, arrange to pass the necessary options to the C compiler
192 independently of @code{CFLAGS}, by writing them explicitly in the
193 compilation commands or by defining an implicit rule, like this:
195 @smallexample
196 CFLAGS = -g
197 ALL_CFLAGS = -I. $(CFLAGS)
198 .c.o:
199         $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $<
200 @end smallexample
202 Do include the @samp{-g} option in @code{CFLAGS}, because that is not
203 @emph{required} for proper compilation.  You can consider it a default
204 that is only recommended.  If the package is set up so that it is
205 compiled with GCC by default, then you might as well include @samp{-O}
206 in the default value of @code{CFLAGS} as well.
208 Put @code{CFLAGS} last in the compilation command, after other variables
209 containing compiler options, so the user can use @code{CFLAGS} to
210 override the others.
212 Every Makefile should define the variable @code{INSTALL}, which is the
213 basic command for installing a file into the system.
215 Every Makefile should also define the variables @code{INSTALL_PROGRAM}
216 and @code{INSTALL_DATA}.  (The default for each of these should be
217 @code{$(INSTALL)}.)  Then it should use those variables as the commands
218 for actual installation, for executables and nonexecutables
219 respectively.  Use these variables as follows:
221 @example
222 $(INSTALL_PROGRAM) foo $(bindir)/foo
223 $(INSTALL_DATA) libfoo.a $(libdir)/libfoo.a
224 @end example
226 @noindent
227 Always use a file name, not a directory name, as the second argument of
228 the installation commands.  Use a separate command for each file to be
229 installed.
231 @node Directory Variables
232 @section Variables for Installation Directories
234 Installation directories should always be named by variables, so it is
235 easy to install in a nonstandard place.  The standard names for these
236 variables are described below.  They are based on a standard filesystem
237 layout; variants of it are used in SVR4, 4.4BSD, Linux, Ultrix v4, and
238 other modern operating systems.
240 These two variables set the root for the installation.  All the other
241 installation directories should be subdirectories of one of these two,
242 and nothing should be directly installed into these two directories.
244 @table @samp
245 @item prefix
246 A prefix used in constructing the default values of the variables listed
247 below.  The default value of @code{prefix} should be @file{/usr/local}.
248 When building the complete GNU system, the prefix will be empty and
249 @file{/usr} will be a symbolic link to @file{/}.
250 (If you are using Autoconf, write it as @samp{@@prefix@@}.)
252 @item exec_prefix
253 A prefix used in constructing the default values of some of the
254 variables listed below.  The default value of @code{exec_prefix} should
255 be @code{$(prefix)}.
256 (If you are using Autoconf, write it as @samp{@@exec_prefix@@}.)
258 Generally, @code{$(exec_prefix)} is used for directories that contain
259 machine-specific files (such as executables and subroutine libraries),
260 while @code{$(prefix)} is used directly for other directories.
261 @end table
263 Executable programs are installed in one of the following directories.
265 @table @samp
266 @item bindir
267 The directory for installing executable programs that users can run.
268 This should normally be @file{/usr/local/bin}, but write it as
269 @file{$(exec_prefix)/bin}.
270 (If you are using Autoconf, write it as @samp{@@bindir@@}.)
272 @item sbindir
273 The directory for installing executable programs that can be run from
274 the shell, but are only generally useful to system administrators.  This
275 should normally be @file{/usr/local/sbin}, but write it as
276 @file{$(exec_prefix)/sbin}.
277 (If you are using Autoconf, write it as @samp{@@sbindir@@}.)
279 @item libexecdir
280 @comment This paragraph adjusted to avoid overfull hbox --roland 5jul94
281 The directory for installing executable programs to be run by other
282 programs rather than by users.  This directory should normally be
283 @file{/usr/local/libexec}, but write it as @file{$(exec_prefix)/libexec}.
284 (If you are using Autoconf, write it as @samp{@@libexecdir@@}.)
285 @end table
287 Data files used by the program during its execution are divided into
288 categories in two ways.
290 @itemize @bullet
291 @item
292 Some files are normally modified by programs; others are never normally
293 modified (though users may edit some of these).
295 @item
296 Some files are architecture-independent and can be shared by all
297 machines at a site; some are architecture-dependent and can be shared
298 only by machines of the same kind and operating system; others may never
299 be shared between two machines.
300 @end itemize
302 This makes for six different possibilities.  However, we want to
303 discourage the use of architecture-dependent files, aside from object
304 files and libraries.  It is much cleaner to make other data files
305 architecture-independent, and it is generally not hard.
307 Therefore, here are the variables Makefiles should use to specify
308 directories:
310 @table @samp
311 @item datadir
312 The directory for installing read-only architecture independent data
313 files.  This should normally be @file{/usr/local/share}, but write it as
314 @file{$(prefix)/share}.
315 (If you are using Autoconf, write it as @samp{@@datadir@@}.)
316 As a special exception, see @file{$(infodir)}
317 and @file{$(includedir)} below.
319 @item sysconfdir
320 The directory for installing read-only data files that pertain to a
321 single machine--that is to say, files for configuring a host.  Mailer
322 and network configuration files, @file{/etc/passwd}, and so forth belong
323 here.  All the files in this directory should be ordinary ASCII text
324 files.  This directory should normally be @file{/usr/local/etc}, but
325 write it as @file{$(prefix)/etc}.
326 (If you are using Autoconf, write it as @samp{@@sysconfdir@@}.)
328 @c rewritten to avoid overfull hbox --tower
329 Do not install executables
330 @c here
331 in this directory (they probably
332 belong in @file{$(libexecdir)} or @file{$(sbindir)}).  Also do not
333 install files that are modified in the normal course of their use
334 (programs whose purpose is to change the configuration of the system
335 excluded).  Those probably belong in @file{$(localstatedir)}.
337 @item sharedstatedir
338 The directory for installing architecture-independent data files which
339 the programs modify while they run.  This should normally be
340 @file{/usr/local/com}, but write it as @file{$(prefix)/com}.
341 (If you are using Autoconf, write it as @samp{@@sharedstatedir@@}.)
343 @item localstatedir
344 The directory for installing data files which the programs modify while
345 they run, and that pertain to one specific machine.  Users should never
346 need to modify files in this directory to configure the package's
347 operation; put such configuration information in separate files that go
348 in @file{$(datadir)} or @file{$(sysconfdir)}.  @file{$(localstatedir)}
349 should normally be @file{/usr/local/var}, but write it as
350 @file{$(prefix)/var}.
351 (If you are using Autoconf, write it as @samp{@@localstatedir@@}.)
353 @item libdir
354 The directory for object files and libraries of object code.  Do not
355 install executables here, they probably ought to go in @file{$(libexecdir)}
356 instead.  The value of @code{libdir} should normally be
357 @file{/usr/local/lib}, but write it as @file{$(exec_prefix)/lib}.
358 (If you are using Autoconf, write it as @samp{@@libdir@@}.)
360 @item infodir
361 The directory for installing the Info files for this package.  By
362 default, it should be @file{/usr/local/info}, but it should be written
363 as @file{$(prefix)/info}.
364 (If you are using Autoconf, write it as @samp{@@infodir@@}.)
366 @item includedir
367 @c rewritten to avoid overfull hbox --roland
368 The directory for installing header files to be included by user
369 programs with the C @samp{#include} preprocessor directive.  This
370 should normally be @file{/usr/local/include}, but write it as
371 @file{$(prefix)/include}.
372 (If you are using Autoconf, write it as @samp{@@includedir@@}.)
374 Most compilers other than GCC do not look for header files in
375 @file{/usr/local/include}.  So installing the header files this way is
376 only useful with GCC.  Sometimes this is not a problem because some
377 libraries are only really intended to work with GCC.  But some libraries
378 are intended to work with other compilers.  They should install their
379 header files in two places, one specified by @code{includedir} and one
380 specified by @code{oldincludedir}.
382 @item oldincludedir
383 The directory for installing @samp{#include} header files for use with
384 compilers other than GCC.  This should normally be @file{/usr/include}.
385 (If you are using Autoconf, you can write it as @samp{@@oldincludedir@@}.)
387 The Makefile commands should check whether the value of
388 @code{oldincludedir} is empty.  If it is, they should not try to use
389 it; they should cancel the second installation of the header files.
391 A package should not replace an existing header in this directory unless
392 the header came from the same package.  Thus, if your Foo package
393 provides a header file @file{foo.h}, then it should install the header
394 file in the @code{oldincludedir} directory if either (1) there is no
395 @file{foo.h} there or (2) the @file{foo.h} that exists came from the Foo
396 package.
398 To tell whether @file{foo.h} came from the Foo package, put a magic
399 string in the file---part of a comment---and @code{grep} for that string.
400 @end table
402 Unix-style man pages are installed in one of the following:
404 @table @samp
405 @item mandir
406 The top-level directory for installing the man pages (if any) for this
407 package.  It will normally be @file{/usr/local/man}, but you should
408 write it as @file{$(prefix)/man}.
409 (If you are using Autoconf, write it as @samp{@@mandir@@}.)
411 @item man1dir
412 The directory for installing section 1 man pages.  Write it as
413 @file{$(mandir)/man1}.
414 @item man2dir
415 The directory for installing section 2 man pages.  Write it as
416 @file{$(mandir)/man2}
417 @item @dots{}
419 @strong{Don't make the primary documentation for any GNU software be a
420 man page.  Write a manual in Texinfo instead.  Man pages are just for
421 the sake of people running GNU software on Unix, which is a secondary
422 application only.}
424 @item manext
425 The file name extension for the installed man page.  This should contain
426 a period followed by the appropriate digit; it should normally be @samp{.1}.
428 @item man1ext
429 The file name extension for installed section 1 man pages.
430 @item man2ext
431 The file name extension for installed section 2 man pages.
432 @item @dots{}
433 Use these names instead of @samp{manext} if the package needs to install man
434 pages in more than one section of the manual.
435 @end table
437 And finally, you should set the following variable:
439 @table @samp
440 @item srcdir
441 The directory for the sources being compiled.  The value of this
442 variable is normally inserted by the @code{configure} shell script.
443 (If you are using Autconf, use @samp{srcdir = @@srcdir@@}.)
444 @end table
446 For example:
448 @smallexample
449 @c I have changed some of the comments here slightly to fix an overfull
450 @c hbox, so the make manual can format correctly. --roland
451 # Common prefix for installation directories.
452 # NOTE: This directory must exist when you start the install.
453 prefix = /usr/local
454 exec_prefix = $(prefix)
455 # Where to put the executable for the command `gcc'.
456 bindir = $(exec_prefix)/bin
457 # Where to put the directories used by the compiler.
458 libexecdir = $(exec_prefix)/libexec
459 # Where to put the Info files.
460 infodir = $(prefix)/info
461 @end smallexample
463 If your program installs a large number of files into one of the
464 standard user-specified directories, it might be useful to group them
465 into a subdirectory particular to that program.  If you do this, you
466 should write the @code{install} rule to create these subdirectories.
468 Do not expect the user to include the subdirectory name in the value of
469 any of the variables listed above.  The idea of having a uniform set of
470 variable names for installation directories is to enable the user to
471 specify the exact same values for several different GNU packages.  In
472 order for this to be useful, all the packages must be designed so that
473 they will work sensibly when the user does so.
475 @node Standard Targets
476 @section Standard Targets for Users
478 All GNU programs should have the following targets in their Makefiles:
480 @table @samp
481 @item all
482 Compile the entire program.  This should be the default target.  This
483 target need not rebuild any documentation files; Info files should
484 normally be included in the distribution, and DVI files should be made
485 only when explicitly asked for.
487 By default, the Make rules should compile and link with @samp{-g}, so
488 that executable programs have debugging symbols.  Users who don't mind
489 being helpless can strip the executables later if they wish.
491 @item install
492 Compile the program and copy the executables, libraries, and so on to
493 the file names where they should reside for actual use.  If there is a
494 simple test to verify that a program is properly installed, this target
495 should run that test.
497 Do not strip executables when installing them.  Devil-may-care users can
498 use the @code{install-strip} target to do that.
500 If possible, write the @code{install} target rule so that it does not
501 modify anything in the directory where the program was built, provided
502 @samp{make all} has just been done.  This is convenient for building the
503 program under one user name and installing it under another.
505 The commands should create all the directories in which files are to be
506 installed, if they don't already exist.  This includes the directories
507 specified as the values of the variables @code{prefix} and
508 @code{exec_prefix}, as well as all subdirectories that are needed.
509 One way to do this is by means of an @code{installdirs} target
510 as described below.
512 Use @samp{-} before any command for installing a man page, so that
513 @code{make} will ignore any errors.  This is in case there are systems
514 that don't have the Unix man page documentation system installed.
516 The way to install Info files is to copy them into @file{$(infodir)}
517 with @code{$(INSTALL_DATA)} (@pxref{Command Variables}), and then run
518 the @code{install-info} program if it is present.  @code{install-info}
519 is a program that edits the Info @file{dir} file to add or update the
520 menu entry for the given Info file; it is part of the Texinfo package.
521 Here is a sample rule to install an Info file:
523 @comment This example has been carefully formatted for the Make manual.
524 @comment Please do not reformat it without talking to roland@gnu.ai.mit.edu.
525 @smallexample
526 $(infodir)/foo.info: foo.info
527 # There may be a newer info file in . than in srcdir.
528         -if test -f foo.info; then d=.; \
529          else d=$(srcdir); fi; \
530         $(INSTALL_DATA) $$d/foo.info $@@; \
531 # Run install-info only if it exists.
532 # Use `if' instead of just prepending `-' to the
533 # line so we notice real errors from install-info.
534 # We use `$(SHELL) -c' because some shells do not
535 # fail gracefully when there is an unknown command.
536         if $(SHELL) -c 'install-info --version' \
537            >/dev/null 2>&1; then \
538           install-info --dir-file=$(infodir)/dir \
539                        $(infodir)/foo.info; \
540         else true; fi
541 @end smallexample
543 @item uninstall
544 Delete all the installed files that the @samp{install} target would
545 create (but not the noninstalled files such as @samp{make all} would
546 create).
548 This rule should not modify the directories where compilation is done,
549 only the directories where files are installed.
551 @item install-strip
552 Like @code{install}, but strip the executable files while installing
553 them.  The definition of this target can be very simple:
555 @smallexample
556 install-strip:
557         $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \
558                 install
559 @end smallexample
561 Normally we do not recommend stripping an executable unless you are sure
562 the program has no bugs.  However, it can be reasonable to install a
563 stripped executable for actual execution while saving the unstripped
564 executable elsewhere in case there is a bug.
566 @comment The gratuitous blank line here is to make the table look better
567 @comment in the printed Make manual.  Please leave it in.
568 @item clean
570 Delete all files from the current directory that are normally created by
571 building the program.  Don't delete the files that record the
572 configuration.  Also preserve files that could be made by building, but
573 normally aren't because the distribution comes with them.
575 Delete @file{.dvi} files here if they are not part of the distribution.
577 @item distclean
578 Delete all files from the current directory that are created by
579 configuring or building the program.  If you have unpacked the source
580 and built the program without creating any other files, @samp{make
581 distclean} should leave only the files that were in the distribution.
583 @item mostlyclean
584 Like @samp{clean}, but may refrain from deleting a few files that people
585 normally don't want to recompile.  For example, the @samp{mostlyclean}
586 target for GCC does not delete @file{libgcc.a}, because recompiling it
587 is rarely necessary and takes a lot of time.
589 @item maintainer-clean
590 Delete almost everything from the current directory that can be
591 reconstructed with this Makefile.  This typically includes everything
592 deleted by @code{distclean}, plus more: C source files produced by
593 Bison, tags tables, Info files, and so on.
595 The reason we say ``almost everything'' is that running the command
596 @samp{make maintainer-clean} should not delete @file{configure} even if
597 @file{configure} can be remade using a rule in the Makefile.  More generally,
598 @samp{make maintainer-clean} should not delete anything that needs to
599 exist in order to run @file{configure} and then begin to build the
600 program.  This is the only exception; @code{maintainer-clean} should
601 delete everything else that can be rebuilt.
603 The @samp{maintainer-clean} target is intended to be used by a maintainer of
604 the package, not by ordinary users.  You may need special tools to
605 reconstruct some of the files that @samp{make maintainer-clean} deletes.
606 Since these files are normally included in the distribution, we don't
607 take care to make them easy to reconstruct.  If you find you need to
608 unpack the full distribution again, don't blame us.
610 To help make users aware of this, the commands for the special
611 @code{maintainer-clean} target should start with these two:
613 @smallexample
614 @@echo 'This command is intended for maintainers to use; it'
615 @@echo 'deletes files that may need special tools to rebuild.'
616 @end smallexample
618 @item TAGS
619 Update a tags table for this program.
620 @c ADR: how?
622 @item info
623 Generate any Info files needed.  The best way to write the rules is as
624 follows:
626 @smallexample
627 info: foo.info
629 foo.info: foo.texi chap1.texi chap2.texi
630         $(MAKEINFO) $(srcdir)/foo.texi
631 @end smallexample
633 @noindent
634 You must define the variable @code{MAKEINFO} in the Makefile.  It should
635 run the @code{makeinfo} program, which is part of the Texinfo
636 distribution.
638 @item dvi
639 Generate DVI files for all Texinfo documentation.
640 For example:
642 @smallexample
643 dvi: foo.dvi
645 foo.dvi: foo.texi chap1.texi chap2.texi
646         $(TEXI2DVI) $(srcdir)/foo.texi
647 @end smallexample
649 @noindent
650 You must define the variable @code{TEXI2DVI} in the Makefile.  It should
651 run the program @code{texi2dvi}, which is part of the Texinfo
652 distribution.@footnote{@code{texi2dvi} uses @TeX{} to do the real work
653 of formatting. @TeX{} is not distributed with Texinfo.}  Alternatively,
654 write just the dependencies, and allow GNU @code{make} to provide the command.
656 @item dist
657 Create a distribution tar file for this program.  The tar file should be
658 set up so that the file names in the tar file start with a subdirectory
659 name which is the name of the package it is a distribution for.  This
660 name can include the version number.
662 For example, the distribution tar file of GCC version 1.40 unpacks into
663 a subdirectory named @file{gcc-1.40}.
665 The easiest way to do this is to create a subdirectory appropriately
666 named, use @code{ln} or @code{cp} to install the proper files in it, and
667 then @code{tar} that subdirectory.
669 Compress the tar file file with @code{gzip}.  For example, the actual
670 distribution file for GCC version 1.40 is called @file{gcc-1.40.tar.gz}.
672 The @code{dist} target should explicitly depend on all non-source files
673 that are in the distribution, to make sure they are up to date in the
674 distribution.
675 @ifset CODESTD
676 @xref{Releases, , Making Releases}.
677 @end ifset
678 @ifclear CODESTD
679 @xref{Releases, , Making Releases, standards, GNU Coding Standards}.
680 @end ifclear
682 @item check
683 Perform self-tests (if any).  The user must build the program before
684 running the tests, but need not install the program; you should write
685 the self-tests so that they work when the program is built but not
686 installed.
687 @end table
689 The following targets are suggested as conventional names, for programs
690 in which they are useful.
692 @table @code
693 @item installcheck
694 Perform installation tests (if any).  The user must build and install
695 the program before running the tests.  You should not assume that
696 @file{$(bindir)} is in the search path.
698 @item installdirs
699 It's useful to add a target named @samp{installdirs} to create the
700 directories where files are installed, and their parent directories.
701 There is a script called @file{mkinstalldirs} which is convenient for
702 this; you can find it in the Texinfo package.
703 @c It's in /gd/gnu/lib/mkinstalldirs.
704 You can use a rule like this:
706 @comment This has been carefully formatted to look decent in the Make manual.
707 @comment Please be sure not to make it extend any further to the right.--roland
708 @smallexample
709 # Make sure all installation directories (e.g. $(bindir))
710 # actually exist by making them if necessary.
711 installdirs: mkinstalldirs
712         $(srcdir)/mkinstalldirs $(bindir) $(datadir) \
713                                 $(libdir) $(infodir) \
714                                 $(mandir)
715 @end smallexample
717 This rule should not modify the directories where compilation is done.
718 It should do nothing but create installation directories.
719 @end table