1# ------------------------------------------------------------------
2# This file is part of bzip2/libbzip2, a program and library for
3# lossless, block-sorting data compression.
4#
5# bzip2/libbzip2 version 1.0.6 of 6 September 2010
6# Copyright (C) 1996-2010 Julian Seward <jseward@bzip.org>
7#
8# Please read the WARNING, DISCLAIMER and PATENTS sections in the
9# README file.
10#
11# This program is released under the terms of the license contained
12# in the file LICENSE.
13# ------------------------------------------------------------------
14
15SHELL=/bin/sh
16
17# To assist in cross-compiling
18CC=gcc
19AR=ar
20RANLIB=ranlib
21LDFLAGS=
22
23BIGFILES=-D_FILE_OFFSET_BITS=64
24CFLAGS=-Wall -Winline -O2 -g $(BIGFILES)
25
26# Where you want it installed when you do 'make install'
27PREFIX=/usr/local
28
29
30OBJS= blocksort.o  \
31      huffman.o    \
32      crctable.o   \
33      randtable.o  \
34      compress.o   \
35      decompress.o \
36      bzlib.o
37
38all: libbz2.a bzip2 bzip2recover test
39
40bzip2: libbz2.a bzip2.o
41	$(CC) $(CFLAGS) $(LDFLAGS) -o bzip2 bzip2.o -L. -lbz2
42
43bzip2recover: bzip2recover.o
44	$(CC) $(CFLAGS) $(LDFLAGS) -o bzip2recover bzip2recover.o
45
46libbz2.a: $(OBJS)
47	rm -f libbz2.a
48	$(AR) cq libbz2.a $(OBJS)
49	@if ( test -f $(RANLIB) -o -f /usr/bin/ranlib -o \
50		-f /bin/ranlib -o -f /usr/ccs/bin/ranlib ) ; then \
51		echo $(RANLIB) libbz2.a ; \
52		$(RANLIB) libbz2.a ; \
53	fi
54
55check: test
56test: bzip2
57	@cat words1
58	./bzip2 -1  < sample1.ref > sample1.rb2
59	./bzip2 -2  < sample2.ref > sample2.rb2
60	./bzip2 -3  < sample3.ref > sample3.rb2
61	./bzip2 -d  < sample1.bz2 > sample1.tst
62	./bzip2 -d  < sample2.bz2 > sample2.tst
63	./bzip2 -ds < sample3.bz2 > sample3.tst
64	cmp sample1.bz2 sample1.rb2
65	cmp sample2.bz2 sample2.rb2
66	cmp sample3.bz2 sample3.rb2
67	cmp sample1.tst sample1.ref
68	cmp sample2.tst sample2.ref
69	cmp sample3.tst sample3.ref
70	@cat words3
71
72install: bzip2 bzip2recover
73	if ( test ! -d $(PREFIX)/bin ) ; then mkdir -p $(PREFIX)/bin ; fi
74	if ( test ! -d $(PREFIX)/lib ) ; then mkdir -p $(PREFIX)/lib ; fi
75	if ( test ! -d $(PREFIX)/man ) ; then mkdir -p $(PREFIX)/man ; fi
76	if ( test ! -d $(PREFIX)/man/man1 ) ; then mkdir -p $(PREFIX)/man/man1 ; fi
77	if ( test ! -d $(PREFIX)/include ) ; then mkdir -p $(PREFIX)/include ; fi
78	cp -f bzip2 $(PREFIX)/bin/bzip2
79	cp -f bzip2 $(PREFIX)/bin/bunzip2
80	cp -f bzip2 $(PREFIX)/bin/bzcat
81	cp -f bzip2recover $(PREFIX)/bin/bzip2recover
82	chmod a+x $(PREFIX)/bin/bzip2
83	chmod a+x $(PREFIX)/bin/bunzip2
84	chmod a+x $(PREFIX)/bin/bzcat
85	chmod a+x $(PREFIX)/bin/bzip2recover
86	cp -f bzip2.1 $(PREFIX)/man/man1
87	chmod a+r $(PREFIX)/man/man1/bzip2.1
88	cp -f bzlib.h $(PREFIX)/include
89	chmod a+r $(PREFIX)/include/bzlib.h
90	cp -f libbz2.a $(PREFIX)/lib
91	chmod a+r $(PREFIX)/lib/libbz2.a
92	cp -f bzgrep $(PREFIX)/bin/bzgrep
93	ln -s -f $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzegrep
94	ln -s -f $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzfgrep
95	chmod a+x $(PREFIX)/bin/bzgrep
96	cp -f bzmore $(PREFIX)/bin/bzmore
97	ln -s -f $(PREFIX)/bin/bzmore $(PREFIX)/bin/bzless
98	chmod a+x $(PREFIX)/bin/bzmore
99	cp -f bzdiff $(PREFIX)/bin/bzdiff
100	ln -s -f $(PREFIX)/bin/bzdiff $(PREFIX)/bin/bzcmp
101	chmod a+x $(PREFIX)/bin/bzdiff
102	cp -f bzgrep.1 bzmore.1 bzdiff.1 $(PREFIX)/man/man1
103	chmod a+r $(PREFIX)/man/man1/bzgrep.1
104	chmod a+r $(PREFIX)/man/man1/bzmore.1
105	chmod a+r $(PREFIX)/man/man1/bzdiff.1
106	echo ".so man1/bzgrep.1" > $(PREFIX)/man/man1/bzegrep.1
107	echo ".so man1/bzgrep.1" > $(PREFIX)/man/man1/bzfgrep.1
108	echo ".so man1/bzmore.1" > $(PREFIX)/man/man1/bzless.1
109	echo ".so man1/bzdiff.1" > $(PREFIX)/man/man1/bzcmp.1
110
111clean:
112	rm -f *.o libbz2.a bzip2 bzip2recover \
113	sample1.rb2 sample2.rb2 sample3.rb2 \
114	sample1.tst sample2.tst sample3.tst
115
116blocksort.o: blocksort.c
117	@cat words0
118	$(CC) $(CFLAGS) -c blocksort.c
119huffman.o: huffman.c
120	$(CC) $(CFLAGS) -c huffman.c
121crctable.o: crctable.c
122	$(CC) $(CFLAGS) -c crctable.c
123randtable.o: randtable.c
124	$(CC) $(CFLAGS) -c randtable.c
125compress.o: compress.c
126	$(CC) $(CFLAGS) -c compress.c
127decompress.o: decompress.c
128	$(CC) $(CFLAGS) -c decompress.c
129bzlib.o: bzlib.c
130	$(CC) $(CFLAGS) -c bzlib.c
131bzip2.o: bzip2.c
132	$(CC) $(CFLAGS) -c bzip2.c
133bzip2recover.o: bzip2recover.c
134	$(CC) $(CFLAGS) -c bzip2recover.c
135
136
137distclean: clean
138	rm -f manual.ps manual.html manual.pdf
139
140DISTNAME=bzip2-1.0.6
141dist: check manual
142	rm -f $(DISTNAME)
143	ln -s -f . $(DISTNAME)
144	tar cvf $(DISTNAME).tar \
145	   $(DISTNAME)/blocksort.c \
146	   $(DISTNAME)/huffman.c \
147	   $(DISTNAME)/crctable.c \
148	   $(DISTNAME)/randtable.c \
149	   $(DISTNAME)/compress.c \
150	   $(DISTNAME)/decompress.c \
151	   $(DISTNAME)/bzlib.c \
152	   $(DISTNAME)/bzip2.c \
153	   $(DISTNAME)/bzip2recover.c \
154	   $(DISTNAME)/bzlib.h \
155	   $(DISTNAME)/bzlib_private.h \
156	   $(DISTNAME)/Makefile \
157	   $(DISTNAME)/LICENSE \
158	   $(DISTNAME)/bzip2.1 \
159	   $(DISTNAME)/bzip2.1.preformatted \
160	   $(DISTNAME)/bzip2.txt \
161	   $(DISTNAME)/words0 \
162	   $(DISTNAME)/words1 \
163	   $(DISTNAME)/words2 \
164	   $(DISTNAME)/words3 \
165	   $(DISTNAME)/sample1.ref \
166	   $(DISTNAME)/sample2.ref \
167	   $(DISTNAME)/sample3.ref \
168	   $(DISTNAME)/sample1.bz2 \
169	   $(DISTNAME)/sample2.bz2 \
170	   $(DISTNAME)/sample3.bz2 \
171	   $(DISTNAME)/dlltest.c \
172	   $(DISTNAME)/manual.html \
173	   $(DISTNAME)/manual.pdf \
174	   $(DISTNAME)/manual.ps \
175	   $(DISTNAME)/README \
176	   $(DISTNAME)/README.COMPILATION.PROBLEMS \
177	   $(DISTNAME)/README.XML.STUFF \
178	   $(DISTNAME)/CHANGES \
179	   $(DISTNAME)/libbz2.def \
180	   $(DISTNAME)/libbz2.dsp \
181	   $(DISTNAME)/dlltest.dsp \
182	   $(DISTNAME)/makefile.msc \
183	   $(DISTNAME)/unzcrash.c \
184	   $(DISTNAME)/spewG.c \
185	   $(DISTNAME)/mk251.c \
186	   $(DISTNAME)/bzdiff \
187	   $(DISTNAME)/bzdiff.1 \
188	   $(DISTNAME)/bzmore \
189	   $(DISTNAME)/bzmore.1 \
190	   $(DISTNAME)/bzgrep \
191	   $(DISTNAME)/bzgrep.1 \
192	   $(DISTNAME)/Makefile-libbz2_so \
193	   $(DISTNAME)/bz-common.xsl \
194	   $(DISTNAME)/bz-fo.xsl \
195	   $(DISTNAME)/bz-html.xsl \
196	   $(DISTNAME)/bzip.css \
197	   $(DISTNAME)/entities.xml \
198	   $(DISTNAME)/manual.xml \
199	   $(DISTNAME)/format.pl \
200	   $(DISTNAME)/xmlproc.sh
201	gzip -v $(DISTNAME).tar
202
203# For rebuilding the manual from sources on my SuSE 9.1 box
204
205MANUAL_SRCS= 	bz-common.xsl bz-fo.xsl bz-html.xsl bzip.css \
206		entities.xml manual.xml
207
208manual: manual.html manual.ps manual.pdf
209
210manual.ps: $(MANUAL_SRCS)
211	./xmlproc.sh -ps manual.xml
212
213manual.pdf: $(MANUAL_SRCS)
214	./xmlproc.sh -pdf manual.xml
215
216manual.html: $(MANUAL_SRCS)
217	./xmlproc.sh -html manual.xml
218