[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bug in sub_proc.c: what to patch?
From: |
Alessandro Vesely |
Subject: |
Re: Bug in sub_proc.c: what to patch? |
Date: |
Sat, 18 Dec 2004 10:26:50 +0100 |
Earnie Boyd wrote:
>
> The make provided by MSYS is a copy of some version of source from Cygwin.
I use my own one, with equally good results.
> > BTW, what about a read-only variable reporting if the shell
> > is unixy? One could then write, e.g.
> >
> > $(if $(NOT_UNIX),if exist *.obj del *.obj,rm -f *.obj)
> >
>
> You mean a runtime environment variable?
yup
> Nothing that I would use as a portable method.
On Unix it would just be undefined
> The shell bit would need to be set at runtime.
yup
> Besides, I could have fileutils installed without a shell and use
> rm -f for RM anyway.
Having assumed that non-shell users are not required to have fileutils,
a portable makefile cannot take advantage of rm.exe being there.
> You should be sure to check the predefined variables such as RM,
> CC, etc and set those appropriately based on the runtime environment then
> use the variable in the command.
>
> <example>
> clean:
> $(RM) *.obj
> </example>
Hmmm... on Windows it should have been $(call RM,*.obj). In fact the del
command doesn't sport a -f option.
Another often used function is `$(subst /,\,$(1))', which one
needs to build non-unixy command lines with a path on any of
the runnable or the redirected file names. (Assuming that the
makefile always uses forward slashes internally.)
<example>
header_generator := $(SOMEDIR)/myfoo.exe
generated_header := $(INCDIR)/bar.h
$(generated_header): $(header_generator)
$(call slashed,$(header_generator)) > $(call
slashed,$(generated_header))
</example>
Also, if you cannot `test -d foo' you have to resort to testing
`if exist foo\*.*' (which only works on non-empty directories.)
Then, if one day a unixy sh.exe makes its way to a user's PATH,
rather than taking advantage of it, the makefile stops working,
vomiting failures that originate from incompatible command syntax.