3 msub \- substitute \fImake\fR variables into template to produce script
22 Makefiles often contain project configuration information specified as
24 variables, and it is often desirable to make use of that information in other
27 allows targets to be produced easily
28 from templates that contain references to those variables.
30 is particularly useful in software projects that use
32 because virtually all configuration parameters are written into Makefiles
33 and are thus available for propagation into other files.
39 and finds all variable definition lines
40 of the form ``\fIvar\fR = \fIvalue\fR''.
43 reads any files named on the command line (or the standard input
44 if none), looks for references to those variables, and replaces the
45 references with the corresponding variable values.
46 References to undefined variables are replaced by the empty string.
47 The result is written to the standard output.
50 takes the following options:
53 Environment variable values override assignments within Makefiles.
54 Normally assignments within Makefiles override environment variables.
57 By default, variable values are extracted from
63 is missing) in the current directory.
67 option is given, variable values are extracted from
72 options may be specified.
82 doesn't, because template input may come from
88 The default variable reference indicators within templates
89 are the same as in Makefiles, i.e.,
90 ``$('' and ``)'', and ``${'' and ``}''.
91 These can be changed with the
95 options, which must be specified in pairs.
97 specifies the string that initiates a variable reference and
99 specifies the string that terminates it.
100 Multiple pairs of reference indicators may be given.
104 This definition overrides any regular definition for the specified
105 variable within the makefile itself or in the environment.
107 Suppose you want to produce for a program a help file that indicates the local
108 e-mail address to which questions may be directed.
109 If this address is specified as the variable EMAILHELPADDR in the
111 you can write a template
117 \&.\|.\|.\|\fIstuff\fP\|.\|.\|.
118 Please direct questions to ${EMAILHELPADDR}.
119 \&.\|.\|.\|\fImore stuff\fP\|.\|.\|.
123 Process the template to produce the help file like this:
127 msub helpfile.msub > helpfile
133 contains the following lines:
137 EMAILHELPADDR = postmaster@$(DOMAIN)
138 DOMAIN = primate.wisc.edu
148 \&.\|.\|.\|\fIstuff\fP\|.\|.\|.
149 Please direct questions to postmaster@primate.wisc.edu.
150 \&.\|.\|.\|\fImore stuff\fP\|.\|.\|.
155 can produce executable scripts, too.
156 If the processor for which you're producing
157 the script allows variable references, make sure you refer to
159 variables in the template in a different way than the processor refers to
161 For instance, ``${\fIvar\fP}'' is ambiguous in a shell script template \- is
162 it a reference to a shell variable that you want
164 to leave alone, or to a
166 variable for which you want
168 to substitute the variable's value?
169 To resolve the ambiguity, you can refer to shell variables as ``$\fIvar\fP''
170 (which the shell recognizes, but
172 doesn't), or you can use different indicators than the defaults to refer to
174 variables in the template.
175 For example, you could use ``@<'' and ``>@'' and refer to variables as
177 Suppose you have a simple shell script to print your home directory pathname.
178 You might write it like this:
187 Then you can process the template like this (note that you must quote the
188 arguments because ``<'' and ``>'' are special to the shell):
192 msub +R"@<" \-R">@" template > script
200 to recognize ``@<SHELL>@'' but not ``${HOME}''.
201 The result looks like this:
211 Paul DuBois, dubois@primate.wisc.edu
212 .SH "BUGS AND RESTRICTIONS"
213 CC, YACC, etc., have implicit values in
215 even if they're not defined in the
223 this isn't normally a problem since
225 Makefiles tend to contain explicit definitions for every parameter in the
229 is more restrictive in the variable names it recognizes and
230 performs substitutions on than
233 allows single character names to be referenced as ``$\fIc\fP'', where
244 Recursive references in
246 variables aren't expanded.
249 contains the definition ``X = ${X}'', X won't be expanded.
250 Indirectly recursive references aren't expanded, either.
253 contains the definitions ``X = ${Y}'' and ``Y = ${X}'',
254 neither X nor Y will be expanded.
255 (These actually aren't bugs in
257 they're problems in the
260 A comment at the end of a variable assignment line become part of the
264 contains the following line:
268 SHELL = /bin/shell # default shell
274 takes the value of SHELL to be ``/bin/shell # default shell''.