wimlib-imagex: Include WIMBoot options in usage printout
[wimlib] / make-windows-release
1 #!/bin/bash
2
3 set -e -u
4
5 WIMLIB_ARCH=i686
6 if [ $# -ge 1 ]; then
7         WIMLIB_ARCH=$1
8 fi
9
10 if [ $# -ge 2 ]; then
11         CONF_EXTRA_ARGS="$2"
12 else
13         CONF_EXTRA_ARGS=
14 fi
15
16 if [[ $WIMLIB_ARCH = i686 ]] ; then
17         DESTDIR=/mnt/tmp/wimlib
18 elif [[ $WIMLIB_ARCH = x86_64 ]]; then
19         DESTDIR=/mnt/tmp/x64/wimlib
20 else
21         echo "Unknown architecture $1" 1>&2
22         exit 2
23 fi
24
25 VERSION=$(grep 'This is wimlib version' README | grep -o '[0-9]\+\.[0-9]\+\.[0-9]')
26 ZIPFILE=wimlib-${VERSION}-windows-${WIMLIB_ARCH}-bin.zip
27
28 if ! grep -q "./configure --host=${WIMLIB_ARCH}-w64-mingw32" config.log; then
29         ./configure --host=${WIMLIB_ARCH}-w64-mingw32 $CONF_EXTRA_ARGS
30         make clean
31 fi
32
33 make -j2
34
35 rm -f $DESTDIR/{libwim-*.dll,doc/*,README*,NEWS*,wim*.bat,wim*.cmd}
36
37 cp .libs/imagex.exe $DESTDIR/wimlib-imagex.exe
38 cp .libs/libwim-*.dll $DESTDIR
39 cp README* NEWS $DESTDIR
40
41 function genman() {
42         local name=$1
43         local dest=$DESTDIR/doc/${name}.pdf
44
45         echo "Generating $dest"
46
47         MANPATH="./doc" man -t $name | ps2pdf - $dest
48 }
49
50 for fil in ./doc/man1/wimlib-imagex-*.1; do
51         base=`basename $fil`
52         base=${base%%.1}
53         cmd=$(echo $base | sed s/wimlib-imagex-//)
54         if [ $cmd == mount -o $cmd == mountrw -o $cmd == unmount ]; then
55                 continue
56         fi
57
58         genman $base
59
60         sed 's/$/\r/g' > $DESTDIR/wim${cmd}.cmd <<- EOF
61                 @echo off
62                 %~dp0\\wimlib-imagex $cmd %*
63         EOF
64 done
65
66 genman wimlib-imagex
67
68 for fil in $DESTDIR/{README*,NEWS}; do
69         sed < $fil > ${fil}.txt -e 's/$/\r/g'
70         rm $fil
71 done
72
73 ${WIMLIB_ARCH}-w64-mingw32-strip $DESTDIR/*.{dll,exe}
74
75 rm -f $ZIPFILE
76 (
77         dir=$PWD
78         cd $DESTDIR
79         zip -r $dir/$ZIPFILE .
80 )