Skip to contentSkip to conversation

erofs-utils: introduce --with-lz4-include and --with-lz4-lib

PATCH Superseded Gao Xiang 2 participants 12 messages Dec 19, 2018 – Dec 20, 2018 Kbuild

lore
Share & tools
lore

Gao Xiang

author
#0 lore raw

PATCH 1/2 erofs-utils: introduce --with-lz4-include and --with-lz4-lib

Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
---
 Makefile.am  |  1 -
 configure.ac | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 61 insertions(+), 11 deletions(-)
Makefile.am +0 -1
index b3dc472..cef847d 100644
@@ -26,7 +26,6 @@ noinst_HEADERS = erofs_config.h  \
 
 mkfs_erofs_CFLAGS = -Wall -Werror -DEROFS_MKFS_VERSION=\"v1.0\"
 mkfs_erofs_LDFLAGS  = --static
-mkfs_erofs_LDADD   = $(LIBLZ4_STATIC)
 ACLOCAL_AMFLAGS = -I m4
 
 if SUPPORT_LARG_FILE_AT_BIT32
configure.ac +61 -10

93 lines not on this page · raw message

Signature · 1 line
2.14.4
author
#1 lore raw

PATCH 2/2 erofs-utils: let erofs-utils use shared libraries if it can

As an option, add LDFLAGS=--static LIBS=-Wl,--static in front of ./configure to force static compilation as before.

ex,

$ LDFLAGS=--static LIBS=-Wl,--static ./configure
$ make
Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
---
 Makefile.am | 1 -
 1 file changed, 1 deletion(-)
Makefile.am +0 -1
index cef847d..4381d3d 100644
@@ -25,7 +25,6 @@ noinst_HEADERS = erofs_config.h  \
 				 mkfs_file.h
 
 mkfs_erofs_CFLAGS = -Wall -Werror -DEROFS_MKFS_VERSION=\"v1.0\"
-mkfs_erofs_LDFLAGS  = --static
 ACLOCAL_AMFLAGS = -I m4
 
 if SUPPORT_LARG_FILE_AT_BIT32
Signature · 1 line
2.14.4
author
#2 lore raw

PATCH v2 1/5 erofs-utils: introduce --with-lz4-include and --with-lz4-lib

In reply to Gao Xiang
Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>

---
v1 -> v2:
- clean up configure.ac further.
- refine commit messages.

 Makefile.am  |  1 -
 configure.ac | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 61 insertions(+), 11 deletions(-)
Makefile.am +0 -1
index b3dc472..cef847d 100644
@@ -26,7 +26,6 @@ noinst_HEADERS = erofs_config.h  \
 
 mkfs_erofs_CFLAGS = -Wall -Werror -DEROFS_MKFS_VERSION=\"v1.0\"
 mkfs_erofs_LDFLAGS  = --static
-mkfs_erofs_LDADD   = $(LIBLZ4_STATIC)
 ACLOCAL_AMFLAGS = -I m4
 
 if SUPPORT_LARG_FILE_AT_BIT32
configure.ac +61 -10

93 lines not on this page · raw message

Signature · 1 line
2.14.4
author
#3 lore raw

PATCH v2 2/5 erofs-utils: let erofs-utils use shared libraries if it can

As an option, add LDFLAGS=--static LIBS=-Wl,--static in front of ./configure to force static compilation as before.
ex, (force static compilation)

 $ LDFLAGS=--static LIBS=-Wl,--static ./configure
 $ make
Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
---
 Makefile.am | 1 -
 1 file changed, 1 deletion(-)
Makefile.am +0 -1
index cef847d..4381d3d 100644
@@ -25,7 +25,6 @@ noinst_HEADERS = erofs_config.h  \
 				 mkfs_file.h
 
 mkfs_erofs_CFLAGS = -Wall -Werror -DEROFS_MKFS_VERSION=\"v1.0\"
-mkfs_erofs_LDFLAGS  = --static
 ACLOCAL_AMFLAGS = -I m4
 
 if SUPPORT_LARG_FILE_AT_BIT32
Signature · 1 line
2.14.4
#4 lore raw

PATCH v2 2/5 erofs-utils: let erofs-utils use shared libraries if it can

Quoted 17 lines · Gao Xiang

As an option, add LDFLAGS=--static LIBS=-Wl,--static in front of ./configure to force static compilation as before.
ex, (force static compilation)

 $ LDFLAGS=--static LIBS=-Wl,--static ./configure
 $ make
Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
---
 Makefile.am | 1 -
 1 file changed, 1 deletion(-)
Makefile.am +0 -0
index cef847d..4381d3d 100644

Makefile.am noinst_HEADERS = erofs_config.h \ · line 30

Quoted 7 lines
Makefile.am +0 -1
@@ -25,7 +25,6 @@ noinst_HEADERS = erofs_config.h  \
 				 mkfs_file.h
 
 mkfs_erofs_CFLAGS = -Wall -Werror -DEROFS_MKFS_VERSION=\"v1.0\"
-mkfs_erofs_LDFLAGS  = --static
 ACLOCAL_AMFLAGS = -I m4
 
 if SUPPORT_LARG_FILE_AT_BIT32
Reviewed-by Li Guifu <bluce.liguifu at huawei.com>

Thanks,

author
#5 lore raw

PATCH v2 3/5 erofs-utils: silence `Consider adding 'AC_CONFIG_MACRO_DIRS([m4])' to configure.ac'

In reply to Gao Xiang
Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
---
 configure.ac | 1 +
 1 file changed, 1 insertion(+)
configure.ac +1 -0
index 4529576..858ae25 100644
@@ -3,6 +3,7 @@
 
 AC_PREREQ([2.69])
 AC_INIT([mkfs.erofs], [0.0.1], [bluce.liguifu at huawei.com])
+AC_CONFIG_MACRO_DIR([m4])
 AM_INIT_AUTOMAKE([foreign -Wall -Werror])
 AC_CONFIG_SRCDIR([mkfs_main.c])
 AC_CONFIG_HEADERS([config.h])
Signature · 1 line
2.14.4
#6 lore raw

PATCH v2 3/5 erofs-utils: silence `Consider adding 'AC_CONFIG_MACRO_DIRS([m4])' to configure.ac'

Quoted 10 lines · Gao Xiang
Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
---
 configure.ac | 1 +
 1 file changed, 1 insertion(+)
configure.ac +0 -0
index 4529576..858ae25 100644

configure.ac line 9

Quoted 7 lines
configure.ac +1 -0
@@ -3,6 +3,7 @@
 
 AC_PREREQ([2.69])
 AC_INIT([mkfs.erofs], [0.0.1], [bluce.liguifu at huawei.com])
+AC_CONFIG_MACRO_DIR([m4])
 AM_INIT_AUTOMAKE([foreign -Wall -Werror])
 AC_CONFIG_SRCDIR([mkfs_main.c])
 AC_CONFIG_HEADERS([config.h])
Reviewed-by Li Guifu <bluce.liguifu at huawei.com>

Thanks,

author
#7 lore raw

PATCH v2 4/5 erofs-utils: add autogen.sh

In reply to Gao Xiang

In order to avoid type too many commands by hand.

Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
---
 README     | 2 +-
 autogen.sh | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)
 create mode 100755 autogen.sh
README +1 -1
index 79a1126..4e34159 100644
@@ -22,7 +22,7 @@ How to build with lz4 static library
 eg. if lz4 lib has been installed into fold of /usr/local/lib
 	./configure --with-lz4=/usr/local/lib && make
 Maybe you should run this first:
-	libtoolize && aclocal && autoconf && autoheader && automake --add-missing
+	./autogen.sh
 
 Usage:
 $ ./mkfs.erofs
autogen.sh new file +8 -0
new file mode 100755
index 0000000..117f4bd
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+aclocal && \
+autoheader && \
+autoconf && \
+libtoolize && \
+automake -a -c
+
Signature · 1 line
2.14.4
#8 lore raw

PATCH v2 4/5 erofs-utils: add autogen.sh

Quoted 28 lines · Gao Xiang

In order to avoid type too many commands by hand.

Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
---
 README     | 2 +-
 autogen.sh | 8 ++++++++
 2 files changed, 9 insertions(+), 1 deletion(-)
 create mode 100755 autogen.sh
README +1 -1
index 79a1126..4e34159 100644
@@ -22,7 +22,7 @@ How to build with lz4 static library
 eg. if lz4 lib has been installed into fold of /usr/local/lib
 	./configure --with-lz4=/usr/local/lib && make
 Maybe you should run this first:
-	libtoolize && aclocal && autoconf && autoheader && automake --add-missing
+	./autogen.sh
 
 Usage:
 $ ./mkfs.erofs
autogen.sh new file +0 -0
new file mode 100755
index 0000000..117f4bd

autogen.sh line 8

Quoted 8 lines
autogen.sh new file +8 -0
@@ -0,0 +1,8 @@
+#!/bin/sh
+
+aclocal && \
+autoheader && \
+autoconf && \
+libtoolize && \
+automake -a -c
+
Reviewed-by Li Guifu <bluce.liguifu at huawei.com>

Thanks,

author
#9 lore raw

PATCH v2 5/5 erofs-utils: add AC_CONFIG_AUX_DIR(config)

In reply to Gao Xiang
Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
---
 .gitignore   | 9 +--------
 configure.ac | 1 +
 2 files changed, 2 insertions(+), 8 deletions(-)
.gitignore +1 -8
index 7e0a1cf..3cebe03 100644
@@ -28,17 +28,10 @@ TAGS
 .deps/
 Makefile.in
 aclocal.m4
-compile
-config.guess
 config.h
 config.h.in
-config.sub
 configure
-depcomp
-install-sh
 libtool
-ltmain.sh
 m4/
-missing
 stamp-h1
-
+config/
configure.ac +1 -0
index 858ae25..345e8ba 100644
@@ -4,6 +4,7 @@
 AC_PREREQ([2.69])
 AC_INIT([mkfs.erofs], [0.0.1], [bluce.liguifu at huawei.com])
 AC_CONFIG_MACRO_DIR([m4])
+AC_CONFIG_AUX_DIR(config)
 AM_INIT_AUTOMAKE([foreign -Wall -Werror])
 AC_CONFIG_SRCDIR([mkfs_main.c])
 AC_CONFIG_HEADERS([config.h])
Signature · 1 line
2.14.4
#10 lore raw

PATCH v2 5/5 erofs-utils: add AC_CONFIG_AUX_DIR(config)

Quoted 34 lines · Gao Xiang
Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>
---
 .gitignore   | 9 +--------
 configure.ac | 1 +
 2 files changed, 2 insertions(+), 8 deletions(-)
.gitignore +1 -8
index 7e0a1cf..3cebe03 100644
@@ -28,17 +28,10 @@ TAGS
 .deps/
 Makefile.in
 aclocal.m4
-compile
-config.guess
 config.h
 config.h.in
-config.sub
 configure
-depcomp
-install-sh
 libtool
-ltmain.sh
 m4/
-missing
 stamp-h1
-
+config/
configure.ac +0 -0
index 858ae25..345e8ba 100644

configure.ac line 10

Quoted 7 lines
configure.ac +1 -0
@@ -4,6 +4,7 @@
 AC_PREREQ([2.69])
 AC_INIT([mkfs.erofs], [0.0.1], [bluce.liguifu at huawei.com])
 AC_CONFIG_MACRO_DIR([m4])
+AC_CONFIG_AUX_DIR(config)
 AM_INIT_AUTOMAKE([foreign -Wall -Werror])
 AC_CONFIG_SRCDIR([mkfs_main.c])
 AC_CONFIG_HEADERS([config.h])
Reviewed-by Li Guifu <bluce.liguifu at huawei.com>

Thanks,

#11 lore raw

PATCH v2 1/5 erofs-utils: introduce --with-lz4-include and --with-lz4-lib

In reply to Gao Xiang
Quoted 111 lines · Gao Xiang
Signed-off-by Gao Xiang <gaoxiang25 at huawei.com>

---
v1 -> v2:
- clean up configure.ac further.
- refine commit messages.

 Makefile.am  |  1 -
 configure.ac | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++---------
 2 files changed, 61 insertions(+), 11 deletions(-)
Makefile.am +0 -1
index b3dc472..cef847d 100644
@@ -26,7 +26,6 @@ noinst_HEADERS = erofs_config.h  \
 
 mkfs_erofs_CFLAGS = -Wall -Werror -DEROFS_MKFS_VERSION=\"v1.0\"
 mkfs_erofs_LDFLAGS  = --static
-mkfs_erofs_LDADD   = $(LIBLZ4_STATIC)
 ACLOCAL_AMFLAGS = -I m4
 
 if SUPPORT_LARG_FILE_AT_BIT32
configure.ac +53 -10
index 15974f8..4529576 100644
@@ -12,27 +12,70 @@ AC_PROG_CC
 AC_PROG_INSTALL
 AC_PROG_LIBTOOL
 
+dnl EROFS_UTILS_PARSE_DIRECTORY
+dnl Input:  $1 = a string to a relative or absolute directory
+dnl Output: $2 = the variable to set with the absolute directory
+AC_DEFUN([EROFS_UTILS_PARSE_DIRECTORY],
+[
+ dnl Check if argument is a directory
+ if test -d $1 ; then
+    dnl Get the absolute path of the directory
+    dnl in case of relative directory.
+    dnl If realpath is not a valid command,
+    dnl an error is produced and we keep the given path.
+    local_tmp=`realpath $1 2>/dev/null`
+    if test "$local_tmp" != "" ; then
+       if test -d "$local_tmp" ; then
+           $2="$local_tmp"
+       else
+           $2=$1
+       fi
+    else
+       $2=$1
+    fi
+    dnl Check for space in the directory
+    if test `echo $1|cut -d' ' -f1` != $1 ; then
+        AC_MSG_ERROR($1 directory shall not contain any space.)
+    fi
+ else
+    AC_MSG_ERROR($1 shall be a valid directory)
+ fi
+])
 
 # checks system architecture firtly for enable support larg file
 ARCH_BIT=`getconf LONG_BIT`
 AM_CONDITIONAL([SUPPORT_LARG_FILE_AT_BIT32],[test x$ARCH_BIT = x32])
 
 # Checks for libraries.
-# Ask user for path to liblz4.a stuff:.
-AC_ARG_WITH(lz4,
-    [ --with-lz4=<path> prefix of liblz4.a installation. e.g. /usr/local or /usr],
-    [LIBLZ4_STATIC=$with_lz4/liblz4.a],
-    AC_MSG_ERROR([You must call configure with the --with-lz4 option.
-    This tells configure where to find the MySql C library and headers.
-    e.g. --with-lz4=/usr/local or --with-lz4=/usr])
-)
+# Ask user for LZ4 library path if needed.
+
+AC_ARG_WITH(lz4_include,
+   [  --with-lz4-include=DIR  LZ4 include directory ],
+   EROFS_UTILS_PARSE_DIRECTORY(["$withval"],[withval])
+   CPPFLAGS="$CPPFLAGS -I$withval")
+
+AC_ARG_WITH(lz4_lib,
+   [  --with-lz4-lib=DIR      LZ4 lib directory ], [
+   EROFS_UTILS_PARSE_DIRECTORY(["$withval"],[withval])
+   LDFLAGS="$LDFLAGS -L$withval"
+   lz4_lib_path="$withval"
+  ])
 
-AC_SUBST(LIBLZ4_STATIC)
+AC_ARG_WITH(lz4,
+   [  --with-lz4=DIR          LZ4 install directory, e.g. /usr/local or /usr ], [
+   EROFS_UTILS_PARSE_DIRECTORY(["$withval"],[withval])
+   if test -z "$with_gmp_lib" && test -z "$with_gmp_include" ; then
+      CPPFLAGS="$CPPFLAGS -I$withval/include"
+      LDFLAGS="$LDFLAGS -L$withval/lib"
+      lz4_lib_path="$withval/lib"
+   else
+      AC_MSG_FAILURE([Do not use --with-lz4 and --with-lz4-include/--with-lz4-lib options simultaneously.])
+   fi
+  ])
 
 # Checks for header files.
 AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stddef.h stdint.h stdlib.h string.h sys/time.h unistd.h])
 
-
 # Checks for typedefs, structures, and compiler characteristics.
 AC_C_INLINE
 AC_TYPE_INT64_T
@@ -45,5 +88,13 @@ AC_TYPE_UINT64_T
 AC_FUNC_MALLOC
 AC_CHECK_FUNCS([ftruncate getcwd gettimeofday memset realpath strdup strerror strrchr strtoull])
 

configure.ac AC_TYPE_UINT64_T · line 100

Quoted 10 lines
configure.ac +8 -0
+# Configure lz4.
+have_lz4="1"
+AC_CHECK_HEADERS([lz4.h], , [have_lz4="0"])
+AC_CHECK_LIB(lz4, LZ4_versionNumber, [LIBS="-Wl,-Bstatic,-llz4,-Bdynamic $LIBS"] , [have_lz4="0"])
+if test "x${have_lz4}" = "x0" ; then
+  AC_MSG_ERROR([Cannot build without lz4])
+fi
+
 AC_CONFIG_FILES([Makefile])
 AC_OUTPUT
Reviewed-by Li Guifu <bluce.liguifu at huawei.com>

Thanks,