Merge pull request #2373 from facebook/libzstd_autoconf_full
Automatic detection of configuration changesdev
commit
bb4ea40e4d
202
lib/Makefile
202
lib/Makefile
|
@ -8,15 +8,16 @@
|
|||
# You may select, at your option, one of the above-listed licenses.
|
||||
# ################################################################
|
||||
|
||||
Q = $(if $(filter 1,$(V) $(VERBOSE)),,@)
|
||||
.PHONY: default
|
||||
default: lib-release
|
||||
|
||||
# define silent mode as default (verbose mode with V=1 or VERBOSE=1)
|
||||
$(V)$(VERBOSE).SILENT:
|
||||
|
||||
# When cross-compiling from linux to windows,
|
||||
# you might need to specify this as "Windows."
|
||||
# Fedora build fails without it.
|
||||
#
|
||||
# Note: mingw-w64 build from linux to windows
|
||||
# does not fail on other tested distros (ubuntu, debian)
|
||||
# even without manually specifying the TARGET_SYSTEM.
|
||||
# one might need to specify TARGET_SYSTEM as "Windows."
|
||||
# Building from Fedora fails without it.
|
||||
# (but Ubuntu and Debian don't need to set anything)
|
||||
TARGET_SYSTEM ?= $(OS)
|
||||
|
||||
# Version numbers
|
||||
|
@ -31,8 +32,8 @@ LIBVER := $(shell echo $(LIBVER_SCRIPT))
|
|||
VERSION?= $(LIBVER)
|
||||
CCVER := $(shell $(CC) --version)
|
||||
|
||||
# This is a helper variable that configures a bunch of other variables to new,
|
||||
# space-optimized defaults.
|
||||
# ZSTD_LIB_MINIFY is a helper variable that
|
||||
# configures a bunch of other variables to space-optimized defaults.
|
||||
ZSTD_LIB_MINIFY ?= 0
|
||||
ifneq ($(ZSTD_LIB_MINIFY), 0)
|
||||
HAVE_CC_OZ ?= $(shell echo "" | $(CC) -Oz -x c -c - -o /dev/null 2> /dev/null && echo 1 || echo 0)
|
||||
|
@ -172,33 +173,26 @@ ZSTD_SUBDIR := common compress decompress dictBuilder legacy deprecated
|
|||
vpath %.c $(ZSTD_SUBDIR)
|
||||
|
||||
UNAME := $(shell uname)
|
||||
|
||||
ifndef BUILD_DIR
|
||||
ifeq ($(UNAME), Darwin)
|
||||
HASH ?= md5
|
||||
endif
|
||||
ifeq ($(UNAME), FreeBSD)
|
||||
else ifeq ($(UNAME), FreeBSD)
|
||||
HASH ?= gmd5sum
|
||||
endif
|
||||
ifeq ($(UNAME), OpenBSD)
|
||||
else ifeq ($(UNAME), OpenBSD)
|
||||
HASH ?= md5
|
||||
endif
|
||||
HASH ?= md5sum
|
||||
|
||||
HAVE_HASH := $(shell echo 1 | $(HASH) > /dev/null && echo 1 || echo 0)
|
||||
ifeq ($(HAVE_HASH), 1)
|
||||
HASH_VALUE := $(shell echo $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(ZSTD_FILES) | $(HASH) | dd bs=1 count=16 status=none)
|
||||
HASH_DIR := conf_$(HASH_VALUE)
|
||||
else
|
||||
$(info warning : could not find hash function to differentiate builds with different flags)
|
||||
HASH_DIR := 0
|
||||
HASH_DIR = conf_$(shell echo $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(ZSTD_FILES) | $(HASH) | cut -f 1 -d " " )
|
||||
HAVE_HASH :=$(shell echo 1 | $(HASH) > /dev/null && echo 1 || echo 0)
|
||||
ifeq ($(HAVE_HASH),0)
|
||||
$(info warning : could not find HASH ($(HASH)), needed to differentiate builds using different flags)
|
||||
BUILD_DIR := obj/generic_noconf
|
||||
endif
|
||||
endif # BUILD_DIR
|
||||
|
||||
|
||||
BUILD_DIR ?= obj/$(HASH_DIR)
|
||||
ZSTD_DYNLIB_DIR := $(BUILD_DIR)/dynlib
|
||||
ZSTD_DYNLIB_OBJ := $(addprefix $(ZSTD_DYNLIB_DIR)/, $(ZSTD_LOCAL_OBJ))
|
||||
ZSTD_STATLIB_DIR := $(BUILD_DIR)/statlib
|
||||
ZSTD_STATLIB_OBJ := $(addprefix $(ZSTD_STATLIB_DIR)/, $(ZSTD_LOCAL_OBJ))
|
||||
|
||||
# macOS linker doesn't support -soname, and use different extension
|
||||
# see : https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html
|
||||
ifeq ($(UNAME), Darwin)
|
||||
|
@ -213,52 +207,86 @@ else
|
|||
SHARED_EXT_VER = $(SHARED_EXT).$(LIBVER)
|
||||
endif
|
||||
|
||||
SET_CACHE_DIRECTORY = \
|
||||
$(MAKE) --no-print-directory $@ \
|
||||
BUILD_DIR=obj/$(HASH_DIR) \
|
||||
CPPFLAGS="$(CPPFLAGS)" \
|
||||
CFLAGS="$(CFLAGS)" \
|
||||
LDFLAGS="$(LDFLAGS)"
|
||||
|
||||
.PHONY: default lib-all all clean install uninstall
|
||||
|
||||
default: lib-release
|
||||
.PHONY: lib-all all clean install uninstall
|
||||
|
||||
# alias
|
||||
lib-all: all
|
||||
|
||||
all: lib
|
||||
|
||||
$(ZSTD_STATLIB_DIR)/libzstd.a: ARFLAGS = rcs
|
||||
$(ZSTD_STATLIB_DIR)/libzstd.a: | $(ZSTD_STATLIB_DIR)
|
||||
$(ZSTD_STATLIB_DIR)/libzstd.a: $(ZSTD_STATLIB_OBJ)
|
||||
@echo compiling static library
|
||||
$(Q)$(AR) $(ARFLAGS) $@ $^
|
||||
|
||||
.PHONY: libzstd.a # must be run every time
|
||||
libzstd.a: $(ZSTD_STATLIB_DIR)/libzstd.a
|
||||
$(Q)ln -sf $< $@
|
||||
|
||||
ifndef BUILD_DIR
|
||||
# determine BUILD_DIR from compilation flags
|
||||
|
||||
libzstd.a:
|
||||
$(SET_CACHE_DIRECTORY)
|
||||
|
||||
else
|
||||
# BUILD_DIR is defined
|
||||
|
||||
ZSTD_STATLIB_DIR := $(BUILD_DIR)/static
|
||||
ZSTD_STATLIB := $(ZSTD_STATLIB_DIR)/libzstd.a
|
||||
ZSTD_STATLIB_OBJ := $(addprefix $(ZSTD_STATLIB_DIR)/,$(ZSTD_LOCAL_OBJ))
|
||||
$(ZSTD_STATLIB): ARFLAGS = rcs
|
||||
$(ZSTD_STATLIB): | $(ZSTD_STATLIB_DIR)
|
||||
$(ZSTD_STATLIB): $(ZSTD_STATLIB_OBJ)
|
||||
@echo compiling static library
|
||||
$(AR) $(ARFLAGS) $@ $^
|
||||
|
||||
libzstd.a: $(ZSTD_STATLIB)
|
||||
ln -sf $< $@
|
||||
|
||||
endif
|
||||
|
||||
ifneq (,$(filter Windows%,$(TARGET_SYSTEM)))
|
||||
|
||||
LIBZSTD = dll\libzstd.dll
|
||||
$(LIBZSTD):
|
||||
$(LIBZSTD): $(ZSTD_FILES)
|
||||
@echo compiling dynamic library $(LIBVER)
|
||||
$(CC) $(FLAGS) -DZSTD_DLL_EXPORT=1 -Wl,--out-implib,dll\libzstd.dll.a -shared $^ -o $@
|
||||
|
||||
else
|
||||
else # not Windows
|
||||
|
||||
LIBZSTD = libzstd.$(SHARED_EXT_VER)
|
||||
$(ZSTD_DYNLIB_DIR)/$(LIBZSTD): CFLAGS += -fPIC
|
||||
$(ZSTD_DYNLIB_DIR)/$(LIBZSTD): LDFLAGS += -shared -fvisibility=hidden
|
||||
$(ZSTD_DYNLIB_DIR)/$(LIBZSTD): | $(ZSTD_DYNLIB_DIR)
|
||||
$(ZSTD_DYNLIB_DIR)/$(LIBZSTD): $(ZSTD_DYNLIB_OBJ)
|
||||
@echo compiling dynamic library $(LIBVER)
|
||||
$(Q)$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
|
||||
@echo creating versioned links
|
||||
$(Q)ln -sf $@ libzstd.$(SHARED_EXT_MAJOR)
|
||||
$(Q)ln -sf $@ libzstd.$(SHARED_EXT)
|
||||
|
||||
.PHONY: $(LIBZSTD) # must be run every time
|
||||
$(LIBZSTD): $(ZSTD_DYNLIB_DIR)/$(LIBZSTD)
|
||||
$(Q)ln -sf $< $@
|
||||
$(LIBZSTD): CFLAGS += -fPIC
|
||||
$(LIBZSTD): LDFLAGS += -shared -fvisibility=hidden
|
||||
|
||||
endif
|
||||
ifndef BUILD_DIR
|
||||
# determine BUILD_DIR from compilation flags
|
||||
|
||||
$(LIBZSTD):
|
||||
$(SET_CACHE_DIRECTORY)
|
||||
|
||||
else
|
||||
# BUILD_DIR is defined
|
||||
|
||||
ZSTD_DYNLIB_DIR := $(BUILD_DIR)/dynamic
|
||||
ZSTD_DYNLIB := $(ZSTD_DYNLIB_DIR)/$(LIBZSTD)
|
||||
ZSTD_DYNLIB_OBJ := $(addprefix $(ZSTD_DYNLIB_DIR)/,$(ZSTD_LOCAL_OBJ))
|
||||
|
||||
$(ZSTD_DYNLIB): | $(ZSTD_DYNLIB_DIR)
|
||||
$(ZSTD_DYNLIB): $(ZSTD_DYNLIB_OBJ)
|
||||
@echo compiling dynamic library $(LIBVER)
|
||||
$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
|
||||
@echo creating versioned links
|
||||
ln -sf $@ libzstd.$(SHARED_EXT_MAJOR)
|
||||
ln -sf $@ libzstd.$(SHARED_EXT)
|
||||
|
||||
$(LIBZSTD): $(ZSTD_DYNLIB)
|
||||
ln -sf $< $@
|
||||
|
||||
endif # ifndef BUILD_DIR
|
||||
endif # if windows
|
||||
|
||||
.PHONY: libzstd
|
||||
libzstd : $(LIBZSTD)
|
||||
|
@ -285,16 +313,16 @@ lib : libzstd.a libzstd
|
|||
DEPFLAGS = -MT $@ -MMD -MP -MF
|
||||
|
||||
$(ZSTD_DYNLIB_DIR)/%.o : %.c $(ZSTD_DYNLIB_DIR)/%.d | $(ZSTD_DYNLIB_DIR)
|
||||
@echo $@
|
||||
$(Q)$(COMPILE.c) $(DEPFLAGS) $(ZSTD_DYNLIB_DIR)/$*.d $(OUTPUT_OPTION) $<
|
||||
@echo CC $@
|
||||
$(COMPILE.c) $(DEPFLAGS) $(ZSTD_DYNLIB_DIR)/$*.d $(OUTPUT_OPTION) $<
|
||||
|
||||
$(ZSTD_STATLIB_DIR)/%.o : %.c $(ZSTD_STATLIB_DIR)/%.d | $(ZSTD_STATLIB_DIR)
|
||||
@echo $@
|
||||
$(Q)$(COMPILE.c) $(DEPFLAGS) $(ZSTD_STATLIB_DIR)/$*.d $(OUTPUT_OPTION) $<
|
||||
@echo CC $@
|
||||
$(COMPILE.c) $(DEPFLAGS) $(ZSTD_STATLIB_DIR)/$*.d $(OUTPUT_OPTION) $<
|
||||
|
||||
MKDIR ?= mkdir
|
||||
$(ZSTD_DYNLIB_DIR) $(ZSTD_STATLIB_DIR):
|
||||
$(Q)$(MKDIR) -p $@
|
||||
$(BUILD_DIR) $(ZSTD_DYNLIB_DIR) $(ZSTD_STATLIB_DIR):
|
||||
$(MKDIR) -p $@
|
||||
|
||||
DEPFILES := $(ZSTD_DYNLIB_OBJ:.o=.d) $(ZSTD_STATLIB_OBJ:.o=.d)
|
||||
$(DEPFILES):
|
||||
|
@ -309,13 +337,13 @@ libzstd-nomt: LDFLAGS += -shared -fPIC -fvisibility=hidden
|
|||
libzstd-nomt: $(ZSTD_NOMT_FILES)
|
||||
@echo compiling single-thread dynamic library $(LIBVER)
|
||||
@echo files : $(ZSTD_NOMT_FILES)
|
||||
$(Q)$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
|
||||
$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
|
||||
|
||||
clean:
|
||||
$(Q)$(RM) -r *.dSYM # macOS-specific
|
||||
$(Q)$(RM) core *.o *.a *.gcda *.$(SHARED_EXT) *.$(SHARED_EXT).* libzstd.pc
|
||||
$(Q)$(RM) dll/libzstd.dll dll/libzstd.lib libzstd-nomt*
|
||||
$(Q)$(RM) -r obj/*
|
||||
$(RM) -r *.dSYM # macOS-specific
|
||||
$(RM) core *.o *.a *.gcda *.$(SHARED_EXT) *.$(SHARED_EXT).* libzstd.pc
|
||||
$(RM) dll/libzstd.dll dll/libzstd.lib libzstd-nomt*
|
||||
$(RM) -r obj/*
|
||||
@echo Cleaning library completed
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
@ -376,7 +404,7 @@ INSTALL_DATA ?= $(INSTALL) -m 644
|
|||
libzstd.pc:
|
||||
libzstd.pc: libzstd.pc.in
|
||||
@echo creating pkgconfig
|
||||
$(Q)@sed $(SED_ERE_OPT) -e 's|@PREFIX@|$(PREFIX)|' \
|
||||
@sed $(SED_ERE_OPT) -e 's|@PREFIX@|$(PREFIX)|' \
|
||||
-e 's|@LIBDIR@|$(PCLIBDIR)|' \
|
||||
-e 's|@INCLUDEDIR@|$(PCINCDIR)|' \
|
||||
-e 's|@VERSION@|$(VERSION)|' \
|
||||
|
@ -386,37 +414,41 @@ install: install-pc install-static install-shared install-includes
|
|||
@echo zstd static and shared library installed
|
||||
|
||||
install-pc: libzstd.pc
|
||||
$(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(PKGCONFIGDIR)/
|
||||
$(Q)$(INSTALL_DATA) libzstd.pc $(DESTDIR)$(PKGCONFIGDIR)/
|
||||
[ -e $(DESTDIR)$(PKGCONFIGDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(PKGCONFIGDIR)/
|
||||
$(INSTALL_DATA) libzstd.pc $(DESTDIR)$(PKGCONFIGDIR)/
|
||||
|
||||
install-static: libzstd.a
|
||||
install-static:
|
||||
# only generate libzstd.a if it's not already present
|
||||
[ -e libzstd.a ] || $(MAKE) libzstd.a-release
|
||||
[ -e $(DESTDIR)$(LIBDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/
|
||||
@echo Installing static library
|
||||
$(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/
|
||||
$(Q)$(INSTALL_DATA) libzstd.a $(DESTDIR)$(LIBDIR)
|
||||
$(INSTALL_DATA) libzstd.a $(DESTDIR)$(LIBDIR)
|
||||
|
||||
install-shared: libzstd
|
||||
install-shared:
|
||||
# only generate libzstd.so if it's not already present
|
||||
[ -e $(LIBZSTD) ] || $(MAKE) libzstd-release
|
||||
[ -e $(DESTDIR)$(LIBDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/
|
||||
@echo Installing shared library
|
||||
$(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/
|
||||
$(Q)$(INSTALL_PROGRAM) $(LIBZSTD) $(DESTDIR)$(LIBDIR)
|
||||
$(Q)ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR)
|
||||
$(Q)ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
|
||||
$(INSTALL_PROGRAM) $(LIBZSTD) $(DESTDIR)$(LIBDIR)
|
||||
ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR)
|
||||
ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
|
||||
|
||||
install-includes:
|
||||
[ -e $(DESTDIR)$(INCLUDEDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(INCLUDEDIR)/
|
||||
@echo Installing includes
|
||||
$(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(INCLUDEDIR)/
|
||||
$(Q)$(INSTALL_DATA) zstd.h $(DESTDIR)$(INCLUDEDIR)
|
||||
$(Q)$(INSTALL_DATA) common/zstd_errors.h $(DESTDIR)$(INCLUDEDIR)
|
||||
$(Q)$(INSTALL_DATA) dictBuilder/zdict.h $(DESTDIR)$(INCLUDEDIR)
|
||||
$(INSTALL_DATA) zstd.h $(DESTDIR)$(INCLUDEDIR)
|
||||
$(INSTALL_DATA) common/zstd_errors.h $(DESTDIR)$(INCLUDEDIR)
|
||||
$(INSTALL_DATA) dictBuilder/zdict.h $(DESTDIR)$(INCLUDEDIR)
|
||||
|
||||
uninstall:
|
||||
$(Q)$(RM) $(DESTDIR)$(LIBDIR)/libzstd.a
|
||||
$(Q)$(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
|
||||
$(Q)$(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR)
|
||||
$(Q)$(RM) $(DESTDIR)$(LIBDIR)/$(LIBZSTD)
|
||||
$(Q)$(RM) $(DESTDIR)$(PKGCONFIGDIR)/libzstd.pc
|
||||
$(Q)$(RM) $(DESTDIR)$(INCLUDEDIR)/zstd.h
|
||||
$(Q)$(RM) $(DESTDIR)$(INCLUDEDIR)/zstd_errors.h
|
||||
$(Q)$(RM) $(DESTDIR)$(INCLUDEDIR)/zdict.h
|
||||
$(RM) $(DESTDIR)$(LIBDIR)/libzstd.a
|
||||
$(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT)
|
||||
$(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR)
|
||||
$(RM) $(DESTDIR)$(LIBDIR)/$(LIBZSTD)
|
||||
$(RM) $(DESTDIR)$(PKGCONFIGDIR)/libzstd.pc
|
||||
$(RM) $(DESTDIR)$(INCLUDEDIR)/zstd.h
|
||||
$(RM) $(DESTDIR)$(INCLUDEDIR)/zstd_errors.h
|
||||
$(RM) $(DESTDIR)$(INCLUDEDIR)/zdict.h
|
||||
@echo zstd libraries successfully uninstalled
|
||||
|
||||
endif
|
||||
|
|
|
@ -15,8 +15,12 @@
|
|||
# zstd-decompress : decompressor-only version of zstd
|
||||
# ##########################################################################
|
||||
|
||||
# verbose mode can be triggered by V=1 or VERBOSE=1
|
||||
Q = $(if $(filter 1,$(V) $(VERBOSE)),,@)
|
||||
.PHONY: default
|
||||
default: zstd-release
|
||||
|
||||
# silent mode by default; verbose can be triggered by V=1 or VERBOSE=1
|
||||
$(V)$(VERBOSE).SILENT:
|
||||
|
||||
|
||||
ZSTDDIR := ../lib
|
||||
|
||||
|
@ -94,28 +98,24 @@ ZSTD_ALL_SRC := $(ZSTDLIB_LOCAL_SRC) $(ZSTD_CLI_SRC)
|
|||
ZSTD_ALL_OBJ := $(ZSTD_ALL_SRC:.c=.o)
|
||||
|
||||
UNAME := $(shell uname)
|
||||
|
||||
ifndef BUILD_DIR
|
||||
ifeq ($(UNAME), Darwin)
|
||||
HASH ?= md5
|
||||
endif
|
||||
ifeq ($(UNAME), FreeBSD)
|
||||
else ifeq ($(UNAME), FreeBSD)
|
||||
HASH ?= gmd5sum
|
||||
endif
|
||||
ifeq ($(UNAME), OpenBSD)
|
||||
else ifeq ($(UNAME), OpenBSD)
|
||||
HASH ?= md5
|
||||
endif
|
||||
HASH ?= md5sum
|
||||
|
||||
HAVE_HASH := $(shell echo 1 | $(HASH) > /dev/null && echo 1 || echo 0)
|
||||
ifeq ($(HAVE_HASH), 1)
|
||||
HASH_VALUE := $(shell echo $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) | $(HASH) | dd bs=1 count=16 status=none)
|
||||
HASH_DIR := conf_$(HASH_VALUE)
|
||||
else
|
||||
$(info warning : could not find hash function to differentiate builds with different flags)
|
||||
HASH_DIR := 0
|
||||
HASH_DIR = conf_$(shell echo $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(ZSTD_FILES) | $(HASH) | cut -f 1 -d " ")
|
||||
HAVE_HASH :=$(shell echo 1 | $(HASH) > /dev/null && echo 1 || echo 0)
|
||||
ifeq ($(HAVE_HASH),0)
|
||||
$(info warning : could not find HASH ($(HASH)), needed to differentiate builds using different flags)
|
||||
BUILD_DIR := obj/generic_noconf
|
||||
endif
|
||||
|
||||
BUILD_DIR ?= obj/$(HASH_DIR)
|
||||
ZSTD_OBJ := $(addprefix $(BUILD_DIR)/, $(ZSTD_ALL_OBJ))
|
||||
endif # BUILD_DIR
|
||||
|
||||
# Define *.exe as extension for Windows systems
|
||||
ifneq (,$(filter Windows%,$(OS)))
|
||||
|
@ -192,9 +192,13 @@ ifeq ($(BACKTRACE), 1)
|
|||
endif
|
||||
endif
|
||||
|
||||
SET_CACHE_DIRECTORY = \
|
||||
$(MAKE) --no-print-directory $@ \
|
||||
BUILD_DIR=obj/$(HASH_DIR) \
|
||||
CPPFLAGS="$(CPPFLAGS)" \
|
||||
CFLAGS="$(CFLAGS)" \
|
||||
LDFLAGS="$(LDFLAGS)"
|
||||
|
||||
.PHONY: default
|
||||
default: zstd-release
|
||||
|
||||
.PHONY: all
|
||||
all: zstd
|
||||
|
@ -202,24 +206,39 @@ all: zstd
|
|||
.PHONY: allVariants
|
||||
allVariants: zstd zstd-compress zstd-decompress zstd-small zstd-nolegacy zstd-dictBuilder
|
||||
|
||||
$(BUILD_DIR)/zstd : $(ZSTD_OBJ)
|
||||
@echo "$(THREAD_MSG)"
|
||||
@echo "$(ZLIB_MSG)"
|
||||
@echo "$(LZMA_MSG)"
|
||||
@echo "$(LZ4_MSG)"
|
||||
$(Q)$(CC) $(FLAGS) $^ -o $@$(EXT) $(LDFLAGS)
|
||||
|
||||
.PHONY: zstd
|
||||
.PHONY: zstd # must always be run
|
||||
zstd : CPPFLAGS += $(THREAD_CPP) $(ZLIBCPP) $(LZMACPP) $(LZ4CPP)
|
||||
zstd : LDFLAGS += $(THREAD_LD) $(ZLIBLD) $(LZMALD) $(LZ4LD) $(DEBUGFLAGS_LD)
|
||||
zstd : CPPFLAGS += -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT)
|
||||
ifneq (,$(filter Windows%,$(OS)))
|
||||
zstd : $(RES_FILE)
|
||||
endif
|
||||
|
||||
ifndef BUILD_DIR
|
||||
# generate BUILD_DIR from flags
|
||||
|
||||
zstd:
|
||||
$(SET_CACHE_DIRECTORY)
|
||||
|
||||
else
|
||||
# BUILD_DIR is defined
|
||||
|
||||
ZSTD_OBJ := $(addprefix $(BUILD_DIR)/, $(ZSTD_ALL_OBJ))
|
||||
$(BUILD_DIR)/zstd : $(ZSTD_OBJ)
|
||||
@echo "$(THREAD_MSG)"
|
||||
@echo "$(ZLIB_MSG)"
|
||||
@echo "$(LZMA_MSG)"
|
||||
@echo "$(LZ4_MSG)"
|
||||
@echo LINK $@
|
||||
$(CC) $(FLAGS) $^ -o $@$(EXT) $(LDFLAGS)
|
||||
|
||||
zstd : $(BUILD_DIR)/zstd
|
||||
$(Q)ln -sf $< $@
|
||||
ln -sf $< $@
|
||||
@echo zstd build completed
|
||||
|
||||
endif # BUILD_DIR
|
||||
|
||||
|
||||
.PHONY: zstd-release
|
||||
zstd-release: DEBUGFLAGS := -DBACKTRACE_ENABLE=0
|
||||
zstd-release: DEBUGFLAGS_LD :=
|
||||
|
@ -315,11 +334,11 @@ endif
|
|||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
$(Q)$(RM) core *.o tmp* result* *.gcda dictionary *.zst \
|
||||
$(RM) core *.o tmp* result* *.gcda dictionary *.zst \
|
||||
zstd$(EXT) zstd32$(EXT) zstd-compress$(EXT) zstd-decompress$(EXT) \
|
||||
zstd-small$(EXT) zstd-frugal$(EXT) zstd-nolegacy$(EXT) zstd4$(EXT) \
|
||||
zstd-dictBuilder$(EXT) *.gcda default*.profraw default.profdata have_zlib$(EXT)
|
||||
$(Q)$(RM) -r obj/*
|
||||
$(RM) -r obj/*
|
||||
@echo Cleaning completed
|
||||
|
||||
MD2ROFF = ronn
|
||||
|
@ -355,11 +374,11 @@ preview-man: clean-man man
|
|||
DEPFLAGS = -MT $@ -MMD -MP -MF
|
||||
|
||||
$(BUILD_DIR)/%.o : %.c $(BUILD_DIR)/%.d | $(BUILD_DIR)
|
||||
@echo $@
|
||||
$(Q)$(COMPILE.c) $(DEPFLAGS) $(BUILD_DIR)/$*.d $(OUTPUT_OPTION) $<
|
||||
@echo CC $@
|
||||
$(COMPILE.c) $(DEPFLAGS) $(BUILD_DIR)/$*.d $(OUTPUT_OPTION) $<
|
||||
|
||||
MKDIR ?= mkdir
|
||||
$(BUILD_DIR): ; $(Q)$(MKDIR) -p $@
|
||||
$(BUILD_DIR): ; $(MKDIR) -p $@
|
||||
|
||||
DEPFILES := $(ZSTD_OBJ:.o=.d)
|
||||
$(DEPFILES):
|
||||
|
@ -371,7 +390,6 @@ include $(wildcard $(DEPFILES))
|
|||
#-----------------------------------------------------------------------------
|
||||
# make install is validated only for Linux, macOS, BSD, Hurd and Solaris targets
|
||||
#-----------------------------------------------------------------------------
|
||||
UNAME := $(shell uname)
|
||||
ifneq (,$(filter $(UNAME),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku))
|
||||
|
||||
HAVE_COLORNEVER = $(shell echo a | egrep --color=never a > /dev/null 2> /dev/null && echo 1 || echo 0)
|
||||
|
@ -388,7 +406,7 @@ AWK = awk
|
|||
## list: Print all targets and their descriptions (if provided)
|
||||
.PHONY: list
|
||||
list:
|
||||
$(Q)TARGETS=$$($(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null \
|
||||
TARGETS=$$($(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null \
|
||||
| $(AWK) -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' \
|
||||
| $(EGREP) -v -e '^[^[:alnum:]]' | sort); \
|
||||
{ \
|
||||
|
@ -434,36 +452,39 @@ INSTALL_DATA ?= $(INSTALL) -m 644
|
|||
INSTALL_MAN ?= $(INSTALL_DATA)
|
||||
|
||||
.PHONY: install
|
||||
install: zstd
|
||||
install:
|
||||
# generate zstd only if not already present
|
||||
[ -e zstd ] || $(MAKE) zstd-release
|
||||
[ -e $(DESTDIR)$(BINDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(BINDIR)/
|
||||
[ -e $(DESTDIR)$(MAN1DIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(MAN1DIR)/
|
||||
@echo Installing binaries
|
||||
$(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(BINDIR)/ $(DESTDIR)$(MAN1DIR)/
|
||||
$(Q)$(INSTALL_PROGRAM) zstd$(EXT) $(DESTDIR)$(BINDIR)/zstd$(EXT)
|
||||
$(Q)ln -sf zstd$(EXT) $(DESTDIR)$(BINDIR)/zstdcat$(EXT)
|
||||
$(Q)ln -sf zstd$(EXT) $(DESTDIR)$(BINDIR)/unzstd$(EXT)
|
||||
$(Q)ln -sf zstd$(EXT) $(DESTDIR)$(BINDIR)/zstdmt$(EXT)
|
||||
$(Q)$(INSTALL_SCRIPT) zstdless $(DESTDIR)$(BINDIR)/zstdless
|
||||
$(Q)$(INSTALL_SCRIPT) zstdgrep $(DESTDIR)$(BINDIR)/zstdgrep
|
||||
$(INSTALL_PROGRAM) zstd$(EXT) $(DESTDIR)$(BINDIR)/zstd$(EXT)
|
||||
ln -sf zstd$(EXT) $(DESTDIR)$(BINDIR)/zstdcat$(EXT)
|
||||
ln -sf zstd$(EXT) $(DESTDIR)$(BINDIR)/unzstd$(EXT)
|
||||
ln -sf zstd$(EXT) $(DESTDIR)$(BINDIR)/zstdmt$(EXT)
|
||||
$(INSTALL_SCRIPT) zstdless $(DESTDIR)$(BINDIR)/zstdless
|
||||
$(INSTALL_SCRIPT) zstdgrep $(DESTDIR)$(BINDIR)/zstdgrep
|
||||
@echo Installing man pages
|
||||
$(Q)$(INSTALL_MAN) zstd.1 $(DESTDIR)$(MAN1DIR)/zstd.1
|
||||
$(Q)ln -sf zstd.1 $(DESTDIR)$(MAN1DIR)/zstdcat.1
|
||||
$(Q)ln -sf zstd.1 $(DESTDIR)$(MAN1DIR)/unzstd.1
|
||||
$(Q)$(INSTALL_MAN) zstdgrep.1 $(DESTDIR)$(MAN1DIR)/zstdgrep.1
|
||||
$(Q)$(INSTALL_MAN) zstdless.1 $(DESTDIR)$(MAN1DIR)/zstdless.1
|
||||
$(INSTALL_MAN) zstd.1 $(DESTDIR)$(MAN1DIR)/zstd.1
|
||||
ln -sf zstd.1 $(DESTDIR)$(MAN1DIR)/zstdcat.1
|
||||
ln -sf zstd.1 $(DESTDIR)$(MAN1DIR)/unzstd.1
|
||||
$(INSTALL_MAN) zstdgrep.1 $(DESTDIR)$(MAN1DIR)/zstdgrep.1
|
||||
$(INSTALL_MAN) zstdless.1 $(DESTDIR)$(MAN1DIR)/zstdless.1
|
||||
@echo zstd installation completed
|
||||
|
||||
.PHONY: uninstall
|
||||
uninstall:
|
||||
$(Q)$(RM) $(DESTDIR)$(BINDIR)/zstdgrep
|
||||
$(Q)$(RM) $(DESTDIR)$(BINDIR)/zstdless
|
||||
$(Q)$(RM) $(DESTDIR)$(BINDIR)/zstdcat
|
||||
$(Q)$(RM) $(DESTDIR)$(BINDIR)/unzstd
|
||||
$(Q)$(RM) $(DESTDIR)$(BINDIR)/zstdmt
|
||||
$(Q)$(RM) $(DESTDIR)$(BINDIR)/zstd
|
||||
$(Q)$(RM) $(DESTDIR)$(MAN1DIR)/zstdless.1
|
||||
$(Q)$(RM) $(DESTDIR)$(MAN1DIR)/zstdgrep.1
|
||||
$(Q)$(RM) $(DESTDIR)$(MAN1DIR)/zstdcat.1
|
||||
$(Q)$(RM) $(DESTDIR)$(MAN1DIR)/unzstd.1
|
||||
$(Q)$(RM) $(DESTDIR)$(MAN1DIR)/zstd.1
|
||||
$(RM) $(DESTDIR)$(BINDIR)/zstdgrep
|
||||
$(RM) $(DESTDIR)$(BINDIR)/zstdless
|
||||
$(RM) $(DESTDIR)$(BINDIR)/zstdcat
|
||||
$(RM) $(DESTDIR)$(BINDIR)/unzstd
|
||||
$(RM) $(DESTDIR)$(BINDIR)/zstdmt
|
||||
$(RM) $(DESTDIR)$(BINDIR)/zstd
|
||||
$(RM) $(DESTDIR)$(MAN1DIR)/zstdless.1
|
||||
$(RM) $(DESTDIR)$(MAN1DIR)/zstdgrep.1
|
||||
$(RM) $(DESTDIR)$(MAN1DIR)/zstdcat.1
|
||||
$(RM) $(DESTDIR)$(MAN1DIR)/unzstd.1
|
||||
$(RM) $(DESTDIR)$(MAN1DIR)/zstd.1
|
||||
@echo zstd programs successfully uninstalled
|
||||
|
||||
endif
|
||||
|
|
Loading…
Reference in New Issue