Makefile fails when CygWin in Path

I'm trying to figure out why a simple Windows command in makefile fails only when the CygWin binary folder is included in the PATH variable.

To take most variables out of the equation I'm using the barebone makefile below:

clean: del /F /Q file.txt

I'm running GNU make 3.81 from a directory that contains only make.exe and makefile.

C:\temp\test>dir /b
make.exe
makefile
C:\temp\test>make -v
GNU Make 3.81
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.
This program built for Windows32

When PATH includes the Cygwin binary folder, I get a ProcessCreate() error.

C:\temp\test>path=c:\tools\cygwin\bin
C:\temp\test>make clean
del /F /Q file.txt
process_begin: CreateProcess(NULL, del /F /Q file.txt, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [clean] Error 2

It works as expected, otherwise.

C:\temp\test>set path=
C:\temp\test>make clean
del /F /Q file.txt
Could Not Find C:\temp\test\file.txt

This makes no sense to me.
Any idea what could be happening here?

1

1 Answer

I've made some progress after more experiments and reading. I think I understand the logic now.

It appears that all recipe commands in the makefile are exclusively shell commands once sh.exe in in the PATH. They cannot be windows commands.

After removing sh.exe from cygwin/bin, the original makefile worked as I expected. 'cmd' can also be explicitly specified instead of the default 'sh' in the makefile as follows:

clean: cmd /c 'del /F /Q file.txt'

If this is correct, this is a bit disappointing. By having cygwin/bin in the 'PATH', I was assuming either type of commands could be used in the makefile, just like on the windows commands or in batch file.

What still does not make great sense to me is that windows commands work when sh.exe is not in reach. Still missing part of the logic.

(sorry for posting on the wrong site, thought I was on stackoverflow. If moderator can move or delete this post, please do.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like