make zstd is now differentiated from zstd-nomt

avoids mixing object files using different flags
dev
Yann Collet 2020-10-23 16:08:21 -07:00
parent 89b961ea46
commit a6ee614a44
2 changed files with 35 additions and 22 deletions

View File

@ -182,15 +182,14 @@ BUILD_DIR ?= 0
ifeq ($(BUILD_DIR),0) ifeq ($(BUILD_DIR),0)
ifeq ($(UNAME), Darwin) ifeq ($(UNAME), Darwin)
HASH ?= md5 HASH ?= md5
endif else ifeq ($(UNAME), FreeBSD)
ifeq ($(UNAME), FreeBSD)
HASH ?= gmd5sum HASH ?= gmd5sum
endif else ifeq ($(UNAME), OpenBSD)
ifeq ($(UNAME), OpenBSD)
HASH ?= md5 HASH ?= md5
endif endif
HASH ?= md5sum HASH ?= md5sum
HASH_DIR = conf_$(shell echo $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(ZSTD_FILES) | $(HASH) | head -c 16)
HAVE_HASH :=$(shell echo 1 | $(HASH) > /dev/null && echo 1 || echo 0) HAVE_HASH :=$(shell echo 1 | $(HASH) > /dev/null && echo 1 || echo 0)
ifeq ($(HAVE_HASH),0) ifeq ($(HAVE_HASH),0)
$(info warning : could not find HASH ($(HASH)), needed to differentiate builds using different flags) $(info warning : could not find HASH ($(HASH)), needed to differentiate builds using different flags)
@ -229,7 +228,7 @@ ifeq ($(BUILD_DIR),0)
.PHONY: libzstd.a # not the actual recipe .PHONY: libzstd.a # not the actual recipe
libzstd.a: libzstd.a:
$(MAKE) --no-print-directory $@ \ $(MAKE) --no-print-directory $@ \
BUILD_DIR=obj/conf_$(shell echo $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(ZSTD_FILES) | $(HASH) | head -c 16) \ BUILD_DIR=obj/$(HASH_DIR) \
CPPFLAGS="$(CPPFLAGS)" CPPFLAGS="$(CPPFLAGS)"
else else
@ -269,7 +268,7 @@ ifeq ($(BUILD_DIR),0)
.PHONY: $(LIBZSTD) # not the actual recipe .PHONY: $(LIBZSTD) # not the actual recipe
$(LIBZSTD): $(LIBZSTD):
$(MAKE) --no-print-directory $@ \ $(MAKE) --no-print-directory $@ \
BUILD_DIR=obj/conf_$(shell echo $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(ZSTD_FILES) | $(HASH) | head -c 16) \ BUILD_DIR=obj/$(HASH_DIR) \
CPPFLAGS="$(CPPFLAGS)" \ CPPFLAGS="$(CPPFLAGS)" \
CFLAGS="$(CFLAGS)" \ CFLAGS="$(CFLAGS)" \
LDFLAGS="$(LDFLAGS)" LDFLAGS="$(LDFLAGS)"

View File

@ -98,28 +98,25 @@ ZSTD_ALL_SRC := $(ZSTDLIB_LOCAL_SRC) $(ZSTD_CLI_SRC)
ZSTD_ALL_OBJ := $(ZSTD_ALL_SRC:.c=.o) ZSTD_ALL_OBJ := $(ZSTD_ALL_SRC:.c=.o)
UNAME := $(shell uname) UNAME := $(shell uname)
BUILD_DIR ?= 0
ifeq ($(BUILD_DIR),0)
ifeq ($(UNAME), Darwin) ifeq ($(UNAME), Darwin)
HASH ?= md5 HASH ?= md5
endif else ifeq ($(UNAME), FreeBSD)
ifeq ($(UNAME), FreeBSD)
HASH ?= gmd5sum HASH ?= gmd5sum
endif else ifeq ($(UNAME), OpenBSD)
ifeq ($(UNAME), OpenBSD)
HASH ?= md5 HASH ?= md5
endif endif
HASH ?= md5sum HASH ?= md5sum
HAVE_HASH := $(shell echo 1 | $(HASH) > /dev/null && echo 1 || echo 0) HASH_DIR = conf_$(shell echo $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(ZSTD_FILES) | $(HASH) | head -c 16)
ifeq ($(HAVE_HASH), 1) HAVE_HASH :=$(shell echo 1 | $(HASH) > /dev/null && echo 1 || echo 0)
HASH_VALUE := $(shell echo $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) | $(HASH) | head -c 16) ifeq ($(HAVE_HASH),0)
HASH_DIR := conf_$(HASH_VALUE) $(info warning : could not find HASH ($(HASH)), needed to differentiate builds using different flags)
else BUILD_DIR := obj/generic_noconf
$(info warning : could not find hash function to differentiate builds with different flags)
HASH_DIR := 0
endif endif
endif # $(BUILD_DIR) == 0
BUILD_DIR ?= obj/$(HASH_DIR)
ZSTD_OBJ := $(addprefix $(BUILD_DIR)/, $(ZSTD_ALL_OBJ))
# Define *.exe as extension for Windows systems # Define *.exe as extension for Windows systems
ifneq (,$(filter Windows%,$(OS))) ifneq (,$(filter Windows%,$(OS)))
@ -203,6 +200,7 @@ all: zstd
.PHONY: allVariants .PHONY: allVariants
allVariants: zstd zstd-compress zstd-decompress zstd-small zstd-nolegacy zstd-dictBuilder allVariants: zstd zstd-compress zstd-decompress zstd-small zstd-nolegacy zstd-dictBuilder
ZSTD_OBJ := $(addprefix $(BUILD_DIR)/, $(ZSTD_ALL_OBJ))
$(BUILD_DIR)/zstd : $(ZSTD_OBJ) $(BUILD_DIR)/zstd : $(ZSTD_OBJ)
@echo "$(THREAD_MSG)" @echo "$(THREAD_MSG)"
@echo "$(ZLIB_MSG)" @echo "$(ZLIB_MSG)"
@ -210,17 +208,34 @@ $(BUILD_DIR)/zstd : $(ZSTD_OBJ)
@echo "$(LZ4_MSG)" @echo "$(LZ4_MSG)"
$(CC) $(FLAGS) $^ -o $@$(EXT) $(LDFLAGS) $(CC) $(FLAGS) $^ -o $@$(EXT) $(LDFLAGS)
.PHONY: zstd .PHONY: zstd # must always be run
zstd : CPPFLAGS += $(THREAD_CPP) $(ZLIBCPP) $(LZMACPP) $(LZ4CPP) zstd : CPPFLAGS += $(THREAD_CPP) $(ZLIBCPP) $(LZMACPP) $(LZ4CPP)
zstd : LDFLAGS += $(THREAD_LD) $(ZLIBLD) $(LZMALD) $(LZ4LD) $(DEBUGFLAGS_LD) zstd : LDFLAGS += $(THREAD_LD) $(ZLIBLD) $(LZMALD) $(LZ4LD) $(DEBUGFLAGS_LD)
zstd : CPPFLAGS += -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT) zstd : CPPFLAGS += -DZSTD_LEGACY_SUPPORT=$(ZSTD_LEGACY_SUPPORT)
ifneq (,$(filter Windows%,$(OS))) ifneq (,$(filter Windows%,$(OS)))
zstd : $(RES_FILE) zstd : $(RES_FILE)
endif endif
ifeq ($(BUILD_DIR),0)
# generate a BUILD_DIR from flags
zstd:
$(MAKE) --no-print-directory $@ \
BUILD_DIR=obj/$(HASH_DIR) \
CPPFLAGS="$(CPPFLAGS)" \
CFLAGS="$(CFLAGS)" \
LDFLAGS="$(LDFLAGS)"
else
# BUILD_DIR is defined
zstd : $(BUILD_DIR)/zstd zstd : $(BUILD_DIR)/zstd
ln -sf $< $@ ln -sf $< $@
@echo zstd build completed @echo zstd build completed
endif
.PHONY: zstd-release .PHONY: zstd-release
zstd-release: DEBUGFLAGS := -DBACKTRACE_ENABLE=0 zstd-release: DEBUGFLAGS := -DBACKTRACE_ENABLE=0
zstd-release: DEBUGFLAGS_LD := zstd-release: DEBUGFLAGS_LD :=
@ -372,7 +387,6 @@ include $(wildcard $(DEPFILES))
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# make install is validated only for Linux, macOS, BSD, Hurd and Solaris targets # 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)) 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) HAVE_COLORNEVER = $(shell echo a | egrep --color=never a > /dev/null 2> /dev/null && echo 1 || echo 0)