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-04-22 23:54:32 +00:00
export RELEASE = rc118
2014-03-12 14:51:59 +00:00
LIBVER_MAJOR = 1
LIBVER_MINOR = 0
LIBVER_PATCH = 0
LIBVER = $( LIBVER_MAJOR) .$( LIBVER_MINOR) .$( LIBVER_PATCH)
2013-10-21 08:03:40 +00:00
DESTDIR =
2014-01-07 18:47:50 +00:00
PREFIX = /usr
2014-03-12 14:51:59 +00:00
CC := $( CC)
CFLAGS += -I. -std= c99 -O3 -Wall -W -Wundef -DLZ4_VERSION= \" $( RELEASE) \"
2014-01-07 18:47:50 +00:00
LIBDIR = $( PREFIX) /lib
INCLUDEDIR = $( PREFIX) /include
PRGDIR = programs
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 )
SONAME_FLAGS =
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-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
@$( CC) $( CFLAGS) -c $^
@ar rcs liblz4.a lz4.o lz4hc.o
@echo compiling dynamic library
@$( CC) $( CFLAGS) -shared $^ -fPIC $( SONAME_FLAGS) -o $@ .$( SHARED_EXT_VER)
@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-03-23 11:15:37 +00:00
@rm -f core *.o *.a *.$( SHARED_EXT) *.$( SHARED_EXT) .* $( DISTRIBNAME) *.sha1
@cd $( PRGDIR) ; $( MAKE) clean
2013-09-25 09:00:37 +00:00
@echo Cleaning completed
2014-03-12 14:51:59 +00:00
#make install option is reserved to Linux & OSX targets
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-01-07 18:47:50 +00:00
install : liblz 4
@install -d -m 755 $( DESTDIR) $( LIBDIR) / $( DESTDIR) $( INCLUDEDIR) /
@install -m 755 liblz4.a $( DESTDIR) $( LIBDIR) /liblz4.a
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-01-07 18:47:50 +00:00
@install -m 755 lz4.h $( DESTDIR) $( INCLUDEDIR) /lz4.h
@install -m 755 lz4hc.h $( DESTDIR) $( INCLUDEDIR) /lz4hc.h
@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-01-07 18:47:50 +00:00
[ -x $( DESTDIR) $( LIBDIR) /liblz4.a ] && rm -f $( DESTDIR) $( LIBDIR) /liblz4.a
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)
[ -x $( DESTDIR) $( LIBDIR) /liblz4.$( SHARED_EXT_VER) ] && rm -f $( DESTDIR) $( LIBDIR) /liblz4.$( SHARED_EXT_VER)
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-04-16 14:26:15 +00:00
test : lz 4programs
@cd $( PRGDIR) ; $( MAKE) -e $@
2013-09-25 09:00:37 +00:00
e n d i f