]> git.proxmox.com Git - ceph.git/blob - ceph/src/xxHash/Makefile
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / xxHash / Makefile
1 # ################################################################
2 # xxHash Makefile
3 # Copyright (C) Yann Collet 2012-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 # - xxHash source repository : http://code.google.com/p/xxhash/
23 # ################################################################
24 # xxhsum : provides 32/64 bits hash of one or multiple files, or stdin
25 # ################################################################
26
27 # Version numbers
28 LIBVER_MAJOR:=`sed -n '/define XXH_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < xxhash.h`
29 LIBVER_MINOR:=`sed -n '/define XXH_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < xxhash.h`
30 LIBVER_PATCH:=`sed -n '/define XXH_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < xxhash.h`
31 LIBVER := $(LIBVER_MAJOR).$(LIBVER_MINOR).$(LIBVER_PATCH)
32
33 CFLAGS ?= -O3
34 CFLAGS += -std=c99 -Wall -Wextra -Wshadow -Wcast-qual -Wcast-align -Wstrict-prototypes -Wstrict-aliasing=1 -Wswitch-enum -Wundef -pedantic
35 FLAGS := $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(MOREFLAGS)
36 XXHSUM_VERSION=$(LIBVER)
37 MD2ROFF =ronn
38 MD2ROFF_FLAGS = --roff --warnings --manual="User Commands" --organization="xxhsum $(XXHSUM_VERSION)"
39
40 # Define *.exe as extension for Windows systems
41 ifneq (,$(filter Windows%,$(OS)))
42 EXT =.exe
43 else
44 EXT =
45 endif
46
47 .PHONY: clean all
48
49 default: xxhsum
50
51 all: xxhsum xxhsum32 xxhsum_privateXXH
52
53 xxhsum: xxhash.c xxhsum.c
54 $(CC) $(FLAGS) $^ -o $@$(EXT)
55 ln -sf $@ xxh32sum
56 ln -sf $@ xxh64sum
57
58 xxhsum32: xxhash.c xxhsum.c
59 $(CC) -m32 $(FLAGS) $^ -o $@$(EXT)
60
61 xxhsum_privateXXH: xxhsum.c
62 $(CC) $(FLAGS) -DXXHSUM_INCLUDE_XXHC $^ -o $@$(EXT)
63
64 test: clean xxhsum
65 # stdin
66 ./xxhsum < xxhash.c
67 # multiple files
68 ./xxhsum *
69 # internal bench
70 ./xxhsum -bi1
71 # file bench
72 ./xxhsum -bi1 xxhash.c
73 # memory tests
74 valgrind --leak-check=yes --error-exitcode=1 ./xxhsum -bi1 xxhash.c
75 valgrind --leak-check=yes --error-exitcode=1 ./xxhsum -H0 xxhash.c
76 valgrind --leak-check=yes --error-exitcode=1 ./xxhsum -H1 xxhash.c
77
78 test32: clean xxhsum32
79 @echo ---- test 32-bits ----
80 ./xxhsum32 -bi1 xxhash.c
81
82 test-xxhsum-c: xxhsum
83 # xxhsum to/from pipe
84 ./xxhsum * | ./xxhsum -c -
85 ./xxhsum -H0 * | ./xxhsum -c -
86 # xxhsum to/from file, shell redirection
87 ./xxhsum * > .test.xxh64
88 ./xxhsum -H0 * > .test.xxh32
89 ./xxhsum -c .test.xxh64
90 ./xxhsum -c .test.xxh32
91 ./xxhsum -c < .test.xxh64
92 ./xxhsum -c < .test.xxh32
93 # xxhsum -c warns improperly format lines.
94 cat .test.xxh64 .test.xxh32 | ./xxhsum -c -
95 cat .test.xxh32 .test.xxh64 | ./xxhsum -c -
96 # Expects "FAILED"
97 echo "0000000000000000 LICENSE" | ./xxhsum -c -; test $$? -eq 1
98 echo "00000000 LICENSE" | ./xxhsum -c -; test $$? -eq 1
99 # Expects "FAILED open or read"
100 echo "0000000000000000 test-expects-file-not-found" | ./xxhsum -c -; test $$? -eq 1
101 echo "00000000 test-expects-file-not-found" | ./xxhsum -c -; test $$? -eq 1
102
103 clean-xxhsum-c:
104 @rm -f .test.xxh32 .test.xxh64
105
106 armtest: clean
107 @echo ---- test ARM compilation ----
108 $(MAKE) xxhsum CC=arm-linux-gnueabi-gcc MOREFLAGS="-Werror"
109
110 clangtest: clean
111 @echo ---- test clang compilation ----
112 $(MAKE) all CC=clang MOREFLAGS="-Werror -Wconversion -Wno-sign-conversion"
113
114 gpptest: clean
115 @echo ---- test g++ compilation ----
116 $(MAKE) all CC=g++ CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror"
117
118 sanitize: clean
119 @echo ---- check undefined behavior - sanitize ----
120 $(MAKE) test CC=clang MOREFLAGS="-g -fsanitize=undefined"
121
122 staticAnalyze: clean
123 @echo ---- static analyzer - scan-build ----
124 CFLAGS="-g -Werror" scan-build --status-bugs -v $(MAKE) all
125
126 xxhsum.1: xxhsum.1.md
127 cat $^ | $(MD2ROFF) $(MD2ROFF_FLAGS) | sed -n '/^\.\\\".*/!p' > $@
128
129 man: xxhsum.1
130
131 clean-man:
132 rm xxhsum.1
133
134 preview-man: clean-man man
135 man ./xxhsum.1
136
137 test-all: clean all test test32 test-xxhsum-c clean-xxhsum-c armtest clangtest gpptest sanitize staticAnalyze
138
139 clean: clean-xxhsum-c
140 @rm -f core *.o xxhsum$(EXT) xxhsum32$(EXT) xxhsum_privateXXH$(EXT) xxh32sum xxh64sum
141 @echo cleaning completed
142
143