|
|
|
@ -8,6 +8,17 @@ |
|
|
|
@cindex conventions for makefiles |
|
|
|
@cindex standards for makefiles |
|
|
|
|
|
|
|
@c Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001 Free |
|
|
|
@c Software Foundation, Inc. |
|
|
|
|
|
|
|
@c Permission is granted to copy, distribute and/or modify this document |
|
|
|
@c under the terms of the GNU Free Documentation License, Version 1.1 |
|
|
|
@c or any later version published by the Free Software Foundation; |
|
|
|
@c with no Invariant Sections, with no |
|
|
|
@c Front-Cover Texts, and with no Back-Cover Texts. |
|
|
|
@c A copy of the license is included in the section entitled ``GNU |
|
|
|
@c Free Documentation License''. |
|
|
|
|
|
|
|
This |
|
|
|
@ifinfo |
|
|
|
node |
|
|
|
@ -21,13 +32,15 @@ chapter |
|
|
|
@end ifclear |
|
|
|
@end iftex |
|
|
|
describes conventions for writing the Makefiles for GNU programs. |
|
|
|
Using Automake will help you write a Makefile that follows these |
|
|
|
conventions. |
|
|
|
|
|
|
|
@menu |
|
|
|
* Makefile Basics:: General Conventions for Makefiles |
|
|
|
* Utilities in Makefiles:: Utilities in Makefiles |
|
|
|
* Command Variables:: Variables for Specifying Commands |
|
|
|
* Directory Variables:: Variables for Installation Directories |
|
|
|
* Standard Targets:: Standard Targets for Users |
|
|
|
* Makefile Basics:: General Conventions for Makefiles |
|
|
|
* Utilities in Makefiles:: Utilities in Makefiles |
|
|
|
* Command Variables:: Variables for Specifying Commands |
|
|
|
* Directory Variables:: Variables for Installation Directories |
|
|
|
* Standard Targets:: Standard Targets for Users |
|
|
|
* Install Command Categories:: Three categories of commands in the `install' |
|
|
|
rule: normal, pre-install and post-install. |
|
|
|
@end menu |
|
|
|
@ -79,7 +92,7 @@ foo.1 : foo.man sedscript |
|
|
|
|
|
|
|
@noindent |
|
|
|
will fail when the build directory is not the source directory, because |
|
|
|
@file{foo.man} and @file{sedscript} are in the the source directory. |
|
|
|
@file{foo.man} and @file{sedscript} are in the source directory. |
|
|
|
|
|
|
|
When using GNU @code{make}, relying on @samp{VPATH} to find the source |
|
|
|
file will work in the case where there is a single dependency file, |
|
|
|
@ -138,7 +151,7 @@ installation should not use any utilities directly except these: |
|
|
|
|
|
|
|
@c dd find |
|
|
|
@c gunzip gzip md5sum |
|
|
|
@c mkfifo mknod tee uname |
|
|
|
@c mkfifo mknod tee uname |
|
|
|
|
|
|
|
@example |
|
|
|
cat cmp cp diff echo egrep expr false grep install-info |
|
|
|
@ -247,9 +260,10 @@ Every Makefile should define the variable @code{INSTALL}, which is the |
|
|
|
basic command for installing a file into the system. |
|
|
|
|
|
|
|
Every Makefile should also define the variables @code{INSTALL_PROGRAM} |
|
|
|
and @code{INSTALL_DATA}. (The default for each of these should be |
|
|
|
@code{$(INSTALL)}.) Then it should use those variables as the commands |
|
|
|
for actual installation, for executables and nonexecutables |
|
|
|
and @code{INSTALL_DATA}. (The default for @code{INSTALL_PROGRAM} should |
|
|
|
be @code{$(INSTALL)}; the default for @code{INSTALL_DATA} should be |
|
|
|
@code{$@{INSTALL@} -m 644}.) Then it should use those variables as the |
|
|
|
commands for actual installation, for executables and nonexecutables |
|
|
|
respectively. Use these variables as follows: |
|
|
|
|
|
|
|
@example |
|
|
|
@ -280,26 +294,28 @@ installed. |
|
|
|
Installation directories should always be named by variables, so it is |
|
|
|
easy to install in a nonstandard place. The standard names for these |
|
|
|
variables are described below. They are based on a standard filesystem |
|
|
|
layout; variants of it are used in SVR4, 4.4BSD, Linux, Ultrix v4, and |
|
|
|
other modern operating systems. |
|
|
|
layout; variants of it are used in SVR4, 4.4BSD, GNU/Linux, Ultrix v4, |
|
|
|
and other modern operating systems. |
|
|
|
|
|
|
|
These two variables set the root for the installation. All the other |
|
|
|
installation directories should be subdirectories of one of these two, |
|
|
|
and nothing should be directly installed into these two directories. |
|
|
|
|
|
|
|
@table @samp |
|
|
|
@table @code |
|
|
|
@item prefix |
|
|
|
@vindex prefix |
|
|
|
A prefix used in constructing the default values of the variables listed |
|
|
|
below. The default value of @code{prefix} should be @file{/usr/local}. |
|
|
|
When building the complete GNU system, the prefix will be empty and |
|
|
|
@file{/usr} will be a symbolic link to @file{/}. |
|
|
|
(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. |
|
|
|
Running @samp{make install} with a different value of @code{prefix} from |
|
|
|
the one used to build the program should @emph{not} recompile the |
|
|
|
program. |
|
|
|
|
|
|
|
@item exec_prefix |
|
|
|
@vindex exec_prefix |
|
|
|
A prefix used in constructing the default values of some of the |
|
|
|
variables listed below. The default value of @code{exec_prefix} should |
|
|
|
be @code{$(prefix)}. |
|
|
|
@ -310,20 +326,22 @@ machine-specific files (such as executables and subroutine libraries), |
|
|
|
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 |
|
|
|
from the one used to build the program should @emph{not} recompile the |
|
|
|
program. |
|
|
|
@end table |
|
|
|
|
|
|
|
Executable programs are installed in one of the following directories. |
|
|
|
|
|
|
|
@table @samp |
|
|
|
@table @code |
|
|
|
@item bindir |
|
|
|
@vindex bindir |
|
|
|
The directory for installing executable programs that users can run. |
|
|
|
This should normally be @file{/usr/local/bin}, but write it as |
|
|
|
@file{$(exec_prefix)/bin}. |
|
|
|
(If you are using Autoconf, write it as @samp{@@bindir@@}.) |
|
|
|
|
|
|
|
@item sbindir |
|
|
|
@vindex sbindir |
|
|
|
The directory for installing executable programs that can be run from |
|
|
|
the shell, but are only generally useful to system administrators. This |
|
|
|
should normally be @file{/usr/local/sbin}, but write it as |
|
|
|
@ -331,6 +349,7 @@ should normally be @file{/usr/local/sbin}, but write it as |
|
|
|
(If you are using Autoconf, write it as @samp{@@sbindir@@}.) |
|
|
|
|
|
|
|
@item libexecdir |
|
|
|
@vindex libexecdir |
|
|
|
@comment This paragraph adjusted to avoid overfull hbox --roland 5jul94 |
|
|
|
The directory for installing executable programs to be run by other |
|
|
|
programs rather than by users. This directory should normally be |
|
|
|
@ -623,7 +642,8 @@ the installation commands. @xref{Install Command Categories}. |
|
|
|
|
|
|
|
@item install-strip |
|
|
|
Like @code{install}, but strip the executable files while installing |
|
|
|
them. In many cases, the definition of this target can be very simple: |
|
|
|
them. In simple cases, this target can use the @code{install} target in |
|
|
|
a simple way: |
|
|
|
|
|
|
|
@smallexample |
|
|
|
install-strip: |
|
|
|
@ -631,6 +651,14 @@ install-strip: |
|
|
|
install |
|
|
|
@end smallexample |
|
|
|
|
|
|
|
But if the package installs scripts as well as real executables, the |
|
|
|
@code{install-strip} target can't just refer to the @code{install} |
|
|
|
target; it has to strip the executables but not the scripts. |
|
|
|
|
|
|
|
@code{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 |
|
|
|
@ -745,7 +773,7 @@ The easiest way to do this is to create a subdirectory appropriately |
|
|
|
named, use @code{ln} or @code{cp} to install the proper files in it, and |
|
|
|
then @code{tar} that subdirectory. |
|
|
|
|
|
|
|
Compress the tar file file with @code{gzip}. For example, the actual |
|
|
|
Compress the tar file with @code{gzip}. For example, the actual |
|
|
|
distribution file for GCC version 1.40 is called @file{gcc-1.40.tar.gz}. |
|
|
|
|
|
|
|
The @code{dist} target should explicitly depend on all non-source files |
|
|
|
@ -793,6 +821,19 @@ installdirs: mkinstalldirs |
|
|
|
$(mandir) |
|
|
|
@end smallexample |
|
|
|
|
|
|
|
@noindent |
|
|
|
or, if you wish to support @env{DESTDIR}, |
|
|
|
|
|
|
|
@smallexample |
|
|
|
# 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) |
|
|
|
@end smallexample |
|
|
|
|
|
|
|
This rule should not modify the directories where compilation is done. |
|
|
|
It should do nothing but create installation directories. |
|
|
|
@end table |
|
|
|
|