aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/mswin-build/README26
-rwxr-xr-xexamples/mswin-build/mkprerelease84
-rwxr-xr-xexamples/mswin-build/mkrelease104
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 @@
1These scripts can be used to cross-compile busybox-w32 on a
2Fedora Linux system with mingw-w64 and llvm-mingw toolchains.
3The former are available from the Fedora repositories; the
4latter needs to be downloaded and installed from:
5
6 https://github.com/mstorsjo/llvm-mingw
7
8The script should be run from the directory above a git repository
9named busybox-w32. The builds are performed in the directories
10named in the TARGETS variable in the scripts. Previous copies of
11these directories are deleted.
12
13The scripts check out the master branch of the git repository. You
14should edit the script if you wish to build from a different commit.
15
16The build time recorded in the executables is the time of the checked
17out commit. This may not result in a perfectly reproducible build
18but it's a step in that direction.
19
20The release build performs some additional optimisation and takes
21slightly longer as a result.
22
23The busybox-w32 help message includes information about the build
24platform. Obtaining this information is very specific to the
25platform used: you may need to adjust this if building on something
26other 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#
5TARGETS="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.
8SRC=busybox-w32
9if [ $# -eq 1 ]
10then
11 SRC=$1
12fi
13
14if [ ! -d $SRC ]
15then
16 echo "$SRC doesn't exist"
17 exit 0
18fi
19
20# remove old and make new build directories
21for i in $TARGETS
22do
23 rm -rf $i
24 cp -rp $SRC $i
25done
26
27# apply default configuration
28for i in $TARGETS
29do
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 )
51done
52
53# perform build
54for i in $TARGETS
55do
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 )
77done
78
79# Check the expected binaries exist
80echo
81for i in $TARGETS
82do
83 ls -l $i/busybox.exe
84done
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#
5TARGETS="build_32 build_64 build_64a build_64u"
6
7if [ ! -d busybox-w32 ]
8then
9 echo "busybox-w32 doesn't exist"
10 exit 0
11fi
12
13# remove old and make new build directories
14for i in $TARGETS
15do
16 rm -rf $i
17 cp -rp busybox-w32 $i
18done
19
20# apply default configuration
21for i in $TARGETS
22do
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 )
71done
72
73# perform build
74for i in $TARGETS
75do
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 )
97done
98
99# Check the expected binaries exist
100echo
101for i in $TARGETS
102do
103 ls -l $i/busybox.exe
104done