btrfs-progs: don't link binaries to a dynamic library
Linking 'btrfs' and other binaries against the dynamic library makes it tedious to use directly from the git repo. This is useful for testing various fixes, but now it'd need to also set LD_LIBRARY_PATH or install the library to a known path. Add a target for static library and use it for linking, the dynamic library is to be used by external users. Signed-off-by: David Sterba <dsterba@suse.cz>
This commit is contained in:
parent
e5cb128a95
commit
5e24225670
13
Makefile
13
Makefile
|
@ -1,5 +1,6 @@
|
||||||
CC = gcc
|
CC = gcc
|
||||||
LN = ln
|
LN = ln
|
||||||
|
AR = ar
|
||||||
AM_CFLAGS = -Wall -D_FILE_OFFSET_BITS=64 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -DBTRFS_FLAT_INCLUDES -fPIC
|
AM_CFLAGS = -Wall -D_FILE_OFFSET_BITS=64 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -DBTRFS_FLAT_INCLUDES -fPIC
|
||||||
CFLAGS = -g -O1
|
CFLAGS = -g -O1
|
||||||
objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \
|
objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \
|
||||||
|
@ -26,7 +27,7 @@ bindir = $(prefix)/bin
|
||||||
lib_LIBS = -luuid -lblkid -lm -lz -L.
|
lib_LIBS = -luuid -lblkid -lm -lz -L.
|
||||||
libdir ?= $(prefix)/lib
|
libdir ?= $(prefix)/lib
|
||||||
incdir = $(prefix)/include/btrfs
|
incdir = $(prefix)/include/btrfs
|
||||||
LIBS = $(lib_LIBS) -lbtrfs
|
LIBS = $(lib_LIBS) $(libs_static)
|
||||||
|
|
||||||
ifeq ("$(origin V)", "command line")
|
ifeq ("$(origin V)", "command line")
|
||||||
BUILD_VERBOSE = $(V)
|
BUILD_VERBOSE = $(V)
|
||||||
|
@ -57,7 +58,9 @@ STATIC_CFLAGS = $(CFLAGS) -ffunction-sections -fdata-sections
|
||||||
STATIC_LDFLAGS = -static -Wl,--gc-sections
|
STATIC_LDFLAGS = -static -Wl,--gc-sections
|
||||||
STATIC_LIBS = $(LIBS) -lpthread
|
STATIC_LIBS = $(LIBS) -lpthread
|
||||||
|
|
||||||
libs = libbtrfs.so.0.1
|
libs_shared = libbtrfs.so.0.1
|
||||||
|
libs_static = libbtrfs.a
|
||||||
|
libs = $(libs_shared) $(libs_static)
|
||||||
lib_links = libbtrfs.so.0 libbtrfs.so
|
lib_links = libbtrfs.so.0 libbtrfs.so
|
||||||
headers = $(libbtrfs_headers)
|
headers = $(libbtrfs_headers)
|
||||||
|
|
||||||
|
@ -88,10 +91,14 @@ static: version.h $(libs) btrfs.static
|
||||||
version.h:
|
version.h:
|
||||||
$(Q)bash version.sh
|
$(Q)bash version.sh
|
||||||
|
|
||||||
$(libs): $(libbtrfs_objects) $(lib_links) send.h
|
$(libs_shared): $(libbtrfs_objects) $(lib_links) send.h
|
||||||
@echo " [LD] $@"
|
@echo " [LD] $@"
|
||||||
$(Q)$(CC) $(CFLAGS) $(libbtrfs_objects) $(lib_LIBS) -shared -Wl,-soname,libbtrfs.so -o libbtrfs.so.0.1
|
$(Q)$(CC) $(CFLAGS) $(libbtrfs_objects) $(lib_LIBS) -shared -Wl,-soname,libbtrfs.so -o libbtrfs.so.0.1
|
||||||
|
|
||||||
|
$(libs_static): $(libbtrfs_objects)
|
||||||
|
@echo " [AR] $@"
|
||||||
|
$(Q)$(AR) cru libbtrfs.a $(libbtrfs_objects)
|
||||||
|
|
||||||
$(lib_links):
|
$(lib_links):
|
||||||
@echo " [LN] $@"
|
@echo " [LN] $@"
|
||||||
$(Q)$(LN) -sf libbtrfs.so.0.1 libbtrfs.so.0
|
$(Q)$(LN) -sf libbtrfs.so.0.1 libbtrfs.so.0
|
||||||
|
|
Loading…
Reference in New Issue