Merge pull request #2368 from facebook/progressive_libzstd
faster rebuild of libzstd
This commit is contained in:
+47
-12
@@ -10,13 +10,13 @@
|
|||||||
|
|
||||||
Q = $(if $(filter 1,$(V) $(VERBOSE)),,@)
|
Q = $(if $(filter 1,$(V) $(VERBOSE)),,@)
|
||||||
|
|
||||||
# When cross-compiling from linux to windows, you might
|
# When cross-compiling from linux to windows,
|
||||||
# need to specify this as "Windows." Fedora build fails
|
# you might need to specify this as "Windows."
|
||||||
# without it.
|
# Fedora build fails without it.
|
||||||
#
|
#
|
||||||
# Note: mingw-w64 build from linux to windows does not
|
# Note: mingw-w64 build from linux to windows
|
||||||
# fail on other tested distros (ubuntu, debian) even
|
# does not fail on other tested distros (ubuntu, debian)
|
||||||
# without manually specifying the TARGET_SYSTEM.
|
# even without manually specifying the TARGET_SYSTEM.
|
||||||
TARGET_SYSTEM ?= $(OS)
|
TARGET_SYSTEM ?= $(OS)
|
||||||
|
|
||||||
# Version numbers
|
# Version numbers
|
||||||
@@ -164,7 +164,17 @@ endif
|
|||||||
endif
|
endif
|
||||||
CPPFLAGS += -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT)
|
CPPFLAGS += -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT)
|
||||||
|
|
||||||
ZSTD_OBJ := $(patsubst %.c,%.o,$(ZSTD_FILES))
|
ZSTD_LOCAL_SRC := $(notdir $(ZSTD_FILES))
|
||||||
|
ZSTD_LOCAL_OBJ := $(ZSTD_LOCAL_SRC:.c=.o)
|
||||||
|
|
||||||
|
ZSTD_SUBDIR := common compress decompress dictBuilder legacy deprecated
|
||||||
|
vpath %.c $(ZSTD_SUBDIR)
|
||||||
|
|
||||||
|
BUILD_DIR ?= obj
|
||||||
|
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
|
# 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
|
# see : https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html
|
||||||
@@ -191,7 +201,7 @@ lib-all: all
|
|||||||
all: lib
|
all: lib
|
||||||
|
|
||||||
libzstd.a: ARFLAGS = rcs
|
libzstd.a: ARFLAGS = rcs
|
||||||
libzstd.a: $(ZSTD_OBJ)
|
libzstd.a: $(ZSTD_STATLIB_OBJ)
|
||||||
@echo compiling static library
|
@echo compiling static library
|
||||||
$(Q)$(AR) $(ARFLAGS) $@ $^
|
$(Q)$(AR) $(ARFLAGS) $@ $^
|
||||||
|
|
||||||
@@ -205,8 +215,9 @@ $(LIBZSTD): $(ZSTD_FILES)
|
|||||||
else
|
else
|
||||||
|
|
||||||
LIBZSTD = libzstd.$(SHARED_EXT_VER)
|
LIBZSTD = libzstd.$(SHARED_EXT_VER)
|
||||||
$(LIBZSTD): LDFLAGS += -shared -fPIC -fvisibility=hidden
|
$(LIBZSTD): CFLAGS += -fPIC
|
||||||
$(LIBZSTD): $(ZSTD_FILES)
|
$(LIBZSTD): LDFLAGS += -shared -fvisibility=hidden
|
||||||
|
$(LIBZSTD): $(ZSTD_DYNLIB_OBJ)
|
||||||
@echo compiling dynamic library $(LIBVER)
|
@echo compiling dynamic library $(LIBVER)
|
||||||
$(Q)$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
|
$(Q)$(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@
|
||||||
@echo creating versioned links
|
@echo creating versioned links
|
||||||
@@ -221,6 +232,7 @@ libzstd : $(LIBZSTD)
|
|||||||
.PHONY: lib
|
.PHONY: lib
|
||||||
lib : libzstd.a libzstd
|
lib : libzstd.a libzstd
|
||||||
|
|
||||||
|
|
||||||
# note : do not define lib-mt or lib-release as .PHONY
|
# note : do not define lib-mt or lib-release as .PHONY
|
||||||
# make does not consider implicit pattern rule for .PHONY target
|
# make does not consider implicit pattern rule for .PHONY target
|
||||||
|
|
||||||
@@ -234,6 +246,28 @@ lib : libzstd.a libzstd
|
|||||||
@echo release build completed
|
@echo release build completed
|
||||||
|
|
||||||
|
|
||||||
|
# Generate .h dependencies automatically
|
||||||
|
|
||||||
|
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) $<
|
||||||
|
|
||||||
|
$(ZSTD_STATLIB_DIR)/%.o : %.c $(ZSTD_STATLIB_DIR)/%.d | $(ZSTD_STATLIB_DIR)
|
||||||
|
@echo $@
|
||||||
|
$(Q)$(COMPILE.c) $(DEPFLAGS) $(ZSTD_STATLIB_DIR)/$*.d $(OUTPUT_OPTION) $<
|
||||||
|
|
||||||
|
MKDIR ?= mkdir
|
||||||
|
$(ZSTD_DYNLIB_DIR) $(ZSTD_STATLIB_DIR):
|
||||||
|
$(Q)$(MKDIR) -p $@
|
||||||
|
|
||||||
|
DEPFILES := $(ZSTD_DYNLIB_OBJ:.o=.d) $(ZSTD_STATLIB_OBJ:.o=.d)
|
||||||
|
$(DEPFILES):
|
||||||
|
|
||||||
|
include $(wildcard $(DEPFILES))
|
||||||
|
|
||||||
|
|
||||||
# Special case : building library in single-thread mode _and_ without zstdmt_compress.c
|
# Special case : building library in single-thread mode _and_ without zstdmt_compress.c
|
||||||
ZSTDMT_FILES = compress/zstdmt_compress.c
|
ZSTDMT_FILES = compress/zstdmt_compress.c
|
||||||
ZSTD_NOMT_FILES = $(filter-out $(ZSTDMT_FILES),$(ZSTD_FILES))
|
ZSTD_NOMT_FILES = $(filter-out $(ZSTDMT_FILES),$(ZSTD_FILES))
|
||||||
@@ -248,6 +282,7 @@ clean:
|
|||||||
$(Q)$(RM) core *.o *.a *.gcda *.$(SHARED_EXT) *.$(SHARED_EXT).* libzstd.pc
|
$(Q)$(RM) core *.o *.a *.gcda *.$(SHARED_EXT) *.$(SHARED_EXT).* libzstd.pc
|
||||||
$(Q)$(RM) dll/libzstd.dll dll/libzstd.lib libzstd-nomt*
|
$(Q)$(RM) dll/libzstd.dll dll/libzstd.lib libzstd-nomt*
|
||||||
$(Q)$(RM) common/*.o compress/*.o decompress/*.o dictBuilder/*.o legacy/*.o deprecated/*.o
|
$(Q)$(RM) common/*.o compress/*.o decompress/*.o dictBuilder/*.o legacy/*.o deprecated/*.o
|
||||||
|
$(Q)$(RM) -r $(ZSTD_STATLIB_DIR)/* $(ZSTD_DYNLIB_DIR)/*
|
||||||
@echo Cleaning library completed
|
@echo Cleaning library completed
|
||||||
|
|
||||||
#-----------------------------------------------------------------------------
|
#-----------------------------------------------------------------------------
|
||||||
@@ -277,7 +312,7 @@ ifeq (,$(PCLIBDIR))
|
|||||||
# Additional prefix check is required, since the empty string is technically a
|
# Additional prefix check is required, since the empty string is technically a
|
||||||
# valid PCLIBDIR
|
# valid PCLIBDIR
|
||||||
ifeq (,$(shell echo "$(LIBDIR)" | sed -n $(SED_ERE_OPT) -e "\\@^$(EXEC_PREFIX)(/|$$)@ p"))
|
ifeq (,$(shell echo "$(LIBDIR)" | sed -n $(SED_ERE_OPT) -e "\\@^$(EXEC_PREFIX)(/|$$)@ p"))
|
||||||
$(error configured libdir ($(LIBDIR)) is outside of prefix ($(PREFIX)), can't generate pkg-config file)
|
$(error configured libdir ($(LIBDIR)) is outside of prefix ($(EXEC_PREFIX)), can't generate pkg-config file)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -285,7 +320,7 @@ ifeq (,$(PCINCDIR))
|
|||||||
# Additional prefix check is required, since the empty string is technically a
|
# Additional prefix check is required, since the empty string is technically a
|
||||||
# valid PCINCDIR
|
# valid PCINCDIR
|
||||||
ifeq (,$(shell echo "$(INCLUDEDIR)" | sed -n $(SED_ERE_OPT) -e "\\@^$(PREFIX)(/|$$)@ p"))
|
ifeq (,$(shell echo "$(INCLUDEDIR)" | sed -n $(SED_ERE_OPT) -e "\\@^$(PREFIX)(/|$$)@ p"))
|
||||||
$(error configured includedir ($(INCLUDEDIR)) is outside of exec_prefix ($(EXEC_PREFIX)), can't generate pkg-config file)
|
$(error configured includedir ($(INCLUDEDIR)) is outside of exec_prefix ($(PREFIX)), can't generate pkg-config file)
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user