FreonLinux/build-extensions

419 lines
7.3 KiB
Bash
Executable File

#!/bin/bash
# Build Freon Linux software from source.
# Version: 0.5.0
# (C) Chris Dorman, 2018-2020 GPLv3+
corecount="25"
#### Variables ###
# mirrors
mpfrmirror="https://ftp.gnu.org/gnu/mpfr"
mpcmirror="https://ftp.gnu.org/gnu/mpc"
gmpmirror="https://ftp.gnu.org/gnu/gmp"
binutilsmirror="https://ftp.gnu.org/gnu/binutils"
gccmirror="http://ftp.gnu.org/gnu/gcc/gcc-9.2.0"
nanomirror="https://www.nano-editor.org/dist/v3"
chttpdmirror="https://github.com/Pentium44/chttpd.git"
ftpmirror="https://github.com/Harlonxl/minFTPD.git"
ncursesmirror="https://ftp.gnu.org/pub/gnu/ncurses"
bashmirror="https://ftp.gnu.org/gnu/bash"
zlibmirror="https://zlib.net"
termcapmirror="https://ftp.gnu.org/gnu/termcap"
htopmirror="https://github.com/htop-dev/htop/archive"
islmirror="http://isl.gforge.inria.fr"
bitchxmirror="git://git.code.sf.net/p/bitchx/git"
# filenames
gcc="gcc-9.2.0.tar.xz"
nano="nano-3.1.tar.xz"
ncurses="ncurses-6.1.tar.gz"
bash="bash-5.0.tar.gz"
zlib="zlib-1.2.11.tar.xz"
termcap="termcap-1.3.1.tar.gz"
htop="htop-2.2.0.tar.gz"
binutils="binutils-2.31.1.tar.xz"
gmp="gmp-6.1.2.tar.xz"
mpfr="mpfr-4.0.2.tar.xz"
mpc="mpc-1.1.0.tar.gz"
isl="isl-0.19.tar.xz"
# work directories
tmpdir="`pwd`/pkgsrc"
softwaredir="`pwd`/src/rootfs"
freondir="/freon"
# source directories
gccsrcdir=${gcc//.tar.xz}
nanosrcdir=${nano//.tar.xz}
ncursessrcdir=${ncurses//.tar.gz}
bashsrcdir=${bash//.tar.gz}
zlibsrcdir=${zlib//.tar.xz}
termcapsrcdir=${termcap//.tar.gz}
htopsrcdir=${htop//.tar.gz}
mpcsrcdir=${mpc//.tar.gz}
mpfrsrcdir=${mpfr//.tar.xz}
binutilssrcdir=${binutils//.tar.xz}
gmpsrcdir=${gmp//.tar.xz}
islsrcdir=${isl//.tar.xz}
if [ ! -d "$tmpdir" ]; then
echo "Warning: package source directory not found, creating."
mkdir $tmpdir > /dev/null 2>&1
fi
bash()
{
cd $tmpdir
# Downloading TCC source
if [ ! -f "$bash" ]; then
echo "Downloading bash sources..."
wget $bashmirror/$bash
tar -xf $bash
fi
cd $bashsrcdir
./configure --prefix=$freondir --without-bash-malloc
make -j$corecount
make install
cd ..
}
gcc()
{
cd $tmpdir
# Downloading GCC source
if [ ! -f "$gcc" ]; then
echo "Downloading GCC sources..."
wget $gccmirror/$gcc
tar -xf $gcc
fi
cd $gccsrcdir
mkdir -v build
cd build
SED=sed
../configure --prefix=$freondir \
--enable-languages=c,c++ \
--disable-multilib \
--disable-bootstrap \
--with-system-zlib
# Compile
make -j$corecount
make install
cd $softwaredir
if [ ! -d "freon-ext" ]; then
mkdir freon-ext
fi
cd freon-ext
cp -a $freondir/. .
rm lib/*.a
rm lib64/*.a
cd $tmpdir
}
htop()
{
cd $tmpdir
# Downloading TCC source
if [ ! -f "$htop" ]; then
echo "Downloading htop sources..."
wget $htopmirror/2.2.0.tar.gz
mv 2.2.0.tar.gz $htop
tar -xf $htop
fi
# Configure TCC
cd $htopsrcdir
./autogen.sh
./configure --prefix=$freondir
# Compile
make -j20
make install
cd ..
}
termcap()
{
cd $tmpdir
# Downloading termcap source
if [ ! -f "$termcap" ]; then
echo "Downloading termcap sources..."
wget $termcapmirror/$termcap
tar -xf $termcap
fi
# Configure TCC
cd $termcapsrcdir
./configure --prefix=$freondir --with-shared --without-normal
# Compile
make -j20
make install
cd ..
}
nano()
{
cd $tmpdir
# Downloading nano source
if [ ! -f "$nano" ]; then
echo "Downloading nano editor sources..."
wget $nanomirror/$nano
tar -xf $nano
fi
# Confingure
cd $nanosrcdir
./configure --prefix=$freondir
# Compile
make -j20
make install
cd ..
}
ncurses()
{
cd $tmpdir
# Downloading nano source
if [ ! -f "$ncurses" ]; then
echo "Downloading ncurses sources..."
wget $ncursesmirror/$ncurses
tar -xf $ncurses
fi
# Configure
cd $ncursessrcdir
./configure --prefix=$freondir \
--with-shared \
--without-debug \
--without-normal \
--enable-widec
# Compile
make -j$corecount
make install
make distclean
./configure --prefix=$freondir \
--with-shared \
--without-normal \
--without-debug \
--without-cxx-binding \
--with-abi-version=5 \
--with-versioned-syms
make sources libs
cp -av lib/lib*.so.5* $freondir/lib
cd $freondir/lib
ln -s libncursesw.so.6 libtinfo.so.6
ln -s libtinfo.so.6 libtinfo.so
ln -s libncurses.so.5 libtinfo.so.5
ln -s libtinfo.so.5 libtinfo.so
ln -s libncursesw.so.6 libncursesw.so.5
cd $tmpdir
}
binutils()
{
cd $tmpdir
# Downloading binutils sources
if [ ! -f "$binutils" ]; then
echo "Downloading binutils sources..."
wget $binutilsmirror/$binutils
tar -xf $binutils
fi
# Configure Binutils
if [ ! -d "${binutilssrcdir}-build" ]; then
mkdir ${binutilssrcdir}-build
fi
cd ${binutilssrcdir}-build
../$binutilssrcdir/configure --prefix=$freondir --enable-shared
make tooldir=$freondir -j$corecount
make tooldir=$freondir install
cp -v ../$binutilssrcdir/include/libiberty.h $freondir/include
cd $tmpdir
}
mpc()
{
cd $tmpdir
# Download sources
if [ ! -f "$mpc" ]; then
echo "Downloading GNU mpc sources..."
wget $mpcmirror/$mpc
tar -xf $mpc
fi
cd $mpcsrcdir
./configure --prefix=$freondir --disable-static
make -j$corecount
make install
cd $tmpdir
}
mpfr()
{
cd $tmpdir
# Download sources
if [ ! -f "$mpfr" ]; then
echo "Downloading GNU mpfr sources..."
wget $mpfrmirror/$mpfr
tar -xf $mpfr
fi
# Configure and compile
cd $mpfrsrcdir
./configure --prefix=$freondir --disable-static --enable-thread-safe
make -j$corecount
make install
cd ..
}
gmp()
{
cd $tmpdir
# Download sources
if [ ! -f "$gmp" ]; then
echo "Downloading GNU gmp sources..."
wget $gmpmirror/$gmp
tar -xf $gmp
fi
# Configure and compile
cd $gmpsrcdir
./configure --prefix=$freondir --disable-static --enable-cxx
make -j$corecount
make install
cd ..
}
ftp()
{
cd $tmpdir
if [ ! -d "minFTPD" ]; then
git clone $ftpmirror
fi
cd minFTPD
make -j20
cp minFTPD ../../src/rootfs/sbin/
cp miniFTPD.conf ../../src/rootfs/etc/
cd $tmpdir
}
isl()
{
cd $tmpdir
# Download sources
if [ ! -f "$isl" ]; then
echo "Downloading ISL sources..."
wget $islmirror/$isl
tar -xf $isl
fi
# Configure and compile
cd $islsrcdir
./configure --prefix=$freondir
make -j$corecount
make install
cd ..
}
# IRC clients / servers
# Because why not! :D
bitchx()
{
cd $tmpdir
# Grab latest sources of community devel BitchX
if [ ! -d "bitchx" ]; then
git clone $bitchxmirror BitchX
fi
cd BitchX
# Configure patch: checks if ncurses calls tputs compile / with later ncurses libraries
# Patch from: http://www.mit.edu/afs.new/sipb/user/ssen/src/BitchX/contrib/BitchX-configure.patch
# Patch BitchX
patch -u configure.in -i ../../patches/bitchx-configure.in.patch
# Configure and build + install
./configure --prefix=$freondir
make -j20
make install
cd $tmpdir
}
case $1 in
all ) echo "Building all!"
ncurses; nano; chttpd; gmp; mpfr; binutils; mpc; gcc; bash; isl; termcap; bitchx;;
packages ) echo "Building useful essentials..."
ncurses; nano; bash; termcap; bitchx;;
* ) echo "Building $1..."
$1;;
esac