aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2009-02-05 09:17:51 +0200
committerLasse Collin <lasse.collin@tukaani.org>2009-02-05 09:17:51 +0200
commite1c3412eec7acec7ca3b32c9c828f3147dc65b49 (patch)
treecaa18a4ce23756fe210f1f2015c5b5d715802c9a
parentVarious code cleanups the the xz command line tool. (diff)
downloadxz-e1c3412eec7acec7ca3b32c9c828f3147dc65b49.tar.xz
Added initial experimental makefile for use with MinGW.
-rw-r--r--windows/Makefile253
-rw-r--r--windows/README164
-rw-r--r--windows/config.h180
3 files changed, 597 insertions, 0 deletions
diff --git a/windows/Makefile b/windows/Makefile
new file mode 100644
index 00000000..43f25af6
--- /dev/null
+++ b/windows/Makefile
@@ -0,0 +1,253 @@
+###############################################################################
+#
+# Makefile to build XZ Utils using MinGW
+#
+# Make flags to alter compilation:
+#
+# DEBUG=1 Enable assertions. Don't use this for production builds!
+# You may also want to set CFLAGS="-g -O0" to disable
+# optimizations.
+#
+# W64=1 Build for 64-bit Windows. Make sure that you have 64-bit
+# MinGW in PATH.
+#
+# STATIC=1 TODO: Build static library instead of a DLL.
+#
+# WINE=1 Shortcut to set CC and STRIP to use Wine to run Windows
+# versions of MinGW binaries.
+#
+# The usual CPPFLAGS and CFLAGS are supported too.
+#
+###############################################################################
+#
+# Author: Lasse Collin
+#
+# This file has been put into the public domain.
+# You can do whatever you want with this file.
+#
+###############################################################################
+
+ifdef W64
+CC = x86_64-pc-mingw32-gcc
+STRIP = x86_64-pc-mingw32-strip
+else
+CC = mingw32-gcc
+STRIP = strip
+endif
+
+SED = sed
+RM = rm -f
+
+CFLAGS = -g -Wall -Wextra -O2
+# CFLAGS = -Wall -Wextra -O3 -fomit-frame-pointer -funroll-loops
+
+ALL_CFLAGS = -std=gnu99 -mms-bitfields
+
+ALL_CPPFLAGS = \
+ -I. \
+ -I../src/common \
+ -I../src/liblzma/api \
+ -I../src/liblzma/common \
+ -I../src/liblzma/check \
+ -I../src/liblzma/rangecoder \
+ -I../src/liblzma/lz \
+ -I../src/liblzma/lzma \
+ -I../src/liblzma/delta \
+ -I../src/liblzma/simple \
+ -I../src/liblzma/subblock
+
+ALL_CPPFLAGS += -DHAVE_CONFIG_H
+
+# This works with Wine too while using native GNU make, sed, and rm.
+ifdef WINE
+ifdef W64
+CC := wine c:/MinGW64/bin/x86_64-pc-mingw32-gcc
+STRIP := wine c:/MinGW64/bin/x86_64-pc-mingw32-strip
+else
+CC := wine c:/MinGW/bin/gcc
+STRIP := wine c:/MinGW/bin/strip
+endif
+endif
+
+ifdef DEBUG
+# Use echo since it works for this purporse on both Windows and POSIX.
+STRIP := echo Skipping strip
+else
+ALL_CPPFLAGS += -DNDEBUG
+endif
+
+ALL_CPPFLAGS += $(CPPFLAGS)
+ALL_CFLAGS += $(CFLAGS)
+
+
+################
+# Common rules #
+################
+
+.PHONY: all clean pkg
+all: liblzma.dll xzdec.exe lzmadec.exe xz.exe
+clean: liblzma-clean xzdec-clean xz-clean
+
+pkg: all
+ $(RM) -r pkg
+ install -d pkg/lib pkg/include/lzma
+ install -m 0644 liblzma.dll xz.exe xzdec.exe lzmadec.exe pkg
+ install -m 0644 liblzma.a liblzma.def pkg/lib
+ install -m 0644 ../src/liblzma/api/lzma.h pkg/include
+ install -m 0644 ../src/liblzma/api/lzma/*.h pkg/include/lzma
+
+
+###############
+# liblzma.dll #
+###############
+
+LIBLZMA_SRCS_C = \
+ ../src/liblzma/common/alone_decoder.c \
+ ../src/liblzma/common/alone_encoder.c \
+ ../src/liblzma/common/auto_decoder.c \
+ ../src/liblzma/common/block_buffer_decoder.c \
+ ../src/liblzma/common/block_buffer_encoder.c \
+ ../src/liblzma/common/block_decoder.c \
+ ../src/liblzma/common/block_encoder.c \
+ ../src/liblzma/common/block_header_decoder.c \
+ ../src/liblzma/common/block_header_encoder.c \
+ ../src/liblzma/common/block_util.c \
+ ../src/liblzma/common/common.c \
+ ../src/liblzma/common/easy.c \
+ ../src/liblzma/common/filter_common.c \
+ ../src/liblzma/common/filter_decoder.c \
+ ../src/liblzma/common/filter_encoder.c \
+ ../src/liblzma/common/filter_flags_decoder.c \
+ ../src/liblzma/common/filter_flags_encoder.c \
+ ../src/liblzma/common/index.c \
+ ../src/liblzma/common/index_decoder.c \
+ ../src/liblzma/common/index_encoder.c \
+ ../src/liblzma/common/index_hash.c \
+ ../src/liblzma/common/stream_buffer_decoder.c \
+ ../src/liblzma/common/stream_buffer_encoder.c \
+ ../src/liblzma/common/stream_decoder.c \
+ ../src/liblzma/common/stream_encoder.c \
+ ../src/liblzma/common/stream_flags_common.c \
+ ../src/liblzma/common/stream_flags_decoder.c \
+ ../src/liblzma/common/stream_flags_encoder.c \
+ ../src/liblzma/common/vli_decoder.c \
+ ../src/liblzma/common/vli_encoder.c \
+ ../src/liblzma/common/vli_size.c \
+ ../src/liblzma/check/check.c \
+ ../src/liblzma/check/crc32_table.c \
+ ../src/liblzma/check/crc64_table.c \
+ ../src/liblzma/check/sha256.c \
+ ../src/liblzma/rangecoder/price_table.c \
+ ../src/liblzma/lz/lz_decoder.c \
+ ../src/liblzma/lz/lz_encoder.c \
+ ../src/liblzma/lz/lz_encoder_mf.c \
+ ../src/liblzma/lzma/fastpos_table.c \
+ ../src/liblzma/lzma/fastpos_tablegen.c \
+ ../src/liblzma/lzma/lzma2_decoder.c \
+ ../src/liblzma/lzma/lzma2_encoder.c \
+ ../src/liblzma/lzma/lzma_decoder.c \
+ ../src/liblzma/lzma/lzma_encoder.c \
+ ../src/liblzma/lzma/lzma_encoder_optimum_fast.c \
+ ../src/liblzma/lzma/lzma_encoder_optimum_normal.c \
+ ../src/liblzma/lzma/lzma_encoder_presets.c \
+ ../src/liblzma/delta/delta_common.c \
+ ../src/liblzma/delta/delta_decoder.c \
+ ../src/liblzma/delta/delta_encoder.c \
+ ../src/liblzma/simple/arm.c \
+ ../src/liblzma/simple/armthumb.c \
+ ../src/liblzma/simple/ia64.c \
+ ../src/liblzma/simple/powerpc.c \
+ ../src/liblzma/simple/simple_coder.c \
+ ../src/liblzma/simple/simple_decoder.c \
+ ../src/liblzma/simple/simple_encoder.c \
+ ../src/liblzma/simple/sparc.c \
+ ../src/liblzma/simple/x86.c
+
+LIBLZMA_SRCS_ASM =
+
+ifdef W64
+LIBLZMA_SRCS_C += \
+ ../src/liblzma/check/crc32_fast.c \
+ ../src/liblzma/check/crc64_fast.c
+else
+LIBLZMA_SRCS_ASM += \
+ ../src/liblzma/check/crc32_x86.S \
+ ../src/liblzma/check/crc64_x86.S
+endif
+
+LIBLZMA_OBJS_C = $(LIBLZMA_SRCS_C:.c=.o)
+LIBLZMA_OBJS_ASM = $(LIBLZMA_SRCS_ASM:.S=.o)
+LIBLZMA_OBJS = $(LIBLZMA_OBJS_C) $(LIBLZMA_OBJS_ASM)
+
+# The sed is needed to remove ordinals from the .def file. I'm not going
+# to track the ordinal numbers, so people should link against liblzma.dll
+# only by using symbol names.
+liblzma.dll: $(LIBLZMA_OBJS)
+ $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -shared -o liblzma.dll $(LIBLZMA_OBJS) -Wl,--out-implib,liblzma.a,--output-def,liblzma.def.in
+ $(SED) 's/ \+@ *[0-9]\+//' liblzma.def.in > liblzma.def
+ $(RM) liblzma.def.in
+ $(STRIP) --strip-unneeded liblzma.a
+ $(STRIP) --strip-all liblzma.dll
+
+$(LIBLZMA_OBJS_C): %.o: %.c
+ $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -o $@ $<
+
+$(LIBLZMA_OBJS_ASM): %.o: %.S
+ $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -o $@ $<
+
+.PHONY: liblzma-clean
+liblzma-clean:
+ -$(RM) $(LIBLZMA_OBJS) liblzma.def.in liblzma.def liblzma.a liblzma.dll
+
+
+###########################
+# xzdec.exe & lzmadec.exe #
+###########################
+
+XZDEC_SRCS = ../src/xzdec/xzdec.c
+
+xzdec.exe: liblzma.dll $(XZDEC_SRCS)
+ $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) $(XZDEC_SRCS) -o xzdec.exe liblzma.a
+ $(STRIP) --strip-all xzdec.exe
+
+lzmadec.exe: liblzma.dll $(XZDEC_SRCS)
+ $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -DLZMADEC $(XZDEC_SRCS) -o lzmadec.exe liblzma.a
+ $(STRIP) --strip-all lzmadec.exe
+
+.PHONY: xzdec-clean
+xzdec-clean:
+ -$(RM) xzdec.exe lzmadec.exe
+
+
+##########
+# xz.exe #
+##########
+
+XZ_SRCS = \
+ ../src/xz/args.c \
+ ../src/xz/hardware.c \
+ ../src/xz/io.c \
+ ../src/xz/main.c \
+ ../src/xz/message.c \
+ ../src/xz/options.c \
+ ../src/xz/process.c \
+ ../src/xz/signals.c \
+ ../src/xz/suffix.c \
+ ../src/xz/util.c
+
+XZ_OBJS = $(XZ_SRCS:.c=.o)
+
+# We need to "fix" the source files which use ' as format character
+# in printf() to get thousand separators. Windows doesn't support it.
+# It's not in C89 or C99, but it is in POSIX.
+$(XZ_OBJS): %.o: %.c
+ $(SED) "s/%'/%/g" $< > $(<:.c=-fixed.c)
+ $(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -o $@ $(<:.c=-fixed.c)
+
+xz.exe: $(XZ_OBJS)
+ $(CC) $(ALL_CFLAGS) $(XZ_OBJS) -o xz.exe liblzma.a
+ $(STRIP) --strip-all xz.exe
+
+.PHONY: xz-clean
+xz-clean:
+ -$(RM) $(XZ_OBJS) $(XZ_SRCS:.c=-fixed.c) xz.exe
diff --git a/windows/README b/windows/README
new file mode 100644
index 00000000..4acc6802
--- /dev/null
+++ b/windows/README
@@ -0,0 +1,164 @@
+
+XZ Utils on Windows
+===================
+
+Introduction
+
+ This document explains how to build XZ Utils for Microsoft Windows
+ using MinGW (Minimalist GNU for Windows).
+
+ This is currently experimental and has got very little testing.
+ No ABI stability is promised for liblzma.dll.
+
+
+Why MinGW
+
+ XZ Utils code is C99. It should be possible to compile at least
+ liblzma using any C99 compiler. Compiling the command line tools may
+ need a little extra work to get them built on new systems, because
+ they use some features that aren't standardized in POSIX.
+
+ MinGW is free software. MinGW runtime provides some functions that
+ made porting the command line tools easier. Most(?) of the MinGW
+ runtime, which gets linked into the resulting binaries, is in the
+ public domain.
+
+ While most C compilers nowadays support C99 well enough (including
+ most compilers for Windows), MSVC doesn't. It seems that Microsoft
+ has no plans to ever support C99. Thus, it is not possible to build
+ XZ Utils using MSVC without doing a lot of work to convert the code.
+ Using prebuilt liblzma from MSVC is possible though, since the
+ liblzma API headers are in C89 and contain some non-standard extra
+ hacks required by MSVC.
+
+
+Getting and Installing MinGW
+
+ You can download MinGW for 32-bit Windows from Sourceforge:
+
+ http://sourceforge.net/project/showfiles.php?group_id=2435
+
+ It is enough to pick Automated MinGW Installer and MSYS Base System.
+ Using the automated installer, select at least runtime, w32api,
+ core compiler, and MinGW make. From MSYS you actually need only
+ certain tools, but it is easiest to just install the whole MSYS.
+
+ To build for x86-64 version of Windows, you can download a snapshot
+ of MinGW targeting for 64-bit Windows:
+
+ http://sourceforge.net/project/showfiles.php?group_id=202880
+
+ You can use the 32-bit MSYS also for 64-bit build, since we don't
+ link against anything in MSYS, just use the tools from it. You may
+ use the make tool from 32-bit MinGW (mingw32-make.exe) although
+ probably the make.exe from MSYS works too.
+
+ Naturally you can pick the components manually, for example to try
+ the latest available GCC. It is also possible to use a cross-compiler
+ to build Windows binaries for example on GNU/Linux, or use Wine to
+ run the Windows binaries. However, these instructions focus on
+ building on Windows.
+
+
+Building for 32-bit Windows
+
+ Add MinGW and MSYS to PATH (adjust if you installed to non-default
+ location):
+
+ C:\>set PATH=C:\MinGW\bin;C:\MSYS\1.0\bin;%PATH%
+
+ Then it should be enough to just run mingw32-make in this directory:
+
+ C:\xz-5.x.x\windows>mingw32-make
+
+
+Building for 64-bit Windows
+
+ For 64-bit build the PATH has to point to 64-bit MinGW:
+
+ C:\>set PATH=C:\MinGW64\bin;C:\MSYS\1.0\bin;%PATH%
+
+ You need to pass W64=1 to mingw32-make (or make if you don't have
+ mingw32-make):
+
+ C:\xz-5.x.x\windows>mingw32-make W64=1
+
+
+Additional Make Flags and Targets
+
+ You may want to try some additional optimizations, which may or
+ may not make the code faster (and may or may not hit possible
+ compiler bugs more easily):
+
+ mingw32-make CFLAGS="-O3 -fomit-frame-pointer -funroll-loops"
+
+ If you want to enable assertions (the assert() macro), use DEBUG=1.
+ You may want to disable optimizations too if you plan to actually
+ debug the code. Never use DEBUG=1 for production builds!
+
+ mingw32-make DEBUG=1 CFLAGS="-g -O0"
+
+ By default, liblzma is built as a DLL and the command line tools
+ linked dynamically against that liblzma.dll. To build static
+ versions instead, use STATIC=1:
+
+ mingw32-make STATIC=1
+
+ TODO: Static build is not implemented yet.
+
+ To copy the built binaries and required headers into a clean
+ directory, use the pkg target:
+
+ mingw32-make pkg
+
+ It first removes a possibly existing pkg directory, and then
+ recreates it with the required files.
+
+ TODO: The pkg target doesn't copy any license or other copyright
+ related information into the pkg directory.
+
+
+Creating an Import Library for MSVC
+
+ The included Makefile creates import library liblzma.a which works
+ only(?) with MinGW. To use liblzma.dll for MSVC, you need to create
+ liblzma.lib using the lib command from MSVC:
+
+ lib /def:liblzma.def /out:liblzma.lib /machine:ix86
+
+ On x86-64, the /machine argument has to naturally be changed:
+
+ lib /def:liblzma.def /out:liblzma.lib /machine:x64
+
+
+To Do
+
+ - Test Win64 support and add instructions about getting x86-64
+ version of MinGW.
+
+ - Static liblzma and statically linked command line tools
+
+ - Creating the import library for other compilers/linkers
+
+ - Building with other compilers for Windows
+
+ - liblzma currently uses cdecl. Would stdcall be more compatible?
+
+ - Support building more size-optimized liblzma (the HAVE_SMALL
+ define and other things that are needed)
+
+ - Support selecting which parts of liblzma to build to make the
+ library even smaller.
+
+ - Use the configure script on Windows just like it is used on all
+ the other systems?
+
+
+Bugs
+
+ Report bugs to <lasse.collin@tukaani.org> (in English or Finnish).
+
+ Take into account that I don't have MSVC and I cannot very easily
+ test anything on Windows. As of writing, I have tried MinGW and the
+ resulting binaries only under 32-bit Wine.
+
diff --git a/windows/config.h b/windows/config.h
new file mode 100644
index 00000000..4a055e8c
--- /dev/null
+++ b/windows/config.h
@@ -0,0 +1,180 @@
+/* Define to 1 if using x86 assembler optimizations. */
+/* #undef HAVE_ASM_X86 */
+
+/* Define to 1 if using x86_64 assembler optimizations. */
+/* #undef HAVE_ASM_X86_64 */
+
+/* Define to 1 if crc32 integrity check is enabled. */
+#define HAVE_CHECK_CRC32 1
+
+/* Define to 1 if crc64 integrity check is enabled. */
+#define HAVE_CHECK_CRC64 1
+
+/* Define to 1 if sha256 integrity check is enabled. */
+#define HAVE_CHECK_SHA256 1
+
+/* Define to 1 if decoder components are enabled. */
+#define HAVE_DECODER 1
+
+/* Define to 1 if arm decoder is enabled. */
+#define HAVE_DECODER_ARM 1
+
+/* Define to 1 if armthumb decoder is enabled. */
+#define HAVE_DECODER_ARMTHUMB 1
+
+/* Define to 1 if delta decoder is enabled. */
+#define HAVE_DECODER_DELTA 1
+
+/* Define to 1 if ia64 decoder is enabled. */
+#define HAVE_DECODER_IA64 1
+
+/* Define to 1 if lzma1 decoder is enabled. */
+#define HAVE_DECODER_LZMA1 1
+
+/* Define to 1 if lzma2 decoder is enabled. */
+#define HAVE_DECODER_LZMA2 1
+
+/* Define to 1 if powerpc decoder is enabled. */
+#define HAVE_DECODER_POWERPC 1
+
+/* Define to 1 if sparc decoder is enabled. */
+#define HAVE_DECODER_SPARC 1
+
+/* Define to 1 if subblock decoder is enabled. */
+/* #undef HAVE_DECODER_SUBBLOCK */
+
+/* Define to 1 if x86 decoder is enabled. */
+#define HAVE_DECODER_X86 1
+
+/* Define to 1 if encoder components are enabled. */
+#define HAVE_ENCODER 1
+
+/* Define to 1 if arm encoder is enabled. */
+#define HAVE_ENCODER_ARM 1
+
+/* Define to 1 if armthumb encoder is enabled. */
+#define HAVE_ENCODER_ARMTHUMB 1
+
+/* Define to 1 if delta encoder is enabled. */
+#define HAVE_ENCODER_DELTA 1
+
+/* Define to 1 if ia64 encoder is enabled. */
+#define HAVE_ENCODER_IA64 1
+
+/* Define to 1 if lzma1 encoder is enabled. */
+#define HAVE_ENCODER_LZMA1 1
+
+/* Define to 1 if lzma2 encoder is enabled. */
+#define HAVE_ENCODER_LZMA2 1
+
+/* Define to 1 if powerpc encoder is enabled. */
+#define HAVE_ENCODER_POWERPC 1
+
+/* Define to 1 if sparc encoder is enabled. */
+#define HAVE_ENCODER_SPARC 1
+
+/* Define to 1 if subblock encoder is enabled. */
+/* #undef HAVE_ENCODER_SUBBLOCK */
+
+/* Define to 1 if x86 encoder is enabled. */
+#define HAVE_ENCODER_X86 1
+
+/* Define to 1 if the system supports fast unaligned memory access. */
+#define HAVE_FAST_UNALIGNED_ACCESS 1
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#define HAVE_INTTYPES_H 1
+
+/* Define to 1 if you have the <limits.h> header file. */
+#define HAVE_LIMITS_H 1
+
+/* Define to 1 if you have the <memory.h> header file. */
+#define HAVE_MEMORY_H 1
+
+/* Define to 1 to enable bt2 match finder. */
+#define HAVE_MF_BT2 1
+
+/* Define to 1 to enable bt3 match finder. */
+#define HAVE_MF_BT3 1
+
+/* Define to 1 to enable bt4 match finder. */
+#define HAVE_MF_BT4 1
+
+/* Define to 1 to enable hc3 match finder. */
+#define HAVE_MF_HC3 1
+
+/* Define to 1 to enable hc4 match finder. */
+#define HAVE_MF_HC4 1
+
+/* Define to 1 if optimizing for size. */
+/* #undef HAVE_SMALL */
+
+/* Define to 1 if stdbool.h conforms to C99. */
+#define HAVE_STDBOOL_H 1
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#define HAVE_STDINT_H 1
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#define HAVE_STDLIB_H 1
+
+/* Define to 1 if you have the <strings.h> header file. */
+#define HAVE_STRINGS_H 1
+
+/* Define to 1 if you have the <string.h> header file. */
+#define HAVE_STRING_H 1
+
+/* Define to 1 if the system has the type `uintptr_t'. */
+#define HAVE_UINTPTR_T 1
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#define HAVE_SYS_TIME_H 1
+
+/* Define to 1 if you have the `utime' function. */
+#define HAVE_UTIME 1
+
+/* Define to 1 or 0, depending whether the compiler supports simple visibility
+ declarations. */
+#define HAVE_VISIBILITY 0
+
+/* Define to 1 if the system has the type `_Bool'. */
+#define HAVE__BOOL 1
+
+/* Name of package */
+#define PACKAGE "xz"
+
+/* Define to the address where bug reports for this package should be sent. */
+#define PACKAGE_BUGREPORT "lasse.collin@tukaani.org"
+
+/* Define to the full name of this package. */
+#define PACKAGE_NAME "XZ Utils"
+
+/* Define to the full name and version of this package. */
+#define PACKAGE_STRING "XZ Utils 4.999.8beta"
+
+/* Define to the one symbol short name of this package. */
+#define PACKAGE_TARNAME "xz"
+
+/* Define to the version of this package. */
+#define PACKAGE_VERSION "4.999.8beta"
+
+/* The size of `size_t', as computed by sizeof. */
+#ifdef _WIN64
+# define SIZEOF_SIZE_T 8
+#else
+# define SIZEOF_SIZE_T 4
+#endif
+
+/* Define to 1 if you have the ANSI C header files. */
+#define STDC_HEADERS 1
+
+/* Version number of package */
+#define VERSION "4.999.8beta"
+
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
+ significant byte first (like Motorola and SPARC, unlike Intel and VAX). */
+#if defined __BIG_ENDIAN__
+# define WORDS_BIGENDIAN 1
+#elif ! defined __LITTLE_ENDIAN__
+/* # undef WORDS_BIGENDIAN */
+#endif