btrfs-progs: build: add --disable-programs

We have a build system internally which only needs to build and install
the libraries out of a repository, not any binaries. There's no easy way
to do this in btrfs-progs currently. Add --disable-programs to
./configure to support this.

Signed-off-by: Omar Sandoval <osandov@fb.com>
Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
Omar Sandoval 2018-07-26 13:34:38 -07:00 committed by David Sterba
parent 7c5a355b74
commit 996a07c602
3 changed files with 36 additions and 18 deletions

View File

@ -206,23 +206,31 @@ endif
MAKEOPTS = --no-print-directory Q=$(Q) MAKEOPTS = --no-print-directory Q=$(Q)
# build all by default
progs = $(progs_install) btrfsck btrfs-corrupt-block
# install only selected # Programs to install.
progs_install = btrfs mkfs.btrfs btrfs-map-logical btrfs-image \ progs_install = btrfs mkfs.btrfs btrfs-map-logical btrfs-image \
btrfs-find-root btrfstune \ btrfs-find-root btrfstune btrfs-select-super
btrfs-select-super
# other tools, not built by default # Programs to build.
progs_extra = btrfs-fragments progs_build = $(progs_install) btrfsck btrfs-corrupt-block
progs_static = $(foreach p,$(progs),$(p).static) # All programs. Use := instead of = so that this is expanded before we reassign
# progs_build below.
progs := $(progs_build) btrfs-convert btrfs-fragments
ifneq ($(DISABLE_BTRFSCONVERT),1) ifneq ($(DISABLE_BTRFSCONVERT),1)
progs_install += btrfs-convert progs_install += btrfs-convert
endif endif
# Static programs to build. Use := instead of = because `make static` should
# still build everything even if --disable-programs was passed to ./configure.
progs_static := $(foreach p,$(progs_build),$(p).static)
ifneq ($(BUILD_PROGRAMS),1)
progs_install =
progs_build =
endif
# external libs required by various binaries; for btrfs-foo, # external libs required by various binaries; for btrfs-foo,
# specify btrfs_foo_libs = <list of libs>; see $($(subst...)) rules below # specify btrfs_foo_libs = <list of libs>; see $($(subst...)) rules below
btrfs_convert_cflags = -DBTRFSCONVERT_EXT2=$(BTRFSCONVERT_EXT2) btrfs_convert_cflags = -DBTRFSCONVERT_EXT2=$(BTRFSCONVERT_EXT2)
@ -233,7 +241,7 @@ cmds_restore_cflags = -DBTRFSRESTORE_ZSTD=$(BTRFSRESTORE_ZSTD)
CHECKER_FLAGS += $(btrfs_convert_cflags) CHECKER_FLAGS += $(btrfs_convert_cflags)
# collect values of the variables above # collect values of the variables above
standalone_deps = $(foreach dep,$(patsubst %,%_objects,$(subst -,_,$(filter btrfs-%, $(progs) $(progs_extra)))),$($(dep))) standalone_deps = $(foreach dep,$(patsubst %,%_objects,$(subst -,_,$(filter btrfs-%, $(progs)))),$($(dep)))
SUBDIRS = SUBDIRS =
BUILDDIRS = $(patsubst %,build-%,$(SUBDIRS)) BUILDDIRS = $(patsubst %,build-%,$(SUBDIRS))
@ -302,7 +310,7 @@ endif
$(Q)$(CC) $(STATIC_CFLAGS) -c $< -o $@ $($(subst -,_,$(@:%.static.o=%)-cflags)) \ $(Q)$(CC) $(STATIC_CFLAGS) -c $< -o $@ $($(subst -,_,$(@:%.static.o=%)-cflags)) \
$($(subst -,_,btrfs-$(@:%/$(notdir $@)=%)-cflags)) $($(subst -,_,btrfs-$(@:%/$(notdir $@)=%)-cflags))
all: $(progs) $(libs) $(lib_links) $(BUILDDIRS) all: $(progs_build) $(libs) $(lib_links) $(BUILDDIRS)
ifeq ($(PYTHON_BINDINGS),1) ifeq ($(PYTHON_BINDINGS),1)
all: libbtrfsutil_python all: libbtrfsutil_python
endif endif
@ -569,9 +577,8 @@ test-build-pre:
test-build-real: test-build-real:
$(MAKE) $(MAKEOPTS) library-test $(MAKE) $(MAKEOPTS) library-test
-$(MAKE) $(MAKEOPTS) library-test.static -$(MAKE) $(MAKEOPTS) library-test.static
$(MAKE) $(MAKEOPTS) -j 8 all $(MAKE) $(MAKEOPTS) -j 8 $(progs) $(libs) $(lib_links) $(BUILDDIRS)
-$(MAKE) $(MAKEOPTS) -j 8 static -$(MAKE) $(MAKEOPTS) -j 8 static
$(MAKE) $(MAKEOPTS) -j 8 $(progs_extra)
manpages: manpages:
$(Q)$(MAKE) $(MAKEOPTS) -C Documentation $(Q)$(MAKE) $(MAKEOPTS) -C Documentation
@ -603,7 +610,7 @@ clean: $(CLEANDIRS)
mktables btrfs.static mkfs.btrfs.static fssum \ mktables btrfs.static mkfs.btrfs.static fssum \
$(check_defs) \ $(check_defs) \
$(libs) $(lib_links) \ $(libs) $(lib_links) \
$(progs_static) $(progs_extra) \ $(progs_static) \
libbtrfsutil/*.o libbtrfsutil/*.o.d libbtrfsutil/*.o libbtrfsutil/*.o.d
ifeq ($(PYTHON_BINDINGS),1) ifeq ($(PYTHON_BINDINGS),1)
$(Q)cd libbtrfsutil/python; \ $(Q)cd libbtrfsutil/python; \
@ -628,21 +635,23 @@ $(CLEANDIRS):
$(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst clean-%,%,$@) clean $(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst clean-%,%,$@) clean
install: $(libs) $(progs_install) $(INSTALLDIRS) install: $(libs) $(progs_install) $(INSTALLDIRS)
ifeq ($(BUILD_PROGRAMS),1)
$(INSTALL) -m755 -d $(DESTDIR)$(bindir) $(INSTALL) -m755 -d $(DESTDIR)$(bindir)
$(INSTALL) $(progs_install) $(DESTDIR)$(bindir) $(INSTALL) $(progs_install) $(DESTDIR)$(bindir)
$(INSTALL) fsck.btrfs $(DESTDIR)$(bindir) $(INSTALL) fsck.btrfs $(DESTDIR)$(bindir)
# btrfsck is a link to btrfs in the src tree, make it so for installed file as well # btrfsck is a link to btrfs in the src tree, make it so for installed file as well
$(LN_S) -f btrfs $(DESTDIR)$(bindir)/btrfsck $(LN_S) -f btrfs $(DESTDIR)$(bindir)/btrfsck
ifneq ($(udevdir),)
$(INSTALL) -m755 -d $(DESTDIR)$(udevruledir)
$(INSTALL) -m644 $(udev_rules) $(DESTDIR)$(udevruledir)
endif
endif
$(INSTALL) -m755 -d $(DESTDIR)$(libdir) $(INSTALL) -m755 -d $(DESTDIR)$(libdir)
$(INSTALL) $(libs) $(DESTDIR)$(libdir) $(INSTALL) $(libs) $(DESTDIR)$(libdir)
cp -d $(lib_links) $(DESTDIR)$(libdir) cp -d $(lib_links) $(DESTDIR)$(libdir)
$(INSTALL) -m755 -d $(DESTDIR)$(incdir)/btrfs $(INSTALL) -m755 -d $(DESTDIR)$(incdir)/btrfs
$(INSTALL) -m644 $(libbtrfs_headers) $(DESTDIR)$(incdir)/btrfs $(INSTALL) -m644 $(libbtrfs_headers) $(DESTDIR)$(incdir)/btrfs
$(INSTALL) -m644 libbtrfsutil/btrfsutil.h $(DESTDIR)$(incdir) $(INSTALL) -m644 libbtrfsutil/btrfsutil.h $(DESTDIR)$(incdir)
ifneq ($(udevdir),)
$(INSTALL) -m755 -d $(DESTDIR)$(udevruledir)
$(INSTALL) -m644 $(udev_rules) $(DESTDIR)$(udevruledir)
endif
ifeq ($(PYTHON_BINDINGS),1) ifeq ($(PYTHON_BINDINGS),1)
install_python: libbtrfsutil_python install_python: libbtrfsutil_python

View File

@ -12,6 +12,7 @@ RMDIR = @RMDIR@
INSTALL = @INSTALL@ INSTALL = @INSTALL@
DISABLE_DOCUMENTATION = @DISABLE_DOCUMENTATION@ DISABLE_DOCUMENTATION = @DISABLE_DOCUMENTATION@
DISABLE_BTRFSCONVERT = @DISABLE_BTRFSCONVERT@ DISABLE_BTRFSCONVERT = @DISABLE_BTRFSCONVERT@
BUILD_PROGRAMS = @BUILD_PROGRAMS@
BTRFSCONVERT_EXT2 = @BTRFSCONVERT_EXT2@ BTRFSCONVERT_EXT2 = @BTRFSCONVERT_EXT2@
BTRFSCONVERT_REISERFS = @BTRFSCONVERT_REISERFS@ BTRFSCONVERT_REISERFS = @BTRFSCONVERT_REISERFS@
BTRFSRESTORE_ZSTD = @BTRFSRESTORE_ZSTD@ BTRFSRESTORE_ZSTD = @BTRFSRESTORE_ZSTD@

View File

@ -118,9 +118,16 @@ if test "x$enable_documentation" = xyes; then
fi fi
AC_SUBST([ASCIIDOC_TOOL]) AC_SUBST([ASCIIDOC_TOOL])
AC_ARG_ENABLE([programs],
AS_HELP_STRING([--disable-programs], [do not build utility programs]),
[], [enable_programs=yes]
)
AS_IF([test "x$enable_programs" = xyes], [BUILD_PROGRAMS=1], [BUILD_PROGRAMS=0])
AC_SUBST([BUILD_PROGRAMS])
AC_ARG_ENABLE([convert], AC_ARG_ENABLE([convert],
AS_HELP_STRING([--disable-convert], [do not build btrfs-convert]), AS_HELP_STRING([--disable-convert], [do not build btrfs-convert]),
[], [enable_convert=yes] [], [enable_convert=$enable_programs]
) )
AS_IF([test "x$enable_convert" = xyes], [DISABLE_BTRFSCONVERT=0], [DISABLE_BTRFSCONVERT=1]) AS_IF([test "x$enable_convert" = xyes], [DISABLE_BTRFSCONVERT=0], [DISABLE_BTRFSCONVERT=1])
@ -277,6 +284,7 @@ AC_MSG_RESULT([
cflags: ${CFLAGS} cflags: ${CFLAGS}
ldflags: ${LDFLAGS} ldflags: ${LDFLAGS}
programs: ${enable_programs}
documentation: ${enable_documentation} documentation: ${enable_documentation}
doc generator: ${ASCIIDOC_TOOL} doc generator: ${ASCIIDOC_TOOL}
backtrace support: ${enable_backtrace} backtrace support: ${enable_backtrace}