7405 |
Prepend directory @var{dir} to the search path. This is used to include |
Prepend directory @var{dir} to the search path. This is used to include |
7406 |
the language-specific files before any third-party macros. |
the language-specific files before any third-party macros. |
7407 |
|
|
7408 |
|
@end table |
7409 |
|
|
7410 |
@cindex @file{autom4te.cfg} |
@cindex @file{autom4te.cfg} |
7411 |
As an example, if Autoconf is installed in its default location, |
As an example, if Autoconf is installed in its default location, |
7412 |
@file{/usr/local}, running @samp{autom4te -l m4sugar foo.m4} is |
@file{/usr/local}, running @samp{autom4te -l m4sugar foo.m4} is |
10221 |
@node Limitations of Make |
@node Limitations of Make |
10222 |
@section Limitations of Make |
@section Limitations of Make |
10223 |
|
|
10224 |
Make itself suffers a great number of limitations, only a few of which |
@command{make} itself suffers a great number of limitations, only a few |
10225 |
being listed here. First of all, remember that since commands are |
of which being listed here. First of all, remember that since commands |
10226 |
executed by the shell, all its weaknesses are inherited@enddots{} |
are executed by the shell, all its weaknesses are inherited@enddots{} |
10227 |
|
|
10228 |
@table @asis |
@table @asis |
10229 |
@item @code{$<} |
@item @code{$<} |
10230 |
@sc{posix} says that the @samp{$<} construct in makefiles can be used |
@sc{posix} says that the @samp{$<} construct in makefiles can be used |
10231 |
only in inference rules and in the @samp{.DEFAULT} rule; its meaning in |
only in inference rules and in the @samp{.DEFAULT} rule; its meaning in |
10232 |
ordinary rules is unspecified. Solaris 8's Make for instance |
ordinary rules is unspecified. Solaris 8's @command{make} for instance |
10233 |
will replace it with the argument. |
will replace it with the argument. |
10234 |
|
|
10235 |
@item Leading underscore in macro names |
@item Leading underscore in macro names |
10236 |
Some Makes don't support leading underscores in macro names, such as on |
Some @command{make}s don't support leading underscores in macro names, |
10237 |
NEWS-OS 4.2R. |
such as on NEWS-OS 4.2R. |
10238 |
|
|
10239 |
@example |
@example |
10240 |
$ @kbd{cat Makefile} |
$ @kbd{cat Makefile} |
10266 |
@end example |
@end example |
10267 |
|
|
10268 |
@noindent |
@noindent |
10269 |
shows @code{FOO} equal to @code{one BAR = two}. Other Makes sensibly |
shows @code{FOO} equal to @code{one BAR = two}. Other @command{make}s |
10270 |
let a backslash continue only to the immediately following line. |
sensibly let a backslash continue only to the immediately following |
10271 |
|
line. |
10272 |
|
|
10273 |
@item Escaped newline in comments |
@item Escaped newline in comments |
10274 |
|
|
10275 |
According to @sc{posix}, Makefile comments start with @code{#} and |
According to @sc{posix}, @file{Makefile} comments start with @code{#} |
10276 |
continue until an unescaped newline is reached. |
and continue until an unescaped newline is reached. |
10277 |
|
|
10278 |
@example |
@example |
10279 |
% @kbd{cat Makefile} |
% @kbd{cat Makefile} |
10311 |
@item @code{make macro=value} and sub-@command{make}s. |
@item @code{make macro=value} and sub-@command{make}s. |
10312 |
|
|
10313 |
A command-line variable definition such as @code{foo=bar} overrides any |
A command-line variable definition such as @code{foo=bar} overrides any |
10314 |
definition of @code{foo} in the @file{Makefile}. Some Make |
definition of @code{foo} in the @file{Makefile}. Some @command{make} |
10315 |
implementations (such as @sc{gnu} Make) will propagate this override to |
implementations (such as @sc{gnu} @command{make}) will propagate this |
10316 |
sub-invocations of @command{make}, this is allowed but not required by |
override to sub-invocations of @command{make}, this is allowed but not |
10317 |
@sc{posix}. |
required by @sc{posix}. |
10318 |
|
|
10319 |
@example |
@example |
10320 |
% @kbd{cat Makefile} |
% @kbd{cat Makefile} |
10371 |
you do that. |
you do that. |
10372 |
|
|
10373 |
@item The @code{SHELL} macro |
@item The @code{SHELL} macro |
10374 |
@cindex @code{SHELL} and Make |
@cindex @code{SHELL} and @command{make} |
10375 |
@cindex Make and @code{SHELL} |
@cindex @command{make} and @code{SHELL} |
10376 |
|
|
10377 |
POSIX Makes internally use the @code{$(SHELL)} macro to spawn shell |
@sc{posix}-compliant @command{make}s internally use the @code{$(SHELL)} |
10378 |
processes and execute @file{Makefile} rules. This is a built-in |
macro to spawn shell processes and execute @file{Makefile} rules. This |
10379 |
macro supplied by Make, but it can be modified from the Makefile or a |
is a built-in macro supplied by @command{make}, but it can be modified |
10380 |
command-line argument. |
from the @file{Makefile} or a command-line argument. |
10381 |
|
|
10382 |
Not all Makes will define this @code{SHELL} macro. OSF/Tru64 Make is |
Not all @command{make}s will define this @code{SHELL} macro. OSF/Tru64 |
10383 |
an example; this implementation will always use @code{/bin/sh}. So it's |
@command{make} is an example; this implementation will always use |
10384 |
a good idea to always define @code{SHELL} in your @file{Makefile}s. If |
@code{/bin/sh}. So it's a good idea to always define @code{SHELL} in |
10385 |
you use Autoconf, do |
your @file{Makefile}s. If you use Autoconf, do |
10386 |
|
|
10387 |
@example |
@example |
10388 |
SHELL = @@SHELL@@ |
SHELL = @@SHELL@@ |
10389 |
@end example |
@end example |
10390 |
|
|
10391 |
@sc{posix}-compliant makes should never acquire the value of $(SHELL) |
@sc{posix}-compliant @command{make}s should never acquire the value of |
10392 |
from the environment, even when @code{make -e} is used (otherwise, think |
$(SHELL) from the environment, even when @code{make -e} is used |
10393 |
about what would happen to your rules if @code{SHELL=/bin/tcsh}). |
(otherwise, think about what would happen to your rules if |
10394 |
|
@code{SHELL=/bin/tcsh}). |
10395 |
|
|
10396 |
However not all Make implementations will make this exception. |
However not all @command{make} implementations will make this exception. |
10397 |
For instance it's not surprising that OSF/Tru64 Make doesn't |
For instance it's not surprising that OSF/Tru64 @command{make} doesn't |
10398 |
protect @code{SHELL}, since it doesn't use it. |
protect @code{SHELL}, since it doesn't use it. |
10399 |
|
|
10400 |
@example |
@example |
10418 |
|
|
10419 |
Never put comments in a rule. |
Never put comments in a rule. |
10420 |
|
|
10421 |
Some Makes treat anything starting with a tab as a command for the |
Some @command{make} treat anything starting with a tab as a command for |
10422 |
current rule, even if the tab is immediately followed by a @code{#}. |
the current rule, even if the tab is immediately followed by a @code{#}. |
10423 |
The Make from Tru64 Unix V5.1 is one of them. The following |
The @command{make} from Tru64 Unix V5.1 is one of them. The following |
10424 |
@file{Makefile} will run @code{# foo} through the shell. |
@file{Makefile} will run @code{# foo} through the shell. |
10425 |
|
|
10426 |
@example |
@example |
10430 |
|
|
10431 |
@item The @file{obj/} subdirectory. |
@item The @file{obj/} subdirectory. |
10432 |
@cindex @file{obj/}, subdirectory |
@cindex @file{obj/}, subdirectory |
10433 |
@cindex BSD make and @file{obj/} |
@cindex BSD @command{make} and @file{obj/} |
10434 |
|
|
10435 |
Never name one of your subdirectories @file{obj/} if you don't like |
Never name one of your subdirectories @file{obj/} if you don't like |
10436 |
surprises. |
surprises. |
10437 |
|
|
10438 |
If an @file{obj/} directory exists, BSD make will enter it |
If an @file{obj/} directory exists, BSD @command{make} will enter it |
10439 |
before reading @file{Makefile}. Hence the @file{Makefile} in the |
before reading @file{Makefile}. Hence the @file{Makefile} in the |
10440 |
current directory will not be read. |
current directory will not be read. |
10441 |
|
|
10478 |
@item @code{VPATH} |
@item @code{VPATH} |
10479 |
@cindex @code{VPATH} |
@cindex @code{VPATH} |
10480 |
|
|
10481 |
There is no @code{VPATH} support specified in @sc{posix}. Many Makes |
There is no @code{VPATH} support specified in @sc{posix}. Many |
10482 |
have a form of @code{VPATH} support, but its implementation is not |
@command{make}s have a form of @code{VPATH} support, but its |
10483 |
consistent amongst Makes. |
implementation is not consistent amongst @command{make}s. |
10484 |
|
|
10485 |
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} |
10486 |
feature is to choose a Make implementation and stick to it. Since the |
feature is to choose a @command{make} implementation and stick to it. |
10487 |
resulting @file{Makefile}s are not portable anyway, better choose a |
Since the resulting @file{Makefile}s are not portable anyway, better |
10488 |
portable Make (hint, hint). |
choose a portable @command{make} (hint, hint). |
10489 |
|
|
10490 |
Here are a couple of known issues with some @code{VPATH} |
Here are a couple of known issues with some @code{VPATH} |
10491 |
implementations. |
implementations. |
10495 |
@item @code{VPATH} and double-colon rules |
@item @code{VPATH} and double-colon rules |
10496 |
@cindex @code{VPATH} and double-colon rules |
@cindex @code{VPATH} and double-colon rules |
10497 |
@cindex double-colon rules and @code{VPATH} |
@cindex double-colon rules and @code{VPATH} |
10498 |
Any assignment to @code{VPATH} causes Sun Make to only execute the first |
|
10499 |
set of double-colon rules. (This comment has been here since 1994 and |
Any assignment to @code{VPATH} causes Sun @command{make} to only execute |
10500 |
the context has been lost. It's probably about SunOS 4. If you can |
the first set of double-colon rules. (This comment has been here since |
10501 |
reproduce this, please send us a test case for illustration.) |
1994 and the context has been lost. It's probably about SunOS 4. If |
10502 |
|
you can reproduce this, please send us a test case for illustration.) |
10503 |
|
|
10504 |
@item @code{$<} in inference rules: |
@item @code{$<} in inference rules: |
10505 |
@cindex suffix rules, @code{$<}, and @code{VPATH} |
@cindex suffix rules, @code{$<}, and @code{VPATH} |
10506 |
@cindex @code{$<}, inference rules, and @code{VPATH} |
@cindex @code{$<}, inference rules, and @code{VPATH} |
10507 |
@cindex @code{VPATH}, inference rules, and @code{$<} |
@cindex @code{VPATH}, inference rules, and @code{$<} |
10508 |
An implementation of make would not prefix @code{$<} if this |
An implementation of @command{make} would not prefix @code{$<} if this |
10509 |
prerequisite has been found in a @code{VPATH} dir. This means that |
prerequisite has been found in a @code{VPATH} dir. This means that |
10510 |
|
|
10511 |
@example |
@example |
10527 |
@end example |
@end example |
10528 |
|
|
10529 |
This kludge was introduced in Automake in 2000, but the exact context |
This kludge was introduced in Automake in 2000, but the exact context |
10530 |
have been lost. If you know which make implementation is involved here, |
have been lost. If you know which @command{make} implementation is |
10531 |
please drop us a note. |
involved here, please drop us a note. |
10532 |
|
|
10533 |
|
|
10534 |
@item @code{$<} not supported in explicit rules |
@item @code{$<} not supported in explicit rules |
10551 |
@cindex @code{VPATH} and automatic rule rewriting |
@cindex @code{VPATH} and automatic rule rewriting |
10552 |
@cindex automatic rule rewriting and @code{VPATH} |
@cindex automatic rule rewriting and @code{VPATH} |
10553 |
|
|
10554 |
Some Make implementations, such as SunOS Make, will |
Some @command{make} implementations, such as SunOS @command{make}, will |
10555 |
search prerequisites in @code{VPATH} and rewrite all their occurrences in |
search prerequisites in @code{VPATH} and rewrite all their occurrences |
10556 |
the rule appropriately. |
in the rule appropriately. |
10557 |
|
|
10558 |
For instance |
For instance |
10559 |
|
|
10567 |
would execute @code{cc -c ../src/foo.c -o foo.o} if @file{foo.c} was |
would execute @code{cc -c ../src/foo.c -o foo.o} if @file{foo.c} was |
10568 |
found in @file{../src}. That sounds great. |
found in @file{../src}. That sounds great. |
10569 |
|
|
10570 |
However, for the sake of other Make implementations, we can't |
However, for the sake of other @command{make} implementations, we can't |
10571 |
rely on this, and we have to search @code{VPATH} manually: |
rely on this, and we have to search @code{VPATH} manually: |
10572 |
|
|
10573 |
@example |
@example |
10578 |
|
|
10579 |
@noindent |
@noindent |
10580 |
However the "prerequisite rewriting" still applies here. So if |
However the "prerequisite rewriting" still applies here. So if |
10581 |
@file{foo.c} is in @file{../src}, SunOS Make will execute |
@file{foo.c} is in @file{../src}, SunOS @command{make} will execute |
10582 |
|
|
10583 |
@example |
@example |
10584 |
@code{cc -c `test -f ../src/foo.c || echo ../src/`foo.c -o foo.o} |
@code{cc -c `test -f ../src/foo.c || echo ../src/`foo.c -o foo.o} |
10680 |
@end example |
@end example |
10681 |
|
|
10682 |
|
|
10683 |
@item OSF/Tru64 make creates prerequisite directories magically |
@item OSF/Tru64 @command{make} creates prerequisite directories magically |
10684 |
@cindex @code{VPATH} and prerequisite directories |
@cindex @code{VPATH} and prerequisite directories |
10685 |
@cindex prerequisite directories and @code{VPATH} |
@cindex prerequisite directories and @code{VPATH} |
10686 |
|
|
10687 |
When a prerequisite is a sub-directory of @code{VPATH}, Tru64 |
When a prerequisite is a sub-directory of @code{VPATH}, Tru64 |
10688 |
Make will create it in the current directory. |
@command{make} will create it in the current directory. |
10689 |
|
|
10690 |
@example |
@example |
10691 |
% @kbd{mkdir -p foo/bar build} |
% @kbd{mkdir -p foo/bar build} |
10711 |
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} |
10712 |
directory that was created in the current directory. |
directory that was created in the current directory. |
10713 |
|
|
10714 |
|
@item target lookup |
10715 |
|
@cindex @code{VPATH}, resolving target pathnames |
10716 |
|
|
10717 |
|
GNU @command{make} uses a rather complex algorithm to decide when it |
10718 |
|
should use files found via a @code{VPATH} search. @xref{Search |
10719 |
|
Algorithm,, How Directory Searches are Performed, make, The GNU Make |
10720 |
|
Manual}. |
10721 |
|
|
10722 |
|
If a target needs to be rebuilt, GNU @command{make} discards the |
10723 |
|
filename found during the @code{VPATH} search for this target, and |
10724 |
|
builds the file locally using the filename given in the @file{Makefile}. |
10725 |
|
If a target does not need to be rebuilt, GNU @command{make} uses the |
10726 |
|
filename found during the @code{VPATH} search. |
10727 |
|
|
10728 |
|
Other @command{make} implementations, like BSD @command{make}, are |
10729 |
|
easier to describe: the filename found during the @code{VPATH} search |
10730 |
|
will be used whether the target needs to be rebuilt or not. Therefore |
10731 |
|
new files are created locally, but existing files are updated at their |
10732 |
|
@code{VPATH} location. |
10733 |
|
|
10734 |
|
When attempting a @code{VPATH} build for an autoconfiscated package |
10735 |
|
(e.g, @code{mkdir build; ../configure}), this means the GNU |
10736 |
|
@command{make} will build everything locally in the @file{build} |
10737 |
|
directory, while BSD @command{make} will build new files locally and |
10738 |
|
update existing files in the source directory. |
10739 |
|
|
10740 |
|
@example |
10741 |
|
% @kbd{cat Makefile} |
10742 |
|
VPATH = .. |
10743 |
|
all: foo.x bar.x |
10744 |
|
foo.x bar.x: newer.x |
10745 |
|
@@echo Building $@@ |
10746 |
|
% @kbd{touch ../bar.x} |
10747 |
|
% @kbd{touch ../newer.x} |
10748 |
|
% @kbd{make} # GNU make |
10749 |
|
Building foo.x |
10750 |
|
Building bar.x |
10751 |
|
% @kbd{pmake} # BSD make |
10752 |
|
Building foo.x |
10753 |
|
Building ../bar.x |
10754 |
|
@end example |
10755 |
|
|
10756 |
|
Another point worth mentioning is that once GNU @command{make} has |
10757 |
|
decided to ignore a @code{VPATH} filename (e.g. it ignored |
10758 |
|
@file{../bar.x} in the above example) it will continue to ignore it when |
10759 |
|
the target occurs as a prerequisite of another rule. |
10760 |
|
|
10761 |
|
The following example shows that GNU @command{make} does not look up |
10762 |
|
@file{bar.x} in @code{VPATH} before performing the @code{.x.y} rule, |
10763 |
|
because it ignored the @code{VPATH} result of @file{bar.x} while running |
10764 |
|
the @code{bar.x: newer.x} rule. |
10765 |
|
|
10766 |
|
@example |
10767 |
|
% @kbd{cat Makefile} |
10768 |
|
VPATH = .. |
10769 |
|
all: bar.y |
10770 |
|
bar.x: newer.x |
10771 |
|
@@echo Building $@@ |
10772 |
|
.SUFFIXES: .x .y |
10773 |
|
.x.y: |
10774 |
|
cp $< $@@ |
10775 |
|
% @kbd{touch ../bar.x} |
10776 |
|
% @kbd{touch ../newer.x} |
10777 |
|
% @kbd{make} # GNU make |
10778 |
|
Building bar.x |
10779 |
|
cp bar.x bar.y |
10780 |
|
cp: cannot stat `bar.x': No such file or directory |
10781 |
|
make: *** [bar.y] Error 1 |
10782 |
|
% @kbd{pmake} # BSD make |
10783 |
|
Building ../bar.x |
10784 |
|
cp ../bar.x bar.y |
10785 |
|
@end example |
10786 |
|
|
10787 |
|
Note that if you drop away the command from the @code{bar.x: newer.x} |
10788 |
|
rule, things will magically start to work: GNU @command{make} knows that |
10789 |
|
@code{bar.x} hasn't been updated, therefore it doesn't discard the |
10790 |
|
result from @code{VPATH} (@file{../bar.x}) in succeeding uses. |
10791 |
|
|
10792 |
|
@example |
10793 |
|
% @kbd{cat Makefile} |
10794 |
|
VPATH = .. |
10795 |
|
all: bar.y |
10796 |
|
bar.x: newer.x |
10797 |
|
.SUFFIXES: .x .y |
10798 |
|
.x.y: |
10799 |
|
cp $< $@@ |
10800 |
|
% @kbd{touch ../bar.x} |
10801 |
|
% @kbd{touch ../newer.x} |
10802 |
|
% @kbd{make} # GNU make |
10803 |
|
cp ../bar.x bar.y |
10804 |
|
% @kbd{rm bar.y} |
10805 |
|
% @kbd{pmake} # BSD make |
10806 |
|
cp ../bar.x bar.y |
10807 |
|
@end example |
10808 |
|
|
10809 |
@end table |
@end table |
10810 |
@end table |
@end table |
10811 |
|
|