* [PATCH v2 0/2] btrfs-progs: build improvements
@ 2018-07-26 20:34 Omar Sandoval
2018-07-26 20:34 ` [PATCH v2 1/2] btrfs-progs: add --disable-programs Omar Sandoval
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Omar Sandoval @ 2018-07-26 20:34 UTC (permalink / raw)
To: linux-btrfs; +Cc: kernel-team, David Sterba
From: Omar Sandoval <osandov@fb.com>
Hi, Dave,
Here's v2 of "btrfs-progs: make all programs and libraries optional",
this time much less overkill. Now, it's just --disable-programs,
--disable-shared, and --disable-static. Based on your devel branch.
Please consider these for the next progs release.
Thanks!
Omar Sandoval (2):
btrfs-progs: add --disable-programs
btrfs-progs: add --disable-shared and --disable-static
Makefile | 56 +++++++++++++++++++++++++++++++++----------------
Makefile.inc.in | 3 +++
configure.ac | 28 +++++++++++++++++++++++--
3 files changed, 67 insertions(+), 20 deletions(-)
--
2.18.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v2 1/2] btrfs-progs: add --disable-programs
2018-07-26 20:34 [PATCH v2 0/2] btrfs-progs: build improvements Omar Sandoval
@ 2018-07-26 20:34 ` Omar Sandoval
2018-07-26 20:34 ` [PATCH v2 2/2] btrfs-progs: add --disable-shared and --disable-static Omar Sandoval
2018-08-02 19:17 ` [PATCH v2 0/2] btrfs-progs: build improvements David Sterba
2 siblings, 0 replies; 4+ messages in thread
From: Omar Sandoval @ 2018-07-26 20:34 UTC (permalink / raw)
To: linux-btrfs; +Cc: kernel-team, David Sterba
From: Omar Sandoval <osandov@fb.com>
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>
---
Makefile | 43 ++++++++++++++++++++++++++-----------------
Makefile.inc.in | 1 +
configure.ac | 10 +++++++++-
3 files changed, 36 insertions(+), 18 deletions(-)
diff --git a/Makefile b/Makefile
index d53f6c1d..24aa8234 100644
--- a/Makefile
+++ b/Makefile
@@ -207,23 +207,31 @@ endif
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 \
- btrfs-find-root btrfstune \
- btrfs-select-super
+ btrfs-find-root btrfstune btrfs-select-super
-# other tools, not built by default
-progs_extra = btrfs-fragments
+# Programs to build.
+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)
progs_install += btrfs-convert
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,
# specify btrfs_foo_libs = <list of libs>; see $($(subst...)) rules below
btrfs_convert_cflags = -DBTRFSCONVERT_EXT2=$(BTRFSCONVERT_EXT2)
@@ -234,7 +242,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))
@@ -303,7 +311,7 @@ endif
$(Q)$(CC) $(STATIC_CFLAGS) -c $< -o $@ $($(subst -,_,$(@:%.static.o=%)-cflags)) \
$($(subst -,_,btrfs-$(@:%/$(notdir $@)=%)-cflags))
-all: $(progs) $(libs) $(lib_links) $(BUILDDIRS)
+all: $(progs_build) $(libs) $(lib_links) $(BUILDDIRS)
ifeq ($(PYTHON_BINDINGS),1)
all: libbtrfsutil_python
endif
@@ -570,9 +578,8 @@ test-build-pre:
test-build-real:
$(MAKE) $(MAKEOPTS) library-test
-$(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 $(progs_extra)
manpages:
$(Q)$(MAKE) $(MAKEOPTS) -C Documentation
@@ -604,7 +611,7 @@ clean: $(CLEANDIRS)
mktables btrfs.static mkfs.btrfs.static fssum \
$(check_defs) \
$(libs) $(lib_links) \
- $(progs_static) $(progs_extra) \
+ $(progs_static) \
libbtrfsutil/*.o libbtrfsutil/*.o.d
ifeq ($(PYTHON_BINDINGS),1)
$(Q)cd libbtrfsutil/python; \
@@ -629,21 +636,23 @@ $(CLEANDIRS):
$(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst clean-%,%,$@) clean
install: $(libs) $(progs_install) $(INSTALLDIRS)
+ifeq ($(BUILD_PROGRAMS),1)
$(INSTALL) -m755 -d $(DESTDIR)$(bindir)
$(INSTALL) $(progs_install) $(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
$(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) $(libs) $(DESTDIR)$(libdir)
cp -d $(lib_links) $(DESTDIR)$(libdir)
$(INSTALL) -m755 -d $(DESTDIR)$(incdir)/btrfs
$(INSTALL) -m644 $(libbtrfs_headers) $(DESTDIR)$(incdir)/btrfs
$(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)
install_python: libbtrfsutil_python
diff --git a/Makefile.inc.in b/Makefile.inc.in
index fb324614..5c8d1297 100644
--- a/Makefile.inc.in
+++ b/Makefile.inc.in
@@ -12,6 +12,7 @@ RMDIR = @RMDIR@
INSTALL = @INSTALL@
DISABLE_DOCUMENTATION = @DISABLE_DOCUMENTATION@
DISABLE_BTRFSCONVERT = @DISABLE_BTRFSCONVERT@
+BUILD_PROGRAMS = @BUILD_PROGRAMS@
BTRFSCONVERT_EXT2 = @BTRFSCONVERT_EXT2@
BTRFSCONVERT_REISERFS = @BTRFSCONVERT_REISERFS@
BTRFSRESTORE_ZSTD = @BTRFSRESTORE_ZSTD@
diff --git a/configure.ac b/configure.ac
index 2567de12..230f37fa 100644
--- a/configure.ac
+++ b/configure.ac
@@ -118,9 +118,16 @@ if test "x$enable_documentation" = xyes; then
fi
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],
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])
@@ -277,6 +284,7 @@ AC_MSG_RESULT([
cflags: ${CFLAGS}
ldflags: ${LDFLAGS}
+ programs: ${enable_programs}
documentation: ${enable_documentation}
doc generator: ${ASCIIDOC_TOOL}
backtrace support: ${enable_backtrace}
--
2.18.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] btrfs-progs: add --disable-shared and --disable-static
2018-07-26 20:34 [PATCH v2 0/2] btrfs-progs: build improvements Omar Sandoval
2018-07-26 20:34 ` [PATCH v2 1/2] btrfs-progs: add --disable-programs Omar Sandoval
@ 2018-07-26 20:34 ` Omar Sandoval
2018-08-02 19:17 ` [PATCH v2 0/2] btrfs-progs: build improvements David Sterba
2 siblings, 0 replies; 4+ messages in thread
From: Omar Sandoval @ 2018-07-26 20:34 UTC (permalink / raw)
To: linux-btrfs; +Cc: kernel-team, David Sterba
From: Omar Sandoval <osandov@fb.com>
The build system mentioned in the previous commit builds libraries in
both PIC and non-PIC mode. Shared libraries don't work in PIC mode, so
it expects a --disable-shared configure option, which most open source
libraries using autoconf have. Let's add it, too.
Signed-off-by: Omar Sandoval <osandov@fb.com>
---
Makefile | 17 ++++++++++++++---
Makefile.inc.in | 2 ++
configure.ac | 18 +++++++++++++++++-
3 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 24aa8234..f4ab14ea 100644
--- a/Makefile
+++ b/Makefile
@@ -275,6 +275,13 @@ libs_shared = libbtrfs.so.0.1 libbtrfsutil.so.$(libbtrfsutil_version)
libs_static = libbtrfs.a libbtrfsutil.a
libs = $(libs_shared) $(libs_static)
lib_links = libbtrfs.so.0 libbtrfs.so libbtrfsutil.so.$(libbtrfsutil_major) libbtrfsutil.so
+libs_build =
+ifeq ($(BUILD_SHARED_LIBRARIES),1)
+libs_build += $(libs_shared) $(lib_links)
+endif
+ifeq ($(BUILD_STATIC_LIBRARIES),1)
+libs_build += $(libs_static)
+endif
# make C=1 to enable sparse
ifdef C
@@ -311,7 +318,7 @@ endif
$(Q)$(CC) $(STATIC_CFLAGS) -c $< -o $@ $($(subst -,_,$(@:%.static.o=%)-cflags)) \
$($(subst -,_,btrfs-$(@:%/$(notdir $@)=%)-cflags))
-all: $(progs_build) $(libs) $(lib_links) $(BUILDDIRS)
+all: $(progs_build) $(libs_build) $(BUILDDIRS)
ifeq ($(PYTHON_BINDINGS),1)
all: libbtrfsutil_python
endif
@@ -635,7 +642,7 @@ $(CLEANDIRS):
@echo "Cleaning $(patsubst clean-%,%,$@)"
$(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst clean-%,%,$@) clean
-install: $(libs) $(progs_install) $(INSTALLDIRS)
+install: $(libs_build) $(progs_install) $(INSTALLDIRS)
ifeq ($(BUILD_PROGRAMS),1)
$(INSTALL) -m755 -d $(DESTDIR)$(bindir)
$(INSTALL) $(progs_install) $(DESTDIR)$(bindir)
@@ -647,12 +654,16 @@ ifneq ($(udevdir),)
$(INSTALL) -m644 $(udev_rules) $(DESTDIR)$(udevruledir)
endif
endif
+ifneq ($(libs_build),)
$(INSTALL) -m755 -d $(DESTDIR)$(libdir)
- $(INSTALL) $(libs) $(DESTDIR)$(libdir)
+ $(INSTALL) $(libs_build) $(DESTDIR)$(libdir)
+ifeq ($(BUILD_SHARED_LIBRARIES),1)
cp -d $(lib_links) $(DESTDIR)$(libdir)
+endif
$(INSTALL) -m755 -d $(DESTDIR)$(incdir)/btrfs
$(INSTALL) -m644 $(libbtrfs_headers) $(DESTDIR)$(incdir)/btrfs
$(INSTALL) -m644 libbtrfsutil/btrfsutil.h $(DESTDIR)$(incdir)
+endif
ifeq ($(PYTHON_BINDINGS),1)
install_python: libbtrfsutil_python
diff --git a/Makefile.inc.in b/Makefile.inc.in
index 5c8d1297..a86c528e 100644
--- a/Makefile.inc.in
+++ b/Makefile.inc.in
@@ -13,6 +13,8 @@ INSTALL = @INSTALL@
DISABLE_DOCUMENTATION = @DISABLE_DOCUMENTATION@
DISABLE_BTRFSCONVERT = @DISABLE_BTRFSCONVERT@
BUILD_PROGRAMS = @BUILD_PROGRAMS@
+BUILD_SHARED_LIBRARIES = @BUILD_SHARED_LIBRARIES@
+BUILD_STATIC_LIBRARIES = @BUILD_STATIC_LIBRARIES@
BTRFSCONVERT_EXT2 = @BTRFSCONVERT_EXT2@
BTRFSCONVERT_REISERFS = @BTRFSCONVERT_REISERFS@
BTRFSRESTORE_ZSTD = @BTRFSRESTORE_ZSTD@
diff --git a/configure.ac b/configure.ac
index 230f37fa..df02f206 100644
--- a/configure.ac
+++ b/configure.ac
@@ -125,6 +125,20 @@ AC_ARG_ENABLE([programs],
AS_IF([test "x$enable_programs" = xyes], [BUILD_PROGRAMS=1], [BUILD_PROGRAMS=0])
AC_SUBST([BUILD_PROGRAMS])
+AC_ARG_ENABLE([shared],
+ AS_HELP_STRING([--disable-shared], [do not build shared libraries]),
+ [], [enable_shared=yes]
+)
+AS_IF([test "x$enable_shared" = xyes], [BUILD_SHARED_LIBRARIES=1], [BUILD_SHARED_LIBRARIES=0])
+AC_SUBST([BUILD_SHARED_LIBRARIES])
+
+AC_ARG_ENABLE([static],
+ AS_HELP_STRING([--disable-static], [do not build static libraries]),
+ [], [enable_static=yes]
+)
+AS_IF([test "x$enable_static" = xyes], [BUILD_STATIC_LIBRARIES=1], [BUILD_STATIC_LIBRARIES=0])
+AC_SUBST([BUILD_STATIC_LIBRARIES])
+
AC_ARG_ENABLE([convert],
AS_HELP_STRING([--disable-convert], [do not build btrfs-convert]),
[], [enable_convert=$enable_programs]
@@ -222,7 +236,7 @@ AC_SUBST(BTRFSRESTORE_ZSTD)
AC_ARG_ENABLE([python],
AS_HELP_STRING([--disable-python], [do not build libbtrfsutil Python bindings]),
- [], [enable_python=yes]
+ [], [enable_python=$enable_shared]
)
if test "x$enable_python" = xyes; then
@@ -285,6 +299,8 @@ AC_MSG_RESULT([
ldflags: ${LDFLAGS}
programs: ${enable_programs}
+ shared libraries: ${enable_shared}
+ static libraries: ${enable_static}
documentation: ${enable_documentation}
doc generator: ${ASCIIDOC_TOOL}
backtrace support: ${enable_backtrace}
--
2.18.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 0/2] btrfs-progs: build improvements
2018-07-26 20:34 [PATCH v2 0/2] btrfs-progs: build improvements Omar Sandoval
2018-07-26 20:34 ` [PATCH v2 1/2] btrfs-progs: add --disable-programs Omar Sandoval
2018-07-26 20:34 ` [PATCH v2 2/2] btrfs-progs: add --disable-shared and --disable-static Omar Sandoval
@ 2018-08-02 19:17 ` David Sterba
2 siblings, 0 replies; 4+ messages in thread
From: David Sterba @ 2018-08-02 19:17 UTC (permalink / raw)
To: Omar Sandoval; +Cc: linux-btrfs, kernel-team, David Sterba
On Thu, Jul 26, 2018 at 01:34:37PM -0700, Omar Sandoval wrote:
> From: Omar Sandoval <osandov@fb.com>
>
> Hi, Dave,
>
> Here's v2 of "btrfs-progs: make all programs and libraries optional",
> this time much less overkill. Now, it's just --disable-programs,
> --disable-shared, and --disable-static. Based on your devel branch.
> Please consider these for the next progs release.
Added to devel, thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-08-02 21:10 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-26 20:34 [PATCH v2 0/2] btrfs-progs: build improvements Omar Sandoval
2018-07-26 20:34 ` [PATCH v2 1/2] btrfs-progs: add --disable-programs Omar Sandoval
2018-07-26 20:34 ` [PATCH v2 2/2] btrfs-progs: add --disable-shared and --disable-static Omar Sandoval
2018-08-02 19:17 ` [PATCH v2 0/2] btrfs-progs: build improvements David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).