2014-07-05 20:33:57 +08:00
|
|
|
# ##########################################################################
|
2014-01-08 02:47:50 +08:00
|
|
|
# LZ4 programs - Makefile
|
2017-08-25 07:59:47 +08:00
|
|
|
# Copyright (C) Yann Collet 2011-2017
|
2014-12-13 22:05:46 +08:00
|
|
|
#
|
2017-01-19 23:28:08 +08:00
|
|
|
# This Makefile is validated for Linux, macOS, *BSD, Hurd, Solaris, MSYS2 targets
|
|
|
|
#
|
2014-01-08 02:47:50 +08: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-30 02:25:10 +08:00
|
|
|
# - LZ4 homepage : http://www.lz4.org
|
2015-03-16 03:40:38 +08:00
|
|
|
# - LZ4 source repository : https://github.com/Cyan4973/lz4
|
2014-07-05 20:33:57 +08:00
|
|
|
# ##########################################################################
|
2014-01-08 02:47:50 +08: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 20:33:57 +08:00
|
|
|
# ##########################################################################
|
2014-01-08 02:47:50 +08:00
|
|
|
|
2016-11-27 22:40:53 +08:00
|
|
|
# Version numbers
|
2017-08-15 06:13:23 +08:00
|
|
|
LZ4DIR := ../lib
|
|
|
|
LIBVER_SRC := $(LZ4DIR)/lz4.h
|
2016-11-27 22:40:53 +08: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-15 06:13:23 +08:00
|
|
|
LIBVER := $(shell echo $(LIBVER_SCRIPT))
|
2016-12-23 01:02:09 +08:00
|
|
|
|
2017-08-27 03:22:51 +08:00
|
|
|
SRCFILES := $(sort $(wildcard $(LZ4DIR)/*.c) $(wildcard *.c))
|
2017-08-25 08:58:13 +08:00
|
|
|
#OBJFILES := $(patsubst %.c,%.o,$(SRCFILES))
|
|
|
|
OBJFILES := $(SRCFILES:.c=.o)
|
2014-05-21 02:14:53 +08:00
|
|
|
|
2017-08-15 06:13:23 +08:00
|
|
|
CPPFLAGS += -I$(LZ4DIR) -DXXH_NAMESPACE=LZ4_
|
|
|
|
CFLAGS ?= -O3
|
2017-06-14 05:45:48 +08:00
|
|
|
DEBUGFLAGS:=-Wall -Wextra -Wundef -Wcast-qual -Wcast-align -Wshadow \
|
2017-08-27 03:22:51 +08:00
|
|
|
-Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes \
|
|
|
|
-Wpointer-arith -Wstrict-aliasing=1
|
2017-08-15 06:13:23 +08:00
|
|
|
CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)
|
|
|
|
FLAGS = $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
|
2015-10-21 19:58:06 +08:00
|
|
|
|
2016-11-27 22:40:53 +08:00
|
|
|
LZ4_VERSION=$(LIBVER)
|
2017-08-15 06:13:23 +08:00
|
|
|
MD2ROFF = ronn
|
|
|
|
MD2ROFF_FLAGS = --roff --warnings --manual="User Commands" --organization="lz4 $(LZ4_VERSION)"
|
2016-11-27 22:40:53 +08:00
|
|
|
|
2014-01-08 02:47:50 +08:00
|
|
|
|
|
|
|
# Define *.exe as extension for Windows systems
|
|
|
|
ifneq (,$(filter Windows%,$(OS)))
|
2016-12-23 01:02:09 +08:00
|
|
|
EXT :=.exe
|
2017-08-15 06:13:23 +08:00
|
|
|
VOID := nul
|
2014-01-08 02:47:50 +08:00
|
|
|
else
|
2016-12-23 01:02:09 +08:00
|
|
|
EXT :=
|
2017-08-15 06:13:23 +08:00
|
|
|
VOID := /dev/null
|
2014-01-08 02:47:50 +08:00
|
|
|
endif
|
|
|
|
|
|
|
|
|
2014-10-28 22:35:43 +08:00
|
|
|
|
2016-11-18 05:02:06 +08:00
|
|
|
default: lz4-release
|
2014-01-08 02:47:50 +08:00
|
|
|
|
2016-11-18 05:02:06 +08:00
|
|
|
all: lz4 lz4c
|
2015-03-26 06:59:38 +08:00
|
|
|
|
2016-11-18 05:02:06 +08:00
|
|
|
all32: CFLAGS+=-m32
|
|
|
|
all32: all
|
2014-01-08 02:47:50 +08:00
|
|
|
|
2016-12-23 01:02:09 +08:00
|
|
|
lz4: $(OBJFILES)
|
|
|
|
$(CC) $(FLAGS) $^ -o $@$(EXT)
|
|
|
|
|
|
|
|
lz4-release: DEBUGFLAGS=
|
|
|
|
lz4-release: lz4
|
2016-11-18 05:02:06 +08:00
|
|
|
|
2017-08-25 08:58:13 +08:00
|
|
|
lz4c: lz4
|
|
|
|
ln -s lz4 lz4c
|
|
|
|
|
2017-05-11 04:26:04 +08:00
|
|
|
lz4c32: CFLAGS += -m32
|
2017-08-15 07:56:05 +08:00
|
|
|
lz4c32 : $(SRCFILES)
|
2016-12-23 01:02:09 +08:00
|
|
|
$(CC) $(FLAGS) $^ -o $@$(EXT)
|
2014-01-08 02:47:50 +08:00
|
|
|
|
2016-11-27 22:40:53 +08:00
|
|
|
lz4.1: lz4.1.md
|
|
|
|
cat $^ | $(MD2ROFF) $(MD2ROFF_FLAGS) | sed -n '/^\.\\\".*/!p' > $@
|
|
|
|
|
|
|
|
man: lz4.1
|
|
|
|
|
|
|
|
clean-man:
|
|
|
|
rm lz4.1
|
|
|
|
|
|
|
|
preview-man: clean-man man
|
|
|
|
man ./lz4.1
|
|
|
|
|
2017-05-11 04:26:04 +08:00
|
|
|
clean:
|
|
|
|
@$(MAKE) -C $(LZ4DIR) $@ > $(VOID)
|
|
|
|
@$(RM) core *.o *.test tmp* \
|
|
|
|
lz4$(EXT) lz4c$(EXT) lz4c32$(EXT) unlz4 lz4cat
|
|
|
|
@echo Cleaning completed
|
|
|
|
|
2016-11-27 22:40:53 +08:00
|
|
|
|
2016-12-23 07:02:01 +08:00
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
# make install is validated only for Linux, OSX, BSD, Hurd and Solaris targets
|
|
|
|
#-----------------------------------------------------------------------------
|
|
|
|
ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS))
|
2014-01-08 02:47:50 +08:00
|
|
|
|
2016-12-08 06:29:22 +08:00
|
|
|
unlz4: lz4
|
|
|
|
ln -s lz4 unlz4
|
|
|
|
|
2016-12-08 06:49:04 +08:00
|
|
|
lz4cat: lz4
|
|
|
|
ln -s lz4 lz4cat
|
|
|
|
|
2016-12-23 07:02:01 +08:00
|
|
|
ifneq (,$(filter $(shell uname),SunOS))
|
|
|
|
INSTALL ?= ginstall
|
|
|
|
else
|
|
|
|
INSTALL ?= install
|
|
|
|
endif
|
2016-12-23 17:05:41 +08:00
|
|
|
|
2017-08-15 06:13:23 +08:00
|
|
|
DESTDIR ?=
|
|
|
|
# directory variables : GNU convention prefers lowercase
|
|
|
|
# support both lower and uppercase (BSD), use uppercase in script
|
|
|
|
prefix ?= /usr/local
|
|
|
|
PREFIX ?= $(prefix)
|
|
|
|
exec_prefix ?= $(PREFIX)
|
|
|
|
bindir ?= $(exec_prefix)/bin
|
|
|
|
BINDIR ?= $(bindir)
|
|
|
|
datarootdir ?= $(PREFIX)/share
|
|
|
|
mandir ?= $(datarootdir)/man
|
2017-08-24 08:53:45 +08:00
|
|
|
man1dir ?= $(mandir)/man1
|
2016-12-28 18:34:23 +08:00
|
|
|
|
|
|
|
ifneq (,$(filter $(shell uname),OpenBSD FreeBSD NetBSD DragonFly SunOS))
|
|
|
|
MANDIR ?= $(PREFIX)/man/man1
|
|
|
|
else
|
2017-08-24 08:53:45 +08:00
|
|
|
MANDIR ?= $(man1dir)
|
2016-12-28 18:34:23 +08:00
|
|
|
endif
|
2016-12-23 07:02:01 +08:00
|
|
|
|
|
|
|
INSTALL_PROGRAM ?= $(INSTALL) -m 755
|
2017-08-15 06:13:23 +08:00
|
|
|
INSTALL_DATA ?= $(INSTALL) -m 644
|
2016-12-23 07:02:01 +08:00
|
|
|
|
|
|
|
|
2017-08-24 08:53:45 +08:00
|
|
|
install: lz4
|
2014-04-15 22:47:48 +08:00
|
|
|
@echo Installing binaries
|
2016-12-23 07:02:01 +08:00
|
|
|
@$(INSTALL) -d -m 755 $(DESTDIR)$(BINDIR)/ $(DESTDIR)$(MANDIR)/
|
|
|
|
@$(INSTALL_PROGRAM) lz4 $(DESTDIR)$(BINDIR)/lz4
|
2017-08-24 08:53:45 +08:00
|
|
|
@ln -sf lz4 $(DESTDIR)$(BINDIR)/lz4c
|
2016-12-08 06:29:22 +08:00
|
|
|
@ln -sf lz4 $(DESTDIR)$(BINDIR)/lz4cat
|
|
|
|
@ln -sf lz4 $(DESTDIR)$(BINDIR)/unlz4
|
2014-04-15 22:47:48 +08:00
|
|
|
@echo Installing man pages
|
2017-08-15 06:13:23 +08:00
|
|
|
@$(INSTALL_DATA) lz4.1 $(DESTDIR)$(MANDIR)/lz4.1
|
2015-03-22 20:42:00 +08:00
|
|
|
@ln -sf lz4.1 $(DESTDIR)$(MANDIR)/lz4c.1
|
|
|
|
@ln -sf lz4.1 $(DESTDIR)$(MANDIR)/lz4cat.1
|
|
|
|
@ln -sf lz4.1 $(DESTDIR)$(MANDIR)/unlz4.1
|
2014-01-08 02:47:50 +08:00
|
|
|
@echo lz4 installation completed
|
|
|
|
|
|
|
|
uninstall:
|
2016-12-08 06:29:22 +08:00
|
|
|
@$(RM) $(DESTDIR)$(BINDIR)/lz4cat
|
|
|
|
@$(RM) $(DESTDIR)$(BINDIR)/unlz4
|
|
|
|
@$(RM) $(DESTDIR)$(BINDIR)/lz4
|
|
|
|
@$(RM) $(DESTDIR)$(BINDIR)/lz4c
|
2016-09-17 17:59:13 +08:00
|
|
|
@$(RM) $(DESTDIR)$(MANDIR)/lz4.1
|
|
|
|
@$(RM) $(DESTDIR)$(MANDIR)/lz4c.1
|
|
|
|
@$(RM) $(DESTDIR)$(MANDIR)/lz4cat.1
|
|
|
|
@$(RM) $(DESTDIR)$(MANDIR)/unlz4.1
|
2014-11-24 01:36:04 +08:00
|
|
|
@echo lz4 programs successfully uninstalled
|
2014-01-08 02:47:50 +08:00
|
|
|
|
|
|
|
endif
|