commit:     060fb03cf25dca1aa7adf2659092a930e88b5dde
Author:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 24 21:16:23 2018 +0000
Commit:     Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
CommitDate: Sat Mar 24 21:16:43 2018 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=060fb03c

dev-util/mingw64-runtime: switch to --prefix=/usr (from --prefix=/)

A couple of changes:
- Allow dev-util/mingw64-runtime[headers-only] for cross-building case.
  One day crossdew won't need cross-${CTARGET}/mingw64-runtime packages
  and will be able to use dev-util/mingw64-runtime directly.
  This change is a step in that direction.
- Awitch to --prefix=/usr (from --prefix=/). This allow cross-building
  dev-util/mingw64-runtime itself and installing libraries into /usr/lib
  (instead of /lib).

Tested as:
- generated working toolchain:
  $ crossdev -t x86_64-w64-mingw32
- cross-built mingw64-runtime successfully:
  $ x86_64-w64-mingw32-emerge -v1 dev-util/mingw64-runtime

Package-Manager: Portage-2.3.24, Repoman-2.3.6

 .../mingw64-runtime-5.0.3-r2.ebuild                | 117 +++++++++++++++++++++
 1 file changed, 117 insertions(+)

diff --git a/dev-util/mingw64-runtime/mingw64-runtime-5.0.3-r2.ebuild 
b/dev-util/mingw64-runtime/mingw64-runtime-5.0.3-r2.ebuild
new file mode 100644
index 00000000000..e52536087f3
--- /dev/null
+++ b/dev-util/mingw64-runtime/mingw64-runtime-5.0.3-r2.ebuild
@@ -0,0 +1,117 @@
+# Copyright 1999-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=6
+
+export CBUILD=${CBUILD:-${CHOST}}
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} ]] ; then
+       if [[ ${CATEGORY} == cross-* ]] ; then
+               export CTARGET=${CATEGORY#cross-}
+       fi
+fi
+
+WANT_AUTOMAKE="1.15"
+
+inherit autotools flag-o-matic eutils
+
+DESCRIPTION="Free Win64 runtime and import library definitions"
+HOMEPAGE="http://mingw-w64.sourceforge.net/";
+SRC_URI="mirror://sourceforge/mingw-w64/mingw-w64/mingw-w64-release/mingw-w64-v${PV}.tar.bz2"
+
+LICENSE="BSD"
+SLOT="0"
+KEYWORDS="~amd64 ~x86"
+IUSE="headers-only idl libraries tools"
+RESTRICT="strip"
+
+S="${WORKDIR}/mingw-w64-v${PV}"
+
+PATCHES=(
+       "${FILESDIR}/${P}-build.patch"
+)
+
+is_crosscompile() {
+       [[ ${CHOST} != ${CTARGET} ]]
+}
+just_headers() {
+       use headers-only
+}
+alt_prefix() {
+       is_crosscompile && echo /usr/${CTARGET}
+}
+crt_with() {
+       just_headers && echo --without-$1 || echo --with-$1
+}
+crt_use_enable() {
+       just_headers && echo --without-$2 || use_enable "$@"
+}
+crt_use_with() {
+       just_headers && echo --without-$2 || use_with "$@"
+}
+
+pkg_setup() {
+       if [[ ${CBUILD} == ${CHOST} ]] && [[ ${CHOST} == ${CTARGET} ]] ; then
+               die "Invalid configuration"
+       fi
+}
+
+src_prepare() {
+       default
+       eautoreconf
+}
+
+src_configure() {
+       CHOST=${CTARGET} strip-unsupported-flags
+
+       if ! just_headers; then
+               mkdir "${WORKDIR}/headers"
+               pushd "${WORKDIR}/headers" > /dev/null
+               CHOST=${CTARGET} "${S}/configure" \
+                       --prefix="${T}/tmproot" \
+                       --with-headers \
+                       --without-crt \
+                       || die
+               popd > /dev/null
+               append-cppflags "-I${T}/tmproot/include"
+       fi
+
+       # By default configure tries to set --sysroot=${prefix}. We disable
+       # this behaviour with --with-sysroot=no to use gcc's sysroot default.
+       # That way we can cross-build mingw64-runtime with cross-emerge.
+       CHOST=${CTARGET} econf \
+               --with-sysroot=no \
+               --prefix="${EPREFIX}"$(alt_prefix)/usr \
+               --with-headers \
+               --enable-sdk \
+               $(crt_with crt) \
+               $(crt_use_enable idl idl) \
+               $(crt_use_with libraries libraries) \
+               $(crt_use_with tools tools) \
+               $(
+                       $(tc-getCPP ${CTARGET}) ${CPPFLAGS} -dM - < /dev/null | 
grep -q __MINGW64__ \
+                               && echo --disable-lib32 --enable-lib64 \
+                               || echo --enable-lib32 --disable-lib64
+               )
+}
+
+src_compile() {
+       if ! just_headers; then
+               emake -C "${WORKDIR}/headers" install
+       fi
+       default
+}
+
+src_install() {
+       default
+
+       if is_crosscompile ; then
+               # gcc is configured to look at specific hard-coded paths for 
mingw #419601
+               dosym usr /usr/${CTARGET}/mingw
+               dosym usr /usr/${CTARGET}/${CTARGET}
+               dosym usr/include /usr/${CTARGET}/sys-include
+       fi
+
+       env -uRESTRICT CHOST=${CTARGET} prepallstrip
+       rm -rf "${ED}/usr/share"
+}

Reply via email to