2010-07-27 17:45:03 +00:00
|
|
|
#!/bin/bash
|
2010-01-31 21:28:51 +00:00
|
|
|
#
|
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# Build a binary package on Windows with MinGW and MSYS
|
|
|
|
#
|
|
|
|
# Set the paths where MinGW, Mingw-w32, or MinGW-w64 are installed. If both
|
2010-10-09 09:27:08 +00:00
|
|
|
# MinGW and MinGW-w32 are specified, MinGW-w32 will be used. If there is no
|
2010-01-31 21:28:51 +00:00
|
|
|
# 32-bit or 64-bit compiler at all, it is simply skipped.
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
# find it automatically. Otherwise adjust the path manually.
|
|
|
|
#
|
|
|
|
# If you want to use a cross-compiler e.g. on GNU/Linux, this script won't
|
|
|
|
# work out of the box. You need to omit "make check" commands and replace
|
|
|
|
# u2d with some other tool to convert newlines from LF to CR+LF. You will
|
|
|
|
# also need to pass the --host option to configure.
|
|
|
|
#
|
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# Author: Lasse Collin
|
|
|
|
#
|
|
|
|
# This file has been put into the public domain.
|
|
|
|
# You can do whatever you want with this file.
|
|
|
|
#
|
|
|
|
###############################################################################
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
2010-02-12 11:16:15 +00:00
|
|
|
# Abort immediately if something goes wrong.
|
2010-01-31 21:28:51 +00:00
|
|
|
set -e
|
|
|
|
|
2010-02-12 11:16:15 +00:00
|
|
|
# White spaces in directory names may break things so catch them immediately.
|
2010-01-31 21:28:51 +00:00
|
|
|
case $(pwd) in
|
|
|
|
' ' | ' ' | '
|
|
|
|
') echo "Error: White space in the directory name" >&2; exit 1 ;;
|
|
|
|
esac
|
|
|
|
|
2010-02-01 20:47:54 +00:00
|
|
|
# This script can be run either at the top-level directory of the package
|
2010-01-31 21:28:51 +00:00
|
|
|
# or in the same directory containing this script.
|
2010-07-27 17:45:03 +00:00
|
|
|
if [ ! -f windows/build.bash ]; then
|
2010-01-31 21:28:51 +00:00
|
|
|
cd ..
|
2010-07-27 17:45:03 +00:00
|
|
|
if [ ! -f windows/build.bash ]; then
|
2010-01-31 21:28:51 +00:00
|
|
|
echo "You are in a wrong directory." >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Run configure and copy the binaries to the given directory.
|
|
|
|
#
|
|
|
|
# The first argument is the directory where to copy the binaries.
|
|
|
|
# The rest of the arguments are passed to configure.
|
|
|
|
buildit()
|
|
|
|
{
|
|
|
|
DESTDIR=$1
|
|
|
|
BUILD=$2
|
|
|
|
CFLAGS=$3
|
|
|
|
|
|
|
|
# Clean up if it was already configured.
|
|
|
|
[ -f Makefile ] && make distclean
|
|
|
|
|
2013-09-17 08:52:28 +00:00
|
|
|
# Build the size-optimized binaries. Providing size-optimized liblzma
|
|
|
|
# could be considered but I don't know if it should only use -Os or
|
|
|
|
# should it also use --enable-small and if it should support
|
|
|
|
# threading. So I don't include a size-optimized liblzma for now.
|
2010-01-31 21:28:51 +00:00
|
|
|
./configure \
|
|
|
|
--prefix= \
|
2014-12-20 18:41:48 +00:00
|
|
|
--enable-silent-rules \
|
|
|
|
--disable-dependency-tracking \
|
2010-01-31 21:28:51 +00:00
|
|
|
--disable-nls \
|
2011-09-06 09:03:41 +00:00
|
|
|
--disable-scripts \
|
2010-01-31 21:28:51 +00:00
|
|
|
--disable-threads \
|
|
|
|
--disable-shared \
|
|
|
|
--enable-small \
|
|
|
|
--build="$BUILD" \
|
|
|
|
CFLAGS="$CFLAGS -Os"
|
|
|
|
make check
|
|
|
|
|
|
|
|
mkdir -pv "$DESTDIR"
|
|
|
|
cp -v src/xzdec/{xz,lzma}dec.exe src/lzmainfo/lzmainfo.exe "$DESTDIR"
|
|
|
|
|
|
|
|
make distclean
|
|
|
|
|
2014-12-20 18:41:48 +00:00
|
|
|
# Build the normal speed-optimized binaries. The type of threading
|
|
|
|
# (win95 vs. vista) will be autodetect from the target architecture.
|
2010-01-31 21:28:51 +00:00
|
|
|
./configure \
|
|
|
|
--prefix= \
|
2014-12-20 18:41:48 +00:00
|
|
|
--enable-silent-rules \
|
|
|
|
--disable-dependency-tracking \
|
2010-01-31 21:28:51 +00:00
|
|
|
--disable-nls \
|
2011-09-06 09:03:41 +00:00
|
|
|
--disable-scripts \
|
2010-01-31 21:28:51 +00:00
|
|
|
--build="$BUILD" \
|
2010-10-08 18:42:37 +00:00
|
|
|
CFLAGS="$CFLAGS -O2"
|
|
|
|
make -C src/liblzma
|
|
|
|
make -C src/xz LDFLAGS=-static
|
|
|
|
make -C tests check
|
2010-01-31 21:28:51 +00:00
|
|
|
|
|
|
|
cp -v src/xz/xz.exe src/liblzma/.libs/liblzma.a "$DESTDIR"
|
|
|
|
cp -v src/liblzma/.libs/liblzma-*.dll "$DESTDIR/liblzma.dll"
|
|
|
|
|
2010-07-27 17:27:32 +00:00
|
|
|
strip -v "$DESTDIR/"*.{exe,dll}
|
|
|
|
strip -vg "$DESTDIR/"*.a
|
2010-01-31 21:28:51 +00:00
|
|
|
}
|
|
|
|
|
2019-05-08 05:30:57 +00:00
|
|
|
# Copy files and convert newlines from LF to CR+LF. Optionally add a suffix
|
2010-01-31 21:28:51 +00:00
|
|
|
# to the destination filename.
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
# is wanted. The rest of the arguments are actual the filenames.
|
|
|
|
txtcp()
|
|
|
|
{
|
|
|
|
DESTDIR=$1
|
|
|
|
SUFFIX=$2
|
|
|
|
shift 2
|
|
|
|
for SRCFILE; do
|
|
|
|
DESTFILE="$DESTDIR/${SRCFILE##*/}$SUFFIX"
|
|
|
|
echo "Converting \`$SRCFILE' -> \`$DESTFILE'"
|
|
|
|
u2d < "$SRCFILE" > "$DESTFILE"
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2010-10-09 09:27:08 +00:00
|
|
|
if [ -d "$MINGW_W32_DIR" ]; then
|
2010-01-31 21:28:51 +00:00
|
|
|
# 32-bit x86, Win95 or later, using MinGW-w32
|
|
|
|
PATH=$MINGW_W32_DIR/bin:$MINGW_W32_DIR/i686-w64-mingw32/bin:$PATH \
|
|
|
|
buildit \
|
2014-12-21 17:50:38 +00:00
|
|
|
pkg/bin_i686 \
|
2014-12-20 18:41:48 +00:00
|
|
|
i686-w64-mingw32 \
|
|
|
|
'-march=i686 -mtune=generic'
|
|
|
|
# 32-bit x86 with SSE2, Win98 or later, using MinGW-w32
|
|
|
|
PATH=$MINGW_W32_DIR/bin:$MINGW_W32_DIR/i686-w64-mingw32/bin:$PATH \
|
|
|
|
buildit \
|
|
|
|
pkg/bin_i686-sse2 \
|
|
|
|
i686-w64-mingw32 \
|
|
|
|
'-march=i686 -msse2 -mfpmath=sse -mtune=generic'
|
2010-10-09 09:27:08 +00:00
|
|
|
elif [ -d "$MINGW_DIR" ]; then
|
|
|
|
# 32-bit x86, Win95 or later, using MinGW
|
|
|
|
PATH=$MINGW_DIR/bin:$PATH \
|
|
|
|
buildit \
|
|
|
|
pkg/bin_i486 \
|
|
|
|
i486-pc-mingw32 \
|
|
|
|
'-march=i486 -mtune=generic'
|
2010-01-31 21:28:51 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -d "$MINGW_W64_DIR" ]; then
|
2013-09-17 08:52:28 +00:00
|
|
|
# x86-64, Windows Vista or later, using MinGW-w64
|
2010-01-31 21:28:51 +00:00
|
|
|
PATH=$MINGW_W64_DIR/bin:$MINGW_W64_DIR/x86_64-w64-mingw32/bin:$PATH \
|
|
|
|
buildit \
|
|
|
|
pkg/bin_x86-64 \
|
|
|
|
x86_64-w64-mingw32 \
|
|
|
|
'-march=x86-64 -mtune=generic'
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Copy the headers, the .def file, and the docs.
|
|
|
|
# They are the same for all architectures and builds.
|
2010-10-26 12:48:48 +00:00
|
|
|
mkdir -pv pkg/{include/lzma,doc/{manuals,examples}}
|
2010-01-31 21:28:51 +00:00
|
|
|
txtcp pkg/include "" src/liblzma/api/lzma.h
|
|
|
|
txtcp pkg/include/lzma "" src/liblzma/api/lzma/*.h
|
|
|
|
txtcp pkg/doc "" src/liblzma/liblzma.def
|
|
|
|
txtcp pkg/doc .txt AUTHORS COPYING NEWS README THANKS TODO
|
2010-10-09 08:33:21 +00:00
|
|
|
txtcp pkg/doc "" doc/*.txt windows/README-Windows.txt
|
2010-01-31 21:28:51 +00:00
|
|
|
txtcp pkg/doc/manuals "" doc/man/txt/{xz,xzdec,lzmainfo}.txt
|
|
|
|
cp -v doc/man/pdf-*/{xz,xzdec,lzmainfo}-*.pdf pkg/doc/manuals
|
2010-10-26 12:48:48 +00:00
|
|
|
txtcp pkg/doc/examples "" doc/examples/*
|
2010-10-09 08:33:21 +00:00
|
|
|
|
|
|
|
if [ -f windows/COPYING-Windows.txt ]; then
|
|
|
|
txtcp pkg/doc "" windows/COPYING-Windows.txt
|
|
|
|
fi
|
2010-01-31 21:28:51 +00:00
|
|
|
|
2010-02-01 08:20:57 +00:00
|
|
|
# Create the package. This requires 7z.exe from 7-Zip. If it wasn't found,
|
|
|
|
# this step is skipped and you have to zip it yourself.
|
2010-09-28 07:59:53 +00:00
|
|
|
VER=$(sh build-aux/version.sh)
|
2010-01-31 21:28:51 +00:00
|
|
|
cd pkg
|
|
|
|
if [ -x "$SEVENZ_EXE" ]; then
|
|
|
|
"$SEVENZ_EXE" a -tzip ../xz-$VER-windows.zip *
|
|
|
|
"$SEVENZ_EXE" a ../xz-$VER-windows.7z *
|
|
|
|
else
|
|
|
|
echo
|
|
|
|
echo "NOTE: 7z.exe was not found. xz-$VER-windows.zip"
|
|
|
|
echo " and xz-$VER-windows.7z were not created."
|
|
|
|
echo " You can create them yourself from the pkg directory."
|
|
|
|
fi
|
|
|
|
|
2010-10-09 15:57:04 +00:00
|
|
|
if [ ! -f ../windows/COPYING-Windows.txt ]; then
|
2010-10-09 08:33:21 +00:00
|
|
|
echo
|
|
|
|
echo "NOTE: windows/COPYING-Windows.txt doesn't exists."
|
|
|
|
echo " MinGW(-w64) runtime copyright information"
|
|
|
|
echo " is not included in the package."
|
|
|
|
fi
|
|
|
|
|
2010-01-31 21:28:51 +00:00
|
|
|
echo
|
|
|
|
echo "Build completed successfully."
|
|
|
|
echo
|