On 6/4/17, Mathieu Lirzin <m...@gnu.org> wrote: > Nick Brown <bro...@brocade.com> 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?%EXT%%DERIVED-EXT%: >> ?!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- compliant way. 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 slash. 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. Cheers, Nick