summaryrefslogtreecommitdiff
path: root/programs/Makefile
diff options
context:
space:
mode:
authoralk3pInjection <webmaster@raspii.tech>2021-08-30 16:43:38 +0800
committeralk3pInjection <webmaster@raspii.tech>2021-08-30 16:43:38 +0800
commitcbe033a53bfe49d980774e59025e3b2af91778b7 (patch)
tree558535f91276162e0be70d07b34ed2e6577e38ad /programs/Makefile
parentfdd43c66dd9e77283aa8f7e52a881be44d622441 (diff)
parentd44371841a2f1728a3f36839fd4b7e872d0927d3 (diff)
Merge tag 'v1.9.3' into lineage-18.1HEADlineage-18.1
Change-Id: Iad56c1b17a32f9f356a4c1ff9557f0e79addf481
Diffstat (limited to 'programs/Makefile')
-rw-r--r--programs/Makefile93
1 files changed, 54 insertions, 39 deletions
diff --git a/programs/Makefile b/programs/Makefile
index bd33d9b..c1053f6 100644
--- a/programs/Makefile
+++ b/programs/Makefile
@@ -22,7 +22,7 @@
#
# You can contact the author at :
# - LZ4 homepage : http://www.lz4.org
-# - LZ4 source repository : https://github.com/Cyan4973/lz4
+# - LZ4 source repository : https://github.com/lz4/lz4
# ##########################################################################
# lz4 : Command Line Utility, supporting gzip-like arguments
# lz4c : CLU, supporting also legacy lz4demo arguments
@@ -41,12 +41,13 @@ LIBVER_MINOR := $(shell echo $(LIBVER_MINOR_SCRIPT))
LIBVER_PATCH := $(shell echo $(LIBVER_PATCH_SCRIPT))
LIBVER := $(shell echo $(LIBVER_SCRIPT))
-SRCFILES := $(sort $(wildcard $(LZ4DIR)/*.c) $(wildcard *.c))
-OBJFILES := $(SRCFILES:.c=.o)
+LIBFILES = $(wildcard $(LZ4DIR)/*.c)
+SRCFILES = $(sort $(LIBFILES) $(wildcard *.c))
+OBJFILES = $(SRCFILES:.c=.o)
CPPFLAGS += -I$(LZ4DIR) -DXXH_NAMESPACE=LZ4_
CFLAGS ?= -O3
-DEBUGFLAGS:=-Wall -Wextra -Wundef -Wcast-qual -Wcast-align -Wshadow \
+DEBUGFLAGS= -Wall -Wextra -Wundef -Wcast-qual -Wcast-align -Wshadow \
-Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes \
-Wpointer-arith -Wstrict-aliasing=1
CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS)
@@ -56,17 +57,7 @@ LZ4_VERSION=$(LIBVER)
MD2ROFF = ronn
MD2ROFF_FLAGS = --roff --warnings --manual="User Commands" --organization="lz4 $(LZ4_VERSION)"
-
-# Define *.exe as extension for Windows systems
-ifneq (,$(filter Windows%,$(OS)))
-EXT :=.exe
-VOID := nul
-else
-EXT :=
-VOID := /dev/null
-endif
-
-
+include ../Makefile.inc
default: lz4-release
@@ -75,14 +66,44 @@ all: lz4 lz4c
all32: CFLAGS+=-m32
all32: all
-lz4: $(OBJFILES)
+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
+lz4: $(OBJFILES)
+ $(CC) $(FLAGS) $(OBJFILES) -o $@$(EXT) $(LDLIBS)
+endif
+.PHONY: lz4-release
lz4-release: DEBUGFLAGS=
lz4-release: lz4
+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
+
lz4c: lz4
- ln -s lz4$(EXT) lz4c$(EXT)
+ $(LN_SF) lz4$(EXT) lz4c$(EXT)
lz4c32: CFLAGS += -m32
lz4c32 : $(SRCFILES)
@@ -94,28 +115,32 @@ lz4.1: lz4.1.md $(LIBVER_SRC)
man: lz4.1
clean-man:
- rm lz4.1
+ $(RM) lz4.1
preview-man: clean-man man
man ./lz4.1
clean:
+ifeq ($(WINBASED),yes)
+ $(Q)$(RM) *.rc
+endif
@$(MAKE) -C $(LZ4DIR) $@ > $(VOID)
@$(RM) core *.o *.test tmp* \
- lz4$(EXT) lz4c$(EXT) lz4c32$(EXT) unlz4$(EXT) lz4cat$(EXT)
+ lz4$(EXT) lz4c$(EXT) lz4c32$(EXT) lz4-wlib$(EXT) \
+ unlz4$(EXT) lz4cat$(EXT)
@echo Cleaning completed
#-----------------------------------------------------------------------------
# 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 Haiku MidnightBSD))
+ifeq ($(POSIX_ENV),Yes)
unlz4: lz4
- ln -s lz4$(EXT) unlz4$(EXT)
+ $(LN_SF) lz4$(EXT) unlz4$(EXT)
lz4cat: lz4
- ln -s lz4$(EXT) lz4cat$(EXT)
+ $(LN_SF) lz4$(EXT) lz4cat$(EXT)
DESTDIR ?=
# directory variables : GNU conventions prefer lowercase
@@ -134,28 +159,18 @@ mandir ?= $(MANDIR)
MAN1DIR ?= $(mandir)/man1
man1dir ?= $(MAN1DIR)
-ifneq (,$(filter $(shell uname),SunOS))
-INSTALL ?= ginstall
-else
-INSTALL ?= install
-endif
-
-INSTALL_PROGRAM ?= $(INSTALL) -m 755
-INSTALL_DATA ?= $(INSTALL) -m 644
-
-
install: lz4
@echo Installing binaries
- @$(INSTALL) -d -m 755 $(DESTDIR)$(bindir)/ $(DESTDIR)$(man1dir)/
+ @$(INSTALL_DIR) $(DESTDIR)$(bindir)/ $(DESTDIR)$(man1dir)/
@$(INSTALL_PROGRAM) lz4$(EXT) $(DESTDIR)$(bindir)/lz4$(EXT)
- @ln -sf lz4$(EXT) $(DESTDIR)$(bindir)/lz4c$(EXT)
- @ln -sf lz4$(EXT) $(DESTDIR)$(bindir)/lz4cat$(EXT)
- @ln -sf lz4$(EXT) $(DESTDIR)$(bindir)/unlz4$(EXT)
+ @$(LN_S) lz4$(EXT) $(DESTDIR)$(bindir)/lz4c$(EXT)
+ @$(LN_S) lz4$(EXT) $(DESTDIR)$(bindir)/lz4cat$(EXT)
+ @$(LN_S) lz4$(EXT) $(DESTDIR)$(bindir)/unlz4$(EXT)
@echo Installing man pages
@$(INSTALL_DATA) lz4.1 $(DESTDIR)$(man1dir)/lz4.1
- @ln -sf lz4.1 $(DESTDIR)$(man1dir)/lz4c.1
- @ln -sf lz4.1 $(DESTDIR)$(man1dir)/lz4cat.1
- @ln -sf lz4.1 $(DESTDIR)$(man1dir)/unlz4.1
+ @$(LN_SF) lz4.1 $(DESTDIR)$(man1dir)/lz4c.1
+ @$(LN_SF) lz4.1 $(DESTDIR)$(man1dir)/lz4cat.1
+ @$(LN_SF) lz4.1 $(DESTDIR)$(man1dir)/unlz4.1
@echo lz4 installation completed
uninstall: