blob: 84a77894f5aae7e6e713049018dc637eb3b5cc4e [file] [log] [blame]
Yann Collet4856a002015-01-24 01:58:16 +01001# ##########################################################################
2# ZSTD programs - Makefile
3# Copyright (C) Yann Collet 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# - ZSTD source repository : http://code.google.com/p/zstd/
23# - Public forum : https://groups.google.com/forum/#!forum/lz4c
24# ##########################################################################
25# zstd : Command Line Utility, supporting gzip-like arguments
26# datagen : Synthetic and parametrable data generator, for tests
27# fuzzer : Test tool, to check zstd integrity on target platform
28# fuzzer32: Same as fuzzer, but forced to compile in 32-bits mode
29# fullbench : Precisely measure speed for each zstd inner function
30# fullbench32: Same as fullbench, but forced to compile in 32-bits mode
31# ##########################################################################
32
Yann Collet6610cb32015-02-09 08:00:26 +010033RELEASE?= r1
Yann Collet4856a002015-01-24 01:58:16 +010034
35DESTDIR?=
36PREFIX ?= /usr
37CFLAGS ?= -O3
38CFLAGS += -std=c99 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wstrict-prototypes -DZSTD_VERSION=\"$(RELEASE)\"
39FLAGS = -I../lib $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
40
41BINDIR=$(PREFIX)/bin
42MANDIR=$(PREFIX)/share/man/man1
43ZSTDDIR=../lib
44
45TEST_FILES = COPYING
46TEST_TARGETS=test-native
47
48
49# Define *.exe as extension for Windows systems
50ifneq (,$(filter Windows%,$(OS)))
51EXT =.exe
52VOID = nul
53else
54EXT =
55VOID = /dev/null
56endif
57
58
59default: zstd
60
61all: zstd zstd32 fullbench fullbench32 fuzzer fuzzer32
62
63zstd: $(ZSTDDIR)/zstd.c xxhash.c bench.c fileio.c zstdcli.c
64 $(CC) $(FLAGS) $^ -o $@$(EXT)
65
66zstd32: $(ZSTDDIR)/zstd.c xxhash.c bench.c fileio.c zstdcli.c
67 $(CC) -m32 $(FLAGS) $^ -o $@$(EXT)
68
Yann Colletf9678062015-02-11 08:19:57 +010069fullbench : $(ZSTDDIR)/zstd.c datagen.c fullbench.c
Yann Collet4856a002015-01-24 01:58:16 +010070 $(CC) $(FLAGS) $^ -o $@$(EXT)
71
Yann Colletf9678062015-02-11 08:19:57 +010072fullbench32: $(ZSTDDIR)/zstd.c datagen.c fullbench.c
Yann Collet4856a002015-01-24 01:58:16 +010073 $(CC) -m32 $(FLAGS) $^ -o $@$(EXT)
74
75fuzzer : $(ZSTDDIR)/zstd.c xxhash.c fuzzer.c
76 $(CC) $(FLAGS) $^ -o $@$(EXT)
77
78fuzzer32: $(ZSTDDIR)/zstd.c xxhash.c fuzzer.c
79 $(CC) -m32 $(FLAGS) $^ -o $@$(EXT)
80
Yann Collet6610cb32015-02-09 08:00:26 +010081datagen : datagen.c datagencli.c
Yann Collet4856a002015-01-24 01:58:16 +010082 $(CC) $(FLAGS) $^ -o $@$(EXT)
83
84clean:
85 @rm -f core *.o tmp \
86 zstd$(EXT) zstd32$(EXT) \
87 fullbench$(EXT) fullbench32$(EXT) \
88 fuzzer$(EXT) fuzzer32$(EXT) \
89 datagen$(EXT)
90 @echo Cleaning completed
91
92
93#------------------------------------------------------------------------
94#make install is validated only for Linux, OSX, kFreeBSD and Hurd targets
95ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU))
96
97install: zstd
98 @echo Installing binaries
99 @install -d -m 755 $(DESTDIR)$(BINDIR)/ $(DESTDIR)$(MANDIR)/
100 @install -m 755 zstd$(EXT) $(DESTDIR)$(BINDIR)/zstd$(EXT)
101 @ln -sf zstd$(EXT) $(DESTDIR)$(BINDIR)/zstdcat
Johan Förberg273d0492015-03-24 20:15:56 +0100102 @ln -sf zstd$(EXT) $(DESTDIR)$(BINDIR)/unzstd
Yann Collet4856a002015-01-24 01:58:16 +0100103 @echo Installing man pages
104 @install -m 644 zstd.1 $(DESTDIR)$(MANDIR)/zstd.1
105 @install -m 644 zstdcat.1 $(DESTDIR)$(MANDIR)/zstdcat.1
Johan Förberg273d0492015-03-24 20:15:56 +0100106 @install -m 644 unzstd.1 $(DESTDIR)$(MANDIR)/unzstd.1
Yann Collet4856a002015-01-24 01:58:16 +0100107 @echo zstd installation completed
108
109uninstall:
110 rm -f $(DESTDIR)$(BINDIR)/zstdcat
Johan Förberg273d0492015-03-24 20:15:56 +0100111 rm -f $(DESTDIR)$(BINDIR)/unzstd
Yann Collet4856a002015-01-24 01:58:16 +0100112 [ -x $(DESTDIR)$(BINDIR)/zstd$(EXT) ] && rm -f $(DESTDIR)$(BINDIR)/zstd$(EXT)
113 [ -f $(DESTDIR)$(MANDIR)/zstd.1 ] && rm -f $(DESTDIR)$(MANDIR)/zstd.1
114 [ -f $(DESTDIR)$(MANDIR)/zstdcat.1 ] && rm -f $(DESTDIR)$(MANDIR)/zstdcat.1
Johan Förberg273d0492015-03-24 20:15:56 +0100115 [ -f $(DESTDIR)$(MANDIR)/unzstd.1 ] && rm -f $(DESTDIR)$(MANDIR)/unzstd.1
Yann Collet4856a002015-01-24 01:58:16 +0100116 @echo zstd programs successfully uninstalled
117
118test: test-zstd test-fullbench test-fuzzer test-mem
119
120test32: test-zstd32 test-fullbench32 test-fuzzer32
121
122test-all: test test32
123
124test-zstd: zstd datagen
125 ./datagen | ./zstd -v | ./zstd -d > $(VOID)
126 ./datagen -g256MB | ./zstd -v | ./zstd -d > $(VOID)
127 ./datagen -g6GB | ./zstd -vq | ./zstd -d > $(VOID)
128
129test-zstd32: zstd32 datagen
130 ./datagen | ./zstd32 -v | ./zstd32 -d > $(VOID)
131 ./datagen -g256MB | ./zstd32 -v | ./zstd32 -d > $(VOID)
132 ./datagen -g6GB | ./zstd32 -vq | ./zstd32 -d > $(VOID)
133
Yann Collet759433d2015-01-24 13:31:55 +0100134test-fullbench: fullbench datagen
Yann Collet4856a002015-01-24 01:58:16 +0100135 ./fullbench -i1
Yann Colletf66d2ba2015-02-11 08:34:50 +0100136 ./fullbench -i1 -P0
Yann Collet4856a002015-01-24 01:58:16 +0100137
Yann Collet759433d2015-01-24 13:31:55 +0100138test-fullbench32: fullbench32 datagen
Yann Collet4856a002015-01-24 01:58:16 +0100139 ./fullbench32 -i1
Yann Colletf66d2ba2015-02-11 08:34:50 +0100140 ./fullbench32 -i1 -P0
Yann Collet4856a002015-01-24 01:58:16 +0100141
142test-fuzzer: fuzzer
143 ./fuzzer
144
145test-fuzzer32: fuzzer32
146 ./fuzzer32
147
148test-mem: zstd datagen fuzzer fullbench
Yann Collet1d629142015-03-09 13:48:34 +0100149 valgrind --leak-check=yes ./datagen -g50M > /dev/null
Yann Collet4856a002015-01-24 01:58:16 +0100150 ./datagen -g16KB > tmp
151 valgrind --leak-check=yes ./zstd -vf tmp /dev/null
152 ./datagen -g128MB > tmp
153 valgrind --leak-check=yes ./zstd -vf tmp /dev/null
Yann Collet6434adc2015-01-29 07:00:43 +0100154 @rm tmp
Yann Collet4856a002015-01-24 01:58:16 +0100155 valgrind --leak-check=yes ./fuzzer -i128 -t1
156 valgrind --leak-check=yes ./fullbench -i1
157
158endif