MinGW support: Don't build fastpos_tablegen.c as part of
liblzma. Build both static and dynamic liblzma, and also static and dynamic versions of the command line tools.
This commit is contained in:
parent
bfd91198e4
commit
d0ab8c1c73
|
@ -11,9 +11,7 @@
|
||||||
# W64=1 Build for 64-bit Windows. Make sure that you have 64-bit
|
# W64=1 Build for 64-bit Windows. Make sure that you have 64-bit
|
||||||
# MinGW in PATH.
|
# MinGW in PATH.
|
||||||
#
|
#
|
||||||
# STATIC=1 TODO: Build static library instead of a DLL.
|
# WINE=1 Shortcut to set CC, AR, and STRIP to use Wine to run Windows
|
||||||
#
|
|
||||||
# WINE=1 Shortcut to set CC and STRIP to use Wine to run Windows
|
|
||||||
# versions of MinGW binaries.
|
# versions of MinGW binaries.
|
||||||
#
|
#
|
||||||
# The usual CPPFLAGS and CFLAGS are supported too.
|
# The usual CPPFLAGS and CFLAGS are supported too.
|
||||||
|
@ -29,9 +27,11 @@
|
||||||
|
|
||||||
ifdef W64
|
ifdef W64
|
||||||
CC = x86_64-pc-mingw32-gcc
|
CC = x86_64-pc-mingw32-gcc
|
||||||
|
AR = x86_64-pc-mingw32-ar
|
||||||
STRIP = x86_64-pc-mingw32-strip
|
STRIP = x86_64-pc-mingw32-strip
|
||||||
else
|
else
|
||||||
CC = mingw32-gcc
|
CC = mingw32-gcc
|
||||||
|
AR = ar
|
||||||
STRIP = strip
|
STRIP = strip
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -60,13 +60,17 @@ ALL_CPPFLAGS = \
|
||||||
|
|
||||||
ALL_CPPFLAGS += -DHAVE_CONFIG_H
|
ALL_CPPFLAGS += -DHAVE_CONFIG_H
|
||||||
|
|
||||||
|
STATIC_CPPFLAGS = -DLZMA_API_STATIC
|
||||||
|
|
||||||
# This works with Wine too while using native GNU make, sed, and rm.
|
# This works with Wine too while using native GNU make, sed, and rm.
|
||||||
ifdef WINE
|
ifdef WINE
|
||||||
ifdef W64
|
ifdef W64
|
||||||
CC := wine c:/MinGW64/bin/x86_64-pc-mingw32-gcc
|
CC := wine c:/MinGW64/bin/x86_64-pc-mingw32-gcc
|
||||||
|
AR := wine c:/MinGW64/bin/x86_64-pc-mingw32-ar
|
||||||
STRIP := wine c:/MinGW64/bin/x86_64-pc-mingw32-strip
|
STRIP := wine c:/MinGW64/bin/x86_64-pc-mingw32-strip
|
||||||
else
|
else
|
||||||
CC := wine c:/MinGW/bin/gcc
|
CC := wine c:/MinGW/bin/gcc
|
||||||
|
AR := wine c:/MinGW/bin/ar
|
||||||
STRIP := wine c:/MinGW/bin/strip
|
STRIP := wine c:/MinGW/bin/strip
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
@ -87,14 +91,14 @@ ALL_CFLAGS += $(CFLAGS)
|
||||||
################
|
################
|
||||||
|
|
||||||
.PHONY: all clean pkg
|
.PHONY: all clean pkg
|
||||||
all: liblzma.dll xzdec.exe lzmadec.exe xz.exe
|
all: liblzma xzdec xz
|
||||||
clean: liblzma-clean xzdec-clean xz-clean
|
clean: liblzma-clean xzdec-clean xz-clean
|
||||||
|
|
||||||
pkg: all
|
pkg: all
|
||||||
$(RM) -r pkg
|
$(RM) -r pkg
|
||||||
$(MKDIR) -p pkg/lib pkg/include/lzma
|
$(MKDIR) -p pkg/lib pkg/include/lzma
|
||||||
$(CP) liblzma.dll xz.exe xzdec.exe lzmadec.exe pkg
|
$(CP) liblzma.dll xz-dynamic.exe xz.exe xzdec-dynamic.exe xzdec.exe lzmadec-dynamic.exe lzmadec.exe pkg
|
||||||
$(CP) liblzma.a liblzma.def pkg/lib
|
$(CP) liblzma.a liblzma.def liblzma_static.lib pkg/lib
|
||||||
$(CP) ../src/liblzma/api/lzma.h pkg/include
|
$(CP) ../src/liblzma/api/lzma.h pkg/include
|
||||||
$(CP) ../src/liblzma/api/lzma/*.h pkg/include/lzma
|
$(CP) ../src/liblzma/api/lzma/*.h pkg/include/lzma
|
||||||
|
|
||||||
|
@ -103,6 +107,9 @@ pkg: all
|
||||||
# liblzma.dll #
|
# liblzma.dll #
|
||||||
###############
|
###############
|
||||||
|
|
||||||
|
.PHONY: liblzma
|
||||||
|
liblzma: liblzma.dll liblzma_static.lib
|
||||||
|
|
||||||
LIBLZMA_SRCS_C = \
|
LIBLZMA_SRCS_C = \
|
||||||
../src/liblzma/common/alone_decoder.c \
|
../src/liblzma/common/alone_decoder.c \
|
||||||
../src/liblzma/common/alone_encoder.c \
|
../src/liblzma/common/alone_encoder.c \
|
||||||
|
@ -144,7 +151,6 @@ LIBLZMA_SRCS_C = \
|
||||||
../src/liblzma/lz/lz_encoder.c \
|
../src/liblzma/lz/lz_encoder.c \
|
||||||
../src/liblzma/lz/lz_encoder_mf.c \
|
../src/liblzma/lz/lz_encoder_mf.c \
|
||||||
../src/liblzma/lzma/fastpos_table.c \
|
../src/liblzma/lzma/fastpos_table.c \
|
||||||
../src/liblzma/lzma/fastpos_tablegen.c \
|
|
||||||
../src/liblzma/lzma/lzma2_decoder.c \
|
../src/liblzma/lzma/lzma2_decoder.c \
|
||||||
../src/liblzma/lzma/lzma2_encoder.c \
|
../src/liblzma/lzma/lzma2_encoder.c \
|
||||||
../src/liblzma/lzma/lzma_decoder.c \
|
../src/liblzma/lzma/lzma_decoder.c \
|
||||||
|
@ -181,11 +187,15 @@ LIBLZMA_OBJS_C = $(LIBLZMA_SRCS_C:.c=.o)
|
||||||
LIBLZMA_OBJS_ASM = $(LIBLZMA_SRCS_ASM:.S=.o)
|
LIBLZMA_OBJS_ASM = $(LIBLZMA_SRCS_ASM:.S=.o)
|
||||||
LIBLZMA_OBJS = $(LIBLZMA_OBJS_C) $(LIBLZMA_OBJS_ASM)
|
LIBLZMA_OBJS = $(LIBLZMA_OBJS_C) $(LIBLZMA_OBJS_ASM)
|
||||||
|
|
||||||
|
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)
|
||||||
|
|
||||||
# The sed is needed to remove ordinals from the .def file. I'm not going
|
# 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
|
# to track the ordinal numbers, so people should link against liblzma.dll
|
||||||
# only by using symbol names.
|
# only by using symbol names.
|
||||||
liblzma.dll: $(LIBLZMA_OBJS)
|
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
|
$(CC) $(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
|
$(SED) 's/ \+@ *[0-9]\+//' liblzma.def.in > liblzma.def
|
||||||
$(RM) liblzma.def.in
|
$(RM) liblzma.def.in
|
||||||
$(STRIP) --strip-unneeded liblzma.a
|
$(STRIP) --strip-unneeded liblzma.a
|
||||||
|
@ -197,34 +207,59 @@ $(LIBLZMA_OBJS_C): %.o: %.c
|
||||||
$(LIBLZMA_OBJS_ASM): %.o: %.S
|
$(LIBLZMA_OBJS_ASM): %.o: %.S
|
||||||
$(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -o $@ $<
|
$(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
liblzma_static.lib: $(LIBLZMA_OBJS_STATIC)
|
||||||
|
$(RM) $@
|
||||||
|
$(AR) rcs $@ $(LIBLZMA_OBJS_STATIC)
|
||||||
|
$(STRIP) --strip-unneeded $@
|
||||||
|
|
||||||
|
$(LIBLZMA_OBJS_STATIC_C): %-static.o: %.c
|
||||||
|
$(CC) $(STATIC_CPPFLAGS) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
$(LIBLZMA_OBJS_STATIC_ASM): %-static.o: %.S
|
||||||
|
$(CC) $(STATIC_CPPFLAGS) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
.PHONY: liblzma-clean
|
.PHONY: liblzma-clean
|
||||||
liblzma-clean:
|
liblzma-clean:
|
||||||
-$(RM) $(LIBLZMA_OBJS) liblzma.def.in liblzma.def liblzma.a liblzma.dll
|
-$(RM) $(LIBLZMA_OBJS) $(LIBLZMA_OBJS_STATIC) liblzma.def.in liblzma.def liblzma.a liblzma.dll liblzma_static.lib
|
||||||
|
|
||||||
|
|
||||||
###########################
|
###########################
|
||||||
# xzdec.exe & lzmadec.exe #
|
# xzdec.exe & lzmadec.exe #
|
||||||
###########################
|
###########################
|
||||||
|
|
||||||
|
.PHONY: xzdec
|
||||||
|
xzdec: xzdec-dynamic.exe lzmadec-dynamic.exe xzdec.exe lzmadec.exe
|
||||||
|
|
||||||
XZDEC_SRCS = ../src/xzdec/xzdec.c
|
XZDEC_SRCS = ../src/xzdec/xzdec.c
|
||||||
|
|
||||||
xzdec.exe: liblzma.dll $(XZDEC_SRCS)
|
xzdec-dynamic.exe: liblzma.dll $(XZDEC_SRCS)
|
||||||
$(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) $(XZDEC_SRCS) -o xzdec.exe liblzma.a
|
$(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) $(XZDEC_SRCS) -o $@ liblzma.a
|
||||||
$(STRIP) --strip-all xzdec.exe
|
$(STRIP) --strip-all $@
|
||||||
|
|
||||||
lzmadec.exe: liblzma.dll $(XZDEC_SRCS)
|
lzmadec-dynamic.exe: liblzma.dll $(XZDEC_SRCS)
|
||||||
$(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -DLZMADEC $(XZDEC_SRCS) -o lzmadec.exe liblzma.a
|
$(CC) $(ALL_CPPFLAGS) -DLZMADEC $(ALL_CFLAGS) $(XZDEC_SRCS) -o $@ liblzma.a
|
||||||
$(STRIP) --strip-all lzmadec.exe
|
$(STRIP) --strip-all $@
|
||||||
|
|
||||||
|
xzdec.exe: liblzma_static.lib $(XZDEC_SRCS)
|
||||||
|
$(CC) $(STATIC_CPPFLAGS) $(ALL_CPPFLAGS) $(ALL_CFLAGS) $(XZDEC_SRCS) -o $@ liblzma_static.lib
|
||||||
|
$(STRIP) --strip-all $@
|
||||||
|
|
||||||
|
lzmadec.exe: liblzma_static.lib $(XZDEC_SRCS)
|
||||||
|
$(CC) $(STATIC_CPPFLAGS) $(ALL_CPPFLAGS) -DLZMADEC $(ALL_CFLAGS) $(XZDEC_SRCS) -o $@ liblzma_static.lib
|
||||||
|
$(STRIP) --strip-all $@
|
||||||
|
|
||||||
.PHONY: xzdec-clean
|
.PHONY: xzdec-clean
|
||||||
xzdec-clean:
|
xzdec-clean:
|
||||||
-$(RM) xzdec.exe lzmadec.exe
|
-$(RM) xzdec-dynamic.exe lzmadec-dynamic.exe xzdec.exe lzmadec.exe
|
||||||
|
|
||||||
|
|
||||||
##########
|
##########
|
||||||
# xz.exe #
|
# xz.exe #
|
||||||
##########
|
##########
|
||||||
|
|
||||||
|
.PHONY: xz
|
||||||
|
xz: xz-dynamic.exe xz.exe
|
||||||
|
|
||||||
XZ_SRCS = \
|
XZ_SRCS = \
|
||||||
../src/xz/args.c \
|
../src/xz/args.c \
|
||||||
../src/xz/hardware.c \
|
../src/xz/hardware.c \
|
||||||
|
@ -237,19 +272,30 @@ XZ_SRCS = \
|
||||||
../src/xz/suffix.c \
|
../src/xz/suffix.c \
|
||||||
../src/xz/util.c
|
../src/xz/util.c
|
||||||
|
|
||||||
|
XZ_SRCS_FIXED = $(XZ_SRCS:.c=-fixed.c)
|
||||||
XZ_OBJS = $(XZ_SRCS:.c=.o)
|
XZ_OBJS = $(XZ_SRCS:.c=.o)
|
||||||
|
XZ_OBJS_STATIC = $(XZ_SRCS:.c=-static.o)
|
||||||
|
|
||||||
|
$(XZ_SRCS_FIXED): %-fixed.c: %.c
|
||||||
|
$(SED) "s/%'/%/g" $< > $@
|
||||||
|
|
||||||
# We need to "fix" the source files which use ' as format character
|
# We need to "fix" the source files which use ' as format character
|
||||||
# in printf() to get thousand separators. Windows doesn't support it.
|
# in printf() to get thousand separators. Windows doesn't support it.
|
||||||
# It's not in C89 or C99, but it is in POSIX.
|
# It's not in C89 or C99, but it is in POSIX.
|
||||||
$(XZ_OBJS): %.o: %.c
|
$(XZ_OBJS): %.o: %-fixed.c
|
||||||
$(SED) "s/%'/%/g" $< > $(<:.c=-fixed.c)
|
$(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -o $@ $<
|
||||||
$(CC) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -o $@ $(<:.c=-fixed.c)
|
|
||||||
|
|
||||||
xz.exe: $(XZ_OBJS)
|
xz-dynamic.exe: liblzma.dll $(XZ_OBJS)
|
||||||
$(CC) $(ALL_CFLAGS) $(XZ_OBJS) -o xz.exe liblzma.a
|
$(CC) $(ALL_CFLAGS) $(XZ_OBJS) -o $@ liblzma.a
|
||||||
$(STRIP) --strip-all xz.exe
|
$(STRIP) --strip-all $@
|
||||||
|
|
||||||
|
$(XZ_OBJS_STATIC): %-static.o: %-fixed.c
|
||||||
|
$(CC) $(STATIC_CPPFLAGS) $(ALL_CPPFLAGS) $(ALL_CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
|
xz.exe: liblzma_static.lib $(XZ_OBJS_STATIC)
|
||||||
|
$(CC) $(ALL_CFLAGS) $(XZ_OBJS_STATIC) -o $@ liblzma_static.lib
|
||||||
|
$(STRIP) --strip-all $@
|
||||||
|
|
||||||
.PHONY: xz-clean
|
.PHONY: xz-clean
|
||||||
xz-clean:
|
xz-clean:
|
||||||
-$(RM) $(XZ_OBJS) $(XZ_SRCS:.c=-fixed.c) xz.exe
|
-$(RM) $(XZ_OBJS) $(XZ_OBJS_STATIC) $(XZ_SRCS_FIXED) xz-dynamic.exe xz.exe
|
||||||
|
|
|
@ -99,14 +99,6 @@ Additional Make Flags and Targets
|
||||||
|
|
||||||
mingw32-make DEBUG=1 CFLAGS="-g -O0"
|
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
|
To copy the built binaries and required headers into a clean
|
||||||
directory, use the pkg target:
|
directory, use the pkg target:
|
||||||
|
|
||||||
|
@ -137,8 +129,6 @@ To Do
|
||||||
- Test Win64 support and add instructions about getting x86-64
|
- Test Win64 support and add instructions about getting x86-64
|
||||||
version of MinGW.
|
version of MinGW.
|
||||||
|
|
||||||
- Static liblzma and statically linked command line tools
|
|
||||||
|
|
||||||
- Creating the import library for other compilers/linkers
|
- Creating the import library for other compilers/linkers
|
||||||
|
|
||||||
- Building with other compilers for Windows
|
- Building with other compilers for Windows
|
||||||
|
|
Loading…
Reference in New Issue