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 [EXTRA_CONFIGURE_ARG]..." 1>&2
25 echo "ERROR: ARCH must be i686 or x86_64" 1>&2
30 VERSION=$(tools/get-version-number)
31 DESTDIR=wimlib-${VERSION}-windows-${ARCH}-bin
32 ZIPFILE=wimlib-${VERSION}-windows-${ARCH}-bin.zip
33 MAKE="make -j $(grep -c processor /proc/cpuinfo)"
37 if ! [ -e config.log ] ||
38 ! grep -q "./configure --host=${ARCH}-w64-mingw32" config.log || \
39 ! grep -q "configure: exit 0" config.log || \
42 # Note: putting -static-libgcc in CC is a workaround for libtool
44 # http://www.gnu.org/software/libtool/manual/libtool.html#Stripped-link-flags
45 ./configure --host=${ARCH}-w64-mingw32 --disable-static \
46 CC="${ARCH}-w64-mingw32-gcc -static-libgcc" "$@"
51 # Create empty destination directory
58 cp .libs/*.{dll,exe} $DESTDIR
59 ${ARCH}-w64-mingw32-strip $DESTDIR/*.{dll,exe}
63 cp NEWS README* COPYING* $DESTDIR
65 sed -n '/^#/q; s/^[\/\* ]*//; p' src/divsufsort.c > $DESTDIR/COPYING.libdivsufsort-lite
66 if ! grep -q 'Copyright' $DESTDIR/COPYING.libdivsufsort-lite; then
67 echo "ERROR: failed to extract libdivsufsort-lite license text" 1>&2
72 for fil in NEWS README* COPYING*; do
73 sed < $fil > ${fil}.txt -e 's/$/\r/g'
83 function gen_pdf_from_man_page() {
85 local pdf=${DESTDIR}/doc/${manbase}.pdf
87 echo "Generating $pdf"
89 MANPATH="./doc" man -t $manbase | ps2pdf - $pdf
92 for fil in ./doc/man1/wim*.1; do
93 manbase=`basename $fil`
96 wimlib-imagex|wimmount|wimmountrw|wimunmount)
101 gen_pdf_from_man_page $cmd
103 sed 's/$/\r/g' > ${DESTDIR}/${cmd}.cmd <<- EOF
105 "%~dp0\\wimlib-imagex" ${cmd#wim} %*
107 chmod +x ${DESTDIR}/${cmd}.cmd
110 gen_pdf_from_man_page wimlib-imagex
112 # Install development files
115 cp .libs/libwim.dll.a $DESTDIR/devel/libwim.lib
116 cp include/wimlib.h $DESTDIR/devel/
124 7z -mx9 a "$dir/$ZIPFILE" .