Optimize host name

This commit is contained in:
John Zhao 2018-03-09 14:10:42 +08:00
parent 0820406313
commit 3e74dab076
3 changed files with 54 additions and 26 deletions

View File

@ -31,13 +31,6 @@ else
endif endif
endif endif
UNAME_S := $(shell uname -s)
ifneq ($(UNAME_S),)
ifneq ($(findstring MINGW,$(UNAME_S)),)
HOST_OS := MinGW
endif
endif
else else
UNAME_S := $(shell uname -s) UNAME_S := $(shell uname -s)
@ -46,7 +39,7 @@ ifneq ($(findstring Linux,$(UNAME_S)),)
else ifneq ($(findstring Darwin,$(UNAME_S)),) else ifneq ($(findstring Darwin,$(UNAME_S)),)
HOST_OS := Mac HOST_OS := Mac
else ifneq ($(findstring MINGW,$(UNAME_S)),) else ifneq ($(findstring MINGW,$(UNAME_S)),)
HOST_OS := MinGW HOST_OS := Win
else ifneq ($(findstring MSYS,$(UNAME_S)),) else ifneq ($(findstring MSYS,$(UNAME_S)),)
# Need MSYS on Windows # Need MSYS on Windows
HOST_OS := Win HOST_OS := Win
@ -74,7 +67,16 @@ endif
endif endif
HOST_NAME := $(HOST_OS) HOST_NAME := $(HOST_OS)
ifeq ($(HOST_OS),Linux) ifeq ($(HOST_OS),Win)
UNAME_S := $(shell uname -s)
ifneq ($(UNAME_S),)
ifneq ($(findstring MINGW,$(UNAME_S)),)
HOST_NAME := MinGW
else ifneq ($(findstring MSYS,$(UNAME_S)),)
HOST_NAME := MSYS
endif
endif
else ifeq ($(HOST_OS),Linux)
UNAME_A := $(shell uname -a) UNAME_A := $(shell uname -a)
ifneq ($(findstring tegra,$(UNAME_A)),) ifneq ($(findstring tegra,$(UNAME_A)),)
HOST_NAME := Tegra HOST_NAME := Tegra
@ -97,16 +99,18 @@ SH := $(SHELL)
ECHO := echo -e ECHO := echo -e
FIND := $(shell ./scripts/getfind.sh) FIND := $(shell ./scripts/getfind.sh)
ifeq ($(HOST_OS),MinGW) ifeq ($(HOST_OS),Win)
CC := x86_64-w64-mingw32-gcc ifeq ($(HOST_NAME),MinGW)
CXX := x86_64-w64-mingw32-g++ CC := x86_64-w64-mingw32-gcc
MAKE := mingw32-make CXX := x86_64-w64-mingw32-g++
BUILD := $(MAKE) MAKE := mingw32-make
else ifeq ($(HOST_OS),Win) BUILD := $(MAKE)
CC := cl else
CXX := cl CC := cl
MAKE := make CXX := cl
BUILD := msbuild.exe ALL_BUILD.vcxproj /property:Configuration=Release MAKE := make
BUILD := msbuild.exe ALL_BUILD.vcxproj /property:Configuration=Release
endif
else else
# mac & linux # mac & linux
# Set realpath for linux because of compiler not found with wrong path when cmake again # Set realpath for linux because of compiler not found with wrong path when cmake again
@ -131,8 +135,12 @@ endif
ifneq ($(CXX),) ifneq ($(CXX),)
CMAKE := $(CMAKE) -DCMAKE_CXX_COMPILER=$(CXX) CMAKE := $(CMAKE) -DCMAKE_CXX_COMPILER=$(CXX)
endif endif
ifneq ($(HOST_OS),Win) ifneq ($(MAKE),)
ifneq ($(MAKE),) ifeq ($(HOST_OS),Win)
ifeq ($(HOST_NAME),MinGW)
CMAKE := $(CMAKE) -DCMAKE_MAKE_PROGRAM=$(MAKE)
endif
else
CMAKE := $(CMAKE) -DCMAKE_MAKE_PROGRAM=$(MAKE) CMAKE := $(CMAKE) -DCMAKE_MAKE_PROGRAM=$(MAKE)
endif endif
endif endif
@ -142,12 +150,11 @@ CMAKE_OPTIONS :=
#CMAKE_OPTIONS += -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON #CMAKE_OPTIONS += -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON
CMAKE_OPTIONS_AFTER := CMAKE_OPTIONS_AFTER :=
ifeq ($(HOST_OS),MinGW)
CMAKE += -G "MinGW Makefiles"
endif
ifeq ($(HOST_OS),Win) ifeq ($(HOST_OS),Win)
ifeq ($(HOST_ARCH),x64)
ifeq ($(HOST_NAME),MinGW)
CMAKE += -G "MinGW Makefiles"
else ifeq ($(HOST_ARCH),x64)
VS_VERSION := $(shell echo "$(shell which cl)" | sed "s/.*Visual\sStudio\s\([0-9]\+\).*/\1/g") VS_VERSION := $(shell echo "$(shell which cl)" | sed "s/.*Visual\sStudio\s\([0-9]\+\).*/\1/g")
ifeq (15,$(VS_VERSION)) ifeq (15,$(VS_VERSION))
CMAKE += -G "Visual Studio 15 2017 Win64" CMAKE += -G "Visual Studio 15 2017 Win64"
@ -167,6 +174,7 @@ ifeq ($(HOST_ARCH),x64)
$(call mkinfo,"Connot specify Visual Studio Win64") $(call mkinfo,"Connot specify Visual Studio Win64")
endif endif
endif endif
endif endif
# Shell # Shell

View File

@ -77,6 +77,7 @@ host:
@$(call echo,Make $@) @$(call echo,Make $@)
@echo HOST_OS: $(HOST_OS) @echo HOST_OS: $(HOST_OS)
@echo HOST_ARCH: $(HOST_ARCH) @echo HOST_ARCH: $(HOST_ARCH)
@echo HOST_NAME: $(HOST_NAME)
@echo SH: $(SH) @echo SH: $(SH)
@echo ECHO: $(ECHO) @echo ECHO: $(ECHO)
@echo FIND: $(FIND) @echo FIND: $(FIND)

View File

@ -56,7 +56,26 @@ fi
fi fi
HOST_NAME="$HOST_OS"
if [ "$HOST_OS" = "Win" ]; then
_UNAME_S=$(uname -s)
if [ -n "$_UNAME_S" ]; then
if _host_contains_ "$_UNAME_S" "MINGW"; then
HOST_NAME="MINGW"
elif _host_contains_ "$_UNAME_S" "MSYS"; then
HOST_NAME="MSYS"
fi
fi
elif [ "$HOST_OS" = "Linux" ]; then
_UNAME_A=$(uname -a)
if _host_contains_ "$_UNAME_A" "tegra\|jetsonbot"; then
HOST_NAME="Tegra"
fi
fi
if [ -n "${_VERBOSE_}" ]; then if [ -n "${_VERBOSE_}" ]; then
echo "-- HOST_OS: $HOST_OS" echo "-- HOST_OS: $HOST_OS"
echo "-- HOST_ARCH: $HOST_ARCH" echo "-- HOST_ARCH: $HOST_ARCH"
echo "-- HOST_NAME: $HOST_NAME"
fi fi