#!/bin/sh # $Id: MinGW-w64.SlackBuild,v 1.9 2024/07/24 04:38:09 root Exp root $ # Copyright 2020, 2021, 2023, 2024 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 # who is the author of '(Mostly) Portable GCC/MinGW', this SlackBuild is an # adapted version of his work, adding support for a 32bit OS. # For more info, see the git homepage at: # https://github.com/Frogging-Family/mostlyportable-gcc # # ----------------------------------------------------------------------------- # # Slackware SlackBuild script # =========================== # By: Eric Hameleers # 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 # * Initial build. # 8.0.0_gcc10.2.0-1: # 10/dec/2020 by Eric Hameleers # * Update. # 9.0.0_gcc11.2.0-1: # 22/dec/2021 by Eric Hameleers # * Update. # 10.0.0_gcc12.2.0-1: # 17/apr/2023 by Eric Hameleers # * Update. # 11.0.0_gcc13.1.0-1: # 23/jul/2024 by Eric Hameleers # * Update. # # 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.40 GCC=13.1.0 MINGW=v11.0.0 # Package version: VERSION=${VERSION:-${MINGW}_gcc${GCC}} # Support tools: GMP=6.3.0 MPFR=4.2.1 MPC=1.3.1 OSL=0.9.5 ISL=0.26 CLOOG=0.20.0 # Automatically determine the architecture we're building on: if [ -z "$ARCH" ]; then case "$(uname -m)" in i?86) ARCH=i686 ;; 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="-L/usr/lib"; LIBDIRSUFFIX="" MINGW_TARGETS="${ARCH}-w64-mingw32" ;; x86_64) SLKCFLAGS="-O2 -fPIC" SLKLDFLAGS="-L/usr/lib64"; LIBDIRSUFFIX="64" MINGW_TARGETS="i686-w64-mingw32 x86_64-w64-mingw32" ;; *) SLKCFLAGS=${SLKCFLAGS:-"-O2"} SLKLDFLAGS=${SLKLDFLAGS:-""}; LIBDIRSUFFIX=${LIBDIRSUFFIX:-""} MINGW_TARGETS="${ARCH}-w64-mingw32" ;; esac TARGET=${ARCH}-slackware-linux # You can chose to use the system gcc instead of compiling it to save some time: BUILD_GCC=${BUILD_GCC:-"YES"} # Tool capabilities: GCC_EXCEPTIONS="dwarf2" GCC_LANGUAGES="c,c++,lto" MINGW_LANGUAGES="c,c++,lto,objc,obj-c++" WIN32_THREADS="false" if [ "$ARCH" == "x86_64" ]; then BINUTILS_TARGETS="x86_64-pep" GCC_MULTI_ARCH="\ --with-arch-32=i686 \ --with-abi=m64 \ --with-multilib-list=m32,m64 \ --enable-multilib \ --enable-multiarch \ --enable-default-pie" else BINUTILS_TARGETS="i386-efi-pe" GCC_MULTI_ARCH="\ --with-arch=i686" fi # 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]="https://ftp.gnu.org/gnu/gmp/gmp-${GMP}.tar.xz" SOURCE[4]="$SRCDIR/sources/mpfr-${MPFR}.tar.xz" SRCURL[4]="https://ftp.gnu.org/gnu/mpfr/mpfr-${MPFR}.tar.xz" SOURCE[5]="$SRCDIR/sources/mpc-${MPC}.tar.gz" SRCURL[5]="https://ftp.gnu.org/gnu/mpc/mpc-${MPC}.tar.gz" SOURCE[6]="$SRCDIR/sources/isl-${ISL}.tar.xz" SRCURL[6]="https://libisl.sourceforge.io/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 --- ## ## # 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: 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}" MY_ARCH="${2:-""}" [ -z "$MY_ARCH" ] && BUILD_ARGS="" || BUILD_ARGS="--build=$MY_ARCH" # gmp: echo "-- gmp --" cd $TMP/tmp-$PRGNAM/gmp-${GMP} ./configure \ --prefix=${MY_DESTDIR} \ ${COMMONCONFIG} \ ${BUILD_ARGS} make ${NUMJOBS} || make || exit 1 make install || exit 1 # mpfr: echo "-- mpfr --" cd $TMP/tmp-$PRGNAM/mpfr-${MPFR} ./configure \ --prefix=${MY_DESTDIR} \ --with-gmp=${MY_DESTDIR} \ ${COMMONCONFIG} \ ${BUILD_ARGS} make ${NUMJOBS} || make || exit 1 make install || exit 1 # mpc: echo "-- mpc --" cd $TMP/tmp-$PRGNAM/mpc-${MPC} ./configure \ --prefix=${MY_DESTDIR} \ --with-gmp=${MY_DESTDIR} \ --with-mpfr=${MY_DESTDIR} \ ${COMMONCONFIG} \ ${BUILD_ARGS} make ${NUMJOBS} || make || exit 1 make install || exit 1 # isl: echo "-- isl --" cd $TMP/tmp-$PRGNAM/isl-${ISL} ./configure \ --prefix=${MY_DESTDIR} \ ${COMMONCONFIG} \ ${BUILD_ARGS} make ${NUMJOBS} || make || exit 1 make install || exit 1 } # end build_support_tools function build_support_tools_mingw() { MY_DESTDIR=${1} # osl: echo "-- 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: echo "-- 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 function untar_and_patch() { 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 # Fix errors in compilation: cd gcc-${GCC} cat $SRCDIR/patches/0020-libgomp-Don-t-hard-code-MS-printf-attributes.patch \ | patch -p1 --verbose || exit 1 sed -i libbacktrace/configure -e 's|\-Werror||g' || exit 1 cd .. chown -R root:root * chmod -R u+w,go+r-w,a+rX-st * } # end untar_and_patch if [ "$BUILD_GCC" == "YES" ]; then # # --- GCC --- # # We extract the sources twice (and remove them inbetween), # to build native GCC and MinGW in two separate stages: untar_and_patch || exit 1 cd $TMP/tmp-$PRGNAM || exit 1 # 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} ${TARGET} # binutils: echo "-- 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=${BINUTILS_TARGETS} \ --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}* if [ "$ARCH" != "x86_64" ]; then # Use the output of '${GCC_BOOTSTRAP_PATH}/bin/ld --verbose | grep SEARCH_DIR' # to see that this ld looks in a not-existing location, which we'll exploit. ln -s /usr ${GCC_BOOTSTRAP_PATH}/i686-pc-linux-gnu fi # gcc: echo "-- gcc --" mkdir -p $TMP/tmp-$PRGNAM/gcc-build && cd $TMP/tmp-$PRGNAM/gcc-build LDFLAGS="$LDFLAGS" \ LD="${GCC_BOOTSTRAP_PATH}/bin/ld" \ AR="${GCC_BOOTSTRAP_PATH}/bin/ar" \ $TMP/tmp-$PRGNAM/gcc-${GCC}/configure \ ${GCC_MULTI_ARCH} \ --prefix=${GCC_BOOTSTRAP_PATH} \ --with-pkgversion='alienBOB' \ --with-build-sysroot='/' \ --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 \ --with-target-system-zlib=auto \ --with-system-zlib \ --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,amdgcn \ --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: echo "-- libgcc --" cd $TMP/tmp-$PRGNAM/gcc-build make -C ${TARGET}/libgcc install make -C libcpp install make -C gcc install-po make -C ${TARGET}/libgcc install-shared rm -f ${GCC_BOOTSTRAP_PATH}/lib/gcc/${TARGET}/${GCC}/libgcc_eh.a if [ "$ARCH" == "x86_64" ]; then make -C ${TARGET}/32/libgcc install make -C ${TARGET}/32/libgcc install-shared rm -f ${GCC_BOOTSTRAP_PATH}/lib/gcc/${TARGET}/${GCC}/32/libgcc_eh.a fi for lib in \ libatomic \ libgomp \ libitm \ libquadmath \ libsanitizer/{a,l,ub}san \ libstdc++-v3/src \ libvtv; do make -C ${TARGET}/$lib install-toolexeclibLTLIBRARIES done if [ "$ARCH" == "x86_64" ]; then make -C ${TARGET}/libsanitizer/tsan install-toolexeclibLTLIBRARIES 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 fi make -C ${TARGET}/libstdc++-v3/po install fi # End $BUILD_GCC == YES # # --- MINGW --- # # We extract the sources twice (and remove them inbetween), # to build native GCC and MinGW in two separate stages: untar_and_patch || exit 1 cd $TMP/tmp-$PRGNAM || exit 1 # Make the process use our tools as they get built: if [ "$BUILD_GCC" == "YES" ]; then 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}" else export PATH="${MINGW_OUTPUT_PATH}/bin:${MINGW_OUTPUT_PATH}/lib:${MINGW_OUTPUT_PATH}/include:${PATH}" fi # Re-build the support tools, this time targeting MinGW: build_support_tools ${MINGW_OUTPUT_PATH} ${TARGET} build_support_tools_mingw ${MINGW_OUTPUT_PATH} # mingw-w64-binutils: echo "-- 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: echo "-- 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: echo "-- 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: echo "-- 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: echo "-- 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: echo "-- mingw-w64-crt --" for _target in ${MINGW_TARGETS}; do echo -e "Building ${_target} CRT" if [ "${_target}" == "x86_64-w64-mingw32" ]; then _crt_configure_args="--disable-lib32 --enable-lib64" else _crt_configure_args="--disable-lib64 --enable-lib32" 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: echo "-- 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: echo "-- 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: echo "-- 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/${ARCH}-w64-mingw32/${GCC}/liblto_plugin.so ${MINGW_OUTPUT_PATH}/lib/bfd-plugins/liblto_plugin.so # gcc docs: echo "-- 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.* # Don't ship .la files: rm -f $PKG/{,usr/}lib${LIBDIRSUFFIX}/*.la # 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:-txz} 2>&1 | tee $OUTPUT/makepkg-${PRGNAM}.log cd $OUTPUT md5sum ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE:-txz} > ${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.${PKGTYPE:-txz}.md5 cd - cat $PKG/install/slack-desc | grep "^${PRGNAM}" > $OUTPUT/${PRGNAM}-${VERSION}-${ARCH}-${BUILD}${TAG}.txt # Restore the original umask: umask ${_UMASK_}