1# ################################################################
2# LZ4 - Makefile
3# Copyright (C) Yann Collet 2011-2015
4# All rights reserved.
5# 
6# BSD license
7# Redistribution and use in source and binary forms, with or without modification,
8# are permitted provided that the following conditions are met:
9# 
10# * Redistributions of source code must retain the above copyright notice, this
11#   list of conditions and the following disclaimer.
12# 
13# * Redistributions in binary form must reproduce the above copyright notice, this
14#   list of conditions and the following disclaimer in the documentation and/or
15#   other materials provided with the distribution.
16# 
17# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
21# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
24# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27# 
28# You can contact the author at :
29#  - LZ4 source repository : http://code.google.com/p/lz4/
30#  - LZ4 forum froup : https://groups.google.com/forum/#!forum/lz4c
31# ################################################################
32
33# Version number
34export VERSION=126
35export RELEASE=r$(VERSION)
36
37DESTDIR?=
38PREFIX ?= /usr
39
40LIBDIR ?= $(PREFIX)/lib
41INCLUDEDIR=$(PREFIX)/include
42PRGDIR  = programs
43LZ4DIR  = lib
44DISTRIBNAME=lz4-$(RELEASE).tar.gz
45
46TEXT =  $(LZ4DIR)/lz4.c $(LZ4DIR)/lz4.h $(LZ4DIR)/lz4hc.c $(LZ4DIR)/lz4hc.h \
47	$(LZ4DIR)/lz4frame.c $(LZ4DIR)/lz4frame.h $(LZ4DIR)/lz4frame_static.h \
48	$(LZ4DIR)/xxhash.c $(LZ4DIR)/xxhash.h \
49	$(LZ4DIR)/liblz4.pc.in $(LZ4DIR)/Makefile $(LZ4DIR)/LICENSE \
50	Makefile lz4_block_format.txt LZ4_Frame_Format.html NEWS README.md \
51	cmake_unofficial/CMakeLists.txt \
52	$(PRGDIR)/fullbench.c $(PRGDIR)/lz4cli.c \
53	$(PRGDIR)/datagen.c $(PRGDIR)/fuzzer.c \
54	$(PRGDIR)/lz4io.c $(PRGDIR)/lz4io.h \
55	$(PRGDIR)/bench.c $(PRGDIR)/bench.h \
56	$(PRGDIR)/lz4.1 $(PRGDIR)/lz4c.1 $(PRGDIR)/lz4cat.1 \
57	$(PRGDIR)/Makefile $(PRGDIR)/COPYING	
58NONTEXT = images/image00.png images/image01.png images/image02.png \
59	images/image03.png images/image04.png images/image05.png \
60	images/image06.png
61SOURCES = $(TEXT) $(NONTEXT)
62
63
64# Select test target for Travis CI's Build Matrix
65ifneq (,$(filter test-%,$(LZ4_TRAVIS_CI_ENV)))
66TRAVIS_TARGET=prg-travis
67else
68TRAVIS_TARGET=$(LZ4_TRAVIS_CI_ENV)
69endif
70
71
72default: lz4programs
73
74all: 
75	@cd $(LZ4DIR); $(MAKE) -e all
76	@cd $(PRGDIR); $(MAKE) -e all
77
78lz4programs:
79	@cd $(PRGDIR); $(MAKE) -e
80
81clean:
82	@rm -f $(DISTRIBNAME) *.sha1
83	@cd $(PRGDIR); $(MAKE) clean
84	@cd $(LZ4DIR); $(MAKE) clean
85	@cd examples; $(MAKE) clean
86	@echo Cleaning completed
87
88
89#------------------------------------------------------------------------
90#make install is validated only for Linux, OSX, kFreeBSD and Hurd targets
91ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU))
92
93install:
94	@cd $(LZ4DIR); $(MAKE) -e install
95	@cd $(PRGDIR); $(MAKE) -e install
96
97uninstall:
98	@cd $(LZ4DIR); $(MAKE) uninstall
99	@cd $(PRGDIR); $(MAKE) uninstall
100
101travis-install:
102	sudo $(MAKE) install
103
104dist: clean
105	@install -dD -m 700 lz4-$(RELEASE)/lib/
106	@install -dD -m 700 lz4-$(RELEASE)/programs/
107	@install -dD -m 700 lz4-$(RELEASE)/cmake_unofficial/
108	@install -dD -m 700 lz4-$(RELEASE)/images/
109	@for f in $(TEXT); do \
110		tr -d '\r' < $$f > .tmp; \
111		install -m 600 .tmp lz4-$(RELEASE)/$$f; \
112	done
113	@rm .tmp
114	@for f in $(NONTEXT); do \
115		install -m 600 $$f lz4-$(RELEASE)/$$f; \
116	done
117	@tar -czf $(DISTRIBNAME) lz4-$(RELEASE)/
118	@rm -rf lz4-$(RELEASE)
119	@sha1sum $(DISTRIBNAME) > $(DISTRIBNAME).sha1
120	@echo Distribution $(DISTRIBNAME) built
121
122test:
123	@cd $(PRGDIR); $(MAKE) -e test
124
125test-travis: $(TRAVIS_TARGET)
126
127cmake:
128	@cd cmake_unofficial; cmake CMakeLists.txt; $(MAKE)
129
130streaming-examples:
131	cd examples; $(MAKE) -e test
132
133prg-travis:
134	@cd $(PRGDIR); $(MAKE) -e test-travis
135
136endif
137