• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# ##########################################################################
2# LZ4 programs - Makefile
3# Copyright (C) Yann Collet 2011-2015
4#
5# GPL v2 License
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2 of the License, or
10# (at your option) any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License along
18# with this program; if not, write to the Free Software Foundation, Inc.,
19# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20#
21# You can contact the author at :
22#  - LZ4 source repository : http://code.google.com/p/lz4/
23#  - LZ4 forum froup : https://groups.google.com/forum/#!forum/lz4c
24# ##########################################################################
25# lz4 : Command Line Utility, supporting gzip-like arguments
26# lz4c  : CLU, supporting also legacy lz4demo arguments
27# lz4c32: Same as lz4c, but forced to compile in 32-bits mode
28# fuzzer  : Test tool, to check lz4 integrity on target platform
29# fuzzer32: Same as fuzzer, but forced to compile in 32-bits mode
30# fullbench  : Precisely measure speed for each LZ4 function variant
31# fullbench32: Same as fullbench, but forced to compile in 32-bits mode
32# ##########################################################################
33
34RELEASE?= r126
35
36DESTDIR?=
37PREFIX ?= /usr
38CFLAGS ?= -O3
39CFLAGS += -std=c99 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -pedantic -DLZ4_VERSION=\"$(RELEASE)\"
40FLAGS   = -I../lib $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
41
42BINDIR=$(PREFIX)/bin
43MANDIR=$(PREFIX)/share/man/man1
44LZ4DIR=../lib
45
46TEST_FILES = COPYING
47TEST_TARGETS=test-native
48
49
50# Define *.exe as extension for Windows systems
51ifneq (,$(filter Windows%,$(OS)))
52EXT =.exe
53VOID = nul
54else
55EXT =
56VOID = /dev/null
57endif
58
59
60# Select test target for Travis CI's Build Matrix
61TRAVIS_TARGET=$(LZ4_TRAVIS_CI_ENV)
62
63
64default: lz4 lz4c
65
66all: lz4 lz4c lz4c32 fullbench fullbench32 fuzzer fuzzer32 frametest frametest32 datagen
67
68lz4: $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4frame.c $(LZ4DIR)/xxhash.c bench.c lz4io.c lz4cli.c
69	$(CC)      $(FLAGS) $^ -o $@$(EXT)
70
71lz4c  : $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4frame.c $(LZ4DIR)/xxhash.c bench.c lz4io.c lz4cli.c
72	$(CC)      $(FLAGS) -DENABLE_LZ4C_LEGACY_OPTIONS $^ -o $@$(EXT)
73
74lz4c32: $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4frame.c $(LZ4DIR)/xxhash.c bench.c lz4io.c lz4cli.c
75	$(CC) -m32 $(FLAGS) -DENABLE_LZ4C_LEGACY_OPTIONS $^ -o $@$(EXT)
76
77fullbench  : $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4frame.c $(LZ4DIR)/xxhash.c fullbench.c
78	$(CC)      $(FLAGS) $^ -o $@$(EXT)
79
80fullbench32: $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4frame.c $(LZ4DIR)/xxhash.c fullbench.c
81	$(CC) -m32 $(FLAGS) $^ -o $@$(EXT)
82
83fuzzer  : $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/xxhash.c fuzzer.c
84	$(CC)      $(FLAGS) $^ -o $@$(EXT)
85
86fuzzer32: $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/xxhash.c fuzzer.c
87	$(CC) -m32 $(FLAGS) $^ -o $@$(EXT)
88
89frametest: $(LZ4DIR)/lz4frame.c $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/xxhash.c frametest.c
90	$(CC)      $(FLAGS) $^ -o $@$(EXT)
91
92frametest32: $(LZ4DIR)/lz4frame.c $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4hc.c $(LZ4DIR)/xxhash.c frametest.c
93	$(CC) -m32 $(FLAGS) $^ -o $@$(EXT)
94
95datagen : datagen.c
96	$(CC)      $(FLAGS) $^ -o $@$(EXT)
97
98
99clean:
100	@rm -f core *.o *.test \
101        lz4$(EXT) lz4c$(EXT) lz4c32$(EXT) \
102        fullbench$(EXT) fullbench32$(EXT) \
103        fuzzer$(EXT) fuzzer32$(EXT) \
104        frametest$(EXT) frametest32$(EXT) \
105        datagen$(EXT)
106	@echo Cleaning completed
107
108
109#------------------------------------------------------------------------
110#make install is validated only for Linux, OSX, kFreeBSD and Hurd targets
111ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU))
112
113install: lz4 lz4c
114	@echo Installing binaries
115	@install -d -m 755 $(DESTDIR)$(BINDIR)/ $(DESTDIR)$(MANDIR)/
116	@install -m 755 lz4$(EXT) $(DESTDIR)$(BINDIR)/lz4$(EXT)
117	@ln -sf lz4$(EXT) $(DESTDIR)$(BINDIR)/lz4cat
118	@install -m 755 lz4c$(EXT) $(DESTDIR)$(BINDIR)/lz4c$(EXT)
119	@echo Installing man pages
120	@install -m 644 lz4.1 $(DESTDIR)$(MANDIR)/lz4.1
121	@install -m 644 lz4c.1 $(DESTDIR)$(MANDIR)/lz4c.1
122	@install -m 644 lz4cat.1 $(DESTDIR)$(MANDIR)/lz4cat.1
123	@echo lz4 installation completed
124
125uninstall:
126	rm -f $(DESTDIR)$(BINDIR)/lz4cat
127	[ -x $(DESTDIR)$(BINDIR)/lz4$(EXT) ] && rm -f $(DESTDIR)$(BINDIR)/lz4$(EXT)
128	[ -x $(DESTDIR)$(BINDIR)/lz4c$(EXT) ] && rm -f $(DESTDIR)$(BINDIR)/lz4c$(EXT)
129	[ -f $(DESTDIR)$(MANDIR)/lz4.1 ] && rm -f $(DESTDIR)$(MANDIR)/lz4.1
130	[ -f $(DESTDIR)$(MANDIR)/lz4c.1 ] && rm -f $(DESTDIR)$(MANDIR)/lz4c.1
131	[ -f $(DESTDIR)$(MANDIR)/lz4cat.1 ] && rm -f $(DESTDIR)$(MANDIR)/lz4cat.1
132	@echo lz4 programs successfully uninstalled
133
134test: test-lz4 test-lz4c test-frametest test-fullbench test-fuzzer test-mem
135
136test32: test-lz4c32 test-frametest32 test-fullbench32 test-fuzzer32 test-mem32
137
138test-all: test test32
139
140test-travis: $(TRAVIS_TARGET)
141
142test-lz4: lz4 datagen
143	./datagen -g16KB  | ./lz4 -9     | ./lz4 -vdq > $(VOID)
144	./datagen         | ./lz4        | ./lz4 -vdq > $(VOID)
145	./datagen -g6M -p100 | ./lz4 -9BD | ./lz4 -vdq > $(VOID)
146	./datagen -g256MB | ./lz4 -vqB4D | ./lz4 -vdq > $(VOID)
147	./datagen -g6GB   | ./lz4 -vqB5D | ./lz4 -vdq > $(VOID)
148# test frame concatenation with null-length frame
149	@echo -n > empty.test
150	@echo hi > nonempty.test
151	cat nonempty.test empty.test nonempty.test > orig.test
152	@./lz4 -zq empty.test > empty.lz4.test
153	@./lz4 -zq nonempty.test > nonempty.lz4.test
154	cat nonempty.lz4.test empty.lz4.test nonempty.lz4.test > concat.lz4.test
155	./lz4 -d concat.lz4.test > result.test
156	sdiff orig.test result.test
157	@rm *.test
158	@echo frame concatenation test completed
159# test frame concatenation with null-length frame
160
161
162test-lz4c: lz4c datagen
163	./datagen -g256MB | ./lz4c -l -v    | ./lz4c   -vdq > $(VOID)
164
165test-lz4c32: lz4 lz4c32 lz4 datagen
166	./datagen -g16KB  | ./lz4c32 -9     | ./lz4c32 -vdq > $(VOID)
167	./datagen -g16KB  | ./lz4c32 -9     | ./lz4    -vdq > $(VOID)
168	./datagen         | ./lz4c32        | ./lz4c32 -vdq > $(VOID)
169	./datagen         | ./lz4c32        | ./lz4    -vdq > $(VOID)
170	./datagen -g256MB | ./lz4c32 -vqB4D | ./lz4c32 -vdq > $(VOID)
171	./datagen -g256MB | ./lz4c32 -vqB4D | ./lz4    -vdq > $(VOID)
172	./datagen -g6GB   | ./lz4c32 -vqB5D | ./lz4c32 -vdq > $(VOID)
173
174test-fullbench: fullbench
175	./fullbench --no-prompt $(TEST_FILES)
176
177test-fullbench32: fullbench32
178	./fullbench32 --no-prompt $(TEST_FILES)
179
180test-fuzzer: fuzzer
181	./fuzzer
182
183test-fuzzer32: fuzzer32
184	./fuzzer32
185
186test-frametest: frametest
187	./frametest
188
189test-frametest32: frametest32
190	./frametest32
191
192test-mem: lz4 datagen fuzzer frametest
193	./datagen -g16KB > tmp
194	valgrind --leak-check=yes ./lz4 -9 -BD -f tmp /dev/null
195	./datagen -g16MB > tmp
196	valgrind --leak-check=yes ./lz4 -9 -B5D -f tmp /dev/null
197	./datagen -g256MB > tmp
198	valgrind --leak-check=yes ./lz4 -B4D -f -vq tmp /dev/null
199	rm tmp
200	valgrind --leak-check=yes ./fuzzer -i64 -t1
201	valgrind --leak-check=yes ./frametest -i256
202
203test-mem32: lz4c32 datagen
204# unfortunately, valgrind doesn't seem to work with non-native binary. If someone knows how to do a valgrind-test on a 32-bits exe with a 64-bits system...
205
206endif
207