From 6c652ea22bf7fd62186ad6feb83a3395bfebd254 Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 20 Dec 2023 21:18:01 +0300 Subject: [PATCH] first --- README.md | 2 -- build.sh | 29 +++++++++++++++++++++++++++++ clean.sh | 2 ++ stages/0-download-src.sh | 10 ++++++++++ stages/1-libc.sh | 11 +++++++++++ stages/2-cross-compiler.sh | 11 +++++++++++ stages/3-micro-utils.sh | 9 +++++++++ stages/4-host-compiler.sh | 10 ++++++++++ tests/c.sh | 20 ++++++++++++++++++++ tests/git.sh | 12 ++++++++++++ tests/make.sh | 12 ++++++++++++ tests/texinfo.sh | 12 ++++++++++++ 12 files changed, 138 insertions(+), 2 deletions(-) delete mode 100644 README.md create mode 100755 build.sh create mode 100755 clean.sh create mode 100755 stages/0-download-src.sh create mode 100755 stages/1-libc.sh create mode 100755 stages/2-cross-compiler.sh create mode 100755 stages/3-micro-utils.sh create mode 100755 stages/4-host-compiler.sh create mode 100755 tests/c.sh create mode 100755 tests/git.sh create mode 100755 tests/make.sh create mode 100755 tests/texinfo.sh diff --git a/README.md b/README.md deleted file mode 100644 index 64182b7..0000000 --- a/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# PlainOsBuilder - diff --git a/build.sh b/build.sh new file mode 100755 index 0000000..4189a74 --- /dev/null +++ b/build.sh @@ -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 diff --git a/clean.sh b/clean.sh new file mode 100755 index 0000000..6534892 --- /dev/null +++ b/clean.sh @@ -0,0 +1,2 @@ +#!/bin/sh +rm -rf rootfs src libc tcc diff --git a/stages/0-download-src.sh b/stages/0-download-src.sh new file mode 100755 index 0000000..986b870 --- /dev/null +++ b/stages/0-download-src.sh @@ -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 diff --git a/stages/1-libc.sh b/stages/1-libc.sh new file mode 100755 index 0000000..2a4ab87 --- /dev/null +++ b/stages/1-libc.sh @@ -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 .. diff --git a/stages/2-cross-compiler.sh b/stages/2-cross-compiler.sh new file mode 100755 index 0000000..b08e7ba --- /dev/null +++ b/stages/2-cross-compiler.sh @@ -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 .. diff --git a/stages/3-micro-utils.sh b/stages/3-micro-utils.sh new file mode 100755 index 0000000..d9187d5 --- /dev/null +++ b/stages/3-micro-utils.sh @@ -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 .. diff --git a/stages/4-host-compiler.sh b/stages/4-host-compiler.sh new file mode 100755 index 0000000..04a8d3f --- /dev/null +++ b/stages/4-host-compiler.sh @@ -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 .. diff --git a/tests/c.sh b/tests/c.sh new file mode 100755 index 0000000..4fe4492 --- /dev/null +++ b/tests/c.sh @@ -0,0 +1,20 @@ +#!/bin/sh +out_name=$(mktemp XXXXXX) + +echo "#include " >> 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 diff --git a/tests/git.sh b/tests/git.sh new file mode 100755 index 0000000..b6e6d54 --- /dev/null +++ b/tests/git.sh @@ -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 + diff --git a/tests/make.sh b/tests/make.sh new file mode 100755 index 0000000..058ef7b --- /dev/null +++ b/tests/make.sh @@ -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 + diff --git a/tests/texinfo.sh b/tests/texinfo.sh new file mode 100755 index 0000000..4afdb9e --- /dev/null +++ b/tests/texinfo.sh @@ -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 +