add TOOLCHAIN make flag for explicit toolchain prefix cross compiling (nw)

This commit is contained in:
Jeffrey Clark 2015-11-02 21:05:34 -06:00
parent 4e7f9e86e8
commit 36df7413dc
4 changed files with 49 additions and 29 deletions

View File

@ -75,6 +75,7 @@
# BUILDDIR = build
# TARGETOS = windows
# CROSS_BUILD = 1
# TOOLCHAIN =
# OVERRIDE_CC = cc
# OVERRIDE_CXX = c++
# OVERRIDE_LD = ld
@ -270,9 +271,9 @@ WINDRES := $(MINGW32)/bin/windres
endif
else
ifeq ($(ARCHITECTURE),_x64)
WINDRES := x86_64-w64-mingw32-windres
WINDRES := $(word 1,$(TOOLCHAIN) x86_64-w64-mingw32-)windres
else
WINDRES := i686-w64-mingw32-windres
WINDRES := $(word 1,$(TOOLCHAIN) i686-w64-mingw32-)windres
endif
endif
@ -407,6 +408,9 @@ endif
PARAMS+= --distro=$(DISTRO)
ifdef TOOLCHAIN
PARAMS += --TOOLCHAIN='$(TOOLCHAIN)'
endif
ifdef OVERRIDE_CC
PARAMS += --CC='$(OVERRIDE_CC)'
ifndef CROSS_BUILD
@ -777,12 +781,12 @@ endif
ifeq ($(OS),windows)
ifeq (posix,$(SHELLTYPE))
GCC_VERSION := $(shell $(subst @,,$(CC)) -dumpversion 2> /dev/null)
CLANG_VERSION := $(shell $(subst @,,$(CC)) --version 2> /dev/null| head -n 1 | grep clang | sed "s/^.*[^0-9]\([0-9]*\.[0-9]*\.[0-9]*\).*$$/\1/" | head -n 1)
GCC_VERSION := $(shell $(TOOLCHAIN)$(subst @,,$(CC)) -dumpversion 2> /dev/null)
CLANG_VERSION := $(shell $(TOOLCHAIN)$(subst @,,$(CC)) --version 2> /dev/null| head -n 1 | grep clang | sed "s/^.*[^0-9]\([0-9]*\.[0-9]*\.[0-9]*\).*$$/\1/" | head -n 1)
PYTHON_AVAILABLE := $(shell $(PYTHON) --version > /dev/null 2>&1 && echo python)
else
GCC_VERSION := $(shell $(subst @,,$(CC)) -dumpversion 2> NUL)
CLANG_VERSION := $(shell $(subst @,,$(CC)) --version 2> NUL| head -n 1 | grep clang | sed "s/^.*[^0-9]\([0-9]*\.[0-9]*\.[0-9]*\).*$$/\1/" | head -n 1)
GCC_VERSION := $(shell $(TOOLCHAIN)$(subst @,,$(CC)) -dumpversion 2> NUL)
CLANG_VERSION := $(shell $(TOOLCHAIN)$(subst @,,$(CC)) --version 2> NUL| head -n 1 | grep clang | sed "s/^.*[^0-9]\([0-9]*\.[0-9]*\.[0-9]*\).*$$/\1/" | head -n 1)
PYTHON_AVAILABLE := $(shell $(PYTHON) --version > NUL 2>&1 && echo python)
endif
ifdef MSBUILD
@ -799,9 +803,9 @@ MSBUILD_PARAMS += /p:Platform=win32
endif
endif
else
GCC_VERSION := $(shell $(subst @,,$(CC)) -dumpversion 2> /dev/null)
GCC_VERSION := $(shell $(TOOLCHAIN)$(subst @,,$(CC)) -dumpversion 2> /dev/null)
ifneq ($(OS),solaris)
CLANG_VERSION := $(shell $(subst @,,$(CC)) --version 2> /dev/null | head -n 1 | grep -e 'version [0-9]\.[0-9]\(\.[0-9]\)\?' -o | grep -e '[0-9]\.[0-9]\(\.[0-9]\)\?' -o | tail -n 1)
CLANG_VERSION := $(shell $(TOOLCHAIN)$(subst @,,$(CC)) --version 2> /dev/null | head -n 1 | grep -e 'version [0-9]\.[0-9]\(\.[0-9]\)\?' -o | grep -e '[0-9]\.[0-9]\(\.[0-9]\)\?' -o | tail -n 1)
endif
PYTHON_AVAILABLE := $(shell $(PYTHON) --version > /dev/null 2>&1 && echo python)
endif

View File

@ -197,6 +197,11 @@ newoption {
description = "LD replacement",
}
newoption {
trigger = "TOOLCHAIN",
description = "Toolchain prefix"
}
newoption {
trigger = "PROFILE",
description = "Enable profiling.",
@ -427,6 +432,10 @@ if(_OPTIONS["USE_BGFX"]~=nil) then
USE_BGFX = tonumber(_OPTIONS["USE_BGFX"])
end
if(_OPTIONS["TOOLCHAIN"] == nil) then
_OPTIONS['TOOLCHAIN'] = ""
end
GEN_DIR = MAME_BUILD_DIR .. "generated/"
if (_OPTIONS["target"] == nil) then return false end

View File

@ -106,7 +106,7 @@ end
function sdlconfigcmd()
if not _OPTIONS["SDL_INSTALL_ROOT"] then
return _OPTIONS["SDL_LIBVER"] .. "-config"
return _OPTIONS['TOOLCHAIN'] .. "pkg-config " .. _OPTIONS["SDL_LIBVER"]
else
return path.join(_OPTIONS["SDL_INSTALL_ROOT"],"bin",_OPTIONS["SDL_LIBVER"]) .. "-config"
end

View File

@ -4,6 +4,11 @@
--
local naclToolchain = ""
local toolchainPrefix = ""
if _OPTIONS['TOOLCHAIN'] then
toolchainPrefix = _OPTIONS["TOOLCHAIN"]
end
newoption {
trigger = "gcc",
@ -204,15 +209,18 @@ function toolchain(_buildDir, _subDir)
if not os.getenv("MINGW32") then
print("Set MINGW32 envrionment variable.")
end
premake.gcc.cc = "$(MINGW32)/bin/i686-w64-mingw32-gcc"
premake.gcc.cxx = "$(MINGW32)/bin/i686-w64-mingw32-g++"
if not toolchainPrefix then
toolchainPrefix = "$(MINGW32)/bin/i686-w64-mingw32-"
end
premake.gcc.cc = toolchainPrefix .. "gcc"
premake.gcc.cxx = toolchainPrefix .. "g++"
-- work around GCC 4.9.2 not having proper linker for LTO=1 usage
local version_4_ar = str_to_version(_OPTIONS["gcc_version"])
if (version_4_ar < 50000) then
premake.gcc.ar = "$(MINGW32)/bin/ar"
premake.gcc.ar = toolchainPrefix .. "ar"
end
if (version_4_ar >= 50000) then
premake.gcc.ar = "$(MINGW32)/bin/gcc-ar"
premake.gcc.ar = toolchainPrefix .. "gcc-ar"
end
location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-mingw32-gcc")
end
@ -221,20 +229,22 @@ function toolchain(_buildDir, _subDir)
if not os.getenv("MINGW64") then
print("Set MINGW64 envrionment variable.")
end
premake.gcc.cc = "$(MINGW64)/bin/x86_64-w64-mingw32-gcc"
premake.gcc.cxx = "$(MINGW64)/bin/x86_64-w64-mingw32-g++"
if not toolchainPrefix then
toolchainPrefix = "$(MINGW64)/bin/x86_64-w64-mingw32-"
end
premake.gcc.cc = toolchainPrefix .. "gcc"
premake.gcc.cxx = toolchainPrefix .. "g++"
-- work around GCC 4.9.2 not having proper linker for LTO=1 usage
local version_4_ar = str_to_version(_OPTIONS["gcc_version"])
if (version_4_ar < 50000) then
premake.gcc.ar = "$(MINGW64)/bin/ar"
premake.gcc.ar = toolchainPrefix .. "ar"
end
if (version_4_ar >= 50000) then
premake.gcc.ar = "$(MINGW64)/bin/gcc-ar"
premake.gcc.ar = toolchainPrefix .. "gcc-ar"
end
location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-mingw64-gcc")
end
if "mingw-clang" == _OPTIONS["gcc"] then
premake.gcc.cc = "clang"
premake.gcc.cxx = "clang++"
@ -283,18 +293,17 @@ function toolchain(_buildDir, _subDir)
if "osx" == _OPTIONS["gcc"] then
if os.is("linux") then
local osxToolchain = "x86_64-apple-darwin13-"
premake.gcc.cc = osxToolchain .. "clang"
premake.gcc.cxx = osxToolchain .. "clang++"
premake.gcc.ar = osxToolchain .. "ar"
premake.gcc.cc = toolchainPrefix .. "clang"
premake.gcc.cxx = toolchainPrefix .. "clang++"
premake.gcc.ar = toolchainPrefix .. "ar"
end
location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-osx")
end
if "osx-clang" == _OPTIONS["gcc"] then
premake.gcc.cc = "clang"
premake.gcc.cxx = "clang++"
premake.gcc.ar = "ar"
premake.gcc.cc = toolchainPrefix .. "clang"
premake.gcc.cxx = toolchainPrefix .. "clang++"
premake.gcc.ar = toolchainPrefix .. "ar"
location (_buildDir .. "projects/" .. _subDir .. "/".. _ACTION .. "-osx-clang")
end
@ -911,7 +920,6 @@ function toolchain(_buildDir, _subDir)
end
function strip()
configuration { "android-arm", "Release" }
postbuildcommands {
"$(SILENT) echo Stripping symbols.",
@ -939,13 +947,12 @@ function strip()
configuration { "mingw*", "x64", "Release" }
postbuildcommands {
"$(SILENT) echo Stripping symbols.",
"$(SILENT) $(MINGW64)/bin/strip -s \"$(TARGET)\"",
"$(SILENT) " .. (_OPTIONS['TOOLCHAIN'] and toolchainPrefix or "$(MINGW64)/bin/") .. "strip -s \"$(TARGET)\"",
}
configuration { "mingw*", "x32", "Release" }
postbuildcommands {
"$(SILENT) echo Stripping symbols.",
"$(SILENT) $(MINGW32)/bin/strip -s \"$(TARGET)\""
"$(SILENT) " .. (_OPTIONS['TOOLCHAIN'] and toolchainPrefix or "$(MINGW32)/bin/") .. "strip -s \"$(TARGET)\"",
}
configuration { "pnacl" }