Merge branch 'dev' into btultra2
This commit is contained in:
+16
-6
@@ -29,7 +29,12 @@ LIBVER := $(shell echo $(LIBVER_SCRIPT))
|
||||
|
||||
ZSTD_VERSION = $(LIBVER)
|
||||
|
||||
GREP = grep --color=never
|
||||
HAVE_COLORNEVER = $(shell echo a | grep --color=never a > /dev/null 2> /dev/null && echo 1 || echo 0)
|
||||
GREP_OPTIONS ?=
|
||||
ifeq ($HAVE_COLORNEVER, 1)
|
||||
GREP_OPTIONS += --color=never
|
||||
endif
|
||||
GREP = grep $(GREP_OPTIONS)
|
||||
|
||||
ifeq ($(shell $(CC) -v 2>&1 | $(GREP) -c "gcc version "), 1)
|
||||
ALIGN_LOOP = -falign-loops=32
|
||||
@@ -91,7 +96,7 @@ VOID = /dev/null
|
||||
|
||||
# thread detection
|
||||
NO_THREAD_MSG := ==> no threads, building without multithreading support
|
||||
HAVE_PTHREAD := $(shell printf '\#include <pthread.h>\nint main(void) { return 0; }' | $(CC) $(FLAGS) -o have_pthread$(EXT) -x c - -pthread 2> $(VOID) && rm have_pthread$(EXT) && echo 1 || echo 0)
|
||||
HAVE_PTHREAD := $(shell printf '\#include <pthread.h>\nint main(void) { return 0; }' > have_pthread.c && $(CC) $(FLAGS) -o have_pthread$(EXT) have_pthread.c -pthread 2> $(VOID) && rm have_pthread$(EXT) && echo 1 || echo 0; rm have_pthread.c)
|
||||
HAVE_THREAD := $(shell [ "$(HAVE_PTHREAD)" -eq "1" -o -n "$(filter Windows%,$(OS))" ] && echo 1 || echo 0)
|
||||
ifeq ($(HAVE_THREAD), 1)
|
||||
THREAD_MSG := ==> building with threading support
|
||||
@@ -103,7 +108,7 @@ endif
|
||||
|
||||
# zlib detection
|
||||
NO_ZLIB_MSG := ==> no zlib, building zstd without .gz support
|
||||
HAVE_ZLIB := $(shell printf '\#include <zlib.h>\nint main(void) { return 0; }' | $(CC) $(FLAGS) -o have_zlib$(EXT) -x c - -lz 2> $(VOID) && rm have_zlib$(EXT) && echo 1 || echo 0)
|
||||
HAVE_ZLIB := $(shell printf '\#include <zlib.h>\nint main(void) { return 0; }' > have_zlib.c && $(CC) $(FLAGS) -o have_zlib$(EXT) have_zlib.c -lz 2> $(VOID) && rm have_zlib$(EXT) && echo 1 || echo 0; rm have_zlib.c)
|
||||
ifeq ($(HAVE_ZLIB), 1)
|
||||
ZLIB_MSG := ==> building zstd with .gz compression support
|
||||
ZLIBCPP = -DZSTD_GZCOMPRESS -DZSTD_GZDECOMPRESS
|
||||
@@ -114,7 +119,7 @@ endif
|
||||
|
||||
# lzma detection
|
||||
NO_LZMA_MSG := ==> no liblzma, building zstd without .xz/.lzma support
|
||||
HAVE_LZMA := $(shell printf '\#include <lzma.h>\nint main(void) { return 0; }' | $(CC) $(FLAGS) -o have_lzma$(EXT) -x c - -llzma 2> $(VOID) && rm have_lzma$(EXT) && echo 1 || echo 0)
|
||||
HAVE_LZMA := $(shell printf '\#include <lzma.h>\nint main(void) { return 0; }' > have_lzma.c && $(CC) $(FLAGS) -o have_lzma$(EXT) have_lzma.c -llzma 2> $(VOID) && rm have_lzma$(EXT) && echo 1 || echo 0; rm have_lzma.c)
|
||||
ifeq ($(HAVE_LZMA), 1)
|
||||
LZMA_MSG := ==> building zstd with .xz/.lzma compression support
|
||||
LZMACPP = -DZSTD_LZMACOMPRESS -DZSTD_LZMADECOMPRESS
|
||||
@@ -125,7 +130,7 @@ endif
|
||||
|
||||
# lz4 detection
|
||||
NO_LZ4_MSG := ==> no liblz4, building zstd without .lz4 support
|
||||
HAVE_LZ4 := $(shell printf '\#include <lz4frame.h>\n\#include <lz4.h>\nint main(void) { return 0; }' | $(CC) $(FLAGS) -o have_lz4$(EXT) -x c - -llz4 2> $(VOID) && rm have_lz4$(EXT) && echo 1 || echo 0)
|
||||
HAVE_LZ4 := $(shell printf '\#include <lz4frame.h>\n\#include <lz4.h>\nint main(void) { return 0; }' > have_lz4.c && $(CC) $(FLAGS) -o have_lz4$(EXT) have_lz4.c -llz4 2> $(VOID) && rm have_lz4$(EXT) && echo 1 || echo 0; rm have_lz4.c)
|
||||
ifeq ($(HAVE_LZ4), 1)
|
||||
LZ4_MSG := ==> building zstd with .lz4 compression support
|
||||
LZ4CPP = -DZSTD_LZ4COMPRESS -DZSTD_LZ4DECOMPRESS
|
||||
@@ -275,7 +280,12 @@ preview-man: clean-man man
|
||||
#-----------------------------------------------------------------------------
|
||||
ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku))
|
||||
|
||||
EGREP = egrep --color=never
|
||||
HAVE_COLORNEVER = $(shell echo a | egrep --color=never a > /dev/null 2> /dev/null && echo 1 || echo 0)
|
||||
EGREP_OPTIONS ?=
|
||||
ifeq ($HAVE_COLORNEVER, 1)
|
||||
EGREP_OPTIONS += --color=never
|
||||
endif
|
||||
EGREP = egrep $(EGREP_OPTIONS)
|
||||
|
||||
# Print a two column output of targets and their description. To add a target description, put a
|
||||
# comment in the Makefile with the format "## <TARGET>: <DESCRIPTION>". For example:
|
||||
|
||||
+1
-1
@@ -151,7 +151,7 @@ static int usage_advanced(const char* programName)
|
||||
#ifdef UTIL_HAS_CREATEFILELIST
|
||||
DISPLAY( " -r : operate recursively on directories \n");
|
||||
#endif
|
||||
DISPLAY( "--format=zstd : compress files to the .zstd format (default) \n");
|
||||
DISPLAY( "--format=zstd : compress files to the .zst format (default) \n");
|
||||
#ifdef ZSTD_GZCOMPRESS
|
||||
DISPLAY( "--format=gzip : compress files to the .gz format \n");
|
||||
#endif
|
||||
|
||||
+74
-67
@@ -31,94 +31,101 @@ grep_args=""
|
||||
hyphen=0
|
||||
silent=0
|
||||
|
||||
prg=$(basename $0)
|
||||
prg=$(basename "$0")
|
||||
|
||||
# handle being called 'zegrep' or 'zfgrep'
|
||||
case ${prg} in
|
||||
*zegrep)
|
||||
grep_args="-E";;
|
||||
*zfgrep)
|
||||
grep_args="-F";;
|
||||
case "${prg}" in
|
||||
*zegrep) grep_args="-E";;
|
||||
*zfgrep) grep_args="-F";;
|
||||
esac
|
||||
|
||||
# skip all options and pass them on to grep taking care of options
|
||||
# with arguments, and if -e was supplied
|
||||
|
||||
while [ $# -gt 0 -a ${endofopts} -eq 0 ]
|
||||
do
|
||||
case $1 in
|
||||
while [ "$#" -gt 0 ] && [ "${endofopts}" -eq 0 ]; do
|
||||
case "$1" in
|
||||
# from GNU grep-2.5.1 -- keep in sync!
|
||||
-[ABCDXdefm])
|
||||
if [ $# -lt 2 ]
|
||||
then
|
||||
echo "${prg}: missing argument for $1 flag" >&2
|
||||
exit 1
|
||||
fi
|
||||
case $1 in
|
||||
-e)
|
||||
pattern="$2"
|
||||
pattern_found=1
|
||||
shift 2
|
||||
break
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
grep_args="${grep_args} $1 $2"
|
||||
shift 2
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
endofopts=1
|
||||
;;
|
||||
-)
|
||||
hyphen=1
|
||||
shift
|
||||
;;
|
||||
-h)
|
||||
silent=1
|
||||
shift
|
||||
;;
|
||||
-*)
|
||||
grep_args="${grep_args} $1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
# pattern to grep for
|
||||
endofopts=1
|
||||
;;
|
||||
-[ABCDXdefm])
|
||||
if [ "$#" -lt 2 ]; then
|
||||
printf '%s: missing argument for %s flag\n' "${prg}" "$1" >&2
|
||||
exit 1
|
||||
fi
|
||||
case "$1" in
|
||||
-e)
|
||||
pattern="$2"
|
||||
pattern_found=1
|
||||
shift 2
|
||||
break
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
grep_args="${grep_args} $1 $2"
|
||||
shift 2
|
||||
;;
|
||||
--)
|
||||
shift
|
||||
endofopts=1
|
||||
;;
|
||||
-)
|
||||
hyphen=1
|
||||
shift
|
||||
;;
|
||||
-h)
|
||||
silent=1
|
||||
shift
|
||||
;;
|
||||
-*)
|
||||
grep_args="${grep_args} $1"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
# pattern to grep for
|
||||
endofopts=1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# if no -e option was found, take next argument as grep-pattern
|
||||
if [ ${pattern_found} -lt 1 ]
|
||||
then
|
||||
if [ $# -ge 1 ]; then
|
||||
pattern="$1"
|
||||
shift
|
||||
elif [ ${hyphen} -gt 0 ]; then
|
||||
pattern="-"
|
||||
if [ "${pattern_found}" -lt 1 ]; then
|
||||
if [ "$#" -ge 1 ]; then
|
||||
pattern="$1"
|
||||
shift
|
||||
elif [ "${hyphen}" -gt 0 ]; then
|
||||
pattern="-"
|
||||
else
|
||||
echo "${prg}: missing pattern" >&2
|
||||
exit 1
|
||||
printf '%s: missing pattern\n' "${prg}" >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
EXIT_CODE=0
|
||||
# call grep ...
|
||||
if [ $# -lt 1 ]
|
||||
then
|
||||
if [ "$#" -lt 1 ]; then
|
||||
# ... on stdin
|
||||
${zcat} -fq - | ${grep} ${grep_args} -- "${pattern}" -
|
||||
set -f # Disable file name generation (globbing).
|
||||
# shellcheck disable=SC2086
|
||||
"${zcat}" -fq - | "${grep}" ${grep_args} -- "${pattern}" -
|
||||
EXIT_CODE=$?
|
||||
set +f
|
||||
else
|
||||
# ... on all files given on the command line
|
||||
if [ ${silent} -lt 1 -a $# -gt 1 ]; then
|
||||
grep_args="-H ${grep_args}"
|
||||
if [ "${silent}" -lt 1 ] && [ "$#" -gt 1 ]; then
|
||||
grep_args="-H ${grep_args}"
|
||||
fi
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
${zcat} -fq -- "$1" | ${grep} --label="${1}" ${grep_args} -- "${pattern}" -
|
||||
shift
|
||||
CUR_EXIT_CODE=0
|
||||
EXIT_CODE=1
|
||||
set -f
|
||||
while [ "$#" -gt 0 ]; do
|
||||
# shellcheck disable=SC2086
|
||||
"${zcat}" -fq -- "$1" | "${grep}" --label="${1}" ${grep_args} -- "${pattern}" -
|
||||
CUR_EXIT_CODE=$?
|
||||
if [ "${CUR_EXIT_CODE}" -eq 0 ] && [ "${EXIT_CODE}" -ne 1 ]; then
|
||||
EXIT_CODE=0
|
||||
fi
|
||||
shift
|
||||
done
|
||||
set +f
|
||||
fi
|
||||
|
||||
exit 0
|
||||
exit "${EXIT_CODE}"
|
||||
|
||||
Reference in New Issue
Block a user