From 773b66547f84792fd4143e605ca27f31c2989945 Mon Sep 17 00:00:00 2001 From: JPeterMugaas Date: Mon, 22 Apr 2019 13:48:59 -0400 Subject: Initial commits from diff I submitted earlier --- Makefile | 53 +++++++++++++++++++++++++++++++++++++---- examples/Makefile | 47 ++++++++++++++++++++++++++++++++---- lib/Makefile | 42 +++++++++++++++++++++++--------- programs/Makefile | 41 ++++++++++++++++++++++++++++---- tests/Makefile | 71 +++++++++++++++++++++++++++++++++++++++++++++++++------ 5 files changed, 221 insertions(+), 33 deletions(-) diff --git a/Makefile b/Makefile index f3c6ce2..51b4216 100644 --- a/Makefile +++ b/Makefile @@ -36,15 +36,50 @@ TESTDIR = tests EXDIR = examples -# Define nul output -ifneq (,$(filter Windows%,$(OS))) +# Define *.exe as extension for targetting Windows systems +TARGET_OS ?= $(shell uname) +ifeq ($(TARGET_OS),) + TARGET_OS ?= $(OS) +endif + +ifneq (,$(filter Windows%,$(TARGET_OS))) +LIBLZ4 = liblz4-$(LIBVER_MAJOR) +EXT = .exe +else +EXT = .exe +ifneq (,$(filter MINGW%,$(TARGET_OS))) +EXT = .exe +else +ifneq (,$(filter MSYS%,$(TARGET_OS))) +EXT = .exe +else +ifneq (,$(filter CYGWIN%,$(TARGET_OS))) EXT = .exe -VOID = nul else EXT = -VOID = /dev/null +endif +endif +endif endif +#determine if dev/nul based on host environment +ifneq (,$(filter MINGW%,$(shell uname))) +VOID := /dev/null +else +ifneq (,$(filter MSYS%,$(shell uname))) +VOID := /dev/null +else +ifneq (,$(filter CYGWIN%,$(shell uname))) +VOID := /dev/null +else +ifneq (,$(filter Windows%,$(OS))) +VOID := nul +else +VOID := /dev/null +endif +endif +endif +endif .PHONY: default default: lib-release lz4-release @@ -93,7 +128,7 @@ clean: #----------------------------------------------------------------------------- # 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 MINGW32_NT-6.1 MINGW64_NT-6.1 MINGW32_NT-10.0 MINGW64_NT-10.0)) +ifneq (,$(filter Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku MidnightBSD MINGW32% MINGW64% CYGWIN% MSYS%,$(shell uname))) HOST_OS = POSIX .PHONY: install uninstall @@ -181,6 +216,14 @@ gpptest gpptest32: clean CC=$(CC) $(MAKE) -C $(PRGDIR) all CFLAGS="$(CFLAGS)" CC=$(CC) $(MAKE) -C $(TESTDIR) all CFLAGS="$(CFLAGS)" +cxx17build : CC = "$(CXX) -Wno-deprecated" +cxx17build : CFLAGS = -std=c++17 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror -pedantic +cxx17build : clean + $(CXX) -v + CC=$(CC) $(MAKE) -C $(LZ4DIR) all CFLAGS="$(CFLAGS)" + CC=$(CC) $(MAKE) -C $(PRGDIR) all CFLAGS="$(CFLAGS)" + CC=$(CC) $(MAKE) -C $(TESTDIR) all CFLAGS="$(CFLAGS)" + ctocpptest: LIBCC="$(CC)" ctocpptest: TESTCC="$(CXX)" ctocpptest: CFLAGS="" diff --git a/examples/Makefile b/examples/Makefile index 103e7ec..26aaafd 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -38,14 +38,51 @@ LZ4 = ../programs/lz4 # Define *.exe as extension for Windows systems -ifneq (,$(filter Windows%,$(OS))) -EXT =.exe -VOID = nul + +# Define *.exe as extension for targetting Windows systems +TARGET_OS ?= $(shell uname) +ifeq ($(TARGET_OS),) + TARGET_OS ?= $(OS) +endif + +ifneq (,$(filter Windows%,$(TARGET_OS))) +LIBLZ4 = liblz4-$(LIBVER_MAJOR) +EXT = .exe +else +EXT = .exe +ifneq (,$(filter MINGW%,$(TARGET_OS))) +EXT = .exe else -EXT = -VOID = /dev/null +ifneq (,$(filter MSYS%,$(TARGET_OS))) +EXT = .exe +else +ifneq (,$(filter CYGWIN%,$(TARGET_OS))) +EXT = .exe +else +EXT = +endif +endif +endif endif +#determine if dev/nul based on host environment +ifneq (,$(filter MINGW%,$(shell uname))) +VOID := /dev/null +else +ifneq (,$(filter MSYS%,$(shell uname))) +VOID := /dev/null +else +ifneq (,$(filter CYGWIN%,$(shell uname))) +VOID := /dev/null +else +ifneq (,$(filter Windows%,$(OS))) +VOID := nul +else +VOID := /dev/null +endif +endif +endif +endif default: all diff --git a/lib/Makefile b/lib/Makefile index cb1571c..4e96b57 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -45,7 +45,10 @@ LIBVER := $(shell echo $(LIBVER_SCRIPT)) BUILD_SHARED:=yes BUILD_STATIC:=yes -OS ?= $(shell uname) +TARGET_OS ?= $(shell uname) +ifeq ($(TARGET_OS),) + TARGET_OS ?= $(OS) +endif CPPFLAGS+= -DXXH_NAMESPACE=LZ4_ CFLAGS ?= -O3 DEBUGFLAGS:= -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \ @@ -71,10 +74,26 @@ else SHARED_EXT_VER = $(SHARED_EXT).$(LIBVER) endif -ifneq (,$(filter Windows%,$(OS))) +WINBASED = yes +ifneq (,$(filter Windows%,$(TARGET_OS))) LIBLZ4 = liblz4-$(LIBVER_MAJOR) +LIBLZ4_EXP = liblz4.lib +else +LIBLZ4_EXP = liblz4.dll.a +ifneq (,$(filter MINGW%,$(TARGET_OS))) +LIBLZ4 = liblz4 +else +ifneq (,$(filter MSYS%,$(TARGET_OS))) +LIBLZ4 = msys-lz4-$(LIBVER_MAJOR) +else +ifneq (,$(filter CYGWIN%,$(TARGET_OS))) +LIBLZ4 = cyglz4-$(LIBVER_MAJOR) else LIBLZ4 = liblz4.$(SHARED_EXT_VER) +WINBASED = no +endif +endif +endif endif .PHONY: default @@ -106,8 +125,8 @@ endif $(LIBLZ4): $(SRCFILES) ifeq ($(BUILD_SHARED),yes) # can be disabled on command line @echo compiling dynamic library $(LIBVER) -ifneq (,$(filter Windows%,$(OS))) - $(Q)$(CC) $(FLAGS) -DLZ4_DLL_EXPORT=1 -shared $^ -o dll/$@.dll -Wl,--out-implib,dll/liblz4.lib +ifeq ($(WINBASED),yes) + $(Q)$(CC) $(FLAGS) -DLZ4_DLL_EXPORT=1 -shared $^ -o dll/$@.dll -Wl,--out-implib,dll/$(LIBLZ4_EXP) else $(Q)$(CC) $(FLAGS) -shared $^ -fPIC -fvisibility=hidden $(SONAME_FLAGS) -o $@ @echo creating versioned links @@ -116,18 +135,19 @@ else endif endif +ifeq (,$(filter MINGW%,$(TARGET_OS))) liblz4: $(LIBLZ4) +endif clean: - $(Q)$(RM) core *.o liblz4.pc dll/liblz4.dll dll/liblz4.lib + $(Q)$(RM) core *.o liblz4.pc dll/$(LIBLZ4).dll dll/$(LIBLZ4_EXP) $(Q)$(RM) *.a *.$(SHARED_EXT) *.$(SHARED_EXT_MAJOR) *.$(SHARED_EXT_VER) @echo Cleaning library 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 MINGW32_NT-6.1 MINGW64_NT-6.1 MINGW32_NT-10.0 MINGW64_NT-10.0)) +ifneq (,$(filter Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku MidnightBSD MINGW32_NT% MINGW64_NT% MSYS% CYGWIN_NT%,$(shell uname))) .PHONY: listL120 listL120: # extract lines >= 120 characters in *.{c,h}, by Takayuki Matsuoka (note : $$, for Makefile compatibility) @@ -184,9 +204,9 @@ ifeq ($(BUILD_SHARED),yes) # Traditionnally, one installs the DLLs in the bin directory as programs # search them first in their directory. This allows to not pollute system # directories (like c:/windows/system32), nor modify the PATH variable. -ifneq (,$(filter Windows%,$(OS))) +ifeq ($(WINBASED),yes) $(Q)$(INSTALL_PROGRAM) dll/$(LIBLZ4).dll $(DESTDIR)$(bindir) - $(Q)$(INSTALL_PROGRAM) dll/liblz4.lib $(DESTDIR)$(libdir) + $(Q)$(INSTALL_PROGRAM) dll/$(LIBLZ4_EXP) $(DESTDIR)$(libdir) else $(Q)$(INSTALL_PROGRAM) liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(libdir) $(Q)ln -sf liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT_MAJOR) @@ -201,9 +221,9 @@ endif uninstall: $(Q)$(RM) $(DESTDIR)$(pkgconfigdir)/liblz4.pc -ifneq (,$(filter Windows%,$(OS))) +ifeq (WINBASED,1) $(Q)$(RM) $(DESTDIR)$(bindir)/$(LIBLZ4).dll - $(Q)$(RM) $(DESTDIR)$(libdir)/liblz4.lib + $(Q)$(RM) $(DESTDIR)$(libdir)/$(LIBLZ4_EXP) else $(Q)$(RM) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT) $(Q)$(RM) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT_MAJOR) diff --git a/programs/Makefile b/programs/Makefile index 92fd683..47912d8 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -56,17 +56,48 @@ LZ4_VERSION=$(LIBVER) MD2ROFF = ronn MD2ROFF_FLAGS = --roff --warnings --manual="User Commands" --organization="lz4 $(LZ4_VERSION)" +TARGET_OS ?= $(shell uname) +ifeq ($(TARGET_OS),) + TARGET_OS ?= $(OS) +endif # Define *.exe as extension for Windows systems -ifneq (,$(filter Windows%,$(OS))) +ifneq (,$(filter Windows%,$(TARGET_OS))) +EXT :=.exe +else +ifneq (,$(filter MINGW%,$(TARGET_OS))) +EXT :=.exe +else +ifneq (,$(filter MSYS%,$(TARGET_OS))) +EXT :=.exe +else +ifneq (,$(filter CYGWIN%,$(TARGET_OS))) EXT :=.exe -VOID := nul else EXT := -VOID := /dev/null +endif +endif +endif endif - +#determine if dev/nul based on host environment +ifneq (,$(filter MINGW%,$(shell uname))) +VOID := /dev/null +else +ifneq (,$(filter MSYS%,$(shell uname))) +VOID := /dev/null +else +ifneq (,$(filter CYGWIN%,$(shell uname))) +VOID := /dev/null +else +ifneq (,$(filter Windows%,$(OS))) +VOID := nul +else +VOID := /dev/null +endif +endif +endif +endif default: lz4-release @@ -109,7 +140,7 @@ clean: #----------------------------------------------------------------------------- # 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 MINGW32_NT-6.1 MINGW64_NT-6.1 MINGW32_NT-10.0 MINGW64_NT-10.0)) +ifneq (,$(filter Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku MidnightBSD MINGW32_NT% MINGW64_NT% MSYS% CYGWIN_NT%,$(shell uname))) unlz4: lz4 ln -s lz4$(EXT) unlz4$(EXT) diff --git a/tests/Makefile b/tests/Makefile index 70cae63..d8104de 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -43,15 +43,72 @@ CFLAGS += $(DEBUGFLAGS) $(MOREFLAGS) CPPFLAGS+= -I$(LZ4DIR) -I$(PRGDIR) -DXXH_NAMESPACE=LZ4_ FLAGS = $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) - # Define *.exe as extension for Windows systems +TARGET_OS ?= $(shell uname) +ifeq ($(TARGET_OS),) + TARGET_OS ?= $(OS) +endif + +ifneq (,$(filter Windows%,$(TARGET_OS))) +EXT :=.exe +else +ifneq (,$(filter MINGW%,$(TARGET_OS))) +EXT :=.exe +else +ifneq (,$(filter MSYS%,$(TARGET_OS))) +EXT :=.exe +else +ifneq (,$(filter CYGWIN%,$(TARGET_OS))) +EXT :=.exe +else +EXT := +endif +endif +endif +endif + +# determine name of .DLL for the target +WINBASED = yes +ifneq (,$(filter Windows%,$(TARGET_OS))) +LIBLZ4 = liblz4-$(LIBVER_MAJOR) +LIBLZ4_EXP = liblz4.lib +else +LIBLZ4_EXP = liblz4.dll.a +ifneq (,$(filter MINGW%,$(TARGET_OS))) +LIBLZ4 = liblz4 +else +ifneq (,$(filter MSYS%,$(TARGET_OS))) +LIBLZ4 = msys-lz4-$(LIBVER_MAJOR) +else +ifneq (,$(filter CYGWIN%,$(TARGET_OS))) +LIBLZ4 = cyglz4-$(LIBVER_MAJOR) +else +LIBLZ4 = liblz4.$(SHARED_EXT_VER) +WINBASED = no +endif +endif +endif +endif + +#determine if dev/nul based on host environment +ifneq (,$(filter MINGW%,$(shell uname))) +VOID := /dev/null +else +ifneq (,$(filter MSYS%,$(shell uname))) +VOID := /dev/null +else +ifneq (,$(filter CYGWIN%,$(shell uname))) +VOID := /dev/null +else ifneq (,$(filter Windows%,$(OS))) -EXT =.exe -VOID = nul +VOID := nul else -EXT = -VOID = /dev/null +VOID := /dev/null +endif endif +endif +endif + LZ4 := $(PRGDIR)/lz4$(EXT) @@ -95,7 +152,7 @@ fullbench-lib: fullbench.c $(LZ4DIR)/liblz4.a fullbench-dll: fullbench.c $(LZ4DIR)/xxhash.c $(MAKE) -C $(LZ4DIR) liblz4 - $(CC) $(FLAGS) $^ -o $@$(EXT) -DLZ4_DLL_IMPORT=1 $(LZ4DIR)/dll/liblz4.dll + $(CC) $(FLAGS) $^ -o $@$(EXT) -DLZ4_DLL_IMPORT=1 $(LZ4DIR)/dll/$(LIBLZ4).dll fuzzer : lz4.o lz4hc.o xxhash.o fuzzer.c $(CC) $(FLAGS) $^ -o $@$(EXT) @@ -137,7 +194,7 @@ checkTag: checkTag.c $(LZ4DIR)/lz4.h #----------------------------------------------------------------------------- # 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)) +ifneq (,$(filter Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku MidnightBSD MINGW32% MINGW64% CYGWIN% MSYS%,$(shell uname))) MD5:=md5sum ifneq (,$(filter $(shell uname), Darwin )) -- cgit v0.12