1 # ################################################################
3 # Copyright (C) Yann Collet 2012-2015
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.
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.
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.
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 # ################################################################
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
)
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
)
38 MD2ROFF_FLAGS
= --roff
--warnings
--manual
="User Commands" --organization
="xxhsum $(XXHSUM_VERSION)"
40 # Define *.exe as extension for Windows systems
41 ifneq (,$(filter Windows
%,$(OS
)))
51 all: xxhsum xxhsum32 xxhsum_privateXXH
53 xxhsum
: xxhash.c xxhsum.c
54 $(CC
) $(FLAGS
) $^
-o
$@
$(EXT
)
58 xxhsum32
: xxhash.c xxhsum.c
59 $(CC
) -m32
$(FLAGS
) $^
-o
$@
$(EXT
)
61 xxhsum_privateXXH
: xxhsum.c
62 $(CC
) $(FLAGS
) -DXXHSUM_INCLUDE_XXHC
$^
-o
$@
$(EXT
)
72 .
/xxhsum
-bi1 xxhash.c
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
78 test32
: clean xxhsum32
79 @echo
---- test 32-bits
----
80 .
/xxhsum32
-bi1 xxhash.c
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
-
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
104 @
rm -f .
test.xxh32 .
test.xxh64
107 @echo
---- test ARM compilation
----
108 $(MAKE
) xxhsum CC
=arm-linux-gnueabi-gcc MOREFLAGS
="-Werror"
111 @echo
---- test clang compilation
----
112 $(MAKE
) all CC
=clang MOREFLAGS
="-Werror -Wconversion -Wno-sign-conversion"
115 @echo
---- test g
++ compilation
----
116 $(MAKE
) all CC
=g
++ CFLAGS
="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror"
119 @echo
---- check undefined behavior
- sanitize
----
120 $(MAKE
) test CC
=clang MOREFLAGS
="-g -fsanitize=undefined"
123 @echo
---- static analyzer
- scan-build
----
124 CFLAGS
="-g -Werror" scan-build
--status-bugs
-v
$(MAKE
) all
126 xxhsum
.1: xxhsum
.1.md
127 cat
$^ |
$(MD2ROFF
) $(MD2ROFF_FLAGS
) | sed
-n
'/^\.\\\".*/!p' > $@
134 preview-man
: clean-man man
137 test-all
: clean all test test32 test-xxhsum-c clean-xxhsum-c armtest clangtest gpptest sanitize staticAnalyze
139 clean: clean-xxhsum-c
140 @
rm -f core
*.o xxhsum
$(EXT
) xxhsum32
$(EXT
) xxhsum_privateXXH
$(EXT
) xxh32sum xxh64sum
141 @echo cleaning completed