Makefile revision f71340ce1d8daa9f13cf4f1ecf2a21f23e3790ff
1d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# ################################################################ 2d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# LZ4 library - Makefile 3daa320f3f7bd9cc121462ef7a201fad87f540bd6Yann Collet# Copyright (C) Yann Collet 2011-2015 4d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# All rights reserved. 54fcb2e17fb065f1d061a9c72066dd4dc1eb94a3fJulius Werner# 6d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# BSD license 7d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# Redistribution and use in source and binary forms, with or without modification, 8d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# are permitted provided that the following conditions are met: 94fcb2e17fb065f1d061a9c72066dd4dc1eb94a3fJulius Werner# 10d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# * Redistributions of source code must retain the above copyright notice, this 11d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# list of conditions and the following disclaimer. 124fcb2e17fb065f1d061a9c72066dd4dc1eb94a3fJulius Werner# 13d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# * Redistributions in binary form must reproduce the above copyright notice, this 14d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# list of conditions and the following disclaimer in the documentation and/or 15d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# other materials provided with the distribution. 164fcb2e17fb065f1d061a9c72066dd4dc1eb94a3fJulius Werner# 17d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 21d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 24d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 274fcb2e17fb065f1d061a9c72066dd4dc1eb94a3fJulius Werner# 28d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# You can contact the author at : 292b55752a5c749e57bbd4c9b830ccf939510beec1Yann Collet# - LZ4 source repository : https://github.com/Cyan4973/lz4 30d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# - LZ4 forum froup : https://groups.google.com/forum/#!forum/lz4c 31d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# ################################################################ 32d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet 33d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# Version numbers 3428f98647e3349a4a0a9c8975199aa89f2a02f6b9Yann ColletLIBVER_MAJOR_SCRIPT:=`sed -n '/define LZ4_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./lz4.h` 3528f98647e3349a4a0a9c8975199aa89f2a02f6b9Yann ColletLIBVER_MINOR_SCRIPT:=`sed -n '/define LZ4_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./lz4.h` 3628f98647e3349a4a0a9c8975199aa89f2a02f6b9Yann ColletLIBVER_PATCH_SCRIPT:=`sed -n '/define LZ4_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./lz4.h` 3728f98647e3349a4a0a9c8975199aa89f2a02f6b9Yann ColletLIBVER_SCRIPT:= $(LIBVER_MAJOR_SCRIPT).$(LIBVER_MINOR_SCRIPT).$(LIBVER_PATCH_SCRIPT) 3828f98647e3349a4a0a9c8975199aa89f2a02f6b9Yann ColletLIBVER_MAJOR := $(shell echo $(LIBVER_MAJOR_SCRIPT)) 3928f98647e3349a4a0a9c8975199aa89f2a02f6b9Yann ColletLIBVER_MINOR := $(shell echo $(LIBVER_MINOR_SCRIPT)) 4028f98647e3349a4a0a9c8975199aa89f2a02f6b9Yann ColletLIBVER_PATCH := $(shell echo $(LIBVER_PATCH_SCRIPT)) 4128f98647e3349a4a0a9c8975199aa89f2a02f6b9Yann ColletLIBVER := $(shell echo $(LIBVER_SCRIPT)) 4228f98647e3349a4a0a9c8975199aa89f2a02f6b9Yann Collet 4343b631223b2d0425a0970876974074934f89c450Mike FrysingerBUILD_STATIC:= yes 44d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet 45d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann ColletDESTDIR?= 462b55752a5c749e57bbd4c9b830ccf939510beec1Yann ColletPREFIX ?= /usr/local 477df658ec1b9976e40d3c6abdf70da4560b2edd38Przemyslaw SkibinskiCPPFLAGS= -DXXH_NAMESPACE=LZ4_ 48d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann ColletCFLAGS ?= -O3 494791cda04af2fdf19f1a1ea7c2d1187ad82cc547Yann ColletCFLAGS += -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \ 50258a5e7fa44825488fe4683f3a04c36fc944a23fYann Collet -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes -Wundef \ 515a5ebeec15d272b0b85aa2cef2a0da3dce920b80Yann Collet -Wpointer-arith -Wstrict-aliasing=1 52d06ab4f4159ed930b36dc4f24d750628daf28f07Przemyslaw SkibinskiCFLAGS += $(MOREFLAGS) 5360119e2585fd652a9c6dfd06aafa4c8f49208501Yann ColletFLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) 54d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet 55d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann ColletLIBDIR?= $(PREFIX)/lib 56d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann ColletINCLUDEDIR=$(PREFIX)/include 57d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet 58d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet 59d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# OS X linker doesn't support -soname, and use different extension 60d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet# see : https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html 61d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Colletifeq ($(shell uname), Darwin) 62d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet SHARED_EXT = dylib 63d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet SHARED_EXT_MAJOR = $(LIBVER_MAJOR).$(SHARED_EXT) 64d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet SHARED_EXT_VER = $(LIBVER).$(SHARED_EXT) 65d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet SONAME_FLAGS = -install_name $(PREFIX)/lib/liblz4.$(SHARED_EXT_MAJOR) -compatibility_version $(LIBVER_MAJOR) -current_version $(LIBVER) 66d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Colletelse 67d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet SONAME_FLAGS = -Wl,-soname=liblz4.$(SHARED_EXT).$(LIBVER_MAJOR) 68d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet SHARED_EXT = so 69d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet SHARED_EXT_MAJOR = $(SHARED_EXT).$(LIBVER_MAJOR) 70d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet SHARED_EXT_VER = $(SHARED_EXT).$(LIBVER) 71d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Colletendif 72d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet 73063b4d92e10bb6b430e515e5cdd36b64fce6a01aPrzemyslaw Skibinskidefault: lib 74d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet 75063b4d92e10bb6b430e515e5cdd36b64fce6a01aPrzemyslaw Skibinskiall: lib 76063b4d92e10bb6b430e515e5cdd36b64fce6a01aPrzemyslaw Skibinski 77063b4d92e10bb6b430e515e5cdd36b64fce6a01aPrzemyslaw Skibinskilib: liblz4.a liblz4 78d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet 79ca80a7c8f77f5405cba5b8a52abb1dda78602bf7Przemyslaw Skibinskiliblz4.a: *.c 8043b631223b2d0425a0970876974074934f89c450Mike Frysingerifeq ($(BUILD_STATIC),yes) 81d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet @echo compiling static library 8228f98647e3349a4a0a9c8975199aa89f2a02f6b9Yann Collet @$(CC) $(FLAGS) -c $^ 83ca80a7c8f77f5405cba5b8a52abb1dda78602bf7Przemyslaw Skibinski @$(AR) rcs $@ *.o 8443b631223b2d0425a0970876974074934f89c450Mike Frysingerendif 85ca80a7c8f77f5405cba5b8a52abb1dda78602bf7Przemyslaw Skibinski 86ca80a7c8f77f5405cba5b8a52abb1dda78602bf7Przemyslaw Skibinskiliblz4: *.c 87d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet @echo compiling dynamic library $(LIBVER) 885a5ebeec15d272b0b85aa2cef2a0da3dce920b80Yann Colletifneq (,$(filter Windows%,$(OS))) 89f71340ce1d8daa9f13cf4f1ecf2a21f23e3790ffPrzemyslaw Skibinski @$(CC) $(FLAGS) -DLZ4_DLL_EXPORT=1 -shared $^ -o dll\$@.dll 90f71340ce1d8daa9f13cf4f1ecf2a21f23e3790ffPrzemyslaw Skibinski dlltool -D dll\liblz4.dll -d dll\liblz4.def -l dll\liblz4.lib 91ca80a7c8f77f5405cba5b8a52abb1dda78602bf7Przemyslaw Skibinskielse 92a3c6daba6e582094897e98c63ccc18ec8097ee5fYann Collet @$(CC) $(FLAGS) -shared $^ -fPIC $(SONAME_FLAGS) -o $@.$(SHARED_EXT_VER) 93d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet @echo creating versioned links 94d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet @ln -sf $@.$(SHARED_EXT_VER) $@.$(SHARED_EXT_MAJOR) 95d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet @ln -sf $@.$(SHARED_EXT_VER) $@.$(SHARED_EXT) 96ca80a7c8f77f5405cba5b8a52abb1dda78602bf7Przemyslaw Skibinskiendif 97d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet 98d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Colletclean: 99f71340ce1d8daa9f13cf4f1ecf2a21f23e3790ffPrzemyslaw Skibinski @$(RM) -f core *.o *.a *.$(SHARED_EXT) *.$(SHARED_EXT).* liblz4.pc dll/liblz4.dll dll/liblz4.lib 100d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet @echo Cleaning library completed 101d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet 102d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet 103d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet#------------------------------------------------------------------------ 1047bfbccb972d349b66f45c9791a12477bfee4c40eMartin Waschbüsch#make install is validated only for Linux, OSX, kFreeBSD, Hurd and 1057bfbccb972d349b66f45c9791a12477bfee4c40eMartin Waschbüsch#FreeBSD targets 1067bfbccb972d349b66f45c9791a12477bfee4c40eMartin Waschbüschifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU FreeBSD)) 107d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet 108d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Colletliblz4.pc: liblz4.pc.in Makefile 109d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet @echo creating pkgconfig 110d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet @sed -e 's|@PREFIX@|$(PREFIX)|' \ 111d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet -e 's|@LIBDIR@|$(LIBDIR)|' \ 112d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet -e 's|@INCLUDEDIR@|$(INCLUDEDIR)|' \ 11328f98647e3349a4a0a9c8975199aa89f2a02f6b9Yann Collet -e 's|@VERSION@|$(LIBVER)|' \ 114d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet $< >$@ 115d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet 116063b4d92e10bb6b430e515e5cdd36b64fce6a01aPrzemyslaw Skibinskiinstall: lib liblz4.pc 117d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet @install -d -m 755 $(DESTDIR)$(LIBDIR)/pkgconfig/ $(DESTDIR)$(INCLUDEDIR)/ 118cd18ed3086a3eaf5d6531412959bd875b74dc6c1Yann Collet @install -m 755 liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR) 119cd18ed3086a3eaf5d6531412959bd875b74dc6c1Yann Collet @ln -sf liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT_MAJOR) 120cd18ed3086a3eaf5d6531412959bd875b74dc6c1Yann Collet @ln -sf liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT) 121cd18ed3086a3eaf5d6531412959bd875b74dc6c1Yann Collet @install -m 644 liblz4.pc $(DESTDIR)$(LIBDIR)/pkgconfig/ 12243b631223b2d0425a0970876974074934f89c450Mike Frysingerifeq ($(BUILD_STATIC),yes) 123d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet @install -m 644 liblz4.a $(DESTDIR)$(LIBDIR)/liblz4.a 12443b631223b2d0425a0970876974074934f89c450Mike Frysingerendif 125d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet @install -m 644 lz4.h $(DESTDIR)$(INCLUDEDIR)/lz4.h 126d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet @install -m 644 lz4hc.h $(DESTDIR)$(INCLUDEDIR)/lz4hc.h 127daa320f3f7bd9cc121462ef7a201fad87f540bd6Yann Collet @install -m 644 lz4frame.h $(DESTDIR)$(INCLUDEDIR)/lz4frame.h 128cd18ed3086a3eaf5d6531412959bd875b74dc6c1Yann Collet @echo lz4 static and shared libraries installed 129d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet 130d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Colletuninstall: 1313b9439ccd043fe5704af6528f3b3155cf6f8f0c4Yann Collet @$(RM) $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT) 1323b9439ccd043fe5704af6528f3b3155cf6f8f0c4Yann Collet @$(RM) $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT_MAJOR) 1333b9439ccd043fe5704af6528f3b3155cf6f8f0c4Yann Collet @$(RM) $(DESTDIR)$(LIBDIR)/pkgconfig/liblz4.pc 1343b9439ccd043fe5704af6528f3b3155cf6f8f0c4Yann Collet @$(RM) $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT_VER) 1353b9439ccd043fe5704af6528f3b3155cf6f8f0c4Yann Collet @$(RM) $(DESTDIR)$(LIBDIR)/liblz4.a 1363b9439ccd043fe5704af6528f3b3155cf6f8f0c4Yann Collet @$(RM) $(DESTDIR)$(INCLUDEDIR)/lz4.h 1373b9439ccd043fe5704af6528f3b3155cf6f8f0c4Yann Collet @$(RM) $(DESTDIR)$(INCLUDEDIR)/lz4hc.h 1383b9439ccd043fe5704af6528f3b3155cf6f8f0c4Yann Collet @$(RM) $(DESTDIR)$(INCLUDEDIR)/lz4frame.h 139d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet @echo lz4 libraries successfully uninstalled 140d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Collet 141d008c87151abf8c36a9f98d28461bf6f3dfdc6aeYann Colletendif 142