Makefile 3.56 KB
Newer Older
1 2
CC=gcc
CFLAGS=-O3 -Wall -Wextra -Wno-unknown-pragmas
3 4
LDFLAGS=
LIBS=-lm -lpthread -lz
5
ZOPFLI=zopfli/src/zopfli/
6 7
ZOP=deflate.o blocksplitter.o tree.o lz77.o cache.o hash.o util.o squeeze.o katajainen.o

8
# use gcc and gmake on Solaris
9

10 11
pigz: pigz.o yarn.o try.o $(ZOP)
	$(CC) $(LDFLAGS) -o pigz pigz.o yarn.o try.o $(ZOP) $(LIBS)
Mark Adler's avatar
Mark Adler committed
12
	ln -f pigz unpigz
Mark Adler's avatar
Mark Adler committed
13

14
pigz.o: pigz.c yarn.h try.h $(ZOPFLI)deflate.h $(ZOPFLI)util.h
Mark Adler's avatar
Mark Adler committed
15 16 17

yarn.o: yarn.c yarn.h

18 19
try.o: try.c try.h

20 21
deflate.o: $(ZOPFLI)deflate.c $(ZOPFLI)deflate.h $(ZOPFLI)blocksplitter.h $(ZOPFLI)lz77.h $(ZOPFLI)squeeze.h $(ZOPFLI)tree.h $(ZOPFLI)zopfli.h $(ZOPFLI)cache.h $(ZOPFLI)hash.h $(ZOPFLI)util.h
	$(CC) $(CFLAGS) -c $(ZOPFLI)deflate.c
22

23 24
blocksplitter.o: $(ZOPFLI)blocksplitter.c $(ZOPFLI)blocksplitter.h $(ZOPFLI)deflate.h $(ZOPFLI)lz77.h $(ZOPFLI)squeeze.h $(ZOPFLI)tree.h $(ZOPFLI)util.h $(ZOPFLI)zopfli.h $(ZOPFLI)cache.h $(ZOPFLI)hash.h
	$(CC) $(CFLAGS) -c $(ZOPFLI)blocksplitter.c
25

26 27
tree.o: $(ZOPFLI)tree.c $(ZOPFLI)tree.h $(ZOPFLI)katajainen.h $(ZOPFLI)util.h
	$(CC) $(CFLAGS) -c $(ZOPFLI)tree.c
28

29 30
lz77.o: $(ZOPFLI)lz77.c $(ZOPFLI)lz77.h $(ZOPFLI)util.h $(ZOPFLI)cache.h $(ZOPFLI)hash.h $(ZOPFLI)zopfli.h
	$(CC) $(CFLAGS) -c $(ZOPFLI)lz77.c
31

32 33
cache.o: $(ZOPFLI)cache.c $(ZOPFLI)cache.h $(ZOPFLI)util.h
	$(CC) $(CFLAGS) -c $(ZOPFLI)cache.c
34

35 36
hash.o: $(ZOPFLI)hash.c $(ZOPFLI)hash.h $(ZOPFLI)util.h
	$(CC) $(CFLAGS) -c $(ZOPFLI)hash.c
37

38 39
util.o: $(ZOPFLI)util.c $(ZOPFLI)util.h
	$(CC) $(CFLAGS) -c $(ZOPFLI)util.c
40

41 42
squeeze.o: $(ZOPFLI)squeeze.c $(ZOPFLI)squeeze.h $(ZOPFLI)blocksplitter.h $(ZOPFLI)deflate.h $(ZOPFLI)tree.h $(ZOPFLI)util.h $(ZOPFLI)zopfli.h $(ZOPFLI)lz77.h $(ZOPFLI)cache.h $(ZOPFLI)hash.h
	$(CC) $(CFLAGS) -c $(ZOPFLI)squeeze.c
43

44 45
katajainen.o: $(ZOPFLI)katajainen.c $(ZOPFLI)katajainen.h
	$(CC) $(CFLAGS) -c $(ZOPFLI)katajainen.c
46

47 48 49
dev: pigz pigzj pigzt pigzn

pigzj: pigzj.o yarn.o try.o
50
	$(CC) $(LDFLAGS) -o pigzj pigzj.o yarn.o try.o $(LIBS)
51 52 53

pigzj.o: pigz.c yarn.h try.h
	$(CC) $(CFLAGS) -DNOZOPFLI -c -o pigzj.o pigz.c
Mark Adler's avatar
Mark Adler committed
54

55 56
pigzt: pigzt.o yarnt.o try.o $(ZOP)
	$(CC) $(LDFLAGS) -o pigzt pigzt.o yarnt.o try.o $(ZOP) $(LIBS)
Mark Adler's avatar
Mark Adler committed
57

58
pigzt.o: pigz.c yarn.h try.h
59
	$(CC) $(CFLAGS) -DDEBUG -g -c -o pigzt.o pigz.c
Mark Adler's avatar
Mark Adler committed
60 61

yarnt.o: yarn.c yarn.h
62
	$(CC) $(CFLAGS) -DDEBUG -g -c -o yarnt.o yarn.c
Mark Adler's avatar
Mark Adler committed
63

64 65
pigzn: pigzn.o tryn.o $(ZOP)
	$(CC) $(LDFLAGS) -o pigzn pigzn.o tryn.o $(ZOP) $(LIBS)
Mark Adler's avatar
Mark Adler committed
66

67
pigzn.o: pigz.c try.h
68
	$(CC) $(CFLAGS) -DDEBUG -DNOTHREAD -g -c -o pigzn.o pigz.c
Mark Adler's avatar
Mark Adler committed
69

70 71 72
tryn.o: try.c try.h
	$(CC) $(CFLAGS) -DDEBUG -DNOTHREAD -g -c -o tryn.o try.c

Mark Adler's avatar
Mark Adler committed
73 74 75 76 77 78
test: pigz
	./pigz -kf pigz.c ; ./pigz -t pigz.c.gz
	./pigz -kfb 32 pigz.c ; ./pigz -t pigz.c.gz
	./pigz -kfp 1 pigz.c ; ./pigz -t pigz.c.gz
	./pigz -kfz pigz.c ; ./pigz -t pigz.c.zz
	./pigz -kfK pigz.c ; ./pigz -t pigz.c.zip
79 80 81 82 83 84 85
	printf "" | ./pigz -cdf | wc -c | test `cat` -eq 0
	printf "x" | ./pigz -cdf | wc -c | test `cat` -eq 1
	printf "xy" | ./pigz -cdf | wc -c | test `cat` -eq 2
	printf "xyz" | ./pigz -cdf | wc -c | test `cat` -eq 3
	(printf "w" | gzip ; printf "x") | ./pigz -cdf | wc -c | test `cat` -eq 2
	(printf "w" | gzip ; printf "xy") | ./pigz -cdf | wc -c | test `cat` -eq 3
	(printf "w" | gzip ; printf "xyz") | ./pigz -cdf | wc -c | test `cat` -eq 4
86
	-@if test "`which compress | grep /`" != ""; then \
87 88 89 90
	  echo 'compress -f < pigz.c | ./unpigz | cmp - pigz.c' ;\
	  compress -f < pigz.c | ./unpigz | cmp - pigz.c ;\
	fi
	@rm -f pigz.c.gz pigz.c.zz pigz.c.zip
Mark Adler's avatar
Mark Adler committed
91 92 93

tests: dev test
	./pigzn -kf pigz.c ; ./pigz -t pigz.c.gz
94
	@rm -f pigz.c.gz
Mark Adler's avatar
Mark Adler committed
95

Mark Adler's avatar
Mark Adler committed
96 97 98 99 100
docs: pigz.pdf

pigz.pdf: pigz.1
	groff -mandoc -f H -T ps pigz.1 | ps2pdf - pigz.pdf

101 102
all: pigz pigzj pigzt pigzn docs

Mark Adler's avatar
Mark Adler committed
103
clean:
104
	@rm -f *.o pigz unpigz pigzj pigzn pigzt pigz.c.gz pigz.c.zz pigz.c.zip