[oi-dev] Libtool 2.4.2 and several questions (nvidia, build process)

Jim Klimov jimklimov at cos.ru
Sat Jul 27 20:39:22 UTC 2013


On 2013-07-27 22:27, Alexander Pyhalov wrote:
> 3) gmake clean fails on components/nvidia.
> Does someone have any idea why it needs this (
> https://github.com/OpenIndiana/oi-userland/blob/oi/hipster/components/nvidia/Makefile
> ):
>
> clean::
>      [ -d $(BUILD_DIR) ] && rm -rf $(BUILD_DIR)
>
> Shouldn't this be transformed just to
>
> clean::
>      rm -rf $(BUILD_DIR)

While IMHO this can be replaced, as long as "rm" on a missing target
does not return an error, note that gmake interprets the Makefile
line by line and passes each one to the shell separately. Thus any
non-zero returns are considered errors; in this case - if the dir
is missing, the test block would return non-zero. I had my share of
such trickery in a few Makefiles recently; one way to work around
is to use complete if blocks, along with backslashes to concatenate
multi-line commands like this:

clean:
	if [ -d $(BUILD_DIR) ]; then \
		rm -rf $(BUILD_DIR); \
	else true; fi

Overall result would be either return code of "rm" or of "true",
and result of the if-test itself won't pollute the logic.

Note that a "simple" solution like the following may be wrong:

clean:
	[ -d $(BUILD_DIR) ] && rm -rf $(BUILD_DIR) || true

I believe it would also return "true" if the "rm" step fails (i.e.
running on a read-only dataset/share).

HTH,
//Jim






More information about the oi-dev mailing list