diff mbox

[1/6] jffs2: make lzo optional at build time

Message ID 1307427548-29306-1-git-send-email-vapier@gentoo.org
State Accepted, archived
Commit 811e2e742e64cdc4bfb9519c0d0db53ac75aa4ce
Headers show

Commit Message

Mike Frysinger June 7, 2011, 6:19 a.m. UTC
The external lzo dep can be a pain to deal with when cross-compiling,
so make it optional for jffs2.  This is useful if people aren't even
using the functionality, or for quicker development.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
---
 Makefile    |    9 +++++++--
 compr_lzo.c |   15 +++++++++++++++
 2 files changed, 22 insertions(+), 2 deletions(-)

Comments

Artem Bityutskiy June 7, 2011, 6:34 a.m. UTC | #1
On Tue, 2011-06-07 at 02:19 -0400, Mike Frysinger wrote:
> The external lzo dep can be a pain to deal with when cross-compiling,
> so make it optional for jffs2.  This is useful if people aren't even
> using the functionality, or for quicker development.
> 
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>

How about mkfs.ubifs - it requires lzo as well. And then mkfs.jffs2
wants libacl which might be the same PITA.
Mike Frysinger June 7, 2011, 6:59 a.m. UTC | #2
On Tue, Jun 7, 2011 at 02:34, Artem Bityutskiy wrote:
> On Tue, 2011-06-07 at 02:19 -0400, Mike Frysinger wrote:
>> The external lzo dep can be a pain to deal with when cross-compiling,
>> so make it optional for jffs2.  This is useful if people aren't even
>> using the functionality, or for quicker development.
>
> How about mkfs.ubifs - it requires lzo as well. And then mkfs.jffs2
> wants libacl which might be the same PITA.

libacl already has a knob.  i didnt bother with mkfs.ubifs because it
additionally requires libuuid which comes from util-linux.  also, it
seemed like lzo is the only compression supported by UBI, so making it
optional didnt seem like it'd result in anything useful.  at least
jffs2 can operate without it by using other compression schemes.
-mike
Artem Bityutskiy June 7, 2011, 7:16 a.m. UTC | #3
On Tue, 2011-06-07 at 02:19 -0400, Mike Frysinger wrote:
> +
> +#else
> +
> +int jffs2_lzo_init(void)
> +{
> +	return 0;
> +}

This function should return -1, I think, so that mkfs.jffs2 would fail
if lzo was not compiled-in.
Artem Bityutskiy June 7, 2011, 7:20 a.m. UTC | #4
On Tue, 2011-06-07 at 02:59 -0400, Mike Frysinger wrote:
> On Tue, Jun 7, 2011 at 02:34, Artem Bityutskiy wrote:
> > On Tue, 2011-06-07 at 02:19 -0400, Mike Frysinger wrote:
> >> The external lzo dep can be a pain to deal with when cross-compiling,
> >> so make it optional for jffs2.  This is useful if people aren't even
> >> using the functionality, or for quicker development.
> >
> > How about mkfs.ubifs - it requires lzo as well. And then mkfs.jffs2
> > wants libacl which might be the same PITA.
> 
> libacl already has a knob.

OK.

>   i didnt bother with mkfs.ubifs because it
> additionally requires libuuid which comes from util-linux.

Yeah. The only reason for this is that it wants to generate an UUID for
the new file-system. We could just use pseudo-random numbers as a
work-around.

>   also, it
> seemed like lzo is the only compression supported by UBI, so making it
> optional didnt seem like it'd result in anything useful.

Not really, UBIFS currently supports lzo, zlib, and no compression. But
lzo is the default.

>   at least
> jffs2 can operate without it by using other compression schemes.

UBIFS as well.

But please, do not bother with UBIFS if you do not need this. Just
verify that mkfs.jffs2 fails if you have not compiled lzo and try to use
it. I mean, mkfs.jffs2 should not silently use zlib in this case.
Mike Frysinger June 7, 2011, 3:16 p.m. UTC | #5
On Tue, Jun 7, 2011 at 03:16, Artem Bityutskiy wrote:
> On Tue, 2011-06-07 at 02:19 -0400, Mike Frysinger wrote:
>> +int jffs2_lzo_init(void)
>> +{
>> +     return 0;
>> +}
>
> This function should return -1, I think, so that mkfs.jffs2 would fail
> if lzo was not compiled-in.

i didnt do that because the func is always called and i was afraid
that it'd prevent normal execution.  the runtime code should already
fail when lzo is requested because the compression routines are looked
up on the fly and when the requested compressor isnt found, it fails
at that time.  (at least that's my understanding of things)
-mike
Artem Bityutskiy June 8, 2011, 11:28 a.m. UTC | #6
On Tue, 2011-06-07 at 02:19 -0400, Mike Frysinger wrote:
> The external lzo dep can be a pain to deal with when cross-compiling,
> so make it optional for jffs2.  This is useful if people aren't even
> using the functionality, or for quicker development.
> 
> Signed-off-by: Mike Frysinger <vapier@gentoo.org>

Pushed to l2-mtd-2.6.git, thanks.
diff mbox

Patch

diff --git a/Makefile b/Makefile
index 6a65258..8bdba8e 100644
--- a/Makefile
+++ b/Makefile
@@ -6,6 +6,11 @@  CPPFLAGS += -I./include $(ZLIBCPPFLAGS) $(LZOCPPFLAGS)
 ifeq ($(WITHOUT_XATTR), 1)
   CPPFLAGS += -DWITHOUT_XATTR
 endif
+ifeq ($(WITHOUT_LZO), 1)
+  CPPFLAGS += -DWITHOUT_LZO
+else
+  LZOLDLIBS = -llzo2
+endif
 
 SUBDIRS = lib ubi-utils mkfs.ubifs
 TESTS = tests
@@ -48,11 +53,11 @@  $(BUILDDIR)/mkfs.jffs2: $(addprefix $(BUILDDIR)/,\
 	compr_rtime.o mkfs.jffs2.o compr_zlib.o compr_lzo.o \
 	compr.o rbtree.o)
 LDFLAGS_mkfs.jffs2 = $(ZLIBLDFLAGS) $(LZOLDFLAGS)
-LDLIBS_mkfs.jffs2  = -lz -llzo2
+LDLIBS_mkfs.jffs2  = -lz $(LZOLDLIBS)
 
 $(BUILDDIR)/jffs2reader: $(BUILDDIR)/jffs2reader.o
 LDFLAGS_jffs2reader = $(ZLIBLDFLAGS) $(LZOLDFLAGS)
-LDLIBS_jffs2reader  = -lz -llzo2
+LDLIBS_jffs2reader  = -lz $(LZOLDLIBS)
 
 $(BUILDDIR)/lib/libmtd.a: subdirs_lib_all ;
 
diff --git a/compr_lzo.c b/compr_lzo.c
index d0f0ed7..d2e2afc 100644
--- a/compr_lzo.c
+++ b/compr_lzo.c
@@ -24,6 +24,8 @@ 
 #include <stdint.h>
 #include <stdio.h>
 #include <string.h>
+
+#ifndef WITHOUT_LZO
 #include <asm/types.h>
 #include <linux/jffs2.h>
 #include <lzo/lzo1x.h>
@@ -118,3 +120,16 @@  void jffs2_lzo_exit(void)
 	free(lzo_compress_buf);
 	free(lzo_mem);
 }
+
+#else
+
+int jffs2_lzo_init(void)
+{
+	return 0;
+}
+
+void jffs2_lzo_exit(void)
+{
+}
+
+#endif