CONFIG: add runtime settings for mingw cross-compiled binaries

- WM_ARCH=win64 to indicate the runtime environment

ENH: cross-compile wmake toolchain for the target-side as well
This commit is contained in:
Mark Olesen 2020-08-06 19:36:19 +02:00
parent 44052de594
commit 1178fc190b
4 changed files with 46 additions and 29 deletions

View File

@ -90,12 +90,22 @@ case Linux:
endsw
breaksw
case Darwin: # Presume x86_64, with clang (not gcc) as system compiler
# Presume x86_64, with clang (not gcc) as system compiler
case Darwin:
setenv WM_ARCH darwin64
if ("$WM_COMPILER" == Gcc) setenv WM_COMPILER Clang
echo "Darwin support is clang/llvm only"
breaksw
# Presume x86_64, with mingw cross-compiled
case MINGW*:
case MSYS*:
WM_ARCH=win64
if ("$WM_COMPILER" == Gcc) setenv WM_COMPILER Mingw
setenv WM_COMPILER_LIB_ARCH 64 # Consistent with linux64Mingw
echo "Windows support (mingw64) is runtime only"
;;
case SunOS*:
setenv WM_ARCH solaris64
setenv WM_COMPILER_LIB_ARCH 64

View File

@ -82,18 +82,27 @@ Linux)
esac
;;
Darwin) # Presume x86_64, with clang (not gcc) as system compiler
# Presume x86_64, with clang (not gcc) as system compiler
Darwin)
WM_ARCH=darwin64
[ "$WM_COMPILER" = Gcc ] && WM_COMPILER=Clang
echo "Darwin support is clang/llvm only" 1>&2
;;
# Presume x86_64, with mingw cross-compiled
MINGW* | MSYS*)
WM_ARCH=win64
[ "$WM_COMPILER" = Gcc ] && WM_COMPILER=Mingw
export WM_COMPILER_LIB_ARCH=64 # Consistent with linux64Mingw
echo "Windows support (mingw64) is runtime only" 1>&2
;;
SunOS*)
WM_ARCH=solaris64
export WM_COMPILER_LIB_ARCH=64
;;
*) # An unsupported operating system
*)
/bin/cat << UNSUPPORTED 1>&2
===============================================================================
Operating system '$WM_ARCH' is unsupported by this OpenFOAM release.

View File

@ -21,19 +21,26 @@ then
exit 1
fi
case "$WM_COMPILER" in
Mingw*)
# Host wmake toolchain with system gcc (when cross-compiling)
if [ "${WM_COMPILER%Mingw}" != "$WM_COMPILER" ] && [ "$WM_ARCH" != win64 ]
then
# Mingw cross-compilation
# Toolchain for build (system gcc)
make \
WM_COMPILER=Gcc WM_COMPILER_TYPE=system \
WMAKE_BIN="${WM_PROJECT_DIR}/platforms/tools/${WM_ARCH}${WM_COMPILER}" \
"$@"
;;
*)
# Toolchain for target (mingw)
make \
WMAKE_BIN="${WM_PROJECT_DIR}/platforms/tools/win64${WM_COMPILER}" \
"$@"
else
# Regular wmake toolchain
make "$@"
;;
esac
fi
#------------------------------------------------------------------------------

View File

@ -6,29 +6,20 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2017-2019 OpenCFD Ltd.
# Copyright (C) 2017-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# File
# Makefile
#
# Description
# Makefile used to compile wmake utilities.
# Makefile for compiling wmake toolchain.
#
# Note
# The 'createCode' script is used to pre-generate the scanner code
# since ragel is not very prevalent.
#
#------------------------------------------------------------------------------
@ -55,7 +46,7 @@ WM_COMPILE_OPTION = Opt
GENERAL_RULES = $(WM_DIR)/rules/General
include $(GENERAL_RULES)/general
archHost := $(WM_ARCH)$(WM_COMPILER)
archBuild := $(WM_ARCH)$(WM_COMPILER)
archTarget := $(shell basename $(WMAKE_BIN))
@ -71,8 +62,8 @@ all: $(WMAKE_BIN)/lemon$(EXT_EXE) $(WMAKE_BIN)/wmkdepend$(EXT_EXE) message
old: $(WMAKE_BIN)/wmkdep$(EXT_EXE)
message:
ifneq ($(archHost),$(archTarget))
@echo "built wmake-bin ($(archTarget)) for $(archHost) host"
ifneq ($(archBuild),$(archTarget))
@echo "built wmake-bin ($(archTarget)) with $(archBuild)"
else
@echo "built wmake-bin ($(archTarget))"
endif