btrfs-progs: build improvements
Subsystems (2)
cover btrfs-progs: build improvements
From: Omar Sandoval <[email protected]>
Hi, Dave,
This is a resend of a couple of patches I sent back in April, rebased on the current devel branch. Patch 1 cleans up some stale build targets, and patch 2 makes the btrfs-progs build more flexible, so that it's possible to pick and choose what gets built. Please consider these for the next progs release.
Thanks!
Omar Sandoval (2):
btrfs-progs: remove stale dir-test and quick-test
btrfs-progs: make all programs and libraries optional
Makefile | 139 ++++++++----- Makefile.inc.in | 16 +- configure.ac | 138 +++++++++++-- dir-test.c | 518 ------------------------------------------------ quick-test.c | 226 --------------------- 5 files changed, 227 insertions(+), 810 deletions(-) delete mode 100644 dir-test.c delete mode 100644 quick-test.c
Signature · 1 line
2.18.0
PATCH RESEND 1/2 btrfs-progs: remove stale dir-test and quick-test
From: Omar Sandoval <[email protected]>
These don't build anymore and don't appear to be used for anything.
--- Makefile | 10 +- dir-test.c | 518 --------------------------------------------------- quick-test.c | 226 ---------------------- 3 files changed, 1 insertion(+), 753 deletions(-) delete mode 100644 dir-test.c delete mode 100644 quick-test.c
Makefile +1 -9
@@ -495,14 +495,6 @@ btrfs-convert.static: $(static_convert_objects) $(static_objects) $(static_libbt @echo " [LD] $@" $(Q)$(CC) -o $@ $^ $(STATIC_LDFLAGS) $(btrfs_convert_libs) $(STATIC_LIBS) -dir-test: dir-test.o $(objects) $(libs) - @echo " [LD] $@" - $(Q)$(CC) -o $@ $^ $(LDFLAGS) $(LIBS) - -quick-test: quick-test.o $(objects) $(libs) - @echo " [LD] $@" - $(Q)$(CC) -o $@ $^ $(LDFLAGS) $(LIBS) - ioctl-test.o: ioctl-test.c ioctl.h kerncompat.h ctree.h @echo " [CC] $@" $(Q)$(CC) $(CFLAGS) -c $< -o $@
@@ -603,7 +595,7 @@ clean: $(CLEANDIRS) image/*.o image/*.o.d \ convert/*.o convert/*.o.d \ mkfs/*.o mkfs/*.o.d check/*.o check/*.o.d \ - dir-test ioctl-test quick-test library-test library-test-static \ + ioctl-test library-test library-test-static \ mktables btrfs.static mkfs.btrfs.static fssum \ $(check_defs) \ $(libs) $(lib_links) \
dir-test.c deleted +0 -518
518 lines not on this page · raw message
quick-test.c deleted +0 -226
226 lines not on this page · raw message
Signature · 1 line
2.18.0
PATCH RESEND 2/2 btrfs-progs: make all programs and libraries optional
In reply to Omar SandovalFrom: Omar Sandoval <[email protected]>
We have a build system internally which only needs to build the libraries out of a repository, not any binaries. I looked at how this works with other projects, and the best example was util-linux, which makes it possible to enable or disable everything individually. This is nice and really flexible, so let's do the same. This way, if you only want to build and install libbtrfsutil, you can simply do
./configure --disable-documentation --disable-all-programs --enable-libbtrfsutil make make install
--- Makefile | 129 +++++++++++++++++++++++++++++++------------- Makefile.inc.in | 16 +++++- configure.ac | 138 +++++++++++++++++++++++++++++++++++++++++------- 3 files changed, 226 insertions(+), 57 deletions(-)
Makefile +92 -37
@@ -206,22 +206,40 @@ endif MAKEOPTS = --no-print-directory Q=$(Q) -# build all by default -progs = $(progs_install) btrfsck btrfs-corrupt-block - -# install only selected -progs_install = btrfs mkfs.btrfs btrfs-map-logical btrfs-image \ - btrfs-find-root btrfstune \ - btrfs-select-super - -# other tools, not built by default -progs_extra = btrfs-fragments - -progs_static = $(foreach p,$(progs),$(p).static) - -ifneq ($(DISABLE_BTRFSCONVERT),1) +ifeq ($(BUILD_BTRFS),1) +progs_install += btrfs +progs += btrfsck +endif +ifeq ($(BUILD_CONVERT),1) progs_install += btrfs-convert endif +ifeq ($(BUILD_CORRUPT_BLOCK),1) +progs += btrfs-corrupt-block +endif +ifeq ($(BUILD_FIND_ROOT),1) +progs_install += btrfs-find-root +endif +ifeq ($(BUILD_FRAGMENTS),1) +progs += btrfs-fragments +endif +ifeq ($(BUILD_IMAGE),1) +progs_install += btrfs-image +endif +ifeq ($(BUILD_MAP_LOGICAL),1) +progs_install += btrfs-map-logical +endif +ifeq ($(BUILD_MKFS),1) +progs_install += mkfs.btrfs +endif +ifeq ($(BUILD_SELECT_SUPER),1) +progs_install += btrfs-select-super +endif +ifeq ($(BUILD_TUNE),1) +progs_install += btrfstune +endif + +progs += $(progs_install) +progs_static = $(foreach p,$(progs),$(p).static) # external libs required by various binaries; for btrfs-foo, # specify btrfs_foo_libs = <list of libs>; see $($(subst...)) rules below
@@ -233,7 +251,7 @@ cmds_restore_cflags = -DBTRFSRESTORE_ZSTD=$(BTRFSRESTORE_ZSTD) CHECKER_FLAGS += $(btrfs_convert_cflags) # 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 = BUILDDIRS = $(patsubst %,build-%,$(SUBDIRS))
@@ -262,10 +280,21 @@ static_convert_objects = $(patsubst %.o, %.static.o, $(convert_objects)) static_mkfs_objects = $(patsubst %.o, %.static.o, $(mkfs_objects)) static_image_objects = $(patsubst %.o, %.static.o, $(image_objects)) -libs_shared = libbtrfs.so.0.1 libbtrfsutil.so.$(libbtrfsutil_version) -libs_static = libbtrfs.a libbtrfsutil.a +ifeq ($(BUILD_LIBBTRFS),1) +ifeq ($(BUILD_SHARED),1) +libs_shared += libbtrfs.so.0.1 +lib_links += libbtrfs.so.0 libbtrfs.so +endif +libs_static += libbtrfs.a +endif +ifeq ($(BUILD_LIBBTRFSUTIL),1) +ifeq ($(BUILD_SHARED),1) +libs_shared += libbtrfsutil.so.$(libbtrfsutil_version) +lib_links += libbtrfsutil.so.$(libbtrfsutil_major) libbtrfsutil.so +endif +libs_static += libbtrfsutil.a +endif libs = $(libs_shared) $(libs_static) -lib_links = libbtrfs.so.0 libbtrfs.so libbtrfsutil.so.$(libbtrfsutil_major) libbtrfsutil.so # make C=1 to enable sparse ifdef C
@@ -303,7 +332,7 @@ endif $($(subst -,_,btrfs-$(@:%/$(notdir $@)=%)-cflags)) all: $(progs) $(libs) $(lib_links) $(BUILDDIRS) -ifeq ($(PYTHON_BINDINGS),1) +ifeq ($(BUILD_PYTHON),1) all: libbtrfsutil_python endif $(SUBDIRS): $(BUILDDIRS)
@@ -353,7 +382,7 @@ testsuite: btrfs-corrupt-block fssum @echo "Export tests as a package" $(Q)cd tests && ./export-testsuite.sh -ifeq ($(PYTHON_BINDINGS),1) +ifeq ($(BUILD_PYTHON),1) test-libbtrfsutil: libbtrfsutil_python mkfs.btrfs $(Q)cd libbtrfsutil/python; \ LD_LIBRARY_PATH=../.. $(PYTHON) -m unittest discover -v tests
@@ -413,7 +442,7 @@ libbtrfsutil.so.$(libbtrfsutil_major) libbtrfsutil.so: libbtrfsutil.so.$(libbtrf @echo " [LN] $@" $(Q)$(LN_S) -f $< $@ -ifeq ($(PYTHON_BINDINGS),1) +ifeq ($(BUILD_PYTHON),1) libbtrfsutil_python: libbtrfsutil.so.$(libbtrfsutil_major) libbtrfsutil.so libbtrfsutil/btrfsutil.h @echo " [PY] libbtrfsutil" $(Q)cd libbtrfsutil/python; \
@@ -439,14 +468,14 @@ btrfs-%.static: btrfs-%.static.o $(static_objects) $(patsubst %.o,%.static.o,$(s $(static_libbtrfs_objects) $(STATIC_LDFLAGS) \ $($(subst -,_,$(subst .static,,$@)-libs)) $(STATIC_LIBS) -btrfs-%: btrfs-%.o $(objects) $(standalone_deps) $(libs_static) +btrfs-%: btrfs-%.o $(objects) $(standalone_deps) libbtrfs.a libbtrfsutil.a @echo " [LD] $@" $(Q)$(CC) -o $@ $(objects) [email protected] \ $($(subst -,_,$@-objects)) \ - $(libs_static) \ + libbtrfs.a libbtrfsutil.a \ $(LDFLAGS) $(LIBS) $($(subst -,_,$@-libs)) -btrfs: btrfs.o $(objects) $(cmds_objects) $(libs_static) +btrfs: btrfs.o $(objects) $(cmds_objects) libbtrfs.a libbtrfsutil.a @echo " [LD] $@" $(Q)$(CC) -o $@ $^ $(LDFLAGS) $(LIBS) $(LIBS_COMP)
@@ -463,7 +492,7 @@ btrfsck.static: btrfs.static @echo " [LN] $@" $(Q)$(LN_S) -f $^ $@ -mkfs.btrfs: $(mkfs_objects) $(objects) $(libs_static) +mkfs.btrfs: $(mkfs_objects) $(objects) libbtrfs.a libbtrfsutil.a @echo " [LD] $@" $(Q)$(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
@@ -471,7 +500,7 @@ mkfs.btrfs.static: $(static_mkfs_objects) $(static_objects) $(static_libbtrfs_ob @echo " [LD] $@" $(Q)$(CC) -o $@ $^ $(STATIC_LDFLAGS) $(STATIC_LIBS) -btrfstune: btrfstune.o $(objects) $(libs_static) +btrfstune: btrfstune.o $(objects) libbtrfs.a libbtrfsutil.a @echo " [LD] $@" $(Q)$(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
@@ -479,7 +508,7 @@ btrfstune.static: btrfstune.static.o $(static_objects) $(static_libbtrfs_objects @echo " [LD] $@" $(Q)$(CC) -o $@ $^ $(STATIC_LDFLAGS) $(STATIC_LIBS) -btrfs-image: $(image_objects) $(objects) $(libs_static) +btrfs-image: $(image_objects) $(objects) libbtrfs.a libbtrfsutil.a @echo " [LD] $@" $(Q)$(CC) -o $@ $^ $(LDFLAGS) $(LIBS) $(LIBS_COMP)
@@ -487,7 +516,7 @@ btrfs-image.static: $(static_image_objects) $(static_objects) $(static_libbtrfs_ @echo " [LD] $@" $(Q)$(CC) -o $@ $^ $(STATIC_LDFLAGS) $(STATIC_LIBS) $(STATIC_LIBS_COMP) -btrfs-convert: $(convert_objects) $(objects) $(libs_static) +btrfs-convert: $(convert_objects) $(objects) libbtrfs.a libbtrfsutil.a @echo " [LD] $@" $(Q)$(CC) -o $@ $^ $(LDFLAGS) $(btrfs_convert_libs) $(LIBS)
@@ -541,7 +570,7 @@ library-test: library-test.c libbtrfs.so @echo " [TEST CLEAN] $@" $(Q)$(RM) -rf -- $(TMPD) -library-test.static: library-test.c $(libs_static) +library-test.static: library-test.c libbtrfs.a @echo " [TEST PREP] $@"$(eval TMPD=$(shell mktemp -d)) $(Q)mkdir -p $(TMPD)/include/btrfs && \ cp $(libbtrfs_headers) $(TMPD)/include/btrfs && \
@@ -567,7 +596,6 @@ test-build-real: -$(MAKE) $(MAKEOPTS) library-test.static $(MAKE) $(MAKEOPTS) -j 8 all -$(MAKE) $(MAKEOPTS) -j 8 static - $(MAKE) $(MAKEOPTS) -j 8 $(progs_extra) manpages: $(Q)$(MAKE) $(MAKEOPTS) -C Documentation
@@ -598,10 +626,10 @@ clean: $(CLEANDIRS) ioctl-test library-test library-test-static \ mktables btrfs.static mkfs.btrfs.static fssum \ $(check_defs) \ - $(libs) $(lib_links) \ - $(progs_static) $(progs_extra) \ + libbtrfs.a libbtrfs.so* libbtrfsutil.a libbtrfsutil.so* \ + $(progs_static) \ libbtrfsutil/*.o libbtrfsutil/*.o.d -ifeq ($(PYTHON_BINDINGS),1) +ifeq ($(BUILD_PYTHON),1) $(Q)cd libbtrfsutil/python; \ $(PYTHON) setup.py $(SETUP_PY_Q) clean -a endif
@@ -624,23 +652,36 @@ $(CLEANDIRS): $(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst clean-%,%,$@) clean install: $(libs) $(progs_install) $(INSTALLDIRS) +ifneq ($(progs_install),) $(INSTALL) -m755 -d $(DESTDIR)$(bindir) $(INSTALL) $(progs_install) $(DESTDIR)$(bindir) +endif +ifeq ($(BUILD_BTRFS),1) $(INSTALL) fsck.btrfs $(DESTDIR)$(bindir) # 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 +ifneq ($(udevdir),) + $(INSTALL) -m755 -d $(DESTDIR)$(udevruledir) + $(INSTALL) -m644 $(udev_rules) $(DESTDIR)$(udevruledir) +endif +endif +ifneq ($(libs),) $(INSTALL) -m755 -d $(DESTDIR)$(libdir) $(INSTALL) $(libs) $(DESTDIR)$(libdir) +ifneq ($(lib_links),) cp -d $(lib_links) $(DESTDIR)$(libdir) +endif +endif +ifeq ($(BUILD_LIBBTRFS),1) $(INSTALL) -m755 -d $(DESTDIR)$(incdir)/btrfs $(INSTALL) -m644 $(libbtrfs_headers) $(DESTDIR)$(incdir)/btrfs +endif +ifeq ($(BUILD_LIBBTRFSUTIL),1) + $(INSTALL) -m755 -d $(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 ($(BUILD_PYTHON),1) install_python: libbtrfsutil_python $(Q)cd libbtrfsutil/python; \ $(PYTHON) setup.py install --skip-build $(if $(DESTDIR),--root $(DESTDIR)) --prefix $(prefix)
@@ -649,22 +690,36 @@ install_python: libbtrfsutil_python endif install-static: $(progs_static) $(INSTALLDIRS) +ifneq ($(progs_static),) $(INSTALL) -m755 -d $(DESTDIR)$(bindir) $(INSTALL) $(progs_static) $(DESTDIR)$(bindir) +endif +ifeq ($(BUILD_BTRFS),1) # btrfsck is a link to btrfs in the src tree, make it so for installed file as well $(LN_S) -f btrfs.static $(DESTDIR)$(bindir)/btrfsck.static +endif $(INSTALLDIRS): @echo "Making install in $(patsubst install-%,%,$@)" $(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst install-%,%,$@) install uninstall: +ifneq ($(DISABLE_DOCUMENTATION),1) $(Q)$(MAKE) $(MAKEOPTS) -C Documentation uninstall +endif +ifeq ($(BUILD_LIBBTRFS),1) cd $(DESTDIR)$(incdir)/btrfs; $(RM) -f -- $(libbtrfs_headers) $(RMDIR) -p --ignore-fail-on-non-empty -- $(DESTDIR)$(incdir)/btrfs +endif +ifeq ($(BUILD_LIBBTRFSUTIL),1) cd $(DESTDIR)$(incdir); $(RM) -f -- btrfsutil.h +endif +ifneq ($(libs) $(lib_links),) cd $(DESTDIR)$(libdir); $(RM) -f -- $(lib_links) $(libs) +endif +ifneq ($(progs_install),) cd $(DESTDIR)$(bindir); $(RM) -f -- btrfsck fsck.btrfs $(progs_install) +endif ifneq ($(MAKECMDGOALS),clean) -include $(all_objects:.o=.o.d) $(subst .btrfs,, $(filter-out btrfsck.o.d, $(progs:=.o.d)))
Makefile.inc.in +14 -2
@@ -11,11 +11,23 @@ RM = @RM@ RMDIR = @RMDIR@ INSTALL = @INSTALL@ DISABLE_DOCUMENTATION = @DISABLE_DOCUMENTATION@ -DISABLE_BTRFSCONVERT = @DISABLE_BTRFSCONVERT@ +BUILD_BTRFS = @BUILD_BTRFS@ +BUILD_CONVERT = @BUILD_CONVERT@ +BUILD_CORRUPT_BLOCK = @BUILD_CORRUPT_BLOCK@ +BUILD_FIND_ROOT = @BUILD_FIND_ROOT@ +BUILD_FRAGMENTS = @BUILD_FRAGMENTS@ +BUILD_IMAGE = @BUILD_IMAGE@ +BUILD_MAP_LOGICAL = @BUILD_MAP_LOGICAL@ +BUILD_MKFS = @BUILD_MKFS@ +BUILD_SELECT_SUPER = @BUILD_SELECT_SUPER@ +BUILD_TUNE = @BUILD_TUNE@ BTRFSCONVERT_EXT2 = @BTRFSCONVERT_EXT2@ BTRFSCONVERT_REISERFS = @BTRFSCONVERT_REISERFS@ BTRFSRESTORE_ZSTD = @BTRFSRESTORE_ZSTD@ -PYTHON_BINDINGS = @PYTHON_BINDINGS@ +BUILD_LIBBTRFS = @BUILD_LIBBTRFS@ +BUILD_LIBBTRFSUTIL = @BUILD_LIBBTRFSUTIL@ +BUILD_PYTHON = @BUILD_PYTHON@ +BUILD_SHARED = @BUILD_SHARED@ PYTHON = @PYTHON@ PYTHON_CFLAGS = @PYTHON_CFLAGS@
configure.ac +120 -18
160 lines not on this page · raw message
Signature · 1 line
2.18.0
Re: [PATCH RESEND 1/2] btrfs-progs: remove stale dir-test and quick-test
In reply to Omar SandovalQuoted 3 lines · Omar Sandoval
From: Omar Sandoval <[email protected]>
These don't build anymore and don't appear to be used for anything.
I've fixed build of quick-test and will keep the code for now, it can be used for some stress testing. The dir-test does not seem to be even potentially useful in the fucute, so it's dropped now.
Re: [PATCH RESEND 2/2] btrfs-progs: make all programs and libraries optional
In reply to Omar SandovalQuoted 9 lines · Omar Sandoval
From: Omar Sandoval <[email protected]>
We have a build system internally which only needs to build the libraries out of a repository, not any binaries. I looked at how this works with other projects, and the best example was util-linux, which makes it possible to enable or disable everything individually. This is nice and really flexible, so let's do the same. This way, if you only want to build and install libbtrfsutil, you can simply do
Quoted 3 lines
./configure --disable-documentation --disable-all-programs --enable-libbtrfsutil make make install
I think this is an overkill and abusing the --enable-XXX options. You want to avoid building the tools by default, so adding an option for that is fine. Selectively building only certain tools can utilize that option too and just follow with 'make btrfs-image' etc.
The number of --enable-* will stay minimal and we don't even have to discuss how to find a good naming scheme (that works for util-linux but looks a bit confusing for btrfs-progs).
Re: [PATCH RESEND 2/2] btrfs-progs: make all programs and libraries optional
Quoted 10 lines · David Sterba
Quoted 9 lines · Omar Sandoval
From: Omar Sandoval <[email protected]>
We have a build system internally which only needs to build the libraries out of a repository, not any binaries. I looked at how this works with other projects, and the best example was util-linux, which makes it possible to enable or disable everything individually. This is nice and really flexible, so let's do the same. This way, if you only want to build and install libbtrfsutil, you can simply do
Quoted 8 lines
Quoted 3 lines
./configure --disable-documentation --disable-all-programs --enable-libbtrfsutil make make installI think this is an overkill and abusing the --enable-XXX options. You want to avoid building the tools by default, so adding an option for that is fine. Selectively building only certain tools can utilize that option too and just follow with 'make btrfs-image' etc.
Yeah, it's easy to build stuff selectively, but make install will still try to build everything, that's the part I'm more concerned with.
Quoted 3 lines
The number of --enable-* will stay minimal and we don't even have to discuss how to find a good naming scheme (that works for util-linux but looks a bit confusing for btrfs-progs).
Ok, I can collapse these into just --disable-programs/--enable-programs, and --disable-libraries/--enable-libraries? That would be enough for me.
Re: [PATCH RESEND 2/2] btrfs-progs: make all programs and libraries optional
Quoted 15 lines · Omar Sandoval
Quoted 14 lines · David Sterba
Quoted 12 lines · Omar Sandoval
From: Omar Sandoval <[email protected]>
We have a build system internally which only needs to build the libraries out of a repository, not any binaries. I looked at how this works with other projects, and the best example was util-linux, which makes it possible to enable or disable everything individually. This is nice and really flexible, so let's do the same. This way, if you only want to build and install libbtrfsutil, you can simply do
./configure --disable-documentation --disable-all-programs --enable-libbtrfsutil make make install
Quoted 7 lines
Quoted 4 lines
I think this is an overkill and abusing the --enable-XXX options. You want to avoid building the tools by default, so adding an option for that is fine. Selectively building only certain tools can utilize that option too and just follow with 'make btrfs-image' etc.
Yeah, it's easy to build stuff selectively, but
make installwill still try to build everything, that's the part I'm more concerned with.
Oh right, installation. What if it installs just the binaries that are built? The default actions done by configure & make & make install would not change, but there could be configure --disable-all, then selectively make and final make install would be
for p in $(progs_install); if test -f $p && $(INSTALL) ...; fi
Quoted 6 lines
Quoted 3 lines
The number of --enable-* will stay minimal and we don't even have to discuss how to find a good naming scheme (that works for util-linux but looks a bit confusing for btrfs-progs).
Ok, I can collapse these into just --disable-programs/--enable-programs, and --disable-libraries/--enable-libraries? That would be enough for me.
Sounds ok.