* [PATCH 01/10] btrfs-progs: add ./configure script
2014-12-12 12:35 btrfs-prog: improve build-system by autoconf Karel Zak
@ 2014-12-12 12:35 ` Karel Zak
2014-12-12 12:35 ` [PATCH 02/10] btrfs-progs: use config.h Karel Zak
` (9 subsequent siblings)
10 siblings, 0 replies; 18+ messages in thread
From: Karel Zak @ 2014-12-12 12:35 UTC (permalink / raw)
To: linux-btrfs; +Cc: Karel Zak
Add ./autogen.sh script, you have to use it after "git clone/clean" to
generate ./configure from configure.ac.
Modify version.sh to be usable from the configure script.
The patch also renames Makefile to Makefile.in, but does NOT change
anything in the file.
Signed-off-by: Karel Zak <kzak@redhat.com>
---
.gitignore | 28 ++++++
Makefile | 87 +++++++++--------
Makefile.in | 314 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
autogen.sh | 58 +++++++++++
configure.ac | 102 +++++++++++++++++++
version.sh | 7 ++
6 files changed, 557 insertions(+), 39 deletions(-)
create mode 100644 Makefile.in
create mode 100755 autogen.sh
create mode 100644 configure.ac
mode change 100644 => 100755 version.sh
diff --git a/.gitignore b/.gitignore
index e637b17..beddedb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -39,3 +39,31 @@ libbtrfs.so.0
libbtrfs.so.0.1
library-test
library-test-static
+
+
+aclocal.m4
+autom4te.cache
+compile
+config.cache
+config.guess
+config.h
+config.h.in
+config.log
+config.rpath
+config.status
+config.sub
+config/ltmain.sh
+config/py-compile
+config/test-driver
+configure
+cscope.out
+depcomp
+install-sh
+libtool
+m4/*.m4
+Makefile
+missing
+mkinstalldirs
+stamp-h
+stamp-h.in
+stamp-h1
diff --git a/Makefile b/Makefile
index 4cae30c..95700be 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,30 @@
# Export all variables to sub-makes by default
export
-CC = gcc
-LN = ln
-AR = ar
-AM_CFLAGS = -Wall -D_FILE_OFFSET_BITS=64 -DBTRFS_FLAT_INCLUDES -fno-strict-aliasing -fPIC
-CFLAGS = -g -O1 -fno-strict-aliasing -rdynamic
+CC = gcc -std=gnu99
+LN_S = ln -s
+AR = /usr/bin/ar
+INSTALL = /usr/bin/install -c
+
+# Non-static compilation flags
+CFLAGS = -g -O1 \
+ -include config.h -Wall \
+ -D_FILE_OFFSET_BITS=64 -DBTRFS_FLAT_INCLUDES \
+ -fno-strict-aliasing -fPIC \
+ -rdynamic
+
+LDFLAGS =
+
+LIBS = -luuid -lblkid -L/usr/lib64 -lz -lzo2 -lm -L.
+LIBBTRFS_LIBS = $(LIBS)
+
+# Static compilation flags
+STATIC_CFLAGS = $(CFLAGS) -ffunction-sections -fdata-sections
+STATIC_LDFLAGS = -static -Wl,--gc-sections
+STATIC_LIBS = @UUID_LIBS_STATIC@ @BLKID_LIBS_STATIC@ \
+ @ZLIB_LIBS_STATIC@ @LZO2_LIBS_STATIC@ -lpthread
+
+
objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \
root-tree.o dir-item.o file-item.o inode-item.o inode-map.o \
extent-cache.o extent_io.o volumes.o utils.o repair.o \
@@ -23,13 +42,10 @@ libbtrfs_headers = send-stream.h send-utils.h send.h rbtree.h btrfs-list.h \
extent_io.h ioctl.h ctree.h btrfsck.h version.h
TESTS = fsck-tests.sh convert-tests.sh
-INSTALL = install
-prefix ?= /usr/local
-bindir = $(prefix)/bin
-lib_LIBS = -luuid -lblkid -lm -lz -llzo2 -L.
-libdir ?= $(prefix)/lib
-incdir = $(prefix)/include/btrfs
-LIBS = $(lib_LIBS) $(libs_static)
+prefix ?= /usr
+bindir = ${exec_prefix}/bin
+libdir ?= ${exec_prefix}/lib
+incdir = ${prefix}/include/btrfs
ifeq ("$(origin V)", "command line")
BUILD_VERBOSE = $(V)
@@ -67,7 +83,7 @@ INSTALLDIRS = $(patsubst %,install-%,$(SUBDIRS))
CLEANDIRS = $(patsubst %,clean-%,$(SUBDIRS))
ifeq ($(DISABLE_BACKTRACE),1)
-AM_CFLAGS += -DBTRFS_DISABLE_BACKTRACE
+CFLAGS += -DBTRFS_DISABLE_BACKTRACE
endif
ifneq ($(DISABLE_DOCUMENTATION),1)
@@ -87,10 +103,6 @@ static_objects = $(patsubst %.o, %.static.o, $(objects))
static_cmds_objects = $(patsubst %.o, %.static.o, $(cmds_objects))
static_libbtrfs_objects = $(patsubst %.o, %.static.o, $(libbtrfs_objects))
-# Define static compilation flags
-STATIC_CFLAGS = $(CFLAGS) -ffunction-sections -fdata-sections
-STATIC_LDFLAGS = -static -Wl,--gc-sections
-STATIC_LIBS = $(lib_LIBS) -lpthread
libs_shared = libbtrfs.so.0.1
libs_static = libbtrfs.a
@@ -118,7 +130,7 @@ ifdef C
else
check = true
check_echo = true
- AM_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
+ CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
endif
%.o.d: %.c
@@ -126,13 +138,13 @@ endif
.c.o:
@$(check_echo) " [SP] $<"
- $(Q)$(check) $(AM_CFLAGS) $(CFLAGS) $<
+ $(Q)$(check) $(CFLAGS) $<
@echo " [CC] $@"
- $(Q)$(CC) $(AM_CFLAGS) $(CFLAGS) -c $<
+ $(Q)$(CC) $(CFLAGS) -c $<
%.static.o: %.c
@echo " [CC] $@"
- $(Q)$(CC) $(AM_CFLAGS) $(STATIC_CFLAGS) -c $< -o $@
+ $(Q)$(CC) $(STATIC_CFLAGS) -c $< -o $@
all: $(progs) $(BUILDDIRS)
$(SUBDIRS): $(BUILDDIRS)
@@ -152,13 +164,9 @@ test:
#
static: $(progs_static)
-version.h:
- @echo " [SH] $@"
- $(Q)bash version.sh
-
$(libs_shared): $(libbtrfs_objects) $(lib_links) send.h
@echo " [LD] $@"
- $(Q)$(CC) $(CFLAGS) $(libbtrfs_objects) $(LDFLAGS) $(lib_LIBS) \
+ $(Q)$(CC) $(CFLAGS) $(libbtrfs_objects) $(LDFLAGS) $(LIBBTRFS_LIBS) \
-shared -Wl,-soname,libbtrfs.so.0 -o libbtrfs.so.0.1
$(libs_static): $(libbtrfs_objects)
@@ -167,8 +175,8 @@ $(libs_static): $(libbtrfs_objects)
$(lib_links):
@echo " [LN] $@"
- $(Q)$(LN) -sf libbtrfs.so.0.1 libbtrfs.so.0
- $(Q)$(LN) -sf libbtrfs.so.0.1 libbtrfs.so
+ $(Q)$(LN_S) -f libbtrfs.so.0.1 libbtrfs.so.0
+ $(Q)$(LN_S) -f libbtrfs.so.0.1 libbtrfs.so
# keep intermediate files from the below implicit rules around
.PRECIOUS: $(addsuffix .o,$(progs))
@@ -188,12 +196,13 @@ btrfs-%.static: $(static_objects) btrfs-%.static.o $(static_libbtrfs_objects)
btrfs-%: $(objects) $(libs) btrfs-%.o
@echo " [LD] $@"
- $(Q)$(CC) $(CFLAGS) -o $@ $(objects) $@.o $(LDFLAGS) $(LIBS) $($(subst -,_,$@-libs))
+ $(Q)$(CC) $(CFLAGS) -o $@ $(objects) $@.o $(libs) \
+ $(LDFLAGS) $(LIBS) $($(subst -,_,$@-libs))
btrfs: $(objects) btrfs.o help.o $(cmds_objects) $(libs)
@echo " [LD] $@"
$(Q)$(CC) $(CFLAGS) -o btrfs btrfs.o help.o $(cmds_objects) \
- $(objects) $(LDFLAGS) $(LIBS) -lpthread
+ $(objects) $(libs) $(LDFLAGS) $(LIBS) -lpthread
btrfs.static: $(static_objects) btrfs.static.o help.static.o $(static_cmds_objects) $(static_libbtrfs_objects)
@echo " [LD] $@"
@@ -203,15 +212,15 @@ btrfs.static: $(static_objects) btrfs.static.o help.static.o $(static_cmds_objec
# For backward compatibility, 'btrfs' changes behaviour to fsck if it's named 'btrfsck'
btrfsck: btrfs
@echo " [LN] $@"
- $(Q)$(LN) -f btrfs btrfsck
+ $(Q)$(LN_S) -f btrfs btrfsck
btrfsck.static: btrfs.static
@echo " [LN] $@"
- $(Q)$(LN) -f $^ $@
+ $(Q)$(LN_S) -f $^ $@
mkfs.btrfs: $(objects) $(libs) mkfs.o
@echo " [LD] $@"
- $(Q)$(CC) $(CFLAGS) -o mkfs.btrfs $(objects) mkfs.o $(LDFLAGS) $(LIBS)
+ $(Q)$(CC) $(CFLAGS) -o mkfs.btrfs $(objects) $(libs) mkfs.o $(LDFLAGS) $(LIBS)
mkfs.btrfs.static: $(static_objects) mkfs.static.o $(static_libbtrfs_objects)
@echo " [LD] $@"
@@ -220,7 +229,7 @@ mkfs.btrfs.static: $(static_objects) mkfs.static.o $(static_libbtrfs_objects)
btrfstune: $(objects) $(libs) btrfstune.o
@echo " [LD] $@"
- $(Q)$(CC) $(CFLAGS) -o btrfstune $(objects) btrfstune.o $(LDFLAGS) $(LIBS)
+ $(Q)$(CC) $(CFLAGS) -o btrfstune $(objects) $(libs) btrfstune.o $(LDFLAGS) $(LIBS)
btrfstune.static: $(static_objects) btrfstune.static.o $(static_libbtrfs_objects)
@echo " [LD] $@"
@@ -229,19 +238,19 @@ btrfstune.static: $(static_objects) btrfstune.static.o $(static_libbtrfs_objects
dir-test: $(objects) $(libs) dir-test.o
@echo " [LD] $@"
- $(Q)$(CC) $(CFLAGS) -o dir-test $(objects) dir-test.o $(LDFLAGS) $(LIBS)
+ $(Q)$(CC) $(CFLAGS) -o dir-test $(objects) $(libs) dir-test.o $(LDFLAGS) $(LIBS)
quick-test: $(objects) $(libs) quick-test.o
@echo " [LD] $@"
- $(Q)$(CC) $(CFLAGS) -o quick-test $(objects) quick-test.o $(LDFLAGS) $(LIBS)
+ $(Q)$(CC) $(CFLAGS) -o quick-test $(objects) $(libs) quick-test.o $(LDFLAGS) $(LIBS)
ioctl-test: $(objects) $(libs) ioctl-test.o
@echo " [LD] $@"
- $(Q)$(CC) $(CFLAGS) -o ioctl-test $(objects) ioctl-test.o $(LDFLAGS) $(LIBS)
+ $(Q)$(CC) $(CFLAGS) -o ioctl-test $(objects) $(libs) ioctl-test.o $(LDFLAGS) $(LIBS)
send-test: $(objects) $(libs) send-test.o
@echo " [LD] $@"
- $(Q)$(CC) $(CFLAGS) -o send-test $(objects) send-test.o $(LDFLAGS) $(LIBS) -lpthread
+ $(Q)$(CC) $(CFLAGS) -o send-test $(objects) $(libs) send-test.o $(LDFLAGS) $(LIBS) -lpthread
library-test: $(libs_shared) library-test.o
@echo " [LD] $@"
@@ -286,7 +295,7 @@ install: $(libs) $(progs) $(INSTALLDIRS)
$(INSTALL) $(progs) $(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) -f $(DESTDIR)$(bindir)/btrfs $(DESTDIR)$(bindir)/btrfsck
+ $(LN_S) -f $(DESTDIR)$(bindir)/btrfs $(DESTDIR)$(bindir)/btrfsck
$(INSTALL) -m755 -d $(DESTDIR)$(libdir)
$(INSTALL) $(libs) $(DESTDIR)$(libdir)
cp -a $(lib_links) $(DESTDIR)$(libdir)
diff --git a/Makefile.in b/Makefile.in
new file mode 100644
index 0000000..4cae30c
--- /dev/null
+++ b/Makefile.in
@@ -0,0 +1,314 @@
+# Export all variables to sub-makes by default
+export
+
+CC = gcc
+LN = ln
+AR = ar
+AM_CFLAGS = -Wall -D_FILE_OFFSET_BITS=64 -DBTRFS_FLAT_INCLUDES -fno-strict-aliasing -fPIC
+CFLAGS = -g -O1 -fno-strict-aliasing -rdynamic
+objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \
+ root-tree.o dir-item.o file-item.o inode-item.o inode-map.o \
+ extent-cache.o extent_io.o volumes.o utils.o repair.o \
+ qgroup.o raid6.o free-space-cache.o list_sort.o props.o \
+ ulist.o qgroup-verify.o backref.o
+cmds_objects = cmds-subvolume.o cmds-filesystem.o cmds-device.o cmds-scrub.o \
+ cmds-inspect.o cmds-balance.o cmds-send.o cmds-receive.o \
+ cmds-quota.o cmds-qgroup.o cmds-replace.o cmds-check.o \
+ cmds-restore.o cmds-rescue.o chunk-recover.o super-recover.o \
+ cmds-property.o
+libbtrfs_objects = send-stream.o send-utils.o rbtree.o btrfs-list.o crc32c.o \
+ uuid-tree.o utils-lib.o rbtree-utils.o
+libbtrfs_headers = send-stream.h send-utils.h send.h rbtree.h btrfs-list.h \
+ crc32c.h list.h kerncompat.h radix-tree.h extent-cache.h \
+ extent_io.h ioctl.h ctree.h btrfsck.h version.h
+TESTS = fsck-tests.sh convert-tests.sh
+
+INSTALL = install
+prefix ?= /usr/local
+bindir = $(prefix)/bin
+lib_LIBS = -luuid -lblkid -lm -lz -llzo2 -L.
+libdir ?= $(prefix)/lib
+incdir = $(prefix)/include/btrfs
+LIBS = $(lib_LIBS) $(libs_static)
+
+ifeq ("$(origin V)", "command line")
+ BUILD_VERBOSE = $(V)
+endif
+ifndef BUILD_VERBOSE
+ BUILD_VERBOSE = 0
+endif
+
+ifeq ($(BUILD_VERBOSE),1)
+ Q =
+else
+ Q = @
+endif
+
+MAKEOPTS = --no-print-directory Q=$(Q)
+
+progs = mkfs.btrfs btrfs-debug-tree btrfsck \
+ btrfs btrfs-map-logical btrfs-image btrfs-zero-log btrfs-convert \
+ btrfs-find-root btrfstune btrfs-show-super
+
+progs_extra = btrfs-corrupt-block btrfs-fragments btrfs-calc-size \
+ btrfs-select-super
+
+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
+btrfs_convert_libs = -lext2fs -lcom_err
+btrfs_image_libs = -lpthread
+btrfs_fragments_libs = -lgd -lpng -ljpeg -lfreetype
+
+SUBDIRS =
+BUILDDIRS = $(patsubst %,build-%,$(SUBDIRS))
+INSTALLDIRS = $(patsubst %,install-%,$(SUBDIRS))
+CLEANDIRS = $(patsubst %,clean-%,$(SUBDIRS))
+
+ifeq ($(DISABLE_BACKTRACE),1)
+AM_CFLAGS += -DBTRFS_DISABLE_BACKTRACE
+endif
+
+ifneq ($(DISABLE_DOCUMENTATION),1)
+BUILDDIRS += build-Documentation
+INSTALLDIRS += install-Documentation
+endif
+
+.PHONY: $(SUBDIRS)
+.PHONY: $(BUILDDIRS)
+.PHONY: $(INSTALLDIRS)
+.PHONY: $(TESTDIRS)
+.PHONY: $(CLEANDIRS)
+.PHONY: all install clean
+
+# Create all the static targets
+static_objects = $(patsubst %.o, %.static.o, $(objects))
+static_cmds_objects = $(patsubst %.o, %.static.o, $(cmds_objects))
+static_libbtrfs_objects = $(patsubst %.o, %.static.o, $(libbtrfs_objects))
+
+# Define static compilation flags
+STATIC_CFLAGS = $(CFLAGS) -ffunction-sections -fdata-sections
+STATIC_LDFLAGS = -static -Wl,--gc-sections
+STATIC_LIBS = $(lib_LIBS) -lpthread
+
+libs_shared = libbtrfs.so.0.1
+libs_static = libbtrfs.a
+libs = $(libs_shared) $(libs_static)
+lib_links = libbtrfs.so.0 libbtrfs.so
+headers = $(libbtrfs_headers)
+
+# make C=1 to enable sparse
+check_defs := .cc-defines.h
+ifdef C
+ #
+ # We're trying to use sparse against glibc headers which go wild
+ # trying to use internal compiler macros to test features. We
+ # copy gcc's and give them to sparse. But not __SIZE_TYPE__
+ # 'cause sparse defines that one.
+ #
+ dummy := $(shell $(CC) -dM -E -x c - < /dev/null | \
+ grep -v __SIZE_TYPE__ > $(check_defs))
+ check = sparse -include $(check_defs) -D__CHECKER__ \
+ -D__CHECK_ENDIAN__ -Wbitwise -Wuninitialized -Wshadow -Wundef
+ check_echo = echo
+ # don't use FORTIFY with sparse because glibc with FORTIFY can
+ # generate so many sparse errors that sparse stops parsing,
+ # which masks real errors that we want to see.
+else
+ check = true
+ check_echo = true
+ AM_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
+endif
+
+%.o.d: %.c
+ $(Q)$(CC) -MM -MG -MF $@ -MT $(@:.o.d=.o) -MT $(@:.o.d=.static.o) -MT $@ $(AM_CFLAGS) $(CFLAGS) $<
+
+.c.o:
+ @$(check_echo) " [SP] $<"
+ $(Q)$(check) $(AM_CFLAGS) $(CFLAGS) $<
+ @echo " [CC] $@"
+ $(Q)$(CC) $(AM_CFLAGS) $(CFLAGS) -c $<
+
+%.static.o: %.c
+ @echo " [CC] $@"
+ $(Q)$(CC) $(AM_CFLAGS) $(STATIC_CFLAGS) -c $< -o $@
+
+all: $(progs) $(BUILDDIRS)
+$(SUBDIRS): $(BUILDDIRS)
+$(BUILDDIRS):
+ @echo "Making all in $(patsubst build-%,%,$@)"
+ $(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst build-%,%,$@)
+
+test:
+ $(Q)for t in $(TESTS); do \
+ echo " [TEST] $$t"; \
+ bash tests/$$t || exit 1; \
+ done
+
+#
+# NOTE: For static compiles, you need to have all the required libs
+# static equivalent available
+#
+static: $(progs_static)
+
+version.h:
+ @echo " [SH] $@"
+ $(Q)bash version.sh
+
+$(libs_shared): $(libbtrfs_objects) $(lib_links) send.h
+ @echo " [LD] $@"
+ $(Q)$(CC) $(CFLAGS) $(libbtrfs_objects) $(LDFLAGS) $(lib_LIBS) \
+ -shared -Wl,-soname,libbtrfs.so.0 -o libbtrfs.so.0.1
+
+$(libs_static): $(libbtrfs_objects)
+ @echo " [AR] $@"
+ $(Q)$(AR) cru libbtrfs.a $(libbtrfs_objects)
+
+$(lib_links):
+ @echo " [LN] $@"
+ $(Q)$(LN) -sf libbtrfs.so.0.1 libbtrfs.so.0
+ $(Q)$(LN) -sf libbtrfs.so.0.1 libbtrfs.so
+
+# keep intermediate files from the below implicit rules around
+.PRECIOUS: $(addsuffix .o,$(progs))
+
+# Make any btrfs-foo out of btrfs-foo.o, with appropriate libs.
+# The $($(subst...)) bits below takes the btrfs_*_libs definitions above and
+# turns them into a list of libraries to link against if they exist
+#
+# For static variants, use an extra $(subst) to get rid of the ".static"
+# from the target name before translating to list of libs
+
+btrfs-%.static: $(static_objects) btrfs-%.static.o $(static_libbtrfs_objects)
+ @echo " [LD] $@"
+ $(Q)$(CC) $(STATIC_CFLAGS) -o $@ $@.o $(static_objects) \
+ $(static_libbtrfs_objects) $(STATIC_LDFLAGS) \
+ $($(subst -,_,$(subst .static,,$@)-libs)) $(STATIC_LIBS)
+
+btrfs-%: $(objects) $(libs) btrfs-%.o
+ @echo " [LD] $@"
+ $(Q)$(CC) $(CFLAGS) -o $@ $(objects) $@.o $(LDFLAGS) $(LIBS) $($(subst -,_,$@-libs))
+
+btrfs: $(objects) btrfs.o help.o $(cmds_objects) $(libs)
+ @echo " [LD] $@"
+ $(Q)$(CC) $(CFLAGS) -o btrfs btrfs.o help.o $(cmds_objects) \
+ $(objects) $(LDFLAGS) $(LIBS) -lpthread
+
+btrfs.static: $(static_objects) btrfs.static.o help.static.o $(static_cmds_objects) $(static_libbtrfs_objects)
+ @echo " [LD] $@"
+ $(Q)$(CC) $(STATIC_CFLAGS) -o btrfs.static btrfs.static.o help.static.o $(static_cmds_objects) \
+ $(static_objects) $(static_libbtrfs_objects) $(STATIC_LDFLAGS) $(STATIC_LIBS)
+
+# For backward compatibility, 'btrfs' changes behaviour to fsck if it's named 'btrfsck'
+btrfsck: btrfs
+ @echo " [LN] $@"
+ $(Q)$(LN) -f btrfs btrfsck
+
+btrfsck.static: btrfs.static
+ @echo " [LN] $@"
+ $(Q)$(LN) -f $^ $@
+
+mkfs.btrfs: $(objects) $(libs) mkfs.o
+ @echo " [LD] $@"
+ $(Q)$(CC) $(CFLAGS) -o mkfs.btrfs $(objects) mkfs.o $(LDFLAGS) $(LIBS)
+
+mkfs.btrfs.static: $(static_objects) mkfs.static.o $(static_libbtrfs_objects)
+ @echo " [LD] $@"
+ $(Q)$(CC) $(STATIC_CFLAGS) -o mkfs.btrfs.static mkfs.static.o $(static_objects) \
+ $(static_libbtrfs_objects) $(STATIC_LDFLAGS) $(STATIC_LIBS)
+
+btrfstune: $(objects) $(libs) btrfstune.o
+ @echo " [LD] $@"
+ $(Q)$(CC) $(CFLAGS) -o btrfstune $(objects) btrfstune.o $(LDFLAGS) $(LIBS)
+
+btrfstune.static: $(static_objects) btrfstune.static.o $(static_libbtrfs_objects)
+ @echo " [LD] $@"
+ $(Q)$(CC) $(STATIC_CFLAGS) -o $@ btrfstune.static.o $(static_objects) \
+ $(static_libbtrfs_objects) $(STATIC_LDFLAGS) $(STATIC_LIBS)
+
+dir-test: $(objects) $(libs) dir-test.o
+ @echo " [LD] $@"
+ $(Q)$(CC) $(CFLAGS) -o dir-test $(objects) dir-test.o $(LDFLAGS) $(LIBS)
+
+quick-test: $(objects) $(libs) quick-test.o
+ @echo " [LD] $@"
+ $(Q)$(CC) $(CFLAGS) -o quick-test $(objects) quick-test.o $(LDFLAGS) $(LIBS)
+
+ioctl-test: $(objects) $(libs) ioctl-test.o
+ @echo " [LD] $@"
+ $(Q)$(CC) $(CFLAGS) -o ioctl-test $(objects) ioctl-test.o $(LDFLAGS) $(LIBS)
+
+send-test: $(objects) $(libs) send-test.o
+ @echo " [LD] $@"
+ $(Q)$(CC) $(CFLAGS) -o send-test $(objects) send-test.o $(LDFLAGS) $(LIBS) -lpthread
+
+library-test: $(libs_shared) library-test.o
+ @echo " [LD] $@"
+ $(Q)$(CC) $(CFLAGS) -o library-test library-test.o $(LDFLAGS) -lbtrfs
+
+library-test.static: $(libs_static) library-test.o
+ @echo " [LD] $@"
+ $(Q)$(CC) $(CFLAGS) -o library-test-static library-test.o $(LDFLAGS) $(libs_static)
+
+test-build:
+ $(MAKE) clean-all
+ $(MAKE) library-test
+ -$(MAKE) library-test.static
+ $(MAKE) -j 8 all
+ -$(MAKE) -j 8 static
+ $(MAKE) -j 8 $(progs_extra)
+
+manpages:
+ $(Q)$(MAKE) $(MAKEOPTS) -C Documentation
+
+clean-all: clean-doc clean
+
+clean: $(CLEANDIRS)
+ @echo "Cleaning"
+ $(Q)rm -f $(progs) cscope.out *.o *.o.d \
+ dir-test ioctl-test quick-test send-test library-test library-test-static \
+ btrfs.static mkfs.btrfs.static \
+ version.h $(check_defs) \
+ $(libs) $(lib_links) \
+ $(progs_static) $(progs_extra)
+
+clean-doc:
+ @echo "Cleaning Documentation"
+ $(Q)$(MAKE) $(MAKEOPTS) -C Documentation clean
+
+$(CLEANDIRS):
+ @echo "Cleaning $(patsubst clean-%,%,$@)"
+ $(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst clean-%,%,$@) clean
+
+install: $(libs) $(progs) $(INSTALLDIRS)
+ $(INSTALL) -m755 -d $(DESTDIR)$(bindir)
+ $(INSTALL) $(progs) $(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) -f $(DESTDIR)$(bindir)/btrfs $(DESTDIR)$(bindir)/btrfsck
+ $(INSTALL) -m755 -d $(DESTDIR)$(libdir)
+ $(INSTALL) $(libs) $(DESTDIR)$(libdir)
+ cp -a $(lib_links) $(DESTDIR)$(libdir)
+ $(INSTALL) -m755 -d $(DESTDIR)$(incdir)
+ $(INSTALL) -m644 $(headers) $(DESTDIR)$(incdir)
+
+install-static: $(progs_static) $(INSTALLDIRS)
+ for p in $(progs_static) ; do \
+ $(INSTALL) -D -m755 $$p $(DESTDIR)$(bindir)/`basename $$p .static` ; \
+ done
+
+$(INSTALLDIRS):
+ @echo "Making install in $(patsubst install-%,%,$@)"
+ $(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst install-%,%,$@) install
+
+uninstall:
+ $(Q)$(MAKE) $(MAKEOPTS) -C Documentation uninstall
+ cd $(DESTDIR)$(incdir); rm -f $(headers)
+ rmdir -p --ignore-fail-on-non-empty $(DESTDIR)$(incdir)
+ cd $(DESTDIR)$(libdir); rm -f $(lib_links) $(libs)
+ cd $(DESTDIR)$(bindir); rm -f btrfsck fsck.btrfs $(progs)
+
+ifneq ($(MAKECMDGOALS),clean)
+-include $(objects:.o=.o.d) $(cmd-objects:.o=.o.d) $(subst .btrfs,, $(filter-out btrfsck.o.d, $(progs:=.o.d)))
+endif
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..0198f1f
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,58 @@
+#!/bin/sh
+
+#
+# Helps generate autoconf stuff, when code is checked out from SCM.
+#
+# Copyright (C) 2006-2014 - Karel Zak <kzak@redhat.com>
+#
+
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+THEDIR=`pwd`
+cd $srcdir
+DIE=0
+
+test -f btrfs.c || {
+ echo
+ echo "You must run this script in the top-level btrfs-progs directory"
+ echo
+ DIE=1
+}
+
+(autoconf --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "You must have autoconf installed to generate btrfs-progs build system."
+ echo
+ DIE=1
+}
+(autoheader --version) < /dev/null > /dev/null 2>&1 || {
+ echo
+ echo "You must have autoheader installed to generate btrfs-progs build system."
+ echo "The autoheader command is part of the GNU autoconf package."
+ echo
+ DIE=1
+}
+
+if test "$DIE" -eq 1; then
+ exit 1
+fi
+
+echo
+echo "Generate build-system by:"
+echo " aclocal: $(aclocal --version | head -1)"
+echo " autoconf: $(autoconf --version | head -1)"
+echo " autoheader: $(autoheader --version | head -1)"
+
+chmod +x version.sh
+rm -rf autom4te.cache
+
+aclocal $AL_OPTS
+autoconf $AC_OPTS
+autoheader $AH_OPTS
+
+cd $THEDIR
+
+echo
+echo "Now type '$srcdir/configure' and 'make' to compile."
+echo
diff --git a/configure.ac b/configure.ac
new file mode 100644
index 0000000..7a6c264
--- /dev/null
+++ b/configure.ac
@@ -0,0 +1,102 @@
+AC_INIT([btrfs-progs],
+ m4_esyscmd([./version.sh --configure]),
+ [linux-btrfs@vger.kernel.org],,
+ [http://btrfs.wiki.kernel.org])
+
+
+AC_PREREQ([2.60])
+
+AC_CONFIG_AUX_DIR([config])
+dnl AC_USE_SYSTEM_EXTENSIONS must be called before any macros that run
+dnl the compiler (like AC_PROG_LIBTOOL) to avoid autoconf errors.
+AC_USE_SYSTEM_EXTENSIONS
+
+AC_CONFIG_SRCDIR([btrfs.c])
+AC_PREFIX_DEFAULT([/usr])
+
+AC_PROG_CC
+AC_CANONICAL_HOST
+AC_C_CONST
+AC_C_VOLATILE
+AC_C_BIGENDIAN
+
+AC_SYS_LARGEFILE
+
+AC_PROG_INSTALL
+
+AC_CHECK_FUNCS([openat], [],
+ [AC_MSG_ERROR([cannot find openat() function])])
+
+m4_ifndef([PKG_PROG_PKG_CONFIG],
+ [m4_fatal([Could not locate the pkg-config autoconf
+ macros. These are usually located in /usr/share/aclocal/pkg.m4.
+ If your macros are in a different location, try setting the
+ environment variable AL_OPTS="-I/other/macro/dir" before running
+ ./autogen.sh or autoreconf again.])])
+PKG_PROG_PKG_CONFIG
+
+
+dnl
+dnl Calls pkg-config --static
+dnl
+AC_DEFUN([PKG_STATIC], [
+ if AC_RUN_LOG([pkg-config --exists --print-errors "$2"]); then
+ $1=`pkg-config --libs --static "$2"`
+ AC_SUBST([$1])
+ else
+ AC_MSG_ERROR([pkg-config description of $2, needed for static build, is not available])
+ fi
+])
+
+dnl Define <NAME>_LIBS= and <NAME>_CFLAGS= by pkg-config
+dnl
+dnl The default PKG_CHECK_MODULES() action-if-not-found is end the
+dnl execution with error. The static libs are optional.
+
+PKG_CHECK_MODULES(BLKID, [blkid])
+PKG_STATIC(BLKID_LIBS_STATIC, [blkid])
+
+PKG_CHECK_MODULES(UUID, [uuid])
+PKG_STATIC(UUID_LIBS_STATIC, [uuid])
+
+PKG_CHECK_MODULES(ZLIB, [zlib])
+PKG_STATIC(ZLIB_LIBS_STATIC, [zlib])
+
+dnl lzo library does not provide pkg-config, let use classic way
+AC_CHECK_LIB([lzo2], [lzo_version], [
+ LZO2_LIBS="-llzo2"
+ LZO2_CFLAGS=""
+ LZO2_LIBS_STATIC="-llzo2"],[
+ AC_MSG_ERROR([cannot find lzo2 library])
+])
+AC_SUBST([LZO2_LIBS])
+AC_SUBST([LZO2_LIBS_STATIC])
+AC_SUBST([LZO2_CFLAGS])
+
+
+
+AC_CONFIG_HEADERS([config.h])
+
+AC_CONFIG_FILES([
+Makefile
+])
+
+AC_OUTPUT
+
+AC_MSG_RESULT([
+ ${PACKAGE_NAME} ${PACKAGE_VERSION}
+
+ prefix: ${prefix}
+ exec prefix: ${exec_prefix}
+
+ bindir: ${bindir}
+ libdir: ${libdir}
+ includedir: ${includedir}
+
+ compiler: ${CC}
+ cflags: ${CFLAGS}
+ ldflags: ${LDFLAGS}
+
+ Type 'make' to compile.
+])
+
diff --git a/version.sh b/version.sh
old mode 100644
new mode 100755
index 773482d..456853c
--- a/version.sh
+++ b/version.sh
@@ -8,6 +8,7 @@
v="v3.17.3"
+opt=$1
lib_major=0
lib_minor=1
lib_patchlevel=1
@@ -28,6 +29,12 @@ if [ $? == 0 -a -d .git ]; then
fi
fi
+if [ "$opt" = "--configure" ]; then
+ # Omit the trailing newline, so that m4_esyscmd can use the result directly.
+ echo "$v" | tr -d '\n'
+ exit 0
+fi
+
echo "/* NOTE: this file is autogenerated by version.sh, do not edit */" > .build-version.h
echo "#ifndef __BUILD_VERSION" >> .build-version.h
echo >> .build-version.h
--
1.9.3
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 02/10] btrfs-progs: use config.h
2014-12-12 12:35 btrfs-prog: improve build-system by autoconf Karel Zak
2014-12-12 12:35 ` [PATCH 01/10] btrfs-progs: add ./configure script Karel Zak
@ 2014-12-12 12:35 ` Karel Zak
2014-12-12 12:35 ` [PATCH 03/10] btrfs-progs: use standard PACKAGE_* macros Karel Zak
` (8 subsequent siblings)
10 siblings, 0 replies; 18+ messages in thread
From: Karel Zak @ 2014-12-12 12:35 UTC (permalink / raw)
To: linux-btrfs; +Cc: Karel Zak
- the header file is generated by ./configure, the standard autotools
way is to use -include config.h on compiler command line rather than
include the file directly from code
- remove _GNU_SOURCE from code, the macros is already defined in config.h
by AC_USE_SYSTEM_EXTENSIONS autoconf macro
Signed-off-by: Karel Zak <kzak@redhat.com>
---
Makefile.in | 4 +++-
btrfs-calc-size.c | 1 -
btrfs-convert.c | 1 -
btrfs-corrupt-block.c | 2 +-
btrfs-find-root.c | 2 +-
btrfs-fragments.c | 1 -
btrfs-image.c | 2 +-
btrfs-list.c | 1 -
btrfs-map-logical.c | 2 +-
btrfs-select-super.c | 2 +-
btrfs-show-super.c | 2 +-
btrfs-zero-log.c | 2 +-
btrfs.c | 1 -
btrfstune.c | 2 +-
chunk-recover.c | 1 -
cmds-check.c | 2 +-
cmds-receive.c | 1 -
cmds-restore.c | 1 -
cmds-send.c | 2 --
disk-io.c | 2 +-
mkfs.c | 1 -
send-test.c | 2 --
super-recover.c | 1 -
utils-lib.c | 2 --
utils.c | 2 +-
25 files changed, 14 insertions(+), 28 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index 4cae30c..0dd83ea 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -4,7 +4,9 @@ export
CC = gcc
LN = ln
AR = ar
-AM_CFLAGS = -Wall -D_FILE_OFFSET_BITS=64 -DBTRFS_FLAT_INCLUDES -fno-strict-aliasing -fPIC
+AM_CFLAGS = -include config.h -Wall \
+ -D_FILE_OFFSET_BITS=64 -DBTRFS_FLAT_INCLUDES \
+ -fno-strict-aliasing -fPIC
CFLAGS = -g -O1 -fno-strict-aliasing -rdynamic
objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \
root-tree.o dir-item.o file-item.o inode-item.o inode-map.o \
diff --git a/btrfs-calc-size.c b/btrfs-calc-size.c
index 501111c..3ec8230 100644
--- a/btrfs-calc-size.c
+++ b/btrfs-calc-size.c
@@ -17,7 +17,6 @@
*/
#define _XOPEN_SOURCE 500
-#define _GNU_SOURCE 1
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/btrfs-convert.c b/btrfs-convert.c
index 02c5e94..c88acc1 100644
--- a/btrfs-convert.c
+++ b/btrfs-convert.c
@@ -17,7 +17,6 @@
*/
#define _XOPEN_SOURCE 600
-#define _GNU_SOURCE 1
#include "kerncompat.h"
diff --git a/btrfs-corrupt-block.c b/btrfs-corrupt-block.c
index af9ae4d..e993680 100644
--- a/btrfs-corrupt-block.c
+++ b/btrfs-corrupt-block.c
@@ -17,7 +17,7 @@
*/
#define _XOPEN_SOURCE 500
-#define _GNU_SOURCE 1
+
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
diff --git a/btrfs-find-root.c b/btrfs-find-root.c
index 6fa61cc..b24dddf 100644
--- a/btrfs-find-root.c
+++ b/btrfs-find-root.c
@@ -17,7 +17,7 @@
*/
#define _XOPEN_SOURCE 500
-#define _GNU_SOURCE 1
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
diff --git a/btrfs-fragments.c b/btrfs-fragments.c
index d03c2c3..ca45686 100644
--- a/btrfs-fragments.c
+++ b/btrfs-fragments.c
@@ -14,7 +14,6 @@
* Boston, MA 021110-1307, USA.
*/
-#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/btrfs-image.c b/btrfs-image.c
index cb17f16..1257966 100644
--- a/btrfs-image.c
+++ b/btrfs-image.c
@@ -17,7 +17,7 @@
*/
#define _XOPEN_SOURCE 500
-#define _GNU_SOURCE 1
+
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
diff --git a/btrfs-list.c b/btrfs-list.c
index 50edcf4..3e29cf8 100644
--- a/btrfs-list.c
+++ b/btrfs-list.c
@@ -16,7 +16,6 @@
* Boston, MA 021110-1307, USA.
*/
-#define _GNU_SOURCE
#include <sys/ioctl.h>
#include <sys/mount.h>
#include "ioctl.h"
diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c
index 47d1104..c34484f 100644
--- a/btrfs-map-logical.c
+++ b/btrfs-map-logical.c
@@ -17,7 +17,7 @@
*/
#define _XOPEN_SOURCE 500
-#define _GNU_SOURCE 1
+
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
diff --git a/btrfs-select-super.c b/btrfs-select-super.c
index 6231d42..54ac436 100644
--- a/btrfs-select-super.c
+++ b/btrfs-select-super.c
@@ -17,7 +17,7 @@
*/
#define _XOPEN_SOURCE 500
-#define _GNU_SOURCE 1
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
diff --git a/btrfs-show-super.c b/btrfs-show-super.c
index 2b48f44..9702eb0 100644
--- a/btrfs-show-super.c
+++ b/btrfs-show-super.c
@@ -17,7 +17,7 @@
*/
#define _XOPEN_SOURCE 500
-#define _GNU_SOURCE 1
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
diff --git a/btrfs-zero-log.c b/btrfs-zero-log.c
index 4154175..411fae3 100644
--- a/btrfs-zero-log.c
+++ b/btrfs-zero-log.c
@@ -17,7 +17,7 @@
*/
#define _XOPEN_SOURCE 500
-#define _GNU_SOURCE 1
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
diff --git a/btrfs.c b/btrfs.c
index e83349c..2451885 100644
--- a/btrfs.c
+++ b/btrfs.c
@@ -14,7 +14,6 @@
* Boston, MA 021110-1307, USA.
*/
-#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/btrfstune.c b/btrfstune.c
index 050418a..899a721 100644
--- a/btrfstune.c
+++ b/btrfstune.c
@@ -17,7 +17,7 @@
*/
#define _XOPEN_SOURCE 500
-#define _GNU_SOURCE 1
+
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
diff --git a/chunk-recover.c b/chunk-recover.c
index 6f43066..688a7d7 100644
--- a/chunk-recover.c
+++ b/chunk-recover.c
@@ -16,7 +16,6 @@
* Boston, MA 021110-1307, USA.
*/
#define _XOPEN_SOURCE 500
-#define _GNU_SOURCE
#include <stdio.h>
#include <stdio_ext.h>
diff --git a/cmds-check.c b/cmds-check.c
index 9fc1410..0894cf0 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -17,7 +17,7 @@
*/
#define _XOPEN_SOURCE 500
-#define _GNU_SOURCE 1
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
diff --git a/cmds-receive.c b/cmds-receive.c
index 358df1f..f234b15 100644
--- a/cmds-receive.c
+++ b/cmds-receive.c
@@ -16,7 +16,6 @@
* Boston, MA 021110-1307, USA.
*/
-#define _GNU_SOURCE
#define _POSIX_C_SOURCE 200809
#define _XOPEN_SOURCE 700
#define _BSD_SOURCE
diff --git a/cmds-restore.c b/cmds-restore.c
index 2f9b72d..a5c99e8 100644
--- a/cmds-restore.c
+++ b/cmds-restore.c
@@ -17,7 +17,6 @@
*/
#define _XOPEN_SOURCE 500
-#define _GNU_SOURCE 1
#include "kerncompat.h"
diff --git a/cmds-send.c b/cmds-send.c
index b17b5e2..f6fae44 100644
--- a/cmds-send.c
+++ b/cmds-send.c
@@ -16,8 +16,6 @@
* Boston, MA 021110-1307, USA.
*/
-#define _GNU_SOURCE
-
#include "kerncompat.h"
#include <unistd.h>
diff --git a/disk-io.c b/disk-io.c
index 03edf8e..9f15c0c 100644
--- a/disk-io.c
+++ b/disk-io.c
@@ -18,7 +18,7 @@
#define _XOPEN_SOURCE 600
#define __USE_XOPEN2K
-#define _GNU_SOURCE 1
+
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
diff --git a/mkfs.c b/mkfs.c
index e10e62d..d5d03fc 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -17,7 +17,6 @@
*/
#define _XOPEN_SOURCE 500
-#define _GNU_SOURCE
#include "kerncompat.h"
diff --git a/send-test.c b/send-test.c
index 0e804a2..af8229e 100644
--- a/send-test.c
+++ b/send-test.c
@@ -21,8 +21,6 @@
* Boston, MA 021110-1307, USA.
*/
-#define _GNU_SOURCE
-
#include <unistd.h>
#include <stdint.h>
#include <dirent.h>
diff --git a/super-recover.c b/super-recover.c
index adb2c44..d0125f4 100644
--- a/super-recover.c
+++ b/super-recover.c
@@ -17,7 +17,6 @@
*/
#define _XOPEN_SOURCE 500
-#define _GNU_SOURCE 1
#include <stdio.h>
#include <stdlib.h>
diff --git a/utils-lib.c b/utils-lib.c
index 9d53c6e..79ef35e 100644
--- a/utils-lib.c
+++ b/utils-lib.c
@@ -1,5 +1,3 @@
-#define _GNU_SOURCE
-
#include "kerncompat.h"
#include <unistd.h>
#include <stdlib.h>
diff --git a/utils.c b/utils.c
index 2a92416..1f95a9b 100644
--- a/utils.c
+++ b/utils.c
@@ -20,7 +20,7 @@
#define _XOPEN_SOURCE 700
#define __USE_XOPEN2K8
#define __XOPEN2K8 /* due to an error in dirent.h, to get dirfd() */
-#define _GNU_SOURCE /* O_NOATIME */
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
--
1.9.3
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 03/10] btrfs-progs: use standard PACKAGE_* macros
2014-12-12 12:35 btrfs-prog: improve build-system by autoconf Karel Zak
2014-12-12 12:35 ` [PATCH 01/10] btrfs-progs: add ./configure script Karel Zak
2014-12-12 12:35 ` [PATCH 02/10] btrfs-progs: use config.h Karel Zak
@ 2014-12-12 12:35 ` Karel Zak
2014-12-12 12:35 ` [PATCH 04/10] btrfs-progs: use ./configure to generate version.h Karel Zak
` (7 subsequent siblings)
10 siblings, 0 replies; 18+ messages in thread
From: Karel Zak @ 2014-12-12 12:35 UTC (permalink / raw)
To: linux-btrfs; +Cc: Karel Zak
- use standard PACKAGE_{NAME,VERSION,STRING,URL,...} autoconf macros
rather than homemade BTRFS_BUILD_VERSION
- don't #include version.h, now the file is necessary for library API only
Note that "btrfs version" returns "btrfs-progs <version>" instead of
the original confusing "btrfs <version>".
Signed-off-by: Karel Zak <kzak@redhat.com>
---
btrfs-calc-size.c | 1 -
btrfs-corrupt-block.c | 1 -
btrfs-debug-tree.c | 5 ++---
btrfs-find-root.c | 1 -
btrfs-image.c | 1 -
btrfs-map-logical.c | 1 -
btrfs-select-super.c | 3 +--
btrfs-show-super.c | 3 +--
btrfs-zero-log.c | 3 +--
btrfs.c | 3 +--
btrfstune.c | 1 -
chunk-recover.c | 1 -
cmds-check.c | 3 +--
cmds-filesystem.c | 5 ++---
cmds-restore.c | 1 -
library-test.c | 1 -
mkfs.c | 9 ++++-----
17 files changed, 13 insertions(+), 30 deletions(-)
diff --git a/btrfs-calc-size.c b/btrfs-calc-size.c
index 3ec8230..2be0d64 100644
--- a/btrfs-calc-size.c
+++ b/btrfs-calc-size.c
@@ -32,7 +32,6 @@
#include "print-tree.h"
#include "transaction.h"
#include "list.h"
-#include "version.h"
#include "volumes.h"
#include "utils.h"
diff --git a/btrfs-corrupt-block.c b/btrfs-corrupt-block.c
index e993680..ba7358d 100644
--- a/btrfs-corrupt-block.c
+++ b/btrfs-corrupt-block.c
@@ -30,7 +30,6 @@
#include "print-tree.h"
#include "transaction.h"
#include "list.h"
-#include "version.h"
#include "utils.h"
#define FIELD_BUF_LEN 80
diff --git a/btrfs-debug-tree.c b/btrfs-debug-tree.c
index e46500d..4468297 100644
--- a/btrfs-debug-tree.c
+++ b/btrfs-debug-tree.c
@@ -26,7 +26,6 @@
#include "disk-io.h"
#include "print-tree.h"
#include "transaction.h"
-#include "version.h"
#include "utils.h"
static int print_usage(void)
@@ -43,7 +42,7 @@ static int print_usage(void)
" only\n");
fprintf(stderr,
"\t-t tree_id : print only the tree with the given id\n");
- fprintf(stderr, "%s\n", BTRFS_BUILD_VERSION);
+ fprintf(stderr, "%s\n", PACKAGE_STRING);
exit(1);
}
@@ -406,7 +405,7 @@ no_node:
uuidbuf[BTRFS_UUID_UNPARSED_SIZE - 1] = '\0';
uuid_unparse(info->super_copy->fsid, uuidbuf);
printf("uuid %s\n", uuidbuf);
- printf("%s\n", BTRFS_BUILD_VERSION);
+ printf("%s\n", PACKAGE_STRING);
close_root:
return close_ctree(root);
}
diff --git a/btrfs-find-root.c b/btrfs-find-root.c
index b24dddf..571c86a 100644
--- a/btrfs-find-root.c
+++ b/btrfs-find-root.c
@@ -30,7 +30,6 @@
#include "print-tree.h"
#include "transaction.h"
#include "list.h"
-#include "version.h"
#include "volumes.h"
#include "utils.h"
#include "crc32c.h"
diff --git a/btrfs-image.c b/btrfs-image.c
index 1257966..74681ba 100644
--- a/btrfs-image.c
+++ b/btrfs-image.c
@@ -33,7 +33,6 @@
#include "disk-io.h"
#include "transaction.h"
#include "utils.h"
-#include "version.h"
#include "volumes.h"
#include "extent_io.h"
diff --git a/btrfs-map-logical.c b/btrfs-map-logical.c
index c34484f..fc4a29b 100644
--- a/btrfs-map-logical.c
+++ b/btrfs-map-logical.c
@@ -30,7 +30,6 @@
#include "print-tree.h"
#include "transaction.h"
#include "list.h"
-#include "version.h"
#include "utils.h"
/* we write the mirror info to stdout unless they are dumping the data
diff --git a/btrfs-select-super.c b/btrfs-select-super.c
index 54ac436..492d38d 100644
--- a/btrfs-select-super.c
+++ b/btrfs-select-super.c
@@ -29,13 +29,12 @@
#include "print-tree.h"
#include "transaction.h"
#include "list.h"
-#include "version.h"
#include "utils.h"
static void print_usage(void)
{
fprintf(stderr, "usage: btrfs-select-super -s number dev\n");
- fprintf(stderr, "%s\n", BTRFS_BUILD_VERSION);
+ fprintf(stderr, "%s\n", PACKAGE_STRING);
exit(1);
}
diff --git a/btrfs-show-super.c b/btrfs-show-super.c
index 9702eb0..15b9e36 100644
--- a/btrfs-show-super.c
+++ b/btrfs-show-super.c
@@ -33,7 +33,6 @@
#include "print-tree.h"
#include "transaction.h"
#include "list.h"
-#include "version.h"
#include "utils.h"
#include "crc32c.h"
@@ -51,7 +50,7 @@ static void print_usage(void)
fprintf(stderr, "\t-a : print information of all superblocks\n");
fprintf(stderr, "\t-i <super_mirror> : specify which mirror to print out\n");
fprintf(stderr, "\t-F : attempt to dump superblocks with bad magic\n");
- fprintf(stderr, "%s\n", BTRFS_BUILD_VERSION);
+ fprintf(stderr, "%s\n", PACKAGE_STRING);
}
int main(int argc, char **argv)
diff --git a/btrfs-zero-log.c b/btrfs-zero-log.c
index 411fae3..0859fe2 100644
--- a/btrfs-zero-log.c
+++ b/btrfs-zero-log.c
@@ -29,14 +29,13 @@
#include "print-tree.h"
#include "transaction.h"
#include "list.h"
-#include "version.h"
#include "utils.h"
static void print_usage(void) __attribute__((noreturn));
static void print_usage(void)
{
fprintf(stderr, "usage: btrfs-zero-log dev\n");
- fprintf(stderr, "%s\n", BTRFS_BUILD_VERSION);
+ fprintf(stderr, "%s\n", PACKAGE_STRING);
exit(1);
}
diff --git a/btrfs.c b/btrfs.c
index 2451885..f0fa848 100644
--- a/btrfs.c
+++ b/btrfs.c
@@ -20,7 +20,6 @@
#include "crc32c.h"
#include "commands.h"
-#include "version.h"
#include "utils.h"
static const char * const btrfs_cmd_group_usage[] = {
@@ -168,7 +167,7 @@ static const char * const cmd_version_usage[] = {
static int cmd_version(int argc, char **argv)
{
- printf("%s\n", BTRFS_BUILD_VERSION);
+ printf("%s\n", PACKAGE_STRING);
return 0;
}
diff --git a/btrfstune.c b/btrfstune.c
index 899a721..65513f6 100644
--- a/btrfstune.c
+++ b/btrfstune.c
@@ -30,7 +30,6 @@
#include "disk-io.h"
#include "transaction.h"
#include "utils.h"
-#include "version.h"
static char *device;
diff --git a/chunk-recover.c b/chunk-recover.c
index 688a7d7..c76b1b2 100644
--- a/chunk-recover.c
+++ b/chunk-recover.c
@@ -37,7 +37,6 @@
#include "transaction.h"
#include "crc32c.h"
#include "utils.h"
-#include "version.h"
#include "btrfsck.h"
#include "commands.h"
diff --git a/cmds-check.c b/cmds-check.c
index 0894cf0..87cb6e2 100644
--- a/cmds-check.c
+++ b/cmds-check.c
@@ -33,7 +33,6 @@
#include "disk-io.h"
#include "print-tree.h"
#include "transaction.h"
-#include "version.h"
#include "utils.h"
#include "commands.h"
#include "free-space-cache.h"
@@ -7986,7 +7985,7 @@ out:
printf("file data blocks allocated: %llu\n referenced %llu\n",
(unsigned long long)data_bytes_allocated,
(unsigned long long)data_bytes_referenced);
- printf("%s\n", BTRFS_BUILD_VERSION);
+ printf("%s\n", PACKAGE_STRING);
free_root_recs_tree(&root_cache);
close_out:
diff --git a/cmds-filesystem.c b/cmds-filesystem.c
index 253f105..85a3897 100644
--- a/cmds-filesystem.c
+++ b/cmds-filesystem.c
@@ -34,7 +34,6 @@
#include "ioctl.h"
#include "utils.h"
#include "volumes.h"
-#include "version.h"
#include "commands.h"
#include "list_sort.h"
#include "disk-io.h"
@@ -989,7 +988,7 @@ devs_only:
free_fs_devices(fs_devices);
}
out:
- printf("%s\n", BTRFS_BUILD_VERSION);
+ printf("%s\n", PACKAGE_STRING);
free_seen_fsid();
return ret;
}
@@ -1245,7 +1244,7 @@ static int cmd_defrag(int argc, char **argv)
}
}
if (defrag_global_verbose)
- printf("%s\n", BTRFS_BUILD_VERSION);
+ printf("%s\n", PACKAGE_STRING);
if (defrag_global_errors)
fprintf(stderr, "total %d failures\n", defrag_global_errors);
diff --git a/cmds-restore.c b/cmds-restore.c
index a5c99e8..27df3d8 100644
--- a/cmds-restore.c
+++ b/cmds-restore.c
@@ -40,7 +40,6 @@
#include "print-tree.h"
#include "transaction.h"
#include "list.h"
-#include "version.h"
#include "volumes.h"
#include "utils.h"
#include "commands.h"
diff --git a/library-test.c b/library-test.c
index 142188a..d23f4a7 100644
--- a/library-test.c
+++ b/library-test.c
@@ -17,7 +17,6 @@
*/
#include "kerncompat.h"
-#include "version.h"
#include "send-stream.h"
/*
diff --git a/mkfs.c b/mkfs.c
index d5d03fc..dc87273 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -41,7 +41,6 @@
#include "volumes.h"
#include "transaction.h"
#include "utils.h"
-#include "version.h"
static u64 index_cnt = 2;
@@ -289,14 +288,14 @@ static void print_usage(void)
fprintf(stderr, "\t -O --features comma separated list of filesystem features\n");
fprintf(stderr, "\t -U --uuid specify the filesystem UUID\n");
fprintf(stderr, "\t -V --version print the mkfs.btrfs version and exit\n");
- fprintf(stderr, "%s\n", BTRFS_BUILD_VERSION);
+ fprintf(stderr, "%s\n", PACKAGE_STRING);
exit(1);
}
static void print_version(void) __attribute__((noreturn));
static void print_version(void)
{
- fprintf(stderr, "mkfs.btrfs, part of %s\n", BTRFS_BUILD_VERSION);
+ fprintf(stderr, "mkfs.btrfs, part of %s\n", PACKAGE_STRING);
exit(0);
}
@@ -1488,8 +1487,8 @@ int main(int ac, char **av)
}
/* if we are here that means all devs are good to btrfsify */
- printf("%s\n", BTRFS_BUILD_VERSION);
- printf("See http://btrfs.wiki.kernel.org for more information.\n\n");
+ printf("%s\n", PACKAGE_STRING);
+ printf("See %s for more information.\n\n", PACKAGE_URL);
dev_cnt--;
--
1.9.3
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 04/10] btrfs-progs: use ./configure to generate version.h
2014-12-12 12:35 btrfs-prog: improve build-system by autoconf Karel Zak
` (2 preceding siblings ...)
2014-12-12 12:35 ` [PATCH 03/10] btrfs-progs: use standard PACKAGE_* macros Karel Zak
@ 2014-12-12 12:35 ` Karel Zak
2014-12-12 12:35 ` [PATCH 05/10] btrfs-progs: check for build programs in ./configure Karel Zak
` (6 subsequent siblings)
10 siblings, 0 replies; 18+ messages in thread
From: Karel Zak @ 2014-12-12 12:35 UTC (permalink / raw)
To: linux-btrfs; +Cc: Karel Zak
The original homemade solution is unnecessary, autotools provides better
infrastructure to generate files.
Signed-off-by: Karel Zak <kzak@redhat.com>
---
Makefile.in | 4 ----
configure.ac | 9 +++++++++
version.h.in | 11 +++++++++++
version.sh | 30 +++---------------------------
4 files changed, 23 insertions(+), 31 deletions(-)
create mode 100644 version.h.in
diff --git a/Makefile.in b/Makefile.in
index 0dd83ea..dad1685 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -154,10 +154,6 @@ test:
#
static: $(progs_static)
-version.h:
- @echo " [SH] $@"
- $(Q)bash version.sh
-
$(libs_shared): $(libbtrfs_objects) $(lib_links) send.h
@echo " [LD] $@"
$(Q)$(CC) $(CFLAGS) $(libbtrfs_objects) $(LDFLAGS) $(lib_LIBS) \
diff --git a/configure.ac b/configure.ac
index 7a6c264..937d50f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3,6 +3,10 @@ AC_INIT([btrfs-progs],
[linux-btrfs@vger.kernel.org],,
[http://btrfs.wiki.kernel.org])
+dnl library version
+LIBBTRFS_MAJOR=0
+LIBBTRFS_MINOR=1
+LIBBTRFS_PATCHLEVEL=1
AC_PREREQ([2.60])
@@ -74,11 +78,16 @@ AC_SUBST([LZO2_LIBS_STATIC])
AC_SUBST([LZO2_CFLAGS])
+dnl library stuff
+AC_SUBST([LIBBTRFS_MAJOR])
+AC_SUBST([LIBBTRFS_MINOR])
+AC_SUBST([LIBBTRFS_PATCHLEVEL])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([
Makefile
+version.h
])
AC_OUTPUT
diff --git a/version.h.in b/version.h.in
new file mode 100644
index 0000000..012d265
--- /dev/null
+++ b/version.h.in
@@ -0,0 +1,11 @@
+#ifndef __LIBBTRFS_VERSION_H__
+#define __LIBBTRFS_VERSION_H__
+
+#define BTRFS_LIB_MAJOR @LIBBTRFS_MAJOR@
+#define BTRFS_LIB_MINOR @LIBBTRFS_MINOR@
+#define BTRFS_LIB_PATCHLEVEL @LIBBTRFS_PATCHLEVEL@
+
+#define BTRFS_LIB_VERSION ( BTRFS_LIB_MAJOR * 10000 + \
+ BTRFS_LIB_MINOR * 100 + \
+ BTRFS_LIB_PATCHLEVEL )
+#endif
diff --git a/version.sh b/version.sh
index 456853c..42b47c4 100755
--- a/version.sh
+++ b/version.sh
@@ -9,9 +9,6 @@
v="v3.17.3"
opt=$1
-lib_major=0
-lib_minor=1
-lib_patchlevel=1
which git &> /dev/null
if [ $? == 0 -a -d .git ]; then
@@ -32,30 +29,9 @@ fi
if [ "$opt" = "--configure" ]; then
# Omit the trailing newline, so that m4_esyscmd can use the result directly.
echo "$v" | tr -d '\n'
- exit 0
+else
+ echo "$v"
fi
-echo "/* NOTE: this file is autogenerated by version.sh, do not edit */" > .build-version.h
-echo "#ifndef __BUILD_VERSION" >> .build-version.h
-echo >> .build-version.h
-echo "#define __BUILD_VERSION" >> .build-version.h
-echo >> .build-version.h
-echo "#define BTRFS_LIB_MAJOR $lib_major" >> .build-version.h
-echo "#define BTRFS_LIB_MINOR $lib_minor" >> .build-version.h
-echo "#define BTRFS_LIB_PATCHLEVEL $lib_patchlevel" >> .build-version.h
-echo >> .build-version.h
-echo "#define BTRFS_LIB_VERSION ( BTRFS_LIB_MAJOR * 10000 + \\" >> .build-version.h
-echo " BTRFS_LIB_MINOR * 100 + \\" >> .build-version.h
-echo " BTRFS_LIB_PATCHLEVEL )" >> .build-version.h
-echo >> .build-version.h
-echo "#define BTRFS_BUILD_VERSION \"Btrfs $v\"" >> .build-version.h
-echo "#endif" >> .build-version.h
+exit 0
-diff -q version.h .build-version.h >& /dev/null
-
-if [ $? == 0 ]; then
- rm .build-version.h
- exit 0
-fi
-
-mv .build-version.h version.h
--
1.9.3
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 05/10] btrfs-progs: check for build programs in ./configure
2014-12-12 12:35 btrfs-prog: improve build-system by autoconf Karel Zak
` (3 preceding siblings ...)
2014-12-12 12:35 ` [PATCH 04/10] btrfs-progs: use ./configure to generate version.h Karel Zak
@ 2014-12-12 12:35 ` Karel Zak
2014-12-12 12:35 ` [PATCH 06/10] btrfs-progs: use paths and $*_LIBS from ./configure Karel Zak
` (5 subsequent siblings)
10 siblings, 0 replies; 18+ messages in thread
From: Karel Zak @ 2014-12-12 12:35 UTC (permalink / raw)
To: linux-btrfs; +Cc: Karel Zak
Signed-off-by: Karel Zak <kzak@redhat.com>
---
Makefile.in | 12 ++++++------
configure.ac | 2 ++
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index dad1685..17eea58 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1,9 +1,9 @@
# Export all variables to sub-makes by default
export
-CC = gcc
-LN = ln
-AR = ar
+CC = @CC@
+LN_S = @LN_S@
+AR = @AR@
AM_CFLAGS = -include config.h -Wall \
-D_FILE_OFFSET_BITS=64 -DBTRFS_FLAT_INCLUDES \
-fno-strict-aliasing -fPIC
@@ -25,7 +25,7 @@ libbtrfs_headers = send-stream.h send-utils.h send.h rbtree.h btrfs-list.h \
extent_io.h ioctl.h ctree.h btrfsck.h version.h
TESTS = fsck-tests.sh convert-tests.sh
-INSTALL = install
+INSTALL = @INSTALL@
prefix ?= /usr/local
bindir = $(prefix)/bin
lib_LIBS = -luuid -lblkid -lm -lz -llzo2 -L.
@@ -165,8 +165,8 @@ $(libs_static): $(libbtrfs_objects)
$(lib_links):
@echo " [LN] $@"
- $(Q)$(LN) -sf libbtrfs.so.0.1 libbtrfs.so.0
- $(Q)$(LN) -sf libbtrfs.so.0.1 libbtrfs.so
+ $(Q)$(LN_S) -f libbtrfs.so.0.1 libbtrfs.so.0
+ $(Q)$(LN_S) -f libbtrfs.so.0.1 libbtrfs.so
# keep intermediate files from the below implicit rules around
.PRECIOUS: $(addsuffix .o,$(progs))
diff --git a/configure.ac b/configure.ac
index 937d50f..662d9ff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -27,6 +27,8 @@ AC_C_BIGENDIAN
AC_SYS_LARGEFILE
AC_PROG_INSTALL
+AC_PROG_LN_S
+AC_PATH_PROG([AR], [ar])
AC_CHECK_FUNCS([openat], [],
[AC_MSG_ERROR([cannot find openat() function])])
--
1.9.3
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 06/10] btrfs-progs: use paths and $*_LIBS from ./configure
2014-12-12 12:35 btrfs-prog: improve build-system by autoconf Karel Zak
` (4 preceding siblings ...)
2014-12-12 12:35 ` [PATCH 05/10] btrfs-progs: check for build programs in ./configure Karel Zak
@ 2014-12-12 12:35 ` Karel Zak
2014-12-12 12:35 ` [PATCH 07/10] btrfs-progs: cleanup compilation flags usage Karel Zak
` (4 subsequent siblings)
10 siblings, 0 replies; 18+ messages in thread
From: Karel Zak @ 2014-12-12 12:35 UTC (permalink / raw)
To: linux-btrfs; +Cc: Karel Zak
Signed-off-by: Karel Zak <kzak@redhat.com>
---
Makefile.in | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index 17eea58..df590ab 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -26,11 +26,11 @@ libbtrfs_headers = send-stream.h send-utils.h send.h rbtree.h btrfs-list.h \
TESTS = fsck-tests.sh convert-tests.sh
INSTALL = @INSTALL@
-prefix ?= /usr/local
-bindir = $(prefix)/bin
-lib_LIBS = -luuid -lblkid -lm -lz -llzo2 -L.
-libdir ?= $(prefix)/lib
-incdir = $(prefix)/include/btrfs
+prefix ?= @prefix@
+bindir = @bindir@
+lib_LIBS = @UUID_LIBS@ @BLKID_LIBS@ @ZLIB_LIBS@ @LZO2_LIBS@ -m -L.
+libdir ?= @libdir@
+incdir = @includedir@/btrfs
LIBS = $(lib_LIBS) $(libs_static)
ifeq ("$(origin V)", "command line")
--
1.9.3
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 07/10] btrfs-progs: cleanup compilation flags usage
2014-12-12 12:35 btrfs-prog: improve build-system by autoconf Karel Zak
` (5 preceding siblings ...)
2014-12-12 12:35 ` [PATCH 06/10] btrfs-progs: use paths and $*_LIBS from ./configure Karel Zak
@ 2014-12-12 12:35 ` Karel Zak
2014-12-12 12:35 ` [PATCH 08/10] btrfs-progs: clean generated files, make version.h stuff more robust Karel Zak
` (3 subsequent siblings)
10 siblings, 0 replies; 18+ messages in thread
From: Karel Zak @ 2014-12-12 12:35 UTC (permalink / raw)
To: linux-btrfs; +Cc: Karel Zak
- define basic default CFLAGS in configure.ac, because:
* autoconf default is -g -O2, but btrfs uses -g -O1
* it's better to follow autoconf; standard way to modify
CFLAGS is to call: CFLAGS="foo bar" ./configure
- move all flags to one place in Makefile.in
- don't use AM_CFLAGS, the CFLAGS and STATIC_CFLAGS are enough
- don't mix objects and flags in $LIBS, it's more readable to
add $(libs) to make rules
Signed-off-by: Karel Zak <kzak@redhat.com>
---
Makefile.in | 67 +++++++++++++++++++++++++++++++++++-------------------------
configure.ac | 2 ++
2 files changed, 41 insertions(+), 28 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index df590ab..58200ca 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -4,10 +4,27 @@ export
CC = @CC@
LN_S = @LN_S@
AR = @AR@
-AM_CFLAGS = -include config.h -Wall \
- -D_FILE_OFFSET_BITS=64 -DBTRFS_FLAT_INCLUDES \
- -fno-strict-aliasing -fPIC
-CFLAGS = -g -O1 -fno-strict-aliasing -rdynamic
+INSTALL = @INSTALL@
+
+# Non-static compilation flags
+CFLAGS = @CFLAGS@ \
+ -include config.h -Wall \
+ -D_FILE_OFFSET_BITS=64 -DBTRFS_FLAT_INCLUDES \
+ -fno-strict-aliasing -fPIC \
+ -rdynamic
+
+LDFLAGS = @LDFLAGS@
+
+LIBS = @UUID_LIBS@ @BLKID_LIBS@ @ZLIB_LIBS@ @LZO2_LIBS@ -lm -L.
+LIBBTRFS_LIBS = $(LIBS)
+
+# Static compilation flags
+STATIC_CFLAGS = $(CFLAGS) -ffunction-sections -fdata-sections
+STATIC_LDFLAGS = -static -Wl,--gc-sections
+STATIC_LIBS = @UUID_LIBS_STATIC@ @BLKID_LIBS_STATIC@ \
+ @ZLIB_LIBS_STATIC@ @LZO2_LIBS_STATIC@ -lpthread
+
+
objects = ctree.o disk-io.o radix-tree.o extent-tree.o print-tree.o \
root-tree.o dir-item.o file-item.o inode-item.o inode-map.o \
extent-cache.o extent_io.o volumes.o utils.o repair.o \
@@ -25,13 +42,10 @@ libbtrfs_headers = send-stream.h send-utils.h send.h rbtree.h btrfs-list.h \
extent_io.h ioctl.h ctree.h btrfsck.h version.h
TESTS = fsck-tests.sh convert-tests.sh
-INSTALL = @INSTALL@
prefix ?= @prefix@
bindir = @bindir@
-lib_LIBS = @UUID_LIBS@ @BLKID_LIBS@ @ZLIB_LIBS@ @LZO2_LIBS@ -m -L.
libdir ?= @libdir@
incdir = @includedir@/btrfs
-LIBS = $(lib_LIBS) $(libs_static)
ifeq ("$(origin V)", "command line")
BUILD_VERBOSE = $(V)
@@ -69,7 +83,7 @@ INSTALLDIRS = $(patsubst %,install-%,$(SUBDIRS))
CLEANDIRS = $(patsubst %,clean-%,$(SUBDIRS))
ifeq ($(DISABLE_BACKTRACE),1)
-AM_CFLAGS += -DBTRFS_DISABLE_BACKTRACE
+CFLAGS += -DBTRFS_DISABLE_BACKTRACE
endif
ifneq ($(DISABLE_DOCUMENTATION),1)
@@ -89,10 +103,6 @@ static_objects = $(patsubst %.o, %.static.o, $(objects))
static_cmds_objects = $(patsubst %.o, %.static.o, $(cmds_objects))
static_libbtrfs_objects = $(patsubst %.o, %.static.o, $(libbtrfs_objects))
-# Define static compilation flags
-STATIC_CFLAGS = $(CFLAGS) -ffunction-sections -fdata-sections
-STATIC_LDFLAGS = -static -Wl,--gc-sections
-STATIC_LIBS = $(lib_LIBS) -lpthread
libs_shared = libbtrfs.so.0.1
libs_static = libbtrfs.a
@@ -120,7 +130,7 @@ ifdef C
else
check = true
check_echo = true
- AM_CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
+ CFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
endif
%.o.d: %.c
@@ -128,13 +138,13 @@ endif
.c.o:
@$(check_echo) " [SP] $<"
- $(Q)$(check) $(AM_CFLAGS) $(CFLAGS) $<
+ $(Q)$(check) $(CFLAGS) $<
@echo " [CC] $@"
- $(Q)$(CC) $(AM_CFLAGS) $(CFLAGS) -c $<
+ $(Q)$(CC) $(CFLAGS) -c $<
%.static.o: %.c
@echo " [CC] $@"
- $(Q)$(CC) $(AM_CFLAGS) $(STATIC_CFLAGS) -c $< -o $@
+ $(Q)$(CC) $(STATIC_CFLAGS) -c $< -o $@
all: $(progs) $(BUILDDIRS)
$(SUBDIRS): $(BUILDDIRS)
@@ -156,7 +166,7 @@ static: $(progs_static)
$(libs_shared): $(libbtrfs_objects) $(lib_links) send.h
@echo " [LD] $@"
- $(Q)$(CC) $(CFLAGS) $(libbtrfs_objects) $(LDFLAGS) $(lib_LIBS) \
+ $(Q)$(CC) $(CFLAGS) $(libbtrfs_objects) $(LDFLAGS) $(LIBBTRFS_LIBS) \
-shared -Wl,-soname,libbtrfs.so.0 -o libbtrfs.so.0.1
$(libs_static): $(libbtrfs_objects)
@@ -186,12 +196,13 @@ btrfs-%.static: $(static_objects) btrfs-%.static.o $(static_libbtrfs_objects)
btrfs-%: $(objects) $(libs) btrfs-%.o
@echo " [LD] $@"
- $(Q)$(CC) $(CFLAGS) -o $@ $(objects) $@.o $(LDFLAGS) $(LIBS) $($(subst -,_,$@-libs))
+ $(Q)$(CC) $(CFLAGS) -o $@ $(objects) $@.o $(libs) \
+ $(LDFLAGS) $(LIBS) $($(subst -,_,$@-libs))
btrfs: $(objects) btrfs.o help.o $(cmds_objects) $(libs)
@echo " [LD] $@"
$(Q)$(CC) $(CFLAGS) -o btrfs btrfs.o help.o $(cmds_objects) \
- $(objects) $(LDFLAGS) $(LIBS) -lpthread
+ $(objects) $(libs) $(LDFLAGS) $(LIBS) -lpthread
btrfs.static: $(static_objects) btrfs.static.o help.static.o $(static_cmds_objects) $(static_libbtrfs_objects)
@echo " [LD] $@"
@@ -201,15 +212,15 @@ btrfs.static: $(static_objects) btrfs.static.o help.static.o $(static_cmds_objec
# For backward compatibility, 'btrfs' changes behaviour to fsck if it's named 'btrfsck'
btrfsck: btrfs
@echo " [LN] $@"
- $(Q)$(LN) -f btrfs btrfsck
+ $(Q)$(LN_S) -f btrfs btrfsck
btrfsck.static: btrfs.static
@echo " [LN] $@"
- $(Q)$(LN) -f $^ $@
+ $(Q)$(LN_S) -f $^ $@
mkfs.btrfs: $(objects) $(libs) mkfs.o
@echo " [LD] $@"
- $(Q)$(CC) $(CFLAGS) -o mkfs.btrfs $(objects) mkfs.o $(LDFLAGS) $(LIBS)
+ $(Q)$(CC) $(CFLAGS) -o mkfs.btrfs $(objects) $(libs) mkfs.o $(LDFLAGS) $(LIBS)
mkfs.btrfs.static: $(static_objects) mkfs.static.o $(static_libbtrfs_objects)
@echo " [LD] $@"
@@ -218,7 +229,7 @@ mkfs.btrfs.static: $(static_objects) mkfs.static.o $(static_libbtrfs_objects)
btrfstune: $(objects) $(libs) btrfstune.o
@echo " [LD] $@"
- $(Q)$(CC) $(CFLAGS) -o btrfstune $(objects) btrfstune.o $(LDFLAGS) $(LIBS)
+ $(Q)$(CC) $(CFLAGS) -o btrfstune $(objects) $(libs) btrfstune.o $(LDFLAGS) $(LIBS)
btrfstune.static: $(static_objects) btrfstune.static.o $(static_libbtrfs_objects)
@echo " [LD] $@"
@@ -227,19 +238,19 @@ btrfstune.static: $(static_objects) btrfstune.static.o $(static_libbtrfs_objects
dir-test: $(objects) $(libs) dir-test.o
@echo " [LD] $@"
- $(Q)$(CC) $(CFLAGS) -o dir-test $(objects) dir-test.o $(LDFLAGS) $(LIBS)
+ $(Q)$(CC) $(CFLAGS) -o dir-test $(objects) $(libs) dir-test.o $(LDFLAGS) $(LIBS)
quick-test: $(objects) $(libs) quick-test.o
@echo " [LD] $@"
- $(Q)$(CC) $(CFLAGS) -o quick-test $(objects) quick-test.o $(LDFLAGS) $(LIBS)
+ $(Q)$(CC) $(CFLAGS) -o quick-test $(objects) $(libs) quick-test.o $(LDFLAGS) $(LIBS)
ioctl-test: $(objects) $(libs) ioctl-test.o
@echo " [LD] $@"
- $(Q)$(CC) $(CFLAGS) -o ioctl-test $(objects) ioctl-test.o $(LDFLAGS) $(LIBS)
+ $(Q)$(CC) $(CFLAGS) -o ioctl-test $(objects) $(libs) ioctl-test.o $(LDFLAGS) $(LIBS)
send-test: $(objects) $(libs) send-test.o
@echo " [LD] $@"
- $(Q)$(CC) $(CFLAGS) -o send-test $(objects) send-test.o $(LDFLAGS) $(LIBS) -lpthread
+ $(Q)$(CC) $(CFLAGS) -o send-test $(objects) $(libs) send-test.o $(LDFLAGS) $(LIBS) -lpthread
library-test: $(libs_shared) library-test.o
@echo " [LD] $@"
@@ -284,7 +295,7 @@ install: $(libs) $(progs) $(INSTALLDIRS)
$(INSTALL) $(progs) $(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) -f $(DESTDIR)$(bindir)/btrfs $(DESTDIR)$(bindir)/btrfsck
+ $(LN_S) -f $(DESTDIR)$(bindir)/btrfs $(DESTDIR)$(bindir)/btrfsck
$(INSTALL) -m755 -d $(DESTDIR)$(libdir)
$(INSTALL) $(libs) $(DESTDIR)$(libdir)
cp -a $(lib_links) $(DESTDIR)$(libdir)
diff --git a/configure.ac b/configure.ac
index 662d9ff..f6adefb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -8,6 +8,8 @@ LIBBTRFS_MAJOR=0
LIBBTRFS_MINOR=1
LIBBTRFS_PATCHLEVEL=1
+CFLAGS="-g -O1"
+
AC_PREREQ([2.60])
AC_CONFIG_AUX_DIR([config])
--
1.9.3
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 08/10] btrfs-progs: clean generated files, make version.h stuff more robust
2014-12-12 12:35 btrfs-prog: improve build-system by autoconf Karel Zak
` (6 preceding siblings ...)
2014-12-12 12:35 ` [PATCH 07/10] btrfs-progs: cleanup compilation flags usage Karel Zak
@ 2014-12-12 12:35 ` Karel Zak
2014-12-12 12:35 ` [PATCH 09/10] btrfs-progs: add --disable-backtrace Karel Zak
` (2 subsequent siblings)
10 siblings, 0 replies; 18+ messages in thread
From: Karel Zak @ 2014-12-12 12:35 UTC (permalink / raw)
To: linux-btrfs; +Cc: Karel Zak
- add rule to generated version.h when any relevant stuff changed
- add rule to clean generated files on "make clean-all"
Signed-off-by: Karel Zak <kzak@redhat.com>
---
Makefile.in | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index 58200ca..df752d3 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -164,6 +164,10 @@ test:
#
static: $(progs_static)
+version.h: version.sh version.h.in configure.ac
+ @echo " [SH] $@"
+ $(Q)bash ./config.status --silent $@
+
$(libs_shared): $(libbtrfs_objects) $(lib_links) send.h
@echo " [LD] $@"
$(Q)$(CC) $(CFLAGS) $(libbtrfs_objects) $(LDFLAGS) $(LIBBTRFS_LIBS) \
@@ -271,14 +275,15 @@ test-build:
manpages:
$(Q)$(MAKE) $(MAKEOPTS) -C Documentation
-clean-all: clean-doc clean
+
+clean-all: clean clean-doc clean-gen
clean: $(CLEANDIRS)
@echo "Cleaning"
$(Q)rm -f $(progs) cscope.out *.o *.o.d \
dir-test ioctl-test quick-test send-test library-test library-test-static \
btrfs.static mkfs.btrfs.static \
- version.h $(check_defs) \
+ $(check_defs) \
$(libs) $(lib_links) \
$(progs_static) $(progs_extra)
@@ -286,6 +291,11 @@ clean-doc:
@echo "Cleaning Documentation"
$(Q)$(MAKE) $(MAKEOPTS) -C Documentation clean
+clean-gen:
+ @echo "Cleaning Generated Files"
+ $(Q)rm -f version.h config.status config.cache connfig.log \
+ configure.lineno config.status.lineno Makefile
+
$(CLEANDIRS):
@echo "Cleaning $(patsubst clean-%,%,$@)"
$(Q)$(MAKE) $(MAKEOPTS) -C $(patsubst clean-%,%,$@) clean
--
1.9.3
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 09/10] btrfs-progs: add --disable-backtrace
2014-12-12 12:35 btrfs-prog: improve build-system by autoconf Karel Zak
` (7 preceding siblings ...)
2014-12-12 12:35 ` [PATCH 08/10] btrfs-progs: clean generated files, make version.h stuff more robust Karel Zak
@ 2014-12-12 12:35 ` Karel Zak
2014-12-12 12:35 ` [PATCH 10/10] btrfs-progs: add --disable-documentation Karel Zak
2014-12-17 14:07 ` btrfs-prog: improve build-system by autoconf David Sterba
10 siblings, 0 replies; 18+ messages in thread
From: Karel Zak @ 2014-12-12 12:35 UTC (permalink / raw)
To: linux-btrfs; +Cc: Karel Zak
It's better to use ./configure than manually edit Makefile.
Signed-off-by: Karel Zak <kzak@redhat.com>
---
Makefile.in | 4 ----
configure.ac | 10 ++++++++++
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index df752d3..bdd7683 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -82,10 +82,6 @@ BUILDDIRS = $(patsubst %,build-%,$(SUBDIRS))
INSTALLDIRS = $(patsubst %,install-%,$(SUBDIRS))
CLEANDIRS = $(patsubst %,clean-%,$(SUBDIRS))
-ifeq ($(DISABLE_BACKTRACE),1)
-CFLAGS += -DBTRFS_DISABLE_BACKTRACE
-endif
-
ifneq ($(DISABLE_DOCUMENTATION),1)
BUILDDIRS += build-Documentation
INSTALLDIRS += install-Documentation
diff --git a/configure.ac b/configure.ac
index f6adefb..290d022 100644
--- a/configure.ac
+++ b/configure.ac
@@ -56,6 +56,16 @@ AC_DEFUN([PKG_STATIC], [
fi
])
+
+AC_ARG_ENABLE([backtrace],
+ AS_HELP_STRING([--disable-backtrace], [disable btrfs backtrace]),
+ [], [enable_backtrace=yes]
+)
+
+AS_IF([test "x$enable_backtrace" = xno], [
+ AC_DEFINE([BTRFS_DISABLE_BACKTRACE], [1], [disable backtrace stuff in kerncompat.h ])
+])
+
dnl Define <NAME>_LIBS= and <NAME>_CFLAGS= by pkg-config
dnl
dnl The default PKG_CHECK_MODULES() action-if-not-found is end the
--
1.9.3
^ permalink raw reply related [flat|nested] 18+ messages in thread* [PATCH 10/10] btrfs-progs: add --disable-documentation
2014-12-12 12:35 btrfs-prog: improve build-system by autoconf Karel Zak
` (8 preceding siblings ...)
2014-12-12 12:35 ` [PATCH 09/10] btrfs-progs: add --disable-backtrace Karel Zak
@ 2014-12-12 12:35 ` Karel Zak
2014-12-17 14:07 ` btrfs-prog: improve build-system by autoconf David Sterba
10 siblings, 0 replies; 18+ messages in thread
From: Karel Zak @ 2014-12-12 12:35 UTC (permalink / raw)
To: linux-btrfs; +Cc: Karel Zak
Signed-off-by: Karel Zak <kzak@redhat.com>
---
Makefile.in | 1 +
configure.ac | 9 +++++++++
2 files changed, 10 insertions(+)
diff --git a/Makefile.in b/Makefile.in
index bdd7683..5889224 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -5,6 +5,7 @@ CC = @CC@
LN_S = @LN_S@
AR = @AR@
INSTALL = @INSTALL@
+DISABLE_DOCUMENTATION = @DISABLE_DOCUMENTATION@
# Non-static compilation flags
CFLAGS = @CFLAGS@ \
diff --git a/configure.ac b/configure.ac
index 290d022..79cb591 100644
--- a/configure.ac
+++ b/configure.ac
@@ -66,6 +66,15 @@ AS_IF([test "x$enable_backtrace" = xno], [
AC_DEFINE([BTRFS_DISABLE_BACKTRACE], [1], [disable backtrace stuff in kerncompat.h ])
])
+
+AC_ARG_ENABLE([documentation],
+ AS_HELP_STRING([--disable-documentation], [do not build domumentation]),
+ [], [enable_documentation=yes]
+)
+AS_IF([test "x$enable_documentation" = xyes], [DISABLE_DOCUMENTATION=0], [DISABLE_DOCUMENTATION=1])
+AC_SUBST([DISABLE_DOCUMENTATION])
+
+
dnl Define <NAME>_LIBS= and <NAME>_CFLAGS= by pkg-config
dnl
dnl The default PKG_CHECK_MODULES() action-if-not-found is end the
--
1.9.3
^ permalink raw reply related [flat|nested] 18+ messages in thread* Re: btrfs-prog: improve build-system by autoconf
2014-12-12 12:35 btrfs-prog: improve build-system by autoconf Karel Zak
` (9 preceding siblings ...)
2014-12-12 12:35 ` [PATCH 10/10] btrfs-progs: add --disable-documentation Karel Zak
@ 2014-12-17 14:07 ` David Sterba
2014-12-18 13:31 ` Karel Zak
2015-01-16 15:26 ` Karel Zak
10 siblings, 2 replies; 18+ messages in thread
From: David Sterba @ 2014-12-17 14:07 UTC (permalink / raw)
To: Karel Zak; +Cc: linux-btrfs
On Fri, Dec 12, 2014 at 01:35:14PM +0100, Karel Zak wrote:
> This is first step to make btrfs-progs build system more conventional
> for userspace users and developers. All is implemented by small incremental
> patches to keep things review-able.
Thanks. I went through the patches and haven't found major problems. The
changes are affecting build system and this will need a longer period
before all distros have a chance to adapt to that, so I'm postponing it
to 3.19.
> Note that there is also strange unused btrfs_convert_libs, btrfs_image_libs and
> btrfs_fragments_libs variables with things like "-lgd -lpng -ljpeg -lfreetype".
> I guess it's some legacy, right? I didn't touch these variables as I have no
> clue about sense of this stuff.
No, it's part of the macro magic. There are pattern rules that accept
any source in the form btrfs-something.c and also pick the libraries for
that from variable btrfs_something_libs:
btrfs-%: $(objects) $(libs) btrfs-%.o
@echo " [LD] $@"
$(Q)$(CC) $(CFLAGS) -o $@ $(objects) $@.o $(LDFLAGS) $(LIBS) $($(subst -,_,$@-libs))
This is for convenience, if this turns out to be hard to do with in combination
with autotools, I don't insist on keeping it but it has simplified the Makefile
significantly.
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: btrfs-prog: improve build-system by autoconf
2014-12-17 14:07 ` btrfs-prog: improve build-system by autoconf David Sterba
@ 2014-12-18 13:31 ` Karel Zak
2014-12-18 18:00 ` Eric Sandeen
2014-12-22 12:47 ` Koen Kooi
2015-01-16 15:26 ` Karel Zak
1 sibling, 2 replies; 18+ messages in thread
From: Karel Zak @ 2014-12-18 13:31 UTC (permalink / raw)
To: dsterba, linux-btrfs
On Wed, Dec 17, 2014 at 03:07:26PM +0100, David Sterba wrote:
> On Fri, Dec 12, 2014 at 01:35:14PM +0100, Karel Zak wrote:
> > This is first step to make btrfs-progs build system more conventional
> > for userspace users and developers. All is implemented by small incremental
> > patches to keep things review-able.
>
> Thanks. I went through the patches and haven't found major problems. The
> changes are affecting build system and this will need a longer period
> before all distros have a chance to adapt to that, so I'm postponing it
> to 3.19.
Cool, I'll try to prepare next set of patches with automake.
BTW, I have good experience with build-system changes -- downstream
distributions (maintainers) are usually pretty flexible :-)
> > Note that there is also strange unused btrfs_convert_libs, btrfs_image_libs and
> > btrfs_fragments_libs variables with things like "-lgd -lpng -ljpeg -lfreetype".
> > I guess it's some legacy, right? I didn't touch these variables as I have no
> > clue about sense of this stuff.
>
> No, it's part of the macro magic. There are pattern rules that accept
> any source in the form btrfs-something.c and also pick the libraries for
> that from variable btrfs_something_libs:
>
> btrfs-%: $(objects) $(libs) btrfs-%.o
> @echo " [LD] $@"
> $(Q)$(CC) $(CFLAGS) -o $@ $(objects) $@.o $(LDFLAGS) $(LIBS) $($(subst -,_,$@-libs))
>
> This is for convenience, if this turns out to be hard to do with in combination
> with autotools, I don't insist on keeping it but it has simplified the Makefile
> significantly.
OK, so -ljpeg in the Makefile is just example, right?
Anyway, for these things is better to introduce extra autoconf
AC_ARG_VAR() variables, keep is empty by default and use it in
Makefile. The advantage is that the variables are documented and
visible by ./configure --help.
For example in util-linux we have many {SUID,DAEMON,SOLIB,...}_CFLAGS
and LDFLAGS for distributions that require extensions like -fPIE,
-Wl,-z,relro etc. The same is possible to do with $LIBS.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: btrfs-prog: improve build-system by autoconf
2014-12-18 13:31 ` Karel Zak
@ 2014-12-18 18:00 ` Eric Sandeen
2014-12-22 12:47 ` Koen Kooi
1 sibling, 0 replies; 18+ messages in thread
From: Eric Sandeen @ 2014-12-18 18:00 UTC (permalink / raw)
To: Karel Zak, dsterba, linux-btrfs
On 12/18/14 7:31 AM, Karel Zak wrote:
> On Wed, Dec 17, 2014 at 03:07:26PM +0100, David Sterba wrote:
>> On Fri, Dec 12, 2014 at 01:35:14PM +0100, Karel Zak wrote:
>>> This is first step to make btrfs-progs build system more conventional
>>> for userspace users and developers. All is implemented by small incremental
>>> patches to keep things review-able.
>>
>> Thanks. I went through the patches and haven't found major problems. The
>> changes are affecting build system and this will need a longer period
>> before all distros have a chance to adapt to that, so I'm postponing it
>> to 3.19.
>
> Cool, I'll try to prepare next set of patches with automake.
>
> BTW, I have good experience with build-system changes -- downstream
> distributions (maintainers) are usually pretty flexible :-)
>
>>> Note that there is also strange unused btrfs_convert_libs, btrfs_image_libs and
>>> btrfs_fragments_libs variables with things like "-lgd -lpng -ljpeg -lfreetype".
>>> I guess it's some legacy, right? I didn't touch these variables as I have no
>>> clue about sense of this stuff.
>>
>> No, it's part of the macro magic. There are pattern rules that accept
>> any source in the form btrfs-something.c and also pick the libraries for
>> that from variable btrfs_something_libs:
>>
>> btrfs-%: $(objects) $(libs) btrfs-%.o
>> @echo " [LD] $@"
>> $(Q)$(CC) $(CFLAGS) -o $@ $(objects) $@.o $(LDFLAGS) $(LIBS) $($(subst -,_,$@-libs))
>>
>> This is for convenience, if this turns out to be hard to do with in combination
>> with autotools, I don't insist on keeping it but it has simplified the Makefile
>> significantly.
Yeah, I did those long ago IIRC. It obfuscates things a bit, but cut down on tons of
cut and paste in the Makefile...
> OK, so -ljpeg in the Makefile is just example, right?
It's been specified for the btrfs-framgnets tool since .. forever.
commit 6d37fbfc1f83c34f00df7c9d8e5b60e49d9db48d
Author: Arne Jansen <sensille@gmx.net>
Date: Mon Nov 28 17:12:30 2011 +0100
Btrfs-progs: tool to visualize fragmentation
...
+btrfs-fragments: $(objects) $(libs) fragments.o
+ @echo " [LD] $@"
+ $(Q)$(CC) $(CFLAGS) -o btrfs-fragments $(objects) fragments.o $(LDFLAGS) $(LIBS) -lgd -lpng -ljpeg -lfreetype
but the code only does:
gdImagePng(im, pngout);
so it's probably not needed...
>
> Anyway, for these things is better to introduce extra autoconf
> AC_ARG_VAR() variables, keep is empty by default and use it in
> Makefile. The advantage is that the variables are documented and
> visible by ./configure --help.
>
> For example in util-linux we have many {SUID,DAEMON,SOLIB,...}_CFLAGS
> and LDFLAGS for distributions that require extensions like -fPIE,
> -Wl,-z,relro etc. The same is possible to do with $LIBS.
Once auto$FOO is implemented, I am sure there are better ways to do it
than what I did. :)
Thanks,
-Eric
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: btrfs-prog: improve build-system by autoconf
2014-12-18 13:31 ` Karel Zak
2014-12-18 18:00 ` Eric Sandeen
@ 2014-12-22 12:47 ` Koen Kooi
1 sibling, 0 replies; 18+ messages in thread
From: Koen Kooi @ 2014-12-22 12:47 UTC (permalink / raw)
To: linux-btrfs
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Karel Zak schreef op 18-12-14 14:31:
> On Wed, Dec 17, 2014 at 03:07:26PM +0100, David Sterba wrote:
>> On Fri, Dec 12, 2014 at 01:35:14PM +0100, Karel Zak wrote:
>>> This is first step to make btrfs-progs build system more
>>> conventional for userspace users and developers. All is implemented
>>> by small incremental patches to keep things review-able.
>>
>> Thanks. I went through the patches and haven't found major problems.
>> The changes are affecting build system and this will need a longer
>> period before all distros have a chance to adapt to that, so I'm
>> postponing it to 3.19.
>
> Cool, I'll try to prepare next set of patches with automake.
>
> BTW, I have good experience with build-system changes -- downstream
> distributions (maintainers) are usually pretty flexible :-)
Especially when switching from homegrown makefiles to autofoo!
regards,
Koen
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)
Comment: GPGTools - http://gpgtools.org
iD8DBQFUmBLqMkyGM64RGpERApjpAJ9Agir/DDJiFYUR8qPDcNmx7pnLnQCgoKsD
1HuCreKom9ZYzZevIbqWz08=
=g1VP
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: btrfs-prog: improve build-system by autoconf
2014-12-17 14:07 ` btrfs-prog: improve build-system by autoconf David Sterba
2014-12-18 13:31 ` Karel Zak
@ 2015-01-16 15:26 ` Karel Zak
2015-01-28 15:38 ` David Sterba
1 sibling, 1 reply; 18+ messages in thread
From: Karel Zak @ 2015-01-16 15:26 UTC (permalink / raw)
To: dsterba, linux-btrfs
On Wed, Dec 17, 2014 at 03:07:26PM +0100, David Sterba wrote:
> On Fri, Dec 12, 2014 at 01:35:14PM +0100, Karel Zak wrote:
> > This is first step to make btrfs-progs build system more conventional
> > for userspace users and developers. All is implemented by small incremental
> > patches to keep things review-able.
>
> Thanks. I went through the patches and haven't found major problems. The
> changes are affecting build system and this will need a longer period
> before all distros have a chance to adapt to that, so I'm postponing it
> to 3.19.
Note that I have rebased the autoconf patches and fixed some issues,
the latest version is available at
https://github.com/karelzak/btrfs-progs/commits/autoconf
you can merge it (now or later) on command line by:
git pull --log git@github.com:karelzak/btrfs-progs.git autoconf
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: btrfs-prog: improve build-system by autoconf
2015-01-16 15:26 ` Karel Zak
@ 2015-01-28 15:38 ` David Sterba
2015-02-04 11:40 ` Karel Zak
0 siblings, 1 reply; 18+ messages in thread
From: David Sterba @ 2015-01-28 15:38 UTC (permalink / raw)
To: Karel Zak; +Cc: linux-btrfs
On Fri, Jan 16, 2015 at 04:26:13PM +0100, Karel Zak wrote:
> On Wed, Dec 17, 2014 at 03:07:26PM +0100, David Sterba wrote:
> > On Fri, Dec 12, 2014 at 01:35:14PM +0100, Karel Zak wrote:
> > > This is first step to make btrfs-progs build system more conventional
> > > for userspace users and developers. All is implemented by small incremental
> > > patches to keep things review-able.
> >
> > Thanks. I went through the patches and haven't found major problems. The
> > changes are affecting build system and this will need a longer period
> > before all distros have a chance to adapt to that, so I'm postponing it
> > to 3.19.
>
> Note that I have rebased the autoconf patches and fixed some issues,
Rebased on 3.18.3, fixed some minor conflicts.
* I'm a bit surprised that automake is required for the
config.{guess,sub} and install-sh files
* my oldish testbox' automake does not support the --print-libdir option
(automake-1.11), enterprise distros ship automake of similar age
* library build test fails, but this may be because I've mismerged
something, I'll check again
Otherwise looks ok and I'll merge it, plus a few fixups to make it build
for me.
> https://github.com/karelzak/btrfs-progs/commits/autoconf
>
> you can merge it (now or later) on command line by:
>
> git pull --log git@github.com:karelzak/btrfs-progs.git autoconf
git-pulls are not (yet) established workflow, mailinglist is preferred,
but it does not hurt to publish branches along.
I've noticed the 'automake' branch that switches to automake. Looking at
the amount of changes and the result, I'm not quite happy and don't see
the benefit of automake. An extra layer that only obfuscates the build.
We're not using any advanced build features. Just a bunch of independent
binaries built from the same sources. The shared library is an exception
and it works.
^ permalink raw reply [flat|nested] 18+ messages in thread* Re: btrfs-prog: improve build-system by autoconf
2015-01-28 15:38 ` David Sterba
@ 2015-02-04 11:40 ` Karel Zak
0 siblings, 0 replies; 18+ messages in thread
From: Karel Zak @ 2015-02-04 11:40 UTC (permalink / raw)
To: dsterba, linux-btrfs
On Wed, Jan 28, 2015 at 04:38:15PM +0100, David Sterba wrote:
> Rebased on 3.18.3, fixed some minor conflicts.
>
> * I'm a bit surprised that automake is required for the
> config.{guess,sub} and install-sh files
well, it's not required, but autoconf does not provide the scripts.
You have to maintain the scripts in git three (IMHO not elegant
solution) or use the scripts from automake.
This problem does not exist if you have fully "autotoolized" project,
because automake provides automatically all the scripts.
> * my oldish testbox' automake does not support the --print-libdir option
> (automake-1.11), enterprise distros ship automake of similar age
>
> * library build test fails, but this may be because I've mismerged
> something, I'll check again
>
> Otherwise looks ok and I'll merge it, plus a few fixups to make it build
> for me.
>
> > https://github.com/karelzak/btrfs-progs/commits/autoconf
> >
> > you can merge it (now or later) on command line by:
> >
> > git pull --log git@github.com:karelzak/btrfs-progs.git autoconf
>
> git-pulls are not (yet) established workflow, mailinglist is preferred,
> but it does not hurt to publish branches along.
OK.
> I've noticed the 'automake' branch that switches to automake. Looking at
> the amount of changes and the result, I'm not quite happy and don't see
> the benefit of automake. An extra layer that only obfuscates the build.
I don't think the set of changes is so huge, all the changes are
mostly Makefile.am.
Anyway, why automake:
- it's way how to standardize build-system, the automake rules are
really easy to read, the Makefile.am files are almost the same in
all projects.
- automake+autoconf provides AM_CONDITIONAL(), so you can keep your
makefiles pretty simple and maintain all if-then logic in ./configure
script where you have available shell and huge number of tests.
For example in util-linux we have many internal and external
dependencies, but in makefiles we have only "if BUILD_UTILNAME",
all logic is strictly in ./configure.ac
- provides large set of targets
- provides more portable environment
(for example: if you want to distribute man pages, then
dist_man_MANS += foo.8 is enough, you don't have to care about
target directories for the man page section, etc.)
- forces maintainer to generate better tarballs, after successful
"make diskcheck" you can be sure that your tarballs are really
usable (for example -- do you know how many header files are
missing in the current btrfs-progs Makefile? Do you have a way how
to check it?)
- manually write and maintain smart build-system is difficult and
result is almost always very complex stuff
There is only one disadvantage, developers have to learn something
new. Yes, people hate this thing :-)
I guess we will see more and more stuff in btrfs-progs, so it's
better to the change now than later.
See e2fsprogs (sorry Ted), it's result of "automake only obfuscates",
many Makefile.in files, '@' everywhere, nightmare.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
^ permalink raw reply [flat|nested] 18+ messages in thread