Mention Automake.

Mention DESTDIR.
Comment on changing prefix or exec_prefix.
This commit is contained in:
Richard M. Stallman 1998-10-15 15:29:00 +00:00
parent 3948640154
commit 4dfe38353e

View file

@ -21,6 +21,8 @@ chapter
@end ifclear @end ifclear
@end iftex @end iftex
describes conventions for writing the Makefiles for GNU programs. describes conventions for writing the Makefiles for GNU programs.
Using Automake will help you write a Makefile that follows these
conventions.
@menu @menu
* Makefile Basics:: General Conventions for Makefiles * Makefile Basics:: General Conventions for Makefiles
@ -257,6 +259,18 @@ $(INSTALL_PROGRAM) foo $(bindir)/foo
$(INSTALL_DATA) libfoo.a $(libdir)/libfoo.a $(INSTALL_DATA) libfoo.a $(libdir)/libfoo.a
@end example @end example
Optionally, you may prepend the value of @code{DESTDIR} to the target
filename. Doing this allows the installer to create a snapshot of the
installation to be copied onto the real target filesystem later. Do not
set the value of @code{DESTDIR} in your Makefile, and do not include it
in any installed files. With support for @code{DESTDIR}, the above
examples become:
@example
$(INSTALL_PROGRAM) foo $(DESTDIR)$(bindir)/foo
$(INSTALL_DATA) libfoo.a $(DESTDIR)$(libdir)/libfoo.a
@end example
@noindent @noindent
Always use a file name, not a directory name, as the second argument of Always use a file name, not a directory name, as the second argument of
the installation commands. Use a separate command for each file to be the installation commands. Use a separate command for each file to be
@ -283,6 +297,10 @@ When building the complete GNU system, the prefix will be empty and
@file{/usr} will be a symbolic link to @file{/}. @file{/usr} will be a symbolic link to @file{/}.
(If you are using Autoconf, write it as @samp{@@prefix@@}.) (If you are using Autoconf, write it as @samp{@@prefix@@}.)
Running @samp{make install} with a different value of @code{prefix}
from the one used to build the program should @var{not} recompile
the program.
@item exec_prefix @item exec_prefix
A prefix used in constructing the default values of some of the A prefix used in constructing the default values of some of the
variables listed below. The default value of @code{exec_prefix} should variables listed below. The default value of @code{exec_prefix} should
@ -292,6 +310,10 @@ be @code{$(prefix)}.
Generally, @code{$(exec_prefix)} is used for directories that contain Generally, @code{$(exec_prefix)} is used for directories that contain
machine-specific files (such as executables and subroutine libraries), machine-specific files (such as executables and subroutine libraries),
while @code{$(prefix)} is used directly for other directories. while @code{$(prefix)} is used directly for other directories.
Running @samp{make install} with a different value of @code{exec_prefix}
from the one used to build the program should @var{not} recompile the
program.
@end table @end table
Executable programs are installed in one of the following directories. Executable programs are installed in one of the following directories.
@ -568,12 +590,12 @@ Here is a sample rule to install an Info file:
@comment This example has been carefully formatted for the Make manual. @comment This example has been carefully formatted for the Make manual.
@comment Please do not reformat it without talking to roland@gnu.ai.mit.edu. @comment Please do not reformat it without talking to roland@gnu.ai.mit.edu.
@smallexample @smallexample
$(infodir)/foo.info: foo.info $(DESTDIR)$(infodir)/foo.info: foo.info
$(POST_INSTALL) $(POST_INSTALL)
# There may be a newer info file in . than in srcdir. # There may be a newer info file in . than in srcdir.
-if test -f foo.info; then d=.; \ -if test -f foo.info; then d=.; \
else d=$(srcdir); fi; \ else d=$(srcdir); fi; \
$(INSTALL_DATA) $$d/foo.info $@@; \ $(INSTALL_DATA) $$d/foo.info $(DESTDIR)$@@; \
# Run install-info only if it exists. # Run install-info only if it exists.
# Use `if' instead of just prepending `-' to the # Use `if' instead of just prepending `-' to the
# line so we notice real errors from install-info. # line so we notice real errors from install-info.
@ -581,8 +603,8 @@ $(infodir)/foo.info: foo.info
# fail gracefully when there is an unknown command. # fail gracefully when there is an unknown command.
if $(SHELL) -c 'install-info --version' \ if $(SHELL) -c 'install-info --version' \
>/dev/null 2>&1; then \ >/dev/null 2>&1; then \
install-info --dir-file=$(infodir)/dir \ install-info --dir-file=$(DESTDIR)$(infodir)/dir \
$(infodir)/foo.info; \ $(DESTDIR)$(infodir)/foo.info; \
else true; fi else true; fi
@end smallexample @end smallexample