Move manpages from doc/ to doc/man1/
[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 for fil in ./doc/wimlib-imagex.1 ./doc/wimlib-imagex-*.1; do
42         base=`basename $fil`
43         base=${base%%.1}
44         cmd=$(echo $base | sed s/wimlib-imagex-//)
45         if [ $cmd == mount -o $cmd == mountrw -o $cmd == unmount ]; then
46                 continue
47         fi
48
49         echo $fil
50         #MANWIDTH=80 man $fil | col -b > $DESTDIR/doc/$base
51         man -t $fil | ps2pdf - $DESTDIR/doc/${base}.pdf
52         sed 's/$/\r/g' > $DESTDIR/wim${cmd}.cmd <<- EOF
53                 @echo off
54                 %~dp0\\wimlib-imagex $cmd %*
55         EOF
56 done
57
58 #for fil in $DESTDIR/{README*,NEWS} $DESTDIR/doc/*; do
59 for fil in $DESTDIR/{README*,NEWS}; do
60         sed < $fil > ${fil}.txt -e 's/$/\r/g'
61         rm $fil
62 done
63
64 ${WIMLIB_ARCH}-w64-mingw32-strip $DESTDIR/*.{dll,exe}
65
66 rm -f $ZIPFILE
67 (
68         dir=$PWD
69         cd $DESTDIR
70         zip -r $dir/$ZIPFILE .
71 )