problems running certain utilities via makefile (Win32)

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

problems running certain utilities via makefile (Win32)

Gorlash
I have been using makefiles for many years, but have historically had problems running certain win32 executables via it, though the same command works fine in a batch file.  One of my more common problem applications is lint-nt.exe, from PcLint.  Here is a typical command:

c:\lint9\lint-nt +v -width(160,4) $(LiFLAGS) +fcp -ic:\lint9 mingw.lnt -os(_lint.tmp) lintdefs.cpp $(CPPSRC)

If I try to run this explicitly, it fails with:

c:\lint9\lint-nt +v -width(160,4)  +fcp -ic:\lint9 mingw.lnt -os(_lint.tmp) lintdefs.cpp json_handler.cpp common_funcs.cpp nsort.cpp
/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `c:\lint9\lint-nt +v -width(160,4)  +fcp -ic:\lint9 mingw.lnt -os(_lint.tmp) lintdefs.cpp json_handler.cpp common_funcs.cpp nsort.cpp '
Makefile:42: recipe for target 'lintraw' failed
make: *** [lintraw] Error 258

(note that the macros expanded properly, and that the resulting command works fine from cmd.exe)

In the past, I used Cygwin make, and with that program I could instead spawn the command in cmd.exe using:
        cmd /c "c:\lint9\lint-nt +v -width(160,4) $(LiFLAGS) +fcp -ic:\lint9 mingw.lnt -os(_lint.tmp) lintdefs.cpp $(CPPSRC)"

and that worked fine.  Recently, though, I've switched to using GnuWin32, but the preceding command fails with:
C:\SourceCode\json Yes, Master?? > make lint
cmd /c "c:\lint9\lint-nt +v -width(160,4)  +fcp -ic:\lint9 mingw.lnt -os(_lint.tmp) lintdefs.cpp json_handler.cpp common_funcs.cpp nsort.cpp "
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

and then it leaves me sitting in this sub-shell, without doing anything.


So, at this point, I can't find any way to run this command from a makefile!!  I even downloaded Make V4.1 and build using MinGW, but that didn't help any.

Is there some technique to solve this problem, whatever it is??
Reply | Threaded
Open this post in threaded view
|

Re: problems running certain utilities via makefile (Win32)

Eli Zaretskii
> Date: Thu, 3 Dec 2015 15:12:36 -0800 (PST)
> From: Gorlash <[hidden email]>
>
> I have been using makefiles for many years, but have historically had
> problems running certain win32 executables via it, though the same command
> works fine in a batch file.  One of my more common problem applications is
> lint-nt.exe, from PcLint.  Here is a typical command:
>
> c:\lint9\lint-nt +v -width(160,4) $(LiFLAGS) +fcp -ic:\lint9 mingw.lnt
> -os(_lint.tmp) lintdefs.cpp $(CPPSRC)
>
> If I try to run this explicitly, it fails with:
>
> c:\lint9\lint-nt +v -width(160,4)  +fcp -ic:\lint9 mingw.lnt -os(_lint.tmp)
> lintdefs.cpp json_handler.cpp common_funcs.cpp nsort.cpp
> /bin/sh: -c: line 0: syntax error near unexpected token `('
> /bin/sh: -c: line 0: `c:\lint9\lint-nt +v -width(160,4)  +fcp -ic:\lint9
> mingw.lnt -os(_lint.tmp) lintdefs.cpp json_handler.cpp common_funcs.cpp
> nsort.cpp '
> Makefile:42: recipe for target 'lintraw' failed
> make: *** [lintraw] Error 258
>
> (note that the macros expanded properly, and that the resulting command
> works fine from cmd.exe)

How did /bin/sh come into play here?  Do you have some sh.exe
somewhere on your PATH?  If so, you need to protect any characters
special for a Unixy shell by escaping them or by quoting.

> In the past, I used Cygwin make, and with that program I could instead spawn
> the command in cmd.exe using:
> cmd /c "c:\lint9\lint-nt +v -width(160,4) $(LiFLAGS) +fcp -ic:\lint9
> mingw.lnt -os(_lint.tmp) lintdefs.cpp $(CPPSRC)"
>
> and that worked fine.  Recently, though, I've switched to using GnuWin32,
> but the preceding command fails with:
> C:\SourceCode\json Yes, Master?? > make lint
> cmd /c "c:\lint9\lint-nt +v -width(160,4)  +fcp -ic:\lint9 mingw.lnt
> -os(_lint.tmp) lintdefs.cpp json_handler.cpp common_funcs.cpp nsort.cpp "
> Microsoft Windows [Version 6.1.7601]
> Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
>
> and then it leaves me sitting in this sub-shell, without doing anything.

GnuWin32 provides an old, buggy port of an old version of GNU Make.
Don't use it.

> So, at this point, I can't find any way to run this command from a
> makefile!!  I even downloaded Make V4.1 and build using MinGW, but that
> didn't help any.

Please show the results of running your Makefile with Make 4.1.  If
you need, you can find precompiled binaries here:

  http://sourceforge.net/projects/ezwinports/files/make-4.1-2-without-guile-w32-bin.zip/download
  http://sourceforge.net/projects/ezwinports/files/make-4.1-2-with-guile-w32-bin.zip/download

(choose one of these 2 builds).

> Is there some technique to solve this problem, whatever it is??

Pc-Lint is a proprietary package, so I cannot test it here.  But it
sounds like the problem is with some Unixy shell lying on your Windows
PATH.  One thing to try is to remove the directory with sh.exe from
your PATH; Make 4.1 should then invoke cmd.exe by default, which will
probably work much better.

_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: problems running certain utilities via makefile (Win32)

Gorlash
Okay, here are runs using your make.exe, with two different run styles:
'make lint' runs with the 'cmd /c' wrapper, 'make lintraw' just runs the program itself.  Both still fail, as shown below.

BTW, the sh.exe that make is picking up, is in \git\bin; I cannot really delete that, since git uses it for other purposes.  What would be desirable would be if make would spawn processes using OS methods such as exec(), rather than trying to spawn sub-shells in the Unix style...

ITM, in most cases I'd be quite happy to use the 'cmd /c' wrapper; this used to work with cygwin make (which is also V4.1), but as you can see, with your make (or GnuWin32, or UnxUtils), it spawns cmd.exe but does not seem to pass my command to that shell, so nothing happens.

C:\SourceCode\json Yes, Master?? > which make
make is an external : C:\utility\make.exe

C:\SourceCode\json Yes, Master?? > make --version
GNU Make 4.1
Built for Windows32
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

C:\SourceCode\json Yes, Master?? > make lint
cmd /c "c:\lint9\lint-nt +v -width(160,4)  +fcp -ic:\lint9 mingw.lnt -os(_lint.tmp) lintdefs.cpp json_handler.cpp common_funcs.cpp nsort.cpp "
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

%@exec[@color 10 on 1 & echos %_cwd & color 13 on 0 & echos  Yes, Master?? & color 3 on 0] > exit

C:\SourceCode\json Yes, Master?? > make lintraw
c:\lint9\lint-nt +v -width(160,4)  +fcp -ic:\lint9 mingw.lnt -os(_lint.tmp) lintdefs.cpp json_handler.cpp common_funcs.cpp nsort.cpp
/bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `c:\lint9\lint-nt +v -width(160,4)  +fcp -ic:\lint9 mingw.lnt -os(_lint.tmp) lintdefs.cpp json_handler.cpp common_funcs.cpp nsort.cpp '
Makefile:43: recipe for target 'lintraw' failed
make: *** [lintraw] Error 258





On Fri, Dec 4, 2015 at 1:18 AM, Eli Zaretskii [via Gnu - Make] <[hidden email]> wrote:
> Date: Thu, 3 Dec 2015 15:12:36 -0800 (PST)
> From: Gorlash <[hidden email]>
>

> I have been using makefiles for many years, but have historically had
> problems running certain win32 executables via it, though the same command
> works fine in a batch file.  One of my more common problem applications is
> lint-nt.exe, from PcLint.  Here is a typical command:
>
> c:\lint9\lint-nt +v -width(160,4) $(LiFLAGS) +fcp -ic:\lint9 mingw.lnt
> -os(_lint.tmp) lintdefs.cpp $(CPPSRC)
>
> If I try to run this explicitly, it fails with:
>
> c:\lint9\lint-nt +v -width(160,4)  +fcp -ic:\lint9 mingw.lnt -os(_lint.tmp)
> lintdefs.cpp json_handler.cpp common_funcs.cpp nsort.cpp
> /bin/sh: -c: line 0: syntax error near unexpected token `('
> /bin/sh: -c: line 0: `c:\lint9\lint-nt +v -width(160,4)  +fcp -ic:\lint9
> mingw.lnt -os(_lint.tmp) lintdefs.cpp json_handler.cpp common_funcs.cpp
> nsort.cpp '
> Makefile:42: recipe for target 'lintraw' failed
> make: *** [lintraw] Error 258
>
> (note that the macros expanded properly, and that the resulting command
> works fine from cmd.exe)
How did /bin/sh come into play here?  Do you have some sh.exe
somewhere on your PATH?  If so, you need to protect any characters
special for a Unixy shell by escaping them or by quoting.

> In the past, I used Cygwin make, and with that program I could instead spawn
> the command in cmd.exe using:
> cmd /c "c:\lint9\lint-nt +v -width(160,4) $(LiFLAGS) +fcp -ic:\lint9
> mingw.lnt -os(_lint.tmp) lintdefs.cpp $(CPPSRC)"
>
> and that worked fine.  Recently, though, I've switched to using GnuWin32,
> but the preceding command fails with:
> C:\SourceCode\json Yes, Master?? > make lint
> cmd /c "c:\lint9\lint-nt +v -width(160,4)  +fcp -ic:\lint9 mingw.lnt
> -os(_lint.tmp) lintdefs.cpp json_handler.cpp common_funcs.cpp nsort.cpp "
> Microsoft Windows [Version 6.1.7601]
> Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
>
> and then it leaves me sitting in this sub-shell, without doing anything.
GnuWin32 provides an old, buggy port of an old version of GNU Make.
Don't use it.

> So, at this point, I can't find any way to run this command from a
> makefile!!  I even downloaded Make V4.1 and build using MinGW, but that
> didn't help any.

Please show the results of running your Makefile with Make 4.1.  If
you need, you can find precompiled binaries here:

  http://sourceforge.net/projects/ezwinports/files/make-4.1-2-without-guile-w32-bin.zip/download
  http://sourceforge.net/projects/ezwinports/files/make-4.1-2-with-guile-w32-bin.zip/download

(choose one of these 2 builds).

> Is there some technique to solve this problem, whatever it is??

Pc-Lint is a proprietary package, so I cannot test it here.  But it
sounds like the problem is with some Unixy shell lying on your Windows
PATH.  One thing to try is to remove the directory with sh.exe from
your PATH; Make 4.1 should then invoke cmd.exe by default, which will
probably work much better.

_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make



If you reply to this email, your message will be added to the discussion below:
http://gnu-make.2324884.n4.nabble.com/problems-running-certain-utilities-via-makefile-Win32-tp16736p16741.html
To unsubscribe from problems running certain utilities via makefile (Win32), click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: problems running certain utilities via makefile (Win32)

Paul Smith-20
On Fri, 2015-12-04 at 10:13 -0800, Gorlash wrote:
> BTW, the sh.exe that make is picking up, is in \git\bin; I cannot
> really delete that, since git uses it for other purposes.

FWIW, the way I have dealt with this in the past is to put the \git\cmd
directory on Windows PATH, NOT \git\bin.  The \git\cmd directory
contains ONLY git.exe (and a few small extras) and not the entire suite
of UNIX command line tools that come with Git for Windows.

That might not be good enough if you use other tools from \git\bin of
course.  Eli will have to comment about tricks to use with make SHELL to
get what you want, if possible.


_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: problems running certain utilities via makefile (Win32)

Gorlash
Hi Paul!
Yes, I do use other utilities in \git\bin, though only a couple... 

I tried experimenting with .ONESHELL, but it didn't solve this problem, possibly because I don't really understand how to use it properly...

On Fri, Dec 4, 2015 at 10:29 AM, Paul Smith-20 [via Gnu - Make] <[hidden email]> wrote:
On Fri, 2015-12-04 at 10:13 -0800, Gorlash wrote:
> BTW, the sh.exe that make is picking up, is in \git\bin; I cannot
> really delete that, since git uses it for other purposes.

FWIW, the way I have dealt with this in the past is to put the \git\cmd
directory on Windows PATH, NOT \git\bin.  The \git\cmd directory
contains ONLY git.exe (and a few small extras) and not the entire suite
of UNIX command line tools that come with Git for Windows.

That might not be good enough if you use other tools from \git\bin of
course.  Eli will have to comment about tricks to use with make SHELL to
get what you want, if possible.


_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make



If you reply to this email, your message will be added to the discussion below:
http://gnu-make.2324884.n4.nabble.com/problems-running-certain-utilities-via-makefile-Win32-tp16736p16743.html
To unsubscribe from problems running certain utilities via makefile (Win32), click here.
NAML

Reply | Threaded
Open this post in threaded view
|

Re: problems running certain utilities via makefile (Win32)

Nicholas Clark
Hi Gorlash,

On the subject of your "syntax error near unexpected token `('" errors,
have you tried putting your parentheses arguments in quotes?

Instead of this:

lint: $(SOURCE_FILES)
    $(LINT_TOOL)  +v -width(160,4)  +fcp -ic:\lint9 mingw.lnt -os(_lint.tmp)
$(SOURCE_FILES)

Try this:


lint: $(SOURCE_FILES)
    $(LINT_TOOL)  +v "-width(160,4)"  +fcp -ic:\lint9 mingw.lnt
"-os(_lint.tmp)" $(SOURCE_FILES)


-Nick


On Fri, Dec 4, 2015 at 11:32 AM, Gorlash <[hidden email]> wrote:

> Hi Paul!
> Yes, I do use other utilities in \git\bin, though only a couple...
>
> I tried experimenting with .ONESHELL, but it didn't solve this problem,
> possibly because I don't really understand how to use it properly...
>
> On Fri, Dec 4, 2015 at 10:29 AM, Paul Smith-20 [via Gnu - Make] <
> [hidden email]> wrote:
>
> > On Fri, 2015-12-04 at 10:13 -0800, Gorlash wrote:
> > > BTW, the sh.exe that make is picking up, is in \git\bin; I cannot
> > > really delete that, since git uses it for other purposes.
> >
> > FWIW, the way I have dealt with this in the past is to put the \git\cmd
> > directory on Windows PATH, NOT \git\bin.  The \git\cmd directory
> > contains ONLY git.exe (and a few small extras) and not the entire suite
> > of UNIX command line tools that come with Git for Windows.
> >
> > That might not be good enough if you use other tools from \git\bin of
> > course.  Eli will have to comment about tricks to use with make SHELL to
> > get what you want, if possible.
> >
> >
> > _______________________________________________
> > Help-make mailing list
> > [hidden email] <http:///user/SendEmail.jtp?type=node&node=16743&i=0>
> > https://lists.gnu.org/mailman/listinfo/help-make
> >
> >
> > ------------------------------
> > If you reply to this email, your message will be added to the discussion
> > below:
> >
> >
> http://gnu-make.2324884.n4.nabble.com/problems-running-certain-utilities-via-makefile-Win32-tp16736p16743.html
> > To unsubscribe from problems running certain utilities via makefile
> > (Win32), click here
> > <
> >
> > .
> > NAML
> > <
>
http://gnu-make.2324884.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml
> >
> >
>
>
>
>
> --
> View this message in context:
> http://gnu-make.2324884.n4.nabble.com/problems-running-certain-utilities-via-makefile-Win32-tp16736p16744.html
> Sent from the Gnu - Make - Help mailing list archive at Nabble.com.
> _______________________________________________
> Help-make mailing list
> [hidden email]
> https://lists.gnu.org/mailman/listinfo/help-make
>
_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: problems running certain utilities via makefile (Win32)

Eli Zaretskii
In reply to this post by Gorlash
> Date: Fri, 4 Dec 2015 10:13:11 -0800 (PST)
> From: Gorlash <[hidden email]>
>
> Okay, here are runs using your make.exe, with two different run styles:
> 'make lint' runs with the 'cmd /c' wrapper, 'make lintraw' just runs the
> program itself.  Both still fail, as shown below.

Thanks, but that doesn't help me help you in any way, as I cannot try
this myself, and don't even know what all these parameters mean or why
they have this peculiar form.  I don't even know if lint-nt is a
program or a batch file.

Once again, as long as a Unixy shell is running the commands, you
_must_ use the quoting style of that shell, and you must protect
characters special for the shell by quoting them.

> BTW, the sh.exe that make is picking up, is in \git\bin; I cannot really
> delete that, since git uses it for other purposes.

Then say SHELL=cmd.exe at the beginning of the Makefile, and Make will
use cmd.exe instead of sh.exe.

> What would be desirable would be if make would spawn processes using
> OS methods such as exec(), rather than trying to spawn sub-shells in
> the Unix style...

Make already does that.  But if your command includes characters
special for the shell, it always invokes a sub-shell, because it
doesn't want to implement all the convoluted logic of the shell with
handling those special characters.

_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: problems running certain utilities via makefile (Win32)

Eli Zaretskii
In reply to this post by Paul Smith-20
> From: Paul Smith <[hidden email]>
> Date: Fri, 04 Dec 2015 13:45:26 -0500
> Cc: [hidden email]
>
> On Fri, 2015-12-04 at 10:13 -0800, Gorlash wrote:
> > BTW, the sh.exe that make is picking up, is in \git\bin; I cannot
> > really delete that, since git uses it for other purposes.
>
> FWIW, the way I have dealt with this in the past is to put the \git\cmd
> directory on Windows PATH, NOT \git\bin.

Granted.  Me, I don't even put the git\cmd directory on my Windows
PATH, I always invoke Git from a separate shell session that runs
Bash.  (If I need to invoke Git from a cmd window or a native Windows
program, I have a git.cmd batch file in my system-wide bin directory,
and that batch file knows how to find Git.)  This arrangement keeps me
sane.

> Eli will have to comment about tricks to use with make SHELL to get
> what you want, if possible.

Yes, SHELL=cmd.exe should be one solution.

_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make
Reply | Threaded
Open this post in threaded view
|

Re: problems running certain utilities via makefile (Win32)

Gorlash
In reply to this post by Eli Zaretskii
Thank you, both Eli *and* Paul!!  I'm getting a better understanding of what is going on now.

item 1: lint-nt.exe is a win32 executable, though I don't think it matters here.

item 2: using double-quotes around the arguments with parens, did not work - but using single-quotes *did* work, at least for lintraw argument; thanks!!   Although I use unix utilities extensively, I'm *not* very skilled with shell-command syntax...

item 3: SHELL=cmd.exe *also* made the lintraw target work, even without the quotes; that's very cool!!  In fact, SHELL=cmd.exe makes *both* targets work!!  

Thank you all for your insights and suggestions!!



On Fri, Dec 4, 2015 at 10:58 AM, Eli Zaretskii [via Gnu - Make] <[hidden email]> wrote:
> Date: Fri, 4 Dec 2015 10:13:11 -0800 (PST)
> From: Gorlash <[hidden email]>
>
> Okay, here are runs using your make.exe, with two different run styles:
> 'make lint' runs with the 'cmd /c' wrapper, 'make lintraw' just runs the
> program itself.  Both still fail, as shown below.

Thanks, but that doesn't help me help you in any way, as I cannot try
this myself, and don't even know what all these parameters mean or why
they have this peculiar form.  I don't even know if lint-nt is a
program or a batch file.

Once again, as long as a Unixy shell is running the commands, you
_must_ use the quoting style of that shell, and you must protect
characters special for the shell by quoting them.

> BTW, the sh.exe that make is picking up, is in \git\bin; I cannot really
> delete that, since git uses it for other purposes.

Then say SHELL=cmd.exe at the beginning of the Makefile, and Make will
use cmd.exe instead of sh.exe.

> What would be desirable would be if make would spawn processes using
> OS methods such as exec(), rather than trying to spawn sub-shells in
> the Unix style...

Make already does that.  But if your command includes characters
special for the shell, it always invokes a sub-shell, because it
doesn't want to implement all the convoluted logic of the shell with
handling those special characters.

_______________________________________________
Help-make mailing list
[hidden email]
https://lists.gnu.org/mailman/listinfo/help-make



If you reply to this email, your message will be added to the discussion below:
http://gnu-make.2324884.n4.nabble.com/problems-running-certain-utilities-via-makefile-Win32-tp16736p16746.html
To unsubscribe from problems running certain utilities via makefile (Win32), click here.
NAML