3131# - LZ4 source repository : https://github.com/lz4/lz4
3232# - LZ4 forum froup : https://groups.google.com/forum/#!forum/lz4c
3333# ################################################################
34+ SED = sed
3435
3536# Version numbers
36- LIBVER_MAJOR_SCRIPT: =` sed -n ' /define LZ4_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./lz4.h`
37- LIBVER_MINOR_SCRIPT: =` sed -n ' /define LZ4_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./lz4.h`
38- LIBVER_PATCH_SCRIPT: =` sed -n ' /define LZ4_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./lz4.h`
37+ LIBVER_MAJOR_SCRIPT: =` $( SED ) -n ' /define LZ4_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./lz4.h`
38+ LIBVER_MINOR_SCRIPT: =` $( SED ) -n ' /define LZ4_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./lz4.h`
39+ LIBVER_PATCH_SCRIPT: =` $( SED ) -n ' /define LZ4_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < ./lz4.h`
3940LIBVER_SCRIPT: = $(LIBVER_MAJOR_SCRIPT ) .$(LIBVER_MINOR_SCRIPT ) .$(LIBVER_PATCH_SCRIPT )
4041LIBVER_MAJOR := $(shell echo $(LIBVER_MAJOR_SCRIPT ) )
4142LIBVER_MINOR := $(shell echo $(LIBVER_MINOR_SCRIPT ) )
@@ -46,12 +47,13 @@ BUILD_SHARED:=yes
4647BUILD_STATIC: =yes
4748
4849CPPFLAGS+ = -DXXH_NAMESPACE=LZ4_
50+ CPPFLAGS+ = $(MOREFLAGS )
4951CFLAGS ?= -O3
5052DEBUGFLAGS: = -Wall -Wextra -Wcast-qual -Wcast-align -Wshadow \
5153 -Wswitch-enum -Wdeclaration-after-statement -Wstrict-prototypes \
5254 -Wundef -Wpointer-arith -Wstrict-aliasing=1
53- CFLAGS += $(DEBUGFLAGS ) $( MOREFLAGS )
54- FLAGS = $(CPPFLAGS ) $(CFLAGS ) $(LDFLAGS )
55+ CFLAGS += $(DEBUGFLAGS )
56+ FLAGS = $(CFLAGS ) $(CPPFLAGS ) $(LDFLAGS )
5557
5658SRCFILES := $(sort $(wildcard * .c) )
5759
@@ -74,27 +76,33 @@ endif
7476.PHONY : default
7577default : lib-release
7678
79+ # silent mode by default; verbose can be triggered by V=1 or VERBOSE=1
80+ $(V )$(VERBOSE ) .SILENT :
81+
7782lib-release : DEBUGFLAGS :=
7883lib-release : lib
7984
85+ .PHONY : lib
8086lib : liblz4.a liblz4
8187
88+ .PHONY : all
8289all : lib
8390
91+ .PHONY : all32
8492all32 : CFLAGS+=-m32
8593all32 : all
8694
8795liblz4.a : $(SRCFILES )
8896ifeq ($(BUILD_STATIC ) ,yes) # can be disabled on command line
8997 @echo compiling static library
90- $(Q)$(CC) $(CPPFLAGS) $(CFLAGS) -c $^
91- $(Q)$( AR) rcs $@ *.o
98+ $(COMPILE.c) $^
99+ $(AR) rcs $@ *.o
92100endif
93101
94102ifeq ($(WINBASED ) ,yes)
95103liblz4-dll.rc : liblz4-dll.rc.in
96104 @echo creating library resource
97- $(Q ) sed -e ' s|@LIBLZ4@|$(LIBLZ4)|' \
105+ $(SED ) -e ' s|@LIBLZ4@|$(LIBLZ4)|' \
98106 -e 's|@LIBVER_MAJOR@|$(LIBVER_MAJOR)|g' \
99107 -e 's|@LIBVER_MINOR@|$(LIBVER_MINOR)|g' \
100108 -e 's|@LIBVER_PATCH@|$(LIBVER_PATCH)|g' \
@@ -104,31 +112,30 @@ liblz4-dll.o: liblz4-dll.rc
104112 $(WINDRES ) -i liblz4-dll.rc -o liblz4-dll.o
105113
106114$(LIBLZ4 ) : $(SRCFILES ) liblz4-dll.o
107- else
115+ @echo compiling dynamic library $(LIBVER )
116+ $(CC ) $(FLAGS ) -DLZ4_DLL_EXPORT=1 -shared $^ -o dll/$@ .dll -Wl,--out-implib,dll/$(LIBLZ4_EXP )
117+
118+ else # not windows
119+
108120$(LIBLZ4 ) : $(SRCFILES )
109- endif
110- ifeq ($(BUILD_SHARED ) ,yes) # can be disabled on command line
111121 @echo compiling dynamic library $(LIBVER )
112- ifeq ($(WINBASED),yes)
113- $(Q)$(CC) $(FLAGS) -DLZ4_DLL_EXPORT=1 -shared $^ -o dll/$@.dll -Wl,--out-implib,dll/$(LIBLZ4_EXP)
114- else
115- $(Q)$(CC) $(FLAGS) -shared $^ -fPIC -fvisibility=hidden $(SONAME_FLAGS) -o $@
122+ $(CC ) $(FLAGS ) -shared $^ -fPIC -fvisibility=hidden $(SONAME_FLAGS ) -o $@
116123 @echo creating versioned links
117- $(Q)$( LN_SF) $@ liblz4.$(SHARED_EXT_MAJOR)
118- $(Q)$( LN_SF) $@ liblz4.$(SHARED_EXT)
119- endif
124+ $(LN_SF ) $@ liblz4.$(SHARED_EXT_MAJOR )
125+ $(LN_SF ) $@ liblz4.$(SHARED_EXT )
126+
120127endif
121128
122- ifeq (, $( filter MINGW % , $( TARGET_OS ) ) )
129+ .PHONY : liblz4
123130liblz4 : $(LIBLZ4 )
124- endif
125131
132+ .PHONY : clean
126133clean :
127134ifeq ($(WINBASED ) ,yes)
128- $(Q)$( RM) *.rc
135+ $(RM) *.rc
129136endif
130- $(Q)$( RM) core *.o liblz4.pc dll/$(LIBLZ4).dll dll/$(LIBLZ4_EXP)
131- $(Q)$( RM) *.a *.$(SHARED_EXT) *.$(SHARED_EXT_MAJOR) *.$(SHARED_EXT_VER)
137+ $(RM) core *.o liblz4.pc dll/$(LIBLZ4).dll dll/$(LIBLZ4_EXP)
138+ $(RM) *.a *.$(SHARED_EXT) *.$(SHARED_EXT_MAJOR) *.$(SHARED_EXT_VER)
132139 @echo Cleaning library completed
133140
134141# -----------------------------------------------------------------------------
@@ -164,54 +171,54 @@ pkgconfigdir ?= $(PKGCONFIGDIR)
164171
165172liblz4.pc : liblz4.pc.in Makefile
166173 @echo creating pkgconfig
167- $(Q ) sed -e ' s|@PREFIX@|$(prefix)|' \
174+ $(SED ) -e ' s|@PREFIX@|$(prefix)|' \
168175 -e 's|@LIBDIR@|$(libdir)|' \
169176 -e 's|@INCLUDEDIR@|$(includedir)|' \
170177 -e 's|@VERSION@|$(LIBVER)|' \
171178 $< >$@
172179
173180install : lib liblz4.pc
174- $(Q )$( INSTALL_DIR ) $(DESTDIR )$(pkgconfigdir ) / $(DESTDIR )$(includedir ) / $(DESTDIR )$(libdir ) / $(DESTDIR )$(bindir ) /
175- $(Q )$( INSTALL_DATA ) liblz4.pc $(DESTDIR )$(pkgconfigdir ) /
181+ $(INSTALL_DIR ) $(DESTDIR )$(pkgconfigdir ) / $(DESTDIR )$(includedir ) / $(DESTDIR )$(libdir ) / $(DESTDIR )$(bindir ) /
182+ $(INSTALL_DATA ) liblz4.pc $(DESTDIR )$(pkgconfigdir ) /
176183 @echo Installing libraries
177184 ifeq ($(BUILD_STATIC),yes)
178- $(Q)$( INSTALL_DATA) liblz4.a $(DESTDIR)$(libdir)/liblz4.a
179- $(Q)$( INSTALL_DATA) lz4frame_static.h $(DESTDIR)$(includedir)/lz4frame_static.h
185+ $(INSTALL_DATA) liblz4.a $(DESTDIR)$(libdir)/liblz4.a
186+ $(INSTALL_DATA) lz4frame_static.h $(DESTDIR)$(includedir)/lz4frame_static.h
180187 endif
181188 ifeq ($(BUILD_SHARED),yes)
182189# Traditionnally, one installs the DLLs in the bin directory as programs
183190# search them first in their directory. This allows to not pollute system
184191# directories (like c:/windows/system32), nor modify the PATH variable.
185192 ifeq ($(WINBASED),yes)
186- $(Q)$( INSTALL_PROGRAM) dll/$(LIBLZ4).dll $(DESTDIR)$(bindir)
187- $(Q)$( INSTALL_PROGRAM) dll/$(LIBLZ4_EXP) $(DESTDIR)$(libdir)
193+ $(INSTALL_PROGRAM) dll/$(LIBLZ4).dll $(DESTDIR)$(bindir)
194+ $(INSTALL_PROGRAM) dll/$(LIBLZ4_EXP) $(DESTDIR)$(libdir)
188195 else
189- $(Q)$( INSTALL_PROGRAM) liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(libdir)
190- $(Q)$( LN_SF) liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT_MAJOR)
191- $(Q)$( LN_SF) liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT)
196+ $(INSTALL_PROGRAM) liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(libdir)
197+ $(LN_SF) liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT_MAJOR)
198+ $(LN_SF) liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT)
192199 endif
193200 endif
194201 @echo Installing headers in $(includedir)
195- $(Q)$( INSTALL_DATA) lz4.h $(DESTDIR)$(includedir)/lz4.h
196- $(Q)$( INSTALL_DATA) lz4hc.h $(DESTDIR)$(includedir)/lz4hc.h
197- $(Q)$( INSTALL_DATA) lz4frame.h $(DESTDIR)$(includedir)/lz4frame.h
202+ $(INSTALL_DATA) lz4.h $(DESTDIR)$(includedir)/lz4.h
203+ $(INSTALL_DATA) lz4hc.h $(DESTDIR)$(includedir)/lz4hc.h
204+ $(INSTALL_DATA) lz4frame.h $(DESTDIR)$(includedir)/lz4frame.h
198205 @echo lz4 libraries installed
199206
200207uninstall :
201- $(Q )$( RM ) $(DESTDIR )$(pkgconfigdir ) /liblz4.pc
208+ $(RM ) $(DESTDIR )$(pkgconfigdir ) /liblz4.pc
202209 ifeq (WINBASED,1)
203- $(Q)$( RM) $(DESTDIR)$(bindir)/$(LIBLZ4).dll
204- $(Q)$( RM) $(DESTDIR)$(libdir)/$(LIBLZ4_EXP)
210+ $(RM) $(DESTDIR)$(bindir)/$(LIBLZ4).dll
211+ $(RM) $(DESTDIR)$(libdir)/$(LIBLZ4_EXP)
205212 else
206- $(Q)$( RM) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT)
207- $(Q)$( RM) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT_MAJOR)
208- $(Q)$( RM) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT_VER)
213+ $(RM) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT)
214+ $(RM) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT_MAJOR)
215+ $(RM) $(DESTDIR)$(libdir)/liblz4.$(SHARED_EXT_VER)
209216 endif
210- $(Q)$( RM) $(DESTDIR)$(libdir)/liblz4.a
211- $(Q)$( RM) $(DESTDIR)$(includedir)/lz4.h
212- $(Q)$( RM) $(DESTDIR)$(includedir)/lz4hc.h
213- $(Q)$( RM) $(DESTDIR)$(includedir)/lz4frame.h
214- $(Q)$( RM) $(DESTDIR)$(includedir)/lz4frame_static.h
217+ $(RM) $(DESTDIR)$(libdir)/liblz4.a
218+ $(RM) $(DESTDIR)$(includedir)/lz4.h
219+ $(RM) $(DESTDIR)$(includedir)/lz4hc.h
220+ $(RM) $(DESTDIR)$(includedir)/lz4frame.h
221+ $(RM) $(DESTDIR)$(includedir)/lz4frame_static.h
215222 @echo lz4 libraries successfully uninstalled
216223
217224endif
0 commit comments