10 #define ERROR_IF_EOF(i) { if ((i) == EOF) ioError(); }
11 #define ERROR_IF_NOT_ZERO(i) { if ((i) != 0) ioError(); }
28 BIGFILES=-D_FILE_OFFSET_BITS=64
29 -CFLAGS=-Wall -Winline -O2 -g $(BIGFILES)
30 +CFLAGS_COMMON=-Wall -Winline -O2 -g $(BIGFILES) -I.
31 +CFLAGS_NOPIC=$(filter-out -O%,$(CFLAGS)) $(CFLAGS_COMMON)
32 +CFLAGS_PIC=$(filter-out -O%,$(CFLAGS)) -fpic -fPIC $(CFLAGS_COMMON)
34 # Where you want it installed when you do 'make install'
46 +ifeq ($(ENABLE_BIN_STATIC),1)
48 + ifneq ($(ENABLE_LIB_STATIC),1)
52 +ifeq ($(ENABLE_BIN_SHARED),1)
54 + ifneq ($(ENABLE_LIB_SHARED),1)
58 +ifeq ($(ENABLE_LIB_STATIC),1)
61 +ifeq ($(ENABLE_LIB_SHARED),1)
71 -all: libbz2.a bzip2 bzip2recover test
73 -bzip2: libbz2.a bzip2.o
74 - $(CC) $(CFLAGS) $(LDFLAGS) -o bzip2 bzip2.o -L. -lbz2
79 +ifeq ($(ENABLE_LIB),1)
83 +ifeq ($(ENABLE_BIN),1)
84 + TGTS_all+=bzip2 bzip2recover
85 + TGTS_install+=bzip2 bzip2recover
87 +ifeq ($(ENABLE_TESTS),1)
95 +ifeq ($(ENABLE_BIN_STATIC),1)
96 + $(CC) $(CFLAGS_NOPIC) $(LDFLAGS) -o bzip2 bzip2.o -L. -lbz2
98 +ifeq ($(ENABLE_BIN_SHARED),1)
99 + $(CC) $(CFLAGS_PIC) -o bzip2-shared bzip2.o libbz2.so.1.0
102 bzip2recover: bzip2recover.o
103 - $(CC) $(CFLAGS) $(LDFLAGS) -o bzip2recover bzip2recover.o
104 + $(CC) $(CFLAGS_NOPIC) $(LDFLAGS) -o bzip2recover bzip2recover.o
108 +ifeq ($(ENABLE_LIB_STATIC),1)
110 $(AR) cq libbz2.a $(OBJS)
111 @if ( test -f $(RANLIB) -o -f /usr/bin/ranlib -o \
113 echo $(RANLIB) libbz2.a ; \
114 $(RANLIB) libbz2.a ; \
117 +ifeq ($(ENABLE_LIB_SHARED),1)
118 + $(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 $(LDFLAGS) -o libbz2.so.1.0.8 $(OBJS)
119 + rm -f libbz2.so.1.0
122 + ln -s libbz2.so.1.0.8 libbz2.so.1.0
123 + ln -s libbz2.so.1.0 libbz2.so.1
124 + ln -s libbz2.so.1 libbz2.so
128 +check: $(TGTS_check)
131 ./bzip2 -1 < sample1.ref > sample1.rb2
132 @@ -69,69 +129,153 @@
133 cmp sample3.tst sample3.ref
136 -install: bzip2 bzip2recover
137 +install: $(TGTS_install)
138 +ifeq ($(ENABLE_BIN),1)
139 if ( test ! -d $(PREFIX)/bin ) ; then mkdir -p $(PREFIX)/bin ; fi
141 +ifeq ($(ENABLE_LIB),1)
142 if ( test ! -d $(PREFIX)/lib ) ; then mkdir -p $(PREFIX)/lib ; fi
144 +ifeq ($(ENABLE_DEV),1)
145 + if ( test ! -d $(PREFIX)/include ) ; then mkdir -p $(PREFIX)/include ; fi
147 +ifeq ($(ENABLE_DOCS),1)
148 if ( test ! -d $(PREFIX)/man ) ; then mkdir -p $(PREFIX)/man ; fi
149 if ( test ! -d $(PREFIX)/man/man1 ) ; then mkdir -p $(PREFIX)/man/man1 ; fi
150 - if ( test ! -d $(PREFIX)/include ) ; then mkdir -p $(PREFIX)/include ; fi
152 +ifeq ($(ENABLE_BIN),1)
153 + ifeq ($(ENABLE_BIN_STATIC),1)
154 cp -f bzip2 $(PREFIX)/bin/bzip2
155 - cp -f bzip2 $(PREFIX)/bin/bunzip2
156 - cp -f bzip2 $(PREFIX)/bin/bzcat
157 + chmod a+rx $(PREFIX)/bin/bzip2
159 + ifeq ($(ENABLE_BIN_SHARED),1)
160 + ifeq ($(ENABLE_BIN_STATIC),1)
161 + cp -f bzip2-shared $(PREFIX)/bin/bzip2-shared
162 + chmod a+rx $(PREFIX)/bin/bzip2-shared
164 + cp -f bzip2-shared $(PREFIX)/bin/bzip2
167 + rm -f $(PREFIX)/bin/bunzip2
168 + rm -f $(PREFIX)/bin/bzcat
169 + ( cd $(PREFIX)/bin && ln -s bzip2 bunzip2 )
170 + ( cd $(PREFIX)/bin && ln -s bzip2 bzcat )
171 + rm -f $(PREFIX)/bin/bunzip2-shared
172 + rm -f $(PREFIX)/bin/bzcat-shared
173 + ifeq ($(ENABLE_BIN_SHARED),1)
174 + ifeq ($(ENABLE_BIN_STATIC),1)
175 + ( cd $(PREFIX)/bin && ln -s bzip2-shared bunzip2-shared )
176 + ( cd $(PREFIX)/bin && ln -s bzip2-shared bzcat-shared )
179 cp -f bzip2recover $(PREFIX)/bin/bzip2recover
180 - chmod a+x $(PREFIX)/bin/bzip2
181 - chmod a+x $(PREFIX)/bin/bunzip2
182 - chmod a+x $(PREFIX)/bin/bzcat
183 - chmod a+x $(PREFIX)/bin/bzip2recover
184 - cp -f bzip2.1 $(PREFIX)/man/man1
185 - chmod a+r $(PREFIX)/man/man1/bzip2.1
186 - cp -f bzlib.h $(PREFIX)/include
187 - chmod a+r $(PREFIX)/include/bzlib.h
188 - cp -f libbz2.a $(PREFIX)/lib
189 - chmod a+r $(PREFIX)/lib/libbz2.a
190 + chmod a+rx $(PREFIX)/bin/bzip2recover
191 cp -f bzgrep $(PREFIX)/bin/bzgrep
192 - ln -s -f $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzegrep
193 - ln -s -f $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzfgrep
194 - chmod a+x $(PREFIX)/bin/bzgrep
195 + chmod a+rx $(PREFIX)/bin/bzgrep
196 + rm -f $(PREFIX)/bin/bzegrep
197 + rm -f $(PREFIX)/bin/bzfgrep
198 + ( cd $(PREFIX)/bin && ln -s bzgrep bzegrep )
199 + ( cd $(PREFIX)/bin && ln -s bzgrep bzfgrep )
200 cp -f bzmore $(PREFIX)/bin/bzmore
201 - ln -s -f $(PREFIX)/bin/bzmore $(PREFIX)/bin/bzless
202 - chmod a+x $(PREFIX)/bin/bzmore
203 + chmod a+rx $(PREFIX)/bin/bzmore
204 + rm -f $(PREFIX)/bin/bzless
205 + ( cd $(PREFIX)/bin && ln -s bzmore bzless )
206 + rm -f $(PREFIX)/bin/bzcmp
207 cp -f bzdiff $(PREFIX)/bin/bzdiff
208 - ln -s -f $(PREFIX)/bin/bzdiff $(PREFIX)/bin/bzcmp
209 - chmod a+x $(PREFIX)/bin/bzdiff
210 - cp -f bzgrep.1 bzmore.1 bzdiff.1 $(PREFIX)/man/man1
211 - chmod a+r $(PREFIX)/man/man1/bzgrep.1
212 - chmod a+r $(PREFIX)/man/man1/bzmore.1
213 - chmod a+r $(PREFIX)/man/man1/bzdiff.1
214 + chmod a+rx $(PREFIX)/bin/bzdiff
215 + ( cd $(PREFIX)/bin && ln -s bzdiff bzcmp )
217 +ifeq ($(ENABLE_DEV),1)
218 + cp -f bzlib.h $(PREFIX)/include
219 + chmod a+r $(PREFIX)/include/bzlib.h
221 +ifeq ($(ENABLE_DOCS),1)
222 + cp -f bzip2.1 bzgrep.1 bzmore.1 bzdiff.1 $(PREFIX)/man/man1
223 echo ".so man1/bzgrep.1" > $(PREFIX)/man/man1/bzegrep.1
224 echo ".so man1/bzgrep.1" > $(PREFIX)/man/man1/bzfgrep.1
225 echo ".so man1/bzmore.1" > $(PREFIX)/man/man1/bzless.1
226 echo ".so man1/bzdiff.1" > $(PREFIX)/man/man1/bzcmp.1
227 + chmod a+r $(PREFIX)/man/man1/bzip2.1
228 + chmod a+r $(PREFIX)/man/man1/bzgrep.1
229 + chmod a+r $(PREFIX)/man/man1/bzmore.1
230 + chmod a+r $(PREFIX)/man/man1/bzdiff.1
231 + chmod a+r $(PREFIX)/man/man1/bzegrep.1
232 + chmod a+r $(PREFIX)/man/man1/bzfgrep.1
233 + chmod a+r $(PREFIX)/man/man1/bzless.1
234 + chmod a+r $(PREFIX)/man/man1/bzcmp.1
236 +ifeq ($(ENABLE_LIB_SHARED),1)
237 + cp -f libbz2.so.1.0.8 $(PREFIX)/lib
238 + chmod a+r $(PREFIX)/lib/libbz2.so.1.0.8
239 + rm -f $(PREFIX)/lib/libbz2.so.1.0
240 + rm -f $(PREFIX)/lib/libbz2.so.1
241 + rm -f $(PREFIX)/lib/libbz2.so
242 + ( cd $(PREFIX)/lib && ln -s libbz2.so.1.0.8 libbz2.so.1.0 )
243 + ( cd $(PREFIX)/lib && ln -s libbz2.so.1.0 libbz2.so.1 )
244 + ( cd $(PREFIX)/lib && ln -s libbz2.so.1 libbz2.so )
246 +ifeq ($(ENABLE_LIB_STATIC),1)
247 + cp -f libbz2.a $(PREFIX)/lib
248 + chmod a+r $(PREFIX)/lib/libbz2.a
252 + rm -f $(PREFIX)/bin/bzip2
253 + rm -f $(PREFIX)/bin/bzip2-shared
254 + rm -f $(PREFIX)/bin/bunzip2
255 + rm -f $(PREFIX)/bin/bzcat
256 + rm -f $(PREFIX)/bin/bunzip2-shared
257 + rm -f $(PREFIX)/bin/bzcat-shared
258 + rm -f $(PREFIX)/bin/bzip2recover
259 + rm -f $(PREFIX)/bin/bzgrep
260 + rm -f $(PREFIX)/bin/bzegrep
261 + rm -f $(PREFIX)/bin/bzfgrep
262 + rm -f $(PREFIX)/bin/bzmore
263 + rm -f $(PREFIX)/bin/bzless
264 + rm -f $(PREFIX)/bin/bzdiff
265 + rm -f $(PREFIX)/bin/bzcmp
266 + rm -f $(PREFIX)/include/bzlib.h
267 + rm -f $(PREFIX)/lib/libbz2.so.1.0.8
268 + rm -f $(PREFIX)/lib/libbz2.so.1.0
269 + rm -f $(PREFIX)/lib/libbz2.so.1
270 + rm -f $(PREFIX)/lib/libbz2.so
271 + rm -f $(PREFIX)/lib/libbz2.a
272 + rm -f $(PREFIX)/man/man1/bzip2.1
273 + rm -f $(PREFIX)/man/man1/bzgrep.1
274 + rm -f $(PREFIX)/man/man1/bzmore.1
275 + rm -f $(PREFIX)/man/man1/bzdiff.1
276 + rm -f $(PREFIX)/man/man1/bzegrep.1
277 + rm -f $(PREFIX)/man/man1/bzfgrep.1
278 + rm -f $(PREFIX)/man/man1/bzless.1
279 + rm -f $(PREFIX)/man/man1/bzcmp.1
280 + (rmdir $(PREFIX)/bin $(PREFIX)/include $(PREFIX)/lib $(PREFIX)/man/man1 $(PREFIX)/man || true ) 2> /dev/null
283 - rm -f *.o libbz2.a bzip2 bzip2recover \
284 + rm -f $(OBJS) bzip2.o \
285 + libbz2.so.1.0.8 libbz2.so.1.0 libbz2.so.1 libbz2.so \
286 + libbz2.a bzip2 bzip2-shared bzip2recover \
287 sample1.rb2 sample2.rb2 sample3.rb2 \
288 sample1.tst sample2.tst sample3.tst
290 blocksort.o: blocksort.c
292 - $(CC) $(CFLAGS) -c blocksort.c
293 + $(CC) $(CFLAGS_NOPIC) -c blocksort.c
295 - $(CC) $(CFLAGS) -c huffman.c
296 + $(CC) $(CFLAGS_NOPIC) -c huffman.c
297 crctable.o: crctable.c
298 - $(CC) $(CFLAGS) -c crctable.c
299 + $(CC) $(CFLAGS_NOPIC) -c crctable.c
300 randtable.o: randtable.c
301 - $(CC) $(CFLAGS) -c randtable.c
302 + $(CC) $(CFLAGS_NOPIC) -c randtable.c
303 compress.o: compress.c
304 - $(CC) $(CFLAGS) -c compress.c
305 + $(CC) $(CFLAGS_NOPIC) -c compress.c
306 decompress.o: decompress.c
307 - $(CC) $(CFLAGS) -c decompress.c
308 + $(CC) $(CFLAGS_NOPIC) -c decompress.c
310 - $(CC) $(CFLAGS) -c bzlib.c
311 + $(CC) $(CFLAGS_NOPIC) -c bzlib.c
313 - $(CC) $(CFLAGS) -c bzip2.c
314 + $(CC) $(CFLAGS_NOPIC) -c bzip2.c
315 bzip2recover.o: bzip2recover.c
316 - $(CC) $(CFLAGS) -c bzip2recover.c
317 + $(CC) $(CFLAGS_NOPIC) -c bzip2recover.c
322 $(DISTNAME)/bzmore.1 \
324 $(DISTNAME)/bzgrep.1 \
325 - $(DISTNAME)/Makefile-libbz2_so \
326 $(DISTNAME)/bz-common.xsl \
327 $(DISTNAME)/bz-fo.xsl \
328 $(DISTNAME)/bz-html.xsl \
329 --- a/Makefile-libbz2_so
330 +++ b/Makefile-libbz2_so
333 -# This Makefile builds a shared version of the library,
334 -# libbz2.so.1.0.8, with soname libbz2.so.1.0,
335 -# at least on x86-Linux (RedHat 7.2),
336 -# with gcc-2.96 20000731 (Red Hat Linux 7.1 2.96-98).
337 -# Please see the README file for some important info
338 -# about building the library like this.
340 -# ------------------------------------------------------------------
341 -# This file is part of bzip2/libbzip2, a program and library for
342 -# lossless, block-sorting data compression.
344 -# bzip2/libbzip2 version 1.0.8 of 13 July 2019
345 -# Copyright (C) 1996-2019 Julian Seward <jseward@acm.org>
347 -# Please read the WARNING, DISCLAIMER and PATENTS sections in the
350 -# This program is released under the terms of the license contained
351 -# in the file LICENSE.
352 -# ------------------------------------------------------------------
357 -BIGFILES=-D_FILE_OFFSET_BITS=64
358 -CFLAGS=-fpic -fPIC -Wall -Winline -O2 -g $(BIGFILES)
369 - $(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.8 $(OBJS)
370 - $(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.8
371 - rm -f libbz2.so.1.0
372 - ln -s libbz2.so.1.0.8 libbz2.so.1.0
375 - rm -f $(OBJS) bzip2.o libbz2.so.1.0.8 libbz2.so.1.0 bzip2-shared
377 -blocksort.o: blocksort.c
378 - $(CC) $(CFLAGS) -c blocksort.c
379 -huffman.o: huffman.c
380 - $(CC) $(CFLAGS) -c huffman.c
381 -crctable.o: crctable.c
382 - $(CC) $(CFLAGS) -c crctable.c
383 -randtable.o: randtable.c
384 - $(CC) $(CFLAGS) -c randtable.c
385 -compress.o: compress.c
386 - $(CC) $(CFLAGS) -c compress.c
387 -decompress.o: decompress.c
388 - $(CC) $(CFLAGS) -c decompress.c
390 - $(CC) $(CFLAGS) -c bzlib.c
400 #define M_BLOCK 1000000