[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Complex pattern rules broken in win32-make (MINGW).

From: Peter Dons Tychsen
Subject: RE: Complex pattern rules broken in win32-make (MINGW).
Date: Tue, 2 Jan 2007 18:25:23 +0100

Ah yes.

I had forgotten about the meaning of "\%" in make.
I should have known better. Looks like my memory cells are not looking
to bright in the new year :-)

However, i am not sure i like the solution where i have to use "/"
instead of "\".
This solution can lead to other errors.

Consider the following example:

obj/%.o: src/%.c
  some_odd_win_compiler -c -o $@ $<

Now the compiler will be called with (for src.o target):

# some_odd_win_compiler -c -o obj/src.o obj/src.c

This will not work for many dos/win tools, as they might puke on the "/"
in the path.
Sadly, it does not really matter what i like, as none of the solutions
work at all.

All of these scenarios fail:

1) obj\%.o: src\%.c     - I understand why this will never work (See
Eli/Pauls remarks).
                          Is consistent with the way a DOS path is
expressed in C ("c:\\some\\path").
2) obj/%.o: src/%.c     - This should work, as DOS/WIN make accepts "/"
as "\" for paths.
3) obj\\%.o: src\\%.c   - This should work, as the double "\" should
undo the effect a single "\" has on a "%".
                          (like other escaped sequences - escaped left
to right, with no recursive parsing).

2) & 3) probably fails due to the way (or maybe the order) in which the
rules and prequisite lines are parsed.

If i wanted to fix this, where should i start?
Which module handles the parsing of these elements?

Anyway, thanks for your snappy and precise input,

Hope the new year brings tons of joy to Make, You and your surroundings!


-----Original Message-----
From: Paul Smith [mailto:address@hidden
Sent: 2. januar 2007 05:46
To: Eli Zaretskii
Cc: Peter Dons Tychsen; address@hidden
Subject: Re: Complex pattern rules broken in win32-make (MINGW).

On Sun, 2006-12-31 at 06:28 +0200, Eli Zaretskii wrote:

> > This rule breaks down:
> >
> > obj\%.o: src\%.c
> >
> > This should however be handled correctly on windows... no ?
> It cannot be fixed easily, as the backslash is required to be able to
> use a literal percent character.

Eli is correct.  The GNU make manual defines the sequence "\%" to be a
literal "%" (the backslash escapes the percent so it's not treated as a
pattern match character).

It's remotely possible that you can get what you want this way:

  obj\\%.o: src\\%.c

since GNU make defines that a backslash can be used to escape a
backslash that would otherwise escape a percent; so the above should
resolve to what you want.

However, I can't say for sure this will work.  In general it's best to
follow Eli's excellent advice and use "/" instead of "\" in your
makefiles, even on Windows.

 Paul D. Smith <address@hidden>          Find some GNU make tips at:            
 "Please remain calm...I may be mad, but I am a professional." --Mad

****         GN Netcom Group  NOTICE - AUTOMATICALLY INSERTED      ****

The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material.  Any review,  retransmission, dissemination or other use of, or
taking of any action in reliance upon,  this information by persons or
entities other than the intended recipient is prohibited.
Any opinions expressed in this email are those of the individual and not
necessarily the Company.

If  you receive this transmission in error, please email to
address@hidden, including a copy of this message. Please then
delete this email and destroy any copies of it.

************************************** DISCLAIMER END 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]