public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* weird behavior regarding case sensitivity of GNU make's $(wildcard) function
@ 2010-07-06 13:41 Robert Schiele
  2010-07-06 15:32 ` Corinna Vinschen
  0 siblings, 1 reply; 3+ messages in thread
From: Robert Schiele @ 2010-07-06 13:41 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 2013 bytes --]

Hi!

I found the following (in my optinion weird) behavior of the $(wildcard)
function of GNU make when running on Cygwin:

I have a place in a makefile that checks for existence of a file (let's call
it "/cygdrive/c/path/to/file") with $(wildcard /cygdrive/c/path/to/file).
Unfortunately the vendor of this file refers to this file with different case
letters than it is materialized on disk.  On the disk the file is actually
stored as "C:\Path\to\File" which translates to the Cygwin style name
"/cygdrive/c/Path/to/File".  Since Windows is supposed to be case-insensitive
this should be fine but in Cygwin's GNU make binary (current version as of
today) I observed the following behavior:

1. "$(wildcard /cygdrive/c/path/to/file)" does not match anything and thus
   returns an empty string.

2. "$(wildcard /cygdrive/c/Path/to/File)" does match the file and thus returns
   "/cygdrive/c/Path/to/File" as expected.

3. "$(wildcard /cygdrive/c/Path/to/file)" does not match anything and thus
   returns an empty string.

4. "$(wildcard /cygdrive/c/path/to/File)" does match the file and thus returns
   "/cygdrive/c/path/to/File".

More generic inspection reveals that apparently the $(wildcard) function seems
to be case-insensitive on the directory part but case-sensitive on the file
name part of the absolute path given.

Is this kind of expected behavior or does this point to a bug in the GNU make
implementation (or even further down in a Cygwin library)?

Does anyone know of a reasonable workaround?  Is there a way to make the
$(wildcard) function case-insensitive completely (like by setting a special
option of flag)?  Or is there probably a better replacement function that does
basically the same but in a case-insensitive way?

If this doesn't work is there probably some function that converts filename
strings to a representation that is exactly how a file is stored on the disk,
i.e. I give it "/cygdrive/c/path/to/file" and it returns
"/cygdrive/c/Path/to/File"?

Any better ideas?

Robert

[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]

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

* Re: weird behavior regarding case sensitivity of GNU make's $(wildcard) function
  2010-07-06 13:41 weird behavior regarding case sensitivity of GNU make's $(wildcard) function Robert Schiele
@ 2010-07-06 15:32 ` Corinna Vinschen
  2010-07-14  8:54   ` Csaba Raduly
  0 siblings, 1 reply; 3+ messages in thread
From: Corinna Vinschen @ 2010-07-06 15:32 UTC (permalink / raw)
  To: cygwin

On Jul  6 14:11, Robert Schiele wrote:
> Hi!
> 
> I found the following (in my optinion weird) behavior of the $(wildcard)
> function of GNU make when running on Cygwin:
> 
> I have a place in a makefile that checks for existence of a file (let's call
> it "/cygdrive/c/path/to/file") with $(wildcard /cygdrive/c/path/to/file).
> Unfortunately the vendor of this file refers to this file with different case
> letters than it is materialized on disk.  On the disk the file is actually
> stored as "C:\Path\to\File" which translates to the Cygwin style name
> "/cygdrive/c/Path/to/File".  Since Windows is supposed to be case-insensitive
> this should be fine but in Cygwin's GNU make binary (current version as of
> today) I observed the following behavior:
> 
> 1. "$(wildcard /cygdrive/c/path/to/file)" does not match anything and thus
>    returns an empty string.
> 
> 2. "$(wildcard /cygdrive/c/Path/to/File)" does match the file and thus returns
>    "/cygdrive/c/Path/to/File" as expected.
> 
> 3. "$(wildcard /cygdrive/c/Path/to/file)" does not match anything and thus
>    returns an empty string.
> 
> 4. "$(wildcard /cygdrive/c/path/to/File)" does match the file and thus returns
>    "/cygdrive/c/path/to/File".
> 
> More generic inspection reveals that apparently the $(wildcard) function seems
> to be case-insensitive on the directory part but case-sensitive on the file
> name part of the absolute path given.
> 
> Is this kind of expected behavior or does this point to a bug in the GNU make
> implementation (or even further down in a Cygwin library)?

It looks like this is expected behaviour due to the way make evaluates
the path in the wildcard function.  The strace shows that it simply
checks for the existence of the parent dir /cygdrive/c/path/to.  This
works, because /cygdrive paths are case-insensitive by default.  Next,
it calls opendir and readdir in a loop to check each file in the
directory for a match.  However, the matching algorithm is case-sensitive
by default.  This explains the above observation.

> Does anyone know of a reasonable workaround?  Is there a way to make the
> $(wildcard) function case-insensitive completely (like by setting a special
> option of flag)?  Or is there probably a better replacement function that does
> basically the same but in a case-insensitive way?

Can't answer that one.  Maybe `info make' is your friend...

> If this doesn't work is there probably some function that converts filename
> strings to a representation that is exactly how a file is stored on the disk,
> i.e. I give it "/cygdrive/c/path/to/file" and it returns
> "/cygdrive/c/Path/to/File"?
> 
> Any better ideas?

As a workaround using Cygwin's case-sensitive path handling works.  I
tested it.  See the fine User's Guide at
http://cygwin.com/cygwin-ug-net/using-specialnames.html#pathnames-casesensitive

I'd suggest to put your build paths under explicit Cygwin mount points,
rather than to change the /cygdrive prefix to posix=1.  The description
in the aforementioned section should explain the problem sufficiently.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
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] 3+ messages in thread

* Re: weird behavior regarding case sensitivity of GNU make's  $(wildcard) function
  2010-07-06 15:32 ` Corinna Vinschen
@ 2010-07-14  8:54   ` Csaba Raduly
  0 siblings, 0 replies; 3+ messages in thread
From: Csaba Raduly @ 2010-07-14  8:54 UTC (permalink / raw)
  To: cygwin

On Tue, Jul 6, 2010 at 3:59 PM, Corinna Vinschen wrote:
> On Jul  6 14:11, Robert Schiele wrote:
>> Hi!
>>
>> I found the following (in my optinion weird) behavior of the $(wildcard)
>> function of GNU make when running on Cygwin:
(snip)
>> More generic inspection reveals that apparently the $(wildcard) function seems
>> to be case-insensitive on the directory part but case-sensitive on the file
>> name part of the absolute path given.
>>
>> Is this kind of expected behavior or does this point to a bug in the GNU make
>> implementation (or even further down in a Cygwin library)?
>
> It looks like this is expected behaviour due to the way make evaluates
> the path in the wildcard function.  The strace shows that it simply
> checks for the existence of the parent dir /cygdrive/c/path/to.  This
> works, because /cygdrive paths are case-insensitive by default.  Next,
> it calls opendir and readdir in a loop to check each file in the
> directory for a match.  However, the matching algorithm is case-sensitive
> by default.  This explains the above observation.
>
>> Does anyone know of a reasonable workaround?  Is there a way to make the
>> $(wildcard) function case-insensitive completely (like by setting a special
>> option of flag)?  Or is there probably a better replacement function that does
>> basically the same but in a case-insensitive way?

Basically this is due to Cygwin's underlying implementation and
there's nothing that the make program can do about it (it was written
for Unix where everything is case-sensitive).

> I'd suggest to put your build paths under explicit Cygwin mount points

Another possibility may be to symlink /cygdrive/c/Path/to somewhere
under your Cygwin home.
For example, I have symlinked C:\Users\xxx\Downloads as
/cygwin/home/xxx/dl and access downloaded files as ~/dl/foo

-- 
Life is complex, with real and imaginary parts.
"Ok, it boots. Which means it must be bug-free and perfect. " -- Linus Torvalds
"People disagree with me. I just ignore them." -- Linus Torvalds

--
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] 3+ messages in thread

end of thread, other threads:[~2010-07-14  8:03 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-07-06 13:41 weird behavior regarding case sensitivity of GNU make's $(wildcard) function Robert Schiele
2010-07-06 15:32 ` Corinna Vinschen
2010-07-14  8:54   ` Csaba Raduly

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).