3 # This script prepares a Windows binary distribution of wimlib on Linux using
4 # MinGW-w64. The desired architecture must be passed as the first argument.
8 if [ ! -e src/wim.c ]; then
9 echo "This script must be run from the toplevel directory" 1>&2
14 echo "Usage: $0 i686|x86_64" 1>&2
25 echo "ERROR: ARCH must be i686 or x86_64" 1>&2
30 VERSION=$(grep 'This is wimlib version' README | \
31 grep -o '\<[0-9]\+\.[0-9]\+\.[0-9]\+\(-BETA\)\?\>')
32 DESTDIR=wimlib-${VERSION}-windows-${ARCH}-bin
33 ZIPFILE=wimlib-${VERSION}-windows-${ARCH}-bin.zip
34 MAKE="make -j $(grep -c processor /proc/cpuinfo)"
35 WINDEPDIR=./tools/windeps
36 SYSROOT=$WINDEPDIR/sysroot_${ARCH}
38 # Prepare third party libraries
40 if [ ! -e $SYSROOT ]; then
41 $MAKE -C $WINDEPDIR sysroot_${ARCH}
46 if ! grep -q "./configure --host=${ARCH}-w64-mingw32" config.log || \
47 ! grep -q "configure: exit 0" config.log
49 # Note: putting -static-libgcc in CC is a workaround for libtool
51 # http://www.gnu.org/software/libtool/manual/libtool.html#Stripped-link-flags
52 ./configure --host=${ARCH}-w64-mingw32 --disable-static \
53 CC="${ARCH}-w64-mingw32-gcc -static-libgcc" \
55 CPPFLAGS="-I$SYSROOT/include -I$SYSROOT/include/libxml2"\
56 LDFLAGS="-L$SYSROOT/lib"
61 # Create empty destination directory
68 cp .libs/*.{dll,exe} $DESTDIR
69 ${ARCH}-w64-mingw32-strip $DESTDIR/*.{dll,exe}
73 cp NEWS README* COPYING* $DESTDIR
74 cp $WINDEPDIR/COPYING* $DESTDIR
77 for fil in NEWS README* COPYING*; do
78 sed < $fil > ${fil}.txt -e 's/$/\r/g'
88 function gen_pdf_from_man_page() {
90 local pdf=${DESTDIR}/doc/${manbase}.pdf
92 echo "Generating $pdf"
94 MANPATH="./doc" man -t $manbase | ps2pdf - $pdf
97 for fil in ./doc/man1/wimlib-imagex-*.1; do
98 manbase=`basename $fil`
99 manbase=${manbase%%.1}
100 cmd=$(echo $manbase | sed s/wimlib-imagex-//)
101 if [ $cmd == mount -o $cmd == mountrw -o $cmd == unmount ]; then
105 gen_pdf_from_man_page $manbase
107 sed 's/$/\r/g' > ${DESTDIR}/wim${cmd}.cmd <<- EOF
109 %~dp0\\wimlib-imagex $cmd %*
111 chmod +x ${DESTDIR}/wim${cmd}.cmd
114 gen_pdf_from_man_page wimlib-imagex
122 7z -mx9 a "$dir/$ZIPFILE" .