public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* How does make determine which shells to invoke when executing external commands?
@ 2013-06-05 15:32 Hua Ai
  2013-06-05 16:42 ` Warren Young
  0 siblings, 1 reply; 5+ messages in thread
From: Hua Ai @ 2013-06-05 15:32 UTC (permalink / raw)
  To: cygwin

Hi all,

I have gone through FAQ and mailing lists but couldn't find an answer
to this. I would appreciate it if someone could shed some lights on
this:

Basically I have a makefile that works in some computers but not
others. Through troubleshooting I think I have located the problem to
the lines below:

$(PREFIX)/include/cyg/hal/basetype.h:
$(REPOSITORY)/$(PACKAGE)/include/basetype.h
   @mkdir -p $(dir $@)
   @cp $< $@
   @chmod u+w $@

Especially, this line:

   @mkdir -p $(dir $@)

It seems that, for the computers where it didn't work, the makefile
always invokes the mkdir from windows (Windows 7 64bit). I know this
because I replaced the line above with "@mkdir aboslute_path" in the
make file, and find that it works if the absolute_path uses \ instead
of /.  If I leave -p in there, it would create a directory named "-p".

If I type in "mkdir -p aboslute_path" in cygwin bash shell instead of
running it from the makefile, it would support -p switch and forward
slash / in the path.

So it sounds like when make executes mkdir from a makefile, it invokes
windows command shell(?) to run mkdir. But if I add "which mkdir" in
the makefile, it returns "/usr/bin/mkdir", which is the same as if I
types "which mkdir" in the bash shell.

My questions are:

1. From what I described, do you think the make program invoked
windows command shell to execute mkdir? How to confirm that (or is it
apparent already)?
2. How can I make sure the make program consistently invokes bash
shell for executing mkdir from the makefile? (some computer
environment does this already, and others doesn't)

Thanks in advance!

Regards,
Hua

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How does make determine which shells to invoke when executing external commands?
  2013-06-05 15:32 How does make determine which shells to invoke when executing external commands? Hua Ai
@ 2013-06-05 16:42 ` Warren Young
  2013-06-06  2:43   ` Hua Ai
  0 siblings, 1 reply; 5+ messages in thread
From: Warren Young @ 2013-06-05 16:42 UTC (permalink / raw)
  To: Cygwin-L

On 6/5/2013 09:32, Hua Ai wrote:
>
> I have gone through FAQ and mailing lists but couldn't find an answer
> to this.

The answer is in the GNU make docs, or in the O'Reilly book if you prefer.

> Especially, this line:
>
>     @mkdir -p $(dir $@)
>
> It seems that, for the computers where it didn't work, the makefile
> always invokes the mkdir from windows (Windows 7 64bit).

That means those computers have a native Windows version of GNU make on 
them, most likely the one from MinGW.  MinGW GNU make is built to use 
cmd.exe to interpret shell commands, not /bin/sh as Cygwin's GNU make 
does by default.

The docs will further enlighten you about how the SHELL variable can 
override this default behavior.  I suspect "SHELL=/bin/sh" still won't 
do the right thing, though, since MinGW GNU make doesn't understand 
POSIX paths.  Something like SHELL=c:\cygwin\bin\sh.exe *might* work.

A superior solution is to get everyone to use Cygwin make.

If you can't do that, because you don't have any influence over the 
software installed on the other computers, you might have to switch to 
one of the portable Makefile builders, so you can ship both POSIX and 
MinGW makefiles.  Bakefile (http://bakefile.org/) can do this for sure. 
  CMake and Scons probably can, too.

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How does make determine which shells to invoke when executing external commands?
  2013-06-05 16:42 ` Warren Young
@ 2013-06-06  2:43   ` Hua Ai
  2013-06-06 10:35     ` Andrey Repin
  2013-06-06 16:25     ` Warren Young
  0 siblings, 2 replies; 5+ messages in thread
From: Hua Ai @ 2013-06-06  2:43 UTC (permalink / raw)
  To: cygwin

Hi Warren,

Thank you for your reply.

>
> The answer is in the GNU make docs, or in the O'Reilly book if you prefer.
>

Will check it out, I thought this is a cygwin issue since windows
commands were invoked.

>
> That means those computers have a native Windows version of GNU make on
> them, most likely the one from MinGW.  MinGW GNU make is built to use
> cmd.exe to interpret shell commands, not /bin/sh as Cygwin's GNU make does
> by default.

We don't have MinGW, but we do have multiple versions of a software
(development tools from Altera) installed on these computers, which
all contains a copy of cygwin (different versions but all with make).

This makefile however was run from a standalone cygwin.

I will do a little bit more digging tomorrow and come back with my
findings. More suggestions will be greatly appreciated.

Thanks,
Hua

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How does make determine which shells to invoke when executing external commands?
  2013-06-06  2:43   ` Hua Ai
@ 2013-06-06 10:35     ` Andrey Repin
  2013-06-06 16:25     ` Warren Young
  1 sibling, 0 replies; 5+ messages in thread
From: Andrey Repin @ 2013-06-06 10:35 UTC (permalink / raw)
  To: Hua Ai, cygwin

Greetings, Hua Ai!

> we do have multiple versions of a software (development tools from Altera)
> installed on these computers, which all contains a copy of cygwin
> (different versions but all with make).

This is, usually, a very, very, very, very-very bad idea.


--
WBR,
Andrey Repin (anrdaemon@freemail.ru) 06.06.2013, <14:22>

Sorry for my terrible english...


--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: How does make determine which shells to invoke when executing external commands?
  2013-06-06  2:43   ` Hua Ai
  2013-06-06 10:35     ` Andrey Repin
@ 2013-06-06 16:25     ` Warren Young
  1 sibling, 0 replies; 5+ messages in thread
From: Warren Young @ 2013-06-06 16:25 UTC (permalink / raw)
  To: Cygwin-L

On 6/5/2013 20:43, Hua Ai wrote:
> I thought this is a cygwin issue since windows
> commands were invoked.

Cygwin make should *always* be using /bin/sh to interpret commands, 
unless you've overridden it with SHELL.

Type this into a Makefile:

	all:
         	@echo Shell is $(SHELL)

Then say "make" in that directory.  It should confirm my assertion.

If it tells you something different on a problem machine, say "make 
--version" and verify that it says "Built for i686-pc-cygwin".

> We don't have MinGW, but we do have multiple versions of a software
> (development tools from Altera) installed on these computers, which
> all contains a copy of cygwin (different versions but all with make).

Are you *certain* Altera is shipping Cygwin GNU make and not MinGW make?

Either way, you're kind of in a bind.

If Altera is shipping MinGW GNU make, you have the conflict I originally 
proposed.

If they are in fact shipping Cygwin, you have this problem:

	http://www.cygwin.com/faq.html#faq.using.multiple-copies

(Items 4.19 through 4.23.)

> This makefile however was run from a standalone cygwin.

What does it say when you say "which make"?

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2013-06-06 16:25 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-05 15:32 How does make determine which shells to invoke when executing external commands? Hua Ai
2013-06-05 16:42 ` Warren Young
2013-06-06  2:43   ` Hua Ai
2013-06-06 10:35     ` Andrey Repin
2013-06-06 16:25     ` Warren Young

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).