2009-02-05 08:17:51 +01:00
|
|
|
###############################################################################
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
2009-02-07 15:26:58 +01:00
|
|
|
# WINE=1 Shortcut to set CC, AR, and STRIP to use Wine to run Windows
|
2009-02-05 08:17:51 +01:00
|
|
|
# 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
|
2009-02-10 20:48:05 +01:00
|
|
|
WINDRES = x86_64-pc-mingw32-windres
|
2009-02-07 15:26:58 +01:00
|
|
|
AR = x86_64-pc-mingw32-ar
|
2009-02-05 08:17:51 +01:00
|
|
|
STRIP = x86_64-pc-mingw32-strip
|
|
|
|
else
|
|
|
|
CC = mingw32-gcc
|
2009-02-10 20:48:05 +01:00
|
|
|
WINDRES = windres
|
2009-02-07 15:26:58 +01:00
|
|
|
AR = ar
|
2009-02-05 08:17:51 +01:00
|
|
|
STRIP = strip
|
|
|
|
endif
|
|
|
|
|
|
|
|
SED = sed
|
2009-02-06 09:06:32 +01:00
|
|
|
MKDIR = mkdir
|
|
|
|
CP = cp
|
2009-02-05 08:17:51 +01:00
|
|
|
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
|
2009-02-10 20:48:05 +01:00
|
|
|
WINDRES := wine c:/MinGW64/bin/x86_64-pc-mingw32-windres
|
2009-02-07 15:26:58 +01:00
|
|
|
AR := wine c:/MinGW64/bin/x86_64-pc-mingw32-ar
|
2009-02-05 08:17:51 +01:00
|
|
|
STRIP := wine c:/MinGW64/bin/x86_64-pc-mingw32-strip
|
|
|
|
else
|
|
|
|
CC := wine c:/MinGW/bin/gcc
|
2009-02-10 20:48:05 +01:00
|
|
|
WINDRES := wine c:/MinGW/bin/windres
|
2009-02-07 15:26:58 +01:00
|
|
|
AR := wine c:/MinGW/bin/ar
|
2009-02-05 08:17:51 +01:00
|
|
|
STRIP := wine c:/MinGW/bin/strip
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifdef DEBUG
|
2009-06-04 21:59:55 +02:00
|
|
|
# Use echo since it works for this purpose on both Windows and POSIX.
|
2009-02-05 08:17:51 +01:00
|
|
|
STRIP := echo Skipping strip
|
|
|
|
else
|
|
|
|
ALL_CPPFLAGS += -DNDEBUG
|
|
|
|
endif
|
|
|
|
|
|
|
|
ALL_CPPFLAGS += $(CPPFLAGS)
|
|
|
|
ALL_CFLAGS += $(CFLAGS)
|
|
|
|
|
|
|
|
|
|
|
|
################
|
|
|
|
# Common rules #
|
|
|
|
################
|
|
|
|
|
|
|
|
.PHONY: all clean pkg
|
2009-02-07 15:26:58 +01:00
|
|
|
all: liblzma xzdec xz
|
2009-02-05 08:17:51 +01:00
|
|
|
clean: liblzma-clean xzdec-clean xz-clean
|
|
|
|
|
|
|
|
pkg: all
|
|
|
|
$(RM) -r pkg
|
2009-02-06 09:06:32 +01:00
|
|
|
$(MKDIR) -p pkg/lib pkg/include/lzma
|
2009-02-07 15:26:58 +01:00
|
|
|
$(CP) liblzma.dll xz-dynamic.exe xz.exe xzdec-dynamic.exe xzdec.exe lzmadec-dynamic.exe lzmadec.exe pkg
|
|
|
|
$(CP) liblzma.a liblzma.def liblzma_static.lib pkg/lib
|
2009-02-06 09:06:32 +01:00
|
|
|
$(CP) ../src/liblzma/api/lzma.h pkg/include
|
|
|
|
$(CP) ../src/liblzma/api/lzma/*.h pkg/include/lzma
|
2009-02-05 08:17:51 +01:00
|
|
|
|
2009-02-10 20:48:05 +01:00
|
|
|
%_rc.o: %.rc
|
2009-02-13 17:02:05 +01:00
|
|
|
$(WINDRES) $(ALL_CPPFLAGS) $< $@
|
2009-02-10 20:48:05 +01:00
|
|
|
|
2009-02-05 08:17:51 +01:00
|
|
|
|
|
|
|
###############
|
|
|
|
# liblzma.dll #
|
|
|
|
###############
|
|
|
|
|
2009-02-07 15:26:58 +01:00
|
|
|
.PHONY: liblzma
|
|
|
|
liblzma: liblzma.dll liblzma_static.lib
|
|
|
|
|
2009-02-05 08:17:51 +01:00
|
|
|
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 \
|
2009-02-17 09:43:00 +01:00
|
|
|
../src/liblzma/common/easy_buffer_encoder.c \
|
|
|
|
../src/liblzma/common/easy_decoder_memusage.c \
|
|
|
|
../src/liblzma/common/easy_encoder.c \
|
|
|
|
../src/liblzma/common/easy_encoder_memusage.c \
|
|
|
|
../src/liblzma/common/easy_preset.c \
|
2009-06-26 14:40:40 +02:00
|
|
|
../src/liblzma/common/filter_buffer_decoder.c \
|
|
|
|
../src/liblzma/common/filter_buffer_encoder.c \
|
2009-02-05 08:17:51 +01:00
|
|
|
../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/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)
|
2009-02-10 20:48:05 +01:00
|
|
|
LIBLZMA_OBJS = $(LIBLZMA_OBJS_C) $(LIBLZMA_OBJS_ASM) liblzma_rc.o
|
2009-02-05 08:17:51 +01:00
|
|
|
|
2009-02-07 15:26:58 +01:00
|
|
|
LIBLZMA_OBJS_STATIC_C = $(LIBLZMA_SRCS_C:.c=-static.o)
|
|
|
|
LIBLZMA_OBJS_STATIC_ASM = $(LIBLZMA_SRCS_ASM:.S=-static.o)
|
|
|
|
LIBLZMA_OBJS_STATIC = $(LIBLZMA_OBJS_STATIC_C) $(LIBLZMA_OBJS_STATIC_ASM)
|
|
|
|
|
2009-02-05 08:17:51 +01:00
|
|
|
# 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)
|
2009-02-07 15:26:58 +01:00
|
|
|
$(CC) $(ALL_CFLAGS) -shared -o liblzma.dll $(LIBLZMA_OBJS) -Wl,--out-implib,liblzma.a,--output-def,liblzma.def.in
|
2009-02-05 08:17:51 +01:00
|
|
|
$(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
|
2009-06-26 14:37:53 +02:00
|
|
|
$(CC) -DDLL_EXPORT $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -o $@ $<
|
2009-02-05 08:17:51 +01:00
|
|
|
|
|
|
|
$(LIBLZMA_OBJS_ASM): %.o: %.S
|
2009-06-26 14:37:53 +02:00
|
|
|
$(CC) -DDLL_EXPORT $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -o $@ $<
|
2009-02-05 08:17:51 +01:00
|
|
|
|
2009-02-07 15:26:58 +01:00
|
|
|
liblzma_static.lib: $(LIBLZMA_OBJS_STATIC)
|
|
|
|
$(RM) $@
|
|
|
|
$(AR) rcs $@ $(LIBLZMA_OBJS_STATIC)
|
|
|
|
$(STRIP) --strip-unneeded $@
|
|
|
|
|
|
|
|
$(LIBLZMA_OBJS_STATIC_C): %-static.o: %.c
|
2009-06-26 14:37:53 +02:00
|
|
|
$(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -o $@ $<
|
2009-02-07 15:26:58 +01:00
|
|
|
|
|
|
|
$(LIBLZMA_OBJS_STATIC_ASM): %-static.o: %.S
|
2009-06-26 14:37:53 +02:00
|
|
|
$(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -o $@ $<
|
2009-02-07 15:26:58 +01:00
|
|
|
|
2009-02-05 08:17:51 +01:00
|
|
|
.PHONY: liblzma-clean
|
|
|
|
liblzma-clean:
|
2009-02-07 15:26:58 +01:00
|
|
|
-$(RM) $(LIBLZMA_OBJS) $(LIBLZMA_OBJS_STATIC) liblzma.def.in liblzma.def liblzma.a liblzma.dll liblzma_static.lib
|
2009-02-05 08:17:51 +01:00
|
|
|
|
|
|
|
|
|
|
|
###########################
|
|
|
|
# xzdec.exe & lzmadec.exe #
|
|
|
|
###########################
|
|
|
|
|
2009-02-07 15:26:58 +01:00
|
|
|
.PHONY: xzdec
|
|
|
|
xzdec: xzdec-dynamic.exe lzmadec-dynamic.exe xzdec.exe lzmadec.exe
|
|
|
|
|
2009-02-05 08:17:51 +01:00
|
|
|
XZDEC_SRCS = ../src/xzdec/xzdec.c
|
|
|
|
|
2009-02-10 20:48:05 +01:00
|
|
|
xzdec-dynamic.exe: liblzma.dll $(XZDEC_SRCS) xzdec_rc.o
|
|
|
|
$(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) $(XZDEC_SRCS) xzdec_rc.o -o $@ liblzma.a
|
2009-02-07 15:26:58 +01:00
|
|
|
$(STRIP) --strip-all $@
|
2009-02-05 08:17:51 +01:00
|
|
|
|
2009-02-10 20:48:05 +01:00
|
|
|
lzmadec-dynamic.exe: liblzma.dll $(XZDEC_SRCS) lzmadec_rc.o
|
|
|
|
$(CC) $(ALL_CPPFLAGS) -DLZMADEC $(ALL_CFLAGS) $(XZDEC_SRCS) lzmadec_rc.o -o $@ liblzma.a
|
2009-02-07 15:26:58 +01:00
|
|
|
$(STRIP) --strip-all $@
|
|
|
|
|
2009-02-10 20:48:05 +01:00
|
|
|
xzdec.exe: liblzma_static.lib $(XZDEC_SRCS) xzdec_rc.o
|
2009-06-26 14:37:53 +02:00
|
|
|
$(CC) -DLZMA_API_STATIC $(ALL_CPPFLAGS) $(ALL_CFLAGS) $(XZDEC_SRCS) xzdec_rc.o -o $@ liblzma_static.lib
|
2009-02-07 15:26:58 +01:00
|
|
|
$(STRIP) --strip-all $@
|
|
|
|
|
2009-02-10 20:48:05 +01:00
|
|
|
lzmadec.exe: liblzma_static.lib $(XZDEC_SRCS) lzmadec_rc.o
|
2009-06-26 14:37:53 +02:00
|
|
|
$(CC) -DLZMA_API_STATIC $(ALL_CPPFLAGS) -DLZMADEC $(ALL_CFLAGS) $(XZDEC_SRCS) lzmadec_rc.o -o $@ liblzma_static.lib
|
2009-02-07 15:26:58 +01:00
|
|
|
$(STRIP) --strip-all $@
|
2009-02-05 08:17:51 +01:00
|
|
|
|
|
|
|
.PHONY: xzdec-clean
|
|
|
|
xzdec-clean:
|
2009-02-10 20:48:05 +01:00
|
|
|
-$(RM) xzdec-dynamic.exe lzmadec-dynamic.exe xzdec.exe lzmadec.exe xzdec_rc.o lzmadec_rc.o
|
2009-02-05 08:17:51 +01:00
|
|
|
|
|
|
|
|
|
|
|
##########
|
|
|
|
# xz.exe #
|
|
|
|
##########
|
|
|
|
|
2009-02-07 15:26:58 +01:00
|
|
|
.PHONY: xz
|
|
|
|
xz: xz-dynamic.exe xz.exe
|
|
|
|
|
2009-02-05 08:17:51 +01:00
|
|
|
XZ_SRCS = \
|
|
|
|
../src/xz/args.c \
|
2009-06-26 19:49:54 +02:00
|
|
|
../src/xz/coder.c \
|
|
|
|
../src/xz/file_io.c \
|
2009-02-05 08:17:51 +01:00
|
|
|
../src/xz/hardware.c \
|
|
|
|
../src/xz/main.c \
|
|
|
|
../src/xz/message.c \
|
|
|
|
../src/xz/options.c \
|
|
|
|
../src/xz/signals.c \
|
|
|
|
../src/xz/suffix.c \
|
|
|
|
../src/xz/util.c
|
|
|
|
|
|
|
|
XZ_OBJS = $(XZ_SRCS:.c=.o)
|
2009-02-07 15:26:58 +01:00
|
|
|
XZ_OBJS_STATIC = $(XZ_SRCS:.c=-static.o)
|
|
|
|
|
2009-06-26 19:36:45 +02:00
|
|
|
$(XZ_OBJS): %.o: %.c
|
2009-02-07 15:26:58 +01:00
|
|
|
$(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -o $@ $<
|
|
|
|
|
2009-02-10 20:48:05 +01:00
|
|
|
xz-dynamic.exe: liblzma.dll $(XZ_OBJS) xz_rc.o
|
|
|
|
$(CC) $(ALL_CFLAGS) $(XZ_OBJS) xz_rc.o -o $@ liblzma.a
|
2009-02-07 15:26:58 +01:00
|
|
|
$(STRIP) --strip-all $@
|
|
|
|
|
2009-06-26 19:36:45 +02:00
|
|
|
$(XZ_OBJS_STATIC): %-static.o: %.c
|
2009-06-26 14:37:53 +02:00
|
|
|
$(CC) -DLZMA_API_STATIC $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -o $@ $<
|
2009-02-05 08:17:51 +01:00
|
|
|
|
2009-02-10 20:48:05 +01:00
|
|
|
xz.exe: liblzma_static.lib $(XZ_OBJS_STATIC) xz_rc.o
|
|
|
|
$(CC) $(ALL_CFLAGS) $(XZ_OBJS_STATIC) xz_rc.o -o $@ liblzma_static.lib
|
2009-02-07 15:26:58 +01:00
|
|
|
$(STRIP) --strip-all $@
|
2009-02-05 08:17:51 +01:00
|
|
|
|
|
|
|
.PHONY: xz-clean
|
|
|
|
xz-clean:
|
2009-06-26 19:36:45 +02:00
|
|
|
-$(RM) $(XZ_OBJS) $(XZ_OBJS_STATIC) xz_rc.o xz-dynamic.exe xz.exe
|