Add ax_pthread.m4
[wimlib] / make-windows-release
1 #!/bin/bash
2
3 set -e
4
5 WIMLIB_ARCH=i686
6 if [ $# -ge 1 ]; then
7         WIMLIB_ARCH=$1
8         shift
9 fi
10
11 if [[ $WIMLIB_ARCH = i686 ]] ; then
12         DESTDIR=/mnt/tmp/wimlib
13 elif [[ $WIMLIB_ARCH = x86_64 ]]; then
14         DESTDIR=/mnt/tmp/x64/wimlib
15 else
16         echo "Unknown architecture $1" 1>&2
17         exit 2
18 fi
19
20 CONF_EXTRA_ARGS=("$@")
21
22 VERSION=$(grep 'This is wimlib version' README | \
23           grep -o '\<[0-9]\+\.[0-9]\+\.[0-9]\+\(-BETA\)\?\>')
24 ZIPFILE=wimlib-${VERSION}-windows-${WIMLIB_ARCH}-bin.zip
25
26 if ! grep -q "./configure --host=${WIMLIB_ARCH}-w64-mingw32" config.log; then
27         ./configure --host=${WIMLIB_ARCH}-w64-mingw32 "${CONF_EXTRA_ARGS[@]}"
28         make clean
29 fi
30
31 make -j2
32
33 rm -f $DESTDIR/{libwim-*.dll,doc/*,wim*.bat,wim*.cmd}
34
35 TEXTFILES=(NEWS README* COPYING*)
36
37 cp .libs/wimlib-imagex.exe $DESTDIR/wimlib-imagex.exe
38 cp .libs/libwim-*.dll $DESTDIR
39 cp "${TEXTFILES[@]}" $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 "${TEXTFILES[@]/#/$DESTDIR/}"; 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 )