127b27ec6Sopenharmony_ci# ########################################################################## 227b27ec6Sopenharmony_ci# LZ4 programs - Makefile 327b27ec6Sopenharmony_ci# Copyright (C) Yann Collet 2011-2020 427b27ec6Sopenharmony_ci# 527b27ec6Sopenharmony_ci# This Makefile is validated for Linux, macOS, *BSD, Hurd, Solaris, MSYS2 targets 627b27ec6Sopenharmony_ci# 727b27ec6Sopenharmony_ci# GPL v2 License 827b27ec6Sopenharmony_ci# 927b27ec6Sopenharmony_ci# This program is free software; you can redistribute it and/or modify 1027b27ec6Sopenharmony_ci# it under the terms of the GNU General Public License as published by 1127b27ec6Sopenharmony_ci# the Free Software Foundation; either version 2 of the License, or 1227b27ec6Sopenharmony_ci# (at your option) any later version. 1327b27ec6Sopenharmony_ci# 1427b27ec6Sopenharmony_ci# This program is distributed in the hope that it will be useful, 1527b27ec6Sopenharmony_ci# but WITHOUT ANY WARRANTY; without even the implied warranty of 1627b27ec6Sopenharmony_ci# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1727b27ec6Sopenharmony_ci# GNU General Public License for more details. 1827b27ec6Sopenharmony_ci# 1927b27ec6Sopenharmony_ci# You should have received a copy of the GNU General Public License along 2027b27ec6Sopenharmony_ci# with this program; if not, write to the Free Software Foundation, Inc., 2127b27ec6Sopenharmony_ci# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 2227b27ec6Sopenharmony_ci# 2327b27ec6Sopenharmony_ci# You can contact the author at : 2427b27ec6Sopenharmony_ci# - LZ4 homepage : http://www.lz4.org 2527b27ec6Sopenharmony_ci# - LZ4 source repository : https://github.com/lz4/lz4 2627b27ec6Sopenharmony_ci# ########################################################################## 2727b27ec6Sopenharmony_ci# lz4 : Command Line Utility, supporting gzip-like arguments 2827b27ec6Sopenharmony_ci# lz4c : CLU, supporting also legacy lz4demo arguments 2927b27ec6Sopenharmony_ci# lz4c32: Same as lz4c, but forced to compile in 32-bits mode 3027b27ec6Sopenharmony_ci# ########################################################################## 3127b27ec6Sopenharmony_ciSED = sed 3227b27ec6Sopenharmony_ci 3327b27ec6Sopenharmony_ci# Version numbers 3427b27ec6Sopenharmony_ciLZ4DIR := ../lib 3527b27ec6Sopenharmony_ciLIBVER_SRC := $(LZ4DIR)/lz4.h 3627b27ec6Sopenharmony_ciLIBVER_MAJOR_SCRIPT:=`$(SED) -n '/define LZ4_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < $(LIBVER_SRC)` 3727b27ec6Sopenharmony_ciLIBVER_MINOR_SCRIPT:=`$(SED) -n '/define LZ4_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < $(LIBVER_SRC)` 3827b27ec6Sopenharmony_ciLIBVER_PATCH_SCRIPT:=`$(SED) -n '/define LZ4_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < $(LIBVER_SRC)` 3927b27ec6Sopenharmony_ciLIBVER_SCRIPT:= $(LIBVER_MAJOR_SCRIPT).$(LIBVER_MINOR_SCRIPT).$(LIBVER_PATCH_SCRIPT) 4027b27ec6Sopenharmony_ciLIBVER_MAJOR := $(shell echo $(LIBVER_MAJOR_SCRIPT)) 4127b27ec6Sopenharmony_ciLIBVER_MINOR := $(shell echo $(LIBVER_MINOR_SCRIPT)) 4227b27ec6Sopenharmony_ciLIBVER_PATCH := $(shell echo $(LIBVER_PATCH_SCRIPT)) 4327b27ec6Sopenharmony_ciLIBVER := $(shell echo $(LIBVER_SCRIPT)) 4427b27ec6Sopenharmony_ci 4527b27ec6Sopenharmony_ciLIBFILES = $(wildcard $(LZ4DIR)/*.c) 4627b27ec6Sopenharmony_ciSRCFILES = $(sort $(LIBFILES) $(wildcard *.c)) 4727b27ec6Sopenharmony_ciOBJFILES = $(SRCFILES:.c=.o) 4827b27ec6Sopenharmony_ci 4927b27ec6Sopenharmony_ciCPPFLAGS += -I$(LZ4DIR) -DXXH_NAMESPACE=LZ4_ 5027b27ec6Sopenharmony_ciCFLAGS ?= -O3 5127b27ec6Sopenharmony_ciDEBUGFLAGS= -Wall -Wextra -Wundef -Wcast-qual -Wcast-align -Wshadow \ 5227b27ec6Sopenharmony_ci -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes \ 5327b27ec6Sopenharmony_ci -Wpointer-arith -Wstrict-aliasing=1 5427b27ec6Sopenharmony_ciCFLAGS += $(DEBUGFLAGS) $(MOREFLAGS) 5527b27ec6Sopenharmony_ci 5627b27ec6Sopenharmony_ciinclude ../Makefile.inc 5727b27ec6Sopenharmony_ci 5827b27ec6Sopenharmony_ciOS_VERSION ?= $(UNAME) -r 5927b27ec6Sopenharmony_ciifeq ($(TARGET_OS)$(shell $(OS_VERSION)),SunOS5.10) 6027b27ec6Sopenharmony_ciLDFLAGS += -lrt 6127b27ec6Sopenharmony_ciendif 6227b27ec6Sopenharmony_ci 6327b27ec6Sopenharmony_ciFLAGS = $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) 6427b27ec6Sopenharmony_ci 6527b27ec6Sopenharmony_ciLZ4_VERSION=$(LIBVER) 6627b27ec6Sopenharmony_ciMD2ROFF = ronn 6727b27ec6Sopenharmony_ciMD2ROFF_FLAGS = --roff --warnings --manual="User Commands" --organization="lz4 $(LZ4_VERSION)" 6827b27ec6Sopenharmony_ci 6927b27ec6Sopenharmony_ci 7027b27ec6Sopenharmony_cidefault: lz4-release 7127b27ec6Sopenharmony_ci 7227b27ec6Sopenharmony_ci# silent mode by default; verbose can be triggered by V=1 or VERBOSE=1 7327b27ec6Sopenharmony_ci$(V)$(VERBOSE).SILENT: 7427b27ec6Sopenharmony_ci 7527b27ec6Sopenharmony_ciall: lz4 lz4c 7627b27ec6Sopenharmony_ci 7727b27ec6Sopenharmony_ciall32: CFLAGS+=-m32 7827b27ec6Sopenharmony_ciall32: all 7927b27ec6Sopenharmony_ci 8027b27ec6Sopenharmony_ciifeq ($(WINBASED),yes) 8127b27ec6Sopenharmony_cilz4-exe.rc: lz4-exe.rc.in 8227b27ec6Sopenharmony_ci @echo creating executable resource 8327b27ec6Sopenharmony_ci $(SED) -e 's|@PROGNAME@|lz4|' \ 8427b27ec6Sopenharmony_ci -e 's|@LIBVER_MAJOR@|$(LIBVER_MAJOR)|g' \ 8527b27ec6Sopenharmony_ci -e 's|@LIBVER_MINOR@|$(LIBVER_MINOR)|g' \ 8627b27ec6Sopenharmony_ci -e 's|@LIBVER_PATCH@|$(LIBVER_PATCH)|g' \ 8727b27ec6Sopenharmony_ci -e 's|@EXT@|$(EXT)|g' \ 8827b27ec6Sopenharmony_ci $< >$@ 8927b27ec6Sopenharmony_ci 9027b27ec6Sopenharmony_cilz4-exe.o: lz4-exe.rc 9127b27ec6Sopenharmony_ci $(WINDRES) -i lz4-exe.rc -o lz4-exe.o 9227b27ec6Sopenharmony_ci 9327b27ec6Sopenharmony_cilz4: $(OBJFILES) lz4-exe.o 9427b27ec6Sopenharmony_ci $(CC) $(FLAGS) $^ -o $@$(EXT) 9527b27ec6Sopenharmony_cielse 9627b27ec6Sopenharmony_cilz4: $(OBJFILES) 9727b27ec6Sopenharmony_ci $(CC) $(FLAGS) $(OBJFILES) -o $@$(EXT) $(LDLIBS) 9827b27ec6Sopenharmony_ciendif 9927b27ec6Sopenharmony_ci 10027b27ec6Sopenharmony_ci.PHONY: lz4-release 10127b27ec6Sopenharmony_cilz4-release: DEBUGFLAGS= 10227b27ec6Sopenharmony_cilz4-release: lz4 10327b27ec6Sopenharmony_ci 10427b27ec6Sopenharmony_cilz4-wlib: LIBFILES = 10527b27ec6Sopenharmony_cilz4-wlib: SRCFILES+= $(LZ4DIR)/xxhash.c # benchmark unit needs XXH64() 10627b27ec6Sopenharmony_cilz4-wlib: LDFLAGS += -L $(LZ4DIR) 10727b27ec6Sopenharmony_cilz4-wlib: LDLIBS = -llz4 10827b27ec6Sopenharmony_cilz4-wlib: liblz4 $(OBJFILES) 10927b27ec6Sopenharmony_ci @echo WARNING: $@ must link to an extended variant of the dynamic library which also exposes unstable symbols 11027b27ec6Sopenharmony_ci $(CC) $(FLAGS) $(OBJFILES) -o $@$(EXT) $(LDLIBS) 11127b27ec6Sopenharmony_ci 11227b27ec6Sopenharmony_ci.PHONY:liblz4 11327b27ec6Sopenharmony_ciliblz4: 11427b27ec6Sopenharmony_ci CPPFLAGS="-DLZ4F_PUBLISH_STATIC_FUNCTIONS -DLZ4_PUBLISH_STATIC_FUNCTIONS" $(MAKE) -C $(LZ4DIR) liblz4 11527b27ec6Sopenharmony_ci 11627b27ec6Sopenharmony_cilz4c: lz4 11727b27ec6Sopenharmony_ci $(LN_SF) lz4$(EXT) lz4c$(EXT) 11827b27ec6Sopenharmony_ci 11927b27ec6Sopenharmony_cilz4c32: CFLAGS += -m32 12027b27ec6Sopenharmony_cilz4c32 : $(SRCFILES) 12127b27ec6Sopenharmony_ci $(CC) $(FLAGS) $^ -o $@$(EXT) 12227b27ec6Sopenharmony_ci 12327b27ec6Sopenharmony_cilz4.1: lz4.1.md $(LIBVER_SRC) 12427b27ec6Sopenharmony_ci cat $< | $(MD2ROFF) $(MD2ROFF_FLAGS) | $(SED) -n '/^\.\\\".*/!p' > $@ 12527b27ec6Sopenharmony_ci 12627b27ec6Sopenharmony_ciman: lz4.1 12727b27ec6Sopenharmony_ci 12827b27ec6Sopenharmony_ciclean-man: 12927b27ec6Sopenharmony_ci $(RM) lz4.1 13027b27ec6Sopenharmony_ci 13127b27ec6Sopenharmony_cipreview-man: clean-man man 13227b27ec6Sopenharmony_ci man ./lz4.1 13327b27ec6Sopenharmony_ci 13427b27ec6Sopenharmony_ciclean: 13527b27ec6Sopenharmony_ciifeq ($(WINBASED),yes) 13627b27ec6Sopenharmony_ci $(RM) *.rc 13727b27ec6Sopenharmony_ciendif 13827b27ec6Sopenharmony_ci $(MAKE) -C $(LZ4DIR) $@ > $(VOID) 13927b27ec6Sopenharmony_ci $(RM) core *.o *.test tmp* \ 14027b27ec6Sopenharmony_ci lz4$(EXT) lz4c$(EXT) lz4c32$(EXT) lz4-wlib$(EXT) \ 14127b27ec6Sopenharmony_ci unlz4$(EXT) lz4cat$(EXT) 14227b27ec6Sopenharmony_ci @echo Cleaning completed 14327b27ec6Sopenharmony_ci 14427b27ec6Sopenharmony_ci 14527b27ec6Sopenharmony_ci#----------------------------------------------------------------------------- 14627b27ec6Sopenharmony_ci# make install is validated only for Linux, OSX, BSD, Hurd and Solaris targets 14727b27ec6Sopenharmony_ci#----------------------------------------------------------------------------- 14827b27ec6Sopenharmony_ciifeq ($(POSIX_ENV),Yes) 14927b27ec6Sopenharmony_ci 15027b27ec6Sopenharmony_ciunlz4: lz4 15127b27ec6Sopenharmony_ci $(LN_SF) lz4$(EXT) unlz4$(EXT) 15227b27ec6Sopenharmony_ci 15327b27ec6Sopenharmony_cilz4cat: lz4 15427b27ec6Sopenharmony_ci $(LN_SF) lz4$(EXT) lz4cat$(EXT) 15527b27ec6Sopenharmony_ci 15627b27ec6Sopenharmony_ciDESTDIR ?= 15727b27ec6Sopenharmony_ci# directory variables : GNU conventions prefer lowercase 15827b27ec6Sopenharmony_ci# see https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html 15927b27ec6Sopenharmony_ci# support both lower and uppercase (BSD), use lowercase in script 16027b27ec6Sopenharmony_ciPREFIX ?= /usr/local 16127b27ec6Sopenharmony_ciprefix ?= $(PREFIX) 16227b27ec6Sopenharmony_ciEXEC_PREFIX ?= $(prefix) 16327b27ec6Sopenharmony_ciexec_prefix ?= $(EXEC_PREFIX) 16427b27ec6Sopenharmony_ciBINDIR ?= $(exec_prefix)/bin 16527b27ec6Sopenharmony_cibindir ?= $(BINDIR) 16627b27ec6Sopenharmony_ciDATAROOTDIR ?= $(prefix)/share 16727b27ec6Sopenharmony_cidatarootdir ?= $(DATAROOTDIR) 16827b27ec6Sopenharmony_ciMANDIR ?= $(datarootdir)/man 16927b27ec6Sopenharmony_cimandir ?= $(MANDIR) 17027b27ec6Sopenharmony_ciMAN1DIR ?= $(mandir)/man1 17127b27ec6Sopenharmony_ciman1dir ?= $(MAN1DIR) 17227b27ec6Sopenharmony_ci 17327b27ec6Sopenharmony_ciinstall: lz4 17427b27ec6Sopenharmony_ci @echo Installing binaries in $(DESTDIR)$(bindir) 17527b27ec6Sopenharmony_ci $(INSTALL_DIR) $(DESTDIR)$(bindir)/ $(DESTDIR)$(man1dir)/ 17627b27ec6Sopenharmony_ci $(INSTALL_PROGRAM) lz4$(EXT) $(DESTDIR)$(bindir)/lz4$(EXT) 17727b27ec6Sopenharmony_ci $(LN_SF) lz4$(EXT) $(DESTDIR)$(bindir)/lz4c$(EXT) 17827b27ec6Sopenharmony_ci $(LN_SF) lz4$(EXT) $(DESTDIR)$(bindir)/lz4cat$(EXT) 17927b27ec6Sopenharmony_ci $(LN_SF) lz4$(EXT) $(DESTDIR)$(bindir)/unlz4$(EXT) 18027b27ec6Sopenharmony_ci @echo Installing man pages in $(DESTDIR)$(man1dir) 18127b27ec6Sopenharmony_ci $(INSTALL_DATA) lz4.1 $(DESTDIR)$(man1dir)/lz4.1 18227b27ec6Sopenharmony_ci $(LN_SF) lz4.1 $(DESTDIR)$(man1dir)/lz4c.1 18327b27ec6Sopenharmony_ci $(LN_SF) lz4.1 $(DESTDIR)$(man1dir)/lz4cat.1 18427b27ec6Sopenharmony_ci $(LN_SF) lz4.1 $(DESTDIR)$(man1dir)/unlz4.1 18527b27ec6Sopenharmony_ci @echo lz4 installation completed 18627b27ec6Sopenharmony_ci 18727b27ec6Sopenharmony_ciuninstall: 18827b27ec6Sopenharmony_ci $(RM) $(DESTDIR)$(bindir)/lz4cat$(EXT) 18927b27ec6Sopenharmony_ci $(RM) $(DESTDIR)$(bindir)/unlz4$(EXT) 19027b27ec6Sopenharmony_ci $(RM) $(DESTDIR)$(bindir)/lz4$(EXT) 19127b27ec6Sopenharmony_ci $(RM) $(DESTDIR)$(bindir)/lz4c$(EXT) 19227b27ec6Sopenharmony_ci $(RM) $(DESTDIR)$(man1dir)/lz4.1 19327b27ec6Sopenharmony_ci $(RM) $(DESTDIR)$(man1dir)/lz4c.1 19427b27ec6Sopenharmony_ci $(RM) $(DESTDIR)$(man1dir)/lz4cat.1 19527b27ec6Sopenharmony_ci $(RM) $(DESTDIR)$(man1dir)/unlz4.1 19627b27ec6Sopenharmony_ci @echo lz4 programs successfully uninstalled 19727b27ec6Sopenharmony_ci 19827b27ec6Sopenharmony_ciendif 199