acpi: Add IORT helper functions
[coreboot2.git] / util / cbfstool / lz4 / lib / Makefile
blobed5957704f39c6f165af306b3d6d2c38a446cdd5
1 ## SPDX-License-Identifier: BSD-2-Clause
2 # ################################################################
3 # LZ4 library - Makefile
4 # Copyright (C) Yann Collet 2011-2015
5 # All rights reserved.
7 # You can contact the author at :
8 # - LZ4 source repository : https://github.com/Cyan4973/lz4
9 # - LZ4 forum froup : https://groups.google.com/forum/#!forum/lz4c
10 # ################################################################
12 # Version numbers
13 VERSION?= 132
14 LIBVER_MAJOR:=`sed -n '/define LZ4_VERSION_MAJOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < lz4.h`
15 LIBVER_MINOR:=`sed -n '/define LZ4_VERSION_MINOR/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < lz4.h`
16 LIBVER_PATCH:=`sed -n '/define LZ4_VERSION_RELEASE/s/.*[[:blank:]]\([0-9][0-9]*\).*/\1/p' < lz4.h`
17 LIBVER := $(LIBVER_MAJOR).$(LIBVER_MINOR).$(LIBVER_PATCH)
19 DESTDIR?=
20 PREFIX ?= /usr/local
21 CPPFLAGS= -DXXH_NAMESPACE=LZ4_
22 CFLAGS ?= -O3
23 CFLAGS += -std=c99 -Wall -Wextra -Wundef -Wshadow -Wcast-align -Wcast-qual -Wstrict-prototypes -pedantic
24 FLAGS = $(CPPFLAGS) $(CFLAGS) $(LDFLAGS)
26 LIBDIR?= $(PREFIX)/lib
27 INCLUDEDIR=$(PREFIX)/include
30 # OS X linker doesn't support -soname, and use different extension
31 # see : https://developer.apple.com/library/mac/documentation/DeveloperTools/Conceptual/DynamicLibraries/100-Articles/DynamicLibraryDesignGuidelines.html
32 ifeq ($(shell uname), Darwin)
33 SHARED_EXT = dylib
34 SHARED_EXT_MAJOR = $(LIBVER_MAJOR).$(SHARED_EXT)
35 SHARED_EXT_VER = $(LIBVER).$(SHARED_EXT)
36 SONAME_FLAGS = -install_name $(PREFIX)/lib/liblz4.$(SHARED_EXT_MAJOR) -compatibility_version $(LIBVER_MAJOR) -current_version $(LIBVER)
37 else
38 SONAME_FLAGS = -Wl,-soname=liblz4.$(SHARED_EXT).$(LIBVER_MAJOR)
39 SHARED_EXT = so
40 SHARED_EXT_MAJOR = $(SHARED_EXT).$(LIBVER_MAJOR)
41 SHARED_EXT_VER = $(SHARED_EXT).$(LIBVER)
42 endif
44 default: liblz4
46 all: liblz4
48 liblz4: lz4.c lz4hc.c lz4frame.c xxhash.c # need to compile once with -fPIC, and once without -fPIC
49 @echo compiling static library
50 @$(AR) rcs $@.a $^
51 @echo compiling dynamic library $(LIBVER)
52 @$(CC) $(FLAGS) -shared $^ -fPIC $(SONAME_FLAGS) -o $@.$(SHARED_EXT_VER)
53 @echo creating versioned links
54 @ln -sf $@.$(SHARED_EXT_VER) $@.$(SHARED_EXT_MAJOR)
55 @ln -sf $@.$(SHARED_EXT_VER) $@.$(SHARED_EXT)
57 clean:
58 @rm -f core *.o *.a *.$(SHARED_EXT) *.$(SHARED_EXT).* liblz4.pc
59 @echo Cleaning library completed
62 #------------------------------------------------------------------------
63 #make install is validated only for Linux, OSX, kFreeBSD and Hurd targets
64 ifneq (,$(filter $(shell uname),Linux Darwin GNU/kFreeBSD GNU))
66 liblz4.pc: liblz4.pc.in Makefile
67 @echo creating pkgconfig
68 @sed -e 's|@PREFIX@|$(PREFIX)|' \
69 -e 's|@LIBDIR@|$(LIBDIR)|' \
70 -e 's|@INCLUDEDIR@|$(INCLUDEDIR)|' \
71 -e 's|@VERSION@|$(VERSION)|' \
72 $< >$@
74 install: liblz4 liblz4.pc
75 @install -d -m 755 $(DESTDIR)$(LIBDIR)/pkgconfig/ $(DESTDIR)$(INCLUDEDIR)/
76 @install -m 755 liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR)
77 @ln -sf liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT_MAJOR)
78 @ln -sf liblz4.$(SHARED_EXT_VER) $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT)
79 @install -m 644 liblz4.pc $(DESTDIR)$(LIBDIR)/pkgconfig/
80 @install -m 644 liblz4.a $(DESTDIR)$(LIBDIR)/liblz4.a
81 @install -m 644 lz4.h $(DESTDIR)$(INCLUDEDIR)/lz4.h
82 @install -m 644 lz4hc.h $(DESTDIR)$(INCLUDEDIR)/lz4hc.h
83 @install -m 644 lz4frame.h $(DESTDIR)$(INCLUDEDIR)/lz4frame.h
84 @echo lz4 static and shared libraries installed
86 uninstall:
87 @rm -f $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT)
88 @rm -f $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT_MAJOR)
89 @rm -f $(DESTDIR)$(LIBDIR)/pkgconfig/liblz4.pc
90 @[ -x $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT_VER) ] && rm -f $(DESTDIR)$(LIBDIR)/liblz4.$(SHARED_EXT_VER)
91 @[ -f $(DESTDIR)$(LIBDIR)/liblz4.a ] && rm -f $(DESTDIR)$(LIBDIR)/liblz4.a
92 @[ -f $(DESTDIR)$(INCLUDEDIR)/lz4.h ] && rm -f $(DESTDIR)$(INCLUDEDIR)/lz4.h
93 @[ -f $(DESTDIR)$(INCLUDEDIR)/lz4hc.h ] && rm -f $(DESTDIR)$(INCLUDEDIR)/lz4hc.h
94 @[ -f $(DESTDIR)$(INCLUDEDIR)/lz4frame.h ] && rm -f $(DESTDIR)$(INCLUDEDIR)/lz4frame.h
95 @echo lz4 libraries successfully uninstalled
97 endif