annotate man/make-stds.texi @ 431:a97165e56215

Added tag r21-2-23 for changeset a5df635868b2
author cvs
date Mon, 13 Aug 2007 11:29:10 +0200
parents 3ecd8885ac67
children abe6d1db359e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 @comment This file is included by both standards.texi and make.texinfo.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 @comment It was broken out of standards.texi on 1/6/93 by roland.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4 @node Makefile Conventions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 @chapter Makefile Conventions
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 @comment standards.texi does not print an index, but make.texinfo does.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 @cindex makefile, conventions for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 @cindex conventions for makefiles
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 @cindex standards for makefiles
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 @ifinfo
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 node
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 @end ifinfo
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 @iftex
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 @ifset CODESTD
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 section
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 @end ifset
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 @ifclear CODESTD
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 chapter
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 @end ifclear
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 @end iftex
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 describes conventions for writing the Makefiles for GNU programs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 Using Automake will help you write a Makefile that follows these
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 conventions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 @menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 * Makefile Basics:: General Conventions for Makefiles
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 * Utilities in Makefiles:: Utilities in Makefiles
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 * Command Variables:: Variables for Specifying Commands
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31 * Directory Variables:: Variables for Installation Directories
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 * Standard Targets:: Standard Targets for Users
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33 * Install Command Categories:: Three categories of commands in the `install'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 rule: normal, pre-install and post-install.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 @end menu
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 @node Makefile Basics
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38 @section General Conventions for Makefiles
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 Every Makefile should contain this line:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 SHELL = /bin/sh
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 @noindent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 to avoid trouble on systems where the @code{SHELL} variable might be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 inherited from the environment. (This is never a problem with GNU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 @code{make}.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 Different @code{make} programs have incompatible suffix lists and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 implicit rules, and this sometimes creates confusion or misbehavior. So
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 it is a good idea to set the suffix list explicitly using only the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 suffixes you need in the particular Makefile, like this:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57 .SUFFIXES:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 .SUFFIXES: .c .o
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
60
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
61 @noindent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
62 The first line clears out the suffix list, the second introduces all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 suffixes which may be subject to implicit rules in this Makefile.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 Don't assume that @file{.} is in the path for command execution. When
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66 you need to run programs that are a part of your package during the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 make, please make sure that it uses @file{./} if the program is built as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 part of the make or @file{$(srcdir)/} if the file is an unchanging part
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
69 of the source code. Without one of these prefixes, the current search
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
70 path is used.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
72 The distinction between @file{./} (the @dfn{build directory}) and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 @file{$(srcdir)/} (the @dfn{source directory}) is important because
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
74 users can build in a separate directory using the @samp{--srcdir} option
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75 to @file{configure}. A rule of the form:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78 foo.1 : foo.man sedscript
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
79 sed -e sedscript foo.man > foo.1
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
80 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 @noindent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 will fail when the build directory is not the source directory, because
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84 @file{foo.man} and @file{sedscript} are in the the source directory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 When using GNU @code{make}, relying on @samp{VPATH} to find the source
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87 file will work in the case where there is a single dependency file,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 since the @code{make} automatic variable @samp{$<} will represent the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 source file wherever it is. (Many versions of @code{make} set @samp{$<}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 only in implicit rules.) A Makefile target like
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 foo.o : bar.c
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 $(CC) -I. -I$(srcdir) $(CFLAGS) -c bar.c -o foo.o
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 @noindent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 should instead be written as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 foo.o : bar.c
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 $(CC) -I. -I$(srcdir) $(CFLAGS) -c $< -o $@@
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 @noindent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 in order to allow @samp{VPATH} to work correctly. When the target has
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 multiple dependencies, using an explicit @samp{$(srcdir)} is the easiest
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 way to make the rule work well. For example, the target above for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109 @file{foo.1} is best written as:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 foo.1 : foo.man sedscript
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 sed -e $(srcdir)/sedscript $(srcdir)/foo.man > $@@
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116 GNU distributions usually contain some files which are not source
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
117 files---for example, Info files, and the output from Autoconf, Automake,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 Bison or Flex. Since these files normally appear in the source
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 directory, they should always appear in the source directory, not in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 build directory. So Makefile rules to update them should put the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 updated files in the source directory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
122
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123 However, if a file does not appear in the distribution, then the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124 Makefile should not put it in the source directory, because building a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 program in ordinary circumstances should not modify the source directory
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 in any way.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 Try to make the build and installation targets, at least (and all their
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 subtargets) work correctly with a parallel @code{make}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 @node Utilities in Makefiles
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 @section Utilities in Makefiles
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 Write the Makefile commands (and any shell scripts, such as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 @code{configure}) to run in @code{sh}, not in @code{csh}. Don't use any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 special features of @code{ksh} or @code{bash}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138 The @code{configure} script and the Makefile rules for building and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
139 installation should not use any utilities directly except these:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
140
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
141 @c dd find
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 @c gunzip gzip md5sum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 @c mkfifo mknod tee uname
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 cat cmp cp diff echo egrep expr false grep install-info
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 ln ls mkdir mv pwd rm rmdir sed sleep sort tar test touch true
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
148 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 The compression program @code{gzip} can be used in the @code{dist} rule.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 Stick to the generally supported options for these programs. For
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 example, don't use @samp{mkdir -p}, convenient as it may be, because
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 most systems don't support it.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 It is a good idea to avoid creating symbolic links in makefiles, since a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 few systems don't support them.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 The Makefile rules for building and installation can also use compilers
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 and related programs, but should do so via @code{make} variables so that the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 user can substitute alternatives. Here are some of the programs we
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
162 mean:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
163
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 ar bison cc flex install ld ldconfig lex
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 make makeinfo ranlib texi2dvi yacc
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
167 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 Use the following @code{make} variables to run those programs:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 $(AR) $(BISON) $(CC) $(FLEX) $(INSTALL) $(LD) $(LDCONFIG) $(LEX)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 $(MAKE) $(MAKEINFO) $(RANLIB) $(TEXI2DVI) $(YACC)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 When you use @code{ranlib} or @code{ldconfig}, you should make sure
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 nothing bad happens if the system does not have the program in question.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 Arrange to ignore an error from that command, and print a message before
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 the command to tell the user that failure of this command does not mean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 a problem. (The Autoconf @samp{AC_PROG_RANLIB} macro can help with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 this.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 If you use symbolic links, you should implement a fallback for systems
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 that don't have symbolic links.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 Additional utilities that can be used via Make variables are:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 chgrp chmod chown mknod
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 It is ok to use other utilities in Makefile portions (or scripts)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 intended only for particular systems where you know those utilities
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 exist.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 @node Command Variables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 @section Variables for Specifying Commands
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199 Makefiles should provide variables for overriding certain commands, options,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 and so on.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 In particular, you should run most utility programs via variables.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 Thus, if you use Bison, have a variable named @code{BISON} whose default
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 value is set with @samp{BISON = bison}, and refer to it with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 @code{$(BISON)} whenever you need to use Bison.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 File management utilities such as @code{ln}, @code{rm}, @code{mv}, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 so on, need not be referred to through variables in this way, since users
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 don't need to replace them with other programs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211 Each program-name variable should come with an options variable that is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 used to supply options to the program. Append @samp{FLAGS} to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 program-name variable name to get the options variable name---for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 example, @code{BISONFLAGS}. (The names @code{CFLAGS} for the C
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215 compiler, @code{YFLAGS} for yacc, and @code{LFLAGS} for lex, are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
216 exceptions to this rule, but we keep them because they are standard.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
217 Use @code{CPPFLAGS} in any compilation command that runs the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
218 preprocessor, and use @code{LDFLAGS} in any compilation command that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
219 does linking as well as in any direct use of @code{ld}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
220
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
221 If there are C compiler options that @emph{must} be used for proper
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
222 compilation of certain files, do not include them in @code{CFLAGS}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
223 Users expect to be able to specify @code{CFLAGS} freely themselves.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
224 Instead, arrange to pass the necessary options to the C compiler
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
225 independently of @code{CFLAGS}, by writing them explicitly in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
226 compilation commands or by defining an implicit rule, like this:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
227
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
228 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
229 CFLAGS = -g
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
230 ALL_CFLAGS = -I. $(CFLAGS)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
231 .c.o:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
232 $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $<
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
234
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
235 Do include the @samp{-g} option in @code{CFLAGS}, because that is not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
236 @emph{required} for proper compilation. You can consider it a default
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
237 that is only recommended. If the package is set up so that it is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
238 compiled with GCC by default, then you might as well include @samp{-O}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
239 in the default value of @code{CFLAGS} as well.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
240
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
241 Put @code{CFLAGS} last in the compilation command, after other variables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
242 containing compiler options, so the user can use @code{CFLAGS} to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
243 override the others.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
244
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
245 @code{CFLAGS} should be used in every invocation of the C compiler,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
246 both those which do compilation and those which do linking.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
247
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
248 Every Makefile should define the variable @code{INSTALL}, which is the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
249 basic command for installing a file into the system.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
250
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
251 Every Makefile should also define the variables @code{INSTALL_PROGRAM}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
252 and @code{INSTALL_DATA}. (The default for each of these should be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
253 @code{$(INSTALL)}.) Then it should use those variables as the commands
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
254 for actual installation, for executables and nonexecutables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
255 respectively. Use these variables as follows:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
256
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
257 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
258 $(INSTALL_PROGRAM) foo $(bindir)/foo
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
259 $(INSTALL_DATA) libfoo.a $(libdir)/libfoo.a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
260 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
261
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
262 Optionally, you may prepend the value of @code{DESTDIR} to the target
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
263 filename. Doing this allows the installer to create a snapshot of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
264 installation to be copied onto the real target filesystem later. Do not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
265 set the value of @code{DESTDIR} in your Makefile, and do not include it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
266 in any installed files. With support for @code{DESTDIR}, the above
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
267 examples become:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
268
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
269 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
270 $(INSTALL_PROGRAM) foo $(DESTDIR)$(bindir)/foo
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
271 $(INSTALL_DATA) libfoo.a $(DESTDIR)$(libdir)/libfoo.a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
272 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
273
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
274 @noindent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
275 Always use a file name, not a directory name, as the second argument of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
276 the installation commands. Use a separate command for each file to be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
277 installed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
278
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
279 @node Directory Variables
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
280 @section Variables for Installation Directories
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
281
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
282 Installation directories should always be named by variables, so it is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
283 easy to install in a nonstandard place. The standard names for these
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
284 variables are described below. They are based on a standard filesystem
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
285 layout; variants of it are used in SVR4, 4.4BSD, Linux, Ultrix v4, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
286 other modern operating systems.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
287
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
288 These two variables set the root for the installation. All the other
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
289 installation directories should be subdirectories of one of these two,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
290 and nothing should be directly installed into these two directories.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
291
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
292 @table @samp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
293 @item prefix
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
294 A prefix used in constructing the default values of the variables listed
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
295 below. The default value of @code{prefix} should be @file{/usr/local}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
296 When building the complete GNU system, the prefix will be empty and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
297 @file{/usr} will be a symbolic link to @file{/}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
298 (If you are using Autoconf, write it as @samp{@@prefix@@}.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
299
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
300 Running @samp{make install} with a different value of @code{prefix}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
301 from the one used to build the program should @var{not} recompile
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
302 the program.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
303
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
304 @item exec_prefix
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
305 A prefix used in constructing the default values of some of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
306 variables listed below. The default value of @code{exec_prefix} should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
307 be @code{$(prefix)}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
308 (If you are using Autoconf, write it as @samp{@@exec_prefix@@}.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
309
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
310 Generally, @code{$(exec_prefix)} is used for directories that contain
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
311 machine-specific files (such as executables and subroutine libraries),
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
312 while @code{$(prefix)} is used directly for other directories.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
313
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
314 Running @samp{make install} with a different value of @code{exec_prefix}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
315 from the one used to build the program should @var{not} recompile the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
316 program.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
317 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
318
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
319 Executable programs are installed in one of the following directories.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
320
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
321 @table @samp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
322 @item bindir
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
323 The directory for installing executable programs that users can run.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
324 This should normally be @file{/usr/local/bin}, but write it as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
325 @file{$(exec_prefix)/bin}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
326 (If you are using Autoconf, write it as @samp{@@bindir@@}.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
327
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
328 @item sbindir
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
329 The directory for installing executable programs that can be run from
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
330 the shell, but are only generally useful to system administrators. This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
331 should normally be @file{/usr/local/sbin}, but write it as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
332 @file{$(exec_prefix)/sbin}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
333 (If you are using Autoconf, write it as @samp{@@sbindir@@}.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
334
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
335 @item libexecdir
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
336 @comment This paragraph adjusted to avoid overfull hbox --roland 5jul94
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
337 The directory for installing executable programs to be run by other
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
338 programs rather than by users. This directory should normally be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
339 @file{/usr/local/libexec}, but write it as @file{$(exec_prefix)/libexec}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
340 (If you are using Autoconf, write it as @samp{@@libexecdir@@}.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
341 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
342
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
343 Data files used by the program during its execution are divided into
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
344 categories in two ways.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
345
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
346 @itemize @bullet
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
347 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
348 Some files are normally modified by programs; others are never normally
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
349 modified (though users may edit some of these).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
350
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
351 @item
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
352 Some files are architecture-independent and can be shared by all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
353 machines at a site; some are architecture-dependent and can be shared
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
354 only by machines of the same kind and operating system; others may never
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
355 be shared between two machines.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
356 @end itemize
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
357
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
358 This makes for six different possibilities. However, we want to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
359 discourage the use of architecture-dependent files, aside from object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
360 files and libraries. It is much cleaner to make other data files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
361 architecture-independent, and it is generally not hard.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
362
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
363 Therefore, here are the variables Makefiles should use to specify
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
364 directories:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
365
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
366 @table @samp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
367 @item datadir
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
368 The directory for installing read-only architecture independent data
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
369 files. This should normally be @file{/usr/local/share}, but write it as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
370 @file{$(prefix)/share}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
371 (If you are using Autoconf, write it as @samp{@@datadir@@}.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
372 As a special exception, see @file{$(infodir)}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
373 and @file{$(includedir)} below.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
374
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
375 @item sysconfdir
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
376 The directory for installing read-only data files that pertain to a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
377 single machine--that is to say, files for configuring a host. Mailer
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
378 and network configuration files, @file{/etc/passwd}, and so forth belong
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
379 here. All the files in this directory should be ordinary ASCII text
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
380 files. This directory should normally be @file{/usr/local/etc}, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
381 write it as @file{$(prefix)/etc}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
382 (If you are using Autoconf, write it as @samp{@@sysconfdir@@}.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
383
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
384 Do not install executables here in this directory (they probably belong
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
385 in @file{$(libexecdir)} or @file{$(sbindir)}). Also do not install
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
386 files that are modified in the normal course of their use (programs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
387 whose purpose is to change the configuration of the system excluded).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
388 Those probably belong in @file{$(localstatedir)}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
389
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
390 @item sharedstatedir
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
391 The directory for installing architecture-independent data files which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
392 the programs modify while they run. This should normally be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
393 @file{/usr/local/com}, but write it as @file{$(prefix)/com}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
394 (If you are using Autoconf, write it as @samp{@@sharedstatedir@@}.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
395
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
396 @item localstatedir
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
397 The directory for installing data files which the programs modify while
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
398 they run, and that pertain to one specific machine. Users should never
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
399 need to modify files in this directory to configure the package's
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
400 operation; put such configuration information in separate files that go
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
401 in @file{$(datadir)} or @file{$(sysconfdir)}. @file{$(localstatedir)}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
402 should normally be @file{/usr/local/var}, but write it as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
403 @file{$(prefix)/var}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
404 (If you are using Autoconf, write it as @samp{@@localstatedir@@}.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
405
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
406 @item libdir
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
407 The directory for object files and libraries of object code. Do not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
408 install executables here, they probably ought to go in @file{$(libexecdir)}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
409 instead. The value of @code{libdir} should normally be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
410 @file{/usr/local/lib}, but write it as @file{$(exec_prefix)/lib}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
411 (If you are using Autoconf, write it as @samp{@@libdir@@}.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
412
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
413 @item infodir
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
414 The directory for installing the Info files for this package. By
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
415 default, it should be @file{/usr/local/info}, but it should be written
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
416 as @file{$(prefix)/info}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
417 (If you are using Autoconf, write it as @samp{@@infodir@@}.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
418
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
419 @item lispdir
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
420 The directory for installing any Emacs Lisp files in this package. By
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
421 default, it should be @file{/usr/local/share/emacs/site-lisp}, but it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
422 should be written as @file{$(prefix)/share/emacs/site-lisp}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
423
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
424 If you are using Autoconf, write the default as @samp{@@lispdir@@}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
425 In order to make @samp{@@lispdir@@} work, you need the following lines
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
426 in your @file{configure.in} file:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
427
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
428 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
429 lispdir='$@{datadir@}/emacs/site-lisp'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
430 AC_SUBST(lispdir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
431 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
432
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
433 @item includedir
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
434 @c rewritten to avoid overfull hbox --roland
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
435 The directory for installing header files to be included by user
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
436 programs with the C @samp{#include} preprocessor directive. This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
437 should normally be @file{/usr/local/include}, but write it as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
438 @file{$(prefix)/include}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
439 (If you are using Autoconf, write it as @samp{@@includedir@@}.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
440
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
441 Most compilers other than GCC do not look for header files in directory
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
442 @file{/usr/local/include}. So installing the header files this way is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
443 only useful with GCC. Sometimes this is not a problem because some
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
444 libraries are only really intended to work with GCC. But some libraries
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
445 are intended to work with other compilers. They should install their
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
446 header files in two places, one specified by @code{includedir} and one
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
447 specified by @code{oldincludedir}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
448
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
449 @item oldincludedir
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
450 The directory for installing @samp{#include} header files for use with
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
451 compilers other than GCC. This should normally be @file{/usr/include}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
452 (If you are using Autoconf, you can write it as @samp{@@oldincludedir@@}.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
453
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
454 The Makefile commands should check whether the value of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
455 @code{oldincludedir} is empty. If it is, they should not try to use
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
456 it; they should cancel the second installation of the header files.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
457
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
458 A package should not replace an existing header in this directory unless
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
459 the header came from the same package. Thus, if your Foo package
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
460 provides a header file @file{foo.h}, then it should install the header
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
461 file in the @code{oldincludedir} directory if either (1) there is no
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
462 @file{foo.h} there or (2) the @file{foo.h} that exists came from the Foo
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
463 package.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
464
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
465 To tell whether @file{foo.h} came from the Foo package, put a magic
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
466 string in the file---part of a comment---and @code{grep} for that string.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
467 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
468
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
469 Unix-style man pages are installed in one of the following:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
470
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
471 @table @samp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
472 @item mandir
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
473 The top-level directory for installing the man pages (if any) for this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
474 package. It will normally be @file{/usr/local/man}, but you should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
475 write it as @file{$(prefix)/man}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
476 (If you are using Autoconf, write it as @samp{@@mandir@@}.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
477
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
478 @item man1dir
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
479 The directory for installing section 1 man pages. Write it as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
480 @file{$(mandir)/man1}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
481 @item man2dir
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
482 The directory for installing section 2 man pages. Write it as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
483 @file{$(mandir)/man2}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
484 @item @dots{}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
485
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
486 @strong{Don't make the primary documentation for any GNU software be a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
487 man page. Write a manual in Texinfo instead. Man pages are just for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
488 the sake of people running GNU software on Unix, which is a secondary
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
489 application only.}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
490
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
491 @item manext
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
492 The file name extension for the installed man page. This should contain
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
493 a period followed by the appropriate digit; it should normally be @samp{.1}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
494
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
495 @item man1ext
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
496 The file name extension for installed section 1 man pages.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
497 @item man2ext
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
498 The file name extension for installed section 2 man pages.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
499 @item @dots{}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
500 Use these names instead of @samp{manext} if the package needs to install man
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
501 pages in more than one section of the manual.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
502 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
503
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
504 And finally, you should set the following variable:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
505
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
506 @table @samp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
507 @item srcdir
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
508 The directory for the sources being compiled. The value of this
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
509 variable is normally inserted by the @code{configure} shell script.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
510 (If you are using Autconf, use @samp{srcdir = @@srcdir@@}.)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
511 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
512
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
513 For example:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
514
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
515 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
516 @c I have changed some of the comments here slightly to fix an overfull
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
517 @c hbox, so the make manual can format correctly. --roland
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
518 # Common prefix for installation directories.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
519 # NOTE: This directory must exist when you start the install.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
520 prefix = /usr/local
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
521 exec_prefix = $(prefix)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
522 # Where to put the executable for the command `gcc'.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
523 bindir = $(exec_prefix)/bin
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
524 # Where to put the directories used by the compiler.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
525 libexecdir = $(exec_prefix)/libexec
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
526 # Where to put the Info files.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
527 infodir = $(prefix)/info
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
528 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
529
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
530 If your program installs a large number of files into one of the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
531 standard user-specified directories, it might be useful to group them
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
532 into a subdirectory particular to that program. If you do this, you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
533 should write the @code{install} rule to create these subdirectories.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
534
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
535 Do not expect the user to include the subdirectory name in the value of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
536 any of the variables listed above. The idea of having a uniform set of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
537 variable names for installation directories is to enable the user to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
538 specify the exact same values for several different GNU packages. In
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
539 order for this to be useful, all the packages must be designed so that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
540 they will work sensibly when the user does so.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
541
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
542 @node Standard Targets
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
543 @section Standard Targets for Users
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
544
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
545 All GNU programs should have the following targets in their Makefiles:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
546
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
547 @table @samp
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
548 @item all
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
549 Compile the entire program. This should be the default target. This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
550 target need not rebuild any documentation files; Info files should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
551 normally be included in the distribution, and DVI files should be made
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
552 only when explicitly asked for.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
553
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
554 By default, the Make rules should compile and link with @samp{-g}, so
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
555 that executable programs have debugging symbols. Users who don't mind
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
556 being helpless can strip the executables later if they wish.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
557
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
558 @item install
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
559 Compile the program and copy the executables, libraries, and so on to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
560 the file names where they should reside for actual use. If there is a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
561 simple test to verify that a program is properly installed, this target
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
562 should run that test.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
563
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
564 Do not strip executables when installing them. Devil-may-care users can
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
565 use the @code{install-strip} target to do that.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
566
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
567 If possible, write the @code{install} target rule so that it does not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
568 modify anything in the directory where the program was built, provided
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
569 @samp{make all} has just been done. This is convenient for building the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
570 program under one user name and installing it under another.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
571
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
572 The commands should create all the directories in which files are to be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
573 installed, if they don't already exist. This includes the directories
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
574 specified as the values of the variables @code{prefix} and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
575 @code{exec_prefix}, as well as all subdirectories that are needed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
576 One way to do this is by means of an @code{installdirs} target
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
577 as described below.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
578
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
579 Use @samp{-} before any command for installing a man page, so that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
580 @code{make} will ignore any errors. This is in case there are systems
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
581 that don't have the Unix man page documentation system installed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
582
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
583 The way to install Info files is to copy them into @file{$(infodir)}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
584 with @code{$(INSTALL_DATA)} (@pxref{Command Variables}), and then run
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
585 the @code{install-info} program if it is present. @code{install-info}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
586 is a program that edits the Info @file{dir} file to add or update the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
587 menu entry for the given Info file; it is part of the Texinfo package.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
588 Here is a sample rule to install an Info file:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
589
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
590 @comment This example has been carefully formatted for the Make manual.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
591 @comment Please do not reformat it without talking to roland@gnu.ai.mit.edu.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
592 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
593 $(DESTDIR)$(infodir)/foo.info: foo.info
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
594 $(POST_INSTALL)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
595 # There may be a newer info file in . than in srcdir.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
596 -if test -f foo.info; then d=.; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
597 else d=$(srcdir); fi; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
598 $(INSTALL_DATA) $$d/foo.info $(DESTDIR)$@@; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
599 # Run install-info only if it exists.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
600 # Use `if' instead of just prepending `-' to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
601 # line so we notice real errors from install-info.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
602 # We use `$(SHELL) -c' because some shells do not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
603 # fail gracefully when there is an unknown command.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
604 if $(SHELL) -c 'install-info --version' \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
605 >/dev/null 2>&1; then \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
606 install-info --dir-file=$(DESTDIR)$(infodir)/dir \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
607 $(DESTDIR)$(infodir)/foo.info; \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
608 else true; fi
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
609 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
610
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
611 When writing the @code{install} target, you must classify all the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
612 commands into three categories: normal ones, @dfn{pre-installation}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
613 commands and @dfn{post-installation} commands. @xref{Install Command
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
614 Categories}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
615
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
616 @item uninstall
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
617 Delete all the installed files---the copies that the @samp{install}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
618 target creates.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
619
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
620 This rule should not modify the directories where compilation is done,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
621 only the directories where files are installed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
622
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
623 The uninstallation commands are divided into three categories, just like
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
624 the installation commands. @xref{Install Command Categories}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
625
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
626 @item install-strip
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
627 Like @code{install}, but strip the executable files while installing
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
628 them. In many cases, the definition of this target can be very simple:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
629
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
630 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
631 install-strip:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
632 $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
633 install
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
634 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
635
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
636 Normally we do not recommend stripping an executable unless you are sure
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
637 the program has no bugs. However, it can be reasonable to install a
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
638 stripped executable for actual execution while saving the unstripped
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
639 executable elsewhere in case there is a bug.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
640
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
641 @comment The gratuitous blank line here is to make the table look better
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
642 @comment in the printed Make manual. Please leave it in.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
643 @item clean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
644
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
645 Delete all files from the current directory that are normally created by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
646 building the program. Don't delete the files that record the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
647 configuration. Also preserve files that could be made by building, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
648 normally aren't because the distribution comes with them.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
649
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
650 Delete @file{.dvi} files here if they are not part of the distribution.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
651
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
652 @item distclean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
653 Delete all files from the current directory that are created by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
654 configuring or building the program. If you have unpacked the source
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
655 and built the program without creating any other files, @samp{make
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
656 distclean} should leave only the files that were in the distribution.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
657
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
658 @item mostlyclean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
659 Like @samp{clean}, but may refrain from deleting a few files that people
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
660 normally don't want to recompile. For example, the @samp{mostlyclean}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
661 target for GCC does not delete @file{libgcc.a}, because recompiling it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
662 is rarely necessary and takes a lot of time.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
663
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
664 @item maintainer-clean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
665 Delete almost everything from the current directory that can be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
666 reconstructed with this Makefile. This typically includes everything
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
667 deleted by @code{distclean}, plus more: C source files produced by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
668 Bison, tags tables, Info files, and so on.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
669
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
670 The reason we say ``almost everything'' is that running the command
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
671 @samp{make maintainer-clean} should not delete @file{configure} even if
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
672 @file{configure} can be remade using a rule in the Makefile. More generally,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
673 @samp{make maintainer-clean} should not delete anything that needs to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
674 exist in order to run @file{configure} and then begin to build the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
675 program. This is the only exception; @code{maintainer-clean} should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
676 delete everything else that can be rebuilt.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
677
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
678 The @samp{maintainer-clean} target is intended to be used by a maintainer of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
679 the package, not by ordinary users. You may need special tools to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
680 reconstruct some of the files that @samp{make maintainer-clean} deletes.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
681 Since these files are normally included in the distribution, we don't
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
682 take care to make them easy to reconstruct. If you find you need to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
683 unpack the full distribution again, don't blame us.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
684
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
685 To help make users aware of this, the commands for the special
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
686 @code{maintainer-clean} target should start with these two:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
687
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
688 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
689 @@echo 'This command is intended for maintainers to use; it'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
690 @@echo 'deletes files that may need special tools to rebuild.'
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
691 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
692
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
693 @item TAGS
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
694 Update a tags table for this program.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
695 @c ADR: how?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
696
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
697 @item info
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
698 Generate any Info files needed. The best way to write the rules is as
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
699 follows:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
700
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
701 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
702 info: foo.info
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
703
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
704 foo.info: foo.texi chap1.texi chap2.texi
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
705 $(MAKEINFO) $(srcdir)/foo.texi
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
706 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
707
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
708 @noindent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
709 You must define the variable @code{MAKEINFO} in the Makefile. It should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
710 run the @code{makeinfo} program, which is part of the Texinfo
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
711 distribution.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
712
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
713 Normally a GNU distribution comes with Info files, and that means the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
714 Info files are present in the source directory. Therefore, the Make
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
715 rule for an info file should update it in the source directory. When
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
716 users build the package, ordinarily Make will not update the Info files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
717 because they will already be up to date.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
718
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
719 @item dvi
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
720 Generate DVI files for all Texinfo documentation.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
721 For example:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
722
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
723 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
724 dvi: foo.dvi
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
725
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
726 foo.dvi: foo.texi chap1.texi chap2.texi
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
727 $(TEXI2DVI) $(srcdir)/foo.texi
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
728 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
729
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
730 @noindent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
731 You must define the variable @code{TEXI2DVI} in the Makefile. It should
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
732 run the program @code{texi2dvi}, which is part of the Texinfo
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
733 distribution.@footnote{@code{texi2dvi} uses @TeX{} to do the real work
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
734 of formatting. @TeX{} is not distributed with Texinfo.} Alternatively,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
735 write just the dependencies, and allow GNU @code{make} to provide the command.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
736
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
737 @item dist
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
738 Create a distribution tar file for this program. The tar file should be
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
739 set up so that the file names in the tar file start with a subdirectory
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
740 name which is the name of the package it is a distribution for. This
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
741 name can include the version number.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
742
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
743 For example, the distribution tar file of GCC version 1.40 unpacks into
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
744 a subdirectory named @file{gcc-1.40}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
745
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
746 The easiest way to do this is to create a subdirectory appropriately
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
747 named, use @code{ln} or @code{cp} to install the proper files in it, and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
748 then @code{tar} that subdirectory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
749
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
750 Compress the tar file file with @code{gzip}. For example, the actual
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
751 distribution file for GCC version 1.40 is called @file{gcc-1.40.tar.gz}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
752
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
753 The @code{dist} target should explicitly depend on all non-source files
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
754 that are in the distribution, to make sure they are up to date in the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
755 distribution.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
756 @ifset CODESTD
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
757 @xref{Releases, , Making Releases}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
758 @end ifset
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
759 @ifclear CODESTD
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
760 @xref{Releases, , Making Releases, standards, GNU Coding Standards}.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
761 @end ifclear
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
762
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
763 @item check
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
764 Perform self-tests (if any). The user must build the program before
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
765 running the tests, but need not install the program; you should write
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
766 the self-tests so that they work when the program is built but not
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
767 installed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
768 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
769
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
770 The following targets are suggested as conventional names, for programs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
771 in which they are useful.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
772
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
773 @table @code
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
774 @item installcheck
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
775 Perform installation tests (if any). The user must build and install
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
776 the program before running the tests. You should not assume that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
777 @file{$(bindir)} is in the search path.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
778
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
779 @item installdirs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
780 It's useful to add a target named @samp{installdirs} to create the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
781 directories where files are installed, and their parent directories.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
782 There is a script called @file{mkinstalldirs} which is convenient for
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
783 this; you can find it in the Texinfo package.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
784 @c It's in /gd/gnu/lib/mkinstalldirs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
785 You can use a rule like this:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
786
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
787 @comment This has been carefully formatted to look decent in the Make manual.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
788 @comment Please be sure not to make it extend any further to the right.--roland
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
789 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
790 # Make sure all installation directories (e.g. $(bindir))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
791 # actually exist by making them if necessary.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
792 installdirs: mkinstalldirs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
793 $(srcdir)/mkinstalldirs $(bindir) $(datadir) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
794 $(libdir) $(infodir) \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
795 $(mandir)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
796 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
797
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
798 This rule should not modify the directories where compilation is done.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
799 It should do nothing but create installation directories.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
800 @end table
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
801
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
802 @node Install Command Categories
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
803 @section Install Command Categories
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
804
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
805 @cindex pre-installation commands
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
806 @cindex post-installation commands
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
807 When writing the @code{install} target, you must classify all the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
808 commands into three categories: normal ones, @dfn{pre-installation}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
809 commands and @dfn{post-installation} commands.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
810
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
811 Normal commands move files into their proper places, and set their
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
812 modes. They may not alter any files except the ones that come entirely
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
813 from the package they belong to.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
814
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
815 Pre-installation and post-installation commands may alter other files;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
816 in particular, they can edit global configuration files or data bases.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
817
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
818 Pre-installation commands are typically executed before the normal
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
819 commands, and post-installation commands are typically run after the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
820 normal commands.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
821
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
822 The most common use for a post-installation command is to run
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
823 @code{install-info}. This cannot be done with a normal command, since
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
824 it alters a file (the Info directory) which does not come entirely and
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
825 solely from the package being installed. It is a post-installation
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
826 command because it needs to be done after the normal command which
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
827 installs the package's Info files.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
828
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
829 Most programs don't need any pre-installation commands, but we have the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
830 feature just in case it is needed.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
831
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
832 To classify the commands in the @code{install} rule into these three
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
833 categories, insert @dfn{category lines} among them. A category line
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
834 specifies the category for the commands that follow.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
835
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
836 A category line consists of a tab and a reference to a special Make
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
837 variable, plus an optional comment at the end. There are three
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
838 variables you can use, one for each category; the variable name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
839 specifies the category. Category lines are no-ops in ordinary execution
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
840 because these three Make variables are normally undefined (and you
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
841 @emph{should not} define them in the makefile).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
842
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
843 Here are the three possible category lines, each with a comment that
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
844 explains what it means:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
845
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
846 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
847 $(PRE_INSTALL) # @r{Pre-install commands follow.}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
848 $(POST_INSTALL) # @r{Post-install commands follow.}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
849 $(NORMAL_INSTALL) # @r{Normal commands follow.}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
850 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
851
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
852 If you don't use a category line at the beginning of the @code{install}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
853 rule, all the commands are classified as normal until the first category
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
854 line. If you don't use any category lines, all the commands are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
855 classified as normal.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
856
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
857 These are the category lines for @code{uninstall}:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
858
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
859 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
860 $(PRE_UNINSTALL) # @r{Pre-uninstall commands follow.}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
861 $(POST_UNINSTALL) # @r{Post-uninstall commands follow.}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
862 $(NORMAL_UNINSTALL) # @r{Normal commands follow.}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
863 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
864
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
865 Typically, a pre-uninstall command would be used for deleting entries
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
866 from the Info directory.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
867
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
868 If the @code{install} or @code{uninstall} target has any dependencies
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
869 which act as subroutines of installation, then you should start
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
870 @emph{each} dependency's commands with a category line, and start the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
871 main target's commands with a category line also. This way, you can
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
872 ensure that each command is placed in the right category regardless of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
873 which of the dependencies actually run.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
874
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
875 Pre-installation and post-installation commands should not run any
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
876 programs except for these:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
877
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
878 @example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
879 [ basename bash cat chgrp chmod chown cmp cp dd diff echo
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
880 egrep expand expr false fgrep find getopt grep gunzip gzip
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
881 hostname install install-info kill ldconfig ln ls md5sum
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
882 mkdir mkfifo mknod mv printenv pwd rm rmdir sed sort tee
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
883 test touch true uname xargs yes
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
884 @end example
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
885
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
886 @cindex binary packages
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
887 The reason for distinguishing the commands in this way is for the sake
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
888 of making binary packages. Typically a binary package contains all the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
889 executables and other files that need to be installed, and has its own
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
890 method of installing them---so it does not need to run the normal
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
891 installation commands. But installing the binary package does need to
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
892 execute the pre-installation and post-installation commands.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
893
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
894 Programs to build binary packages work by extracting the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
895 pre-installation and post-installation commands. Here is one way of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
896 extracting the pre-installation commands:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
897
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
898 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
899 make -n install -o all \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
900 PRE_INSTALL=pre-install \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
901 POST_INSTALL=post-install \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
902 NORMAL_INSTALL=normal-install \
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
903 | gawk -f pre-install.awk
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
904 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
905
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
906 @noindent
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
907 where the file @file{pre-install.awk} could contain this:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
908
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
909 @smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
910 $0 ~ /^\t[ \t]*(normal_install|post_install)[ \t]*$/ @{on = 0@}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
911 on @{print $0@}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
912 $0 ~ /^\t[ \t]*pre_install[ \t]*$/ @{on = 1@}
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
913 @end smallexample
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
914
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
915 The resulting file of pre-installation commands is executed as a shell
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
916 script as part of installing the binary package.