mirror of
https://github.com/lz4/lz4.git
synced 2024-11-23 18:04:05 +08:00
More build imrpvements
Moved a few other tests to Makefiles.inc. Other things might need to go there. Made a test for symlink appropriateness. Windows can NOT handle them the same way Unix-like operating systems do (if at all). This is mostly the same as the Visual C projects. embed version info into .dll and .exes that are redistributed.
This commit is contained in:
parent
229b016f50
commit
7136489d33
50
Makefile.inc
50
Makefile.inc
@ -1,3 +1,9 @@
|
||||
ifeq ($(V), 1)
|
||||
Q =
|
||||
else
|
||||
Q = @
|
||||
endif
|
||||
|
||||
TARGET_OS ?= $(shell uname)
|
||||
ifeq ($(TARGET_OS),)
|
||||
TARGET_OS ?= $(OS)
|
||||
@ -31,24 +37,17 @@ endif
|
||||
|
||||
ifeq ($(WINBASED),yes)
|
||||
EXT = .exe
|
||||
WINDRES = windres
|
||||
endif
|
||||
|
||||
#determine if dev/nul based on host environment
|
||||
ifneq (,$(filter MINGW%,$(shell uname)))
|
||||
ifneq (,$(filter MINGW% MSYS% CYGWIN%,$(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)))
|
||||
ifneq (,$(filter Windows%,$(OS)))
|
||||
VOID := nul
|
||||
else
|
||||
else
|
||||
VOID := /dev/null
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
@ -57,3 +56,32 @@ POSIX_ENV = Yes
|
||||
else
|
||||
POSIX_ENV = No
|
||||
endif
|
||||
|
||||
# Avoid symlinks when targetting Windows or building on a Windows host
|
||||
ifeq ($(WINBASED),yes)
|
||||
LN_S = cp -p
|
||||
LN_SF = cp -p
|
||||
else
|
||||
ifneq (,$(filter MINGW% MSYS% CYGWIN%,$(shell uname)))
|
||||
LN_S = cp -p
|
||||
LN_SF = cp -p
|
||||
else
|
||||
ifneq (,$(filter Windows%,$(OS)))
|
||||
LN_S = cp -p
|
||||
LN_SF = cp -p
|
||||
else
|
||||
LN_S = ln -s
|
||||
LN_SF = ln -sf
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq (,$(filter $(shell uname),SunOS))
|
||||
INSTALL ?= ginstall
|
||||
else
|
||||
INSTALL ?= install
|
||||
endif
|
||||
|
||||
INSTALL_PROGRAM ?= $(INSTALL) -m 755
|
||||
INSTALL_DATA ?= $(INSTALL) -m 644
|
||||
INSTALL_DIR ?= $(INSTALL) -d -m 755
|
||||
|
75
lib/Makefile
75
lib/Makefile
@ -85,12 +85,6 @@ all: lib
|
||||
all32: CFLAGS+=-m32
|
||||
all32: all
|
||||
|
||||
ifeq ($(V), 1)
|
||||
Q =
|
||||
else
|
||||
Q = @
|
||||
endif
|
||||
|
||||
liblz4.a: $(SRCFILES)
|
||||
ifeq ($(BUILD_STATIC),yes) # can be disabled on command line
|
||||
@echo compiling static library
|
||||
@ -98,17 +92,32 @@ ifeq ($(BUILD_STATIC),yes) # can be disabled on command line
|
||||
$(Q)$(AR) rcs $@ *.o
|
||||
endif
|
||||
|
||||
ifeq ($(WINBASED),yes)
|
||||
liblz4-dll.rc: liblz4-dll.rc.in
|
||||
@echo creating library resource
|
||||
$(Q)sed -e 's|@LIBLZ4@|$(LIBLZ4)|' \
|
||||
-e 's|@LIBVER_MAJOR@|$(LIBVER_MAJOR)|g' \
|
||||
-e 's|@LIBVER_MINOR@|$(LIBVER_MINOR)|g' \
|
||||
-e 's|@LIBVER_PATCH@|$(LIBVER_PATCH)|g' \
|
||||
$< >$@
|
||||
|
||||
liblz4-dll.o: liblz4-dll.rc
|
||||
$(WINDRES) -i liblz4-dll.rc -o liblz4-dll.o
|
||||
|
||||
$(LIBLZ4): $(SRCFILES) liblz4-dll.o
|
||||
else
|
||||
$(LIBLZ4): $(SRCFILES)
|
||||
endif
|
||||
ifeq ($(BUILD_SHARED),yes) # can be disabled on command line
|
||||
@echo compiling dynamic library $(LIBVER)
|
||||
ifeq ($(WINBASED),yes)
|
||||
ifeq ($(WINBASED),yes)
|
||||
$(Q)$(CC) $(FLAGS) -DLZ4_DLL_EXPORT=1 -shared $^ -o dll/$@.dll -Wl,--out-implib,dll/$(LIBLZ4_EXP)
|
||||
else
|
||||
else
|
||||
$(Q)$(CC) $(FLAGS) -shared $^ -fPIC -fvisibility=hidden $(SONAME_FLAGS) -o $@
|
||||
@echo creating versioned links
|
||||
$(Q)ln -sf $@ liblz4.$(SHARED_EXT_MAJOR)
|
||||
$(Q)ln -sf $@ liblz4.$(SHARED_EXT)
|
||||
endif
|
||||
$(Q)$(LN_SF) $@ liblz4.$(SHARED_EXT_MAJOR)
|
||||
$(Q)$(LN_SF) $@ liblz4.$(SHARED_EXT)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq (,$(filter MINGW%,$(TARGET_OS)))
|
||||
@ -116,6 +125,9 @@ liblz4: $(LIBLZ4)
|
||||
endif
|
||||
|
||||
clean:
|
||||
ifeq ($(WINBASED),yes)
|
||||
$(Q)$(RM) *.rc
|
||||
endif
|
||||
$(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
|
||||
@ -144,22 +156,13 @@ libdir ?= $(LIBDIR)
|
||||
INCLUDEDIR ?= $(prefix)/include
|
||||
includedir ?= $(INCLUDEDIR)
|
||||
|
||||
ifneq (,$(filter $(OS),OpenBSD FreeBSD NetBSD DragonFly MidnightBSD))
|
||||
ifneq (,$(filter $(TARGET_OS),OpenBSD FreeBSD NetBSD DragonFly MidnightBSD))
|
||||
PKGCONFIGDIR ?= $(prefix)/libdata/pkgconfig
|
||||
else
|
||||
else
|
||||
PKGCONFIGDIR ?= $(libdir)/pkgconfig
|
||||
endif
|
||||
endif
|
||||
pkgconfigdir ?= $(PKGCONFIGDIR)
|
||||
|
||||
ifneq (,$(filter $(OS),SunOS))
|
||||
INSTALL ?= ginstall
|
||||
else
|
||||
INSTALL ?= install
|
||||
endif
|
||||
|
||||
INSTALL_PROGRAM ?= $(INSTALL)
|
||||
INSTALL_DATA ?= $(INSTALL) -m 644
|
||||
|
||||
liblz4.pc: liblz4.pc.in Makefile
|
||||
@echo creating pkgconfig
|
||||
$(Q)sed -e 's|@PREFIX@|$(prefix)|' \
|
||||
@ -169,26 +172,26 @@ liblz4.pc: liblz4.pc.in Makefile
|
||||
$< >$@
|
||||
|
||||
install: lib liblz4.pc
|
||||
$(Q)$(INSTALL) -d -m 755 $(DESTDIR)$(pkgconfigdir)/ $(DESTDIR)$(includedir)/ $(DESTDIR)$(libdir)/ $(DESTDIR)$(bindir)/
|
||||
$(Q)$(INSTALL_DIR) $(DESTDIR)$(pkgconfigdir)/ $(DESTDIR)$(includedir)/ $(DESTDIR)$(libdir)/ $(DESTDIR)$(bindir)/
|
||||
$(Q)$(INSTALL_DATA) liblz4.pc $(DESTDIR)$(pkgconfigdir)/
|
||||
@echo Installing libraries
|
||||
ifeq ($(BUILD_STATIC),yes)
|
||||
ifeq ($(BUILD_STATIC),yes)
|
||||
$(Q)$(INSTALL_DATA) liblz4.a $(DESTDIR)$(libdir)/liblz4.a
|
||||
$(Q)$(INSTALL_DATA) lz4frame_static.h $(DESTDIR)$(includedir)/lz4frame_static.h
|
||||
endif
|
||||
ifeq ($(BUILD_SHARED),yes)
|
||||
endif
|
||||
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.
|
||||
ifeq ($(WINBASED),yes)
|
||||
ifeq ($(WINBASED),yes)
|
||||
$(Q)$(INSTALL_PROGRAM) dll/$(LIBLZ4).dll $(DESTDIR)$(bindir)
|
||||
$(Q)$(INSTALL_PROGRAM) dll/$(LIBLZ4_EXP) $(DESTDIR)$(libdir)
|
||||
else
|
||||
else
|
||||
$(Q)$(INSTALL_PROGRAM) liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(libdir)
|
||||
$(Q)ln -sf liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT_MAJOR)
|
||||
$(Q)ln -sf liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT)
|
||||
endif
|
||||
endif
|
||||
$(Q)$(LN_SF) liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT_MAJOR)
|
||||
$(Q)$(LN_SF) liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT)
|
||||
endif
|
||||
endif
|
||||
@echo Installing headers in $(includedir)
|
||||
$(Q)$(INSTALL_DATA) lz4.h $(DESTDIR)$(includedir)/lz4.h
|
||||
$(Q)$(INSTALL_DATA) lz4hc.h $(DESTDIR)$(includedir)/lz4hc.h
|
||||
@ -197,14 +200,14 @@ endif
|
||||
|
||||
uninstall:
|
||||
$(Q)$(RM) $(DESTDIR)$(pkgconfigdir)/liblz4.pc
|
||||
ifeq (WINBASED,1)
|
||||
ifeq (WINBASED,1)
|
||||
$(Q)$(RM) $(DESTDIR)$(bindir)/$(LIBLZ4).dll
|
||||
$(Q)$(RM) $(DESTDIR)$(libdir)/$(LIBLZ4_EXP)
|
||||
else
|
||||
else
|
||||
$(Q)$(RM) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT)
|
||||
$(Q)$(RM) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT_MAJOR)
|
||||
$(Q)$(RM) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT_VER)
|
||||
endif
|
||||
endif
|
||||
$(Q)$(RM) $(DESTDIR)$(libdir)/liblz4.a
|
||||
$(Q)$(RM) $(DESTDIR)$(includedir)/lz4.h
|
||||
$(Q)$(RM) $(DESTDIR)$(includedir)/lz4hc.h
|
||||
|
35
lib/liblz4-dll.rc.in
Normal file
35
lib/liblz4-dll.rc.in
Normal file
@ -0,0 +1,35 @@
|
||||
#include <windows.h>
|
||||
|
||||
// DLL version information.
|
||||
1 VERSIONINFO
|
||||
FILEVERSION @LIBVER_MAJOR@,@LIBVER_MINOR@,@LIBVER_PATCH@,0
|
||||
PRODUCTVERSION @LIBVER_MAJOR@,@LIBVER_MINOR@,@LIBVER_PATCH@,0
|
||||
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS VS_FF_DEBUG | VS_FF_PRERELEASE
|
||||
#else
|
||||
FILEFLAGS 0
|
||||
#endif
|
||||
FILEOS VOS_NT_WINDOWS32
|
||||
FILETYPE VFT_DLL
|
||||
FILESUBTYPE VFT2_UNKNOWN
|
||||
BEGIN
|
||||
BLOCK "StringFileInfo"
|
||||
BEGIN
|
||||
BLOCK "040904B0"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "Yann Collet"
|
||||
VALUE "FileDescription", "Extremely fast compression"
|
||||
VALUE "FileVersion", "@LIBVER_MAJOR@.@LIBVER_MINOR@.@LIBVER_PATCH@.0"
|
||||
VALUE "InternalName", "@LIBLZ4@"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2013-2016, Yann Collet"
|
||||
VALUE "OriginalFilename", "@LIBLZ4@.dll"
|
||||
VALUE "ProductName", "LZ4"
|
||||
VALUE "ProductVersion", "@LIBVER_MAJOR@.@LIBVER_MINOR@.@LIBVER_PATCH@.0"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
BEGIN
|
||||
VALUE "Translation", 0x0409, 1200
|
||||
END
|
||||
END
|
@ -65,14 +65,32 @@ all: lz4 lz4c
|
||||
all32: CFLAGS+=-m32
|
||||
all32: all
|
||||
|
||||
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) $^ -o $@$(EXT)
|
||||
endif
|
||||
|
||||
|
||||
lz4-release: DEBUGFLAGS=
|
||||
lz4-release: lz4
|
||||
|
||||
lz4c: lz4
|
||||
ln -s lz4$(EXT) lz4c$(EXT)
|
||||
$(LN_SF) lz4$(EXT) lz4c$(EXT)
|
||||
|
||||
lz4c32: CFLAGS += -m32
|
||||
lz4c32 : $(SRCFILES)
|
||||
@ -90,6 +108,9 @@ 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)
|
||||
@ -99,13 +120,13 @@ clean:
|
||||
#-----------------------------------------------------------------------------
|
||||
# make install is validated only for Linux, OSX, BSD, Hurd and Solaris targets
|
||||
#-----------------------------------------------------------------------------
|
||||
ifneq (,$(filter Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku MidnightBSD MINGW32_NT% MINGW64_NT% MSYS% CYGWIN_NT%,$(shell uname)))
|
||||
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
|
||||
@ -124,28 +145,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:
|
||||
|
27
programs/lz4-exe.rc.in
Normal file
27
programs/lz4-exe.rc.in
Normal file
@ -0,0 +1,27 @@
|
||||
1 VERSIONINFO
|
||||
FILEVERSION @LIBVER_MAJOR@,@LIBVER_MINOR@,@LIBVER_PATCH@,0
|
||||
PRODUCTVERSION @LIBVER_MAJOR@,@LIBVER_MINOR@,@LIBVER_PATCH@,0
|
||||
FILEFLAGSMASK 0
|
||||
FILEOS 0x40000
|
||||
FILETYPE 1
|
||||
{
|
||||
BLOCK "StringFileInfo"
|
||||
{
|
||||
BLOCK "040904B0"
|
||||
{
|
||||
VALUE "CompanyName", "Yann Collet"
|
||||
VALUE "FileDescription", "Extremely fast compression"
|
||||
VALUE "FileVersion", "@LIBVER_MAJOR@.@LIBVER_MINOR@.@LIBVER_PATCH@.0"
|
||||
VALUE "InternalName", "@PROGNAME@"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2013-2016, Yann Collet"
|
||||
VALUE "OriginalFilename", "@PROGNAME@.@EXT@"
|
||||
VALUE "ProductName", "LZ4"
|
||||
VALUE "ProductVersion", "@LIBVER_MAJOR@.@LIBVER_MINOR@.@LIBVER_PATCH@.0"
|
||||
}
|
||||
}
|
||||
BLOCK "VarFileInfo"
|
||||
{
|
||||
VALUE "Translation", 0x0409, 1200
|
||||
}
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ lib liblz4.pc:
|
||||
$(MAKE) -C $(LZ4DIR) $@ CFLAGS="$(CFLAGS)"
|
||||
|
||||
lz4c unlz4 lz4cat: lz4
|
||||
ln -sf $(LZ4) $(PRGDIR)/$@
|
||||
$(LN_SF) $(LZ4) $(PRGDIR)/$@
|
||||
|
||||
lz4c32: # create a 32-bits version for 32/64 interop tests
|
||||
$(MAKE) -C $(PRGDIR) $@ CFLAGS="-m32 $(CFLAGS)"
|
||||
|
Loading…
Reference in New Issue
Block a user