main
build-userland
1#!/bin/sh -e
2. ./util/lib.sh
3
4printf "\nyou can skip this build process by removing this from create-mwakat; this is just for getting a slightly smaller userland.\n"
5
6set -x
7pwd=`pwd`
8
9rm -rf build/*
10
11### toybox
12
13git clone --depth 1 'https://github.com/landley/toybox.git' build/toybox/
14cd build/toybox/
15
16echo 'cc -static -Oz -Wl,-s -Wl,--as-needed -Wl,-Os $@' > ./cc.sh
17chmod 755 ./cc.sh
18export CC=`pwd`/cc.sh
19export HOSTCC=$CC
20make defconfig
21
22sed -i 's/ Toybox/ Serious Loonix/g' toys/posix/uname.c
23sed -i 's/-o/-static -Oz -Oz -Wl,-s -Wl,--as-needed -Wl,-Os -o/g' scripts/install.sh
24sed -i 's/cc/cc -static -Oz -Oz -Wl,-s -Wl,--as-needed -Wl,-Os/g' kconfig/Makefile
25sed -i 's#scripts/install.sh#scripts/install.sh --static#g' Makefile
26sed -i 's/\$HOSTCC/$HOSTCC -static -Oz -Wl,-s -Wl,--as-needed -Wl,-Os/g' scripts/make.sh
27
28make CFLAGS='-static -Oz -Wl,-s -Wl,--as-needed -Wl,-Os' LDFLAGS='-static -Oz -Wl,-s -Wl,--as-needed -Wl,-Os' PREFIX="$PKG"
29cp -f ./toybox $m/bin/toybox
30
31### busybox
32
33cd $pwd
34rm -f busybox-1.36.1.tar.bz2
35wget 'https://busybox.net/downloads/busybox-1.36.1.tar.bz2'
36tar -xf busybox-1.36.1.tar.bz2 -C build/
37cd build/busybox*/
38cp $pwd/util/busybox.config .config
39
40sed -i 's/gcc/cc -static -static -Oz -Wl,-s -Wl,--as-needed -Wl,-Os/g' Makefile
41sed -i 's#GNU/Linux#Serious/Linux#g' `find . -name .config -type f`
42# make olddefconfig
43gmake PREFIX="$PREFIX" CFLAGS='-static -Oz -Wl,-s -Wl,--as-needed -Wl,-Os' DESTDIR="$PKG" LDFLAGS='-static -static -Oz -Wl,-s -Wl,--as-needed -Wl,-Os' V=0
44cp -f ./busybox $m/usr/sbin/busybox.static