diff --git a/Libraries/CMSIS/Device/Maxim/GCC/gcc.mk b/Libraries/CMSIS/Device/Maxim/GCC/gcc.mk index a94f4b004c..8eac3897fc 100644 --- a/Libraries/CMSIS/Device/Maxim/GCC/gcc.mk +++ b/Libraries/CMSIS/Device/Maxim/GCC/gcc.mk @@ -106,6 +106,59 @@ OBJS += $(PROJ_OBJS) ################################################################################ # Goals +################################################################################ +# Get the operating system name. If this is Cygwin, the .d files will be +# munged to convert c: into /cygdrive/c so that "make" will be happy with the +# auto-generated dependencies. Also if this is Cygwin, file paths for ARM GCC +# will be converted from /cygdrive/c to C:. +################################################################################ + +# Detect target OS +# windows : native windows +# windows_msys : MSYS2 on windows +# windows_cygwin : Cygwin on windows (legacy config from old sdk) +# linux : Any linux distro +# macos : MacOS +ifeq "$(_OS)" "" + +ifeq "$(OS)" "Windows_NT" +_OS = windows + +UNAME_RESULT := $(shell uname -s 2>&1) +# MSYS2 may be present on Windows. In this case, +# linux utilities should be used. However, the OS environment +# variable will still be set to Windows_NT since we configure +# MSYS2 to inherit from Windows by default. +# Here we'll attempt to call uname (only present on MSYS2) +# while routing stderr -> stdout to avoid throwing an error +# if uname can't be found. +ifneq ($(findstring CYGWIN, $(UNAME_RESULT)), ) +CYGWIN=True +_OS = windows_cygwin +endif + +ifneq ($(findstring MSYS, $(UNAME_RESULT)), ) +MSYS=True +_OS = windows_msys +endif +ifneq ($(findstring MINGW, $(UNAME_RESULT)), ) +MSYS=True +_OS = windows_msys +endif + +else # OS +$(info "") +UNAME_RESULT := $(shell uname -s) +ifeq "$(UNAME_RESULT)" "Linux" +_OS = linux +endif +ifeq "$(UNAME_RESULT)" "Darwin" +_OS = macos +endif + +endif + +endif # The default goal, which causes the example to be built. .DEFAULT_GOAL :=