From 0b6aed138649cb843cbbdfe2ca5ff5e56f3a0825 Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Sun, 4 Jun 2023 10:56:34 +0100 Subject: Example build scripts Supply the scripts used to build release and prerelease busybox-w32. (GitHub issue #330) --- examples/mswin-build/README | 6 ++++ examples/mswin-build/mkprerelease | 48 +++++++++++++++++++++++++++ examples/mswin-build/mkrelease | 70 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 124 insertions(+) create mode 100644 examples/mswin-build/README create mode 100755 examples/mswin-build/mkprerelease create mode 100755 examples/mswin-build/mkrelease diff --git a/examples/mswin-build/README b/examples/mswin-build/README new file mode 100644 index 000000000..57a13d8d5 --- /dev/null +++ b/examples/mswin-build/README @@ -0,0 +1,6 @@ +These are the scripts used to cross-compile busybox-w32. + +The release build performs some additional optimisation and is +slightly slower as a result. It also includes information about +the build platform in the help message. This assumes the build is +done on a Fedora Linux system. diff --git a/examples/mswin-build/mkprerelease b/examples/mswin-build/mkprerelease new file mode 100755 index 000000000..ea98785d7 --- /dev/null +++ b/examples/mswin-build/mkprerelease @@ -0,0 +1,48 @@ +#!/bin/sh +# +# Build busybox prerelease binaries +# +TARGETS="build_pre_32 build_pre_64" + +# If an argument is supplied it overrides the default source directory. +SRC=busybox-w32 +if [ $# -eq 1 ] +then + SRC=$1 +fi + +if [ ! -d $SRC ] +then + echo "$SRC doesn't exist" + exit 0 +fi + +# remove old and make new build directories +for i in $TARGETS +do + rm -rf $i + cp -rp $SRC $i +done + +# apply default configuration +for i in $TARGETS +do + if [ $i = "build_pre_64" ] + then + CONFIG=mingw64_defconfig; + elif [ $i = "build_pre_32" ] + then + CONFIG=mingw32_defconfig; + fi + + (cd $i; git checkout master; make ${CONFIG}) +done + +# perform build +for i in $TARGETS +do + ( + cd $i + make -j $(nproc) EXTRAVERSION="-$(git describe --match=FRP | sed 's/FRP/PRE/')" + ) +done diff --git a/examples/mswin-build/mkrelease b/examples/mswin-build/mkrelease new file mode 100755 index 000000000..7ce9094f6 --- /dev/null +++ b/examples/mswin-build/mkrelease @@ -0,0 +1,70 @@ +#!/bin/sh +# +# Build 32- and 64-bit busybox binaries for release +# +TARGETS="build_32 build_64" + +if [ ! -d busybox-w32 ] +then + echo "busybox-w32 doesn't exist" + exit 0 +fi + +# remove old and make new build directories +for i in $TARGETS +do + rm -rf $i + cp -rp busybox-w32 $i +done + +# apply default configuration +for i in $TARGETS +do + BITS=32 + if [ $i = "build_64" ] + then + BITS=64; + fi + + ( + cd $i + make mingw${BITS}_defconfig + # link time optimisation, fortify, stack protection + sed -e 's/^CONFIG_EXTRA_CFLAGS="\(.*\)"$/CONFIG_EXTRA_CFLAGS="\1 -flto -fstack-protector --param=ssp-buffer-size=4"/' \ + -e 's/^CONFIG_EXTRA_CFLAGS=" /CONFIG_EXTRA_CFLAGS="/' \ + -e 's/^CONFIG_EXTRA_LDLIBS="\(.*\)"$/CONFIG_EXTRA_LDLIBS="\1 -l:libssp.a"/' \ + -e 's/^CONFIG_EXTRA_LDLIBS=" /CONFIG_EXTRA_LDLIBS="/' \ + -i .config + # does ld support --disable-reloc-section? + eval $(grep CONFIG_CROSS_COMPILER_PREFIX .config) + [ $BITS -eq 32 ] && [ -n "$CONFIG_CROSS_COMPILER_PREFIX" ] && \ + ${CONFIG_CROSS_COMPILER_PREFIX}ld --help | \ + grep -q disable-reloc-section && + sed -e 's/^CONFIG_EXTRA_LDFLAGS="\(.*\)"$/CONFIG_EXTRA_LDFLAGS="\1 -Wl,--disable-reloc-section"/' \ + -e 's/^CONFIG_EXTRA_LDFLAGS=" /CONFIG_EXTRA_LDFLAGS="/' \ + -i .config + ) +done + +# perform build +for i in $TARGETS +do + BITS=32 + if [ $i = "build_64" ] + then + BITS=64; + fi + + ( + cd $i + GCCV=`rpm -q --qf '%{name} %{version}-%{release}\n' mingw${BITS}-gcc` + CRTV=`rpm -q --qf '%{name} %{version}-%{release}\n' mingw${BITS}-crt` + GLOB="; noglob" + if grep -q ^CONFIG_GLOBBING=y .config + then + GLOB="; glob" + fi + VER="($GCCV; $CRTV$GLOB)" + make -j $(nproc) EXTRAVERSION="-`git describe --match=FRP`" MINGW_VER="$VER" + ) +done -- cgit v1.2.3-55-g6feb