diff options
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/mswin-build/README | 26 | ||||
| -rwxr-xr-x | examples/mswin-build/mkprerelease | 84 | ||||
| -rwxr-xr-x | examples/mswin-build/mkrelease | 104 |
3 files changed, 214 insertions, 0 deletions
diff --git a/examples/mswin-build/README b/examples/mswin-build/README new file mode 100644 index 000000000..e1d550d74 --- /dev/null +++ b/examples/mswin-build/README | |||
| @@ -0,0 +1,26 @@ | |||
| 1 | These scripts can be used to cross-compile busybox-w32 on a | ||
| 2 | Fedora Linux system with mingw-w64 and llvm-mingw toolchains. | ||
| 3 | The former are available from the Fedora repositories; the | ||
| 4 | latter needs to be downloaded and installed from: | ||
| 5 | |||
| 6 | https://github.com/mstorsjo/llvm-mingw | ||
| 7 | |||
| 8 | The script should be run from the directory above a git repository | ||
| 9 | named busybox-w32. The builds are performed in the directories | ||
| 10 | named in the TARGETS variable in the scripts. Previous copies of | ||
| 11 | these directories are deleted. | ||
| 12 | |||
| 13 | The scripts check out the master branch of the git repository. You | ||
| 14 | should edit the script if you wish to build from a different commit. | ||
| 15 | |||
| 16 | The build time recorded in the executables is the time of the checked | ||
| 17 | out commit. This may not result in a perfectly reproducible build | ||
| 18 | but it's a step in that direction. | ||
| 19 | |||
| 20 | The release build performs some additional optimisation and takes | ||
| 21 | slightly longer as a result. | ||
| 22 | |||
| 23 | The busybox-w32 help message includes information about the build | ||
| 24 | platform. Obtaining this information is very specific to the | ||
| 25 | platform used: you may need to adjust this if building on something | ||
| 26 | other than Fedora. | ||
diff --git a/examples/mswin-build/mkprerelease b/examples/mswin-build/mkprerelease new file mode 100755 index 000000000..7562c8557 --- /dev/null +++ b/examples/mswin-build/mkprerelease | |||
| @@ -0,0 +1,84 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # | ||
| 3 | # Build busybox prerelease binaries | ||
| 4 | # | ||
| 5 | TARGETS="build_pre_32 build_pre_64 build_pre_64a build_pre_64u" | ||
| 6 | |||
| 7 | # If an argument is supplied it overrides the default source directory. | ||
| 8 | SRC=busybox-w32 | ||
| 9 | if [ $# -eq 1 ] | ||
| 10 | then | ||
| 11 | SRC=$1 | ||
| 12 | fi | ||
| 13 | |||
| 14 | if [ ! -d $SRC ] | ||
| 15 | then | ||
| 16 | echo "$SRC doesn't exist" | ||
| 17 | exit 0 | ||
| 18 | fi | ||
| 19 | |||
| 20 | # remove old and make new build directories | ||
| 21 | for i in $TARGETS | ||
| 22 | do | ||
| 23 | rm -rf $i | ||
| 24 | cp -rp $SRC $i | ||
| 25 | done | ||
| 26 | |||
| 27 | # apply default configuration | ||
| 28 | for i in $TARGETS | ||
| 29 | do | ||
| 30 | ( | ||
| 31 | if [ $i = "build_pre_64" ] | ||
| 32 | then | ||
| 33 | CONFIG=mingw64_defconfig | ||
| 34 | elif [ $i = "build_pre_64u" ] | ||
| 35 | then | ||
| 36 | CONFIG=mingw64u_defconfig | ||
| 37 | elif [ $i = "build_pre_64a" ] | ||
| 38 | then | ||
| 39 | CONFIG=mingw64a_defconfig | ||
| 40 | PATH="/data2/llvm/current/bin:$PATH" | ||
| 41 | elif [ $i = "build_pre_32" ] | ||
| 42 | then | ||
| 43 | CONFIG=mingw32_defconfig | ||
| 44 | fi | ||
| 45 | |||
| 46 | cd $i | ||
| 47 | git checkout master | ||
| 48 | SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) TZ=UTC0 \ | ||
| 49 | make ${CONFIG} | ||
| 50 | ) | ||
| 51 | done | ||
| 52 | |||
| 53 | # perform build | ||
| 54 | for i in $TARGETS | ||
| 55 | do | ||
| 56 | BITS=64 | ||
| 57 | if [ $i = "build_pre_32" ] | ||
| 58 | then | ||
| 59 | BITS=32; | ||
| 60 | fi | ||
| 61 | |||
| 62 | ( | ||
| 63 | cd $i | ||
| 64 | if [ $i = "build_pre_64a" ] | ||
| 65 | then | ||
| 66 | # /data2/llvm/current should be a symlink | ||
| 67 | PATH="/data2/llvm/current/bin:$PATH" | ||
| 68 | VERSION=$(readlink /data2/llvm/current) | ||
| 69 | else | ||
| 70 | GCCV=$(rpm -q --qf '%{name} %{version}-%{release}\n' mingw${BITS}-gcc) | ||
| 71 | CRTV=$(rpm -q --qf '%{name} %{version}-%{release}\n' mingw${BITS}-crt) | ||
| 72 | VERSION="$GCCV; $CRTV" | ||
| 73 | fi | ||
| 74 | SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) TZ=UTC0 \ | ||
| 75 | make -j $(nproc) EXTRAVERSION="-$(git describe --match=FRP | sed 's/FRP/PRE/')" MINGW_VER="$VERSION" | ||
| 76 | ) | ||
| 77 | done | ||
| 78 | |||
| 79 | # Check the expected binaries exist | ||
| 80 | echo | ||
| 81 | for i in $TARGETS | ||
| 82 | do | ||
| 83 | ls -l $i/busybox.exe | ||
| 84 | done | ||
diff --git a/examples/mswin-build/mkrelease b/examples/mswin-build/mkrelease new file mode 100755 index 000000000..2f59dce13 --- /dev/null +++ b/examples/mswin-build/mkrelease | |||
| @@ -0,0 +1,104 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # | ||
| 3 | # Build 32- and 64-bit busybox binaries for release | ||
| 4 | # | ||
| 5 | TARGETS="build_32 build_64 build_64a build_64u" | ||
| 6 | |||
| 7 | if [ ! -d busybox-w32 ] | ||
| 8 | then | ||
| 9 | echo "busybox-w32 doesn't exist" | ||
| 10 | exit 0 | ||
| 11 | fi | ||
| 12 | |||
| 13 | # remove old and make new build directories | ||
| 14 | for i in $TARGETS | ||
| 15 | do | ||
| 16 | rm -rf $i | ||
| 17 | cp -rp busybox-w32 $i | ||
| 18 | done | ||
| 19 | |||
| 20 | # apply default configuration | ||
| 21 | for i in $TARGETS | ||
| 22 | do | ||
| 23 | ( | ||
| 24 | if [ $i = "build_64" ] | ||
| 25 | then | ||
| 26 | CONFIG=mingw64_defconfig | ||
| 27 | BITS=64 | ||
| 28 | elif [ $i = "build_64a" ] | ||
| 29 | then | ||
| 30 | PATH="/data2/llvm/current/bin:$PATH" | ||
| 31 | CONFIG=mingw64a_defconfig | ||
| 32 | BITS=64 | ||
| 33 | elif [ $i = "build_64u" ] | ||
| 34 | then | ||
| 35 | CONFIG=mingw64u_defconfig | ||
| 36 | BITS=64 | ||
| 37 | elif [ $i = "build_32" ] | ||
| 38 | then | ||
| 39 | CONFIG=mingw32_defconfig | ||
| 40 | BITS=32 | ||
| 41 | fi | ||
| 42 | |||
| 43 | cd $i | ||
| 44 | git checkout master | ||
| 45 | SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) TZ=UTC0 \ | ||
| 46 | make ${CONFIG} | ||
| 47 | |||
| 48 | # The clang/aarch64 build is not subject to optimisation. The | ||
| 49 | # '-flto' option increased the size of the binary slightly (0.23%) | ||
| 50 | # and decreased the time to run the testsuite slightly (0.33%). | ||
| 51 | # It hardly seems worth bothering about. | ||
| 52 | # | ||
| 53 | if [ $i != "build_64a" ] | ||
| 54 | then | ||
| 55 | # link time optimisation, stack protection | ||
| 56 | sed -e 's/^CONFIG_EXTRA_CFLAGS="\(.*\)"$/CONFIG_EXTRA_CFLAGS="\1 -flto -fstack-protector --param=ssp-buffer-size=4"/' \ | ||
| 57 | -e 's/^CONFIG_EXTRA_CFLAGS=" /CONFIG_EXTRA_CFLAGS="/' \ | ||
| 58 | -e 's/^CONFIG_EXTRA_LDLIBS="\(.*\)"$/CONFIG_EXTRA_LDLIBS="\1 -l:libssp.a"/' \ | ||
| 59 | -e 's/^CONFIG_EXTRA_LDLIBS=" /CONFIG_EXTRA_LDLIBS="/' \ | ||
| 60 | -i .config | ||
| 61 | # does ld support --disable-reloc-section? | ||
| 62 | eval $(grep CONFIG_CROSS_COMPILER_PREFIX .config) | ||
| 63 | [ $BITS -eq 32 ] && [ -n "$CONFIG_CROSS_COMPILER_PREFIX" ] && \ | ||
| 64 | ${CONFIG_CROSS_COMPILER_PREFIX}ld --help | \ | ||
| 65 | grep -q disable-reloc-section && | ||
| 66 | sed -e 's/^CONFIG_EXTRA_LDFLAGS="\(.*\)"$/CONFIG_EXTRA_LDFLAGS="\1 -Wl,--disable-reloc-section"/' \ | ||
| 67 | -e 's/^CONFIG_EXTRA_LDFLAGS=" /CONFIG_EXTRA_LDFLAGS="/' \ | ||
| 68 | -i .config | ||
| 69 | fi | ||
| 70 | ) | ||
| 71 | done | ||
| 72 | |||
| 73 | # perform build | ||
| 74 | for i in $TARGETS | ||
| 75 | do | ||
| 76 | BITS=64 | ||
| 77 | if [ $i = "build_32" ] | ||
| 78 | then | ||
| 79 | BITS=32 | ||
| 80 | fi | ||
| 81 | |||
| 82 | ( | ||
| 83 | cd $i | ||
| 84 | if [ $i = "build_64a" ] | ||
| 85 | then | ||
| 86 | # /data2/llvm/current should be a symlink | ||
| 87 | PATH="/data2/llvm/current/bin:$PATH" | ||
| 88 | VERSION=$(readlink /data2/llvm/current) | ||
| 89 | else | ||
| 90 | GCCV=$(rpm -q --qf '%{name} %{version}-%{release}\n' mingw${BITS}-gcc) | ||
| 91 | CRTV=$(rpm -q --qf '%{name} %{version}-%{release}\n' mingw${BITS}-crt) | ||
| 92 | VERSION="$GCCV; $CRTV" | ||
| 93 | fi | ||
| 94 | SOURCE_DATE_EPOCH=$(git log -1 --pretty=%ct) TZ=UTC0 \ | ||
| 95 | make -j $(nproc) EXTRAVERSION="-`git describe --match=FRP`" MINGW_VER="$VERSION" | ||
| 96 | ) | ||
| 97 | done | ||
| 98 | |||
| 99 | # Check the expected binaries exist | ||
| 100 | echo | ||
| 101 | for i in $TARGETS | ||
| 102 | do | ||
| 103 | ls -l $i/busybox.exe | ||
| 104 | done | ||
