9943 |
will replace it with the argument. |
will replace it with the argument. |
9944 |
|
|
9945 |
@item Leading underscore in macro names |
@item Leading underscore in macro names |
9946 |
Some Make don't support leading underscores in macro names, such as on |
Some Makes don't support leading underscores in macro names, such as on |
9947 |
NEWS-OS 4.2R. |
NEWS-OS 4.2R. |
9948 |
|
|
9949 |
@example |
@example |
9963 |
|
|
9964 |
@item @code{make macro=value} and sub-@command{make}s. |
@item @code{make macro=value} and sub-@command{make}s. |
9965 |
|
|
9966 |
A command argument definition such as @code{foo=bar} overrides any foo |
A command-line variable definition such as @code{foo=bar} overrides any |
9967 |
definition in the Makefile. Some Make implementations (such as @sc{gnu} |
definition of @code{foo} in the @file{Makefile}. Some Make |
9968 |
Make) will propagate this override to sub-invocations of @command{make}, |
implementations (such as @sc{gnu} Make) will propagate this override to |
9969 |
but @sc{posix} conformant implementations won't. |
sub-invocations of @command{make}, this is allowed but not required by |
9970 |
|
@sc{posix}. |
9971 |
|
|
9972 |
@example |
@example |
9973 |
% @kbd{cat Makefile} |
% @kbd{cat Makefile} |
10001 |
|
|
10002 |
The @code{-e} option is propagated to sub-@command{make}s automatically, |
The @code{-e} option is propagated to sub-@command{make}s automatically, |
10003 |
and since the environment is inherited between @command{make} |
and since the environment is inherited between @command{make} |
10004 |
invocations the @code{foo} macro will be overridden in |
invocations, the @code{foo} macro will be overridden in |
10005 |
sub-@code{make}s as expected. |
sub-@code{make}s as expected. |
10006 |
|
|
10007 |
Using @code{-e} could have unexpected side-effects if your environment |
Using @code{-e} could have unexpected side-effects if your environment |
10030 |
POSIX Makes internally use the @code{$(SHELL)} macro to spawn shell |
POSIX Makes internally use the @code{$(SHELL)} macro to spawn shell |
10031 |
processes and execute @file{Makefile} rules. This is a built-in |
processes and execute @file{Makefile} rules. This is a built-in |
10032 |
macro supplied by Make, but it can be modified from the Makefile or a |
macro supplied by Make, but it can be modified from the Makefile or a |
10033 |
command line argument. |
command-line argument. |
10034 |
|
|
10035 |
Not all Makes will define this @code{SHELL} macro. OSF/Tru64 Make is |
Not all Makes will define this @code{SHELL} macro. OSF/Tru64 Make is |
10036 |
an example, this implementation will always use @code{/bin/sh}. So it's |
an example; this implementation will always use @code{/bin/sh}. So it's |
10037 |
a good idea to always define @code{SHELL} in your @file{Makefile}s. If |
a good idea to always define @code{SHELL} in your @file{Makefile}s. If |
10038 |
you use Autoconf, do |
you use Autoconf, do |
10039 |
|
|
10041 |
SHELL = @@SHELL@@ |
SHELL = @@SHELL@@ |
10042 |
@end example |
@end example |
10043 |
|
|
10044 |
@sc{posix} compliant makes should never acquire the value of $(SHELL) |
@sc{posix}-compliant makes should never acquire the value of $(SHELL) |
10045 |
from the environment, even when @code{make -e} is used (otherwise, think |
from the environment, even when @code{make -e} is used (otherwise, think |
10046 |
about what would happen to your rules if @code{SHELL=/bin/tcsh}). |
about what would happen to your rules if @code{SHELL=/bin/tcsh}). |
10047 |
|
|
10064 |
bar |
bar |
10065 |
@end example |
@end example |
10066 |
|
|
10067 |
|
@item Comments in rules |
10068 |
|
@cindex Comments in @file{Makefile} rules |
10069 |
|
@cindex @file{Makefile} rules and comments |
10070 |
|
|
10071 |
|
Never put comments in a rule. |
10072 |
|
|
10073 |
|
Some Makes treat anything starting with a tab as a command for the |
10074 |
|
current rule, even if the tab is immediately followed by a @code{#}. |
10075 |
|
The Make from Tru64 Unix V5.1 is one of them. The following |
10076 |
|
@file{Makefile} will run @code{# foo} through the shell. |
10077 |
|
|
10078 |
|
@example |
10079 |
|
all: |
10080 |
|
# foo |
10081 |
|
@end example |
10082 |
|
|
10083 |
|
|
10084 |
@item @code{VPATH} |
@item @code{VPATH} |
10085 |
@cindex @code{VPATH} |
@cindex @code{VPATH} |
10086 |
|
|
10090 |
|
|
10091 |
Maybe the best suggestion to give to people who need the @code{VPATH} |
Maybe the best suggestion to give to people who need the @code{VPATH} |
10092 |
feature is to choose a Make implementation and stick to it. Since the |
feature is to choose a Make implementation and stick to it. Since the |
10093 |
resulting @file{Makefile}s are not portable anyway, better chose a |
resulting @file{Makefile}s are not portable anyway, better choose a |
10094 |
portable Make (hint, hint). |
portable Make (hint, hint). |
10095 |
|
|
10096 |
Here are a couple of known issues with some @code{VPATH} |
Here are a couple of known issues with some @code{VPATH} |
10102 |
@cindex @code{VPATH} and double-colon rules |
@cindex @code{VPATH} and double-colon rules |
10103 |
@cindex double-colon rules and @code{VPATH} |
@cindex double-colon rules and @code{VPATH} |
10104 |
Any assignment to @code{VPATH} causes Sun Make to only execute the first |
Any assignment to @code{VPATH} causes Sun Make to only execute the first |
10105 |
set of double-colon rules. (This comments has been here since 1994 and the |
set of double-colon rules. (This comment has been here since 1994 and |
10106 |
context has been lost. It's probably about SunOS 4. If you can |
the context has been lost. It's probably about SunOS 4. If you can |
10107 |
reproduce this, please send us a testcase for illustration.) |
reproduce this, please send us a test case for illustration.) |
10108 |
|
|
10109 |
@item @code{$<} in inference rules: |
@item @code{$<} in inference rules: |
10110 |
@cindex suffix rules, @code{$<}, and @code{VPATH} |
@cindex suffix rules, @code{$<}, and @code{VPATH} |
10132 |
@end example |
@end example |
10133 |
|
|
10134 |
This kludge was introduced in Automake in 2000, but the exact context |
This kludge was introduced in Automake in 2000, but the exact context |
10135 |
have has lost. If you know which make implementation is involved here, |
have been lost. If you know which make implementation is involved here, |
10136 |
please drop us a note. |
please drop us a note. |
10137 |
|
|
10138 |
|
|
10142 |
@cindex @code{VPATH}, explicit rules, and @code{$<} |
@cindex @code{VPATH}, explicit rules, and @code{$<} |
10143 |
|
|
10144 |
As said elsewhere, using @code{$<} in explicit rules is not portable. |
As said elsewhere, using @code{$<} in explicit rules is not portable. |
10145 |
You have to perform a @code{VPATH} search manually. For instance, using |
The prerequisite file must be named explicitly in the rule. If you want |
10146 |
the same pattern as above: |
to find the prerequisite via a @code{VPATH} search, you have to code the |
10147 |
|
whole thing manually. For instance, using the same pattern as above: |
10148 |
|
|
10149 |
@example |
@example |
10150 |
VPATH = ../src |
VPATH = ../src |
10225 |
@end example |
@end example |
10226 |
|
|
10227 |
The above @code{install-HEADERS} rule is not sun-proof because @code{for |
The above @code{install-HEADERS} rule is not sun-proof because @code{for |
10228 |
i in $(HEADERS);} will expanded as @code{for i in foo.h foo2.h foo3.h;} |
i in $(HEADERS);} will be expanded as @code{for i in foo.h foo2.h foo3.h;} |
10229 |
where @code{foo.h} and @code{foo2.h} are plain words and are hence |
where @code{foo.h} and @code{foo2.h} are plain words and are hence |
10230 |
subject to @code{VPATH} adjustments. |
subject to @code{VPATH} adjustments. |
10231 |
|
|
10232 |
If the three files are in @file{../src}, the rule is run as |
If the three files are in @file{../src}, the rule is run as: |
10233 |
|
|
10234 |
@example |
@example |
10235 |
for i in ../src/foo.h ../src/foo2.h foo3.h; do \ |
for i in ../src/foo.h ../src/foo2.h foo3.h; do \ |
10238 |
done |
done |
10239 |
@end example |
@end example |
10240 |
|
|
10241 |
where the two first @command{install} calls will fails. For instance, |
where the two first @command{install} calls will fail. For instance, |
10242 |
consider the @code{foo.h} installation: |
consider the @code{foo.h} installation: |
10243 |
|
|
10244 |
@example |
@example |
10245 |
install -m 644 `test -f ../src/foo.h || echo ../src/`../src/foo.h \ |
install -m 644 `test -f ../src/foo.h || echo ../src/`../src/foo.h \ |
10246 |
/usr/local/inclue/../src/foo.h; |
/usr/local/include/../src/foo.h; |
10247 |
@end example |
@end example |
10248 |
@noindent |
@noindent |
10249 |
It reduces to: |
It reduces to: |
10252 |
install -m 644 ../src/foo.h /usr/local/include/../src/foo.h; |
install -m 644 ../src/foo.h /usr/local/include/../src/foo.h; |
10253 |
@end example |
@end example |
10254 |
|
|
10255 |
Note that the manual @code{VPATH} search did not cause any problem here; |
Note that the manual @code{VPATH} search did not cause any problems here; |
10256 |
however this command fails to install @file{foo.h} in the correct |
however this command installs @file{foo.h} in an incorrect directory. |
|
directory. |
|
10257 |
|
|
10258 |
Trying to quote @code{$(HEADERS)} in some way, like we did for |
Trying to quote @code{$(HEADERS)} in some way, as we did for |
10259 |
@code{foo.c} a few @file{Makefile}s ago, does not help: |
@code{foo.c} a few @file{Makefile}s ago, does not help: |
10260 |
|
|
10261 |
@example |
@example |
10268 |
|
|
10269 |
Indeed, @code{headers='$(HEADERS)'} expands to @code{headers='foo.h |
Indeed, @code{headers='$(HEADERS)'} expands to @code{headers='foo.h |
10270 |
foo2.h foo3.h'} where @code{foo2.h} is still a plain word. (Aside: the |
foo2.h foo3.h'} where @code{foo2.h} is still a plain word. (Aside: the |
10271 |
@code{headers='$(HEADERS)'; for i in $$headers;} idiom is this a good |
@code{headers='$(HEADERS)'; for i in $$headers;} idiom is a good |
10272 |
idea if @code{$(HEADERS)} can be empty, because some shell produce a |
idea if @code{$(HEADERS)} can be empty, because some shell produce a |
10273 |
syntax error on @code{for i in;}.) |
syntax error on @code{for i in;}.) |
10274 |
|
|
10314 |
@end example |
@end example |
10315 |
|
|
10316 |
The above @command{command} will be run on the empty @file{foo/bar} |
The above @command{command} will be run on the empty @file{foo/bar} |
10317 |
directory created in the current directory. |
directory that was created in the current directory. |
10318 |
|
|
10319 |
@end table |
@end table |
10320 |
@end table |
@end table |