[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#27188: lex/yacc with subdir-objects and --disable-dependency-trackin
bug#27188: lex/yacc with subdir-objects and --disable-dependency-tracking broken
Mon, 5 Jun 2017 19:16:56 -0400
On 6/4/17, Mathieu Lirzin <address@hidden> wrote:
> Nick Brown <address@hidden> writes:
>> diff --git a/lib/am/lex.am b/lib/am/lex.am
>> index d7ddc77..6357507 100644
>> --- a/lib/am/lex.am
>> +++ b/lib/am/lex.am
>> @@ -23,6 +23,7 @@ endif %?MAINTAINER-MODE%
>> ?!GENERIC?%OBJ%: %SOURCE%
>> +?SUBDIROBJ? %SILENT%test -d $(dir $@) || $(MKDIR_P) $(dir $@)
> I suspect the '$(dir ..)' syntax is not portable. Hopefully there
> should be a alternative. Can you look into it?
$(dir ...) is most definitely not portable. One alternative is to use
$(@D), which is specified in POSIX and essentially works in every make
implementation that I know of.
However, there are still portability gotchas. At least one implementation
(dmake) supports $(@D) in principle but expands it in a not-quite-POSIX-
POSIX says that the expansion of $(@D) (and similar variables) does not
include a trailing slash and expands to . for the current directory
(i.e., when the target name does not contain a slash).
In dmake, the expansion of $(@D) (and similar variables) for the current
directory is the empty string, otherwise the expansion contains a trailing
In cases where the difference matters, this can be worked around in the
shell easily enough. The difference matters if we adapt the above example
because mkdir with an empty string will fail. Something like this should
be pretty portable (untested):
test x"$(@D)" = x || $(MKDIR_P) "$(@D)"
Another way, perhaps even more portable, would be to do the splitting
entirely in the shell, e.g., by using expr.