2014-07-05 12:33:57 +00:00
|
|
|
# ##########################################################################
|
2014-01-07 18:47:50 +00:00
|
|
|
# LZ4 programs - Makefile
|
2020-11-25 22:45:14 +00:00
|
|
|
# Copyright (C) Yann Collet 2011-2020
|
2014-12-13 14:05:46 +00:00
|
|
|
#
|
2017-01-19 15:28:08 +00:00
|
|
|
# This Makefile is validated for Linux, macOS, *BSD, Hurd, Solaris, MSYS2 targets
|
|
|
|
#
|
2014-01-07 18:47:50 +00:00
|
|
|
# GPL v2 License
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
#
|
|
|
|
# You can contact the author at :
|
2016-06-29 18:25:10 +00:00
|
|
|
# - LZ4 homepage : http://www.lz4.org
|
2020-11-15 09:31:09 +00:00
|
|
|
# - LZ4 source repository : https://github.com/lz4/lz4
|
2014-07-05 12:33:57 +00:00
|
|
|
# ##########################################################################
|
2014-01-07 18:47:50 +00:00
|
|
|
# lz4 : Command Line Utility, supporting gzip-like arguments
|
|
|
|
# lz4c : CLU, supporting also legacy lz4demo arguments
|
|
|
|
# lz4c32: Same as lz4c, but forced to compile in 32-bits mode
|
2014-07-05 12:33:57 +00:00
|
|
|
# ##########################################################################
|
2014-01-07 18:47:50 +00:00
|
|
|
|
2016-11-27 14:40:53 +00:00
|
|
|
# Version numbers
|
2017-08-14 22:13:23 +00:00
|
|
|
LZ4DIR := ../lib
|
|
|
|
LIBVER_SRC := $(LZ4DIR)/lz4.h
|
2016-11-27 14:40:53 +00:00
|
|
|
LIBVER_MAJOR_SCRIPT:=`sed -n '/define LZ4_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < $(LIBVER_SRC)`
|
|
|
|
LIBVER_MINOR_SCRIPT:=`sed -n '/define LZ4_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < $(LIBVER_SRC)`
|
|
|
|
LIBVER_PATCH_SCRIPT:=`sed -n '/define LZ4_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < $(LIBVER_SRC)`
|
|
|
|
LIBVER_SCRIPT:= $(LIBVER_MAJOR_SCRIPT).$(LIBVER_MINOR_SCRIPT).$(LIBVER_PATCH_SCRIPT)
|
|
|
|
LIBVER_MAJOR := $(shell echo $(LIBVER_MAJOR_SCRIPT))
|
|
|
|
LIBVER_MINOR := $(shell echo $(LIBVER_MINOR_SCRIPT))
|
|
|
|
LIBVER_PATCH := $(shell echo $(LIBVER_PATCH_SCRIPT))
|
2017-08-14 22:13:23 +00:00
|
|
|
LIBVER := $(shell echo $(LIBVER_SCRIPT))
|
2016-12-22 17:02:09 +00:00
|
|
|
|
2020-08-11 21:03:20 +00:00
|
|
|
LIBFILES = $(wildcard $(LZ4DIR)/*.c)
|
|
|
|
SRCFILES = $(sort $(LIBFILES) $(wildcard *.c))
|
|
|
|
OBJFILES = $(SRCFILES:.c=.o)
|
2014-05-20 18:14:53 +00:00
|
|
|
|
2017-08-14 22:13:23 +00:00
|
|
|
CPPFLAGS += -I$(LZ4DIR) -DXXH_NAMESPACE=LZ4_
|
|
|
|
CFLAGS ?= -O3
|
2020-08-11 21:03:20 +00:00
|
|
|
DEBUGFLAGS= -Wall -Wextra -Wundef -Wcast-qual -Wcast-align -Wshadow \
|
2017-08-26 19:22:51 +00:00
|
|
|
-Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes \
|
|
|
|
-Wpointer-arith -Wstrict-aliasing=1
|
2017-08-14 22:13:23 +00:00
|
|
|
CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)
|
|
|
|
FLAGS = $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
|
2015-10-21 11:58:06 +00:00
|
|
|
|
2016-11-27 14:40:53 +00:00
|
|
|
LZ4_VERSION=$(LIBVER)
|
2017-08-14 22:13:23 +00:00
|
|
|
MD2ROFF = ronn
|
|
|
|
MD2ROFF_FLAGS = --roff --warnings --manual="User Commands" --organization="lz4 $(LZ4_VERSION)"
|
2016-11-27 14:40:53 +00:00
|
|
|
|
2019-04-22 21:38:43 +00:00
|
|
|
include ../Makefile.inc
|
2014-10-28 14:35:43 +00:00
|
|
|
|
2016-11-17 21:02:06 +00:00
|
|
|
default: lz4-release
|
2014-01-07 18:47:50 +00:00
|
|
|
|
2016-11-17 21:02:06 +00:00
|
|
|
all: lz4 lz4c
|
2015-03-25 22:59:38 +00:00
|
|
|
|
2016-11-17 21:02:06 +00:00
|
|
|
all32: CFLAGS+=-m32
|
|
|
|
all32: all
|
2014-01-07 18:47:50 +00:00
|
|
|
|
2019-04-23 11:44:00 +00:00
|
|
|
ifeq ($(WINBASED),yes)
|
|
|
|
lz4-exe.rc: lz4-exe.rc.in
|
|
|
|
@echo creating executable resource
|
|
|
|
$(Q)sed -e 's|@PROGNAME@|lz4|' \
|
|
|
|
-e 's|@LIBVER_MAJOR@|$(LIBVER_MAJOR)|g' \
|
|
|
|
-e 's|@LIBVER_MINOR@|$(LIBVER_MINOR)|g' \
|
|
|
|
-e 's|@LIBVER_PATCH@|$(LIBVER_PATCH)|g' \
|
|
|
|
-e 's|@EXT@|$(EXT)|g' \
|
|
|
|
$< >$@
|
|
|
|
|
|
|
|
lz4-exe.o: lz4-exe.rc
|
|
|
|
$(WINDRES) -i lz4-exe.rc -o lz4-exe.o
|
|
|
|
|
|
|
|
lz4: $(OBJFILES) lz4-exe.o
|
|
|
|
$(CC) $(FLAGS) $^ -o $@$(EXT)
|
|
|
|
else
|
2016-12-22 17:02:09 +00:00
|
|
|
lz4: $(OBJFILES)
|
2020-08-11 21:03:20 +00:00
|
|
|
$(CC) $(FLAGS) $(OBJFILES) -o $@$(EXT) $(LDLIBS)
|
2019-04-23 11:44:00 +00:00
|
|
|
endif
|
|
|
|
|
2020-08-11 21:03:20 +00:00
|
|
|
.PHONY: lz4-release
|
2016-12-22 17:02:09 +00:00
|
|
|
lz4-release: DEBUGFLAGS=
|
|
|
|
lz4-release: lz4
|
2016-11-17 21:02:06 +00:00
|
|
|
|
2020-08-11 21:03:20 +00:00
|
|
|
lz4-wlib: LIBFILES =
|
|
|
|
lz4-wlib: SRCFILES+= $(LZ4DIR)/xxhash.c # benchmark unit needs XXH64()
|
|
|
|
lz4-wlib: LDFLAGS += -L $(LZ4DIR)
|
|
|
|
lz4-wlib: LDLIBS = -llz4
|
|
|
|
lz4-wlib: liblz4 $(OBJFILES)
|
|
|
|
@echo WARNING: $@ must link to an extended variant of the dynamic library which also exposes unstable symbols
|
|
|
|
$(CC) $(FLAGS) $(OBJFILES) -o $@$(EXT) $(LDLIBS)
|
|
|
|
|
|
|
|
.PHONY:liblz4
|
|
|
|
liblz4:
|
|
|
|
CPPFLAGS="-DLZ4F_PUBLISH_STATIC_FUNCTIONS -DLZ4_PUBLISH_STATIC_FUNCTIONS" $(MAKE) -C $(LZ4DIR) liblz4
|
|
|
|
|
2017-08-25 00:58:13 +00:00
|
|
|
lz4c: lz4
|
2019-04-23 11:44:00 +00:00
|
|
|
$(LN_SF) lz4$(EXT) lz4c$(EXT)
|
2017-08-25 00:58:13 +00:00
|
|
|
|
2017-05-10 20:26:04 +00:00
|
|
|
lz4c32: CFLAGS += -m32
|
2017-08-14 23:56:05 +00:00
|
|
|
lz4c32 : $(SRCFILES)
|
2016-12-22 17:02:09 +00:00
|
|
|
$(CC) $(FLAGS) $^ -o $@$(EXT)
|
2014-01-07 18:47:50 +00:00
|
|
|
|
2018-01-14 02:46:13 +00:00
|
|
|
lz4.1: lz4.1.md $(LIBVER_SRC)
|
|
|
|
cat $< | $(MD2ROFF) $(MD2ROFF_FLAGS) | sed -n '/^\.\\\".*/!p' > $@
|
2016-11-27 14:40:53 +00:00
|
|
|
|
|
|
|
man: lz4.1
|
|
|
|
|
|
|
|
clean-man:
|
2019-04-11 21:15:33 +00:00
|
|
|
$(RM) lz4.1
|
2016-11-27 14:40:53 +00:00
|
|
|
|
|
|
|
preview-man: clean-man man
|
|
|
|
man ./lz4.1
|
|
|
|
|
2017-05-10 20:26:04 +00:00
|
|
|
clean:
|
2019-04-23 11:44:00 +00:00
|
|
|
ifeq ($(WINBASED),yes)
|
|
|
|
$(Q)$(RM) *.rc
|
|
|
|
endif
|
2017-05-10 20:26:04 +00:00
|
|
|
@$(MAKE) -C $(LZ4DIR) $@ > $(VOID)
|
|
|
|
@$(RM) core *.o *.test tmp* \
|
2020-08-11 21:03:20 +00:00
|
|
|
lz4$(EXT) lz4c$(EXT) lz4c32$(EXT) lz4-wlib$(EXT) \
|
|
|
|
unlz4$(EXT) lz4cat$(EXT)
|
2017-05-10 20:26:04 +00:00
|
|
|
@echo Cleaning completed
|
|
|
|
|
2016-11-27 14:40:53 +00:00
|
|
|
|
2016-12-22 23:02:01 +00:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# make install is validated only for Linux, OSX, BSD, Hurd and Solaris targets
|
|
|
|
#-----------------------------------------------------------------------------
|
2019-04-23 11:44:00 +00:00
|
|
|
ifeq ($(POSIX_ENV),Yes)
|
2014-01-07 18:47:50 +00:00
|
|
|
|
2016-12-07 22:29:22 +00:00
|
|
|
unlz4: lz4
|
2019-04-23 11:44:00 +00:00
|
|
|
$(LN_SF) lz4$(EXT) unlz4$(EXT)
|
2016-12-07 22:29:22 +00:00
|
|
|
|
2016-12-07 22:49:04 +00:00
|
|
|
lz4cat: lz4
|
2019-04-23 11:44:00 +00:00
|
|
|
$(LN_SF) lz4$(EXT) lz4cat$(EXT)
|
2016-12-07 22:49:04 +00:00
|
|
|
|
2017-08-14 22:13:23 +00:00
|
|
|
DESTDIR ?=
|
2017-09-07 00:41:44 +00:00
|
|
|
# directory variables : GNU conventions prefer lowercase
|
|
|
|
# see https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html
|
2018-05-04 20:35:10 +00:00
|
|
|
# support both lower and uppercase (BSD), use lowercase in script
|
|
|
|
PREFIX ?= /usr/local
|
|
|
|
prefix ?= $(PREFIX)
|
|
|
|
EXEC_PREFIX ?= $(prefix)
|
|
|
|
exec_prefix ?= $(EXEC_PREFIX)
|
|
|
|
BINDIR ?= $(exec_prefix)/bin
|
|
|
|
bindir ?= $(BINDIR)
|
|
|
|
DATAROOTDIR ?= $(prefix)/share
|
|
|
|
datarootdir ?= $(DATAROOTDIR)
|
|
|
|
MANDIR ?= $(datarootdir)/man
|
|
|
|
mandir ?= $(MANDIR)
|
|
|
|
MAN1DIR ?= $(mandir)/man1
|
|
|
|
man1dir ?= $(MAN1DIR)
|
2016-12-22 23:02:01 +00:00
|
|
|
|
2017-08-24 00:53:45 +00:00
|
|
|
install: lz4
|
2014-04-15 14:47:48 +00:00
|
|
|
@echo Installing binaries
|
2019-04-23 11:44:00 +00:00
|
|
|
@$(INSTALL_DIR) $(DESTDIR)$(bindir)/ $(DESTDIR)$(man1dir)/
|
2018-08-13 05:17:54 +00:00
|
|
|
@$(INSTALL_PROGRAM) lz4$(EXT) $(DESTDIR)$(bindir)/lz4$(EXT)
|
2019-04-23 11:44:00 +00:00
|
|
|
@$(LN_S) lz4$(EXT) $(DESTDIR)$(bindir)/lz4c$(EXT)
|
|
|
|
@$(LN_S) lz4$(EXT) $(DESTDIR)$(bindir)/lz4cat$(EXT)
|
|
|
|
@$(LN_S) lz4$(EXT) $(DESTDIR)$(bindir)/unlz4$(EXT)
|
2014-04-15 14:47:48 +00:00
|
|
|
@echo Installing man pages
|
2018-05-04 20:35:10 +00:00
|
|
|
@$(INSTALL_DATA) lz4.1 $(DESTDIR)$(man1dir)/lz4.1
|
2019-04-23 11:44:00 +00:00
|
|
|
@$(LN_SF) lz4.1 $(DESTDIR)$(man1dir)/lz4c.1
|
|
|
|
@$(LN_SF) lz4.1 $(DESTDIR)$(man1dir)/lz4cat.1
|
|
|
|
@$(LN_SF) lz4.1 $(DESTDIR)$(man1dir)/unlz4.1
|
2014-01-07 18:47:50 +00:00
|
|
|
@echo lz4 installation completed
|
|
|
|
|
|
|
|
uninstall:
|
2018-08-13 05:17:54 +00:00
|
|
|
@$(RM) $(DESTDIR)$(bindir)/lz4cat$(EXT)
|
|
|
|
@$(RM) $(DESTDIR)$(bindir)/unlz4$(EXT)
|
|
|
|
@$(RM) $(DESTDIR)$(bindir)/lz4$(EXT)
|
|
|
|
@$(RM) $(DESTDIR)$(bindir)/lz4c$(EXT)
|
2018-05-04 20:35:10 +00:00
|
|
|
@$(RM) $(DESTDIR)$(man1dir)/lz4.1
|
|
|
|
@$(RM) $(DESTDIR)$(man1dir)/lz4c.1
|
|
|
|
@$(RM) $(DESTDIR)$(man1dir)/lz4cat.1
|
|
|
|
@$(RM) $(DESTDIR)$(man1dir)/unlz4.1
|
2014-11-23 17:36:04 +00:00
|
|
|
@echo lz4 programs successfully uninstalled
|
2014-01-07 18:47:50 +00:00
|
|
|
|
|
|
|
endif
|