All GNU programs should have the following targets in their Makefiles:
By default, the Make rules should compile and link with ‘-g’, so
that executable programs have debugging symbols. Users who don't mind
being helpless can strip the executables later if they wish.
Do not strip executables when installing them. Devil-may-care users can
install-strip target to do that.
If possible, write the
install target rule so that it does not
modify anything in the directory where the program was built, provided
‘make all’ has just been done. This is convenient for building the
program under one user name and installing it under another.
The commands should create all the directories in which files are to be
installed, if they don't already exist. This includes the directories
specified as the values of the variables
exec_prefix, as well as all subdirectories that are needed.
One way to do this is by means of an
as described below.
Use ‘-’ before any command for installing a man page, so that
make will ignore any errors. This is in case there are systems
that don't have the Unix man page documentation system installed.
The way to install Info files is to copy them into $(infodir)
$(INSTALL_DATA) (see Command Variables), and then run
install-info program if it is present.
is a program that edits the Info dir file to add or update the
menu entry for the given Info file; it is part of the Texinfo package.
Here is a sample rule to install an Info file that also tries to
handle some additional situations, such as
do-install-info: foo.info installdirs $(NORMAL_INSTALL) # Prefer an info file in . to one in srcdir. if test -f foo.info; then d=.; \ else d="$(srcdir)"; fi; \ $(INSTALL_DATA) $$d/foo.info \ "$(DESTDIR)$(infodir)/foo.info" # Run install-info only if it exists. # Use `if' instead of just prepending `-' to the # line so we notice real errors from install-info. # Use `$(SHELL) -c' because some shells do not # fail gracefully when there is an unknown command. $(POST_INSTALL) if $(SHELL) -c 'install-info --version' \ >/dev/null 2>&1; then \ install-info --dir-file="$(DESTDIR)$(infodir)/dir" \ "$(DESTDIR)$(infodir)/foo.info"; \ else true; fi
When writing the
install target, you must classify all the
commands into three categories: normal ones, pre-installation
commands and post-installation commands. See Install Command Categories.
When you have many documentation files to install, we recommend that
you avoid collisions and clutter by arranging for these targets to
install in subdirectories of the appropriate installation directory,
htmldir. As one example, if your package has multiple
manuals, and you wish to install HTML documentation with many files
(such as the “split” mode output by
makeinfo --html), you'll
certainly want to use subdirectories, or two nodes with the same name
in different manuals will overwrite each other.
Please make these
install-format targets invoke the
commands for the format target, for example, by making
format a dependency.
This rule should not modify the directories where compilation is done, only the directories where files are installed.
The uninstallation commands are divided into three categories, just like
the installation commands. See Install Command Categories.
install, but strip the executable files while installing them. In simple cases, this target can use the
installtarget in a simple way:
install-strip: $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \ install
But if the package installs scripts as well as real executables, the
install-strip target can't just refer to the
target; it has to strip the executables but not the scripts.
install-strip should not strip the executables in the build
directory which are being copied for installation. It should only strip
the copies that are installed.
Normally we do not recommend stripping an executable unless you are sure
the program has no bugs. However, it can be reasonable to install a
stripped executable for actual execution while saving the unstripped
executable elsewhere in case there is a bug.
Delete .dvi files here if they are not part of the distribution.
distclean, plus more: C source files produced by Bison, tags tables, Info files, and so on.
The reason we say “almost everything” is that running the command
‘make maintainer-clean’ should not delete configure even
if configure can be remade using a rule in the Makefile. More
generally, ‘make maintainer-clean’ should not delete anything
that needs to exist in order to run configure and then begin to
build the program. Also, there is no need to delete parent
directories that were created with ‘mkdir -p’, since they could
have existed anyway. These are the only exceptions;
maintainer-clean should delete everything else that can be
The ‘maintainer-clean’ target is intended to be used by a maintainer of the package, not by ordinary users. You may need special tools to reconstruct some of the files that ‘make maintainer-clean’ deletes. Since these files are normally included in the distribution, we don't take care to make them easy to reconstruct. If you find you need to unpack the full distribution again, don't blame us.
To help make users aware of this, the commands for the special
maintainer-clean target should start with these two:
@echo 'This command is intended for maintainers to use; it' @echo 'deletes files that may need special tools to rebuild.'
info: foo.info foo.info: foo.texi chap1.texi chap2.texi $(MAKEINFO) $(srcdir)/foo.texi
You must define the variable
MAKEINFO in the Makefile. It should
makeinfo program, which is part of the Texinfo
Normally a GNU distribution comes with Info files, and that means the
Info files are present in the source directory. Therefore, the Make
rule for an info file should update it in the source directory. When
users build the package, ordinarily Make will not update the Info files
because they will already be up to date.
alltarget; the user must manually invoke them.
Here's an example rule for generating DVI files from Texinfo:
dvi: foo.dvi foo.dvi: foo.texi chap1.texi chap2.texi $(TEXI2DVI) $(srcdir)/foo.texi
You must define the variable
TEXI2DVI in the Makefile. It should
run the program
texi2dvi, which is part of the Texinfo
write just the dependencies, and allow GNU
make to provide the command.
Here's another example, this one for generating HTML from Texinfo:
html: foo.html foo.html: foo.texi chap1.texi chap2.texi $(TEXI2HTML) $(srcdir)/foo.texi
Again, you would define the variable
TEXI2HTML in the Makefile;
for example, it might run
makeinfo --no-split --html
(makeinfo is part of the Texinfo distribution).
For example, the distribution tar file of GCC version 1.40 unpacks into a subdirectory named gcc-1.40.
The easiest way to do this is to create a subdirectory appropriately
cp to install the proper files in it, and
tar that subdirectory.
Compress the tar file with
gzip. For example, the actual
distribution file for GCC version 1.40 is called gcc-1.40.tar.gz.
It is ok to support other free compression formats as well.
dist target should explicitly depend on all non-source files
that are in the distribution, to make sure they are up to date in the
See Making Releases.
The following targets are suggested as conventional names, for programs in which they are useful.
# Make sure all installation directories (e.g. $(bindir)) # actually exist by making them if necessary. installdirs: mkinstalldirs $(srcdir)/mkinstalldirs $(bindir) $(datadir) \ $(libdir) $(infodir) \ $(mandir)
or, if you wish to support DESTDIR (strongly encouraged),
# Make sure all installation directories (e.g. $(bindir)) # actually exist by making them if necessary. installdirs: mkinstalldirs $(srcdir)/mkinstalldirs \ $(DESTDIR)$(bindir) $(DESTDIR)$(datadir) \ $(DESTDIR)$(libdir) $(DESTDIR)$(infodir) \ $(DESTDIR)$(mandir)
This rule should not modify the directories where compilation is done. It should do nothing but create installation directories.
texi2dvi uses TeX to do the real work
of formatting. TeX is not distributed with Texinfo.