2013-09-09 09:06:21 +00:00
# ################################################################
2014-01-07 18:47:50 +00:00
# LZ4 library - Makefile
# Copyright (C) Yann Collet 2011-2014
# All rights reserved.
#
# BSD license
# Redistribution and use in source and binary forms, with or without modification,
# are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice, this
# list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice, this
# list of conditions and the following disclaimer in the documentation and/or
# other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
2013-09-09 09:06:21 +00:00
# You can contact the author at :
# - LZ4 source repository : http://code.google.com/p/lz4/
2013-09-25 09:00:37 +00:00
# - LZ4 forum froup : https://groups.google.com/forum/#!forum/lz4c
2013-09-09 09:06:21 +00:00
# ################################################################
2014-06-14 15:56:24 +00:00
# Version numbers
2014-07-20 15:18:48 +00:00
VERSION = 120
export RELEASE = r$( VERSION)
2014-03-12 14:51:59 +00:00
LIBVER_MAJOR = 1
2014-07-14 22:04:10 +00:00
LIBVER_MINOR = 3
2014-03-12 14:51:59 +00:00
LIBVER_PATCH = 0
LIBVER = $( LIBVER_MAJOR) .$( LIBVER_MINOR) .$( LIBVER_PATCH)
2013-10-21 08:03:40 +00:00
DESTDIR =
2014-06-24 17:59:51 +00:00
PREFIX = /usr
CC := $( CC)
2014-07-21 20:01:59 +00:00
CFLAGS ?= -O3
CFLAGS += -I. -std= c99 -Wall -Wextra -Wundef -Wshadow -Wstrict-prototypes -DLZ4_VERSION= \" $( RELEASE) \"
2014-01-07 18:47:50 +00:00
2014-06-24 17:59:51 +00:00
LIBDIR ?= $( PREFIX) /lib
2014-01-07 18:47:50 +00:00
INCLUDEDIR = $( PREFIX) /include
2014-06-24 17:59:51 +00:00
PRGDIR = programs
2014-01-07 18:47:50 +00:00
DISTRIBNAME = lz4-$( RELEASE) .tar.gz
2012-03-09 21:46:59 +00:00
2013-09-09 09:06:21 +00:00
# Define *.exe as extension for Windows systems
2013-09-25 09:00:37 +00:00
i f n e q ( , $( filter Windows %,$ ( OS ) ) )
2012-10-24 12:59:19 +00:00
EXT = .exe
2013-09-25 09:00:37 +00:00
e l s e
EXT =
2012-03-09 21:46:59 +00:00
e n d i f
2014-03-23 11:15:37 +00:00
# OS X linker doesn't support -soname, and use different extension
# see : https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html
i f e q ( $( shell uname ) , D a r w i n )
SHARED_EXT = dylib
2014-03-24 20:59:20 +00:00
SHARED_EXT_MAJOR = $( LIBVER_MAJOR) .$( SHARED_EXT)
SHARED_EXT_VER = $( LIBVER) .$( SHARED_EXT)
2014-07-05 12:05:55 +00:00
SONAME_FLAGS = -install_name $( PREFIX) /lib/liblz4.$( SHARED_EXT_MAJOR) -compatibility_version $( LIBVER_MAJOR) -current_version $( LIBVER)
2014-03-23 11:15:37 +00:00
e l s e
SONAME_FLAGS = -Wl,-soname= liblz4.$( SHARED_EXT) .$( LIBVER_MAJOR)
SHARED_EXT = so
2014-03-24 20:59:20 +00:00
SHARED_EXT_MAJOR = $( SHARED_EXT) .$( LIBVER_MAJOR)
SHARED_EXT_VER = $( SHARED_EXT) .$( LIBVER)
2014-03-23 11:15:37 +00:00
e n d i f
2014-01-07 18:47:50 +00:00
TEXT = lz4.c lz4.h lz4hc.c lz4hc.h \
2014-04-15 18:43:39 +00:00
lz4_format_description.txt Makefile NEWS LICENSE README.md \
2014-01-07 18:47:50 +00:00
cmake_unofficial/CMakeLists.txt \
$( PRGDIR) /fullbench.c $( PRGDIR) /fuzzer.c $( PRGDIR) /lz4cli.c \
2014-02-04 14:11:10 +00:00
$( PRGDIR) /lz4io.c $( PRGDIR) /lz4io.h \
2014-01-07 18:47:50 +00:00
$( PRGDIR) /bench.c $( PRGDIR) /bench.h \
$( PRGDIR) /xxhash.c $( PRGDIR) /xxhash.h \
2014-04-15 14:47:48 +00:00
$( PRGDIR) /lz4.1 $( PRGDIR) /lz4c.1 $( PRGDIR) /lz4cat.1 \
$( PRGDIR) /Makefile $( PRGDIR) /COPYING
2013-10-01 20:32:43 +00:00
NONTEXT = LZ4_Streaming_Format.odt
SOURCES = $( TEXT) $( NONTEXT)
2013-09-25 09:00:37 +00:00
2014-01-07 18:47:50 +00:00
default : liblz 4
2014-03-12 14:51:59 +00:00
@cd $( PRGDIR) ; $( MAKE) -e
2013-07-01 07:50:40 +00:00
2014-01-07 18:47:50 +00:00
all : liblz 4 lz 4programs
2011-05-25 22:25:57 +00:00
2014-01-07 18:47:50 +00:00
lz4programs : lz 4.c lz 4hc .c
2014-03-12 14:51:59 +00:00
@cd $( PRGDIR) ; $( MAKE) -e all
2013-08-12 08:35:52 +00:00
2014-03-24 20:59:20 +00:00
liblz4 : lz 4.c lz 4hc .c
@echo compiling static library
2014-07-21 20:01:59 +00:00
@$( CC) $( CPPFLAGS) $( CFLAGS) -c $^
2014-05-21 18:46:36 +00:00
@$( AR) rcs liblz4.a lz4.o lz4hc.o
2014-03-24 20:59:20 +00:00
@echo compiling dynamic library
2014-07-21 20:01:59 +00:00
@$( CC) $( CPPFLAGS) $( CFLAGS) $( LDFLAGS) -shared $^ -fPIC $( SONAME_FLAGS) -o $@ .$( SHARED_EXT_VER)
2014-03-24 20:59:20 +00:00
@echo creating versioned links
@ln -sf $@ .$( SHARED_EXT_VER) $@ .$( SHARED_EXT_MAJOR)
@ln -sf $@ .$( SHARED_EXT_VER) $@ .$( SHARED_EXT)
2013-08-12 08:35:52 +00:00
2011-05-25 22:25:57 +00:00
clean :
2014-07-20 15:18:48 +00:00
@rm -f core *.o *.a *.$( SHARED_EXT) *.$( SHARED_EXT) .* $( DISTRIBNAME) *.sha1 liblz4.pc
2014-03-23 11:15:37 +00:00
@cd $( PRGDIR) ; $( MAKE) clean
2013-09-25 09:00:37 +00:00
@echo Cleaning completed
2014-07-20 15:18:48 +00:00
#------------------------------------------------------------------------
2014-06-09 00:01:04 +00:00
#make install option is designed for Linux & OSX targets only
2014-07-20 15:18:48 +00:00
2014-01-07 18:47:50 +00:00
i f n e q ( , $( filter $ ( shell uname ) ,Linux Darwin ) )
2013-09-25 09:00:37 +00:00
2014-07-20 15:18:48 +00:00
liblz4.pc : liblz 4.pc .in Makefile
sed -e 's|@PREFIX@|$(PREFIX)|' \
-e 's|@LIBDIR@|$(LIBDIR)|' \
-e 's|@INCLUDEDIR@|$(INCLUDEDIR)|' \
-e 's|@VERSION@|$(VERSION)|' \
$< >$@
install : liblz 4 liblz 4.pc
@install -d -m 755 $( DESTDIR) $( LIBDIR) /pkgconfig/ $( DESTDIR) $( INCLUDEDIR) /
2014-03-24 20:59:20 +00:00
@install -m 755 liblz4.$( SHARED_EXT_VER) $( DESTDIR) $( LIBDIR) /liblz4.$( SHARED_EXT_VER)
@cp -a liblz4.$( SHARED_EXT_MAJOR) $( DESTDIR) $( LIBDIR)
2014-03-23 11:15:37 +00:00
@cp -a liblz4.$( SHARED_EXT) $( DESTDIR) $( LIBDIR)
2014-07-20 15:18:48 +00:00
@cp -a liblz4.pc $( DESTDIR) $( LIBDIR) /pkgconfig/
2014-06-09 00:01:04 +00:00
@install -m 644 liblz4.a $( DESTDIR) $( LIBDIR) /liblz4.a
@install -m 644 lz4.h $( DESTDIR) $( INCLUDEDIR) /lz4.h
@install -m 644 lz4hc.h $( DESTDIR) $( INCLUDEDIR) /lz4hc.h
2014-01-07 18:47:50 +00:00
@echo lz4 static and shared library installed
2014-03-23 11:15:37 +00:00
@cd $( PRGDIR) ; $( MAKE) -e install
2013-09-25 09:00:37 +00:00
uninstall :
2014-03-23 11:15:37 +00:00
rm -f $( DESTDIR) $( LIBDIR) /liblz4.$( SHARED_EXT)
2014-03-24 20:59:20 +00:00
rm -f $( DESTDIR) $( LIBDIR) /liblz4.$( SHARED_EXT_MAJOR)
2014-07-20 15:18:48 +00:00
rm -f $( DESTDIR) $( LIBDIR) /pkgconfig/liblz4.pc
2014-03-24 20:59:20 +00:00
[ -x $( DESTDIR) $( LIBDIR) /liblz4.$( SHARED_EXT_VER) ] && rm -f $( DESTDIR) $( LIBDIR) /liblz4.$( SHARED_EXT_VER)
2014-06-09 00:01:04 +00:00
[ -f $( DESTDIR) $( LIBDIR) /liblz4.a ] && rm -f $( DESTDIR) $( LIBDIR) /liblz4.a
2014-01-08 18:50:11 +00:00
[ -f $( DESTDIR) $( INCLUDEDIR) /lz4.h ] && rm -f $( DESTDIR) $( INCLUDEDIR) /lz4.h
[ -f $( DESTDIR) $( INCLUDEDIR) /lz4hc.h ] && rm -f $( DESTDIR) $( INCLUDEDIR) /lz4hc.h
2014-01-07 18:47:50 +00:00
@echo lz4 libraries successfully uninstalled
2014-03-23 11:15:37 +00:00
@cd $( PRGDIR) ; $( MAKE) uninstall
2013-09-25 09:00:37 +00:00
dist : clean
2014-01-07 18:47:50 +00:00
@install -dD -m 700 lz4-$( RELEASE) /programs/
@install -dD -m 700 lz4-$( RELEASE) /cmake_unofficial/
2013-10-01 20:32:43 +00:00
@for f in $( TEXT) ; do \
tr -d '\r' < $$ f > .tmp; \
install -m 600 .tmp lz4-$( RELEASE) /$$ f; \
done
@rm .tmp
@for f in $( NONTEXT) ; do \
2013-09-25 09:00:37 +00:00
install -m 600 $$ f lz4-$( RELEASE) /$$ f; \
done
2013-10-01 20:32:43 +00:00
@tar -czf $( DISTRIBNAME) lz4-$( RELEASE) /
2013-09-25 09:00:37 +00:00
@rm -rf lz4-$( RELEASE)
2014-03-23 11:15:37 +00:00
@sha1sum $( DISTRIBNAME) > $( DISTRIBNAME) .sha1
2013-10-01 20:32:43 +00:00
@echo Distribution $( DISTRIBNAME) built
2013-09-25 09:00:37 +00:00
2014-07-21 20:01:59 +00:00
test :
@cd $( PRGDIR) ; $( MAKE) -e $@
test-travis : lz 4programs
2014-04-16 14:26:15 +00:00
@cd $( PRGDIR) ; $( MAKE) -e $@
2013-09-25 09:00:37 +00:00
e n d i f