Windows build updates
authorEric Biggers <ebiggers3@gmail.com>
Fri, 19 Dec 2014 03:38:48 +0000 (21:38 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Fri, 19 Dec 2014 04:40:15 +0000 (22:40 -0600)
NEWS
README.WINDOWS
clang-scan-build.sh [deleted file]
configure.ac
make-releases [deleted file]
make-windows-release [deleted file]
tools/clang-scan-build [new file with mode: 0755]
tools/make-releases [new file with mode: 0755]
tools/make-windows-release [new file with mode: 0755]
tools/update-version [moved from update-version with 92% similarity]
tools/windeps/Makefile [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index e374642..5f6394b 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,9 @@ Version 1.7.4-BETA:
        the target files do not yet exist.  (Broken since v1.7.0, but actually a
        result of a Microsoft bug.)
 
+       The Windows binary distribution no longer contain third party DLLs.
+       These dependencies are instead compiled directly into libwim.dll.
+
        More fixes for wimlib on non-x86 architectures such as ARM.
 
        Slight performance improvements in compression and decompression.
index 775d545..0ebea29 100644 (file)
@@ -22,9 +22,8 @@ ZIP file containing the following items:
   * The documentation, including this file, the generic README.txt, and
     PDF documentation for wimlib-imagex in the 'doc' directory.
 
-  * Various DLL (.dll) files, including the wimlib library itself
-    (libwim-15.dll).  The C header wimlib.h is not included; download the source
-    if you want it.
+  * The library itself (libwim-15.dll).  The C header wimlib.h is not
+    included; download the source if you want it.
 
   * License files for all software included.  These are all free software
     licenses.
diff --git a/clang-scan-build.sh b/clang-scan-build.sh
deleted file mode 100644 (file)
index 32d4127..0000000
+++ /dev/null
@@ -1 +0,0 @@
-scan-build --use-analyzer=/bin/clang clang src/*.c programs/imagex.c -o imagex -D_FILE_OFFSET_BITS=64 -std=gnu99 -lntfs-3g -lxml2 -lfuse -lpthread -lrt -Iinclude/ -I./ -I/usr/include/libxml2/ -D HAVE_CONFIG_H -Wno-pointer-sign -D_GNU_SOURCE -lcrypto
index 581710e..e5e834f 100644 (file)
@@ -96,7 +96,7 @@ AC_CHECK_MEMBER([struct stat.st_mtim],
 AX_PTHREAD([], [AC_MSG_ERROR(["cannot find pthreads library"])])
 
 # ------------------------------ libxml2 --------------------------------------
-AC_CHECK_LIB([xml2], [xmlParseFile], [],
+AC_CHECK_LIB([xml2], [xmlReadMemory], [],
             [AC_MSG_ERROR(["cannot find libxml2"])])
 PKG_CHECK_MODULES([LIBXML2], [libxml-2.0])
 PKGCONFIG_PRIVATE_REQUIRES="$PKGCONFIG_PRIVATE_REQUIRES libxml-2.0"
diff --git a/make-releases b/make-releases
deleted file mode 100755 (executable)
index 8eb4ea3..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-
-set -e -u
-
-./configure && make distcheck
-for arch in i686 x86_64; do
-       ./make-windows-release ${arch}
-done
diff --git a/make-windows-release b/make-windows-release
deleted file mode 100755 (executable)
index be897d1..0000000
+++ /dev/null
@@ -1,80 +0,0 @@
-#!/bin/bash
-
-set -e
-
-WIMLIB_ARCH=i686
-if [ $# -ge 1 ]; then
-       WIMLIB_ARCH=$1
-       shift
-fi
-
-if [[ $WIMLIB_ARCH = i686 ]] ; then
-       DESTDIR=/mnt/tmp/wimlib
-elif [[ $WIMLIB_ARCH = x86_64 ]]; then
-       DESTDIR=/mnt/tmp/x64/wimlib
-else
-       echo "Unknown architecture $1" 1>&2
-       exit 2
-fi
-
-CONF_EXTRA_ARGS=("$@")
-
-VERSION=$(grep 'This is wimlib version' README | \
-         grep -o '\<[0-9]\+\.[0-9]\+\.[0-9]\+\(-BETA\)\?\>')
-ZIPFILE=wimlib-${VERSION}-windows-${WIMLIB_ARCH}-bin.zip
-
-if ! grep -q "./configure --host=${WIMLIB_ARCH}-w64-mingw32" config.log; then
-       ./configure --host=${WIMLIB_ARCH}-w64-mingw32 "${CONF_EXTRA_ARGS[@]}"
-       make clean
-fi
-
-make -j2
-
-rm -f $DESTDIR/{libwim-*.dll,doc/*,wim*.bat,wim*.cmd}
-
-TEXTFILES=(NEWS README* COPYING*)
-
-cp .libs/wimlib-imagex.exe $DESTDIR/wimlib-imagex.exe
-cp .libs/libwim-*.dll $DESTDIR
-cp "${TEXTFILES[@]}" $DESTDIR
-
-function genman() {
-       local name=$1
-       local dest=$DESTDIR/doc/${name}.pdf
-
-       echo "Generating $dest"
-
-       MANPATH="./doc" man -t $name | ps2pdf - $dest
-}
-
-for fil in ./doc/man1/wimlib-imagex-*.1; do
-       base=`basename $fil`
-       base=${base%%.1}
-       cmd=$(echo $base | sed s/wimlib-imagex-//)
-       if [ $cmd == mount -o $cmd == mountrw -o $cmd == unmount ]; then
-               continue
-       fi
-
-       genman $base
-
-       sed 's/$/\r/g' > $DESTDIR/wim${cmd}.cmd <<- EOF
-               @echo off
-               %~dp0\\wimlib-imagex $cmd %*
-       EOF
-done
-
-genman wimlib-imagex
-
-for fil in "${TEXTFILES[@]/#/$DESTDIR/}"; do
-       sed < $fil > ${fil}.txt -e 's/$/\r/g'
-       rm $fil
-done
-
-${WIMLIB_ARCH}-w64-mingw32-strip $DESTDIR/*.{dll,exe}
-
-rm -f $ZIPFILE
-(
-       dir=$PWD
-       cd $DESTDIR
-       zip -r $dir/$ZIPFILE .
-)
diff --git a/tools/clang-scan-build b/tools/clang-scan-build
new file mode 100755 (executable)
index 0000000..34b1467
--- /dev/null
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+exec scan-build --use-analyzer=/usr/bin/clang /usr/bin/clang   \
+       src/*.c programs/imagex.c -o wimlib-imagex              \
+       -std=c99 -Wno-pointer-sign                              \
+       -D_GNU_SOURCE -DHAVE_CONFIG_H -D_FILE_OFFSET_BITS=64    \
+       -Iinclude -I. -I/usr/include/libxml2                    \
+       -lntfs-3g -lxml2 -lfuse -lpthread -lrt -lcrypto
diff --git a/tools/make-releases b/tools/make-releases
new file mode 100755 (executable)
index 0000000..5505bb5
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+set -e
+
+MAKE="make -j$(grep -c processor /proc/cpuinfo)"
+
+./configure && $MAKE distcheck
+
+# Recompress with 7-Zip
+gzfile=$(ls wimlib-*.tar.gz | tail -1)
+tarfile=${gzfile%.gz}
+gunzip $gzfile
+7z -mx9 a $gzfile $tarfile
+rm -f $tarfile
+
+for arch in i686 x86_64; do
+       ./tools/make-windows-release $arch
+done
diff --git a/tools/make-windows-release b/tools/make-windows-release
new file mode 100755 (executable)
index 0000000..ee9790d
--- /dev/null
@@ -0,0 +1,123 @@
+#!/bin/bash
+#
+# This script prepares a Windows binary distribution of wimlib on Linux using
+# MinGW-w64.  The desired architecture must be passed as the first argument.
+
+set -e
+
+if [ ! -e src/wim.c ]; then
+       echo "This script must be run from the toplevel directory" 1>&2
+       exit 1
+fi
+
+if [ $# -ne 1 ]; then
+       echo "Usage: $0 i686|x86_64" 1>&2
+       exit 1
+fi
+
+ARCH="$1"
+shift
+
+case "$ARCH" in
+i686|x86_64)
+       ;;
+*)
+       echo "ERROR: ARCH must be i686 or x86_64" 1>&2
+       exit 1
+       ;;
+esac
+
+VERSION=$(grep 'This is wimlib version' README | \
+         grep -o '\<[0-9]\+\.[0-9]\+\.[0-9]\+\(-BETA\)\?\>')
+DESTDIR=wimlib-${VERSION}-windows-${ARCH}-bin
+ZIPFILE=wimlib-${VERSION}-windows-${ARCH}-bin.zip
+MAKE="make -j $(grep -c processor /proc/cpuinfo)"
+WINDEPDIR=./tools/windeps
+SYSROOT=$WINDEPDIR/sysroot_${ARCH}
+
+# Prepare third party libraries
+
+if [ ! -e $SYSROOT ]; then
+       $MAKE -C $WINDEPDIR sysroot_${ARCH}
+fi
+
+# Compile wimlib
+
+if ! grep -q "./configure --host=${ARCH}-w64-mingw32" config.log || \
+       ! grep -q "configure: exit 0" config.log
+then
+       # Note: putting -static-libgcc in CC is a workaround for libtool
+       # stripping it:
+       # http://www.gnu.org/software/libtool/manual/libtool.html#Stripped-link-flags
+       ./configure --host=${ARCH}-w64-mingw32 --disable-static         \
+               CC="${ARCH}-w64-mingw32-gcc -static-libgcc"             \
+               CFLAGS="-O2 -Wall"                                      \
+               CPPFLAGS="-I$SYSROOT/include -I$SYSROOT/include/libxml2"\
+               LDFLAGS="-L$SYSROOT/lib"
+       $MAKE clean
+fi
+$MAKE
+
+# Create empty destination directory
+
+rm -rf $DESTDIR
+mkdir $DESTDIR
+
+# Install binaries
+
+cp .libs/*.{dll,exe} $DESTDIR
+${ARCH}-w64-mingw32-strip $DESTDIR/*.{dll,exe}
+
+# Install text files
+
+cp NEWS README* COPYING* $DESTDIR
+cp $WINDEPDIR/COPYING* $DESTDIR
+(
+       cd $DESTDIR
+       for fil in NEWS README* COPYING*; do
+               sed < $fil > ${fil}.txt -e 's/$/\r/g'
+               rm $fil
+       done
+)
+
+
+# Install man pages
+
+mkdir $DESTDIR/doc
+
+function gen_pdf_from_man_page() {
+       local manbase=$1
+       local pdf=${DESTDIR}/doc/${manbase}.pdf
+
+       echo "Generating $pdf"
+
+       MANPATH="./doc" man -t $manbase | ps2pdf - $pdf
+}
+
+for fil in ./doc/man1/wimlib-imagex-*.1; do
+       manbase=`basename $fil`
+       manbase=${manbase%%.1}
+       cmd=$(echo $manbase | sed s/wimlib-imagex-//)
+       if [ $cmd == mount -o $cmd == mountrw -o $cmd == unmount ]; then
+               continue
+       fi
+
+       gen_pdf_from_man_page $manbase
+
+       sed 's/$/\r/g' > ${DESTDIR}/wim${cmd}.cmd <<- EOF
+               @echo off
+               %~dp0\\wimlib-imagex $cmd %*
+       EOF
+       chmod +x ${DESTDIR}/wim${cmd}.cmd
+done
+
+gen_pdf_from_man_page wimlib-imagex
+
+# Generate ZIP file
+
+rm -f $ZIPFILE
+(
+       dir=$PWD
+       cd $DESTDIR
+       7z -mx9 a "$dir/$ZIPFILE" .
+)
similarity index 92%
rename from update-version
rename to tools/update-version
index b15fbfd..2253059 100755 (executable)
@@ -23,7 +23,7 @@ sed -i -e 's/\(#define WIMLIB_MAJOR_VERSION[[:space:]]\+\)[[:digit:]]\+/\1'$newm
        -e 's/\(the library interface of wimlib \)'$oldver'/\1'$newver'/' \
          include/wimlib.h
 
-sed -i -e "1s/$oldmonth $oldyear/$newmonth $newyear/;s/wimlib $oldver/wimlib $newver/" \
+sed -i -e "1s/$oldmonth $oldyear/$newmonth $newyear/;1s/wimlib $oldver/wimlib $newver/"        \
          doc/man[1-9]/*.[1-9]
 
 sed -i "s/pkgver=$oldver/pkgver=$newver/" archlinux/PKGBUILD
diff --git a/tools/windeps/Makefile b/tools/windeps/Makefile
new file mode 100644 (file)
index 0000000..060e63b
--- /dev/null
@@ -0,0 +1,131 @@
+#
+# This Makefile builds the third-party libraries needed to build a standalone
+# libwim.dll for Windows.  We build these third-party libraries ourselves mainly
+# to cut down on bloat.
+#
+# Among other things, this Makefile requires MinGW-w64 (i686 and x86_64
+# versions) and a windeps.wim containing the following images:
+#
+#      - libxml2-2.9.2
+#      - winpthreads
+#      - win-iconv-0.0.6
+
+ARCHITECTURES          := i686 x86_64
+LIBXML_VERSION         := 2-2.9.2
+WINPTHREADS_VERSION    :=
+WINICONV_VERSION       := -0.0.6
+
+LIBXML_SRCDIR          := libxml$(LIBXML_VERSION)
+SOURCE_TARGETS         += $(LIBXML_SRCDIR)
+$(LIBXML_SRCDIR):
+       wimapply --unix-data windeps.wim $(LIBXML_SRCDIR) $(LIBXML_SRCDIR)
+       cp $(LIBXML_SRCDIR)/COPYING COPYING.libxml2
+MAKE_CLEAN_FILES += $(LIBXML_SRCDIR) COPYING.libxml2
+
+WINPTHREADS_SRCDIR     := winpthreads$(WINPTHREADS_VERSION)
+SOURCE_TARGETS         += $(WINPTHREADS_SRCDIR)
+$(WINPTHREADS_SRCDIR):
+       wimapply --unix-data windeps.wim $(WINPTHREADS_SRCDIR) $(WINPTHREADS_SRCDIR)
+       cp $(WINPTHREADS_SRCDIR)/COPYING COPYING.winpthreads
+MAKE_CLEAN_FILES += $(WINPTHREADS_SRCDIR) COPYING.winpthreads
+
+WINICONV_SRCDIR                := win-iconv$(WINICONV_VERSION)
+SOURCE_TARGETS         += $(WINICONV_SRCDIR)
+$(WINICONV_SRCDIR):
+       wimapply --unix-data windeps.wim $(WINICONV_SRCDIR) $(WINICONV_SRCDIR)
+# win-iconv is public domain, so there's no license file.
+MAKE_CLEAN_FILES       += $(WINICONV_SRCDIR)
+
+#
+# declare_libxml_target(arch)
+#
+define declare_libxml_target
+libxml_$(1):$(LIBXML_SRCDIR)
+       builddir=build_libxml_$(1);                             \
+       rm -rf $$$$builddir;                                    \
+       mkdir $$$$builddir;                                     \
+       cd $$$$builddir;                                        \
+       ../$(LIBXML_SRCDIR)/configure                           \
+               --host=$(1)-w64-mingw32                         \
+               --enable-static                                 \
+               --disable-shared                                \
+               --prefix=$$$$PWD/../sysroot_$(1)                \
+               CFLAGS=-Os                                      \
+               --with-minimum                                  \
+               --without-lzma                                  \
+               --with-writer;                                  \
+       $(MAKE) install;                                        \
+       rm -f ../sysroot_$(1)/lib/libxml2.la;
+
+$(1)_BUILD_TARGETS += libxml_$(1)
+MAKE_CLEAN_FILES += build_libxml_$(1)
+endef
+
+#
+# declare_winpthreads_target(arch)
+#
+define declare_winpthreads_target
+winpthreads_$(1):$(WINPTHREADS_SRCDIR)
+       builddir=build_winpthreads_$(1);                        \
+       rm -rf $$$$builddir;                                    \
+       cp -r $(WINPTHREADS_SRCDIR) $$$$builddir;               \
+       cd $$$$builddir;                                        \
+       ./configure                                             \
+               --host=$(1)-w64-mingw32                         \
+               --enable-static                                 \
+               --disable-shared                                \
+               --prefix=$$$$PWD/../sysroot_$(1)                \
+               CFLAGS=-O2;                                     \
+       $(MAKE) install;                                        \
+       sed -i 's/if defined DLL_EXPORT/if 0/' ../sysroot_$(1)/include/pthread.h;
+
+$(1)_BUILD_TARGETS += winpthreads_$(1)
+MAKE_CLEAN_FILES += build_winpthreads_$(1)
+endef
+
+#
+# declare_winiconv_target(arch)
+#
+define declare_winiconv_target
+winiconv_$(1):$(WINICONV_SRCDIR)
+       builddir=build_winiconv_$(1);                           \
+       rm -rf $$$$builddir;                                    \
+       cp -r $(WINICONV_SRCDIR) $$$$builddir;                  \
+       cd $$$$builddir;                                        \
+       $(MAKE) CC=$(1)-w64-mingw32-gcc                         \
+               AR=$(1)-w64-mingw32-ar                          \
+               RANLIB=$(1)-w64-mingw32-ranlib                  \
+               DLLTOOL=$(1)-w64-mingw32-dlltool                \
+               CFLAGS=-O2                                      \
+               prefix=$$$$PWD/../sysroot_$(1)                  \
+               install;                                        \
+       rm -f ../sysroot_$(1)/lib/libiconv.dll.a;
+
+$(1)_BUILD_TARGETS += winiconv_$(1)
+MAKE_CLEAN_FILES += build_winiconv_$(1)
+endef
+
+#
+# declare_arch_targets(arch)
+#
+define declare_arch_targets
+$(eval $(call declare_libxml_target,$(1)))
+$(eval $(call declare_winpthreads_target,$(1)))
+$(eval $(call declare_winiconv_target,$(1)))
+
+sysroot_$(1): $($(1)_BUILD_TARGETS)
+
+ALL_SYSROOTS += sysroot_$(1)
+MAKE_CLEAN_FILES += sysroot_$(1)
+endef
+
+$(foreach arch,$(ARCHITECTURES),$(eval $(call declare_arch_targets,$(arch))))
+
+all: $(ALL_SYSROOTS)
+
+clean:
+       rm -rf $(MAKE_CLEAN_FILES)
+
+.PHONY: all clean $(SOURCE_TARGETS)
+
+.DEFAULT_GOAL = all