mirror of https://github.com/rusefi/bldc.git
[Makefile][System ID] Improved method for detecting OS
This commit is contained in:
parent
b87e2c8d70
commit
7d93da7313
|
@ -1,47 +1,52 @@
|
|||
# shared.mk
|
||||
#
|
||||
# environment variables common to all operating systems supported by the make system
|
||||
# C.f. https://gist.github.com/sighingnow/deee806603ec9274fd47
|
||||
|
||||
# Make sure we know a few things about the architecture
|
||||
UNAME := $(shell uname)
|
||||
ARCH := $(shell uname -m)
|
||||
ifneq (,$(filter $(ARCH), x86_64 amd64))
|
||||
X86-64 := 1
|
||||
X86_64 := 1
|
||||
AMD64 := 1
|
||||
endif
|
||||
OSFLAG :=
|
||||
|
||||
# configure some variables dependent upon what type of system this is
|
||||
|
||||
# Linux
|
||||
ifeq ($(UNAME), Linux)
|
||||
OSFAMILY := linux
|
||||
LINUX := 1
|
||||
endif
|
||||
|
||||
# Mac OSX
|
||||
ifeq ($(UNAME), Darwin)
|
||||
OSFAMILY := macos
|
||||
MACOS := 1
|
||||
endif
|
||||
|
||||
# Windows using MinGW shell
|
||||
ifeq (MINGW, $(findstring MINGW,$(UNAME)))
|
||||
OSFAMILY := windows
|
||||
MINGW := 1
|
||||
WINDOWS := 1
|
||||
endif
|
||||
|
||||
# Windows using Cygwin shell
|
||||
ifeq (CYGWIN ,$(findstring CYGWIN,$(UNAME)))
|
||||
ifeq ($(OS),Windows_NT)
|
||||
OSFLAG += -D WIN32
|
||||
OSFAMILY := windows
|
||||
WINDOWS := 1
|
||||
CYGWIN := 1
|
||||
|
||||
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
|
||||
OSFLAG += -D AMD64
|
||||
endif
|
||||
ifeq ($(PROCESSOR_ARCHITECTURE),x86)
|
||||
OSFLAG += -D IA32
|
||||
endif
|
||||
else
|
||||
UNAME_S := $(shell uname -s)
|
||||
ifeq ($(UNAME_S),Linux)
|
||||
OSFLAG += -D LINUX
|
||||
OSFAMILY := linux
|
||||
LINUX := 1
|
||||
endif
|
||||
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
OSFLAG += -D OSX
|
||||
OSFAMILY := macos
|
||||
MACOS := 1
|
||||
endif
|
||||
|
||||
UNAME_P := $(shell uname -p)
|
||||
ifeq ($(UNAME_P),x86_64)
|
||||
OSFLAG += -D AMD64
|
||||
endif
|
||||
|
||||
ifneq ($(filter %86,$(UNAME_P)),)
|
||||
OSFLAG += -D IA32
|
||||
endif
|
||||
|
||||
ifneq ($(filter arm%,$(UNAME_P)),)
|
||||
OSFLAG += -D ARM
|
||||
endif
|
||||
endif
|
||||
|
||||
# report an error if we couldn't work out what OS this is running on
|
||||
ifndef OSFAMILY
|
||||
$(info uname reports $(UNAME))
|
||||
$(info uname -m reports $(ARCH))
|
||||
$(error failed to detect operating system)
|
||||
$(error failed to detect operating system)
|
||||
endif
|
||||
|
|
Loading…
Reference in New Issue