The problem arises when makefile needs be run on different OS and various setting should be properly set up (escaping, path separator, etc) depending on OS. The first approach was to use Windows COMSPEC:
ifneq ($(COMSPEC)$(ComSpec),)
## in windows
else
## in linux
endif
This is false positive for Cygwin, because it sees Windows' environment variables and detects Cygwin as Windows. Then we tried Linux PWD:
ifeq ($(PWD),)
## in windows
else
## in linux, cygwin
endif
However, as a result of integration of off-site tool we have PWD set in windows (one of the perl's modules). So, the detection fails again.
I wonder, what is the best approach to differentiate between Cygwin, Linux, Windows using environment variables?