summaryrefslogtreecommitdiffstats
path: root/MinGW-w64
diff options
context:
space:
mode:
author Eric Hameleers <alien@slackware.com>2020-09-24 19:47:56 +0000
committer Eric Hameleers <alien@slackware.com>2020-09-24 19:47:56 +0000
commit9f4e7d637aa0dbe7749294a904524cc698f554fb (patch)
tree427a54fd4e61ead6ecba64e9339f50decbcc01c6 /MinGW-w64
parentc178429b63c5c7cc08d116411e8a2e841bd949d5 (diff)
downloadasb-9f4e7d637aa0dbe7749294a904524cc698f554fb.tar.gz
asb-9f4e7d637aa0dbe7749294a904524cc698f554fb.tar.xz
Initial revision
Diffstat (limited to 'MinGW-w64')
-rwxr-xr-xMinGW-w64/build/MinGW-w64.SlackBuild682
-rw-r--r--MinGW-w64/build/profile.d/mingw-w64.csh3
-rw-r--r--MinGW-w64/build/profile.d/mingw-w64.sh4
-rw-r--r--MinGW-w64/build/slack-desc19
4 files changed, 708 insertions, 0 deletions
diff --git a/MinGW-w64/build/MinGW-w64.SlackBuild b/MinGW-w64/build/MinGW-w64.SlackBuild
new file mode 100755
index 00000000..29a2189f
--- /dev/null
+++ b/MinGW-w64/build/MinGW-w64.SlackBuild
@@ -0,0 +1,682 @@
+#!/bin/sh
+# $Id$
+# Copyright 2020 Eric Hameleers, Eindhoven, NL
+# All rights reserved.
+#
+# Permission to use, copy, modify, and distribute this software for
+# any purpose with or without fee is hereby granted, provided that
+# the above copyright notice and this permission notice appear in all
+# copies.
+#
+# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+# IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
+# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+# -----------------------------------------------------------------------------
+#
+# This script pays hommage to the work of Tk-Glitch <ti3nou at gmail dot com>
+# who is the author of '(Mostly) Portable GCC/MinGW', this SlackBuild is a
+# simplified version of his work. For more info, see the git homepage at
+# https://github.com/Frogging-Family/mostlyportable-gcc
+#
+# -----------------------------------------------------------------------------
+#
+# Slackware SlackBuild script
+# ===========================
+# By: Eric Hameleers <alien@slackware.com>
+# For: MinGW-w64
+# Descr: Mininalist GCC to compile Windows binaries
+# URL: http://mingw-w64.org/doku.php
+# Build needs:
+# Needs:
+# Changelog:
+# 7.0.0_gcc9.3.0-1:
+# 21/Sep/2020 by Eric Hameleers <alien@slackware.com>
+# * Initial build.
+#
+# Run 'sh MinGW-w64.SlackBuild' to build a Slackware package.
+# The package (.t?z) and .txt file as well as build logs are created in /tmp .
+# Install the package using 'installpkg' or 'upgradepkg --install-new'.
+#
+# -----------------------------------------------------------------------------
+
+PRGNAM=MinGW-w64
+BUILD=${BUILD:-1}
+NUMJOBS=${NUMJOBS:-" -j$(nproc) "}
+TAG=${TAG:-alien}
+
+BINUTILS_DOCS="COPYING* ChangeLog.linux MAI* README*"
+GCC_DOCS="COPYING* ChangeLog* INSTALL LAST_UPDATED MAINTAINERS \
+ NEWS README*"
+MINGW_DOCS="AUTHORS COPYING* DISCLAIMER*"
+
+# Core tools:
+BINUTILS=2.35
+GCC=9.3.0
+MINGW=v7.0.0
+
+# Package version:
+VERSION=${VERSION:-${MINGW}_gcc${GCC}}
+
+# Support tools:
+GMP=6.2.0
+MPFR=4.1.0
+MPC=1.2.0
+OSL=0.9.2
+ISL=0.22.1
+CLOOG=0.20.0
+
+# Tool capabilities:
+GCC_EXCEPTIONS="dwarf2"
+GCC_LANGUAGES="c,c++,lto"
+MINGW_LANGUAGES="c,c++,lto,objc,obj-c++"
+WIN32_THREADS="false"
+
+# Arguments for the MinGW gcc compilation:
+if [ "$GCC_EXCEPTIONS" == "dwarf2" ]; then
+ EXCEPTIONS_ARGS="--disable-sjlj-exceptions --with-dwarf2"
+else
+ EXCEPTIONS_ARGS="--disable-dw2-exceptions"
+fi
+if [ "$WIN32_THREADS" == "true" ]; then
+ WIN32THREADS_ARGS="--enable-threads=win32"
+else
+ WIN32THREADS_ARGS="--enable-threads=posix"
+fi
+
+# Where do we look for sources?
+SRCDIR=$(cd $(dirname $0); pwd)
+
+# Place to build (TMP) package (PKG) and output (OUTPUT) the program:
+# Note: OUTPUT should *not* be a subdirectory of TMP!
+TMP=${TMP:-/tmp/build}
+PKG=$TMP/package-$PRGNAM
+OUTPUT=${OUTPUT:-/tmp}
+
+# Where will our bootstrap gcc be installed:
+GCC_BOOTSTRAP_PATH="${TMP}/mingw_gcc_bootstrap"
+
+# Where will MinGW be installed:
+MINGW_OUTPUT_PATH="${PKG}/usr/mingw-w64-$VERSION"
+
+# If you want automatic download to work, supply a URL for 'SRCURL' below:
+SOURCE[0]="$SRCDIR/sources/mingw-w64-${MINGW}.tar.bz2"
+SRCURL[0]="https://sourceforge.net/projects/mingw-w64/files/mingw-w64/mingw-w64-release/mingw-w64-${MINGW}.tar.bz2"
+
+# Source tarballs and download locations:
+mkdir -p $SRCDIR/sources
+
+SOURCE[1]="$SRCDIR/sources/gcc-${GCC}.tar.xz"
+SRCURL[1]="ftp://ftp.gnu.org/gnu/gcc/gcc-${GCC}/gcc-${GCC}.tar.xz"
+
+SOURCE[2]="$SRCDIR/sources/binutils-${BINUTILS}.tar.gz"
+SRCURL[2]="https://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS}.tar.gz"
+
+SOURCE[3]="$SRCDIR/sources/gmp-${GMP}.tar.xz"
+SRCURL[3]="ftp://ftp.gnu.org/gnu/gmp/gmp-${GMP}.tar.xz"
+
+SOURCE[4]="$SRCDIR/sources/mpfr-${MPFR}.tar.xz"
+SRCURL[4]="ftp://ftp.gnu.org/gnu/mpfr/mpfr-${MPFR}.tar.xz"
+
+SOURCE[5]="$SRCDIR/sources/mpc-${MPC}.tar.gz"
+SRCURL[5]="ftp://ftp.gnu.org/gnu/mpc/mpc-${MPC}.tar.gz"
+
+SOURCE[6]="$SRCDIR/sources/isl-${ISL}.tar.xz"
+SRCURL[6]="http://isl.gforge.inria.fr/isl-${ISL}.tar.xz"
+
+SOURCE[7]="$SRCDIR/sources/osl-${OSL}.tar.gz"
+SRCURL[7]=" https://github.com/periscop/openscop/releases/download/${OSL}/osl-${OSL}.tar.gz"
+
+SOURCE[8]="$SRCDIR/sources/cloog-${CLOOG}.tar.gz"
+SRCURL[8]=" https://github.com/periscop/cloog/releases/download/cloog-${CLOOG}/cloog-${CLOOG}.tar.gz"
+
+
+##
+## --- with a little luck, you won't have to edit below this point --- ##
+##
+
+# Automatically determine the architecture we're building on:
+if [ -z "$ARCH" ]; then
+ case "$(uname -m)" in
+ i?86) ARCH=i586 ;;
+ arm*) readelf /usr/bin/file -A | egrep -q "Tag_CPU.*[4,5]" && ARCH=arm || ARCH=armv7hl ;;
+ # Unless $ARCH is already set, use uname -m for all other archs:
+ *) ARCH=$(uname -m) ;;
+ esac
+ export ARCH
+fi
+# Set CFLAGS/CXXFLAGS and LIBDIRSUFFIX:
+case "$ARCH" in
+ i?86) SLKCFLAGS="-O2 -march=${ARCH} -mtune=i686"
+ SLKLDFLAGS=""; LIBDIRSUFFIX=""
+ ;;
+ x86_64) SLKCFLAGS="-O2 -fPIC"
+ SLKLDFLAGS="-L/usr/lib64"; LIBDIRSUFFIX="64"
+ ;;
+ *) SLKCFLAGS=${SLKCFLAGS:-"-O2"}
+ SLKLDFLAGS=${SLKLDFLAGS:-""}; LIBDIRSUFFIX=${LIBDIRSUFFIX:-""}
+ ;;
+esac
+TARGET=${ARCH}-slackware-linux
+
+# Exit the script on errors:
+set -e
+trap 'echo "$0 FAILED at line ${LINENO}" | tee $OUTPUT/error-${PRGNAM}.log' ERR
+# Catch unitialized variables:
+set -u
+P1=${1:-1}
+
+# Save old umask and set to 0022:
+_UMASK_=$(umask)
+umask 0022
+
+# Create working directories:
+mkdir -p $OUTPUT # place for the package to be saved
+mkdir -p $TMP/tmp-$PRGNAM # location to build the source
+mkdir -p $PKG # place for the package to be built
+rm -rf $PKG/* # always erase old package's contents
+rm -rf $TMP/tmp-$PRGNAM/* # remove the remnants of previous build
+rm -rf $OUTPUT/{configure,make,install,error,makepkg,patch}-$PRGNAM.log
+ # remove old log files
+rm -rf $GCC_BOOTSTRAP_PATH # Remove other files created outside of $PKG
+
+# Source file availability:
+for (( i = 0; i < ${#SOURCE[*]}; i++ )) ; do
+ if ! [ -f ${SOURCE[$i]} ]; then
+ echo "Source '$(basename ${SOURCE[$i]})' not available yet..."
+ # Check if the $SRCDIR is writable at all - if not, download to $OUTPUT
+ [ -w "$SRCDIR" ] || SOURCE[$i]="$OUTPUT/$(basename ${SOURCE[$i]})"
+ if [ -f ${SOURCE[$i]} ]; then echo "Ah, found it!"; continue; fi
+ if ! [ "x${SRCURL[$i]}" == "x" ]; then
+ echo "Will download file to $(dirname $SOURCE[$i])"
+ wget --no-check-certificate -nv -T 20 -O "${SOURCE[$i]}" ${SRCURL[$i]} || true
+ if [ $? -ne 0 -o ! -s "${SOURCE[$i]}" ]; then
+ echo "Fail to download '$(basename ${SOURCE[$i]})'. Aborting the build."
+ mv -f "${SOURCE[$i]}" "${SOURCE[$i]}".FAIL
+ exit 1
+ fi
+ fi
+ if [ ! -f "${SOURCE[$i]}" -o ! -s "${SOURCE[$i]}" ]; then
+ echo "File '$(basename ${SOURCE[$i]})' not available. Aborting the build."
+ exit 1
+ fi
+ fi
+done
+
+if [ "$P1" == "--download" ]; then
+ echo "Download complete."
+ exit 0
+fi
+
+# --- PACKAGE BUILDING ---
+
+echo "++"
+echo "|| $PRGNAM-$VERSION"
+echo "++"
+
+echo Building ...
+export LDFLAGS="$SLKLDFLAGS"
+export CXXFLAGS="$SLKCFLAGS"
+export CFLAGS="$SLKCFLAGS"
+export CPPFLAGS="$SLKCFLAGS"
+
+# Used in all compilations:
+MINGW_TARGETS="i686-w64-mingw32 x86_64-w64-mingw32"
+COMMONCONFIG="--disable-shared --enable-static"
+
+# Build the supporting tools first, then build a custom gcc for our platform
+# and then build mingw-w64 binaries using our support tools and custom gcc:
+
+function build_support_tools() {
+ MY_DESTDIR=${1}
+
+ # gmp:
+ cd $TMP/tmp-$PRGNAM/gmp-${GMP}
+ ./configure \
+ --prefix=${MY_DESTDIR} \
+ ${COMMONCONFIG}
+ make ${NUMJOBS} || make || exit 1
+ make install || exit 1
+
+ # mpfr:
+ cd $TMP/tmp-$PRGNAM/mpfr-${MPFR}
+ ./configure \
+ --prefix=${MY_DESTDIR} \
+ --with-gmp=${MY_DESTDIR} \
+ ${COMMONCONFIG}
+ make ${NUMJOBS} || make || exit 1
+ make install || exit 1
+
+ # mpc:
+ cd $TMP/tmp-$PRGNAM/mpc-${MPC}
+ ./configure \
+ --prefix=${MY_DESTDIR} \
+ --with-gmp=${MY_DESTDIR} \
+ --with-mpfr=${MY_DESTDIR} \
+ ${COMMONCONFIG}
+ make ${NUMJOBS} || make || exit 1
+ make install || exit 1
+
+ # isl:
+ cd $TMP/tmp-$PRGNAM/isl-${ISL}
+ ./configure \
+ --prefix=${MY_DESTDIR} \
+ ${COMMONCONFIG}
+ make ${NUMJOBS} || make || exit 1
+ make install || exit 1
+
+} # end build_support_tools
+
+function build_support_tools_mingw() {
+ MY_DESTDIR=${1}
+
+ # osl:
+ cd $TMP/tmp-$PRGNAM/osl-${OSL}
+ ./configure \
+ --prefix=${MY_DESTDIR} \
+ --with-gmp=${MY_DESTDIR} \
+ ${COMMONCONFIG}
+ make ${NUMJOBS} || make || exit 1
+ make install || exit 1
+
+ # cloog:
+ cd $TMP/tmp-$PRGNAM/cloog-${CLOOG}
+ ./configure \
+ --prefix=${MY_DESTDIR} \
+ --with-isl=${MY_DESTDIR} \
+ --with-osl=${MY_DESTDIR} \
+ ${COMMONCONFIG}
+ make ${NUMJOBS} || make || exit 1
+ # Issues with parallism in installing docs:
+ make -i install
+
+} # end build_support_tools_mingw
+
+#
+# --- GCC ---
+#
+
+# We extract the sources twice (and remove them inbetween),
+# to build native GCC and MinGW in two separate stages:
+cd $TMP/tmp-$PRGNAM || exit 1
+echo "[GCC] Extracting the source archive(s) for $PRGNAM..."
+for (( i = 0; i < ${#SOURCE[*]}; i++ )) ; do
+ tar -xf ${SOURCE[$i]}
+done
+chown -R root:root *
+chmod -R u+w,go+r-w,a+rX-st *
+
+# Make the process use our tools as they get built:
+export PATH="${GCC_BOOTSTRAP_PATH}/bin:${GCC_BOOTSTRAP_PATH}/lib:${GCC_BOOTSTRAP_PATH}/include:${PATH}"
+
+# Build the support tools:
+build_support_tools ${GCC_BOOTSTRAP_PATH}
+
+# binutils:
+mkdir -p $TMP/tmp-$PRGNAM/binutils-build && cd $TMP/tmp-$PRGNAM/binutils-build
+$TMP/tmp-$PRGNAM/binutils-${BINUTILS}/configure \
+ --prefix=${GCC_BOOTSTRAP_PATH} \
+ --with-lib-path="${GCC_BOOTSTRAP_PATH}/lib" \
+ --enable-deterministic-archives \
+ --enable-gold \
+ --enable-ld=default \
+ --enable-lto \
+ --enable-plugins \
+ --enable-relro \
+ --enable-targets=x86_64-pep \
+ --enable-threads \
+ --disable-gdb \
+ --disable-werror \
+ --with-pic \
+ --with-system-zlib \
+ ${COMMONCONFIG}
+make ${NUMJOBS} configure-host || exit 1
+make ${NUMJOBS} tooldir=${GCC_BOOTSTRAP_PATH} || exit 1
+make install prefix=${GCC_BOOTSTRAP_PATH} tooldir=${GCC_BOOTSTRAP_PATH} || exit 1
+# Remove unwanted files:
+rm -f ${GCC_BOOTSTRAP_PATH}/share/man/man1/{dlltool,nlmconv,windres,windmc}*
+
+# gcc:
+mkdir -p $TMP/tmp-$PRGNAM/gcc-build && cd $TMP/tmp-$PRGNAM/gcc-build
+$TMP/tmp-$PRGNAM/gcc-${GCC}/configure \
+ --prefix=${GCC_BOOTSTRAP_PATH} \
+ --with-pkgversion='alienBOB' \
+ --enable-languages=${GCC_LANGUAGES} \
+ --disable-bootstrap \
+ --with-gcc-major-version-only \
+ --enable-linker-build-id \
+ --disable-libstdcxx-pch \
+ --without-included-gettext \
+ --enable-libgomp \
+ --enable-lto \
+ --enable-threads=posix \
+ --enable-tls \
+ --enable-nls \
+ --enable-clocale=gnu \
+ --enable-libstdcxx-time=yes \
+ --with-default-libstdcxx-abi=new \
+ --enable-gnu-unique-object \
+ --disable-vtable-verify \
+ --enable-plugin \
+ --enable-default-pie \
+ --with-target-system-zlib=auto \
+ --with-system-zlib \
+ --enable-multiarch \
+ --with-arch-32=i686 \
+ --with-abi=m64 \
+ --with-multilib-list=m32,m64 \
+ --enable-multilib \
+ --disable-werror \
+ --enable-checking=release \
+ --with-fpmath=sse \
+ --with-tune=generic \
+ --without-cuda-driver \
+ --with-isl=${GCC_BOOTSTRAP_PATH} \
+ --with-gmp=${GCC_BOOTSTRAP_PATH} \
+ --with-mpfr=${GCC_BOOTSTRAP_PATH} \
+ --with-mpc=${GCC_BOOTSTRAP_PATH} \
+ --enable-offload-targets=nvptx-none,hsa \
+ --build=${TARGET} \
+ --host=${TARGET} \
+ --target=${TARGET} \
+ || exit 1
+
+make ${NUMJOBS} || make || exit 1
+make install || exit 1
+ln -s gcc ${GCC_BOOTSTRAP_PATH}/bin/cc
+
+#libgcc:
+cd $TMP/tmp-$PRGNAM/gcc-build
+make -C ${TARGET}/libgcc install
+make -C ${TARGET}/32/libgcc install
+make -C libcpp install
+make -C gcc install-po
+make -C ${TARGET}/libgcc install-shared
+make -C ${TARGET}/32/libgcc install-shared
+rm -f ${GCC_BOOTSTRAP_PATH}/lib/gcc/${TARGET}/${GCC}/libgcc_eh.a
+rm -f ${GCC_BOOTSTRAP_PATH}/lib/gcc/${TARGET}/${GCC}/32/libgcc_eh.a
+for lib in \
+ libatomic \
+ libgomp \
+ libitm \
+ libquadmath \
+ libsanitizer/{a,l,ub,t}san \
+ libstdc++-v3/src \
+ libvtv; do
+ make -C ${TARGET}/$lib install-toolexeclibLTLIBRARIES
+done
+for lib in \
+ libatomic \
+ libgomp \
+ libitm \
+ libquadmath \
+ libsanitizer/{a,l,ub}san \
+ libstdc++-v3/src \
+ libvtv; do
+ make -C ${TARGET}/32/$lib install-toolexeclibLTLIBRARIES
+done
+make -C ${TARGET}/libstdc++-v3/po install
+
+#
+# --- MINGW ---
+#
+
+# We extract the sources twice (and remove them inbetween),
+# to build native GCC and MinGW in two separate stages:
+cd $TMP/tmp-$PRGNAM || exit 1
+rm -rf *
+echo "[MINGW] Extracting the source archive(s) for $PRGNAM..."
+for (( i = 0; i < ${#SOURCE[*]}; i++ )) ; do
+ tar -xf ${SOURCE[$i]}
+done
+chown -R root:root *
+chmod -R u+w,go+r-w,a+rX-st *
+
+# Make the process use our tools as they get built:
+export PATH="${GCC_BOOTSTRAP_PATH}/bin:${GCC_BOOTSTRAP_PATH}/lib:${GCC_BOOTSTRAP_PATH}/include:${MINGW_OUTPUT_PATH}/bin:${MINGW_OUTPUT_PATH}/lib:${MINGW_OUTPUT_PATH}/include:${PATH}"
+
+# Re-build the support tools, this time targeting MinGW:
+build_support_tools ${MINGW_OUTPUT_PATH}
+build_support_tools_mingw ${MINGW_OUTPUT_PATH}
+
+# mingw-w64-binutils:
+cd $TMP/tmp-$PRGNAM/binutils-${BINUTILS}
+# Do not install libiberty:
+sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in
+for _target in ${MINGW_TARGETS}; do
+ echo -e "Building ${_target} cross binutils"
+ mkdir -p $TMP/tmp-$PRGNAM/binutils-${_target} && cd $TMP/tmp-$PRGNAM/binutils-${_target}
+ $TMP/tmp-$PRGNAM/binutils-${BINUTILS}/configure \
+ --target="${_target}" \
+ --enable-lto \
+ --enable-plugins \
+ --enable-deterministic-archives \
+ --disable-multilib \
+ --disable-nls \
+ --disable-werror \
+ --prefix="${MINGW_OUTPUT_PATH}" \
+ ${COMMONCONFIG}
+ make ${NUMJOBS} || make || exit 1
+done
+for _target in ${MINGW_TARGETS}; do
+ echo -e "Installing ${_target} cross binutils"
+ cd $TMP/tmp-$PRGNAM/binutils-${_target}
+ make install || exit 1
+done
+
+# binutils docs:
+mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION/binutils
+( cd $TMP/tmp-$PRGNAM/binutils-${BINUTILS}
+ cp -a $BINUTILS_DOCS $PKG/usr/doc/$PRGNAM-$VERSION/binutils/ || true
+)
+
+# mingw-w64-headers:
+for _target in ${MINGW_TARGETS}; do
+ echo -e "Configuring ${_target} headers"
+ mkdir -p $TMP/tmp-$PRGNAM/headers-${_target} && cd $TMP/tmp-$PRGNAM/headers-${_target}
+ $TMP/tmp-$PRGNAM/mingw-w64-${MINGW}/mingw-w64-headers/configure \
+ --enable-sdk=all \
+ --enable-secure-api \
+ --host="${_target}" \
+ --prefix="${MINGW_OUTPUT_PATH}/${_target}"
+ make || exit 1
+done
+for _target in ${MINGW_TARGETS}; do
+ echo -e "Installing ${_target} headers"
+ cd $TMP/tmp-$PRGNAM/headers-${_target}
+ make install
+ rm ${MINGW_OUTPUT_PATH}/${_target}/include/pthread_signal.h
+ rm ${MINGW_OUTPUT_PATH}/${_target}/include/pthread_time.h
+ rm ${MINGW_OUTPUT_PATH}/${_target}/include/pthread_unistd.h
+done
+
+# mingw-w64-headers-bootstrap:
+_dummystring="/* Dummy header, which gets overriden, if winpthread library gets installed. */"
+mkdir -p $TMP/tmp-$PRGNAM/dummy/ && cd $TMP/tmp-$PRGNAM//dummy
+echo "${_dummystring}" > pthread_signal.h
+echo "${_dummystring}" > pthread_time.h
+echo "${_dummystring}" > pthread_unistd.h
+for _target in ${MINGW_TARGETS}; do
+ install -Dm644 $TMP/tmp-$PRGNAM/dummy/pthread_signal.h ${MINGW_OUTPUT_PATH}/${_target}/include/pthread_signal.h
+ install -Dm644 $TMP/tmp-$PRGNAM/dummy/pthread_time.h ${MINGW_OUTPUT_PATH}/${_target}/include/pthread_time.h
+ install -Dm644 $TMP/tmp-$PRGNAM/dummy/pthread_unistd.h ${MINGW_OUTPUT_PATH}/${_target}/include/pthread_unistd.h
+done
+
+# Use a separate src dir for mingw-w64-gcc-base:
+cp -r $TMP/tmp-$PRGNAM/gcc-${GCC} $TMP/tmp-$PRGNAM/gcc-${GCC}-base
+
+# mingw-w64-gcc-base:
+# Do not install libiberty:
+sed -i 's/install_to_$(INSTALL_DEST) //' $TMP/tmp-$PRGNAM/gcc-${GCC}-base/libiberty/Makefile.in
+for _target in ${MINGW_TARGETS}; do
+ echo -e "Building "${_target}" GCC C compiler"
+ mkdir -p $TMP/tmp-$PRGNAM/gcc-${GCC}-base-${_target} && cd $TMP/tmp-$PRGNAM/gcc-${GCC}-base-${_target}
+ $TMP/tmp-$PRGNAM/gcc-${GCC}-base/configure \
+ --target="${_target}" \
+ --enable-languages=c,lto \
+ --with-system-zlib \
+ --enable-lto \
+ --disable-nls \
+ --enable-version-specific-runtime-libs \
+ --disable-multilib \
+ --enable-checking=release \
+ --with-isl="${MINGW_OUTPUT_PATH}" \
+ --with-gmp="${MINGW_OUTPUT_PATH}" \
+ --with-mpfr="${MINGW_OUTPUT_PATH}" \
+ --with-mpc="${MINGW_OUTPUT_PATH}" \
+ --prefix="${MINGW_OUTPUT_PATH}" \
+ ${EXCEPTIONS_ARGS} \
+ ${COMMONCONFIG} \
+ || exit 1
+ make ${NUMJOBS} all-gcc || make all-gcc || exit 1
+done
+for _target in ${MINGW_TARGETS}; do
+ echo -e "Installing ${_target} GCC C compiler"
+ cd $TMP/tmp-$PRGNAM/gcc-${GCC}-base-"${_target}"
+ make install-gcc
+ strip ${MINGW_OUTPUT_PATH}/bin/${_target}-* || true
+ strip ${MINGW_OUTPUT_PATH}/libexec/gcc/${_target}/${GCC}/{cc1,collect2,lto*} || true
+done
+
+# mingw-w64-crt:
+for _target in ${MINGW_TARGETS}; do
+ echo -e "Building ${_target} CRT"
+ if [ "${_target}" == "i686-w64-mingw32" ]; then
+ _crt_configure_args="--disable-lib64 --enable-lib32"
+ elif [ "${_target}" == "x86_64-w64-mingw32" ]; then
+ _crt_configure_args="--disable-lib32 --enable-lib64"
+ fi
+ mkdir -p $TMP/tmp-$PRGNAM/crt-${_target} && cd $TMP/tmp-$PRGNAM/crt-${_target}
+ $TMP/tmp-$PRGNAM/mingw-w64-${MINGW}/mingw-w64-crt/configure \
+ --host="${_target}" \
+ --enable-wildcard \
+ ${_crt_configure_args} \
+ --prefix=${MINGW_OUTPUT_PATH}/${_target}
+ make ${NUMJOBS} || make || exit 1
+done
+for _target in ${MINGW_TARGETS}; do
+ echo -e "Installing ${_target} crt"
+ cd $TMP/tmp-$PRGNAM/crt-${_target}
+ make install
+done
+
+# mingw-w64-winpthreads:
+for _target in ${MINGW_TARGETS}; do
+ echo -e "Building ${_target} winpthreads..."
+ mkdir -p $TMP/tmp-$PRGNAM/winpthreads-build-${_target} && cd $TMP/tmp-$PRGNAM/winpthreads-build-${_target}
+ $TMP/tmp-$PRGNAM/mingw-w64-${MINGW}/mingw-w64-libraries/winpthreads/configure \
+ --host="${_target}" \
+ --prefix=${MINGW_OUTPUT_PATH}/${_target} \
+ ${COMMONCONFIG}
+ make ${NUMJOBS} || make || exit 1
+done
+for _target in ${MINGW_TARGETS}; do
+ cd $TMP/tmp-$PRGNAM/winpthreads-build-${_target}
+ make install || exit 1
+ ${_target}-strip --strip-unneeded ${MINGW_OUTPUT_PATH}/${_target}/bin/*.dll || true
+done
+
+# mingw-w64 docs:
+mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION/mingw-w64
+( cd $TMP/tmp-$PRGNAM/mingw-w64-${MINGW}
+ cp -a $MINGW_DOCS $PKG/usr/doc/$PRGNAM-$VERSION/mingw-w64/ || true
+)
+
+# mingw-w64-gcc:
+for _target in ${MINGW_TARGETS}; do
+ mkdir -p $TMP/tmp-$PRGNAM/gcc-build-${_target} && cd $TMP/tmp-$PRGNAM/gcc-build-${_target}
+ $TMP/tmp-$PRGNAM/gcc-${GCC}/configure \
+ --with-pkgversion='alienBOB' \
+ --target="${_target}" \
+ --libexecdir=${MINGW_OUTPUT_PATH}/lib \
+ --enable-languages=${MINGW_LANGUAGES} \
+ --disable-shared \
+ --enable-fully-dynamic-string \
+ --enable-libstdcxx-time=yes \
+ --enable-libstdcxx-filesystem-ts=yes \
+ --with-system-zlib \
+ --enable-cloog-backend=isl \
+ --enable-lto \
+ --enable-libgomp \
+ --disable-multilib \
+ --enable-checking=release \
+ --with-isl="${MINGW_OUTPUT_PATH}" \
+ --with-gmp="${MINGW_OUTPUT_PATH}" \
+ --with-mpfr="${MINGW_OUTPUT_PATH}" \
+ --with-mpc="${MINGW_OUTPUT_PATH}" \
+ --prefix="${MINGW_OUTPUT_PATH}" \
+ ${EXCEPTIONS_ARGS} \
+ ${WIN32THREADS_ARGS} \
+ || exit 1
+ make ${NUMJOBS} || make || exit 1
+done
+for _target in ${MINGW_TARGETS}; do
+ cd $TMP/tmp-$PRGNAM/gcc-build-${_target}
+ make install || exit 1
+ ${_target}-strip ${MINGW_OUTPUT_PATH}/${_target}/lib/*.dll || true
+ strip ${MINGW_OUTPUT_PATH}/bin/${_target}-* || true
+ strip ${MINGW_OUTPUT_PATH}/lib/gcc/${_target}/${GCC}/{cc1*,collect2,lto*} || true
+ ln -s ${_target}-gcc ${MINGW_OUTPUT_PATH}/bin/${_target}-cc
+ # Move dlls to the correct location:
+ mkdir -p ${MINGW_OUTPUT_PATH}/${_target}/bin/
+ mv ${MINGW_OUTPUT_PATH}/${_target}/lib/*.dll ${MINGW_OUTPUT_PATH}/${_target}/bin/ || true
+done
+for _binaries in ${MINGW_OUTPUT_PATH}/bin/*; do
+ if [[ "$_binaries" != *"eu"* ]]; then
+ strip $_binaries || true
+ fi
+done
+# Remove unnecessary files:
+rm -rf ${MINGW_OUTPUT_PATH}/share
+rm -f ${MINGW_OUTPUT_PATH}/lib/libcc1.*
+# Create lto plugin link:
+mkdir -p ${MINGW_OUTPUT_PATH}/lib/bfd-plugins
+ln -sf ../gcc/x86_64-w64-mingw32/${GCC}/liblto_plugin.so ${MINGW_OUTPUT_PATH}/lib/bfd-plugins/liblto_plugin.so
+
+# gcc docs:
+mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION/gcc
+( cd $TMP/tmp-$PRGNAM/gcc-${GCC}
+ cp -a $GCC_DOCS $PKG/usr/doc/$PRGNAM-$VERSION/gcc/ || true
+)
+
+#
+# --- DONE ---
+#
+
+# Add profile scripts to modify the $PATH:
+mkdir -p $PKG/etc/profile.d
+cat $SRCDIR/profile.d/mingw-w64.sh | sed -e "s/@@VERSION@@/$VERSION/" \
+ > $PKG/etc/profile.d/mingw-w64.sh
+cat $SRCDIR/profile.d/mingw-w64.csh | sed -e "s/@@VERSION@@/$VERSION/" \
+ > $PKG/etc/profile.d/mingw-w64.csh
+chmod 0755 $PKG/etc/profile.d/mingw-w64.*
+
+# Add documentation:
+mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
+cat $SRCDIR/$(basename $0) > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
+chown -R root:root $PKG/usr/doc/$PRGNAM-$VERSION
+find $PKG/usr/doc -type f -exec chmod 644 {} \;
+
+# Add a package description:
+mkdir -p $PKG/install
+cat $SRCDIR/slack-desc > $PKG/install/slack-desc
+
+# Build the package:
+cd $PKG
+makepkg --linkadd y --chown n $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE:-tgz} 2>&1 | tee $OUTPUT/makepkg-${PRGNAM}.log
+cd $OUTPUT
+md5sum ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE:-tgz} > ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE:-tgz}.md5
+cd -
+cat $PKG/install/slack-desc | grep "^${PRGNAM}" > $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.txt
+
+# Restore the original umask:
+umask ${_UMASK_}
+
diff --git a/MinGW-w64/build/profile.d/mingw-w64.csh b/MinGW-w64/build/profile.d/mingw-w64.csh
new file mode 100644
index 00000000..6aa91715
--- /dev/null
+++ b/MinGW-w64/build/profile.d/mingw-w64.csh
@@ -0,0 +1,3 @@
+#!/bin/csh
+setenv PATH ${PATH}:/usr/mingw-w64-@@VERSION@@/bin
+
diff --git a/MinGW-w64/build/profile.d/mingw-w64.sh b/MinGW-w64/build/profile.d/mingw-w64.sh
new file mode 100644
index 00000000..da7b48a6
--- /dev/null
+++ b/MinGW-w64/build/profile.d/mingw-w64.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+PATH=$PATH:/usr/mingw-w64-@@VERSION@@/bin
+export PATH
+
diff --git a/MinGW-w64/build/slack-desc b/MinGW-w64/build/slack-desc
new file mode 100644
index 00000000..9cbbb23b
--- /dev/null
+++ b/MinGW-w64/build/slack-desc
@@ -0,0 +1,19 @@
+# HOW TO EDIT THIS FILE:
+# The "handy ruler" below makes it easier to edit a package description. Line
+# up the first '|' above the ':' following the base package name, and the '|'
+# on the right side marks the last column you can put a character in. You must
+# make exactly 11 lines for the formatting to be correct. It's also
+# customary to leave one space after the ':' except on otherwise blank lines.
+
+ |-----handy-ruler------------------------------------------------------|
+MinGW-w64: MinGW-w64 (Mininalist GCC to compile Windows binaries)
+MinGW-w64:
+MinGW-w64: Mingw-w64 is an advancement of the original mingw.org project,
+MinGW-w64: created to support the GCC compiler on Windows systems.
+MinGW-w64: It has forked it in 2007 in order to provide support
+MinGW-w64: for 64 bits and new APIs.
+MinGW-w64:
+MinGW-w64:
+MinGW-w64:
+MinGW-w64: See also: http://mingw-w64.org/doku.php
+MinGW-w64: