This commit is contained in:
Your Name 2023-12-20 21:18:01 +03:00
parent 8a97b330f2
commit 6c652ea22b
12 changed files with 138 additions and 2 deletions

View File

@ -1,2 +0,0 @@
# PlainOsBuilder

29
build.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/sh
CC=cc
RTFS=$(pwd)/rootfs
mu_repo="https://git.macaw.me/8nl/micro-utils"
ml_repo="git://git.musl-libc.org/musl"
cc_repo="git://repo.or.cz/tinycc.git"
#Tests
for i in tests/*; do
if ! env CC=$CC $i; then
echo "Build failed"
exit 1
fi
done
#Clean
./clean.sh
#Make rootfs
mkdir rootfs
#Build system
for i in stages/*; do
if ! env mu_repo=$mu_repo ml_repo=$ml_repo cc_repo=$cc_repo RTFS=$RTFS $i; then
echo "Build failed"
exit 1
fi
done

2
clean.sh Executable file
View File

@ -0,0 +1,2 @@
#!/bin/sh
rm -rf rootfs src libc tcc

10
stages/0-download-src.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
echo "* Download micro-utils sources..."
git clone $mu_repo src
echo "* Download musl sources..."
git clone $ml_repo libc
echo "* Download tcc sources..."
git clone $cc_repo tcc

11
stages/1-libc.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
echo "* Build musl libc"
cd libc
make clean
./configure CC=cc CFLAGS="-Os -s -pipe" --disable-warnings --disable-static --prefix=$RTFS
make -j $(nproc)
make install
cd ..

11
stages/2-cross-compiler.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
echo "* Build cross compiler"
cd tcc
make clean
./configure --extra-cflags="-Os -s" --prefix=$RTFS/ --elfinterp=/lib/libc.so --config-musl --config-bcheck=no --enable-static
make -j $(nproc)
make install
cd ..

9
stages/3-micro-utils.sh Executable file
View File

@ -0,0 +1,9 @@
#!/bin/sh
echo " * Build micro-utils"
cd src
env CC="$RTFS/bin/tcc" CFLAGS="-pedantic -Os -s -Wall -I $RTFS/include -L $RTFS/lib/tcc -L $RTFS/lib" ./build.sh
mv bin/* $RTFS/bin
cd ..

10
stages/4-host-compiler.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/sh
echo "* Build host compiler"
cd tcc
./configure --extra-cflags="-Os -s" --prefix=$RTFS/ --elfinterp=/lib/libc.so --config-musl --config-bcheck=no --enable-static --cc=$RTFS/bin/tcc
make -j $(nproc)
make install
cd ..

20
tests/c.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/sh
out_name=$(mktemp XXXXXX)
echo "#include <stdio.h>" >> test.c
echo "int main(void){return 0;}" >> test.c
$CC test.c -o $out_name
rm test.c
if ./$out_name; then
echo "[OK] C compiler work..."
rm $out_name
exit 0
else
echo "[FAILED] Fix c compiler or headers..."
rm $out_name
exit 1
fi

12
tests/git.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
if ! git > /dev/null; then
echo "[OK] Git installed..."
exit 0;
else
echo "[FAILED] Git is not installed..."
exit 1
fi

12
tests/make.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
if make -h > /dev/null; then
echo "[OK] Make installed..."
exit 0;
else
echo "[FAILED] Make is not installed..."
exit 1
fi

12
tests/texinfo.sh Executable file
View File

@ -0,0 +1,12 @@
#!/bin/sh
if makeinfo -h > /dev/null; then
echo "[OK] Texinfo installed..."
exit 0;
else
echo "[FAILED] Texinfo is not installed..."
exit 1
fi