127b27ec6Sopenharmony_ci# ################################################################ 227b27ec6Sopenharmony_ci# LZ4 library - Makefile 327b27ec6Sopenharmony_ci# Copyright (C) Yann Collet 2011-2020 427b27ec6Sopenharmony_ci# All rights reserved. 527b27ec6Sopenharmony_ci# 627b27ec6Sopenharmony_ci# This Makefile is validated for Linux, macOS, *BSD, Hurd, Solaris, MSYS2 targets 727b27ec6Sopenharmony_ci# 827b27ec6Sopenharmony_ci# BSD license 927b27ec6Sopenharmony_ci# Redistribution and use in source and binary forms, with or without modification, 1027b27ec6Sopenharmony_ci# are permitted provided that the following conditions are met: 1127b27ec6Sopenharmony_ci# 1227b27ec6Sopenharmony_ci# * Redistributions of source code must retain the above copyright notice, this 1327b27ec6Sopenharmony_ci# list of conditions and the following disclaimer. 1427b27ec6Sopenharmony_ci# 1527b27ec6Sopenharmony_ci# * Redistributions in binary form must reproduce the above copyright notice, this 1627b27ec6Sopenharmony_ci# list of conditions and the following disclaimer in the documentation and/or 1727b27ec6Sopenharmony_ci# other materials provided with the distribution. 1827b27ec6Sopenharmony_ci# 1927b27ec6Sopenharmony_ci# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 2027b27ec6Sopenharmony_ci# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 2127b27ec6Sopenharmony_ci# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 2227b27ec6Sopenharmony_ci# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 2327b27ec6Sopenharmony_ci# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 2427b27ec6Sopenharmony_ci# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 2527b27ec6Sopenharmony_ci# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 2627b27ec6Sopenharmony_ci# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 2727b27ec6Sopenharmony_ci# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 2827b27ec6Sopenharmony_ci# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2927b27ec6Sopenharmony_ci# 3027b27ec6Sopenharmony_ci# You can contact the author at : 3127b27ec6Sopenharmony_ci# - LZ4 source repository : https://github.com/lz4/lz4 3227b27ec6Sopenharmony_ci# - LZ4 forum froup : https://groups.google.com/forum/#!forum/lz4c 3327b27ec6Sopenharmony_ci# ################################################################ 3427b27ec6Sopenharmony_ciSED = sed 3527b27ec6Sopenharmony_ci 3627b27ec6Sopenharmony_ci# Version numbers 3727b27ec6Sopenharmony_ciLIBVER_MAJOR_SCRIPT:=`$(SED) -n '/define LZ4_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./lz4.h` 3827b27ec6Sopenharmony_ciLIBVER_MINOR_SCRIPT:=`$(SED) -n '/define LZ4_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./lz4.h` 3927b27ec6Sopenharmony_ciLIBVER_PATCH_SCRIPT:=`$(SED) -n '/define LZ4_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./lz4.h` 4027b27ec6Sopenharmony_ciLIBVER_SCRIPT:= $(LIBVER_MAJOR_SCRIPT).$(LIBVER_MINOR_SCRIPT).$(LIBVER_PATCH_SCRIPT) 4127b27ec6Sopenharmony_ciLIBVER_MAJOR := $(shell echo $(LIBVER_MAJOR_SCRIPT)) 4227b27ec6Sopenharmony_ciLIBVER_MINOR := $(shell echo $(LIBVER_MINOR_SCRIPT)) 4327b27ec6Sopenharmony_ciLIBVER_PATCH := $(shell echo $(LIBVER_PATCH_SCRIPT)) 4427b27ec6Sopenharmony_ciLIBVER := $(shell echo $(LIBVER_SCRIPT)) 4527b27ec6Sopenharmony_ci 4627b27ec6Sopenharmony_ciBUILD_SHARED:=yes 4727b27ec6Sopenharmony_ciBUILD_STATIC:=yes 4827b27ec6Sopenharmony_ci 4927b27ec6Sopenharmony_ciCPPFLAGS+= -DXXH_NAMESPACE=LZ4_ 5027b27ec6Sopenharmony_ciCPPFLAGS+= $(MOREFLAGS) 5127b27ec6Sopenharmony_ciCFLAGS ?= -O3 5227b27ec6Sopenharmony_ciDEBUGFLAGS:= -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \ 5327b27ec6Sopenharmony_ci -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes \ 5427b27ec6Sopenharmony_ci -Wundef -Wpointer-arith -Wstrict-aliasing=1 5527b27ec6Sopenharmony_ciCFLAGS += $(DEBUGFLAGS) 5627b27ec6Sopenharmony_ciFLAGS = $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) 5727b27ec6Sopenharmony_ci 5827b27ec6Sopenharmony_ciSRCFILES := $(sort $(wildcard *.c)) 5927b27ec6Sopenharmony_ci 6027b27ec6Sopenharmony_ciinclude ../Makefile.inc 6127b27ec6Sopenharmony_ci 6227b27ec6Sopenharmony_ci# OS X linker doesn't support -soname, and use different extension 6327b27ec6Sopenharmony_ci# see : https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html 6427b27ec6Sopenharmony_ciifeq ($(TARGET_OS), Darwin) 6527b27ec6Sopenharmony_ci SHARED_EXT = dylib 6627b27ec6Sopenharmony_ci SHARED_EXT_MAJOR = $(LIBVER_MAJOR).$(SHARED_EXT) 6727b27ec6Sopenharmony_ci SHARED_EXT_VER = $(LIBVER).$(SHARED_EXT) 6827b27ec6Sopenharmony_ci SONAME_FLAGS = -install_name $(libdir)/liblz4.$(SHARED_EXT_MAJOR) -compatibility_version $(LIBVER_MAJOR) -current_version $(LIBVER) 6927b27ec6Sopenharmony_cielse 7027b27ec6Sopenharmony_ci SONAME_FLAGS = -Wl,-soname=liblz4.$(SHARED_EXT).$(LIBVER_MAJOR) 7127b27ec6Sopenharmony_ci SHARED_EXT = so 7227b27ec6Sopenharmony_ci SHARED_EXT_MAJOR = $(SHARED_EXT).$(LIBVER_MAJOR) 7327b27ec6Sopenharmony_ci SHARED_EXT_VER = $(SHARED_EXT).$(LIBVER) 7427b27ec6Sopenharmony_ciendif 7527b27ec6Sopenharmony_ci 7627b27ec6Sopenharmony_ci.PHONY: default 7727b27ec6Sopenharmony_cidefault: lib-release 7827b27ec6Sopenharmony_ci 7927b27ec6Sopenharmony_ci# silent mode by default; verbose can be triggered by V=1 or VERBOSE=1 8027b27ec6Sopenharmony_ci$(V)$(VERBOSE).SILENT: 8127b27ec6Sopenharmony_ci 8227b27ec6Sopenharmony_cilib-release: DEBUGFLAGS := 8327b27ec6Sopenharmony_cilib-release: lib 8427b27ec6Sopenharmony_ci 8527b27ec6Sopenharmony_ci.PHONY: lib 8627b27ec6Sopenharmony_cilib: liblz4.a liblz4 8727b27ec6Sopenharmony_ci 8827b27ec6Sopenharmony_ci.PHONY: all 8927b27ec6Sopenharmony_ciall: lib 9027b27ec6Sopenharmony_ci 9127b27ec6Sopenharmony_ci.PHONY: all32 9227b27ec6Sopenharmony_ciall32: CFLAGS+=-m32 9327b27ec6Sopenharmony_ciall32: all 9427b27ec6Sopenharmony_ci 9527b27ec6Sopenharmony_ciliblz4.a: $(SRCFILES) 9627b27ec6Sopenharmony_ciifeq ($(BUILD_STATIC),yes) # can be disabled on command line 9727b27ec6Sopenharmony_ci @echo compiling static library 9827b27ec6Sopenharmony_ci $(COMPILE.c) $^ 9927b27ec6Sopenharmony_ci $(AR) rcs $@ *.o 10027b27ec6Sopenharmony_ciendif 10127b27ec6Sopenharmony_ci 10227b27ec6Sopenharmony_ciifeq ($(WINBASED),yes) 10327b27ec6Sopenharmony_ciliblz4-dll.rc: liblz4-dll.rc.in 10427b27ec6Sopenharmony_ci @echo creating library resource 10527b27ec6Sopenharmony_ci $(SED) -e 's|@LIBLZ4@|$(LIBLZ4)|' \ 10627b27ec6Sopenharmony_ci -e 's|@LIBVER_MAJOR@|$(LIBVER_MAJOR)|g' \ 10727b27ec6Sopenharmony_ci -e 's|@LIBVER_MINOR@|$(LIBVER_MINOR)|g' \ 10827b27ec6Sopenharmony_ci -e 's|@LIBVER_PATCH@|$(LIBVER_PATCH)|g' \ 10927b27ec6Sopenharmony_ci $< >$@ 11027b27ec6Sopenharmony_ci 11127b27ec6Sopenharmony_ciliblz4-dll.o: liblz4-dll.rc 11227b27ec6Sopenharmony_ci $(WINDRES) -i liblz4-dll.rc -o liblz4-dll.o 11327b27ec6Sopenharmony_ci 11427b27ec6Sopenharmony_ci$(LIBLZ4): $(SRCFILES) liblz4-dll.o 11527b27ec6Sopenharmony_ci @echo compiling dynamic library $(LIBVER) 11627b27ec6Sopenharmony_ci $(CC) $(FLAGS) -DLZ4_DLL_EXPORT=1 -shared $^ -o dll/$@.dll -Wl,--out-implib,dll/$(LIBLZ4_EXP) 11727b27ec6Sopenharmony_ci 11827b27ec6Sopenharmony_cielse # not windows 11927b27ec6Sopenharmony_ci 12027b27ec6Sopenharmony_ci$(LIBLZ4): $(SRCFILES) 12127b27ec6Sopenharmony_ci @echo compiling dynamic library $(LIBVER) 12227b27ec6Sopenharmony_ci $(CC) $(FLAGS) -shared $^ -fPIC -fvisibility=hidden $(SONAME_FLAGS) -o $@ 12327b27ec6Sopenharmony_ci @echo creating versioned links 12427b27ec6Sopenharmony_ci $(LN_SF) $@ liblz4.$(SHARED_EXT_MAJOR) 12527b27ec6Sopenharmony_ci $(LN_SF) $@ liblz4.$(SHARED_EXT) 12627b27ec6Sopenharmony_ci 12727b27ec6Sopenharmony_ciendif 12827b27ec6Sopenharmony_ci 12927b27ec6Sopenharmony_ci.PHONY: liblz4 13027b27ec6Sopenharmony_ciliblz4: $(LIBLZ4) 13127b27ec6Sopenharmony_ci 13227b27ec6Sopenharmony_ci.PHONY: clean 13327b27ec6Sopenharmony_ciclean: 13427b27ec6Sopenharmony_ciifeq ($(WINBASED),yes) 13527b27ec6Sopenharmony_ci $(RM) *.rc 13627b27ec6Sopenharmony_ciendif 13727b27ec6Sopenharmony_ci $(RM) core *.o liblz4.pc dll/$(LIBLZ4).dll dll/$(LIBLZ4_EXP) 13827b27ec6Sopenharmony_ci $(RM) *.a *.$(SHARED_EXT) *.$(SHARED_EXT_MAJOR) *.$(SHARED_EXT_VER) 13927b27ec6Sopenharmony_ci @echo Cleaning library completed 14027b27ec6Sopenharmony_ci 14127b27ec6Sopenharmony_ci#----------------------------------------------------------------------------- 14227b27ec6Sopenharmony_ci# make install is validated only for Linux, OSX, BSD, Hurd and Solaris targets 14327b27ec6Sopenharmony_ci#----------------------------------------------------------------------------- 14427b27ec6Sopenharmony_ciifeq ($(POSIX_ENV),Yes) 14527b27ec6Sopenharmony_ci 14627b27ec6Sopenharmony_ci.PHONY: listL120 14727b27ec6Sopenharmony_cilistL120: # extract lines >= 120 characters in *.{c,h}, by Takayuki Matsuoka (note : $$, for Makefile compatibility) 14827b27ec6Sopenharmony_ci find . -type f -name '*.c' -o -name '*.h' | while read -r filename; do awk 'length > 120 {print FILENAME "(" FNR "): " $$0}' $$filename; done 14927b27ec6Sopenharmony_ci 15027b27ec6Sopenharmony_ciDESTDIR ?= 15127b27ec6Sopenharmony_ci# directory variables : GNU conventions prefer lowercase 15227b27ec6Sopenharmony_ci# see https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html 15327b27ec6Sopenharmony_ci# support both lower and uppercase (BSD), use lower in script 15427b27ec6Sopenharmony_ciPREFIX ?= /usr/local 15527b27ec6Sopenharmony_ciprefix ?= $(PREFIX) 15627b27ec6Sopenharmony_ciEXEC_PREFIX ?= $(prefix) 15727b27ec6Sopenharmony_ciexec_prefix ?= $(EXEC_PREFIX) 15827b27ec6Sopenharmony_ciBINDIR ?= $(exec_prefix)/bin 15927b27ec6Sopenharmony_cibindir ?= $(BINDIR) 16027b27ec6Sopenharmony_ciLIBDIR ?= $(exec_prefix)/lib 16127b27ec6Sopenharmony_cilibdir ?= $(LIBDIR) 16227b27ec6Sopenharmony_ciINCLUDEDIR ?= $(prefix)/include 16327b27ec6Sopenharmony_ciincludedir ?= $(INCLUDEDIR) 16427b27ec6Sopenharmony_ci 16527b27ec6Sopenharmony_ci ifneq (,$(filter $(TARGET_OS),OpenBSD FreeBSD NetBSD DragonFly MidnightBSD)) 16627b27ec6Sopenharmony_ciPKGCONFIGDIR ?= $(prefix)/libdata/pkgconfig 16727b27ec6Sopenharmony_ci else 16827b27ec6Sopenharmony_ciPKGCONFIGDIR ?= $(libdir)/pkgconfig 16927b27ec6Sopenharmony_ci endif 17027b27ec6Sopenharmony_cipkgconfigdir ?= $(PKGCONFIGDIR) 17127b27ec6Sopenharmony_ci 17227b27ec6Sopenharmony_ciliblz4.pc: liblz4.pc.in Makefile 17327b27ec6Sopenharmony_ci @echo creating pkgconfig 17427b27ec6Sopenharmony_ci $(SED) -e 's|@PREFIX@|$(prefix)|' \ 17527b27ec6Sopenharmony_ci -e 's|@LIBDIR@|$(libdir)|' \ 17627b27ec6Sopenharmony_ci -e 's|@INCLUDEDIR@|$(includedir)|' \ 17727b27ec6Sopenharmony_ci -e 's|@VERSION@|$(LIBVER)|' \ 17827b27ec6Sopenharmony_ci -e 's|=${prefix}/|=$${prefix}/|' \ 17927b27ec6Sopenharmony_ci $< >$@ 18027b27ec6Sopenharmony_ci 18127b27ec6Sopenharmony_ciinstall: lib liblz4.pc 18227b27ec6Sopenharmony_ci $(INSTALL_DIR) $(DESTDIR)$(pkgconfigdir)/ $(DESTDIR)$(includedir)/ $(DESTDIR)$(libdir)/ $(DESTDIR)$(bindir)/ 18327b27ec6Sopenharmony_ci $(INSTALL_DATA) liblz4.pc $(DESTDIR)$(pkgconfigdir)/ 18427b27ec6Sopenharmony_ci @echo Installing libraries in $(DESTDIR)$(libdir) 18527b27ec6Sopenharmony_ci ifeq ($(BUILD_STATIC),yes) 18627b27ec6Sopenharmony_ci $(INSTALL_DATA) liblz4.a $(DESTDIR)$(libdir)/liblz4.a 18727b27ec6Sopenharmony_ci $(INSTALL_DATA) lz4frame_static.h $(DESTDIR)$(includedir)/lz4frame_static.h 18827b27ec6Sopenharmony_ci endif 18927b27ec6Sopenharmony_ci ifeq ($(BUILD_SHARED),yes) 19027b27ec6Sopenharmony_ci# Traditionally, one installs the DLLs in the bin directory as programs 19127b27ec6Sopenharmony_ci# search them first in their directory. This allows to not pollute system 19227b27ec6Sopenharmony_ci# directories (like c:/windows/system32), nor modify the PATH variable. 19327b27ec6Sopenharmony_ci ifeq ($(WINBASED),yes) 19427b27ec6Sopenharmony_ci $(INSTALL_PROGRAM) dll/$(LIBLZ4).dll $(DESTDIR)$(bindir) 19527b27ec6Sopenharmony_ci $(INSTALL_PROGRAM) dll/$(LIBLZ4_EXP) $(DESTDIR)$(libdir) 19627b27ec6Sopenharmony_ci else 19727b27ec6Sopenharmony_ci $(INSTALL_PROGRAM) liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(libdir) 19827b27ec6Sopenharmony_ci $(LN_SF) liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT_MAJOR) 19927b27ec6Sopenharmony_ci $(LN_SF) liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT) 20027b27ec6Sopenharmony_ci endif 20127b27ec6Sopenharmony_ci endif 20227b27ec6Sopenharmony_ci @echo Installing headers in $(DESTDIR)$(includedir) 20327b27ec6Sopenharmony_ci $(INSTALL_DATA) lz4.h $(DESTDIR)$(includedir)/lz4.h 20427b27ec6Sopenharmony_ci $(INSTALL_DATA) lz4hc.h $(DESTDIR)$(includedir)/lz4hc.h 20527b27ec6Sopenharmony_ci $(INSTALL_DATA) lz4frame.h $(DESTDIR)$(includedir)/lz4frame.h 20627b27ec6Sopenharmony_ci @echo lz4 libraries installed 20727b27ec6Sopenharmony_ci 20827b27ec6Sopenharmony_ciuninstall: 20927b27ec6Sopenharmony_ci $(RM) $(DESTDIR)$(pkgconfigdir)/liblz4.pc 21027b27ec6Sopenharmony_ci ifeq (WINBASED,1) 21127b27ec6Sopenharmony_ci $(RM) $(DESTDIR)$(bindir)/$(LIBLZ4).dll 21227b27ec6Sopenharmony_ci $(RM) $(DESTDIR)$(libdir)/$(LIBLZ4_EXP) 21327b27ec6Sopenharmony_ci else 21427b27ec6Sopenharmony_ci $(RM) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT) 21527b27ec6Sopenharmony_ci $(RM) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT_MAJOR) 21627b27ec6Sopenharmony_ci $(RM) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT_VER) 21727b27ec6Sopenharmony_ci endif 21827b27ec6Sopenharmony_ci $(RM) $(DESTDIR)$(libdir)/liblz4.a 21927b27ec6Sopenharmony_ci $(RM) $(DESTDIR)$(includedir)/lz4.h 22027b27ec6Sopenharmony_ci $(RM) $(DESTDIR)$(includedir)/lz4hc.h 22127b27ec6Sopenharmony_ci $(RM) $(DESTDIR)$(includedir)/lz4frame.h 22227b27ec6Sopenharmony_ci $(RM) $(DESTDIR)$(includedir)/lz4frame_static.h 22327b27ec6Sopenharmony_ci @echo lz4 libraries successfully uninstalled 22427b27ec6Sopenharmony_ci 22527b27ec6Sopenharmony_ciendif 226