From 1178fc190bc51a9a068f03f36b37c65c16f71542 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 6 Aug 2020 19:36:19 +0200 Subject: [PATCH] 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 --- etc/config.csh/settings | 12 +++++++++++- etc/config.sh/settings | 13 +++++++++++-- wmake/src/Allmake | 21 ++++++++++++++------- wmake/src/Makefile | 29 ++++++++++------------------- 4 files changed, 46 insertions(+), 29 deletions(-) diff --git a/etc/config.csh/settings b/etc/config.csh/settings index ca3490032f..09be3c5a47 100644 --- a/etc/config.csh/settings +++ b/etc/config.csh/settings @@ -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 diff --git a/etc/config.sh/settings b/etc/config.sh/settings index 69ad56b385..327b21f8fc 100644 --- a/etc/config.sh/settings +++ b/etc/config.sh/settings @@ -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. diff --git a/wmake/src/Allmake b/wmake/src/Allmake index 9e78c5eb52..406daf115a 100755 --- a/wmake/src/Allmake +++ b/wmake/src/Allmake @@ -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 #------------------------------------------------------------------------------ diff --git a/wmake/src/Makefile b/wmake/src/Makefile index 2b602f11c1..f53f29f50f 100644 --- a/wmake/src/Makefile +++ b/wmake/src/Makefile @@ -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 . +# 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