2023-11-16 12:04:05 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
CURRENT_DIR=$(pwd)
|
2023-11-16 22:30:10 +00:00
|
|
|
GCC_VERSION=$(cat GCC_VERSION)
|
|
|
|
GCC_GIT="git://gcc.gnu.org/git/gcc.git"
|
2023-11-16 12:20:21 +00:00
|
|
|
GCC_SRC="${CURRENT_DIR}/../gcc"
|
2023-11-16 13:24:31 +00:00
|
|
|
|
|
|
|
build_cd() {
|
|
|
|
cd $@
|
|
|
|
echo "****** Now at: $(pwd)"
|
|
|
|
}
|
2023-11-16 12:04:05 +00:00
|
|
|
|
2023-11-16 22:30:10 +00:00
|
|
|
if [ -z "$GCC_VERSION" ]; then
|
|
|
|
echo "GCC_VERSION not set!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2023-11-16 12:04:05 +00:00
|
|
|
# Clone GCC
|
|
|
|
echo "===> Cloning GCC..."
|
|
|
|
git clone -b "releases/gcc-$GCC_VERSION" --depth 1 "${GCC_GIT}" "${GCC_SRC}"
|
|
|
|
|
2023-11-16 13:24:31 +00:00
|
|
|
# Download prerequisites
|
|
|
|
echo "===> Downloading prerequisites..."
|
|
|
|
build_cd ${GCC_SRC}
|
|
|
|
./contrib/download_prerequisites
|
|
|
|
build_cd ${CURRENT_DIR}
|
|
|
|
|
2023-11-16 12:04:05 +00:00
|
|
|
# Apply patches
|
|
|
|
echo "===> Applying patches..."
|
2023-11-16 13:24:31 +00:00
|
|
|
build_cd ${GCC_SRC}
|
2023-11-16 12:29:49 +00:00
|
|
|
patch -p1 < ${CURRENT_DIR}/patches/gcc-$GCC_VERSION.patch
|
2023-11-16 13:24:31 +00:00
|
|
|
build_cd ${CURRENT_DIR}
|
2023-11-16 12:04:05 +00:00
|
|
|
|
|
|
|
# Configure GCC
|
|
|
|
echo "===> Configuring GCC..."
|
2023-11-16 13:24:31 +00:00
|
|
|
build_cd ${CURRENT_DIR}/build
|
2023-11-16 12:04:05 +00:00
|
|
|
${GCC_SRC}/configure -v \
|
|
|
|
--enable-languages=c,c++ \
|
|
|
|
--prefix=/usr \
|
|
|
|
--build=x86_64-linux-gnu \
|
|
|
|
--host=x86_64-linux-gnu \
|
|
|
|
--target=x86_64-linux-gnu \
|
|
|
|
--with-pkgversion="s2oj-gcc-$GCC_VERSION~1baoshuo1"
|
|
|
|
|
|
|
|
# Build GCC
|
|
|
|
echo "===> Building GCC..."
|
|
|
|
make -j$(nproc)
|
|
|
|
|
2023-11-16 22:38:02 +00:00
|
|
|
# Prepare for packaging
|
|
|
|
echo "===> Preparing for packaging..."
|
2023-11-16 12:04:05 +00:00
|
|
|
make -j$(nproc) DESTDIR=${CURRENT_DIR}/deb install
|
2023-11-16 13:24:31 +00:00
|
|
|
build_cd ${CURRENT_DIR}/deb
|
2023-11-16 12:04:05 +00:00
|
|
|
mkdir -p DEBIAN
|
|
|
|
cat << EOF > DEBIAN/control
|
|
|
|
Package: s2oj-gcc
|
|
|
|
Version: $GCC_VERSION~1baoshuo1
|
|
|
|
Section: base
|
|
|
|
Priority: optional
|
|
|
|
Architecture: amd64
|
|
|
|
Maintainer: Baoshuo <i@baoshuo.ren>
|
|
|
|
Description: GCC $GCC_VERSION for S2OJ
|
|
|
|
EOF
|
2023-11-16 13:24:31 +00:00
|
|
|
build_cd ${CURRENT_DIR}
|