This is the mail archive of the mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Make SHELL variable

In message <>, "Jeffery G. Smith" writes:
>I notice that when make executes a command it actually does a
>	$(SHELL) -c command
>This appears to be a GNU make thing since it happens on our standard
>UNIX platforms as well.  I wasn't able to find any documentation that
>admitted that this -c was added or how to get rid of it.  I really would
>like to be able to use cmd.exe as the SHELL but the -c gets in the way.

I ran into this same exact problem and it is indeed a GNU make thing.
If you browse through the .info files that come with GNU make, you'll
find it documented somewhere in there.  (I'm using GNU make v3.75.)

My understanding of the doc was that make assumes *all* shells
understand '-c' and consequently *hard codes* it to the syntax you
give above.  I saw no way to change this behavior.

Then native win32 (sans gnu-win32 stuff) build of GNU make is set up
fall back to an MSDOS mode (using batch files) for launching programs
in the absence of of a Bourne/Bash style shell (sh.exe).  However
they don't recommend it; it hasn't seen much testing.  (See the
README.WIN32 in the GNU make distribution.)

This whole problem is what prompted me to go out and get Cygnus' GNU
Win32 bash and tools in the first place.  The biggest problem I
encountered with doing this was that all the rules must be written so
they launch commands with Bourne shell syntax rather than cmd.exe
syntax.  Mostly this boiled down to quoting or escaping any backslash
('\') characters.  Beyond that and ironing out a couple of other
little quirks, I found this to be quite a workable solution.

If you still want to use cmd.exe as your SHELL, here's another
approach you might want to try.  You could write a small wrapper
program that just eats the initial '-c' argument and uses the
remaining arguments to construct the command to be executed via a
system() call.  I actually did this as part of my experimentation and
you'd be more than welcome to the source if you want it (~30 lines of
C).  One thing you'd still have to watch out for here, though, is how
to handle quoted arguments.  (My code doesn't handle this.) 

Good luck.  I hope this helps.

For help on using this list, send a message to
"" with one line of text: "help".

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]