Determining the OS
We want to identify the OS efficiently and correctly, and there are probably a hundred different ways to do it. First, we’ll try to determine the OS by reading environment variables. If all else fails, we’ll run uname. Create os.mk in the nospb/mk directory.
os.mk
# Try to determine OS name without shelling out to uname if possible. ifndef __uname export __uname:=$(OSNAME) endif ifndef __uname export __uname:=$(OSTYPE) endif ifndef __uname # Assume we're running MinGW if not Cygwin. export __uname:=$(if $(COMSPEC),mingw,) endif ifndef __uname # Ran out of environment tricks, so just run uname. export __uname:=$(shell uname) endif ifeq ($(__uname),cygwin) PLATFORM_CYGWIN=1 ISWINDOWS=1 endif ifeq ($(__uname),mingw) PLATFORM_MINGW=1 ISWINDOWS=1 endif ifeq ($(__uname),Darwin) PLATFORM_DARWIN=1 ISBSD=1 ISUNIX=1 endif ifeq ($(__uname),FreeBSD) PLATFORM_FREEBSD=1 ISBSD=1 ISUNIX=1 endif ifeq ($(__uname),Linux) PLATFORM_LINUX=1 ISUNIX=1 endif
Update rules.mk
Now you need to add os.mk to your rules framework. After the line that defines __nospb_dir, include os.mk.
os.mk snippet
# Include OS identification module. include $(__nospb_dir)os.mk