Skip to content

Commit 4b54256

Browse files
add xz package which builds liblzma, needed for extra compression of ROOT files.
git-svn-id: http://root.cern.ch/svn/root/trunk@39870 27541ba8-7e3a-0410-8455-c3a389f83636
1 parent d181a0e commit 4b54256

File tree

4 files changed

+332
-0
lines changed

4 files changed

+332
-0
lines changed

core/lzma/Module.mk

Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
# Module.mk for lzma module
2+
# Copyright (c) 2011 Rene Brun and Fons Rademakers
3+
#
4+
# Author: Fons Rademakers, 15/6/2011
5+
6+
MODNAME := lzma
7+
MODDIR := $(ROOT_SRCDIR)/core/$(MODNAME)
8+
MODDIRS := $(MODDIR)/src
9+
MODDIRI := $(MODDIR)/inc
10+
11+
LZMADIR := $(MODDIR)
12+
LZMADIRS := $(LZMADIR)/src
13+
LZMADIRI := $(LZMADIR)/inc
14+
15+
LZMAVERS := xz-5.0.3
16+
ifeq ($(BUILTINLZMA),yes)
17+
LZMALIBDIRS := $(call stripsrc,$(MODDIRS)/$(LZMAVERS))
18+
LZMALIBDIRI := -I$(LZMALIBDIRS)/src/liblzma/api
19+
else
20+
LZMALIBDIRS :=
21+
LZMALIBDIRI := $(LZMAINCDIR:%=-I%)
22+
endif
23+
24+
##### liblzma.a #####
25+
ifeq ($(BUILTINLZMA),yes)
26+
LZMALIBS := $(MODDIRS)/$(LZMAVERS).tar.gz
27+
ifeq ($(PLATFORM),win32)
28+
LZMALIBA := $(LZMALIBDIRS)/objs/liblzma.lib
29+
LZMALIB := $(LPATH)/liblzma.lib
30+
ifeq (yes,$(WINRTDEBUG))
31+
LZMACFG := "liblzma - Win32 Debug Multithreaded"
32+
else
33+
LZMACFG := "liblzma - Win32 Release Multithreaded"
34+
endif
35+
else
36+
LZMALIBA := $(LZMALIBDIRS)/src/liblzma/.libs/liblzma.a
37+
LZMALIB := $(LPATH)/liblzma.a
38+
endif
39+
LZMALIBDEP := $(LZMALIB)
40+
else
41+
LZMALIBA := $(LZMALIBDIR) $(LZMACLILIB)
42+
LZMALIB := $(LZMALIBDIR) $(LZMACLILIB)
43+
LZMALIBDEP :=
44+
endif
45+
46+
##### ZipLZMA, part of libCore #####
47+
LZMAH := $(MODDIRI)/ZipLZMA.h
48+
LZMAS := $(MODDIRS)/ZipLZMA.c
49+
LZMAO := $(call stripsrc,$(LZMAS:.c=.o))
50+
51+
LZMADEP := $(LZMAO:.o=.d)
52+
53+
# used in the main Makefile
54+
ALLHDRS += $(patsubst $(MODDIRI)/%.h,include/%.h,$(LZMAH))
55+
56+
# include all dependency files
57+
INCLUDEFILES += $(LZMADEP)
58+
59+
##### local rules #####
60+
.PHONY: all-$(MODNAME) clean-$(MODNAME) distclean-$(MODNAME)
61+
62+
include/%.h: $(LZMADIRI)/%.h
63+
cp $< $@
64+
65+
ifeq ($(BUILTINLZMA),yes)
66+
$(LZMALIB): $(LZMALIBA)
67+
ifeq ($(PLATFORM),aix5)
68+
ar rv $@ $(LZMALIBDIRS)/src/liblzma/.libs/*.o
69+
else
70+
cp $< $@
71+
@(if [ $(PLATFORM) = "macosx" ]; then \
72+
ranlib $@; \
73+
fi)
74+
endif
75+
76+
$(LZMALIBA): $(LZMALIBS)
77+
$(MAKEDIR)
78+
ifeq ($(PLATFORM),win32)
79+
ifneq ($(ROOT_OBJDIR),$(ROOT_SRCDIR))
80+
@$(RSYNC) --exclude '.svn' --exclude '*.lib' $(LZMADIRS)/win $(call stripsrc,$(LZMADIRS))
81+
endif
82+
@(if [ -d $(LZMALIBDIRS) ]; then \
83+
rm -rf $(LZMALIBDIRS); \
84+
fi; \
85+
echo "*** Building $@..."; \
86+
cd $(call stripsrc,$(LZMADIRS)); \
87+
if [ ! -d $(LZMAVERS) ]; then \
88+
gunzip -c $(LZMALIBS) | tar xf -; \
89+
fi; \
90+
cd $(LZMAVERS)/builds/win32/visualc; \
91+
cp ../../../../win/lzma.mak .; \
92+
cp ../../../../win/lzma.dep .; \
93+
unset MAKEFLAGS; \
94+
nmake -nologo -f lzma.mak \
95+
CFG=$(LZMACFG) \
96+
NMAKECXXFLAGS="$(BLDCXXFLAGS) -D_CRT_SECURE_NO_DEPRECATE")
97+
else
98+
@(if [ -d $(LZMALIBDIRS) ]; then \
99+
rm -rf $(LZMALIBDIRS); \
100+
fi; \
101+
echo "*** Building $@..."; \
102+
cd $(call stripsrc,$(LZMADIRS)); \
103+
if [ ! -d $(LZMAVERS) ]; then \
104+
gunzip -c $(LZMALIBS) | tar xf -; \
105+
fi; \
106+
cd $(LZMAVERS); \
107+
LZMACC="$(CC)"; \
108+
if [ "$(CC)" = "icc" ]; then \
109+
LZMACC="icc -wd188 -wd181"; \
110+
fi; \
111+
if [ $(ARCH) = "alphacxx6" ]; then \
112+
LZMACC="cc"; \
113+
fi; \
114+
if [ $(ARCH) = "linux" ]; then \
115+
LZMACC="$$LZMACC -m32"; \
116+
LZMA_CFLAGS="-m32"; \
117+
fi; \
118+
if [ $(ARCH) = "linuxx8664gcc" ]; then \
119+
LZMACC="$$LZMACC -m64"; \
120+
LZMA_CFLAGS="-m64"; \
121+
fi; \
122+
if [ $(ARCH) = "linuxicc" ]; then \
123+
LZMACC="$$LZMACC -m32"; \
124+
LZMA_CFLAGS="-m32"; \
125+
fi; \
126+
if [ $(ARCH) = "linuxx8664icc" ]; then \
127+
LZMACC="$$LZMACC -m64"; \
128+
LZMA_CFLAGS="-m64"; \
129+
fi; \
130+
if [ $(ARCH) = "macosx" ]; then \
131+
LZMACC="$$LZMACC -m32"; \
132+
LZMA_CFLAGS="-m32"; \
133+
fi; \
134+
if [ $(ARCH) = "macosx64" ]; then \
135+
LZMACC="$$LZMACC -m64"; \
136+
LZMA_CFLAGS="-m64"; \
137+
fi; \
138+
if [ $(ARCH) = "iossim" ]; then \
139+
LZMACC="$$LZMACC -arch i386"; \
140+
LZMA_CFLAGS="-arch i386 -isysroot $(IOSSDK) -miphoneos-version-min=$(IOSVERS)"; \
141+
LZMA_HOST="--host=i686-apple-darwin10"; \
142+
fi; \
143+
if [ $(ARCH) = "ios" ]; then \
144+
LZMACC="$$LZMACC -arch armv7"; \
145+
LZMA_CFLAGS="-arch armv7 -isysroot $(IOSSDK) -miphoneos-version-min=$(IOSVERS)"; \
146+
LZMA_HOST="--host=arm-apple-darwin10"; \
147+
fi; \
148+
if [ $(ARCH) = "solaris64CC5" ]; then \
149+
LZMACC="$$LZMACC -m64"; \
150+
LZMA_CFLAGS="-m64"; \
151+
fi; \
152+
if [ $(ARCH) = "sgicc64" ]; then \
153+
LZMACC="cc"; \
154+
LZMA_CFLAGS="-64"; \
155+
fi; \
156+
if [ $(ARCH) = "linuxppc64gcc" ]; then \
157+
LZMACC="$$LZMACC -m64"; \
158+
LZMA_CFLAGS="-m64"; \
159+
fi; \
160+
if [ $(ARCH) = "hpuxia64acc" ]; then \
161+
LZMACC="cc"; \
162+
LZMA_CFLAGS="+DD64 -Ae +W863"; \
163+
fi; \
164+
GNUMAKE=$(MAKE) CC=$$LZMACC CFLAGS="$$LZMA_CFLAGS -O" \
165+
./configure $$LZMA_HOST --with-pic --disable-shared; \
166+
cd src/liblzma; \
167+
$(MAKE))
168+
endif
169+
endif
170+
171+
all-$(MODNAME): $(LZMAO)
172+
173+
clean-$(MODNAME):
174+
@rm -f $(LZMAO)
175+
ifeq ($(BUILTINLZMA),yes)
176+
ifeq ($(PLATFORM),win32)
177+
-@(if [ -d $(LZMALIBDIRS)/builds/win32/visualc ]; then \
178+
cd $(LZMALIBDIRS)/builds/win32/visualc; \
179+
unset MAKEFLAGS; \
180+
nmake -nologo -f lzma.mak \
181+
CFG=$(LZMACFG) clean; \
182+
fi)
183+
else
184+
-@(if [ -d $(LZMALIBDIRS) ]; then \
185+
cd $(LZMALIBDIRS); \
186+
$(MAKE) clean; \
187+
fi)
188+
endif
189+
endif
190+
191+
clean:: clean-$(MODNAME)
192+
193+
distclean-$(MODNAME): clean-$(MODNAME)
194+
@rm -f $(LZMADEP)
195+
@rm -rf $(call stripsrc,$(LZMADIRS)/$(LZMAVERS))
196+
ifeq ($(BUILTINLZMA),yes)
197+
@rm -f $(LZMALIB)
198+
endif
199+
ifeq ($(PLATFORM),win32)
200+
ifneq ($(ROOT_OBJDIR),$(ROOT_SRCDIR))
201+
@rm -rf $(call stripsrc,$(LZMADIRS)/win)
202+
endif
203+
endif
204+
205+
distclean:: distclean-$(MODNAME)
206+
207+
##### extra rules ######
208+
$(LZMAO): $(LZMALIBDEP)
209+
$(LZMAO): CFLAGS += $(LZMALIBDIRI)
210+

core/lzma/inc/ZipLZMA.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// @(#)root/lzma:$Id$
2+
// Author: David Dagenhart May 2011
3+
4+
/*************************************************************************
5+
* Copyright (C) 1995-2011, Rene Brun and Fons Rademakers. *
6+
* All rights reserved. *
7+
* *
8+
* For the licensing terms see $ROOTSYS/LICENSE. *
9+
* For the list of contributors see $ROOTSYS/README/CREDITS. *
10+
*************************************************************************/
11+
12+
static const int kHeaderSize = 9;
13+
14+
void R__zipLZMA(int cxlevel, int *srcsize, char *src, int *tgtsize, char *tgt, int *irep);
15+
16+
void R__unzipLZMA(int *srcsize, unsigned char *src, int *tgtsize, unsigned char *tgt, int *irep);

core/lzma/src/ZipLZMA.c

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
// @(#)root/lzma:$Id$
2+
// Author: David Dagenhart May 2011
3+
4+
/*************************************************************************
5+
* Copyright (C) 1995-2011, Rene Brun and Fons Rademakers. *
6+
* All rights reserved. *
7+
* *
8+
* For the licensing terms see $ROOTSYS/LICENSE. *
9+
* For the list of contributors see $ROOTSYS/README/CREDITS. *
10+
*************************************************************************/
11+
12+
#include "ZipLZMA.h"
13+
#include "lzma.h"
14+
#include <stdio.h>
15+
16+
void R__zipLZMA(int cxlevel, int *srcsize, char *src, int *tgtsize, char *tgt, int *irep)
17+
{
18+
*irep = 0;
19+
20+
if (*tgtsize <= 0) {
21+
return;
22+
}
23+
24+
if (*srcsize > 0xffffff || *srcsize < 0) {
25+
return;
26+
}
27+
28+
lzma_stream stream = LZMA_STREAM_INIT;
29+
lzma_ret returnStatus;
30+
if (cxlevel > 9) cxlevel = 9;
31+
returnStatus = lzma_easy_encoder(&stream,
32+
(uint32_t)(cxlevel),
33+
LZMA_CHECK_CRC32);
34+
if (returnStatus != LZMA_OK) {
35+
return;
36+
}
37+
38+
stream.next_in = (const uint8_t *)src;
39+
stream.avail_in = (size_t)(*srcsize);
40+
41+
stream.next_out = (uint8_t *)(&tgt[kHeaderSize]);
42+
stream.avail_out = (size_t)(*tgtsize);
43+
44+
returnStatus = lzma_code(&stream, LZMA_FINISH);
45+
if (returnStatus != LZMA_STREAM_END) {
46+
/* No need to print an error message. We simply abandon the compression
47+
the buffer cannot be compressed or compressed buffer would be larger than original buffer
48+
*/
49+
lzma_end(&stream);
50+
return;
51+
}
52+
lzma_end(&stream);
53+
54+
55+
tgt[0] = 'X'; /* Signature of LZMA from XZ Utils */
56+
tgt[1] = 'Z';
57+
tgt[2] = 0;
58+
59+
unsigned in_size = (unsigned) (*srcsize);
60+
uint64_t out_size = stream.total_out; /* compressed size */
61+
62+
tgt[3] = (char)(out_size & 0xff);
63+
tgt[4] = (char)((out_size >> 8) & 0xff);
64+
tgt[5] = (char)((out_size >> 16) & 0xff);
65+
66+
tgt[6] = (char)(in_size & 0xff); /* decompressed size */
67+
tgt[7] = (char)((in_size >> 8) & 0xff);
68+
tgt[8] = (char)((in_size >> 16) & 0xff);
69+
70+
*irep = stream.total_out + kHeaderSize;
71+
}
72+
73+
void R__unzipLZMA(int *srcsize, unsigned char *src, int *tgtsize, unsigned char *tgt, int *irep)
74+
{
75+
*irep = 0;
76+
77+
lzma_stream stream = LZMA_STREAM_INIT;
78+
lzma_ret returnStatus;
79+
80+
returnStatus = lzma_stream_decoder(&stream,
81+
UINT64_MAX,
82+
0U);
83+
if (returnStatus != LZMA_OK) {
84+
fprintf(stderr,
85+
"R__unzipLZMA: error %d in lzma_stream_decoder\n",
86+
returnStatus);
87+
return;
88+
}
89+
90+
stream.next_in = (const uint8_t *)(&src[kHeaderSize]);
91+
stream.avail_in = (size_t)(*srcsize);
92+
stream.next_out = (uint8_t *)tgt;
93+
stream.avail_out = (size_t)(*tgtsize);
94+
95+
returnStatus = lzma_code(&stream, LZMA_FINISH);
96+
if (returnStatus != LZMA_STREAM_END) {
97+
fprintf(stderr,
98+
"R__unzipLZMA: error %d in lzma_code\n",
99+
returnStatus);
100+
lzma_end(&stream);
101+
return;
102+
}
103+
lzma_end(&stream);
104+
105+
*irep = stream.total_out;
106+
}

core/lzma/src/xz-5.0.3.tar.gz

1.2 MB
Binary file not shown.

0 commit comments

Comments
 (0)