187 lines
5.4 KiB
Bash
Executable file
187 lines
5.4 KiB
Bash
Executable file
#!/bin/bash
|
|
# "gwh-ified" based on http://slackware.uk/slint/x86_64/slint-15.0/source/libgccjit/
|
|
|
|
cd $(dirname $0) ; CWD=$(pwd)
|
|
|
|
PKGNAM=$(basename "$CWD")
|
|
BUILD=${BUILD:-2}
|
|
TAG=${TAG:-gwh}
|
|
|
|
OFFICIAL_GCC_SRC_PATH=${OFFICIAL_GCC_SRC_PATH:-/home/installs/mirrors/slackware64-current/source/d/gcc/}
|
|
SRCNAM=gcc
|
|
SRCVER=${VERSION:-$(echo $OFFICIAL_GCC_SRC_PATH/$SRCNAM-*.tar.?z | rev | cut -f 3- -d . | cut -f 1 -d - | rev)}
|
|
VERSION=$(echo $SRCVER | cut -f 1 -d _)
|
|
|
|
TMP=${TMP:-/tmp/$TAG}
|
|
OUTPUT=${OUTPUT:-/tmp}
|
|
|
|
# This is the main DESTDIR target:
|
|
PKG=$TMP/pkg-$PKGNAM
|
|
|
|
# How many jobs to run in parallel:
|
|
NUMJOBS=${NUMJOBS:-" -j$(expr $(nproc) + 1) "}
|
|
|
|
# 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
|
|
|
|
# If the variable PRINT_PACKAGE_NAME is set, then this script will report what
|
|
# the name of the created package would be, and then exit. This information
|
|
# could be useful to other scripts.
|
|
if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
|
|
echo "$PKGNAM-$VERSION-$ARCH-$BUILD.txz"
|
|
exit 0
|
|
fi
|
|
|
|
if [ "$ARCH" = "i386" ]; then
|
|
SLKCFLAGS="-O2 -march=i386 -mcpu=i686"
|
|
LIBDIRSUFFIX=""
|
|
LIB_ARCH=i386
|
|
elif [ "$ARCH" = "i486" ]; then
|
|
SLKCFLAGS="-O2 -march=i486 -mtune=i686"
|
|
LIBDIRSUFFIX=""
|
|
LIB_ARCH=i386
|
|
elif [ "$ARCH" = "i586" ]; then
|
|
SLKCFLAGS="-O2 -march=i586 -mtune=i686"
|
|
LIBDIRSUFFIX=""
|
|
LIB_ARCH=i386
|
|
elif [ "$ARCH" = "i686" ]; then
|
|
SLKCFLAGS="-O2 -march=i686"
|
|
LIBDIRSUFFIX=""
|
|
LIB_ARCH=i386
|
|
elif [ "$ARCH" = "s390" ]; then
|
|
SLKCFLAGS="-O2"
|
|
LIBDIRSUFFIX=""
|
|
LIB_ARCH=s390
|
|
elif [ "$ARCH" = "x86_64" ]; then
|
|
SLKCFLAGS="-O2 -fPIC"
|
|
LIBDIRSUFFIX="64"
|
|
LIB_ARCH=amd64
|
|
elif [ "$ARCH" = "armv7hl" ]; then
|
|
SLKCFLAGS="-O3 -march=armv7-a -mfpu=vfpv3-d16"
|
|
LIBDIRSUFFIX=""
|
|
LIB_ARCH=armv7hl
|
|
else
|
|
SLKCFLAGS="-O2"
|
|
LIBDIRSUFFIX=""
|
|
LIB_ARCH=$ARCH
|
|
fi
|
|
|
|
case "$ARCH" in
|
|
arm*) TARGET=$ARCH-slackware-linux-gnueabi ;;
|
|
*) TARGET=$ARCH-slackware-linux ;;
|
|
esac
|
|
|
|
# Extract the source code:
|
|
mkdir -p $TMP
|
|
cd $TMP || exit 1
|
|
rm -rf gcc-$SRCVER
|
|
tar xf $OFFICIAL_GCC_SRC_PATH/gcc-$SRCVER.tar.?z || exit 1
|
|
|
|
# Clear the build locations:
|
|
rm -rf $PKG
|
|
mkdir $PKG
|
|
|
|
cd gcc-$SRCVER || exit 1
|
|
|
|
# Fix perms/owners:
|
|
chown -R root:root .
|
|
find . \
|
|
\( -perm 777 -o -perm 775 -o -perm 754 \) \
|
|
-exec chmod 755 {} \+ -o \
|
|
\( -perm 664 \) \
|
|
-exec chmod 644 {} \+
|
|
|
|
mkdir -p $PKG/usr/doc/$PKGNAM
|
|
cp -a \
|
|
COPYING* gcc/ONEWS README INSTALL LAST_UPDATED \
|
|
$PKG/usr/doc/$PKGNAM
|
|
|
|
mkdir gcc.build.lnx
|
|
cd gcc.build.lnx
|
|
|
|
if [ "$ARCH" != "x86_64" ]; then
|
|
GCC_ARCHOPTS="--with-arch=$ARCH"
|
|
else
|
|
GCC_ARCHOPTS="--disable-multilib"
|
|
fi
|
|
|
|
CFLAGS="$SLKCFLAGS" \
|
|
CXXFLAGS="$SLKCFLAGS" \
|
|
../configure --prefix=/usr \
|
|
--libdir=/usr/lib$LIBDIRSUFFIX \
|
|
--mandir=/usr/man \
|
|
--infodir=/usr/info \
|
|
--enable-shared \
|
|
--enable-host-shared \
|
|
--enable-bootstrap \
|
|
--enable-languages=jit \
|
|
--enable-threads=posix \
|
|
--enable-checking=release \
|
|
--enable-objc-gc \
|
|
--with-system-zlib \
|
|
--enable-libstdcxx-dual-abi \
|
|
--with-default-libstdcxx-abi=new \
|
|
--disable-libstdcxx-pch \
|
|
--disable-libunwind-exceptions \
|
|
--enable-__cxa_atexit \
|
|
--disable-libssp \
|
|
--enable-gnu-unique-object \
|
|
--enable-plugin \
|
|
--enable-lto \
|
|
--disable-install-libiberty \
|
|
--disable-werror \
|
|
--with-gnu-ld \
|
|
--with-isl \
|
|
--verbose \
|
|
--with-arch-directory=$LIB_ARCH \
|
|
--disable-gtktest \
|
|
--enable-clocale=gnu \
|
|
$GCC_ARCHOPTS \
|
|
--target=${TARGET} \
|
|
--build=${TARGET} \
|
|
--host=${TARGET} || exit 1
|
|
|
|
make $NUMJOBS bootstrap || exit 1
|
|
make -C gcc DESTDIR="$PKG" jit.install-common jit.install-info
|
|
find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
|
|
| cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
|
|
|
|
cd $PKG || exit 1
|
|
rm -rf usr/bin usrlib64/gcc usr/libexec usr/man usr/info/dir
|
|
cd usr/info
|
|
gzip -9 *
|
|
|
|
cd $PKG || exit 1
|
|
mkdir -p install/
|
|
cat <<EOF > install/slack-desc
|
|
# 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 ':'.
|
|
|
|
|-----handy-ruler------------------------------------------------------|
|
|
libgccjit: libgccit (Just In Time Compilation: shared library and header files.)
|
|
libgccjit:
|
|
libgccjit: GCC can be built as a shared library "libgccjit.so", for generating
|
|
libgccjit: machine code from API calls, using GCC as the backend.
|
|
libgccjit: This shared library can then be dynamically-linked into bytecode
|
|
libgccjit: interpreters and other such programs that want to generate machine
|
|
libgccjit: code "on the fly" at run-time. It can also be used for ahead-of-time
|
|
libgccjit: code generation, for building standalone compilers (so the "jit"
|
|
libgccjit: part of the name is now something of a misnomer).
|
|
libgccjit: The library provides a C API, along with a C++ wrapper API, with
|
|
libgccjit: bindings for languages available from 3rd parties
|
|
libgccjit:
|
|
EOF
|
|
|
|
makepkg -l y -c n $OUTPUT/$PKGNAM-$VERSION-$ARCH-$BUILD$TAG.txz
|