"Fossies" - the Fresh Open Source Software Archive

Member "xxHash-0.8.0/Makefile" (27 Jul 2020, 17762 Bytes) of package /linux/misc/xxHash-0.8.0.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "Makefile": 0.7.4_vs_0.8.0.

    1 # ################################################################
    2 # xxHash Makefile
    3 # Copyright (C) 2012-2020 Yann Collet
    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 homepage: https://www.xxhash.com
   23 #   - xxHash source repository: https://github.com/Cyan4973/xxHash
   24 # ################################################################
   25 # xxhsum: provides 32/64 bits hash of one or multiple files, or stdin
   26 # ################################################################
   27 Q = $(if $(filter 1,$(V) $(VERBOSE)),,@)
   28 
   29 # Version numbers
   30 SED ?= sed
   31 SED_ERE_OPT ?= -E
   32 LIBVER_MAJOR_SCRIPT:=`$(SED) -n '/define XXH_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < xxhash.h`
   33 LIBVER_MINOR_SCRIPT:=`$(SED) -n '/define XXH_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < xxhash.h`
   34 LIBVER_PATCH_SCRIPT:=`$(SED) -n '/define XXH_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < xxhash.h`
   35 LIBVER_MAJOR := $(shell echo $(LIBVER_MAJOR_SCRIPT))
   36 LIBVER_MINOR := $(shell echo $(LIBVER_MINOR_SCRIPT))
   37 LIBVER_PATCH := $(shell echo $(LIBVER_PATCH_SCRIPT))
   38 LIBVER := $(LIBVER_MAJOR).$(LIBVER_MINOR).$(LIBVER_PATCH)
   39 
   40 CFLAGS ?= -O3
   41 DEBUGFLAGS+=-Wall -Wextra -Wconversion -Wcast-qual -Wcast-align -Wshadow \
   42             -Wstrict-aliasing=1 -Wswitch-enum -Wdeclaration-after-statement \
   43             -Wstrict-prototypes -Wundef -Wpointer-arith -Wformat-security \
   44             -Wvla -Wformat=2 -Winit-self -Wfloat-equal -Wwrite-strings \
   45             -Wredundant-decls -Wstrict-overflow=2
   46 CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)
   47 FLAGS   = $(CFLAGS) $(CPPFLAGS)
   48 XXHSUM_VERSION = $(LIBVER)
   49 UNAME := $(shell uname)
   50 
   51 # Define *.exe as extension for Windows systems
   52 ifneq (,$(filter Windows%,$(OS)))
   53 EXT =.exe
   54 else
   55 EXT =
   56 endif
   57 
   58 # OS X linker doesn't support -soname, and use different extension
   59 # see: https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html
   60 ifeq ($(UNAME), Darwin)
   61 	SHARED_EXT = dylib
   62 	SHARED_EXT_MAJOR = $(LIBVER_MAJOR).$(SHARED_EXT)
   63 	SHARED_EXT_VER = $(LIBVER).$(SHARED_EXT)
   64 	SONAME_FLAGS = -install_name $(LIBDIR)/libxxhash.$(SHARED_EXT_MAJOR) -compatibility_version $(LIBVER_MAJOR) -current_version $(LIBVER)
   65 else
   66 	SONAME_FLAGS = -Wl,-soname=libxxhash.$(SHARED_EXT).$(LIBVER_MAJOR)
   67 	SHARED_EXT = so
   68 	SHARED_EXT_MAJOR = $(SHARED_EXT).$(LIBVER_MAJOR)
   69 	SHARED_EXT_VER = $(SHARED_EXT).$(LIBVER)
   70 endif
   71 
   72 LIBXXH = libxxhash.$(SHARED_EXT_VER)
   73 
   74 
   75 ## generate CLI and libraries in release mode (default for `make`)
   76 .PHONY: default
   77 default: DEBUGFLAGS=
   78 default: lib xxhsum_and_links
   79 
   80 .PHONY: all
   81 all: lib xxhsum xxhsum_inlinedXXH
   82 
   83 ## xxhsum is the command line interface (CLI)
   84 ifeq ($(DISPATCH),1)
   85 xxhsum: CPPFLAGS += -DXXHSUM_DISPATCH=1
   86 xxhsum: xxh_x86dispatch.o
   87 endif
   88 xxhsum: xxhash.o xxhsum.o
   89 	$(CC) $(FLAGS) $^ $(LDFLAGS) -o $@$(EXT)
   90 
   91 xxhsum32: CFLAGS += -m32  ## generate CLI in 32-bits mode
   92 xxhsum32: xxhash.c xxhsum.c  ## do not generate object (avoid mixing different ABI)
   93 	$(CC) $(FLAGS) $^ $(LDFLAGS) -o $@$(EXT)
   94 
   95 ## dispatch only works for x86/x64 systems
   96 dispatch: CPPFLAGS += -DXXHSUM_DISPATCH=1
   97 dispatch: xxhash.o xxh_x86dispatch.o xxhsum.c
   98 	$(CC) $(FLAGS) $^ $(LDFLAGS) -o $@$(EXT)
   99 
  100 xxhash.o: xxhash.c xxhash.h
  101 xxhsum.o: xxhsum.c xxhash.h xxh_x86dispatch.h
  102 xxh_x86dispatch.o: xxh_x86dispatch.c xxh_x86dispatch.h xxhash.h
  103 
  104 .PHONY: xxhsum_and_links
  105 xxhsum_and_links: xxhsum xxh32sum xxh64sum xxh128sum
  106 
  107 xxh32sum xxh64sum xxh128sum: xxhsum
  108 	ln -sf $<$(EXT) $@$(EXT)
  109 
  110 xxhsum_inlinedXXH: CPPFLAGS += -DXXH_INLINE_ALL
  111 xxhsum_inlinedXXH: xxhsum.c
  112 	$(CC) $(FLAGS) $^ -o $@$(EXT)
  113 
  114 
  115 # library
  116 
  117 libxxhash.a: ARFLAGS = rcs
  118 libxxhash.a: xxhash.o
  119 	$(AR) $(ARFLAGS) $@ $^
  120 
  121 $(LIBXXH): LDFLAGS += -shared
  122 ifeq (,$(filter Windows%,$(OS)))
  123 $(LIBXXH): CFLAGS += -fPIC
  124 endif
  125 ifeq ($(DISPATCH),1)
  126 $(LIBXXH): xxh_x86dispatch.c
  127 endif
  128 $(LIBXXH): xxhash.c
  129 	$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
  130 	ln -sf $@ libxxhash.$(SHARED_EXT_MAJOR)
  131 	ln -sf $@ libxxhash.$(SHARED_EXT)
  132 
  133 .PHONY: libxxhash
  134 libxxhash:  ## generate dynamic xxhash library
  135 libxxhash: $(LIBXXH)
  136 
  137 .PHONY: lib
  138 lib:  ## generate static and dynamic xxhash libraries
  139 lib: libxxhash.a libxxhash
  140 
  141 # helper targets
  142 
  143 AWK = awk
  144 GREP = grep
  145 SORT = sort
  146 
  147 .PHONY: list
  148 list:  ## list all Makefile targets
  149 	$(Q)$(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
  150 
  151 .PHONY: help
  152 help:  ## list documented targets
  153 	$(Q)$(GREP) -E '^[0-9a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
  154 	$(SORT) | \
  155 	$(AWK) 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
  156 
  157 .PHONY: clean
  158 clean:  ## remove all build artifacts
  159 	$(Q)$(RM) -r *.dSYM   # Mac OS-X specific
  160 	$(Q)$(RM) core *.o *.$(SHARED_EXT) *.$(SHARED_EXT).* *.a libxxhash.pc
  161 	$(Q)$(RM) xxhsum$(EXT) xxhsum32$(EXT) xxhsum_inlinedXXH$(EXT) dispatch$(EXT)
  162 	$(Q)$(RM) xxh32sum$(EXT) xxh64sum$(EXT) xxh128sum$(EXT)
  163 	@echo cleaning completed
  164 
  165 
  166 # =================================================
  167 # tests
  168 # =================================================
  169 
  170 # make check can be run with cross-compiled binaries on emulated environments (qemu user mode)
  171 # by setting $(RUN_ENV) to the target emulation environment
  172 .PHONY: check
  173 check: xxhsum   ## basic tests for xxhsum CLI, set RUN_ENV for emulated environments
  174 	# stdin
  175 	$(RUN_ENV) ./xxhsum$(EXT) < xxhash.c
  176 	# multiple files
  177 	$(RUN_ENV) ./xxhsum$(EXT) xxhash.* xxhsum.*
  178 	# internal bench
  179 	$(RUN_ENV) ./xxhsum$(EXT) -bi0
  180 	# long bench command
  181 	$(RUN_ENV) ./xxhsum$(EXT) --benchmark-all -i0
  182 	# bench multiple variants
  183 	$(RUN_ENV) ./xxhsum$(EXT) -b1,2,3 -i0
  184 	# file bench
  185 	$(RUN_ENV) ./xxhsum$(EXT) -bi0 xxhash.c
  186 	# 32-bit
  187 	$(RUN_ENV) ./xxhsum$(EXT) -H0 xxhash.c
  188 	# 128-bit
  189 	$(RUN_ENV) ./xxhsum$(EXT) -H2 xxhash.c
  190 	# request incorrect variant
  191 	$(RUN_ENV) ./xxhsum$(EXT) -H9 xxhash.c ; test $$? -eq 1
  192 	@printf "\n .......   checks completed successfully   ....... \n"
  193 
  194 .PHONY: test-unicode
  195 test-unicode:
  196 	$(MAKE) -C tests test_unicode
  197 
  198 .PHONY: test-mem
  199 VALGRIND = valgrind --leak-check=yes --error-exitcode=1
  200 test-mem: RUN_ENV = $(VALGRIND)
  201 test-mem: xxhsum check
  202 
  203 .PHONY: test32
  204 test32: clean xxhsum32
  205 	@echo ---- test 32-bit ----
  206 	./xxhsum32 -bi1 xxhash.c
  207 
  208 .PHONY: test-xxhsum-c
  209 test-xxhsum-c: xxhsum
  210 	# xxhsum to/from pipe
  211 	./xxhsum xxh* | ./xxhsum -c -
  212 	./xxhsum -H0 xxh* | ./xxhsum -c -
  213 	# xxhsum -q does not display "Loading" message into stderr (#251)
  214 	! ./xxhsum -q xxh* 2>&1 | grep Loading
  215 	# xxhsum does not display "Loading" message into stderr either
  216 	! ./xxhsum xxh* 2>&1 | grep Loading
  217 	# Check that xxhsum do display filename that it failed to open.
  218 	LC_ALL=C ./xxhsum nonexistent 2>&1 | grep "Error: Could not open 'nonexistent'"
  219 	# xxhsum to/from file, shell redirection
  220 	./xxhsum xxh* > .test.xxh64
  221 	./xxhsum --tag xxh* > .test.xxh64_tag
  222 	./xxhsum --little-endian xxh* > .test.le_xxh64
  223 	./xxhsum --tag --little-endian xxh* > .test.le_xxh64_tag
  224 	./xxhsum -H0 xxh* > .test.xxh32
  225 	./xxhsum -H0 --tag xxh* > .test.xxh32_tag
  226 	./xxhsum -H0 --little-endian xxh* > .test.le_xxh32
  227 	./xxhsum -H0 --tag --little-endian xxh* > .test.le_xxh32_tag
  228 	./xxhsum -H2 xxh* > .test.xxh128
  229 	./xxhsum -H2 --tag xxh* > .test.xxh128_tag
  230 	./xxhsum -H2 --little-endian xxh* > .test.le_xxh128
  231 	./xxhsum -H2 --tag --little-endian xxh* > .test.le_xxh128_tag
  232 	./xxhsum -c .test.xxh*
  233 	./xxhsum -c --little-endian .test.le_xxh*
  234 	./xxhsum -c .test.*_tag
  235 	# read list of files from stdin
  236 	./xxhsum -c < .test.xxh64
  237 	./xxhsum -c < .test.xxh32
  238 	cat .test.xxh* | ./xxhsum -c -
  239 	# check variant with '*' marker as second separator
  240 	$(SED) 's/  / \*/' .test.xxh32 | ./xxhsum -c
  241 	# bsd-style output
  242 	./xxhsum --tag xxhsum* | $(GREP) XXH64
  243 	./xxhsum --tag -H0 xxhsum* | $(GREP) XXH32
  244 	./xxhsum --tag -H1 xxhsum* | $(GREP) XXH64
  245 	./xxhsum --tag -H2 xxhsum* | $(GREP) XXH128
  246 	./xxhsum --tag -H32 xxhsum* | $(GREP) XXH32
  247 	./xxhsum --tag -H64 xxhsum* | $(GREP) XXH64
  248 	./xxhsum --tag -H128 xxhsum* | $(GREP) XXH128
  249 	./xxhsum --tag -H0 --little-endian xxhsum* | $(GREP) XXH32_LE
  250 	./xxhsum --tag -H1 --little-endian xxhsum* | $(GREP) XXH64_LE
  251 	./xxhsum --tag -H2 --little-endian xxhsum* | $(GREP) XXH128_LE
  252 	./xxhsum --tag -H32 --little-endian xxhsum* | $(GREP) XXH32_LE
  253 	./xxhsum --tag -H64 --little-endian xxhsum* | $(GREP) XXH64_LE
  254 	./xxhsum --tag -H128 --little-endian xxhsum* | $(GREP) XXH128_LE
  255 	# check bsd-style
  256 	./xxhsum --tag xxhsum* | ./xxhsum -c
  257 	./xxhsum --tag -H32 --little-endian xxhsum* | ./xxhsum -c
  258 	# xxhsum -c warns improperly format lines.
  259 	echo '12345678 ' >>.test.xxh32
  260 	./xxhsum -c .test.xxh32 | $(GREP) improperly
  261 	echo '123456789  file' >>.test.xxh64
  262 	./xxhsum -c .test.xxh64 | $(GREP) improperly
  263 	# Expects "FAILED"
  264 	echo "0000000000000000  LICENSE" | ./xxhsum -c -; test $$? -eq 1
  265 	echo "00000000  LICENSE" | ./xxhsum -c -; test $$? -eq 1
  266 	# Expects "FAILED open or read"
  267 	echo "0000000000000000  test-expects-file-not-found" | ./xxhsum -c -; test $$? -eq 1
  268 	echo "00000000  test-expects-file-not-found" | ./xxhsum -c -; test $$? -eq 1
  269 	@$(RM) .test.*
  270 
  271 .PHONY: armtest
  272 armtest: clean
  273 	@echo ---- test ARM compilation ----
  274 	CC=arm-linux-gnueabi-gcc MOREFLAGS="-Werror -static" $(MAKE) xxhsum
  275 
  276 .PHONY: clangtest
  277 clangtest: clean
  278 	@echo ---- test clang compilation ----
  279 	CC=clang MOREFLAGS="-Werror -Wconversion -Wno-sign-conversion" $(MAKE) all
  280 
  281 .PHONY: cxxtest
  282 cxxtest: clean
  283 	@echo ---- test C++ compilation ----
  284 	CC="$(CXX) -Wno-deprecated" $(MAKE) all CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror -fPIC"
  285 
  286 .PHONY: c90test
  287 ifeq ($(NO_C90_TEST),true)
  288 c90test:
  289 	@echo no c90 compatibility test
  290 else
  291 c90test: CPPFLAGS += -DXXH_NO_LONG_LONG
  292 c90test: CFLAGS += -std=c90 -Werror -pedantic
  293 c90test: xxhash.c
  294 	@echo ---- test strict C90 compilation [xxh32 only] ----
  295 	$(RM) xxhash.o
  296 	$(CC) $(FLAGS) $^ $(LDFLAGS) -c
  297 	$(RM) xxhash.o
  298 endif
  299 
  300 .PHONY: usan
  301 usan: CC=clang
  302 usan: CXX=clang++
  303 usan:  ## check CLI runtime for undefined behavior, using clang's sanitizer
  304 	@echo ---- check undefined behavior - sanitize ----
  305 	$(MAKE) clean
  306 	$(MAKE) test CC=$(CC) CXX=$(CXX) MOREFLAGS="-g -fsanitize=undefined -fno-sanitize-recover=all"
  307 
  308 .PHONY: staticAnalyze
  309 SCANBUILD ?= scan-build
  310 staticAnalyze: clean  ## check C source files using $(SCANBUILD) static analyzer
  311 	@echo ---- static analyzer - $(SCANBUILD) ----
  312 	CFLAGS="-g -Werror" $(SCANBUILD) --status-bugs -v $(MAKE) all
  313 
  314 CPPCHECK ?= cppcheck
  315 .PHONY: cppcheck
  316 cppcheck:  ## check C source files using $(CPPCHECK) static analyzer
  317 	@echo ---- static analyzer - $(CPPCHECK) ----
  318 	$(CPPCHECK) . --force --enable=warning,portability,performance,style --error-exitcode=1 > /dev/null
  319 
  320 .PHONY: namespaceTest
  321 namespaceTest:  ## ensure XXH_NAMESPACE redefines all public symbols
  322 	$(CC) -c xxhash.c
  323 	$(CC) -DXXH_NAMESPACE=TEST_ -c xxhash.c -o xxhash2.o
  324 	$(CC) xxhash.o xxhash2.o xxhsum.c -o xxhsum2  # will fail if one namespace missing (symbol collision)
  325 	$(RM) *.o xxhsum2  # clean
  326 
  327 MD2ROFF ?= ronn
  328 MD2ROFF_FLAGS ?= --roff --warnings --manual="User Commands" --organization="xxhsum $(XXHSUM_VERSION)"
  329 xxhsum.1: xxhsum.1.md xxhash.h
  330 	cat $< | $(MD2ROFF) $(MD2ROFF_FLAGS) | $(SED) -n '/^\.\\\".*/!p' > $@
  331 
  332 .PHONY: man
  333 man: xxhsum.1  ## generate man page from markdown source
  334 
  335 .PHONY: clean-man
  336 clean-man:
  337 	$(RM) xxhsum.1
  338 
  339 .PHONY: preview-man
  340 preview-man: man
  341 	man ./xxhsum.1
  342 
  343 .PHONY: test
  344 test: DEBUGFLAGS += -DXXH_DEBUGLEVEL=1
  345 test: all namespaceTest check test-xxhsum-c c90test test-tools
  346 
  347 .PHONY: test-inline
  348 test-inline:
  349 	$(MAKE) -C tests test_multiInclude
  350 
  351 .PHONY: test-all
  352 test-all: CFLAGS += -Werror
  353 test-all: test test32 clangtest cxxtest usan test-inline listL120 trailingWhitespace test-unicode
  354 
  355 .PHONY: test-tools
  356 test-tools:
  357 	CFLAGS=-Werror $(MAKE) -C tests/bench
  358 	CFLAGS=-Werror $(MAKE) -C tests/collisions
  359 
  360 .PHONY: listL120
  361 listL120:  # extract lines >= 120 characters in *.{c,h}, by Takayuki Matsuoka (note: $$, for Makefile compatibility)
  362 	find . -type f -name '*.c' -o -name '*.h' | while read -r filename; do awk 'length > 120 {print FILENAME "(" FNR "): " $$0}' $$filename; done
  363 
  364 .PHONY: trailingWhitespace
  365 trailingWhitespace:
  366 	! $(GREP) -E "`printf '[ \\t]$$'`" xxhsum.1 *.c *.h LICENSE Makefile cmake_unofficial/CMakeLists.txt
  367 
  368 
  369 # =========================================================
  370 # make install is validated only for the following targets
  371 # =========================================================
  372 ifneq (,$(filter Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS CYGWIN% , $(UNAME)))
  373 
  374 DESTDIR     ?=
  375 # directory variables: GNU conventions prefer lowercase
  376 # see https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html
  377 # support both lower and uppercase (BSD), use uppercase in script
  378 prefix      ?= /usr/local
  379 PREFIX      ?= $(prefix)
  380 exec_prefix ?= $(PREFIX)
  381 EXEC_PREFIX ?= $(exec_prefix)
  382 libdir      ?= $(EXEC_PREFIX)/lib
  383 LIBDIR      ?= $(libdir)
  384 includedir  ?= $(PREFIX)/include
  385 INCLUDEDIR  ?= $(includedir)
  386 bindir      ?= $(EXEC_PREFIX)/bin
  387 BINDIR      ?= $(bindir)
  388 datarootdir ?= $(PREFIX)/share
  389 mandir      ?= $(datarootdir)/man
  390 man1dir     ?= $(mandir)/man1
  391 
  392 ifneq (,$(filter $(UNAME),FreeBSD NetBSD DragonFly))
  393 PKGCONFIGDIR ?= $(PREFIX)/libdata/pkgconfig
  394 else
  395 PKGCONFIGDIR ?= $(LIBDIR)/pkgconfig
  396 endif
  397 
  398 ifneq (,$(filter $(UNAME),OpenBSD FreeBSD NetBSD DragonFly SunOS))
  399 MANDIR  ?= $(PREFIX)/man/man1
  400 else
  401 MANDIR  ?= $(man1dir)
  402 endif
  403 
  404 ifneq (,$(filter $(UNAME),SunOS))
  405 INSTALL ?= ginstall
  406 else
  407 INSTALL ?= install
  408 endif
  409 
  410 INSTALL_PROGRAM ?= $(INSTALL)
  411 INSTALL_DATA    ?= $(INSTALL) -m 644
  412 
  413 
  414 PCLIBDIR ?= $(shell echo "$(LIBDIR)"     | $(SED) -n $(SED_ERE_OPT) -e "s@^$(EXEC_PREFIX)(/|$$)@@p")
  415 PCINCDIR ?= $(shell echo "$(INCLUDEDIR)" | $(SED) -n $(SED_ERE_OPT) -e "s@^$(PREFIX)(/|$$)@@p")
  416 PCEXECDIR?= $(if $(filter $(PREFIX),$(EXEC_PREFIX)),$$\{prefix\},$(EXEC_PREFIX))
  417 
  418 ifeq (,$(PCLIBDIR))
  419 # Additional prefix check is required, since the empty string is technically a
  420 # valid PCLIBDIR
  421 ifeq (,$(shell echo "$(LIBDIR)" | $(SED) -n $(SED_ERE_OPT) -e "\\@^$(EXEC_PREFIX)(/|$$)@ p"))
  422 $(error configured libdir ($(LIBDIR)) is outside of exec_prefix ($(EXEC_PREFIX)), can't generate pkg-config file)
  423 endif
  424 endif
  425 
  426 ifeq (,$(PCINCDIR))
  427 # Additional prefix check is required, since the empty string is technically a
  428 # valid PCINCDIR
  429 ifeq (,$(shell echo "$(INCLUDEDIR)" | $(SED) -n $(SED_ERE_OPT) -e "\\@^$(PREFIX)(/|$$)@ p"))
  430 $(error configured includedir ($(INCLUDEDIR)) is outside of prefix ($(PREFIX)), can't generate pkg-config file)
  431 endif
  432 endif
  433 
  434 libxxhash.pc: libxxhash.pc.in
  435 	@echo creating pkgconfig
  436 	$(Q)$(SED) $(SED_ERE_OPT) -e 's|@PREFIX@|$(PREFIX)|' \
  437           -e 's|@EXECPREFIX@|$(PCEXECDIR)|' \
  438           -e 's|@LIBDIR@|$(PCLIBDIR)|' \
  439           -e 's|@INCLUDEDIR@|$(PCINCDIR)|' \
  440           -e 's|@VERSION@|$(VERSION)|' \
  441           $< > $@
  442 
  443 
  444 .PHONY: install
  445 install: lib libxxhash.pc xxhsum  ## install libraries, CLI, links and man page
  446 	@echo Installing libxxhash
  447 	$(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)
  448 	$(Q)$(INSTALL_DATA) libxxhash.a $(DESTDIR)$(LIBDIR)
  449 	$(Q)$(INSTALL_PROGRAM) $(LIBXXH) $(DESTDIR)$(LIBDIR)
  450 	$(Q)ln -sf $(LIBXXH) $(DESTDIR)$(LIBDIR)/libxxhash.$(SHARED_EXT_MAJOR)
  451 	$(Q)ln -sf $(LIBXXH) $(DESTDIR)$(LIBDIR)/libxxhash.$(SHARED_EXT)
  452 	$(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(INCLUDEDIR)   # includes
  453 	$(Q)$(INSTALL_DATA) xxhash.h $(DESTDIR)$(INCLUDEDIR)
  454 	$(Q)$(INSTALL_DATA) xxh3.h $(DESTDIR)$(INCLUDEDIR) # for compatibility, will be removed in v0.9.0
  455 ifeq ($(DISPATCH),1)
  456 	$(Q)$(INSTALL_DATA) xxh_x86dispatch.h $(DESTDIR)$(INCLUDEDIR)
  457 endif
  458 	@echo Installing pkgconfig
  459 	$(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(PKGCONFIGDIR)/
  460 	$(Q)$(INSTALL_DATA) libxxhash.pc $(DESTDIR)$(PKGCONFIGDIR)/
  461 	@echo Installing xxhsum
  462 	$(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(BINDIR)/ $(DESTDIR)$(MANDIR)/
  463 	$(Q)$(INSTALL_PROGRAM) xxhsum $(DESTDIR)$(BINDIR)/xxhsum
  464 	$(Q)ln -sf xxhsum $(DESTDIR)$(BINDIR)/xxh32sum
  465 	$(Q)ln -sf xxhsum $(DESTDIR)$(BINDIR)/xxh64sum
  466 	$(Q)ln -sf xxhsum $(DESTDIR)$(BINDIR)/xxh128sum
  467 	@echo Installing man pages
  468 	$(Q)$(INSTALL_DATA) xxhsum.1 $(DESTDIR)$(MANDIR)/xxhsum.1
  469 	$(Q)ln -sf xxhsum.1 $(DESTDIR)$(MANDIR)/xxh32sum.1
  470 	$(Q)ln -sf xxhsum.1 $(DESTDIR)$(MANDIR)/xxh64sum.1
  471 	$(Q)ln -sf xxhsum.1 $(DESTDIR)$(MANDIR)/xxh128sum.1
  472 	@echo xxhash installation completed
  473 
  474 .PHONY: uninstall
  475 uninstall:  ## uninstall libraries, CLI, links and man page
  476 	$(Q)$(RM) $(DESTDIR)$(LIBDIR)/libxxhash.a
  477 	$(Q)$(RM) $(DESTDIR)$(LIBDIR)/libxxhash.$(SHARED_EXT)
  478 	$(Q)$(RM) $(DESTDIR)$(LIBDIR)/libxxhash.$(SHARED_EXT_MAJOR)
  479 	$(Q)$(RM) $(DESTDIR)$(LIBDIR)/$(LIBXXH)
  480 	$(Q)$(RM) $(DESTDIR)$(INCLUDEDIR)/xxhash.h
  481 	$(Q)$(RM) $(DESTDIR)$(INCLUDEDIR)/xxh3.h
  482 	$(Q)$(RM) $(DESTDIR)$(INCLUDEDIR)/xxh_x86dispatch.h
  483 	$(Q)$(RM) $(DESTDIR)$(PKGCONFIGDIR)/libxxhash.pc
  484 	$(Q)$(RM) $(DESTDIR)$(BINDIR)/xxh32sum
  485 	$(Q)$(RM) $(DESTDIR)$(BINDIR)/xxh64sum
  486 	$(Q)$(RM) $(DESTDIR)$(BINDIR)/xxh128sum
  487 	$(Q)$(RM) $(DESTDIR)$(BINDIR)/xxhsum
  488 	$(Q)$(RM) $(DESTDIR)$(MANDIR)/xxh32sum.1
  489 	$(Q)$(RM) $(DESTDIR)$(MANDIR)/xxh64sum.1
  490 	$(Q)$(RM) $(DESTDIR)$(MANDIR)/xxh128sum.1
  491 	$(Q)$(RM) $(DESTDIR)$(MANDIR)/xxhsum.1
  492 	@echo xxhsum successfully uninstalled
  493 
  494 endif