1# ################################################################
2# LZ4 - Makefile common definitions
3# Copyright (C) Yann Collet 2020
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 : https://github.com/lz4/lz4
30#  - LZ4 forum froup : https://groups.google.com/forum/#!forum/lz4c
31# ################################################################
32
33TARGET_OS ?= $(shell uname)
34ifeq ($(TARGET_OS),)
35  TARGET_OS ?= $(OS)
36endif
37
38ifneq (,$(filter Windows%,$(TARGET_OS)))
39LIBLZ4 = liblz4-$(LIBVER_MAJOR)
40LIBLZ4_EXP = liblz4.lib
41WINBASED   = yes
42else
43LIBLZ4_EXP = liblz4.dll.a
44  ifneq (,$(filter MINGW%,$(TARGET_OS)))
45LIBLZ4     = liblz4
46WINBASED   = yes
47  else
48    ifneq (,$(filter MSYS%,$(TARGET_OS)))
49LIBLZ4     = msys-lz4-$(LIBVER_MAJOR)
50WINBASED   = yes
51    else
52      ifneq (,$(filter CYGWIN%,$(TARGET_OS)))
53LIBLZ4     = cyglz4-$(LIBVER_MAJOR)
54WINBASED   = yes
55      else
56LIBLZ4     = liblz4.$(SHARED_EXT_VER)
57WINBASED   = no
58EXT        =
59      endif
60    endif
61  endif
62endif
63
64ifeq ($(WINBASED),yes)
65EXT        = .exe
66WINDRES    = windres
67endif
68
69#determine if dev/nul based on host environment
70ifneq (,$(filter MINGW% MSYS% CYGWIN%,$(shell uname)))
71VOID := /dev/null
72else
73  ifneq (,$(filter Windows%,$(OS)))
74VOID := nul
75  else
76VOID  := /dev/null
77  endif
78endif
79
80ifneq (,$(filter Linux Darwin GNU/kFreeBSD GNU OpenBSD FreeBSD NetBSD DragonFly SunOS Haiku MidnightBSD MINGW% CYGWIN% MSYS%,$(shell uname)))
81POSIX_ENV = Yes
82else
83POSIX_ENV = No
84endif
85
86# Avoid symlinks when targetting Windows or building on a Windows host
87ifeq ($(WINBASED),yes)
88LN_SF = cp -p
89else
90  ifneq (,$(filter MINGW% MSYS% CYGWIN%,$(shell uname)))
91LN_SF = cp -p
92  else
93    ifneq (,$(filter Windows%,$(OS)))
94LN_SF = cp -p
95    else
96LN_SF  = ln -sf
97    endif
98  endif
99endif
100
101ifneq (,$(filter $(shell uname),SunOS))
102INSTALL ?= ginstall
103else
104INSTALL ?= install
105endif
106
107INSTALL_PROGRAM ?= $(INSTALL) -m 755
108INSTALL_DATA    ?= $(INSTALL) -m 644
109INSTALL_DIR     ?= $(INSTALL) -d -m 755
110