From 3e74dab07621a902c36a32b8f17ba146f7d36ddf Mon Sep 17 00:00:00 2001 From: John Zhao Date: Fri, 9 Mar 2018 14:10:42 +0800 Subject: [PATCH] Optimize host name --- CommonDefs.mk | 60 ++++++++++++++++++++++++------------------ Makefile | 1 + scripts/common/host.sh | 19 +++++++++++++ 3 files changed, 54 insertions(+), 26 deletions(-) diff --git a/CommonDefs.mk b/CommonDefs.mk index 43532d7..6011d86 100644 --- a/CommonDefs.mk +++ b/CommonDefs.mk @@ -31,13 +31,6 @@ else endif endif -UNAME_S := $(shell uname -s) -ifneq ($(UNAME_S),) -ifneq ($(findstring MINGW,$(UNAME_S)),) - HOST_OS := MinGW -endif -endif - else UNAME_S := $(shell uname -s) @@ -46,7 +39,7 @@ ifneq ($(findstring Linux,$(UNAME_S)),) else ifneq ($(findstring Darwin,$(UNAME_S)),) HOST_OS := Mac else ifneq ($(findstring MINGW,$(UNAME_S)),) - HOST_OS := MinGW + HOST_OS := Win else ifneq ($(findstring MSYS,$(UNAME_S)),) # Need MSYS on Windows HOST_OS := Win @@ -74,7 +67,16 @@ endif endif 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) ifneq ($(findstring tegra,$(UNAME_A)),) HOST_NAME := Tegra @@ -97,16 +99,18 @@ SH := $(SHELL) ECHO := echo -e FIND := $(shell ./scripts/getfind.sh) -ifeq ($(HOST_OS),MinGW) - CC := x86_64-w64-mingw32-gcc - CXX := x86_64-w64-mingw32-g++ - MAKE := mingw32-make - BUILD := $(MAKE) -else ifeq ($(HOST_OS),Win) - CC := cl - CXX := cl - MAKE := make - BUILD := msbuild.exe ALL_BUILD.vcxproj /property:Configuration=Release +ifeq ($(HOST_OS),Win) + ifeq ($(HOST_NAME),MinGW) + CC := x86_64-w64-mingw32-gcc + CXX := x86_64-w64-mingw32-g++ + MAKE := mingw32-make + BUILD := $(MAKE) + else + CC := cl + CXX := cl + MAKE := make + BUILD := msbuild.exe ALL_BUILD.vcxproj /property:Configuration=Release + endif else # mac & linux # Set realpath for linux because of compiler not found with wrong path when cmake again @@ -131,8 +135,12 @@ endif ifneq ($(CXX),) CMAKE := $(CMAKE) -DCMAKE_CXX_COMPILER=$(CXX) 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) endif endif @@ -142,12 +150,11 @@ CMAKE_OPTIONS := #CMAKE_OPTIONS += -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON CMAKE_OPTIONS_AFTER := -ifeq ($(HOST_OS),MinGW) - CMAKE += -G "MinGW Makefiles" -endif - 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") ifeq (15,$(VS_VERSION)) CMAKE += -G "Visual Studio 15 2017 Win64" @@ -167,6 +174,7 @@ ifeq ($(HOST_ARCH),x64) $(call mkinfo,"Connot specify Visual Studio Win64") endif endif + endif # Shell diff --git a/Makefile b/Makefile index 70b79df..7a63ffb 100644 --- a/Makefile +++ b/Makefile @@ -77,6 +77,7 @@ host: @$(call echo,Make $@) @echo HOST_OS: $(HOST_OS) @echo HOST_ARCH: $(HOST_ARCH) + @echo HOST_NAME: $(HOST_NAME) @echo SH: $(SH) @echo ECHO: $(ECHO) @echo FIND: $(FIND) diff --git a/scripts/common/host.sh b/scripts/common/host.sh index f841f9b..3497cb2 100755 --- a/scripts/common/host.sh +++ b/scripts/common/host.sh @@ -56,7 +56,26 @@ 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 echo "-- HOST_OS: $HOST_OS" echo "-- HOST_ARCH: $HOST_ARCH" + echo "-- HOST_NAME: $HOST_NAME" fi