~mmach/netext73/lz4

« back to all changes in this revision

Viewing changes to .pc/0001-Fix-static-link.patch/programs/Makefile

  • Committer: mmach
  • Date: 2022-11-09 18:52:10 UTC
  • Revision ID: netbit73@gmail.com-20221109185210-w358idlhh0phq688
1.9.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# ##########################################################################
 
2
# LZ4 programs - Makefile
 
3
# Copyright (C) Yann Collet 2011-2020
 
4
#
 
5
# This Makefile is validated for Linux, macOS, *BSD, Hurd, Solaris, MSYS2 targets
 
6
#
 
7
# GPL v2 License
 
8
#
 
9
# This program is free software; you can redistribute it and/or modify
 
10
# it under the terms of the GNU General Public License as published by
 
11
# the Free Software Foundation; either version 2 of the License, or
 
12
# (at your option) any later version.
 
13
#
 
14
# This program is distributed in the hope that it will be useful,
 
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
# GNU General Public License for more details.
 
18
#
 
19
# You should have received a copy of the GNU General Public License along
 
20
# with this program; if not, write to the Free Software Foundation, Inc.,
 
21
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
22
#
 
23
# You can contact the author at :
 
24
#  - LZ4 homepage : http://www.lz4.org
 
25
#  - LZ4 source repository : https://github.com/lz4/lz4
 
26
# ##########################################################################
 
27
# lz4 : Command Line Utility, supporting gzip-like arguments
 
28
# lz4c  : CLU, supporting also legacy lz4demo arguments
 
29
# lz4c32: Same as lz4c, but forced to compile in 32-bits mode
 
30
# ##########################################################################
 
31
SED = sed
 
32
 
 
33
# Version numbers
 
34
LZ4DIR   := ../lib
 
35
LIBVER_SRC := $(LZ4DIR)/lz4.h
 
36
LIBVER_MAJOR_SCRIPT:=`$(SED) -n '/define LZ4_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < $(LIBVER_SRC)`
 
37
LIBVER_MINOR_SCRIPT:=`$(SED) -n '/define LZ4_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < $(LIBVER_SRC)`
 
38
LIBVER_PATCH_SCRIPT:=`$(SED) -n '/define LZ4_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < $(LIBVER_SRC)`
 
39
LIBVER_SCRIPT:= $(LIBVER_MAJOR_SCRIPT).$(LIBVER_MINOR_SCRIPT).$(LIBVER_PATCH_SCRIPT)
 
40
LIBVER_MAJOR := $(shell echo $(LIBVER_MAJOR_SCRIPT))
 
41
LIBVER_MINOR := $(shell echo $(LIBVER_MINOR_SCRIPT))
 
42
LIBVER_PATCH := $(shell echo $(LIBVER_PATCH_SCRIPT))
 
43
LIBVER   := $(shell echo $(LIBVER_SCRIPT))
 
44
 
 
45
LIBFILES  = $(wildcard $(LZ4DIR)/*.c)
 
46
SRCFILES  = $(sort $(LIBFILES) $(wildcard *.c))
 
47
OBJFILES  = $(SRCFILES:.c=.o)
 
48
 
 
49
CPPFLAGS += -I$(LZ4DIR) -DXXH_NAMESPACE=LZ4_
 
50
CFLAGS   ?= -O3
 
51
DEBUGFLAGS= -Wall -Wextra -Wundef -Wcast-qual -Wcast-align -Wshadow \
 
52
            -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes \
 
53
            -Wpointer-arith -Wstrict-aliasing=1
 
54
CFLAGS   += $(DEBUGFLAGS) $(MOREFLAGS)
 
55
 
 
56
include ../Makefile.inc
 
57
 
 
58
OS_VERSION ?= $(UNAME) -r
 
59
ifeq ($(TARGET_OS)$(shell $(OS_VERSION)),SunOS5.10)
 
60
LDFLAGS  += -lrt
 
61
endif
 
62
 
 
63
FLAGS     = $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
 
64
 
 
65
LZ4_VERSION=$(LIBVER)
 
66
MD2ROFF   = ronn
 
67
MD2ROFF_FLAGS = --roff --warnings --manual="User Commands" --organization="lz4 $(LZ4_VERSION)"
 
68
 
 
69
 
 
70
default: lz4-release
 
71
 
 
72
# silent mode by default; verbose can be triggered by V=1 or VERBOSE=1
 
73
$(V)$(VERBOSE).SILENT:
 
74
 
 
75
all: lz4 lz4c
 
76
 
 
77
all32: CFLAGS+=-m32
 
78
all32: all
 
79
 
 
80
ifeq ($(WINBASED),yes)
 
81
lz4-exe.rc: lz4-exe.rc.in
 
82
        @echo creating executable resource
 
83
        $(SED) -e 's|@PROGNAME@|lz4|' \
 
84
         -e 's|@LIBVER_MAJOR@|$(LIBVER_MAJOR)|g' \
 
85
         -e 's|@LIBVER_MINOR@|$(LIBVER_MINOR)|g' \
 
86
         -e 's|@LIBVER_PATCH@|$(LIBVER_PATCH)|g' \
 
87
         -e 's|@EXT@|$(EXT)|g' \
 
88
          $< >$@
 
89
 
 
90
lz4-exe.o: lz4-exe.rc
 
91
        $(WINDRES) -i lz4-exe.rc -o lz4-exe.o
 
92
 
 
93
lz4: $(OBJFILES) lz4-exe.o
 
94
        $(CC) $(FLAGS) $^ -o $@$(EXT)
 
95
else
 
96
lz4: $(OBJFILES)
 
97
        $(CC) $(FLAGS) $(OBJFILES) -o $@$(EXT) $(LDLIBS)
 
98
endif
 
99
 
 
100
.PHONY: lz4-release
 
101
lz4-release: DEBUGFLAGS=
 
102
lz4-release: lz4
 
103
 
 
104
lz4-wlib: LIBFILES =
 
105
lz4-wlib: SRCFILES+= $(LZ4DIR)/xxhash.c  # benchmark unit needs XXH64()
 
106
lz4-wlib: LDFLAGS += -L $(LZ4DIR)
 
107
lz4-wlib: LDLIBS   = -llz4
 
108
lz4-wlib: liblz4 $(OBJFILES)
 
109
        @echo WARNING: $@ must link to an extended variant of the dynamic library which also exposes unstable symbols
 
110
        $(CC) $(FLAGS) $(OBJFILES) -o $@$(EXT) $(LDLIBS)
 
111
 
 
112
.PHONY:liblz4
 
113
liblz4:
 
114
        CPPFLAGS="-DLZ4F_PUBLISH_STATIC_FUNCTIONS -DLZ4_PUBLISH_STATIC_FUNCTIONS" $(MAKE) -C $(LZ4DIR) liblz4
 
115
 
 
116
lz4c: lz4
 
117
        $(LN_SF) lz4$(EXT) lz4c$(EXT)
 
118
 
 
119
lz4c32: CFLAGS += -m32
 
120
lz4c32 : $(SRCFILES)
 
121
        $(CC) $(FLAGS) $^ -o $@$(EXT)
 
122
 
 
123
lz4.1: lz4.1.md $(LIBVER_SRC)
 
124
        cat $< | $(MD2ROFF) $(MD2ROFF_FLAGS) | $(SED) -n '/^\.\\\".*/!p' > $@
 
125
 
 
126
man: lz4.1
 
127
 
 
128
clean-man:
 
129
        $(RM) lz4.1
 
130
 
 
131
preview-man: clean-man man
 
132
        man ./lz4.1
 
133
 
 
134
clean:
 
135
ifeq ($(WINBASED),yes)
 
136
        $(RM) *.rc
 
137
endif
 
138
        $(MAKE) -C $(LZ4DIR) $@ > $(VOID)
 
139
        $(RM) core *.o *.test tmp* \
 
140
           lz4$(EXT) lz4c$(EXT) lz4c32$(EXT) lz4-wlib$(EXT) \
 
141
           unlz4$(EXT) lz4cat$(EXT)
 
142
        @echo Cleaning completed
 
143
 
 
144
 
 
145
#-----------------------------------------------------------------------------
 
146
# make install is validated only for Linux, OSX, BSD, Hurd and Solaris targets
 
147
#-----------------------------------------------------------------------------
 
148
ifeq ($(POSIX_ENV),Yes)
 
149
 
 
150
unlz4: lz4
 
151
        $(LN_SF) lz4$(EXT) unlz4$(EXT)
 
152
 
 
153
lz4cat: lz4
 
154
        $(LN_SF) lz4$(EXT) lz4cat$(EXT)
 
155
 
 
156
DESTDIR     ?=
 
157
# directory variables : GNU conventions prefer lowercase
 
158
# see https://www.gnu.org/prep/standards/html_node/Makefile-Conventions.html
 
159
# support both lower and uppercase (BSD), use lowercase in script
 
160
PREFIX      ?= /usr/local
 
161
prefix      ?= $(PREFIX)
 
162
EXEC_PREFIX ?= $(prefix)
 
163
exec_prefix ?= $(EXEC_PREFIX)
 
164
BINDIR      ?= $(exec_prefix)/bin
 
165
bindir      ?= $(BINDIR)
 
166
DATAROOTDIR ?= $(prefix)/share
 
167
datarootdir ?= $(DATAROOTDIR)
 
168
MANDIR      ?= $(datarootdir)/man
 
169
mandir      ?= $(MANDIR)
 
170
MAN1DIR     ?= $(mandir)/man1
 
171
man1dir     ?= $(MAN1DIR)
 
172
 
 
173
install: lz4
 
174
        @echo Installing binaries in $(DESTDIR)$(bindir)
 
175
        $(INSTALL_DIR) $(DESTDIR)$(bindir)/ $(DESTDIR)$(man1dir)/
 
176
        $(INSTALL_PROGRAM) lz4$(EXT) $(DESTDIR)$(bindir)/lz4$(EXT)
 
177
        $(LN_SF) lz4$(EXT) $(DESTDIR)$(bindir)/lz4c$(EXT)
 
178
        $(LN_SF) lz4$(EXT) $(DESTDIR)$(bindir)/lz4cat$(EXT)
 
179
        $(LN_SF) lz4$(EXT) $(DESTDIR)$(bindir)/unlz4$(EXT)
 
180
        @echo Installing man pages in $(DESTDIR)$(man1dir)
 
181
        $(INSTALL_DATA) lz4.1 $(DESTDIR)$(man1dir)/lz4.1
 
182
        $(LN_SF) lz4.1 $(DESTDIR)$(man1dir)/lz4c.1
 
183
        $(LN_SF) lz4.1 $(DESTDIR)$(man1dir)/lz4cat.1
 
184
        $(LN_SF) lz4.1 $(DESTDIR)$(man1dir)/unlz4.1
 
185
        @echo lz4 installation completed
 
186
 
 
187
uninstall:
 
188
        $(RM) $(DESTDIR)$(bindir)/lz4cat$(EXT)
 
189
        $(RM) $(DESTDIR)$(bindir)/unlz4$(EXT)
 
190
        $(RM) $(DESTDIR)$(bindir)/lz4$(EXT)
 
191
        $(RM) $(DESTDIR)$(bindir)/lz4c$(EXT)
 
192
        $(RM) $(DESTDIR)$(man1dir)/lz4.1
 
193
        $(RM) $(DESTDIR)$(man1dir)/lz4c.1
 
194
        $(RM) $(DESTDIR)$(man1dir)/lz4cat.1
 
195
        $(RM) $(DESTDIR)$(man1dir)/unlz4.1
 
196
        @echo lz4 programs successfully uninstalled
 
197
 
 
198
endif