From 507a4a4dea1e5462f12f7ed4b076c34e02054a38 Mon Sep 17 00:00:00 2001 From: Lasse Collin Date: Tue, 27 Jul 2010 20:45:03 +0300 Subject: Windows: build.sh is a bash script so name it correctly. --- INSTALL | 2 +- windows/INSTALL-Windows.txt | 6 +- windows/build.bash | 189 ++++++++++++++++++++++++++++++++++++++++++++ windows/build.sh | 189 -------------------------------------------- 4 files changed, 193 insertions(+), 193 deletions(-) create mode 100644 windows/build.bash delete mode 100644 windows/build.sh diff --git a/INSTALL b/INSTALL index 5f38085e..805f1175 100644 --- a/INSTALL +++ b/INSTALL @@ -78,7 +78,7 @@ XZ Utils Installation 1.2.3. Windows Building XZ Utils on Windows is supported under MinGW + MSYS and - Cygwin. There is windows/build.sh to ease packaging XZ Utils with + Cygwin. There is windows/build.bash to ease packaging XZ Utils with MinGW + MSYS into a redistributable .zip or .7z file. See windows/INSTALL-Windows.txt for more information. diff --git a/windows/INSTALL-Windows.txt b/windows/INSTALL-Windows.txt index b5ac9630..b3ed93e3 100644 --- a/windows/INSTALL-Windows.txt +++ b/windows/INSTALL-Windows.txt @@ -118,13 +118,13 @@ Building XZ Utils cd /c/devel tar xzf xz-5.x.x.tar.gz cd xz-5.x.x - sh windows/build.sh + bash windows/build.bash If you used some other directory than C:\devel\tools for the build - tools, edit the variables near the beginning of build.sh first. + tools, edit the variables near the beginning of build.bash first. If you want to build manually, read the buildit() function in - build.sh. Look especially at the latter configure invocation. + build.bash. Look especially at the latter configure invocation. Be patient. Running configure and other scripts used by the build system is (very) slow under Windows. diff --git a/windows/build.bash b/windows/build.bash new file mode 100644 index 00000000..e6754358 --- /dev/null +++ b/windows/build.bash @@ -0,0 +1,189 @@ +#!/bin/bash +# +############################################################################### +# +# Build a binary package on Windows with MinGW and MSYS +# +# Set the paths where MinGW, Mingw-w32, or MinGW-w64 are installed. If both +# MinGW and MinGW-w32 are specified, MinGW will be used. If there is no +# 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 + + +# Abort immediately if something goes wrong. +set -e + +# White spaces in directory names may break things so catch them immediately. +case $(pwd) in + ' ' | ' ' | ' +') echo "Error: White space in the directory name" >&2; exit 1 ;; +esac + +# This script can be run either at the top-level directory of the package +# or in the same directory containing this script. +if [ ! -f windows/build.bash ]; then + cd .. + if [ ! -f windows/build.bash ]; then + 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 + + # Build the size-optimized binaries. Note that I don't want to + # provide size-optimized liblzma (shared nor static), because + # that isn't thread-safe now, and depending on bunch of things, + # maybe it will never be on Windows (pthreads-win32 helps but + # static liblzma might bit a bit tricky with it). + ./configure \ + --prefix= \ + --disable-nls \ + --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 + + # Build the normal speed-optimized binaries. Note that while + # --disable-threads has been documented to make some things + # thread-unsafe, it's not actually true with this combination + # of configure flags in XZ Utils 5.0.x. Things can (and probably + # will) change after 5.0.x, and this script will be updated too. + ./configure \ + --prefix= \ + --disable-nls \ + --disable-threads \ + --enable-dynamic=no \ + --build="$BUILD" \ + CFLAGS="$CFLAGS -O2" + make check + + cp -v src/xz/xz.exe src/liblzma/.libs/liblzma.a "$DESTDIR" + cp -v src/liblzma/.libs/liblzma-*.dll "$DESTDIR/liblzma.dll" + + strip -v "$DESTDIR/"*.{exe,dll} + strip -vg "$DESTDIR/"*.a +} + +# Copy files and convert newlines from LF to CR+LF. Optinally add a suffix +# 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 +} + +# FIXME: Make sure that we don't get i686 or i586 code from the runtime. +# Actually i586 would be fine, but i686 probably not if the idea is to +# support even Win95. +# +# FIXME: Using i486 in the configure triplet may be wrong. +if [ -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' +elif [ -d "$MINGW_W32_DIR" ]; then + # 32-bit x86, Win95 or later, using MinGW-w32 + PATH=$MINGW_W32_DIR/bin:$MINGW_W32_DIR/i686-w64-mingw32/bin:$PATH \ + buildit \ + pkg/bin_i486 \ + i486-w64-mingw32 \ + '-march=i486 -mtune=generic' +fi + +if [ -d "$MINGW_W64_DIR" ]; then + # 64-bit x86, WinXP or later, using MinGW-w64 + 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. +mkdir -pv pkg/{include/lzma,doc/manuals} +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 +txtcp pkg/doc "" doc/*.txt +txtcp pkg/doc/manuals "" doc/man/txt/{xz,xzdec,lzmainfo}.txt +cp -v doc/man/pdf-*/{xz,xzdec,lzmainfo}-*.pdf pkg/doc/manuals +txtcp pkg "" windows/README-Windows.txt + +# 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. +VER=$(sh version.sh) +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 + +echo +echo "Build completed successfully." +echo diff --git a/windows/build.sh b/windows/build.sh deleted file mode 100644 index 665951b9..00000000 --- a/windows/build.sh +++ /dev/null @@ -1,189 +0,0 @@ -#!/bin/sh -# -############################################################################### -# -# Build a binary package on Windows with MinGW and MSYS -# -# Set the paths where MinGW, Mingw-w32, or MinGW-w64 are installed. If both -# MinGW and MinGW-w32 are specified, MinGW will be used. If there is no -# 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 - - -# Abort immediately if something goes wrong. -set -e - -# White spaces in directory names may break things so catch them immediately. -case $(pwd) in - ' ' | ' ' | ' -') echo "Error: White space in the directory name" >&2; exit 1 ;; -esac - -# This script can be run either at the top-level directory of the package -# or in the same directory containing this script. -if [ ! -f windows/build.sh ]; then - cd .. - if [ ! -f windows/build.sh ]; then - 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 - - # Build the size-optimized binaries. Note that I don't want to - # provide size-optimized liblzma (shared nor static), because - # that isn't thread-safe now, and depending on bunch of things, - # maybe it will never be on Windows (pthreads-win32 helps but - # static liblzma might bit a bit tricky with it). - ./configure \ - --prefix= \ - --disable-nls \ - --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 - - # Build the normal speed-optimized binaries. Note that while - # --disable-threads has been documented to make some things - # thread-unsafe, it's not actually true with this combination - # of configure flags in XZ Utils 5.0.x. Things can (and probably - # will) change after 5.0.x, and this script will be updated too. - ./configure \ - --prefix= \ - --disable-nls \ - --disable-threads \ - --enable-dynamic=no \ - --build="$BUILD" \ - CFLAGS="$CFLAGS -O2" - make check - - cp -v src/xz/xz.exe src/liblzma/.libs/liblzma.a "$DESTDIR" - cp -v src/liblzma/.libs/liblzma-*.dll "$DESTDIR/liblzma.dll" - - strip -v "$DESTDIR/"*.{exe,dll} - strip -vg "$DESTDIR/"*.a -} - -# Copy files and convert newlines from LF to CR+LF. Optinally add a suffix -# 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 -} - -# FIXME: Make sure that we don't get i686 or i586 code from the runtime. -# Actually i586 would be fine, but i686 probably not if the idea is to -# support even Win95. -# -# FIXME: Using i486 in the configure triplet may be wrong. -if [ -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' -elif [ -d "$MINGW_W32_DIR" ]; then - # 32-bit x86, Win95 or later, using MinGW-w32 - PATH=$MINGW_W32_DIR/bin:$MINGW_W32_DIR/i686-w64-mingw32/bin:$PATH \ - buildit \ - pkg/bin_i486 \ - i486-w64-mingw32 \ - '-march=i486 -mtune=generic' -fi - -if [ -d "$MINGW_W64_DIR" ]; then - # 64-bit x86, WinXP or later, using MinGW-w64 - 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. -mkdir -pv pkg/{include/lzma,doc/manuals} -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 -txtcp pkg/doc "" doc/*.txt -txtcp pkg/doc/manuals "" doc/man/txt/{xz,xzdec,lzmainfo}.txt -cp -v doc/man/pdf-*/{xz,xzdec,lzmainfo}-*.pdf pkg/doc/manuals -txtcp pkg "" windows/README-Windows.txt - -# 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. -VER=$(sh version.sh) -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 - -echo -echo "Build completed successfully." -echo -- cgit v1.2.3