kusano 7d535a
# ################################################################
kusano 7d535a
# LZ4 - Makefile
kusano 7d535a
# Copyright (C) Yann Collet 2011-2015
kusano 7d535a
# All rights reserved.
kusano 7d535a
# 
kusano 7d535a
# BSD license
kusano 7d535a
# Redistribution and use in source and binary forms, with or without modification,
kusano 7d535a
# are permitted provided that the following conditions are met:
kusano 7d535a
# 
kusano 7d535a
# * Redistributions of source code must retain the above copyright notice, this
kusano 7d535a
#   list of conditions and the following disclaimer.
kusano 7d535a
# 
kusano 7d535a
# * Redistributions in binary form must reproduce the above copyright notice, this
kusano 7d535a
#   list of conditions and the following disclaimer in the documentation and/or
kusano 7d535a
#   other materials provided with the distribution.
kusano 7d535a
# 
kusano 7d535a
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
kusano 7d535a
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
kusano 7d535a
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
kusano 7d535a
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
kusano 7d535a
# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
kusano 7d535a
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
kusano 7d535a
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
kusano 7d535a
# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
kusano 7d535a
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
kusano 7d535a
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
kusano 7d535a
# 
kusano 7d535a
# You can contact the author at :
kusano 7d535a
#  - LZ4 source repository : https://github.com/Cyan4973/lz4
kusano 7d535a
#  - LZ4 forum froup : https://groups.google.com/forum/#!forum/lz4c
kusano 7d535a
# ################################################################
kusano 7d535a
kusano 7d535a
# Version number
kusano 7d535a
export VERSION=131
kusano 7d535a
export RELEASE=r$(VERSION)
kusano 7d535a
kusano 7d535a
DESTDIR?=
kusano 7d535a
PREFIX ?= /usr/local
kusano 7d535a
kusano 7d535a
LIBDIR ?= $(PREFIX)/lib
kusano 7d535a
INCLUDEDIR=$(PREFIX)/include
kusano 7d535a
PRGDIR  = programs
kusano 7d535a
LZ4DIR  = lib
kusano 7d535a
kusano 7d535a
kusano 7d535a
# Select test target for Travis CI's Build Matrix
kusano 7d535a
ifneq (,$(filter test-%,$(LZ4_TRAVIS_CI_ENV)))
kusano 7d535a
TRAVIS_TARGET=prg-travis
kusano 7d535a
else
kusano 7d535a
TRAVIS_TARGET=$(LZ4_TRAVIS_CI_ENV)
kusano 7d535a
endif
kusano 7d535a
kusano 7d535a
# Define nul output
kusano 7d535a
ifneq (,$(filter Windows%,$(OS)))
kusano 7d535a
VOID = nul
kusano 7d535a
else
kusano 7d535a
VOID = /dev/null
kusano 7d535a
endif
kusano 7d535a
kusano 7d535a
kusano 7d535a
.PHONY: default all lib lz4programs clean test versionsTest
kusano 7d535a
kusano 7d535a
default: lz4programs
kusano 7d535a
kusano 7d535a
all: lib
kusano 7d535a
	@cd $(PRGDIR); $(MAKE) -e all
kusano 7d535a
kusano 7d535a
lib:
kusano 7d535a
	@cd $(LZ4DIR); $(MAKE) -e all
kusano 7d535a
kusano 7d535a
lz4programs:
kusano 7d535a
	@cd $(PRGDIR); $(MAKE) -e
kusano 7d535a
kusano 7d535a
clean:
kusano 7d535a
	@cd $(PRGDIR); $(MAKE) clean > $(VOID)
kusano 7d535a
	@cd $(LZ4DIR); $(MAKE) clean > $(VOID)
kusano 7d535a
	@cd examples;  $(MAKE) clean > $(VOID)
kusano 7d535a
	@cd versionsTest; $(MAKE) clean > $(VOID)
kusano 7d535a
	@echo Cleaning completed
kusano 7d535a
kusano 7d535a
kusano 7d535a
#------------------------------------------------------------------------
kusano 7d535a
#make install is validated only for Linux, OSX, kFreeBSD and Hurd targets
kusano 7d535a
ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU))
kusano 7d535a
kusano 7d535a
install:
kusano 7d535a
	@cd $(LZ4DIR); $(MAKE) -e install
kusano 7d535a
	@cd $(PRGDIR); $(MAKE) -e install
kusano 7d535a
kusano 7d535a
uninstall:
kusano 7d535a
	@cd $(LZ4DIR); $(MAKE) uninstall
kusano 7d535a
	@cd $(PRGDIR); $(MAKE) uninstall
kusano 7d535a
kusano 7d535a
travis-install:
kusano 7d535a
	sudo $(MAKE) install
kusano 7d535a
kusano 7d535a
test:
kusano 7d535a
	@cd $(PRGDIR); $(MAKE) -e test
kusano 7d535a
kusano 7d535a
test-travis: $(TRAVIS_TARGET)
kusano 7d535a
kusano 7d535a
cmake:
kusano 7d535a
	@cd cmake_unofficial; cmake CMakeLists.txt; $(MAKE)
kusano 7d535a
kusano 7d535a
gpptest: clean
kusano 7d535a
	$(MAKE) all CC=g++ CFLAGS="-O3 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Werror"
kusano 7d535a
kusano 7d535a
clangtest: clean
kusano 7d535a
	$(MAKE) all CC=clang CPPFLAGS="-Werror -Wconversion -Wno-sign-conversion"
kusano 7d535a
kusano 7d535a
sanitize: clean
kusano 7d535a
	$(MAKE) test CC=clang CPPFLAGS="-g -fsanitize=undefined" FUZZER_TIME="-T1mn" NB_LOOPS=-i1
kusano 7d535a
kusano 7d535a
staticAnalyze: clean
kusano 7d535a
	CPPFLAGS=-g scan-build --status-bugs -v $(MAKE) all
kusano 7d535a
kusano 7d535a
armtest: clean
kusano 7d535a
	cd lib; $(MAKE) -e all CC=arm-linux-gnueabi-gcc CPPFLAGS="-Werror"
kusano 7d535a
	cd programs; $(MAKE) -e bins CC=arm-linux-gnueabi-gcc CPPFLAGS="-Werror"
kusano 7d535a
kusano 7d535a
versionsTest: clean
kusano 7d535a
	@cd versionsTest; $(MAKE)
kusano 7d535a
kusano 7d535a
examples:
kusano 7d535a
	cd lib; $(MAKE) -e
kusano 7d535a
	cd programs; $(MAKE) -e lz4
kusano 7d535a
	cd examples; $(MAKE) -e test
kusano 7d535a
kusano 7d535a
prg-travis:
kusano 7d535a
	@cd $(PRGDIR); $(MAKE) -e test-travis
kusano 7d535a
kusano 7d535a
endif