mirror of
https://git.tukaani.org/xz.git
synced 2024-04-04 12:36:23 +02:00
Windows: Update windows/build.bash.
Support for the old MinGW was dropped. Only MinGW-w64 with GCC is supported now. The script now supports also cross-compilation from GNU/Linux (tests are not run). MSYS2 and also the old MSYS 1.0.11 work for building on Windows. The i686 and x86_64 toolchains must be in PATH to build both 32-bit and 64-bit versions. Parallel builds are done if "nproc" from GNU coreutils is available. MinGW-w64 runtime copyright information file was renamed from COPYING-Windows.txt to COPYING.MinGW-w64-runtime.txt which is the filename used by MinGW-w64 itself. Its existence is now mandatory, it's checked at the beginning of the script. The file TODO is no longer copied to the package.
This commit is contained in:
parent
60462e4260
commit
1ee716f740
1 changed files with 112 additions and 79 deletions
|
@ -3,20 +3,27 @@
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
#
|
#
|
||||||
# Build a binary package on Windows with MinGW and MSYS
|
# This build a XZ Utils binary package using the GNU Autotools build system
|
||||||
#
|
#
|
||||||
# Set the paths where MinGW, Mingw-w32, or MinGW-w64 are installed. If both
|
# NOTE: This requires files that are generated as part of "make mydist".
|
||||||
# MinGW and MinGW-w32 are specified, MinGW-w32 will be used. If there is no
|
# So if building from xz.git, create a distribution tarball first,
|
||||||
# 32-bit or 64-bit compiler at all, it is simply skipped.
|
# extract it, and run this script from there.
|
||||||
|
#
|
||||||
|
# These were tested and known to work:
|
||||||
|
# - Cross-compilation with MinGW-w64 v10.0.0 and GCC 12.2.0 from
|
||||||
|
# GNU/Linux ("make check" will be skipped)
|
||||||
|
# - MSYS2 with MinGW-w64 and GCC
|
||||||
|
# - MSYS 1.0.11 (from 2009) with MinGW-w64 v11.0.0 and GCC 13.1.0
|
||||||
#
|
#
|
||||||
# Optionally, 7-Zip is used to create the final .zip and .7z packages.
|
# Optionally, 7-Zip is used to create the final .zip and .7z packages.
|
||||||
# If you have installed it in the default directory, this script should
|
# If the 7z tool is in PATH or if you have installed it in the default
|
||||||
# find it automatically. Otherwise adjust the path manually.
|
# directory on Windows, this script should find it automatically.
|
||||||
#
|
#
|
||||||
# If you want to use a cross-compiler e.g. on GNU/Linux, this script won't
|
# Before running this script, copy COPYING.MinGW-w64-runtime.txt to
|
||||||
# work out of the box. You need to omit "make check" commands and replace
|
# the 'windows' directory.
|
||||||
# u2d with some other tool to convert newlines from LF to CR+LF. You will
|
#
|
||||||
# also need to pass the --host option to configure.
|
# NOTE: MinGW-w64 includes getopt_long(). The GNU getopt_long() (LGPLv2.1)
|
||||||
|
# included in XZ Utils isn't used when building with MinGW-w64.
|
||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
#
|
#
|
||||||
|
@ -24,17 +31,6 @@
|
||||||
#
|
#
|
||||||
###############################################################################
|
###############################################################################
|
||||||
|
|
||||||
MINGW_DIR=/c/devel/tools/mingw
|
|
||||||
MINGW_W32_DIR=/c/devel/tools/mingw-w32
|
|
||||||
MINGW_W64_DIR=/c/devel/tools/mingw-w64
|
|
||||||
|
|
||||||
for SEVENZ_EXE in "$PROGRAMW6432/7-Zip/7z.exe" "$PROGRAMFILES/7-Zip/7z.exe" \
|
|
||||||
"/c/Program Files/7-Zip/7z.exe"
|
|
||||||
do
|
|
||||||
[ -x "$SEVENZ_EXE" ] && break
|
|
||||||
done
|
|
||||||
|
|
||||||
|
|
||||||
# Abort immediately if something goes wrong.
|
# Abort immediately if something goes wrong.
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
@ -49,11 +45,34 @@ esac
|
||||||
if [ ! -f windows/build.bash ]; then
|
if [ ! -f windows/build.bash ]; then
|
||||||
cd ..
|
cd ..
|
||||||
if [ ! -f windows/build.bash ]; then
|
if [ ! -f windows/build.bash ]; then
|
||||||
echo "You are in a wrong directory." >&2
|
echo "ERROR: You are in a wrong directory. This script" >&2
|
||||||
|
echo "can be run either at the top-level directory of" >&2
|
||||||
|
echo "the package or in the same directory containing" >&2
|
||||||
|
echo "this script." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# COPYING.MinGW-w64-runtime.txt needs to be manually copied from MinGW-w64.
|
||||||
|
if [ ! -f windows/COPYING.MinGW-w64-runtime.txt ]; then
|
||||||
|
echo "ERROR: The file 'windows/COPYING.MinGW-w64-runtime.txt'" >&2
|
||||||
|
echo "doesn't exists. Copy it from MinGW-w64 so that the" >&2
|
||||||
|
echo "copyright and license notices of the MinGW-w64 runtime" >&2
|
||||||
|
echo "can be included in the package." >&2
|
||||||
|
echo "(Or create an empty file if only doing a test build.)" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Number of jobs for "make":
|
||||||
|
MAKE_JOBS=$(nproc 2> /dev/null || echo 1)
|
||||||
|
|
||||||
|
# "make check" has to be skipped when cross-compiling.
|
||||||
|
if [ "x$(uname -o)" = xMsys ]; then
|
||||||
|
IS_NATIVE_BUILD=true
|
||||||
|
else
|
||||||
|
IS_NATIVE_BUILD=false
|
||||||
|
fi
|
||||||
|
|
||||||
# Run configure and copy the binaries to the given directory.
|
# Run configure and copy the binaries to the given directory.
|
||||||
#
|
#
|
||||||
# The first argument is the directory where to copy the binaries.
|
# The first argument is the directory where to copy the binaries.
|
||||||
|
@ -61,9 +80,26 @@ fi
|
||||||
buildit()
|
buildit()
|
||||||
{
|
{
|
||||||
DESTDIR=$1
|
DESTDIR=$1
|
||||||
BUILD=$2
|
TRIPLET=$2
|
||||||
CFLAGS=$3
|
CFLAGS=$3
|
||||||
|
|
||||||
|
# In the MinGW-w64 + GCC toolchains running natively on Windows,
|
||||||
|
# $TRIPLET-windres and $TRIPLET-strip commands might not exist.
|
||||||
|
# Only the short names "windres" and "strip" might be available.
|
||||||
|
# If both i686 and x86_64 toolchains are in PATH, wrong windres.exe
|
||||||
|
# will be used for one of the builds, making the build fail. The
|
||||||
|
# workaround is to put the directory of $TRIPLET-gcc to the front
|
||||||
|
# of PATH if $TRIPLET-windres or $TRIPLET-strip is missing.
|
||||||
|
OLD_PATH=$PATH
|
||||||
|
if type -P "$TRIPLET-windres" > /dev/null \
|
||||||
|
&& type -P "$TRIPLET-strip" > /dev/null; then
|
||||||
|
STRIP=$TRIPLET-strip
|
||||||
|
else
|
||||||
|
STRIP=strip
|
||||||
|
GCC_DIR=$(type -P "$TRIPLET-gcc")
|
||||||
|
PATH=${GCC_DIR%/*}:$PATH
|
||||||
|
fi
|
||||||
|
|
||||||
# Clean up if it was already configured.
|
# Clean up if it was already configured.
|
||||||
[ -f Makefile ] && make distclean
|
[ -f Makefile ] && make distclean
|
||||||
|
|
||||||
|
@ -80,9 +116,13 @@ buildit()
|
||||||
--disable-threads \
|
--disable-threads \
|
||||||
--disable-shared \
|
--disable-shared \
|
||||||
--enable-small \
|
--enable-small \
|
||||||
--build="$BUILD" \
|
--host="$TRIPLET" \
|
||||||
CFLAGS="$CFLAGS -Os"
|
CFLAGS="$CFLAGS -Os"
|
||||||
make check
|
make -j"$MAKE_JOBS"
|
||||||
|
|
||||||
|
if "$IS_NATIVE_BUILD"; then
|
||||||
|
make -j"$MAKE_JOBS" check
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir -pv "$DESTDIR"
|
mkdir -pv "$DESTDIR"
|
||||||
cp -v src/xzdec/{xz,lzma}dec.exe src/lzmainfo/lzmainfo.exe "$DESTDIR"
|
cp -v src/xzdec/{xz,lzma}dec.exe src/lzmainfo/lzmainfo.exe "$DESTDIR"
|
||||||
|
@ -97,17 +137,20 @@ buildit()
|
||||||
--disable-dependency-tracking \
|
--disable-dependency-tracking \
|
||||||
--disable-nls \
|
--disable-nls \
|
||||||
--disable-scripts \
|
--disable-scripts \
|
||||||
--build="$BUILD" \
|
--host="$TRIPLET" \
|
||||||
CFLAGS="$CFLAGS -O2"
|
CFLAGS="$CFLAGS -O2"
|
||||||
make -C src/liblzma
|
make -j"$MAKE_JOBS" -C src/liblzma
|
||||||
make -C src/xz LDFLAGS=-static
|
make -j"$MAKE_JOBS" -C src/xz LDFLAGS=-static
|
||||||
make -C tests check
|
|
||||||
|
|
||||||
cp -v src/xz/xz.exe src/liblzma/.libs/liblzma.a "$DESTDIR"
|
if "$IS_NATIVE_BUILD"; then
|
||||||
cp -v src/liblzma/.libs/liblzma-*.dll "$DESTDIR/liblzma.dll"
|
make -j"$MAKE_JOBS" -C tests check
|
||||||
|
fi
|
||||||
|
|
||||||
strip -v "$DESTDIR/"*.{exe,dll}
|
cp -v src/xz/xz.exe "$DESTDIR"
|
||||||
strip -vg "$DESTDIR/"*.a
|
cp -v src/liblzma/.libs/liblzma-5.dll "$DESTDIR/liblzma.dll"
|
||||||
|
"$STRIP" -v "$DESTDIR/"*.{exe,dll}
|
||||||
|
|
||||||
|
PATH=$OLD_PATH
|
||||||
}
|
}
|
||||||
|
|
||||||
# Copy files and convert newlines from LF to CR+LF. Optionally add a suffix
|
# Copy files and convert newlines from LF to CR+LF. Optionally add a suffix
|
||||||
|
@ -115,7 +158,7 @@ buildit()
|
||||||
#
|
#
|
||||||
# The first argument is the destination directory. The second argument is
|
# The first argument is the destination directory. The second argument is
|
||||||
# the suffix to append to the filenames; use empty string if no extra suffix
|
# the suffix to append to the filenames; use empty string if no extra suffix
|
||||||
# is wanted. The rest of the arguments are actual the filenames.
|
# is wanted. The rest of the arguments are the actual filenames.
|
||||||
txtcp()
|
txtcp()
|
||||||
{
|
{
|
||||||
DESTDIR=$1
|
DESTDIR=$1
|
||||||
|
@ -124,39 +167,32 @@ txtcp()
|
||||||
for SRCFILE; do
|
for SRCFILE; do
|
||||||
DESTFILE="$DESTDIR/${SRCFILE##*/}$SUFFIX"
|
DESTFILE="$DESTDIR/${SRCFILE##*/}$SUFFIX"
|
||||||
echo "Converting '$SRCFILE' -> '$DESTFILE'"
|
echo "Converting '$SRCFILE' -> '$DESTFILE'"
|
||||||
u2d < "$SRCFILE" > "$DESTFILE"
|
sed s/\$/$'\r'/ < "$SRCFILE" > "$DESTFILE"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ -d "$MINGW_W32_DIR" ]; then
|
if type -P i686-w64-mingw32-gcc > /dev/null; then
|
||||||
# 32-bit x86, Win2k or later, using MinGW-w32
|
# 32-bit x86, Win2k or later
|
||||||
PATH=$MINGW_W32_DIR/bin:$MINGW_W32_DIR/i686-w64-mingw32/bin:$PATH \
|
buildit pkg/bin_i686 i686-w64-mingw32 \
|
||||||
buildit \
|
|
||||||
pkg/bin_i686 \
|
|
||||||
i686-w64-mingw32 \
|
|
||||||
'-march=i686 -mtune=generic'
|
'-march=i686 -mtune=generic'
|
||||||
# 32-bit x86 with SSE2, Win2k or later, using MinGW-w32
|
|
||||||
PATH=$MINGW_W32_DIR/bin:$MINGW_W32_DIR/i686-w64-mingw32/bin:$PATH \
|
# 32-bit x86 with SSE2, Win2k or later
|
||||||
buildit \
|
buildit pkg/bin_i686-sse2 i686-w64-mingw32 \
|
||||||
pkg/bin_i686-sse2 \
|
'-march=i686 -msse2 -mtune=generic'
|
||||||
i686-w64-mingw32 \
|
else
|
||||||
'-march=i686 -msse2 -mfpmath=sse -mtune=generic'
|
echo
|
||||||
elif [ -d "$MINGW_DIR" ]; then
|
echo "i686-w64-mingw32-gcc is not in PATH, skipping 32-bit x86 builds"
|
||||||
# 32-bit x86, Win2k or later, using MinGW
|
echo
|
||||||
PATH=$MINGW_DIR/bin:$PATH \
|
|
||||||
buildit \
|
|
||||||
pkg/bin_i486 \
|
|
||||||
i486-pc-mingw32 \
|
|
||||||
'-march=i486 -mtune=generic'
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d "$MINGW_W64_DIR" ]; then
|
if type -P x86_64-w64-mingw32-gcc > /dev/null; then
|
||||||
# x86-64, Windows Vista or later, using MinGW-w64
|
# x86-64, Windows Vista or later
|
||||||
PATH=$MINGW_W64_DIR/bin:$MINGW_W64_DIR/x86_64-w64-mingw32/bin:$PATH \
|
buildit pkg/bin_x86-64 x86_64-w64-mingw32 \
|
||||||
buildit \
|
|
||||||
pkg/bin_x86-64 \
|
|
||||||
x86_64-w64-mingw32 \
|
|
||||||
'-march=x86-64 -mtune=generic'
|
'-march=x86-64 -mtune=generic'
|
||||||
|
else
|
||||||
|
echo
|
||||||
|
echo "x86_64-w64-mingw32-gcc is not in PATH, skipping x86-64 build"
|
||||||
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy the headers, the .def file, and the docs.
|
# Copy the headers, the .def file, and the docs.
|
||||||
|
@ -165,38 +201,35 @@ mkdir -pv pkg/{include/lzma,doc/{api,manuals,examples}}
|
||||||
txtcp pkg/include "" src/liblzma/api/lzma.h
|
txtcp pkg/include "" src/liblzma/api/lzma.h
|
||||||
txtcp pkg/include/lzma "" src/liblzma/api/lzma/*.h
|
txtcp pkg/include/lzma "" src/liblzma/api/lzma/*.h
|
||||||
txtcp pkg/doc "" src/liblzma/liblzma.def
|
txtcp pkg/doc "" src/liblzma/liblzma.def
|
||||||
txtcp pkg/doc .txt AUTHORS COPYING NEWS README THANKS TODO
|
txtcp pkg/doc .txt AUTHORS COPYING NEWS README THANKS
|
||||||
txtcp pkg/doc "" doc/*.txt windows/README-Windows.txt
|
txtcp pkg/doc "" doc/*.txt windows/README-Windows.txt
|
||||||
|
txtcp pkg/doc "" windows/COPYING.MinGW-w64-runtime.txt
|
||||||
txtcp pkg/doc/manuals "" doc/man/txt/{xz,xzdec,lzmainfo}.txt
|
txtcp pkg/doc/manuals "" doc/man/txt/{xz,xzdec,lzmainfo}.txt
|
||||||
cp -v doc/man/pdf-*/{xz,xzdec,lzmainfo}-*.pdf pkg/doc/manuals
|
cp -v doc/man/pdf-*/{xz,xzdec,lzmainfo}-*.pdf pkg/doc/manuals
|
||||||
cp -v doc/api/* pkg/doc/api
|
cp -v doc/api/* pkg/doc/api
|
||||||
txtcp pkg/doc/examples "" doc/examples/*
|
txtcp pkg/doc/examples "" doc/examples/*
|
||||||
|
|
||||||
if [ -f windows/COPYING-Windows.txt ]; then
|
# Create the package. This requires 7z from 7-Zip.
|
||||||
txtcp pkg/doc "" windows/COPYING-Windows.txt
|
# If it isn't found, this step is skipped.
|
||||||
fi
|
for SEVENZ in "$(type -P 7z || true)" \
|
||||||
|
"$PROGRAMW6432/7-Zip/7z.exe" "$PROGRAMFILES/7-Zip/7z.exe" \
|
||||||
|
"/c/Program Files/7-Zip/7z.exe"
|
||||||
|
do
|
||||||
|
[ -x "$SEVENZ" ] && break
|
||||||
|
done
|
||||||
|
|
||||||
# Create the package. This requires 7z.exe from 7-Zip. If it wasn't found,
|
if [ -x "$SEVENZ" ]; then
|
||||||
# this step is skipped and you have to zip it yourself.
|
VER=$(sh build-aux/version.sh)
|
||||||
VER=$(sh build-aux/version.sh)
|
cd pkg
|
||||||
cd pkg
|
"$SEVENZ" a -tzip ../xz-$VER-windows.zip *
|
||||||
if [ -x "$SEVENZ_EXE" ]; then
|
"$SEVENZ" a ../xz-$VER-windows.7z *
|
||||||
"$SEVENZ_EXE" a -tzip ../xz-$VER-windows.zip *
|
|
||||||
"$SEVENZ_EXE" a ../xz-$VER-windows.7z *
|
|
||||||
else
|
else
|
||||||
echo
|
echo
|
||||||
echo "NOTE: 7z.exe was not found. xz-$VER-windows.zip"
|
echo "NOTE: 7z was not found. xz-$VER-windows.zip"
|
||||||
echo " and xz-$VER-windows.7z were not created."
|
echo " and xz-$VER-windows.7z were not created."
|
||||||
echo " You can create them yourself from the pkg directory."
|
echo " You can create them yourself from the pkg directory."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f ../windows/COPYING-Windows.txt ]; then
|
|
||||||
echo
|
|
||||||
echo "NOTE: windows/COPYING-Windows.txt doesn't exists."
|
|
||||||
echo " MinGW(-w64) runtime copyright information"
|
|
||||||
echo " is not included in the package."
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo
|
echo
|
||||||
echo "Build completed successfully."
|
echo "Build completed successfully."
|
||||||
echo
|
echo
|
||||||
|
|
Loading…
Reference in a new issue