#!/bin/bash #ulimit -s unlimited shopt -s extglob # # GCC package build script (written by volkerdi@slackware.com) # # Copyright 2003, 2004 Slackware Linux, Inc., Concord, California, USA # Copyright 2005-2025 Patrick J. Volkerding, Sebeka, MN, USA # All rights reserved. # # Redistribution and use of this script, with or without modification, is # permitted provided that the following conditions are met: # # 1. Redistributions of this script must retain the above copyright # notice, this list of conditions and the following disclaimer. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 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 AUTHOR 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. # # # Modified by Stuart Winter for Slackware ARM. # 30-May-04 # Notes: # [1] Some parts of the gcc suite do not work for ARM so they are currently # missing; this isn't an oversight on my part - they simply don't work! ;-) # Record toolchain & other info for the build log: slackbuildinfo # Paths to skeleton port's source & real Slackware source tree: slackset_var_cwds # Determine the CFLAGS for the known architectures. If you specify -mtune=xscale # for ARM then the build breaks. # Also disable libspp (Stack Protector) because with gcc 4.2.3, code compiled # with it tends to segfault. Unfortunately, many newer releases of sources # check for -fstack-protector & use it if available; glibc is one of these. # # # LIBSUFFIX is set within slackkit's buildkit.sh library # case $ARCH in arm) # "--with-arch" sets the gcc defaults export SLKCFLAGS="$SLKCFLAGS -fPIC" export SLKCXXFLAGS="$SLKCFLAGS" export BOOT_LDFLAGS="-Wl,-z,relro" \ export LDFLAGS_FOR_TARGET="-Wl,-z,relro" \ export ARCH_CONFARGS="--with-arch=armv7-a \ --with-float=hard \ --with-fpu=vfpv3-d16 \ --with-tune=generic-armv7-a \ --disable-sjlj-exceptions " ;; # https://gcc.gnu.org/onlinedocs/gcc/AArch64-Options.html # Could also pick 'native' (or not set this option) but I prefer seeing what the baseline is here. aarch64) export ARCH_CONFARGS="--with-arch=armv8-a";; esac # To research: #--enable-fix-cortex-a53-835769 #--enable-fix-cortex-a53-843419 #--with-gcc-major-version-only \ #--enable-gnu-indirect-function #--enable-initfini-array \ #--enable-linker-build-id \ << looked into, what is the benefit of this over doing md5sum and comparing to a verified txz?! fill me in. #--with-linker-hash-style=gnu \ # We only use the slack-desc files from the Slackware source tree. #CWD=$SLACKSOURCE/d/gcc #if [ ! -d "$CWD" ]; then # echo "ERROR: Cannot find original Slackware source dir $CWD" # echo " you would miss the slack-desc files." # exit 1 #fi PORTCWD=$PWD # The new toolchain's name (set by the slackkit buildkit.sh library): TARGET=${SLK_ARCH_TARGET} # Temporary build location. This should *NOT* be a directory # path a non-root user could create later... # grr - this got annoying actually - deleting /gcc-foo -- and # nobody should have write access to /root. rm -rf $TMP/build-$PKGNAM* export TMPBUILD=$TMP/build-$PKGNAM export PKG=$TMP/package-$PKGNAM rm -rf $TMP/package-gcc* # clear other gcc named packages mkpkgdirs # Delete & re-create temporary directories then cd into $TMPBUILD # Python branch version (e.g. 2.6 , 2.7) we have installed on the # system currently: #PYTHONVER=$( python -c 'import sys; print sys.version[:3]' ) #echo "Building with Python branch version: $PYTHONVER" # This is the main DESTDIR target: PKG1=$TMP/package-gcc # These are the directories to build other packages in: PKG2=$TMP/package-gcc-g++ PKG3=$TMP/package-gcc-gfortran PKG4=$TMP/package-gcc-gnat PKG6=$TMP/package-gcc-objc PKG8=$TMP/package-gcc-go PKG10=$TMP/package-gdc PKG11=$TMP/package-gcc-gm2 PKG12=$TMP/package-gcc-rust mkdir -p $PKG{1,2,3,4,5,6,7,8,9,10,11,12}/install # Install the descriptions: ( cd $CWD install -vpm644 slack-desc.gcc $PKG1/install/slack-desc install -vpm644 slack-desc.gcc-g++ $PKG2/install/slack-desc install -vpm644 slack-desc.gcc-gfortran $PKG3/install/slack-desc install -vpm644 slack-desc.gcc-gnat $PKG4/install/slack-desc install -vpm644 slack-desc.gcc-objc $PKG6/install/slack-desc # install -vpm644 slack-desc.gcc-g++-gch $PKG7/install/slack-desc install -vpm644 slack-desc.gcc-go $PKG8/install/slack-desc install -vpm644 slack-desc.gcc-gdc $PKG10/install/slack-desc install -vpm644 slack-desc.gcc-gm2 $PKG11/install/slack-desc install -vpm644 slack-desc.gcc-rust $PKG12/install/slack-desc ) # Create doc dirs: mkdir -p $PKG{1,2,3,4,5,6,7,8,9,11,12}/usr/doc/gcc-$VERSION # Extract source: echo "Unpacking gcc source..." tar xf $CWD/gcc-[0-9]*\.[0-9]*.tar.!(*sign|*asc|*sig) #tar xf $PORTCWD/sources/gcc-[0-9].[0-9]*.tar.!(*sign|*asc|*sig) || exit 1 cd gcc-*/ || failextract slackhousekeeping ######################################################################################## # Apply patches from upstream Slackware: ######################################################################################## # Apply any required patches: for patch in $CWD/patches/*.patch $CWD/patches/*.diff ; do if [ -r "$patch" ]; then cat $patch | patch -p1 --verbose --backup --suffix=.orig || exit 1 fi done for patch in $CWD/patches/*.patch.gz $CWD/patches/*.diff.gz ; do if [ -r "$patch" ]; then zcat $patch | patch -p1 --verbose --backup --suffix=.orig || exit 1 fi done ######################################################################################## # Apply patches from Slackware ARM: ######################################################################################## # Jan-2021: # As SA64 is experimental, I'm going to add a patch set from git. # It's too late in the devel cycle to add these to ARM though as 15.0 is imminent. #if [ "$SLKPORTARCH" = "aarch64" ]; then # auto_apply_patch $PORTCWD/sources/git-updates.diff.xz || failpatch #fi # https://patchwork.openembedded.org/patch/80431/ # We need to change the dynamic linker to /lib64 as that's the # standard on 64bit platforms. # This isn't strictly necessary but see the comments in l/glibc # SlackBuild for more info. # This change only affects AArch64: sed -i 's?^#define GLIBC_DYNAMIC_LINKER \"/lib/ld-linux-aarch64%?#define GLIBC_DYNAMIC_LINKER \"/lib'"${LIBDIRSUFFIX}"'/ld-linux-aarch64%?g' \ gcc/config/aarch64/aarch64-linux.h || failpatch ####################################################################################### ## Install documentation into the individual packages # ####################################################################################### mkdir -p $PKG1/usr/doc/gcc-$VERSION cp -a \ COPYING* ChangeLog* FAQ INSTALL \ LAST_UPDATED MAINTAINERS NEWS \ README* *.html \ $PKG1/usr/doc/gcc-$VERSION # We will keep part of these, but they are really big... if [ -r ChangeLog ]; then DOCSDIR=$(echo $PKG1/usr/doc/gcc-$VERSION) cat ChangeLog | head -n 1000 > $DOCSDIR/ChangeLog touch -r ChangeLog $DOCSDIR/ChangeLog fi if [ -r NEWS ]; then DOCSDIR=$(echo $PKG1/usr/doc/gcc-$VERSION) cat NEWS | head -n 1500 > $DOCSDIR/NEWS touch -r NEWS $DOCSDIR/NEWS fi mkdir -p $PKG1/usr/doc/gcc-${VERSION}/gcc ( cd gcc || exit 0 cp -a \ ABOUT* COPYING* DATESTAMP DEV-PHASE LANG* ONEWS README* SERVICE \ $PKG1/usr/doc/gcc-$VERSION/gcc ) mkdir -p $PKG3/usr/doc/gcc-${VERSION}/gcc/fortran ( cd gcc/fortran || exit 0 if [ -r ChangeLog ]; then cat ChangeLog | head -n 1000 > $PKG3/usr/doc/gcc-$VERSION/gcc/fortran/ChangeLog touch -r ChangeLog $PKG3/usr/doc/gcc-$VERSION/gcc/fortran/ChangeLog fi ) mkdir -p $PKG4/usr/doc/gcc-${VERSION}/gcc/ada ( cd gcc/ada || exit 0 cp -a \ ChangeLog.tree-ssa \ $PKG4/usr/doc/gcc-$VERSION/gcc/ada if [ -r ChangeLog ]; then cat ChangeLog | head -n 1000 > $PKG4/usr/doc/gcc-$VERSION/gcc/ada/ChangeLog touch -r ChangeLog $PKG4/usr/doc/gcc-$VERSION/gcc/ada/ChangeLog fi ) mkdir -p $PKG6/usr/doc/gcc-${VERSION}/gcc/objc ( cd gcc/objc || exit 0 cp -a \ README* \ $PKG6/usr/doc/gcc-${VERSION}/gcc/objc if [ -r ChangeLog ]; then cat ChangeLog | head -n 1000 > $PKG6/usr/doc/gcc-${VERSION}/gcc/objc/ChangeLog touch -r ChangeLog $PKG6/usr/doc/gcc-${VERSION}/gcc/objc/ChangeLog fi ) mkdir -p $PKG6/usr/doc/gcc-${VERSION}/gcc/objcp ( cd gcc/objcp || exit 0 cp -a \ README* \ $PKG6/usr/doc/gcc-${VERSION}/gcc/objcp if [ -r ChangeLog ]; then cat ChangeLog | head -n 1000 > $PKG6/usr/doc/gcc-${VERSION}/gcc/objcp/ChangeLog touch -r ChangeLog $PKG6/usr/doc/gcc-${VERSION}/gcc/objcp/ChangeLog fi ) mkdir -p $PKG8/usr/doc/gcc-${VERSION}/gcc/go ( cd gcc/go || exit 0 if [ -r ChangeLog ]; then cat ChangeLog | head -n 1000 > $PKG8/usr/doc/gcc-${VERSION}/gcc/go/ChangeLog touch -r ChangeLog $PKG8/usr/doc/gcc-${VERSION}/gcc/go/ChangeLog fi cp -a \ README* THREADS* \ gofrontend/{LICENSE,PATENTS,README} \ $PKG8/usr/doc/gcc-${VERSION}/gcc/go ) mkdir -p $PKG10/usr/doc/gcc-${VERSION}/gcc/d ( cd gcc/d || exit 0 if [ -r ChangeLog ]; then cat ChangeLog | head -n 1000 > $PKG10/usr/doc/gcc-${VERSION}/gcc/d/ChangeLog touch -r ChangeLog $PKG10/usr/doc/gcc-${VERSION}/gcc/d/ChangeLog fi ) mkdir -p $PKG11/usr/doc/gcc-${VERSION}/gcc/m2 ( cd gcc/m2 || exit 0 if [ -r ChangeLog ]; then cat ChangeLog | head -n 1000 > $PKG11/usr/doc/gcc-${VERSION}/gcc/m2/ChangeLog touch -r ChangeLog $PKG11/usr/doc/gcc-${VERSION}/gcc/m2/ChangeLog fi cp -a \ COPYING* NEWS* README* \ $PKG11/usr/doc/gcc-${VERSION}/gcc/m2 ) mkdir -p $PKG12/usr/doc/gcc-${VERSION}/gcc/rust ( cd gcc/rust || exit 0 if [ -r ChangeLog ]; then cat ChangeLog | head -n 1000 > $PKG12/usr/doc/gcc-${VERSION}/gcc/rust/ChangeLog touch -r ChangeLog $PKG12/usr/doc/gcc-${VERSION}/gcc/rust/ChangeLog fi cp -a \ CONTRIBUTING* \ COPYING* NEWS* README* \ $PKG12/usr/doc/gcc-${VERSION}/gcc/rust ) mkdir -p $PKG3/usr/doc/gcc-${VERSION}/libgfortran ( cd libgfortran || exit 0 if [ -r ChangeLog ]; then cat ChangeLog | head -n 1000 > $PKG3/usr/doc/gcc-${VERSION}/libgfortran/ChangeLog touch -r ChangeLog $PKG3/usr/doc/gcc-${VERSION}/libgfortran/ChangeLog fi ) mkdir -p $PKG4/usr/doc/gcc-${VERSION}/libada ( cd libada || exit 0 if [ -r ChangeLog ]; then cat ChangeLog | head -n 1000 > $PKG4/usr/doc/gcc-${VERSION}/libada/ChangeLog touch -r ChangeLog $PKG4/usr/doc/gcc-${VERSION}/libada/ChangeLog fi ) mkdir -p $PKG1/usr/doc/gcc-${VERSION}/libgomp ( cd libgomp || exit 0 if [ -r ChangeLog ]; then cat ChangeLog | head -n 1000 > $PKG1/usr/doc/gcc-${VERSION}/libgomp/ChangeLog touch -r ChangeLog $PKG1/usr/doc/gcc-${VERSION}/libgomp/ChangeLog fi ) mkdir -p $PKG6/usr/doc/gcc-${VERSION}/libobjc ( cd libobjc || exit 0 if [ -r ChangeLog ]; then cat ChangeLog | head -n 1000 > $PKG6/usr/doc/gcc-${VERSION}/libobjc/ChangeLog touch -r ChangeLog $PKG6/usr/doc/gcc-${VERSION}/libobjc/ChangeLog fi cp -a \ README* THREADS* \ $PKG6/usr/doc/gcc-${VERSION}/libobjc ) mkdir -p $PKG2/usr/doc/gcc-${VERSION}/libstdc++-v3 ( cd libstdc++-v3 || exit 0 cp -a \ README* \ doc/html/faq.html \ $PKG2/usr/doc/gcc-${VERSION}/libstdc++-v3 if [ -r ChangeLog ]; then cat ChangeLog | head -n 1000 > $PKG2/usr/doc/gcc-${VERSION}/libstdc++-v3/ChangeLog touch -r ChangeLog $PKG2/usr/doc/gcc-${VERSION}/libstdc++-v3/ChangeLog fi ) ####################################################################################### ## Build GCC # ####################################################################################### echo "*************************" echo "*** Building main GCC ***" echo "*************************" mkdir gcc.build.lnx cd gcc.build.lnx # --enable-languages=c,c++,d,ada,fortran,go,lto,objc,obj-c++ \ # Configure to build Ada compiler (GNAT) if our Slackware environment is # self-hosted (e.g. not in the bootstrapping stages): if [ -f /var/lib/pkgtools/packages/gcc-gnat-[0-9]* ]; then # For the '--enable-languages' config option echo "Self-hosted Ada compiler found, will build GNAT" WITH_ADA="ada," else echo "Bootstrap mode: cannot build gcc-gnat - unable to self-host." WITH_ADA="" fi BOOT_CFLAGS="$SLKCFLAGS" \ STAGE1_CFLAGS="$SLKCFLAGS" \ CFLAGS="$SLKCFLAGS" \ CXXFLAGS="$SLKCXXFLAGS" \ LIBCFLAGS="$SLKCFLAGS" \ LIBCXXFLAGS="$SLKCXXFLAGS" \ GCJFLAGS="$SLKCFLAGS" \ ../configure $ARCH_CONFARGS \ --verbose \ \ --prefix=/usr \ --mandir=/usr/man \ --infodir=/usr/info \ --libdir=/usr/lib$LIBDIRSUFFIX \ \ --enable-bootstrap \ --enable-checking=release \ --enable-libstdcxx-dual-abi \ --enable-shared \ --enable-languages=${WITH_ADA}c,c++,d,fortran,go,lto,m2,objc,obj-c++,rust \ --enable-objc-gc \ --enable-threads=posix \ --enable-__cxa_atexit \ --enable-gnu-unique-object \ --enable-clocale=gnu \ --enable-plugin \ --enable-lto \ \ --with-arch-directory=$LIB_ARCH \ --with-system-zlib \ --with-gnu-ld \ --with-isl \ --with-default-libstdcxx-abi=new \ \ --disable-libunwind-exceptions \ --disable-libstdcxx-pch \ --disable-libssp \ --disable-werror \ --disable-gtktest \ --disable-install-libiberty \ \ --host=$TARGET \ --build=$TARGET \ --target=$TARGET || exit 1 # Start the build: # BOOT_CFLAGS="$SLKCFLAGS -fno-stack-protector" \ # STAGE1_CFLAGS="$SLKCFLAGS -fno-stack-protector" \ # Hard code the number of parallel jobs here rather than use $NUMJOBS # This is because the bootstrap compiler is built using distcc against the x86 cluster, but # the new compiler (built *from* the bootstrap compiler) is run natively, so -j22 # is a bit too much for a single ARM core. # We'll leave 1 core free to keep the machine running smoothly: export NUMJOBS="-j$(( $(nproc) -1 ))" make $NUMJOBS \ BOOT_CFLAGS="$SLKCFLAGS" \ STAGE1_CFLAGS="$SLKCFLAGS" \ CFLAGS="$SLKCFLAGS" \ CXXFLAGS="$SLKCXXFLAGS" \ LIBCFLAGS="$SLKCFLAGS" \ LIBCXXFLAGS="$SLKCXXFLAGS" \ bootstrap || make \ BOOT_CFLAGS="$SLKCFLAGS" \ STAGE1_CFLAGS="$SLKCFLAGS" \ CFLAGS="$SLKCFLAGS" \ CXXFLAGS="$SLKCXXFLAGS" \ LIBCFLAGS="$SLKCFLAGS" \ LIBCXXFLAGS="$SLKCXXFLAGS" \ bootstrap || exit 1 # Build GNAT if possible: if [ ! -z "$WITH_ADA" ]; then echo "*************************" echo "*** Building GCC GNAT ***" echo "*************************" ( cd gcc make $NUMJOBS gnatlib GNATLIBCFLAGS="$SLKCFLAGS" || make gnatlib GNATLIBCFLAGS="$SLKCFLAGS" || exit 1 CFLAGS="$SLKCFLAGS" \ CXXFLAGS="$SLKCXXFLAGS" \ make $NUMJOBS gnattools || make gnattools || exit 1 ) || exit 1 else echo "************* WARNING: Bootstrap mode: cannot build gcc-gnat - unable to self-host." fi # Build info pages: if [ -f /var/lib/pkgtools/packages/texinfo-[0-9]* ]; then make info || exit 1 else echo "Bootstrap mode: skipping building info pages" fi # Set GCCCHECK=something to run the tests if [ ! -z $GCCCHECK ]; then make check || exit 1 fi ####################################################################################### ## Install/package GCC # ####################################################################################### # To begin, install the whole thing into one package. We split up later. make install DESTDIR=$PKG1 || exit 1 # Move gdb pretty printers to the correct place mkdir -p $PKG1/usr/share/gdb/auto-load/usr/lib$LIBDIRSUFFIX mv $PKG1/usr/lib$LIBDIRSUFFIX/*-gdb.py \ $PKG1/usr/share/gdb/auto-load/usr/lib$LIBDIRSUFFIX/ # Be sure the "specs" file is installed. There was an issue with that on 4.1.1: if [ ! -r $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/${TARGET}/${VERSION}/specs ]; then echo "************************************************************************" echo "************************* MISSING SPECS FILE ***************************" echo "************************************************************************" echo "************************************************************************" set -x cat stage1-gcc/specs > $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/${TARGET}/${VERSION}/specs set +x fi # Make our 64bit gcc look for 32bit gcc binaries in ./32 subdirectory: if [ "$ARCH" = "aarch64" ]; then sed -i 's#;.\(:../lib !m64 m32;\)$#;32\1#' \ $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/${TARGET}/${VERSION}/specs fi make -i install-info DESTDIR=$PKG1 || exit 1 chmod 755 $PKG1/usr/lib${LIBDIRSUFFIX}/libgcc_s.so.1 # Fix stuff up: ( cd $PKG1/usr/info ; rm dir ; gzip -9 * ) ( cd $PKG1 # *not* ${LIBDIRSUFFIX} mkdir -p lib cd lib ln -sf /usr/bin/cpp . ) ( cd $PKG1/usr/bin mv g++ g++-gcc-$VERSION mv gcc gcc-$VERSION mv ${TARGET}-gfortran gfortran-gcc-$VERSION ln -sf g++-gcc-$VERSION g++ ln -sf gcc-$VERSION gcc ln -sf g++ c++ ln -sf gcc cc ln -sf gcc-$VERSION ${TARGET}-cc ln -sf gcc-$VERSION ${TARGET}-gcc ln -sf gcc-$VERSION ${TARGET}-gcc-$VERSION ln -sf gcc-ar ${TARGET}-gcc-ar ln -sf gcc-nm ${TARGET}-gcc-nm ln -sf gcc-ranlib ${TARGET}-gcc-ranlib ln -sf g++-gcc-$VERSION ${TARGET}-c++ ln -sf g++-gcc-$VERSION ${TARGET}-g++ ln -sf gfortran-gcc-$VERSION gfortran ln -sf gfortran-gcc-$VERSION ${TARGET}-gfortran ln -sf gfortran-gcc-$VERSION ${TARGET}-gfortran-$VERSION ln -sf gfortran-gcc-$VERSION ${TARGET}-g95 ln -sf gfortran g95 ln -sf gfortran f95 ln -sf gfortran-gcc-$VERSION ${TARGET}-g77 ln -sf gfortran g77 ln -sf gfortran f77 cat $CWD/c89.sh > c89 cat $CWD/c99.sh > c99 chmod 755 c89 c99 ) ( cd $PKG1/usr/man gzip -9 */* cd man1 ln -sf g++.1.gz c++.1.gz ln -sf gcc.1.gz cc.1.gz ) ## build an all-in-one txz package: #( # cd $PKG1; # makepkg -l y -c n $TMP/gcc-$VERSION-$ARCH-$BUILD.txz #) # Filter all .la files (thanks much to Mark Post for the sed script): ( cd $PKG1 for file in $(find . -type f -name "*.la") ; do cat $file | sed -e 's%-L/gcc-[[:graph:]]* % %g' > $TMPBUILD/tmp-la-file cat $TMPBUILD/tmp-la-file > $file done rm $TMPBUILD/tmp-la-file ) rm -f $PKG1/{,usr/}lib${LIBDIRSUFFIX}/*.la # Before we strip the binaries and move the contents in to separate packages, # we'll copy it all to a temporary location. # gcc-go fails rather than hangs, if it's unstripped; so we'll package this version. # as it'll be more useful to debug. #rsync -Pa $PKG1/ $TMPBUILD/gcc-not-stripped # Strip bloated binaries and libraries: ( cd $PKG1 find . -name "lib*so*" -exec strip --strip-unneeded "{}" \; find . -name "lib*so*" -exec patchelf --remove-rpath "{}" \; find . -name "lib*a" -exec strip -g "{}" \; strip --strip-unneeded usr/bin/* 2> /dev/null find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null ) # OK, time to split the big package where needed: # gcc-g++: echo "**************** Setting up $PKG2 ******************" ( cd $PKG2 mkdir -p usr/bin mv $PKG1/usr/bin/*++* usr/bin mkdir -p usr/include mv $PKG1/usr/include/c++ usr/include mkdir -p usr/lib${LIBDIRSUFFIX} mv $PKG1/usr/lib${LIBDIRSUFFIX}/*++* usr/lib${LIBDIRSUFFIX} mkdir -p usr/libexec/gcc/$TARGET/$VERSION mv $PKG1/usr/libexec/gcc/$TARGET/$VERSION/cc1plus usr/libexec/gcc/$TARGET/$VERSION/cc1plus mkdir -p usr/man/man1 mv $PKG1/usr/man/man1/*++* usr/man/man1 mkdir -p usr/share mv $PKG1/usr/share/gdb usr/share mkdir -p usr/share/gcc-$VERSION/python mv $PKG1/usr/share/gcc-$VERSION/python/libstdcxx usr/share/gcc-$VERSION/python ) # gcc-gfortran: echo "******************* Setting up $PKG3 ****************" ( cd $PKG3 mkdir -p usr/bin mv $PKG1/usr/bin/*gfortran* usr/bin mv $PKG1/usr/bin/*95* usr/bin mv $PKG1/usr/bin/*77* usr/bin # Doesn't this seem like a logical idea? ( cd usr/bin ; ln -sf gfortran-gcc-${VERSION} fortran ) mkdir -p usr/info mv $PKG1/usr/info/gfortran* usr/info mkdir -p usr/lib${LIBDIRSUFFIX} mv $PKG1/usr/lib${LIBDIRSUFFIX}/libgfortran* usr/lib${LIBDIRSUFFIX} mkdir -p usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION mv $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/finclude usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION mv $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/libgfortran* usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION mkdir -p usr/libexec/gcc/$TARGET/$VERSION mv $PKG1/usr/libexec/gcc/$TARGET/$VERSION/f951 usr/libexec/gcc/$TARGET/$VERSION/f951 mv $PKG1/usr/libexec/gcc/$TARGET/$VERSION/libgfortran* usr/libexec/gcc/$TARGET/$VERSION mkdir -p usr/man/man1 mv $PKG1/usr/man/man1/gfortran* usr/man/man1 ) # gcc-gnat: echo "***************** Setting up $PKG4 ****************" ( cd $PKG4 mkdir -p usr/bin mv $PKG1/usr/bin/gnat* usr/bin mv $PKG1/usr/bin/gpr* usr/bin mkdir -p usr/info mv $PKG1/usr/info/gnat* usr/info mkdir -p usr/libexec/gcc/$TARGET/$VERSION mv $PKG1/usr/libexec/gcc/$TARGET/$VERSION/gnat1 usr/libexec/gcc/$TARGET/$VERSION mkdir -p usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION mv $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/adainclude usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION mv $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/adalib usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION ) # gcc-objc: echo "******************* Setting up $PKG6 **********************" ( cd $PKG6 mkdir -p usr/lib${LIBDIRSUFFIX} mv $PKG1/usr/lib${LIBDIRSUFFIX}/libobjc* usr/lib${LIBDIRSUFFIX} mkdir -p usr/libexec/gcc/$TARGET/$VERSION mv $PKG1/usr/libexec/gcc/$TARGET/$VERSION/cc1obj usr/libexec/gcc/$TARGET/$VERSION mv $PKG1/usr/libexec/gcc/$TARGET/$VERSION/cc1objplus usr/libexec/gcc/$TARGET/$VERSION mkdir -p usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include mv $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include/objc usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include mv $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include/cc1objplus usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include ) ## NOTE: Thought about this, because the precompiled headers are so large. ## Probably easier to keep everything together, though. ## gcc-g++-gch (precompiled c++ headers) #echo "****************** Setting up $PKG7 **********************" #( cd $PKG7 # mkdir -p usr/include/c++/$VERSION/$TARGET/bits # mv $PKG2/usr/include/c++/$VERSION/$TARGET/bits/stdc++.h.gch usr/include/c++/$VERSION/$TARGET/bits #) # gcc-go: echo "******************* Setting up $PKG8 **********************" ( set -x cd $PKG8 mkdir -p usr/bin mv -fv $PKG1/usr/bin/*gccgo* usr/bin mv -fv $PKG1/usr/bin/go{,fmt} usr/bin mkdir -p usr/libexec/gcc/$TARGET/$VERSION mv -fv $PKG1/usr/libexec/gcc/$TARGET/$VERSION/{cgo,go1} usr/libexec/gcc/$TARGET/$VERSION mkdir -p usr/info mv -fv $PKG1/usr/info/gccgo.info.gz usr/info mkdir -p usr/lib${LIBDIRSUFFIX} mv -fv $PKG1/usr/lib${LIBDIRSUFFIX}/go usr/lib${LIBDIRSUFFIX} if [ -r $PKG1/usr/lib${LIBDIRSUFFIX}/libgo.la ]; then mv -fv $PKG1/usr/lib${LIBDIRSUFFIX}/libgo.la usr/lib${LIBDIRSUFFIX} fi mv -fv $PKG1/usr/lib${LIBDIRSUFFIX}/{libgo.so*,libgobegin.a,libgolibbegin.a} usr/lib${LIBDIRSUFFIX} || exit 1 # Don't package the (bloated) libgo.a. As a rule, we don't package static libraries. rm -fv $PKG1/usr/lib${LIBDIRSUFFIX}/libgo.a mkdir -p usr/man/man1 mv -fv $PKG1/usr/man/man1/gccgo.1.gz usr/man/man1 mv -fv $PKG1/usr/man/man1/go.1.gz usr/man/man1 mv -fv $PKG1/usr/man/man1/gofmt.1.gz usr/man/man1 # Find the equivalent files in the non-stripped $PKG1 and copy them over: if [ -d $TMPBUILD/gcc-not-stripped ]; then echo "**** TEMP HACK:::::: Copying unstripped gcc binaries to PKG8 : $PKG8 *****" cd $PKG8 # Overwrite the stripped version with the non-stripped version: find usr/ -type f | while read file ; do cp -dfav $TMPBUILD/gcc-not-stripped/$file $PKG8/$( dirname $file )/ ; done fi # Convert hard link to symlink because I prefer it: ln -rvfs $PKG8/usr/bin/{$TARGET-gccgo,gccgo} ) || exit 1 # gcc-gdc: ( echo "******************* Setting up $PKG10 **********************" cd $PKG10 mkdir -p usr/bin mv -fv $PKG1/usr/bin/gdc $PKG1/usr/bin/*-gdc usr/bin mkdir -p usr/lib${LIBDIRSUFFIX} mv -fv $PKG1/usr/lib${LIBDIRSUFFIX}/libgdruntime* usr/lib${LIBDIRSUFFIX} mv -fv $PKG1/usr/lib${LIBDIRSUFFIX}/libgphobos* usr/lib${LIBDIRSUFFIX} # Don't package the (bloated) libgphobos.a or libgdruntime.a. # As a rule, we don't package static libraries. # rm -fv usr/lib${LIBDIRSUFFIX}/libgphobos.a # rm -fv usr/lib${LIBDIRSUFFIX}/libgdruntime.a mkdir -p usr/libexec/gcc/$TARGET/$VERSION mv -fv $PKG1/usr/libexec/gcc/$TARGET/$VERSION/d21 usr/libexec/gcc/$TARGET/$VERSION mkdir -p usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include mv -fv $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include/d usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/include mkdir -p usr/info mv -fv $PKG1/usr/info/gdc.info.gz usr/info mkdir -p usr/man/man1 mv -fv $PKG1/usr/man/man1/gdc.1.gz usr/man/man1 ) || exit 1 # gcc-gm2: ( echo "******************* Setting up $PKG11 **********************" cd $PKG11 mkdir -vpm755 usr/bin mv -fv $PKG1/usr/bin/gm2 $PKG1/usr/bin/*-gm2 usr/bin mkdir -vpm755 usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/plugin mv -fv $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/m2 usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION mv -fv $PKG1/usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/plugin/m2* usr/lib${LIBDIRSUFFIX}/gcc/$TARGET/$VERSION/plugin mv -fv $PKG1/usr/lib${LIBDIRSUFFIX}/libm2* usr/lib${LIBDIRSUFFIX} # As a rule, we don't package static libraries: ( cd usr/lib${LIBDIRSUFFIX} for library in libm2*.so ; do rm -fv $(basename $library .so).a done ) mkdir -vpm755 usr/libexec/gcc/$TARGET/$VERSION mv -fv $PKG1/usr/libexec/gcc/$TARGET/$VERSION/cc1gm2 usr/libexec/gcc/$TARGET/$VERSION mkdir -vpm755 usr/man/man1 mv -fv $PKG1/usr/man/man1/gm2.1.gz usr/man/man1 ) || exit 1 # gcc-rust: ( echo "******************* Setting up $PKG12 **********************" cd $PKG12 mkdir -vpm755 usr/bin mv -fv $PKG1/usr/bin/gccrs $PKG1/usr/bin/*-gccrs usr/bin mkdir -vpm755 usr/libexec/gcc/$TARGET/$VERSION mv -fv $PKG1/usr/libexec/gcc/$TARGET/$VERSION/crab1 usr/libexec/gcc/$TARGET/$VERSION ) || exit 1 # Delete old packages - if you want the old ones, move them out # of the way first! rm -fv $PKGSTORE/$PKGSERIES/gcc-*.t* # Don't delete old packages otherwise 'slackmp' wipes # the base gcc package. export DELETEOLDPKGS=No # Build packages: ( echo "Building gcc package" cd $PKG1 slackchown slack644docs export SLACKPACKAGE=gcc-$VERSION-$PKGARCH-$BUILD.txz slackmp ) ( echo "Building g++ package" cd $PKG2 slackchown slack644docs export SLACKPACKAGE=gcc-g++-$VERSION-$PKGARCH-$BUILD.txz slackmp ) ( echo "Building fortran package" cd $PKG3 slackchown slack644docs export SLACKPACKAGE=gcc-gfortran-$VERSION-$PKGARCH-$BUILD.txz slackmp ) if [ -x $PKG4/usr/bin/gnat ]; then ( echo "Building gnat package" cd $PKG4 slackchown slack644docs export SLACKPACKAGE=gcc-gnat-$VERSION-$PKGARCH-$BUILD.txz slackmp ) fi ( echo "Building objc package" cd $PKG6 slackchown slack644docs export SLACKPACKAGE=gcc-objc-$VERSION-$PKGARCH-$BUILD.txz slackmp ) # Only package if it's been built: # Sept-2018: Note that instead of hanging, gcc-go fails during assembly if it's not # stripped. This was a bug outside of gcc-go that vbatts told me about. # # NOTE: We're moving gcc-go in to the 'testing' directory because it doesn't work. # properly, but want to give people a chance to fix it! # if [ -x $PKG8/usr/bin/gccgo ]; then ( cd $PKG8 slackchown slack644docs # The 'rsync' copies all of the gcc package in to this temp directory. # If that dir is there, we'll assume we're still hacking around with gcc-go and will # store the resulting package in to the 'testing' package rather than the main tree. # To move gcc-go back in to the main tree, comment out the rsync. if [ -d $TMPBUILD/gcc-not-stripped ]; then echo "**** TEMP HACK:::::: Moving gcc-go in to /testing/ *****" export PKGSTORE=${PORTSRC}/testing/ echo "Deleting previous gcc-go package from /testing/packages" rm -fv ${PORTSRC}/testing/packages/gcc-go-* export PKGSERIES=packages # since there's no "a", "ap" in testing.. fi export SLACKPACKAGE=gcc-go-$VERSION-$PKGARCH-$BUILD.txz slackmp ) else echo "****** gcc-go did not build, so has not been packaged! *****" fi # Only package if it's been built: # brig left gcc in gcc-12, but we keep this here as an example for # other non-ARM languages: #if [ -x $PKG9/usr/bin/brig ]; then # ( cd $PKG9 # slackchown # slack644docs # export SLACKPACKAGE=gcc-brig-$VERSION-$PKGARCH-$BUILD.txz # slackmp ) # else # echo "****** gcc-brig did not build, so has not been packaged! *****" #fi ( echo "Building gcc-gdc package" cd $PKG10 slackchown slack644docs export SLACKPACKAGE=gcc-gdc-$VERSION-$PKGARCH-$BUILD.txz slackmp ) ( echo "Building gcc-gm2 package" cd $PKG11 slackchown slack644docs export SLACKPACKAGE=gcc-gm2-$VERSION-$PKGARCH-$BUILD.txz slackmp ) ( echo "Building gcc-rust package" cd $PKG12 slackchown slack644docs export SLACKPACKAGE=gcc-rust-$VERSION-$PKGARCH-$BUILD.txz slackmp )