mingw32-make issue with windows style directories as target dependencies

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

mingw32-make issue with windows style directories as target dependencies

Ketan Surender
Hello,

I am running into an issue using mingw32-make with a makefile that has specified some target dependencies using Windows style directories (IE ..\myDirectory instead of ../myDirectory).  It appears that "\" is being treated as a concatenation operator in the dependency name.  This is leading to make errors (specified target cannot be found).

Here is a simple makefile example that exhibits this behavior:

<Start Makefile>

# Variables
LIBDIRNAME = ..\lib

# Targets

setup: $(LIBDIRNAME)

$(LIBDIRNAME):
    if not exist $(LIBDIRNAME) mkdir $(LIBDIRNAME)
   
.PHONY: setup

<End Makefile>

In the Windows command shell I execute:

>mingw32-make -f test_make.gcc setup

I receive the error:

*** No rule to make target '...lib', needed by 'setup'.  Stop

Note that is has removed the "\" character in the dependency name.  It should be looking for a target name '..\lib' instead of '..lib'.

If I execute:

>mingw32-make -f test_make.gcc ..\lib

I do not receive any errors and the directory is created correctly.  Do I need to do something additional to tell mingw32-make that I am using Windows style paths?

> mingw32-make --version says I have GNU Make 3.82.90

Thanks

KS




------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: mingw32-make issue with windows style directories as target dependencies

Eli Zaretskii
> Date: Fri, 31 Aug 2012 15:56:56 -0400
> From: Ketan Surender <[hidden email]>
>
> I am running into an issue using mingw32-make with a makefile that has
> specified some target dependencies using Windows style directories (IE
> ..\myDirectory instead of ../myDirectory).  It appears that "\" is being
> treated as a concatenation operator in the dependency name.

It's not a concatenation operator, it's an escape character.  It
causes the next character to be interpreted as itself (obviously,
redundant for simple characters such as '.').

> # Variables
> LIBDIRNAME = ..\lib
>
> # Targets
>
> setup: $(LIBDIRNAME)
>
> $(LIBDIRNAME):
>     if not exist $(LIBDIRNAME) mkdir $(LIBDIRNAME)
>
> .PHONY: setup
>
> <End Makefile>
>
> In the Windows command shell I execute:
>
> >mingw32-make -f test_make.gcc setup
>
> I receive the error:
>
> *** No rule to make target '...lib', needed by 'setup'.  Stop
>
> Note that is has removed the "\" character in the dependency name.  It
> should be looking for a target name '..\lib' instead of '..lib'.
>
> If I execute:
>
> >mingw32-make -f test_make.gcc ..\lib
>
> I do not receive any errors and the directory is created correctly.  Do I
> need to do something additional to tell mingw32-make that I am using
> Windows style paths?

My advice: don't use backslashes in Makefiles as much as you can.  Use
forward slashes instead.  You will make your life much easier that way.

Many Windows commands will accept forward slashes, although sometimes
you will need to quote the file name for that to work.  When file
names with forward slashes absolutely don't work, convert them to
backslashes in the command line of the rule you run.  For example:

<Start Makefile>

# Variables
LIBDIRNAME = ../lib

# Targets

setup: $(LIBDIRNAME)

$(LIBDIRNAME):
        if not exist $(subst /,\,$(LIBDIRNAME)) mkdir "$(LIBDIRNAME)"

.PHONY: setup

<End Makefile>

The above shows one instance of using ".." quoting and one instance of
converting forward slashes to backslashes when the command needs that.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: mingw32-make issue with windows style directories as target dependencies

Ketan Surender
Thanks for the info.  Those are definitely good practices when creating makefiles. 

In this case I am trying to build an existing library from a provided makefile that uses backslashes in file and directory names.  I was wondering if this is supported or was previously supported by mingw32-make. 

Thanks

Ketan

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: mingw32-make issue with windows style directories as target dependencies

Ketan Surender
In reply to this post by Ketan Surender
On Fri, Aug 31, 2012 at 3:56 PM, Ketan Surender
<[hidden email]> wrote:

>
> Hello,
>
> I am running into an issue using mingw32-make with a makefile that has specified some target dependencies using Windows style directories (IE ..\myDirectory instead of ../myDirectory).  It appears that "\" is being treated as a concatenation operator in the dependency name.  This is leading to make errors (specified target cannot be found).
>
> Here is a simple makefile example that exhibits this behavior:
>
> <Start Makefile>
>
> # Variables
> LIBDIRNAME = ..\lib
>
> # Targets
>
> setup: $(LIBDIRNAME)
>
> $(LIBDIRNAME):
>     if not exist $(LIBDIRNAME) mkdir $(LIBDIRNAME)
>
> .PHONY: setup
>
> <End Makefile>
>
> In the Windows command shell I execute:
>
> >mingw32-make -f test_make.gcc setup
>
> I receive the error:
>
> *** No rule to make target '...lib', needed by 'setup'.  Stop
>
> Note that is has removed the "\" character in the dependency name.  It should be looking for a target name '..\lib' instead of '..lib'.
>
> If I execute:
>
> >mingw32-make -f test_make.gcc ..\lib
>
> I do not receive any errors and the directory is created correctly.  Do I need to do something additional to tell mingw32-make that I am using Windows style paths?
>
> > mingw32-make --version says I have GNU Make 3.82.90
>
> Thanks
>
> KS

mingw32-make 3.82 (instead of 3.82.90) with the above example makefile
the runs the setup target without any errors.

Ketan

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: mingw32-make issue with windows style directories as target dependencies

Eli Zaretskii
> Date: Sat, 1 Sep 2012 01:52:31 -0400
> From: Ketan Surender <[hidden email]>
>
> mingw32-make 3.82 (instead of 3.82.90) with the above example makefile
> the runs the setup target without any errors.

As does 3.82.90 I compiled myself from CVS a few months ago.

Either this is due to a new feature or some bug in the build process
of MinGW Make.

In any case, the original question, as I understood it, was what to do
when backslashes don't work (and they sometimes don't, because in some
contexts they are interpreted as escape characters).

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: mingw32-make issue with windows style directories as target dependencies

Eli Zaretskii
In reply to this post by Ketan Surender
> Date: Fri, 31 Aug 2012 22:04:53 -0400
> From: Ketan Surender <[hidden email]>
>
> In this case I am trying to build an existing library from a provided
> makefile that uses backslashes in file and directory names.  I was
> wondering if this is supported or was previously supported by
> mingw32-make.

It is supported, but not in every context in a Makefile.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: mingw32-make issue with windows style directories as target dependencies

Eli Zaretskii
In reply to this post by Eli Zaretskii
> Date: Sat, 01 Sep 2012 10:05:57 +0300
> From: Eli Zaretskii <[hidden email]>
>
> > Date: Sat, 1 Sep 2012 01:52:31 -0400
> > From: Ketan Surender <[hidden email]>
> >
> > mingw32-make 3.82 (instead of 3.82.90) with the above example makefile
> > the runs the setup target without any errors.
>
> As does 3.82.90 I compiled myself from CVS a few months ago.
>
> Either this is due to a new feature or some bug in the build process
> of MinGW Make.

It's a bug.  Fixed with the following change (to be committed to CVS
shortly):

--- read.c~ 2012-09-01 10:09:16.000000000 +0300
+++ read.c 2012-09-01 10:44:30.098750000 +0300
@@ -2242,8 +2242,8 @@ unescape_char (char *string, int c)
               /* It is, and there's >1 backslash.  Take half of them.  */
               l /= 2;
               memcpy (p, s, l);
-              p += l;
             }
+  p += l;
           s = e;
         }
 

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe
Reply | Threaded
Open this post in threaded view
|

Re: mingw32-make issue with windows style directories as target dependencies

Chris Sutcliffe-2
On 1 September 2012 03:47, Eli Zaretskii wrote:

>> Date: Sat, 01 Sep 2012 10:05:57 +0300
>> From: Eli Zaretskii <[hidden email]>
>>
>> > Date: Sat, 1 Sep 2012 01:52:31 -0400
>> > From: Ketan Surender <[hidden email]>
>> >
>> > mingw32-make 3.82 (instead of 3.82.90) with the above example makefile
>> > the runs the setup target without any errors.
>>
>> As does 3.82.90 I compiled myself from CVS a few months ago.
>>
>> Either this is due to a new feature or some bug in the build process
>> of MinGW Make.
>
> It's a bug.  Fixed with the following change (to be committed to CVS
> shortly):
>
> --- read.c~     2012-09-01 10:09:16.000000000 +0300
> +++ read.c      2012-09-01 10:44:30.098750000 +0300
> @@ -2242,8 +2242,8 @@ unescape_char (char *string, int c)
>                /* It is, and there's >1 backslash.  Take half of them.  */
>                l /= 2;
>                memcpy (p, s, l);
> -              p += l;
>              }
> +         p += l;
>            s = e;
>          }

I'll create a new release with this fix included.

Chris

--
Chris Sutcliffe
http://emergedesktop.org
http://www.google.com/profiles/ir0nh34d

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:[hidden email]?subject=unsubscribe