10c16b537SWarner Losh# ################################################################ 2*5ff13fbcSAllan Jude# Copyright (c) Yann Collet, Facebook, Inc. 30c16b537SWarner Losh# All rights reserved. 40c16b537SWarner Losh# 50c16b537SWarner Losh# This source code is licensed under both the BSD-style license (found in the 60c16b537SWarner Losh# LICENSE file in the root directory of this source tree) and the GPLv2 (found 70c16b537SWarner Losh# in the COPYING file in the root directory of this source tree). 837f1f268SConrad Meyer# You may select, at your option, one of the above-listed licenses. 90c16b537SWarner Losh# ################################################################ 100c16b537SWarner Losh 1137f1f268SConrad Meyer# Modules 120f743729SConrad MeyerZSTD_LIB_COMPRESSION ?= 1 130f743729SConrad MeyerZSTD_LIB_DECOMPRESSION ?= 1 140f743729SConrad MeyerZSTD_LIB_DICTBUILDER ?= 1 15*5ff13fbcSAllan JudeZSTD_LIB_DEPRECATED ?= 0 1637f1f268SConrad Meyer 17*5ff13fbcSAllan Jude# Input variables for libzstd.mk 180f743729SConrad Meyerifeq ($(ZSTD_LIB_COMPRESSION), 0) 190f743729SConrad Meyer ZSTD_LIB_DICTBUILDER = 0 200f743729SConrad Meyer ZSTD_LIB_DEPRECATED = 0 210f743729SConrad Meyerendif 220f743729SConrad Meyer 230f743729SConrad Meyerifeq ($(ZSTD_LIB_DECOMPRESSION), 0) 240f743729SConrad Meyer ZSTD_LEGACY_SUPPORT = 0 250f743729SConrad Meyer ZSTD_LIB_DEPRECATED = 0 260f743729SConrad Meyerendif 270f743729SConrad Meyer 28*5ff13fbcSAllan Judeinclude libzstd.mk 29*5ff13fbcSAllan Jude 30*5ff13fbcSAllan JudeZSTD_FILES := $(ZSTD_COMMON_FILES) $(ZSTD_LEGACY_FILES) 31*5ff13fbcSAllan Jude 320f743729SConrad Meyerifneq ($(ZSTD_LIB_COMPRESSION), 0) 33*5ff13fbcSAllan Jude ZSTD_FILES += $(ZSTD_COMPRESS_FILES) 340f743729SConrad Meyerendif 350f743729SConrad Meyer 360f743729SConrad Meyerifneq ($(ZSTD_LIB_DECOMPRESSION), 0) 37*5ff13fbcSAllan Jude ZSTD_FILES += $(ZSTD_DECOMPRESS_FILES) 380f743729SConrad Meyerendif 390f743729SConrad Meyer 400f743729SConrad Meyerifneq ($(ZSTD_LIB_DEPRECATED), 0) 41*5ff13fbcSAllan Jude ZSTD_FILES += $(ZSTD_DEPRECATED_FILES) 420f743729SConrad Meyerendif 430f743729SConrad Meyer 440f743729SConrad Meyerifneq ($(ZSTD_LIB_DICTBUILDER), 0) 45*5ff13fbcSAllan Jude ZSTD_FILES += $(ZSTD_DICTBUILDER_FILES) 460f743729SConrad Meyerendif 470c16b537SWarner Losh 48f7cd7fe5SConrad MeyerZSTD_LOCAL_SRC := $(notdir $(ZSTD_FILES)) 49*5ff13fbcSAllan JudeZSTD_LOCAL_OBJ0 := $(ZSTD_LOCAL_SRC:.c=.o) 50*5ff13fbcSAllan JudeZSTD_LOCAL_OBJ := $(ZSTD_LOCAL_OBJ0:.S=.o) 51f7cd7fe5SConrad Meyer 52*5ff13fbcSAllan JudeVERSION := $(ZSTD_VERSION) 53f7cd7fe5SConrad Meyer 54*5ff13fbcSAllan Jude# Note: by default, the static library is built single-threaded and dynamic library is built 55*5ff13fbcSAllan Jude# multi-threaded. It is possible to force multi or single threaded builds by appending 56*5ff13fbcSAllan Jude# -mt or -nomt to the build target (like lib-mt for multi-threaded, lib-nomt for single-threaded). 57*5ff13fbcSAllan Jude.PHONY: default 58*5ff13fbcSAllan Judedefault: lib-release 59f7cd7fe5SConrad Meyer 60*5ff13fbcSAllan JudeCPPFLAGS_DYNLIB += -DZSTD_MULTITHREAD # dynamic library build defaults to multi-threaded 61*5ff13fbcSAllan JudeLDFLAGS_DYNLIB += -pthread 62*5ff13fbcSAllan JudeCPPFLAGS_STATLIB += # static library build defaults to single-threaded 63*5ff13fbcSAllan Jude 64*5ff13fbcSAllan Jude 65*5ff13fbcSAllan Judeifeq ($(findstring GCC,$(CCVER)),GCC) 66*5ff13fbcSAllan Judedecompress/zstd_decompress_block.o : CFLAGS+=-fno-tree-vectorize 67f7cd7fe5SConrad Meyerendif 68f7cd7fe5SConrad Meyer 690c16b537SWarner Losh 700f743729SConrad Meyer# macOS linker doesn't support -soname, and use different extension 710c16b537SWarner Losh# see : https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html 72f7cd7fe5SConrad Meyerifeq ($(UNAME), Darwin) 730c16b537SWarner Losh SHARED_EXT = dylib 740c16b537SWarner Losh SHARED_EXT_MAJOR = $(LIBVER_MAJOR).$(SHARED_EXT) 750c16b537SWarner Losh SHARED_EXT_VER = $(LIBVER).$(SHARED_EXT) 760c16b537SWarner Losh SONAME_FLAGS = -install_name $(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR) -compatibility_version $(LIBVER_MAJOR) -current_version $(LIBVER) 770c16b537SWarner Loshelse 78*5ff13fbcSAllan Jude ifeq ($(UNAME), AIX) 79*5ff13fbcSAllan Jude SONAME_FLAGS = 80*5ff13fbcSAllan Jude else 810c16b537SWarner Losh SONAME_FLAGS = -Wl,-soname=libzstd.$(SHARED_EXT).$(LIBVER_MAJOR) 82*5ff13fbcSAllan Jude endif 830c16b537SWarner Losh SHARED_EXT = so 840c16b537SWarner Losh SHARED_EXT_MAJOR = $(SHARED_EXT).$(LIBVER_MAJOR) 850c16b537SWarner Losh SHARED_EXT_VER = $(SHARED_EXT).$(LIBVER) 860c16b537SWarner Loshendif 870c16b537SWarner Losh 88*5ff13fbcSAllan Jude 89*5ff13fbcSAllan Jude.PHONY: all 90*5ff13fbcSAllan Judeall: lib 91*5ff13fbcSAllan Jude 92*5ff13fbcSAllan Jude 93*5ff13fbcSAllan Jude.PHONY: libzstd.a # must be run every time 94*5ff13fbcSAllan Judelibzstd.a: CPPFLAGS += $(CPPFLAGS_STATLIB) 95*5ff13fbcSAllan Jude 96f7cd7fe5SConrad MeyerSET_CACHE_DIRECTORY = \ 97*5ff13fbcSAllan Jude +$(MAKE) --no-print-directory $@ \ 98f7cd7fe5SConrad Meyer BUILD_DIR=obj/$(HASH_DIR) \ 99f7cd7fe5SConrad Meyer CPPFLAGS="$(CPPFLAGS)" \ 100f7cd7fe5SConrad Meyer CFLAGS="$(CFLAGS)" \ 101f7cd7fe5SConrad Meyer LDFLAGS="$(LDFLAGS)" 1020c16b537SWarner Losh 103f7cd7fe5SConrad Meyerifndef BUILD_DIR 104f7cd7fe5SConrad Meyer# determine BUILD_DIR from compilation flags 105f7cd7fe5SConrad Meyer 106f7cd7fe5SConrad Meyerlibzstd.a: 107f7cd7fe5SConrad Meyer $(SET_CACHE_DIRECTORY) 108f7cd7fe5SConrad Meyer 109f7cd7fe5SConrad Meyerelse 110f7cd7fe5SConrad Meyer# BUILD_DIR is defined 111f7cd7fe5SConrad Meyer 112f7cd7fe5SConrad MeyerZSTD_STATLIB_DIR := $(BUILD_DIR)/static 113f7cd7fe5SConrad MeyerZSTD_STATLIB := $(ZSTD_STATLIB_DIR)/libzstd.a 114f7cd7fe5SConrad MeyerZSTD_STATLIB_OBJ := $(addprefix $(ZSTD_STATLIB_DIR)/,$(ZSTD_LOCAL_OBJ)) 115f7cd7fe5SConrad Meyer$(ZSTD_STATLIB): ARFLAGS = rcs 116f7cd7fe5SConrad Meyer$(ZSTD_STATLIB): | $(ZSTD_STATLIB_DIR) 117f7cd7fe5SConrad Meyer$(ZSTD_STATLIB): $(ZSTD_STATLIB_OBJ) 118*5ff13fbcSAllan Jude # Check for multithread flag at target execution time 119*5ff13fbcSAllan Jude $(if $(filter -DZSTD_MULTITHREAD,$(CPPFLAGS)),\ 120*5ff13fbcSAllan Jude @echo compiling multi-threaded static library $(LIBVER),\ 121*5ff13fbcSAllan Jude @echo compiling single-threaded static library $(LIBVER)) 122f7cd7fe5SConrad Meyer $(AR) $(ARFLAGS) $@ $^ 123f7cd7fe5SConrad Meyer 124f7cd7fe5SConrad Meyerlibzstd.a: $(ZSTD_STATLIB) 125f7cd7fe5SConrad Meyer cp -f $< $@ 126f7cd7fe5SConrad Meyer 127f7cd7fe5SConrad Meyerendif 1280c16b537SWarner Losh 12937f1f268SConrad Meyerifneq (,$(filter Windows%,$(TARGET_SYSTEM))) 1300f743729SConrad Meyer 131f7cd7fe5SConrad MeyerLIBZSTD = dll/libzstd.dll 1320f743729SConrad Meyer$(LIBZSTD): $(ZSTD_FILES) 1330f743729SConrad Meyer @echo compiling dynamic library $(LIBVER) 134f7cd7fe5SConrad Meyer $(CC) $(FLAGS) -DZSTD_DLL_EXPORT=1 -Wl,--out-implib,dll/libzstd.dll.a -shared $^ -o $@ 1350f743729SConrad Meyer 136f7cd7fe5SConrad Meyerelse # not Windows 1370f743729SConrad Meyer 1380f743729SConrad MeyerLIBZSTD = libzstd.$(SHARED_EXT_VER) 139f7cd7fe5SConrad Meyer.PHONY: $(LIBZSTD) # must be run every time 140*5ff13fbcSAllan Jude$(LIBZSTD): CPPFLAGS += $(CPPFLAGS_DYNLIB) 141*5ff13fbcSAllan Jude$(LIBZSTD): CFLAGS += -fPIC -fvisibility=hidden 142*5ff13fbcSAllan Jude$(LIBZSTD): LDFLAGS += -shared $(LDFLAGS_DYNLIB) 1430f743729SConrad Meyer 144f7cd7fe5SConrad Meyerifndef BUILD_DIR 145f7cd7fe5SConrad Meyer# determine BUILD_DIR from compilation flags 146f7cd7fe5SConrad Meyer 147f7cd7fe5SConrad Meyer$(LIBZSTD): 148f7cd7fe5SConrad Meyer $(SET_CACHE_DIRECTORY) 149f7cd7fe5SConrad Meyer 150f7cd7fe5SConrad Meyerelse 151f7cd7fe5SConrad Meyer# BUILD_DIR is defined 152f7cd7fe5SConrad Meyer 153f7cd7fe5SConrad MeyerZSTD_DYNLIB_DIR := $(BUILD_DIR)/dynamic 154f7cd7fe5SConrad MeyerZSTD_DYNLIB := $(ZSTD_DYNLIB_DIR)/$(LIBZSTD) 155f7cd7fe5SConrad MeyerZSTD_DYNLIB_OBJ := $(addprefix $(ZSTD_DYNLIB_DIR)/,$(ZSTD_LOCAL_OBJ)) 156f7cd7fe5SConrad Meyer 157f7cd7fe5SConrad Meyer$(ZSTD_DYNLIB): | $(ZSTD_DYNLIB_DIR) 158f7cd7fe5SConrad Meyer$(ZSTD_DYNLIB): $(ZSTD_DYNLIB_OBJ) 159*5ff13fbcSAllan Jude# Check for multithread flag at target execution time 160*5ff13fbcSAllan Jude $(if $(filter -DZSTD_MULTITHREAD,$(CPPFLAGS)),\ 161*5ff13fbcSAllan Jude @echo compiling multi-threaded dynamic library $(LIBVER),\ 162*5ff13fbcSAllan Jude @echo compiling single-threaded dynamic library $(LIBVER)) 163f7cd7fe5SConrad Meyer $(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@ 164f7cd7fe5SConrad Meyer @echo creating versioned links 165f7cd7fe5SConrad Meyer ln -sf $@ libzstd.$(SHARED_EXT_MAJOR) 166f7cd7fe5SConrad Meyer ln -sf $@ libzstd.$(SHARED_EXT) 167f7cd7fe5SConrad Meyer 168f7cd7fe5SConrad Meyer$(LIBZSTD): $(ZSTD_DYNLIB) 169f7cd7fe5SConrad Meyer cp -f $< $@ 170f7cd7fe5SConrad Meyer 171f7cd7fe5SConrad Meyerendif # ifndef BUILD_DIR 172f7cd7fe5SConrad Meyerendif # if windows 1730c16b537SWarner Losh 17437f1f268SConrad Meyer.PHONY: libzstd 1750c16b537SWarner Loshlibzstd : $(LIBZSTD) 1760c16b537SWarner Losh 17737f1f268SConrad Meyer.PHONY: lib 1780c16b537SWarner Loshlib : libzstd.a libzstd 1790c16b537SWarner Losh 180f7cd7fe5SConrad Meyer 181f7cd7fe5SConrad Meyer# note : do not define lib-mt or lib-release as .PHONY 182f7cd7fe5SConrad Meyer# make does not consider implicit pattern rule for .PHONY target 183f7cd7fe5SConrad Meyer 184*5ff13fbcSAllan Jude%-mt : CPPFLAGS_DYNLIB := -DZSTD_MULTITHREAD 185*5ff13fbcSAllan Jude%-mt : CPPFLAGS_STATLIB := -DZSTD_MULTITHREAD 186*5ff13fbcSAllan Jude%-mt : LDFLAGS_DYNLIB := -pthread 18737f1f268SConrad Meyer%-mt : % 188*5ff13fbcSAllan Jude @echo multi-threaded build completed 189*5ff13fbcSAllan Jude 190*5ff13fbcSAllan Jude%-nomt : CPPFLAGS_DYNLIB := 191*5ff13fbcSAllan Jude%-nomt : LDFLAGS_DYNLIB := 192*5ff13fbcSAllan Jude%-nomt : CPPFLAGS_STATLIB := 193*5ff13fbcSAllan Jude%-nomt : % 194*5ff13fbcSAllan Jude @echo single-threaded build completed 1950c16b537SWarner Losh 19637f1f268SConrad Meyer%-release : DEBUGFLAGS := 19737f1f268SConrad Meyer%-release : % 19837f1f268SConrad Meyer @echo release build completed 19937f1f268SConrad Meyer 2000c16b537SWarner Losh 201f7cd7fe5SConrad Meyer# Generate .h dependencies automatically 202f7cd7fe5SConrad Meyer 203f7cd7fe5SConrad MeyerDEPFLAGS = -MT $@ -MMD -MP -MF 204f7cd7fe5SConrad Meyer 205f7cd7fe5SConrad Meyer$(ZSTD_DYNLIB_DIR)/%.o : %.c $(ZSTD_DYNLIB_DIR)/%.d | $(ZSTD_DYNLIB_DIR) 206f7cd7fe5SConrad Meyer @echo CC $@ 207f7cd7fe5SConrad Meyer $(COMPILE.c) $(DEPFLAGS) $(ZSTD_DYNLIB_DIR)/$*.d $(OUTPUT_OPTION) $< 208f7cd7fe5SConrad Meyer 209f7cd7fe5SConrad Meyer$(ZSTD_STATLIB_DIR)/%.o : %.c $(ZSTD_STATLIB_DIR)/%.d | $(ZSTD_STATLIB_DIR) 210f7cd7fe5SConrad Meyer @echo CC $@ 211f7cd7fe5SConrad Meyer $(COMPILE.c) $(DEPFLAGS) $(ZSTD_STATLIB_DIR)/$*.d $(OUTPUT_OPTION) $< 212f7cd7fe5SConrad Meyer 213*5ff13fbcSAllan Jude$(ZSTD_DYNLIB_DIR)/%.o : %.S | $(ZSTD_DYNLIB_DIR) 214*5ff13fbcSAllan Jude @echo AS $@ 215*5ff13fbcSAllan Jude $(COMPILE.S) $(OUTPUT_OPTION) $< 216*5ff13fbcSAllan Jude 217*5ff13fbcSAllan Jude$(ZSTD_STATLIB_DIR)/%.o : %.S | $(ZSTD_STATLIB_DIR) 218*5ff13fbcSAllan Jude @echo AS $@ 219*5ff13fbcSAllan Jude $(COMPILE.S) $(OUTPUT_OPTION) $< 220*5ff13fbcSAllan Jude 221f7cd7fe5SConrad MeyerMKDIR ?= mkdir 222f7cd7fe5SConrad Meyer$(BUILD_DIR) $(ZSTD_DYNLIB_DIR) $(ZSTD_STATLIB_DIR): 223f7cd7fe5SConrad Meyer $(MKDIR) -p $@ 224f7cd7fe5SConrad Meyer 225f7cd7fe5SConrad MeyerDEPFILES := $(ZSTD_DYNLIB_OBJ:.o=.d) $(ZSTD_STATLIB_OBJ:.o=.d) 226f7cd7fe5SConrad Meyer$(DEPFILES): 227f7cd7fe5SConrad Meyer 228f7cd7fe5SConrad Meyerinclude $(wildcard $(DEPFILES)) 229f7cd7fe5SConrad Meyer 230f7cd7fe5SConrad Meyer 2310c16b537SWarner Losh# Special case : building library in single-thread mode _and_ without zstdmt_compress.c 2320c16b537SWarner LoshZSTDMT_FILES = compress/zstdmt_compress.c 2330c16b537SWarner LoshZSTD_NOMT_FILES = $(filter-out $(ZSTDMT_FILES),$(ZSTD_FILES)) 234*5ff13fbcSAllan Judelibzstd-nomt: CFLAGS += -fPIC -fvisibility=hidden 235*5ff13fbcSAllan Judelibzstd-nomt: LDFLAGS += -shared 2360c16b537SWarner Loshlibzstd-nomt: $(ZSTD_NOMT_FILES) 2370c16b537SWarner Losh @echo compiling single-thread dynamic library $(LIBVER) 2380c16b537SWarner Losh @echo files : $(ZSTD_NOMT_FILES) 239f7cd7fe5SConrad Meyer $(CC) $(FLAGS) $^ $(LDFLAGS) $(SONAME_FLAGS) -o $@ 2400c16b537SWarner Losh 241*5ff13fbcSAllan Jude.PHONY: clean 2420c16b537SWarner Loshclean: 243f7cd7fe5SConrad Meyer $(RM) -r *.dSYM # macOS-specific 244f7cd7fe5SConrad Meyer $(RM) core *.o *.a *.gcda *.$(SHARED_EXT) *.$(SHARED_EXT).* libzstd.pc 245f7cd7fe5SConrad Meyer $(RM) dll/libzstd.dll dll/libzstd.lib libzstd-nomt* 246f7cd7fe5SConrad Meyer $(RM) -r obj/* 2470c16b537SWarner Losh @echo Cleaning library completed 2480c16b537SWarner Losh 2490c16b537SWarner Losh#----------------------------------------------------------------------------- 25037f1f268SConrad Meyer# make install is validated only for below listed environments 2510c16b537SWarner Losh#----------------------------------------------------------------------------- 252*5ff13fbcSAllan Judeifneq (,$(filter $(UNAME),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku AIX)) 2530c16b537SWarner Losh 254*5ff13fbcSAllan Judelib: libzstd.pc 25537f1f268SConrad Meyer 256f7cd7fe5SConrad MeyerHAS_EXPLICIT_EXEC_PREFIX := $(if $(or $(EXEC_PREFIX),$(exec_prefix)),1,) 257f7cd7fe5SConrad Meyer 2580c16b537SWarner LoshDESTDIR ?= 2590c16b537SWarner Losh# directory variables : GNU conventions prefer lowercase 2600c16b537SWarner Losh# see https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html 2610c16b537SWarner Losh# support both lower and uppercase (BSD), use uppercase in script 2620c16b537SWarner Loshprefix ?= /usr/local 2630c16b537SWarner LoshPREFIX ?= $(prefix) 2640c16b537SWarner Loshexec_prefix ?= $(PREFIX) 26537f1f268SConrad MeyerEXEC_PREFIX ?= $(exec_prefix) 26637f1f268SConrad Meyerlibdir ?= $(EXEC_PREFIX)/lib 2670c16b537SWarner LoshLIBDIR ?= $(libdir) 2680c16b537SWarner Loshincludedir ?= $(PREFIX)/include 2690c16b537SWarner LoshINCLUDEDIR ?= $(includedir) 2700c16b537SWarner Losh 271f7cd7fe5SConrad MeyerPCINCDIR := $(patsubst $(PREFIX)%,%,$(INCLUDEDIR)) 272f7cd7fe5SConrad MeyerPCLIBDIR := $(patsubst $(EXEC_PREFIX)%,%,$(LIBDIR)) 27337f1f268SConrad Meyer 274f7cd7fe5SConrad Meyer# If we successfully stripped off a prefix, we'll add a reference to the 275f7cd7fe5SConrad Meyer# relevant pc variable. 276f7cd7fe5SConrad MeyerPCINCPREFIX := $(if $(findstring $(INCLUDEDIR),$(PCINCDIR)),,$${prefix}) 277f7cd7fe5SConrad MeyerPCLIBPREFIX := $(if $(findstring $(LIBDIR),$(PCLIBDIR)),,$${exec_prefix}) 27837f1f268SConrad Meyer 279f7cd7fe5SConrad Meyer# If no explicit EXEC_PREFIX was set by the caller, write it out as a reference 280f7cd7fe5SConrad Meyer# to PREFIX, rather than as a resolved value. 281f7cd7fe5SConrad MeyerPCEXEC_PREFIX := $(if $(HAS_EXPLICIT_EXEC_PREFIX),$(EXEC_PREFIX),$${prefix}) 28237f1f268SConrad Meyer 283f7cd7fe5SConrad Meyerifneq (,$(filter $(UNAME),FreeBSD NetBSD DragonFly)) 2840c16b537SWarner Losh PKGCONFIGDIR ?= $(PREFIX)/libdata/pkgconfig 2850c16b537SWarner Loshelse 2860c16b537SWarner Losh PKGCONFIGDIR ?= $(LIBDIR)/pkgconfig 2870c16b537SWarner Loshendif 2880c16b537SWarner Losh 289f7cd7fe5SConrad Meyerifneq (,$(filter $(UNAME),SunOS)) 2900c16b537SWarner Losh INSTALL ?= ginstall 2910c16b537SWarner Loshelse 2920c16b537SWarner Losh INSTALL ?= install 2930c16b537SWarner Loshendif 2940c16b537SWarner Losh 2950c16b537SWarner LoshINSTALL_PROGRAM ?= $(INSTALL) 2960c16b537SWarner LoshINSTALL_DATA ?= $(INSTALL) -m 644 2970c16b537SWarner Losh 2980c16b537SWarner Losh 2990c16b537SWarner Loshlibzstd.pc: libzstd.pc.in 3000c16b537SWarner Losh @echo creating pkgconfig 301f7cd7fe5SConrad Meyer @sed $(SED_ERE_OPT) \ 302f7cd7fe5SConrad Meyer -e 's|@PREFIX@|$(PREFIX)|' \ 303f7cd7fe5SConrad Meyer -e 's|@EXEC_PREFIX@|$(PCEXEC_PREFIX)|' \ 304f7cd7fe5SConrad Meyer -e 's|@INCLUDEDIR@|$(PCINCPREFIX)$(PCINCDIR)|' \ 305f7cd7fe5SConrad Meyer -e 's|@LIBDIR@|$(PCLIBPREFIX)$(PCLIBDIR)|' \ 3060c16b537SWarner Losh -e 's|@VERSION@|$(VERSION)|' \ 307*5ff13fbcSAllan Jude -e 's|@LIBS_PRIVATE@|$(LDFLAGS_DYNLIB)|' \ 3080c16b537SWarner Losh $< >$@ 3090c16b537SWarner Losh 310*5ff13fbcSAllan Jude.PHONY: install 3110f743729SConrad Meyerinstall: install-pc install-static install-shared install-includes 3120f743729SConrad Meyer @echo zstd static and shared library installed 3130f743729SConrad Meyer 314*5ff13fbcSAllan Jude.PHONY: install-pc 3150f743729SConrad Meyerinstall-pc: libzstd.pc 316f7cd7fe5SConrad Meyer [ -e $(DESTDIR)$(PKGCONFIGDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(PKGCONFIGDIR)/ 317f7cd7fe5SConrad Meyer $(INSTALL_DATA) libzstd.pc $(DESTDIR)$(PKGCONFIGDIR)/ 3180f743729SConrad Meyer 319*5ff13fbcSAllan Jude.PHONY: install-static 320f7cd7fe5SConrad Meyerinstall-static: 321f7cd7fe5SConrad Meyer # only generate libzstd.a if it's not already present 322f7cd7fe5SConrad Meyer [ -e libzstd.a ] || $(MAKE) libzstd.a-release 323f7cd7fe5SConrad Meyer [ -e $(DESTDIR)$(LIBDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/ 3240f743729SConrad Meyer @echo Installing static library 325f7cd7fe5SConrad Meyer $(INSTALL_DATA) libzstd.a $(DESTDIR)$(LIBDIR) 3260f743729SConrad Meyer 327*5ff13fbcSAllan Jude.PHONY: install-shared 328f7cd7fe5SConrad Meyerinstall-shared: 329f7cd7fe5SConrad Meyer # only generate libzstd.so if it's not already present 330f7cd7fe5SConrad Meyer [ -e $(LIBZSTD) ] || $(MAKE) libzstd-release 331f7cd7fe5SConrad Meyer [ -e $(DESTDIR)$(LIBDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(LIBDIR)/ 3320f743729SConrad Meyer @echo Installing shared library 333f7cd7fe5SConrad Meyer $(INSTALL_PROGRAM) $(LIBZSTD) $(DESTDIR)$(LIBDIR) 334f7cd7fe5SConrad Meyer ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR) 335f7cd7fe5SConrad Meyer ln -sf $(LIBZSTD) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT) 3360f743729SConrad Meyer 337*5ff13fbcSAllan Jude.PHONY: install-includes 3380f743729SConrad Meyerinstall-includes: 339f7cd7fe5SConrad Meyer [ -e $(DESTDIR)$(INCLUDEDIR) ] || $(INSTALL) -d -m 755 $(DESTDIR)$(INCLUDEDIR)/ 3400c16b537SWarner Losh @echo Installing includes 341f7cd7fe5SConrad Meyer $(INSTALL_DATA) zstd.h $(DESTDIR)$(INCLUDEDIR) 342*5ff13fbcSAllan Jude $(INSTALL_DATA) zstd_errors.h $(DESTDIR)$(INCLUDEDIR) 343*5ff13fbcSAllan Jude $(INSTALL_DATA) zdict.h $(DESTDIR)$(INCLUDEDIR) 3440c16b537SWarner Losh 345*5ff13fbcSAllan Jude.PHONY: uninstall 3460c16b537SWarner Loshuninstall: 347f7cd7fe5SConrad Meyer $(RM) $(DESTDIR)$(LIBDIR)/libzstd.a 348f7cd7fe5SConrad Meyer $(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT) 349f7cd7fe5SConrad Meyer $(RM) $(DESTDIR)$(LIBDIR)/libzstd.$(SHARED_EXT_MAJOR) 350f7cd7fe5SConrad Meyer $(RM) $(DESTDIR)$(LIBDIR)/$(LIBZSTD) 351f7cd7fe5SConrad Meyer $(RM) $(DESTDIR)$(PKGCONFIGDIR)/libzstd.pc 352f7cd7fe5SConrad Meyer $(RM) $(DESTDIR)$(INCLUDEDIR)/zstd.h 353f7cd7fe5SConrad Meyer $(RM) $(DESTDIR)$(INCLUDEDIR)/zstd_errors.h 354f7cd7fe5SConrad Meyer $(RM) $(DESTDIR)$(INCLUDEDIR)/zdict.h 3550c16b537SWarner Losh @echo zstd libraries successfully uninstalled 3560c16b537SWarner Losh 3570c16b537SWarner Loshendif 358