name=busybox-32
version=1.38.0
release=1
desc="Init, getty, device manager and network tools, 32-bit"
url="https://busybox.net/"
license="GPL-2.0-only"
depend="glibc-32"
makedepend=""
source="https://busybox.net/downloads/busybox-1.38.0.tar.bz2"
sha256="SKIP"

build() {
	cd "busybox-1.38.0"
	unset CFLAGS CXXFLAGS LDFLAGS
	cp "$(dirname "$recipe")/../../main/busybox/scraplinux.config" .config
	sed -i "s/^CONFIG_CROSS_COMPILER_PREFIX=.*/CONFIG_CROSS_COMPILER_PREFIX=\"\"/" .config
	make oldconfig </dev/null >/dev/null
	make -j"$JOBS" CC="clang -m32" CFLAGS_EXTRA="-Wno-error -fno-pie" EXTRA_LDFLAGS="-no-pie"
}

package() {
	cd "busybox-1.38.0"
	install -Dm755 busybox "$pkgdir/usr/lib32/scraplinux/busybox32"
	mkdir -p "$pkgdir/usr/bin"
	ln -sf ../lib32/scraplinux/busybox32 "$pkgdir/usr/bin/busybox32"
}
