2013-12-05 22:47:05 +00:00
|
|
|
# ################################################################
|
|
|
|
# xxHash Makefile
|
2020-03-09 01:28:43 +00:00
|
|
|
# Copyright (C) 2012-2020 Yann Collet
|
2015-05-04 21:56:53 +00:00
|
|
|
#
|
2013-12-05 22:47:05 +00:00
|
|
|
# GPL v2 License
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
#
|
2020-03-02 22:26:49 +00:00
|
|
|
# You can contact the author at:
|
2020-03-05 02:36:13 +00:00
|
|
|
# - xxHash homepage: https://www.xxhash.com
|
2020-03-02 22:26:49 +00:00
|
|
|
# - xxHash source repository: https://github.com/Cyan4973/xxHash
|
2013-12-05 22:47:05 +00:00
|
|
|
# ################################################################
|
2020-03-03 17:10:19 +00:00
|
|
|
# xxhsum: provides 32/64 bits hash of one or multiple files, or stdin
|
2013-12-05 22:47:05 +00:00
|
|
|
# ################################################################
|
|
|
|
|
2016-02-21 14:10:20 +00:00
|
|
|
# Version numbers
|
2017-09-14 16:44:34 +00:00
|
|
|
LIBVER_MAJOR_SCRIPT:=`sed -n '/define XXH_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < xxhash.h`
|
|
|
|
LIBVER_MINOR_SCRIPT:=`sed -n '/define XXH_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < xxhash.h`
|
|
|
|
LIBVER_PATCH_SCRIPT:=`sed -n '/define XXH_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < xxhash.h`
|
|
|
|
LIBVER_MAJOR := $(shell echo $(LIBVER_MAJOR_SCRIPT))
|
|
|
|
LIBVER_MINOR := $(shell echo $(LIBVER_MINOR_SCRIPT))
|
|
|
|
LIBVER_PATCH := $(shell echo $(LIBVER_PATCH_SCRIPT))
|
2016-02-21 14:10:20 +00:00
|
|
|
LIBVER := $(LIBVER_MAJOR).$(LIBVER_MINOR).$(LIBVER_PATCH)
|
|
|
|
|
2019-03-07 22:29:26 +00:00
|
|
|
CFLAGS ?= -O3
|
2019-02-26 21:45:56 +00:00
|
|
|
DEBUGFLAGS+=-Wall -Wextra -Wconversion -Wcast-qual -Wcast-align -Wshadow \
|
2018-09-17 18:17:41 +00:00
|
|
|
-Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \
|
|
|
|
-Wstrict-prototypes -Wundef -Wpointer-arith -Wformat-security \
|
|
|
|
-Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \
|
2019-10-07 17:56:02 +00:00
|
|
|
-Wredundant-decls -Wstrict-overflow=2
|
2020-06-09 21:10:13 +00:00
|
|
|
CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)
|
|
|
|
FLAGS = $(CFLAGS) $(CPPFLAGS)
|
2018-09-17 18:17:41 +00:00
|
|
|
XXHSUM_VERSION = $(LIBVER)
|
2013-05-11 11:22:55 +00:00
|
|
|
|
2014-09-25 20:22:59 +00:00
|
|
|
# Define *.exe as extension for Windows systems
|
|
|
|
ifneq (,$(filter Windows%,$(OS)))
|
2013-05-11 11:22:55 +00:00
|
|
|
EXT =.exe
|
2014-07-10 20:44:08 +00:00
|
|
|
else
|
2014-09-25 20:22:59 +00:00
|
|
|
EXT =
|
2014-07-10 20:44:08 +00:00
|
|
|
endif
|
|
|
|
|
2017-09-14 16:44:34 +00:00
|
|
|
# OS X linker doesn't support -soname, and use different extension
|
2020-03-03 17:10:19 +00:00
|
|
|
# see: https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html
|
2017-09-14 16:44:34 +00:00
|
|
|
ifeq ($(shell uname), Darwin)
|
|
|
|
SHARED_EXT = dylib
|
|
|
|
SHARED_EXT_MAJOR = $(LIBVER_MAJOR).$(SHARED_EXT)
|
|
|
|
SHARED_EXT_VER = $(LIBVER).$(SHARED_EXT)
|
|
|
|
SONAME_FLAGS = -install_name $(LIBDIR)/libxxhash.$(SHARED_EXT_MAJOR) -compatibility_version $(LIBVER_MAJOR) -current_version $(LIBVER)
|
|
|
|
else
|
|
|
|
SONAME_FLAGS = -Wl,-soname=libxxhash.$(SHARED_EXT).$(LIBVER_MAJOR)
|
|
|
|
SHARED_EXT = so
|
|
|
|
SHARED_EXT_MAJOR = $(SHARED_EXT).$(LIBVER_MAJOR)
|
|
|
|
SHARED_EXT_VER = $(SHARED_EXT).$(LIBVER)
|
|
|
|
endif
|
|
|
|
|
|
|
|
LIBXXH = libxxhash.$(SHARED_EXT_VER)
|
|
|
|
|
|
|
|
|
2020-06-10 18:36:58 +00:00
|
|
|
## generate CLI and libraries in release mode (default for `make`)
|
2017-09-08 08:24:43 +00:00
|
|
|
.PHONY: default
|
2018-09-17 18:17:41 +00:00
|
|
|
default: DEBUGFLAGS=
|
2017-12-29 10:15:37 +00:00
|
|
|
default: lib xxhsum_and_links
|
2013-05-11 11:22:55 +00:00
|
|
|
|
2017-09-08 08:24:43 +00:00
|
|
|
.PHONY: all
|
2020-06-10 19:12:24 +00:00
|
|
|
all: lib xxhsum xxhsum_inlinedXXH
|
2013-05-11 11:22:55 +00:00
|
|
|
|
2020-06-10 18:36:58 +00:00
|
|
|
## xxhsum is the command line interface (CLI)
|
2020-06-11 07:13:06 +00:00
|
|
|
ifeq ($(DISPATCH),1)
|
|
|
|
xxhsum: CPPFLAGS += -DXXHSUM_DISPATCH=1
|
|
|
|
xxhsum: xxh_x86dispatch.o
|
|
|
|
endif
|
2020-06-10 18:36:58 +00:00
|
|
|
xxhsum: xxhash.o xxhsum.o
|
2020-02-13 01:37:34 +00:00
|
|
|
$(CC) $(FLAGS) $^ $(LDFLAGS) -o $@$(EXT)
|
2018-09-30 06:54:24 +00:00
|
|
|
|
2020-02-13 01:46:50 +00:00
|
|
|
xxhsum32: CFLAGS += -m32 ## generate CLI in 32-bits mode
|
|
|
|
xxhsum32: xxhash.c xxhsum.c ## do not generate object (avoid mixing different ABI)
|
2018-09-17 18:17:41 +00:00
|
|
|
$(CC) $(FLAGS) $^ $(LDFLAGS) -o $@$(EXT)
|
2017-12-29 10:15:37 +00:00
|
|
|
|
2020-06-10 19:12:24 +00:00
|
|
|
## dispatch only works for x86/x64 systems
|
2020-06-09 06:15:08 +00:00
|
|
|
dispatch: CPPFLAGS += -DXXHSUM_DISPATCH=1
|
|
|
|
dispatch: xxhash.o xxh_x86dispatch.o xxhsum.c
|
|
|
|
$(CC) $(FLAGS) $^ $(LDFLAGS) -o $@$(EXT)
|
|
|
|
|
2020-02-15 00:44:30 +00:00
|
|
|
xxhash.o: xxhash.c xxhash.h xxh3.h
|
2020-06-10 18:36:58 +00:00
|
|
|
xxhsum.o: xxhsum.c xxhash.h xxh3.h xxh_x86dispatch.h
|
2020-06-09 06:15:08 +00:00
|
|
|
xxh_x86dispatch.o: xxh_x86dispatch.c xxh_x86dispatch.h xxhash.h xxh3.h
|
2019-03-09 04:59:02 +00:00
|
|
|
|
2017-12-29 10:15:37 +00:00
|
|
|
.PHONY: xxhsum_and_links
|
2019-10-11 15:12:25 +00:00
|
|
|
xxhsum_and_links: xxhsum xxh32sum xxh64sum xxh128sum
|
2018-09-17 18:17:41 +00:00
|
|
|
|
2019-10-11 15:12:25 +00:00
|
|
|
xxh32sum xxh64sum xxh128sum: xxhsum
|
2020-02-13 01:37:34 +00:00
|
|
|
ln -sf $<$(EXT) $@$(EXT)
|
2014-07-10 07:28:57 +00:00
|
|
|
|
2018-09-30 06:09:23 +00:00
|
|
|
xxhsum_inlinedXXH: CPPFLAGS += -DXXH_INLINE_ALL
|
2016-06-06 12:12:27 +00:00
|
|
|
xxhsum_inlinedXXH: xxhsum.c
|
2018-09-30 06:09:23 +00:00
|
|
|
$(CC) $(FLAGS) $^ -o $@$(EXT)
|
2016-01-04 07:32:38 +00:00
|
|
|
|
2017-09-14 16:44:34 +00:00
|
|
|
|
|
|
|
# library
|
|
|
|
|
|
|
|
libxxhash.a: ARFLAGS = rcs
|
|
|
|
libxxhash.a: xxhash.o
|
2018-09-30 06:13:01 +00:00
|
|
|
$(AR) $(ARFLAGS) $@ $^
|
2017-09-14 16:44:34 +00:00
|
|
|
|
2018-03-20 18:13:30 +00:00
|
|
|
$(LIBXXH): LDFLAGS += -shared
|
2018-03-20 18:16:26 +00:00
|
|
|
ifeq (,$(filter Windows%,$(OS)))
|
2018-09-17 18:17:41 +00:00
|
|
|
$(LIBXXH): CFLAGS += -fPIC
|
2018-03-20 18:13:30 +00:00
|
|
|
endif
|
2017-09-14 16:44:34 +00:00
|
|
|
$(LIBXXH): xxhash.c
|
2018-09-17 18:17:41 +00:00
|
|
|
$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
|
2018-09-30 06:13:01 +00:00
|
|
|
ln -sf $@ libxxhash.$(SHARED_EXT_MAJOR)
|
|
|
|
ln -sf $@ libxxhash.$(SHARED_EXT)
|
2017-09-14 16:44:34 +00:00
|
|
|
|
2019-05-03 17:14:42 +00:00
|
|
|
.PHONY: libxxhash
|
|
|
|
libxxhash: ## generate dynamic xxhash library
|
|
|
|
libxxhash: $(LIBXXH)
|
2017-09-14 16:44:34 +00:00
|
|
|
|
2018-09-30 06:54:24 +00:00
|
|
|
.PHONY: lib
|
2019-05-03 17:14:42 +00:00
|
|
|
lib: ## generate static and dynamic xxhash libraries
|
2017-09-14 16:44:34 +00:00
|
|
|
lib: libxxhash.a libxxhash
|
|
|
|
|
2020-03-04 20:08:35 +00:00
|
|
|
pkgconfig:
|
|
|
|
@sed -e 's|@PREFIX@|$(PREFIX)|' \
|
|
|
|
-e 's|@VERSION@|$(LIBVER)|' \
|
|
|
|
libxxhash.pc.in >libxxhash.pc
|
2017-09-14 16:44:34 +00:00
|
|
|
|
2019-05-03 17:14:42 +00:00
|
|
|
# helper targets
|
|
|
|
|
|
|
|
AWK = awk
|
|
|
|
GREP = grep
|
|
|
|
SORT = sort
|
|
|
|
|
|
|
|
.PHONY: list
|
|
|
|
list: ## list all Makefile targets
|
|
|
|
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | $(AWK) -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | $(SORT) | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs
|
|
|
|
|
|
|
|
.PHONY: help
|
|
|
|
help: ## list documented targets
|
|
|
|
@$(GREP) -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
|
|
|
|
$(SORT) | \
|
|
|
|
$(AWK) 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean: ## remove all build artifacts
|
|
|
|
@$(RM) -r *.dSYM # Mac OS-X specific
|
2020-03-04 20:08:35 +00:00
|
|
|
@$(RM) core *.o *.$(SHARED_EXT) *.$(SHARED_EXT).* *.a libxxhash.pc
|
2020-06-09 06:15:08 +00:00
|
|
|
@$(RM) xxhsum$(EXT) xxhsum32$(EXT) xxhsum_inlinedXXH$(EXT) dispatch$(EXT)
|
2020-02-13 01:37:34 +00:00
|
|
|
@$(RM) xxh32sum$(EXT) xxh64sum$(EXT) xxh128sum$(EXT)
|
2019-05-03 17:14:42 +00:00
|
|
|
@echo cleaning completed
|
|
|
|
|
|
|
|
|
2019-03-12 18:31:57 +00:00
|
|
|
# =================================================
|
2017-09-14 16:44:34 +00:00
|
|
|
# tests
|
2019-03-12 18:31:57 +00:00
|
|
|
# =================================================
|
2017-09-14 16:44:34 +00:00
|
|
|
|
2019-03-12 19:44:42 +00:00
|
|
|
# make check can be run with cross-compiled binaries on emulated environments (qemu user mode)
|
|
|
|
# by setting $(RUN_ENV) to the target emulation environment
|
2018-03-20 17:41:22 +00:00
|
|
|
.PHONY: check
|
2019-05-03 17:14:42 +00:00
|
|
|
check: xxhsum ## basic tests for xxhsum CLI, set RUN_ENV for emulated environments
|
2015-08-07 23:22:56 +00:00
|
|
|
# stdin
|
2020-02-13 01:37:34 +00:00
|
|
|
$(RUN_ENV) ./xxhsum$(EXT) < xxhash.c
|
2015-08-07 23:22:56 +00:00
|
|
|
# multiple files
|
2020-02-13 01:37:34 +00:00
|
|
|
$(RUN_ENV) ./xxhsum$(EXT) xxhash.* xxhsum.*
|
2015-08-07 23:22:56 +00:00
|
|
|
# internal bench
|
2020-06-12 19:25:15 +00:00
|
|
|
$(RUN_ENV) ./xxhsum$(EXT) -bi0
|
2020-06-12 21:52:46 +00:00
|
|
|
# long bench command
|
|
|
|
$(RUN_ENV) ./xxhsum$(EXT) --benchmark-all -i0
|
2020-06-12 22:07:20 +00:00
|
|
|
# bench multiple variants
|
|
|
|
$(RUN_ENV) ./xxhsum$(EXT) -b1,2,3 -i0
|
2015-08-07 23:22:56 +00:00
|
|
|
# file bench
|
2020-06-12 19:25:15 +00:00
|
|
|
$(RUN_ENV) ./xxhsum$(EXT) -bi0 xxhash.c
|
2019-09-28 02:50:40 +00:00
|
|
|
# 32-bit
|
2020-02-13 01:37:34 +00:00
|
|
|
$(RUN_ENV) ./xxhsum$(EXT) -H0 xxhash.c
|
2019-09-28 00:50:02 +00:00
|
|
|
# 128-bit
|
2020-02-13 01:37:34 +00:00
|
|
|
$(RUN_ENV) ./xxhsum$(EXT) -H2 xxhash.c
|
2019-09-28 00:50:02 +00:00
|
|
|
# request incorrect variant
|
2020-02-13 01:37:34 +00:00
|
|
|
$(RUN_ENV) ./xxhsum$(EXT) -H9 xxhash.c ; test $$? -eq 1
|
|
|
|
|
2020-02-13 01:54:13 +00:00
|
|
|
.PHONY: test-unicode
|
Implement a safer Unicode test
This new test doesn't use any Unicode in the source files, instead
encoding all UTF-8 and UTF-16 as hex.
The test script will be generated from a C file, in which both a shell
script and a batch script will be generated, as well as the Unicode file
to test.
On Cygwin, MinGW, and MSYS, we will automatically bail from the shell
script to the batch script, as cmd.exe has more reliable Unicode
support, at least on Windows 7 and later.
When the make rule is called, it first checks if `$LANG` contains UTF-8,
defining the (overridable) ENABLE_UNICODE flag. If so, it will skip the
test with a warning.
Also fixed an issue with printf in multiInclude.c causing warnings on
old MinGW versions which expect %I64, and updated the .gitignore.
2020-02-15 00:08:09 +00:00
|
|
|
test-unicode:
|
|
|
|
$(MAKE) -C tests test_unicode
|
2019-05-03 17:14:42 +00:00
|
|
|
|
2017-09-08 08:24:43 +00:00
|
|
|
.PHONY: test-mem
|
2019-05-03 17:14:42 +00:00
|
|
|
VALGRIND = valgrind --leak-check=yes --error-exitcode=1
|
2019-09-28 02:50:40 +00:00
|
|
|
test-mem: RUN_ENV = $(VALGRIND)
|
|
|
|
test-mem: xxhsum check
|
2014-07-10 20:44:08 +00:00
|
|
|
|
2017-09-08 08:24:43 +00:00
|
|
|
.PHONY: test32
|
2015-05-05 00:01:10 +00:00
|
|
|
test32: clean xxhsum32
|
2017-12-26 01:57:24 +00:00
|
|
|
@echo ---- test 32-bit ----
|
2015-05-05 00:01:10 +00:00
|
|
|
./xxhsum32 -bi1 xxhash.c
|
|
|
|
|
2019-05-03 17:29:39 +00:00
|
|
|
.PHONY: test-xxhsum-c
|
2016-01-25 10:25:46 +00:00
|
|
|
test-xxhsum-c: xxhsum
|
|
|
|
# xxhsum to/from pipe
|
2019-09-28 21:58:07 +00:00
|
|
|
./xxhsum xxh* | ./xxhsum -c -
|
|
|
|
./xxhsum -H0 xxh* | ./xxhsum -c -
|
2019-09-18 01:06:25 +00:00
|
|
|
# xxhsum -q does not display "Loading" message into stderr (#251)
|
|
|
|
! ./xxhsum -q xxh* 2>&1 | grep Loading
|
2020-05-27 18:43:41 +00:00
|
|
|
# xxhsum does not display "Loading" message into stderr either
|
|
|
|
! ./xxhsum xxh* 2>&1 | grep Loading
|
|
|
|
# Check that xxhsum do display filename that it failed to open.
|
|
|
|
LC_ALL=C ./xxhsum nonexistent 2>&1 | grep "Error: Could not open 'nonexistent'"
|
2016-01-25 10:25:46 +00:00
|
|
|
# xxhsum to/from file, shell redirection
|
2019-09-28 21:58:07 +00:00
|
|
|
./xxhsum xxh* > .test.xxh64
|
|
|
|
./xxhsum -H0 xxh* > .test.xxh32
|
2019-09-28 23:49:11 +00:00
|
|
|
./xxhsum -H2 xxh* > .test.xxh128
|
2016-01-25 10:25:46 +00:00
|
|
|
./xxhsum -c .test.xxh64
|
|
|
|
./xxhsum -c .test.xxh32
|
2019-09-28 23:49:11 +00:00
|
|
|
./xxhsum -c .test.xxh128
|
2019-12-27 23:21:26 +00:00
|
|
|
# read list of files from stdin
|
2016-01-25 10:25:46 +00:00
|
|
|
./xxhsum -c < .test.xxh64
|
|
|
|
./xxhsum -c < .test.xxh32
|
|
|
|
# xxhsum -c warns improperly format lines.
|
2019-12-27 23:21:26 +00:00
|
|
|
cat .test.xxh64 .test.xxh32 | ./xxhsum -c - | $(GREP) improperly
|
|
|
|
cat .test.xxh32 .test.xxh64 | ./xxhsum -c - | $(GREP) improperly
|
2016-01-25 10:25:46 +00:00
|
|
|
# Expects "FAILED"
|
|
|
|
echo "0000000000000000 LICENSE" | ./xxhsum -c -; test $$? -eq 1
|
|
|
|
echo "00000000 LICENSE" | ./xxhsum -c -; test $$? -eq 1
|
|
|
|
# Expects "FAILED open or read"
|
|
|
|
echo "0000000000000000 test-expects-file-not-found" | ./xxhsum -c -; test $$? -eq 1
|
|
|
|
echo "00000000 test-expects-file-not-found" | ./xxhsum -c -; test $$? -eq 1
|
2019-12-27 23:21:26 +00:00
|
|
|
@$(RM) .test.xxh32 .test.xxh64 .test.xxh128
|
2016-01-25 10:25:46 +00:00
|
|
|
|
2019-05-03 17:29:39 +00:00
|
|
|
.PHONY: armtest
|
2015-06-28 11:20:23 +00:00
|
|
|
armtest: clean
|
2015-05-05 00:01:10 +00:00
|
|
|
@echo ---- test ARM compilation ----
|
2018-09-17 18:40:06 +00:00
|
|
|
CC=arm-linux-gnueabi-gcc MOREFLAGS="-Werror -static" $(MAKE) xxhsum
|
2015-05-05 00:01:10 +00:00
|
|
|
|
2019-05-03 17:29:39 +00:00
|
|
|
.PHONY: clangtest
|
2015-06-28 11:20:23 +00:00
|
|
|
clangtest: clean
|
2015-05-05 00:01:10 +00:00
|
|
|
@echo ---- test clang compilation ----
|
2018-09-17 18:40:06 +00:00
|
|
|
CC=clang MOREFLAGS="-Werror -Wconversion -Wno-sign-conversion" $(MAKE) all
|
2015-05-05 00:01:10 +00:00
|
|
|
|
2019-05-03 17:29:39 +00:00
|
|
|
.PHONY: cxxtest
|
2018-09-17 18:40:06 +00:00
|
|
|
cxxtest: clean
|
2018-09-30 06:54:24 +00:00
|
|
|
@echo ---- test C++ compilation ----
|
2018-09-17 18:40:06 +00:00
|
|
|
CC="$(CXX) -Wno-deprecated" $(MAKE) all CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror -fPIC"
|
2015-05-05 00:01:10 +00:00
|
|
|
|
2018-09-30 06:54:24 +00:00
|
|
|
.PHONY: c90test
|
2019-12-03 01:27:38 +00:00
|
|
|
ifeq ($(NO_C90_TEST),true)
|
|
|
|
c90test:
|
|
|
|
@echo no c90 compatibility test
|
|
|
|
else
|
2018-09-30 06:54:24 +00:00
|
|
|
c90test: CPPFLAGS += -DXXH_NO_LONG_LONG
|
|
|
|
c90test: CFLAGS += -std=c90 -Werror -pedantic
|
|
|
|
c90test: xxhash.c
|
2016-08-10 22:53:10 +00:00
|
|
|
@echo ---- test strict C90 compilation [xxh32 only] ----
|
2018-09-30 06:54:24 +00:00
|
|
|
$(RM) xxhash.o
|
|
|
|
$(CC) $(FLAGS) $^ $(LDFLAGS) -c
|
2016-08-10 22:53:10 +00:00
|
|
|
$(RM) xxhash.o
|
2019-12-03 01:27:38 +00:00
|
|
|
endif
|
2016-08-10 22:53:10 +00:00
|
|
|
|
2019-11-05 01:25:42 +00:00
|
|
|
.PHONY: usan
|
2018-03-20 19:53:25 +00:00
|
|
|
usan: CC=clang
|
2019-11-05 01:25:42 +00:00
|
|
|
usan: CXX=clang++
|
2019-05-03 17:29:39 +00:00
|
|
|
usan: ## check CLI runtime for undefined behavior, using clang's sanitizer
|
2015-05-05 00:01:10 +00:00
|
|
|
@echo ---- check undefined behavior - sanitize ----
|
2019-05-03 17:29:39 +00:00
|
|
|
$(MAKE) clean
|
2019-11-05 01:25:42 +00:00
|
|
|
$(MAKE) test CC=$(CC) CXX=$(CXX) MOREFLAGS="-g -fsanitize=undefined -fno-sanitize-recover=all"
|
2015-05-05 00:01:10 +00:00
|
|
|
|
2018-09-17 20:47:54 +00:00
|
|
|
.PHONY: staticAnalyze
|
2019-06-14 20:10:14 +00:00
|
|
|
SCANBUILD ?= scan-build
|
2019-06-14 19:44:15 +00:00
|
|
|
staticAnalyze: clean ## check C source files using $(SCANBUILD) static analyzer
|
|
|
|
@echo ---- static analyzer - $(SCANBUILD) ----
|
|
|
|
CFLAGS="-g -Werror" $(SCANBUILD) --status-bugs -v $(MAKE) all
|
2015-05-05 00:01:10 +00:00
|
|
|
|
2019-06-14 20:10:14 +00:00
|
|
|
CPPCHECK ?= cppcheck
|
2018-09-17 20:47:54 +00:00
|
|
|
.PHONY: cppcheck
|
2019-06-14 20:10:14 +00:00
|
|
|
cppcheck: ## check C source files using $(CPPCHECK) static analyzer
|
|
|
|
@echo ---- static analyzer - $(CPPCHECK) ----
|
2019-05-03 17:14:42 +00:00
|
|
|
$(CPPCHECK) . --force --enable=warning,portability,performance,style --error-exitcode=1 > /dev/null
|
2018-09-17 20:47:54 +00:00
|
|
|
|
2018-09-30 06:54:24 +00:00
|
|
|
.PHONY: namespaceTest
|
2019-05-03 17:29:39 +00:00
|
|
|
namespaceTest: ## ensure XXH_NAMESPACE redefines all public symbols
|
2016-08-10 04:55:55 +00:00
|
|
|
$(CC) -c xxhash.c
|
|
|
|
$(CC) -DXXH_NAMESPACE=TEST_ -c xxhash.c -o xxhash2.o
|
|
|
|
$(CC) xxhash.o xxhash2.o xxhsum.c -o xxhsum2 # will fail if one namespace missing (symbol collision)
|
|
|
|
$(RM) *.o xxhsum2 # clean
|
|
|
|
|
2019-06-14 20:10:14 +00:00
|
|
|
MD2ROFF ?= ronn
|
|
|
|
MD2ROFF_FLAGS ?= --roff --warnings --manual="User Commands" --organization="xxhsum $(XXHSUM_VERSION)"
|
2019-09-28 00:55:33 +00:00
|
|
|
xxhsum.1: xxhsum.1.md xxhash.h
|
|
|
|
cat $< | $(MD2ROFF) $(MD2ROFF_FLAGS) | sed -n '/^\.\\\".*/!p' > $@
|
2016-02-19 18:08:46 +00:00
|
|
|
|
2018-09-30 06:54:24 +00:00
|
|
|
.PHONY: man
|
2019-05-03 17:14:42 +00:00
|
|
|
man: xxhsum.1 ## generate man page from markdown source
|
2016-02-19 18:08:46 +00:00
|
|
|
|
2019-05-03 17:29:39 +00:00
|
|
|
.PHONY: clean-man
|
2016-02-19 18:08:46 +00:00
|
|
|
clean-man:
|
2016-08-10 04:55:55 +00:00
|
|
|
$(RM) xxhsum.1
|
2016-02-19 18:08:46 +00:00
|
|
|
|
2019-05-03 17:29:39 +00:00
|
|
|
.PHONY: preview-man
|
|
|
|
preview-man: man
|
2016-02-19 18:08:46 +00:00
|
|
|
man ./xxhsum.1
|
|
|
|
|
2019-05-03 17:29:39 +00:00
|
|
|
.PHONY: test
|
2020-05-20 20:36:24 +00:00
|
|
|
test: DEBUGFLAGS += -DXXH_DEBUGLEVEL=1
|
2020-02-13 01:58:10 +00:00
|
|
|
test: all namespaceTest check test-xxhsum-c c90test test-tools
|
2018-03-20 17:41:22 +00:00
|
|
|
|
2020-02-12 19:43:33 +00:00
|
|
|
.PHONY: test-inline
|
|
|
|
test-inline:
|
Implement a safer Unicode test
This new test doesn't use any Unicode in the source files, instead
encoding all UTF-8 and UTF-16 as hex.
The test script will be generated from a C file, in which both a shell
script and a batch script will be generated, as well as the Unicode file
to test.
On Cygwin, MinGW, and MSYS, we will automatically bail from the shell
script to the batch script, as cmd.exe has more reliable Unicode
support, at least on Windows 7 and later.
When the make rule is called, it first checks if `$LANG` contains UTF-8,
defining the (overridable) ENABLE_UNICODE flag. If so, it will skip the
test with a warning.
Also fixed an issue with printf in multiInclude.c causing warnings on
old MinGW versions which expect %I64, and updated the .gitignore.
2020-02-15 00:08:09 +00:00
|
|
|
$(MAKE) -C tests test_multiInclude
|
2020-02-12 19:43:33 +00:00
|
|
|
|
2019-05-03 17:29:39 +00:00
|
|
|
.PHONY: test-all
|
2019-02-27 00:49:23 +00:00
|
|
|
test-all: CFLAGS += -Werror
|
2020-06-13 01:11:01 +00:00
|
|
|
test-all: test test32 clangtest cxxtest usan test-inline listL120 trailingWhitespace test-unicode
|
2014-07-10 20:44:08 +00:00
|
|
|
|
2019-10-11 15:12:25 +00:00
|
|
|
.PHONY: test-tools
|
|
|
|
test-tools:
|
2020-02-29 01:41:33 +00:00
|
|
|
CFLAGS=-Werror $(MAKE) -C tests/bench
|
|
|
|
CFLAGS=-Werror $(MAKE) -C tests/collisions
|
2019-10-11 15:12:25 +00:00
|
|
|
|
2017-10-09 20:22:16 +00:00
|
|
|
.PHONY: listL120
|
2020-03-03 17:10:19 +00:00
|
|
|
listL120: # extract lines >= 120 characters in *.{c,h}, by Takayuki Matsuoka (note: $$, for Makefile compatibility)
|
2017-10-09 19:37:02 +00:00
|
|
|
find . -type f -name '*.c' -o -name '*.h' | while read -r filename; do awk 'length > 120 {print FILENAME "(" FNR "): " $$0}' $$filename; done
|
|
|
|
|
2018-03-19 00:17:02 +00:00
|
|
|
.PHONY: trailingWhitespace
|
|
|
|
trailingWhitespace:
|
2019-07-26 00:19:58 +00:00
|
|
|
! $(GREP) -E "`printf '[ \\t]$$'`" xxhsum.1 *.c *.h LICENSE Makefile cmake_unofficial/CMakeLists.txt
|
2016-08-23 09:42:53 +00:00
|
|
|
|
|
|
|
|
2019-05-03 17:14:42 +00:00
|
|
|
# =========================================================
|
2017-09-08 07:31:30 +00:00
|
|
|
# make install is validated only for the following targets
|
2019-05-03 17:14:42 +00:00
|
|
|
# =========================================================
|
2017-09-08 07:31:30 +00:00
|
|
|
ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS))
|
|
|
|
|
|
|
|
DESTDIR ?=
|
2020-03-03 17:10:19 +00:00
|
|
|
# directory variables: GNU conventions prefer lowercase
|
2017-09-08 07:31:30 +00:00
|
|
|
# see https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html
|
|
|
|
# support both lower and uppercase (BSD), use uppercase in script
|
|
|
|
prefix ?= /usr/local
|
|
|
|
PREFIX ?= $(prefix)
|
|
|
|
exec_prefix ?= $(PREFIX)
|
2017-09-14 16:44:34 +00:00
|
|
|
libdir ?= $(exec_prefix)/lib
|
|
|
|
LIBDIR ?= $(libdir)
|
|
|
|
includedir ?= $(PREFIX)/include
|
|
|
|
INCLUDEDIR ?= $(includedir)
|
2017-09-08 07:31:30 +00:00
|
|
|
bindir ?= $(exec_prefix)/bin
|
|
|
|
BINDIR ?= $(bindir)
|
|
|
|
datarootdir ?= $(PREFIX)/share
|
|
|
|
mandir ?= $(datarootdir)/man
|
|
|
|
man1dir ?= $(mandir)/man1
|
|
|
|
|
2020-03-04 20:08:35 +00:00
|
|
|
ifneq (,$(filter $(shell uname),FreeBSD NetBSD DragonFly))
|
|
|
|
PKGCONFIGDIR ?= $(PREFIX)/libdata/pkgconfig
|
|
|
|
else
|
|
|
|
PKGCONFIGDIR ?= $(LIBDIR)/pkgconfig
|
|
|
|
endif
|
|
|
|
|
2017-09-08 07:31:30 +00:00
|
|
|
ifneq (,$(filter $(shell uname),OpenBSD FreeBSD NetBSD DragonFly SunOS))
|
|
|
|
MANDIR ?= $(PREFIX)/man/man1
|
|
|
|
else
|
|
|
|
MANDIR ?= $(man1dir)
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifneq (,$(filter $(shell uname),SunOS))
|
|
|
|
INSTALL ?= ginstall
|
|
|
|
else
|
|
|
|
INSTALL ?= install
|
|
|
|
endif
|
|
|
|
|
|
|
|
INSTALL_PROGRAM ?= $(INSTALL)
|
|
|
|
INSTALL_DATA ?= $(INSTALL) -m 644
|
|
|
|
|
2016-08-23 09:42:53 +00:00
|
|
|
|
2017-09-08 07:31:30 +00:00
|
|
|
.PHONY: install
|
2020-03-04 20:08:35 +00:00
|
|
|
install: lib pkgconfig xxhsum ## install libraries, CLI, links and man page
|
2017-09-14 16:44:34 +00:00
|
|
|
@echo Installing libxxhash
|
2017-10-18 08:25:54 +00:00
|
|
|
@$(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)
|
2017-09-14 16:44:34 +00:00
|
|
|
@$(INSTALL_DATA) libxxhash.a $(DESTDIR)$(LIBDIR)
|
|
|
|
@$(INSTALL_PROGRAM) $(LIBXXH) $(DESTDIR)$(LIBDIR)
|
|
|
|
@ln -sf $(LIBXXH) $(DESTDIR)$(LIBDIR)/libxxhash.$(SHARED_EXT_MAJOR)
|
|
|
|
@ln -sf $(LIBXXH) $(DESTDIR)$(LIBDIR)/libxxhash.$(SHARED_EXT)
|
|
|
|
@$(INSTALL) -d -m 755 $(DESTDIR)$(INCLUDEDIR) # includes
|
|
|
|
@$(INSTALL_DATA) xxhash.h $(DESTDIR)$(INCLUDEDIR)
|
2019-11-04 23:53:35 +00:00
|
|
|
@$(INSTALL_DATA) xxh3.h $(DESTDIR)$(INCLUDEDIR)
|
2020-03-04 20:08:35 +00:00
|
|
|
@echo Installing pkgconfig
|
|
|
|
@$(INSTALL) -d -m 755 $(DESTDIR)$(PKGCONFIGDIR)/
|
|
|
|
@$(INSTALL_DATA) libxxhash.pc $(DESTDIR)$(PKGCONFIGDIR)/
|
2017-09-14 16:44:34 +00:00
|
|
|
@echo Installing xxhsum
|
2017-09-08 07:31:30 +00:00
|
|
|
@$(INSTALL) -d -m 755 $(DESTDIR)$(BINDIR)/ $(DESTDIR)$(MANDIR)/
|
|
|
|
@$(INSTALL_PROGRAM) xxhsum $(DESTDIR)$(BINDIR)/xxhsum
|
2016-08-23 09:42:53 +00:00
|
|
|
@ln -sf xxhsum $(DESTDIR)$(BINDIR)/xxh32sum
|
|
|
|
@ln -sf xxhsum $(DESTDIR)$(BINDIR)/xxh64sum
|
2019-09-28 23:49:11 +00:00
|
|
|
@ln -sf xxhsum $(DESTDIR)$(BINDIR)/xxh128sum
|
2016-08-23 09:42:53 +00:00
|
|
|
@echo Installing man pages
|
2017-09-08 07:31:30 +00:00
|
|
|
@$(INSTALL_DATA) xxhsum.1 $(DESTDIR)$(MANDIR)/xxhsum.1
|
2017-07-29 19:17:40 +00:00
|
|
|
@ln -sf xxhsum.1 $(DESTDIR)$(MANDIR)/xxh32sum.1
|
|
|
|
@ln -sf xxhsum.1 $(DESTDIR)$(MANDIR)/xxh64sum.1
|
2019-09-28 23:49:11 +00:00
|
|
|
@ln -sf xxhsum.1 $(DESTDIR)$(MANDIR)/xxh128sum.1
|
2017-09-14 16:44:34 +00:00
|
|
|
@echo xxhash installation completed
|
2016-08-23 09:42:53 +00:00
|
|
|
|
2017-09-08 07:31:30 +00:00
|
|
|
.PHONY: uninstall
|
2019-05-03 17:14:42 +00:00
|
|
|
uninstall: ## uninstall libraries, CLI, links and man page
|
2017-09-14 16:44:34 +00:00
|
|
|
@$(RM) $(DESTDIR)$(LIBDIR)/libxxhash.a
|
|
|
|
@$(RM) $(DESTDIR)$(LIBDIR)/libxxhash.$(SHARED_EXT)
|
|
|
|
@$(RM) $(DESTDIR)$(LIBDIR)/libxxhash.$(SHARED_EXT_MAJOR)
|
|
|
|
@$(RM) $(DESTDIR)$(LIBDIR)/$(LIBXXH)
|
|
|
|
@$(RM) $(DESTDIR)$(INCLUDEDIR)/xxhash.h
|
2020-03-04 20:08:35 +00:00
|
|
|
@$(RM) $(DESTDIR)$(PKGCONFIGDIR)/libxxhash.pc
|
2017-09-14 16:44:34 +00:00
|
|
|
@$(RM) $(DESTDIR)$(BINDIR)/xxh32sum
|
|
|
|
@$(RM) $(DESTDIR)$(BINDIR)/xxh64sum
|
2019-09-28 23:49:11 +00:00
|
|
|
@$(RM) $(DESTDIR)$(BINDIR)/xxh128sum
|
2017-09-14 16:44:34 +00:00
|
|
|
@$(RM) $(DESTDIR)$(BINDIR)/xxhsum
|
|
|
|
@$(RM) $(DESTDIR)$(MANDIR)/xxh32sum.1
|
|
|
|
@$(RM) $(DESTDIR)$(MANDIR)/xxh64sum.1
|
2019-09-28 23:49:11 +00:00
|
|
|
@$(RM) $(DESTDIR)$(MANDIR)/xxh128sum.1
|
2017-09-14 16:44:34 +00:00
|
|
|
@$(RM) $(DESTDIR)$(MANDIR)/xxhsum.1
|
2016-08-23 09:42:53 +00:00
|
|
|
@echo xxhsum successfully uninstalled
|
|
|
|
|
|
|
|
endif
|