This version now uses autotools to configure the build system. They are also using the newly added zlib package. Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> Tested-by: Koen Vandeputte <koen.vandeputte@ncentric.com>master
parent
bf167f8a9a
commit
c7cd166479
@ -1,25 +0,0 @@ |
||||
From 9a06f45ec71116d76ee4b268ebe1b33d45b06fc0 Mon Sep 17 00:00:00 2001
|
||||
From: Mike Frysinger <vapier@gentoo.org>
|
||||
Date: Sat, 16 Apr 2016 22:10:43 -0400
|
||||
Subject: [PATCH mtd-utils] include sys/sysmacros.h for major/minor/makedev
|
||||
|
||||
These functions have always been defined in sys/sysmacros.h under
|
||||
Linux C libraries. For some, including sys/types.h implicitly
|
||||
includes that as well, but glibc wants to deprecate that, and some
|
||||
others already have. Include the header explicitly for the funcs.
|
||||
|
||||
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
|
||||
---
|
||||
include/common.h | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
--- a/include/common.h
|
||||
+++ b/include/common.h
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <inttypes.h>
|
||||
+#include <sys/sysmacros.h>
|
||||
#include "version.h"
|
||||
|
||||
#ifndef PROGRAM_NAME
|
@ -1,119 +0,0 @@ |
||||
--- a/mkfs.ubifs/compr.c
|
||||
+++ b/mkfs.ubifs/compr.c
|
||||
@@ -24,7 +24,6 @@
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
-#include <lzo/lzo1x.h>
|
||||
#include <linux/types.h>
|
||||
|
||||
#define crc32 __zlib_crc32
|
||||
@@ -34,7 +33,6 @@
|
||||
#include "compr.h"
|
||||
#include "mkfs.ubifs.h"
|
||||
|
||||
-static void *lzo_mem;
|
||||
static unsigned long long errcnt = 0;
|
||||
static struct ubifs_info *c = &info_;
|
||||
|
||||
@@ -85,6 +83,25 @@ static int zlib_deflate(void *in_buf, si
|
||||
return 0;
|
||||
}
|
||||
|
||||
+#ifndef WITHOUT_LZO
|
||||
+#include <lzo/lzo1x.h>
|
||||
+
|
||||
+static void *lzo_mem;
|
||||
+
|
||||
+static int lzo_init(void)
|
||||
+{
|
||||
+ lzo_mem = malloc(LZO1X_999_MEM_COMPRESS);
|
||||
+ if (!lzo_mem)
|
||||
+ return -1;
|
||||
+
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static void lzo_fini(void)
|
||||
+{
|
||||
+ free(lzo_mem);
|
||||
+}
|
||||
+
|
||||
static int lzo_compress(void *in_buf, size_t in_len, void *out_buf,
|
||||
size_t *out_len)
|
||||
{
|
||||
@@ -102,6 +119,12 @@ static int lzo_compress(void *in_buf, si
|
||||
|
||||
return 0;
|
||||
}
|
||||
+#else
|
||||
+static inline int lzo_compress(void *in_buf, size_t in_len, void *out_buf,
|
||||
+ size_t *out_len) { return -1; }
|
||||
+static inline int lzo_init(void) { return 0; }
|
||||
+static inline void lzo_fini(void) { }
|
||||
+#endif
|
||||
|
||||
static int no_compress(void *in_buf, size_t in_len, void *out_buf,
|
||||
size_t *out_len)
|
||||
@@ -122,7 +145,6 @@ static int favor_lzo_compress(void *in_b
|
||||
lzo_len = zlib_len = *out_len;
|
||||
lzo_ret = lzo_compress(in_buf, in_len, out_buf, &lzo_len);
|
||||
zlib_ret = zlib_deflate(in_buf, in_len, zlib_buf, &zlib_len);
|
||||
-
|
||||
if (lzo_ret && zlib_ret)
|
||||
/* Both compressors failed */
|
||||
return -1;
|
||||
@@ -197,23 +219,28 @@ int compress_data(void *in_buf, size_t i
|
||||
|
||||
int init_compression(void)
|
||||
{
|
||||
- lzo_mem = malloc(LZO1X_999_MEM_COMPRESS);
|
||||
- if (!lzo_mem)
|
||||
- return -1;
|
||||
+ int ret;
|
||||
+
|
||||
+ ret = lzo_init();
|
||||
+ if (ret)
|
||||
+ goto err;
|
||||
|
||||
zlib_buf = malloc(UBIFS_BLOCK_SIZE * WORST_COMPR_FACTOR);
|
||||
- if (!zlib_buf) {
|
||||
- free(lzo_mem);
|
||||
- return -1;
|
||||
- }
|
||||
+ if (!zlib_buf)
|
||||
+ goto err_lzo;
|
||||
|
||||
return 0;
|
||||
+
|
||||
+err_lzo:
|
||||
+ lzo_fini();
|
||||
+err:
|
||||
+ return ret;
|
||||
}
|
||||
|
||||
void destroy_compression(void)
|
||||
{
|
||||
free(zlib_buf);
|
||||
- free(lzo_mem);
|
||||
+ lzo_fini();
|
||||
if (errcnt)
|
||||
fprintf(stderr, "%llu compression errors occurred\n", errcnt);
|
||||
}
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -108,7 +108,13 @@ $(call _mkdep,lib/,libmtd.a)
|
||||
obj-mkfs.ubifs = crc16.o lpt.o compr.o devtable.o \
|
||||
hashtable/hashtable.o hashtable/hashtable_itr.o
|
||||
LDFLAGS_mkfs.ubifs = $(ZLIBLDFLAGS) $(LZOLDFLAGS) $(UUIDLDFLAGS)
|
||||
-LDLIBS_mkfs.ubifs = -lz -llzo2 -lm -luuid
|
||||
+ifeq ($(WITHOUT_LZO), 1)
|
||||
+ CPPFLAGS += -DWITHOUT_LZO
|
||||
+else
|
||||
+ LZOLDLIBS = -llzo2
|
||||
+endif
|
||||
+
|
||||
+LDLIBS_mkfs.ubifs = -lz $(LZOLDLIBS) -lm -luuid
|
||||
$(call mkdep,mkfs.ubifs/,mkfs.ubifs,,ubi-utils/libubi.a)
|
||||
|
||||
#
|
@ -1,43 +0,0 @@ |
||||
--- a/common.mk
|
||||
+++ b/common.mk
|
||||
@@ -2,6 +2,16 @@ CC := $(CROSS)gcc
|
||||
AR := $(CROSS)ar
|
||||
RANLIB := $(CROSS)ranlib
|
||||
|
||||
+ifeq ($(STATIC),1)
|
||||
+ define static_link
|
||||
+ -Wl,-Bstatic $(1) -Wl,-Bdynamic
|
||||
+ endef
|
||||
+else
|
||||
+ define static_link
|
||||
+ $(1)
|
||||
+ endef
|
||||
+endif
|
||||
+
|
||||
# Stolen from Linux build system
|
||||
comma = ,
|
||||
try-run = $(shell set -e; ($(1)) >/dev/null 2>&1 && echo "$(2)" || echo "$(3)")
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -89,10 +89,10 @@ obj-mkfs.jffs2 = compr_rtime.o compr_zli
|
||||
compr_lzma.o lzma/LzFind.o lzma/LzmaEnc.o lzma/LzmaDec.o \
|
||||
compr.o rbtree.o
|
||||
LDFLAGS_mkfs.jffs2 = $(ZLIBLDFLAGS) $(LZOLDFLAGS)
|
||||
-LDLIBS_mkfs.jffs2 = -lz $(LZOLDLIBS)
|
||||
+LDLIBS_mkfs.jffs2 = $(call static_link,-lz $(LZOLDLIBS))
|
||||
|
||||
LDFLAGS_jffs2reader = $(ZLIBLDFLAGS) $(LZOLDFLAGS)
|
||||
-LDLIBS_jffs2reader = -lz $(LZOLDLIBS)
|
||||
+LDLIBS_jffs2reader = $(call static_link,-lz $(LZOLDLIBS))
|
||||
|
||||
$(foreach v,$(MTD_BINS),$(eval $(call mkdep,,$(v))))
|
||||
|
||||
@@ -114,7 +114,7 @@ else
|
||||
LZOLDLIBS = -llzo2
|
||||
endif
|
||||
|
||||
-LDLIBS_mkfs.ubifs = -lz $(LZOLDLIBS) -lm -luuid
|
||||
+LDLIBS_mkfs.ubifs = $(call static_link,-lz $(LZOLDLIBS)) -lm $(call static_link,-luuid)
|
||||
$(call mkdep,mkfs.ubifs/,mkfs.ubifs,,ubi-utils/libubi.a)
|
||||
|
||||
#
|
Loading…
Reference in new issue