Skip to contentSkip to conversation

btrfs-prog: improve build-system by autoconf

PATCH New Karel Zak 4 participants 18 messages Dec 12, 2014 – Feb 4, 2015

Subsystems (2)
lore
Share & tools
lore

Karel Zak

author
#0 lore raw

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.

The Makefile targets and rules are no changed, things like V=1 (verbose), C=1 (sparse) static builds, etc. still work as expected. All the changes are mostly about $LIBS, $CFLAGS and proper libraries (uuid, blkid, lzo2, ..) detection.

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.

[PATCH 01/10] btrfs-progs: add ./configure script [PATCH 02/10] btrfs-progs: use config.h
[PATCH 03/10] btrfs-progs: use standard PACKAGE_* macros [PATCH 04/10] btrfs-progs: use ./configure to generate version.h [PATCH 05/10] btrfs-progs: check for build programs in ./configure [PATCH 06/10] btrfs-progs: use paths and $*_LIBS from ./configure [PATCH 07/10] btrfs-progs: cleanup compilation flags usage [PATCH 08/10] btrfs-progs: clean generated files, make version.h [PATCH 09/10] btrfs-progs: add --disable-backtrace [PATCH 10/10] btrfs-progs: add --disable-documentation

The next possible step is automake, but I'd like merge ./configure stuff first.

Karel

author
#1 lore raw

PATCH 1/10 btrfs-progs: add ./configure script

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.

---
 .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
.gitignore +28 -0
index e637b17..beddedb 100644
@@ -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
Makefile +48 -39

190 lines not on this page · raw message

Makefile.in new file +314 -0

314 lines not on this page · raw message

autogen.sh new file +58 -0

58 lines not on this page · raw message

configure.ac new file +102 -0

102 lines not on this page · raw message

version.sh +7 -0
old mode 100644
new mode 100755
index 773482d..456853c
@@ -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
Signature · 1 line
1.9.3
author
#2 lore raw

PATCH 2/10 btrfs-progs: use config.h

In reply to 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

---
 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(-)
Makefile.in +3 -1
index 4cae30c..0dd83ea 100644
@@ -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 \
btrfs-calc-size.c +0 -1
index 501111c..3ec8230 100644
@@ -17,7 +17,6 @@
  */
 
 #define _XOPEN_SOURCE 500
-#define _GNU_SOURCE 1
 #include <ctype.h>
 #include <stdio.h>
 #include <stdlib.h>
btrfs-convert.c +0 -1
index 02c5e94..c88acc1 100644
@@ -17,7 +17,6 @@
  */
 
 #define _XOPEN_SOURCE 600
-#define _GNU_SOURCE 1
 
 #include "kerncompat.h"
 
btrfs-corrupt-block.c +1 -1
index af9ae4d..e993680 100644
@@ -17,7 +17,7 @@
  */
 
 #define _XOPEN_SOURCE 500
-#define _GNU_SOURCE 1
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <fcntl.h>
btrfs-find-root.c +1 -1
index 6fa61cc..b24dddf 100644
@@ -17,7 +17,7 @@
  */
 
 #define _XOPEN_SOURCE 500
-#define _GNU_SOURCE 1
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
btrfs-fragments.c +0 -1
index d03c2c3..ca45686 100644
@@ -14,7 +14,6 @@
  * Boston, MA 021110-1307, USA.
  */
 
-#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
btrfs-image.c +1 -1
index cb17f16..1257966 100644
@@ -17,7 +17,7 @@
  */
 
 #define _XOPEN_SOURCE 500
-#define _GNU_SOURCE 1
+
 #include <pthread.h>
 #include <stdio.h>
 #include <stdlib.h>
btrfs-list.c +0 -1
index 50edcf4..3e29cf8 100644
@@ -16,7 +16,6 @@
  * Boston, MA 021110-1307, USA.
  */
 
-#define _GNU_SOURCE
 #include <sys/ioctl.h>
 #include <sys/mount.h>
 #include "ioctl.h"
btrfs-map-logical.c +1 -1
index 47d1104..c34484f 100644
@@ -17,7 +17,7 @@
  */
 
 #define _XOPEN_SOURCE 500
-#define _GNU_SOURCE 1
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <fcntl.h>
btrfs-select-super.c +1 -1
index 6231d42..54ac436 100644
@@ -17,7 +17,7 @@
  */
 
 #define _XOPEN_SOURCE 500
-#define _GNU_SOURCE 1
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
btrfs-show-super.c +1 -1
index 2b48f44..9702eb0 100644
@@ -17,7 +17,7 @@
  */
 
 #define _XOPEN_SOURCE 500
-#define _GNU_SOURCE 1
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
btrfs-zero-log.c +1 -1
index 4154175..411fae3 100644
@@ -17,7 +17,7 @@
  */
 
 #define _XOPEN_SOURCE 500
-#define _GNU_SOURCE 1
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
btrfs.c +0 -1
index e83349c..2451885 100644
@@ -14,7 +14,6 @@
  * Boston, MA 021110-1307, USA.
  */
 
-#define _GNU_SOURCE
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
btrfstune.c +1 -1
index 050418a..899a721 100644
@@ -17,7 +17,7 @@
  */
 
 #define _XOPEN_SOURCE 500
-#define _GNU_SOURCE 1
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <sys/types.h>
chunk-recover.c +0 -1
index 6f43066..688a7d7 100644
@@ -16,7 +16,6 @@
  * Boston, MA 021110-1307, USA.
  */
 #define _XOPEN_SOURCE 500
-#define _GNU_SOURCE
 
 #include <stdio.h>
 #include <stdio_ext.h>
cmds-check.c +1 -1
index 9fc1410..0894cf0 100644
@@ -17,7 +17,7 @@
  */
 
 #define _XOPEN_SOURCE 500
-#define _GNU_SOURCE 1
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
cmds-receive.c +0 -1
index 358df1f..f234b15 100644
@@ -16,7 +16,6 @@
  * Boston, MA 021110-1307, USA.
  */
 
-#define _GNU_SOURCE
 #define _POSIX_C_SOURCE 200809
 #define _XOPEN_SOURCE 700
 #define _BSD_SOURCE
cmds-restore.c +0 -1
index 2f9b72d..a5c99e8 100644
@@ -17,7 +17,6 @@
  */
 
 #define _XOPEN_SOURCE 500
-#define _GNU_SOURCE 1
 
 #include "kerncompat.h"
 
cmds-send.c +0 -2
index b17b5e2..f6fae44 100644
@@ -16,8 +16,6 @@
  * Boston, MA 021110-1307, USA.
  */
 
-#define _GNU_SOURCE
-
 #include "kerncompat.h"
 
 #include <unistd.h>
disk-io.c +1 -1
index 03edf8e..9f15c0c 100644
@@ -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>
mkfs.c +0 -1
index e10e62d..d5d03fc 100644
@@ -17,7 +17,6 @@
  */
 
 #define _XOPEN_SOURCE 500
-#define _GNU_SOURCE
 
 #include "kerncompat.h"
 
send-test.c +0 -2
index 0e804a2..af8229e 100644
@@ -21,8 +21,6 @@
  * Boston, MA 021110-1307, USA.
  */
 
-#define _GNU_SOURCE
-
 #include <unistd.h>
 #include <stdint.h>
 #include <dirent.h>
super-recover.c +0 -1
index adb2c44..d0125f4 100644
@@ -17,7 +17,6 @@
  */
 
 #define _XOPEN_SOURCE 500
-#define _GNU_SOURCE 1
 
 #include <stdio.h>
 #include <stdlib.h>
utils-lib.c +0 -2
index 9d53c6e..79ef35e 100644
@@ -1,5 +1,3 @@
-#define _GNU_SOURCE
-
 #include "kerncompat.h"
 #include <unistd.h>
 #include <stdlib.h>
utils.c +1 -1
index 2a92416..1f95a9b 100644
@@ -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>
Signature · 1 line
1.9.3
author
#3 lore raw

PATCH 3/10 btrfs-progs: use standard PACKAGE_* macros

In reply to 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>".

---
 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(-)
btrfs-calc-size.c +0 -1
index 3ec8230..2be0d64 100644
@@ -32,7 +32,6 @@
 #include "print-tree.h"
 #include "transaction.h"
 #include "list.h"
-#include "version.h"
 #include "volumes.h"
 #include "utils.h"
 
btrfs-corrupt-block.c +0 -1
index e993680..ba7358d 100644
@@ -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
btrfs-debug-tree.c +2 -3
index e46500d..4468297 100644
@@ -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);
 }
btrfs-find-root.c +0 -1
index b24dddf..571c86a 100644
@@ -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"
btrfs-image.c +0 -1
index 1257966..74681ba 100644
@@ -33,7 +33,6 @@
 #include "disk-io.h"
 #include "transaction.h"
 #include "utils.h"
-#include "version.h"
 #include "volumes.h"
 #include "extent_io.h"
 
btrfs-map-logical.c +0 -1
index c34484f..fc4a29b 100644
@@ -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
btrfs-select-super.c +1 -2
index 54ac436..492d38d 100644
@@ -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);
 }
 
btrfs-show-super.c +1 -2
index 9702eb0..15b9e36 100644
@@ -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)
btrfs-zero-log.c +1 -2
index 411fae3..0859fe2 100644
@@ -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);
 }
 
btrfs.c +1 -2
index 2451885..f0fa848 100644
@@ -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;
 }
 
btrfstune.c +0 -1
index 899a721..65513f6 100644
@@ -30,7 +30,6 @@
 #include "disk-io.h"
 #include "transaction.h"
 #include "utils.h"
-#include "version.h"
 
 static char *device;
 
chunk-recover.c +0 -1
index 688a7d7..c76b1b2 100644
@@ -37,7 +37,6 @@
 #include "transaction.h"
 #include "crc32c.h"
 #include "utils.h"
-#include "version.h"
 #include "btrfsck.h"
 #include "commands.h"
 
cmds-check.c +1 -2
index 0894cf0..87cb6e2 100644
@@ -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:
cmds-filesystem.c +2 -3
index 253f105..85a3897 100644
@@ -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);
 
cmds-restore.c +0 -1
index a5c99e8..27df3d8 100644
@@ -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"
library-test.c +0 -1
index 142188a..d23f4a7 100644
@@ -17,7 +17,6 @@
  */
 
 #include "kerncompat.h"
-#include "version.h"
 #include "send-stream.h"
 
 /*
mkfs.c +4 -5
index d5d03fc..dc87273 100644
@@ -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--;
 
Signature · 1 line
1.9.3
author
#4 lore raw

PATCH 4/10 btrfs-progs: use ./configure to generate version.h

In reply to Karel Zak

The original homemade solution is unnecessary, autotools provides better infrastructure to generate files.

---
 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
Makefile.in +0 -4
index 0dd83ea..dad1685 100644
@@ -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) \
configure.ac +9 -0
index 7a6c264..937d50f 100644
@@ -3,6 +3,10 @@ AC_INIT([btrfs-progs],
 	[[email protected]],,
 	[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
version.h.in new file +11 -0
new file mode 100644
index 0000000..012d265
@@ -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
version.sh +3 -27
index 456853c..42b47c4 100755
@@ -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
Signature · 1 line
1.9.3
author
#5 lore raw

PATCH 5/10 btrfs-progs: check for build programs in ./configure

In reply to Karel Zak
---
 Makefile.in  | 12 ++++++------
 configure.ac |  2 ++
 2 files changed, 8 insertions(+), 6 deletions(-)
Makefile.in +6 -6
index dad1685..17eea58 100644
@@ -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))
configure.ac +2 -0
index 937d50f..662d9ff 100644
@@ -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])])
Signature · 1 line
1.9.3
author
#6 lore raw

PATCH 6/10 btrfs-progs: use paths and $*_LIBS from ./configure

In reply to Karel Zak
---
 Makefile.in | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
Makefile.in +5 -5
index 17eea58..df590ab 100644
@@ -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")
Signature · 1 line
1.9.3
author
#7 lore raw

PATCH 7/10 btrfs-progs: cleanup compilation flags usage

In reply to 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

---
 Makefile.in  | 67 +++++++++++++++++++++++++++++++++++-------------------------
 configure.ac |  2 ++
 2 files changed, 41 insertions(+), 28 deletions(-)
Makefile.in +39 -28
index df590ab..58200ca 100644
@@ -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) [email protected] $(LDFLAGS) $(LIBS) $($(subst -,_,$@-libs))
+	$(Q)$(CC) $(CFLAGS) -o $@ $(objects) [email protected] $(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)
configure.ac +2 -0
index 662d9ff..f6adefb 100644
@@ -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])
Signature · 1 line
1.9.3
author
#8 lore raw

PATCH 8/10 btrfs-progs: clean generated files, make version.h stuff more robust

In reply to Karel Zak

- add rule to generated version.h when any relevant stuff changed
- add rule to clean generated files on "make clean-all"

---
 Makefile.in | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
Makefile.in +12 -2
index 58200ca..df752d3 100644
@@ -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
Signature · 1 line
1.9.3
author
#9 lore raw

PATCH 9/10 btrfs-progs: add --disable-backtrace

In reply to Karel Zak

It's better to use ./configure than manually edit Makefile.

---
 Makefile.in  |  4 ----
 configure.ac | 10 ++++++++++
 2 files changed, 10 insertions(+), 4 deletions(-)
Makefile.in +0 -4
index df752d3..bdd7683 100644
@@ -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
configure.ac +10 -0
index f6adefb..290d022 100644
@@ -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
Signature · 1 line
1.9.3
author
#10 lore raw

PATCH 10/10 btrfs-progs: add --disable-documentation

In reply to Karel Zak
---
 Makefile.in  | 1 +
 configure.ac | 9 +++++++++
 2 files changed, 10 insertions(+)
Makefile.in +1 -0
index bdd7683..5889224 100644
@@ -5,6 +5,7 @@ CC = @CC@
 LN_S = @LN_S@
 AR = @AR@
 INSTALL = @INSTALL@
+DISABLE_DOCUMENTATION = @DISABLE_DOCUMENTATION@
 
 # Non-static compilation flags
 CFLAGS = @CFLAGS@ \
configure.ac +9 -0
index 290d022..79cb591 100644
@@ -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
Signature · 1 line
1.9.3
#11 lore raw
In reply to Karel Zak
Quoted 3 lines · Karel Zak

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.

Quoted 4 lines

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) [email protected] $(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.

author
#12 lore raw
Quoted 9 lines · David Sterba
Quoted 3 lines · Karel Zak

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 :-)

Quoted 9 lines
Quoted 4 lines

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:

Quoted 7 lines

btrfs-%: $(objects) $(libs) btrfs-%.o

        @echo "    [LD]     $@"
        $(Q)$(CC) $(CFLAGS) -o $@ $(objects) [email protected] $(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

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
#13 lore raw
Quoted 11 lines · Karel Zak
Quoted 9 lines · David Sterba
Quoted 3 lines · Karel Zak

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.

Quoted 21 lines

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 :-)

Quoted 16 lines
Quoted 4 lines

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) [email protected] $(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...

Quoted 1 line

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 <[email protected]>
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...

Quoted 9 lines

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

#14 lore raw
In reply to Karel Zak

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Karel Zak schreef op 18-12-14 14:31:

Quoted 11 lines · David Sterba
Quoted 9 lines · Karel Zak
Quoted 3 lines

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.

Quoted 4 lines

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-----

author
#15 lore raw
In reply to David Sterba
Quoted 9 lines · David Sterba
Quoted 3 lines · Karel Zak

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 [email protected]:karelzak/btrfs-progs.git autoconf

Karel

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com
#16 lore raw
Quoted 6 lines · Karel Zak
Quoted 5 lines · David Sterba
Quoted 3 lines · Karel Zak

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.

Quoted 6 lines
Quoted 4 lines

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.

Quoted 5 lines

https://github.com/karelzak/btrfs-progs/commits/autoconf

you can merge it (now or later) on command line by:

    git pull --log [email protected]: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.

author
#17 lore raw
Quoted 4 lines · David Sterba

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.

Quoted 9 lines

* 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.

Quoted 8 lines
Quoted 5 lines

https://github.com/karelzak/btrfs-progs/commits/autoconf

you can merge it (now or later) on command line by:

    git pull --log [email protected]: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.

Quoted 3 lines

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

Signature · 2 lines
 Karel Zak  <[email protected]>
 http://karelzak.blogspot.com