From 8aed1fcd443b550c15a21ddbf1b1d3899803120a Mon Sep 17 00:00:00 2001
From: Waldemar Brodkorb <wbx@openadk.org>
Date: Sun, 30 Mar 2014 15:55:20 +0200
Subject: rework hosttools building, add tools into package stuff

---
 package/mtd-utils/patches/patch-Makefile           | 65 ++++++++++++++++++++++
 package/mtd-utils/patches/patch-common_mk          | 11 ++++
 package/mtd-utils/patches/patch-compr_c            | 21 +++++++
 package/mtd-utils/patches/patch-compr_lzo_c        | 10 ++++
 package/mtd-utils/patches/patch-compr_zlib_c       | 10 ++++
 .../patches/patch-include_mtd_jffs2-user_h         | 16 ++++++
 .../mtd-utils/patches/patch-include_mtd_mtd-abi_h  | 14 +++++
 .../patches/patch-include_mtd_ubi-media_h          | 18 ++++++
 package/mtd-utils/patches/patch-lib_libfec_c       | 20 +++++++
 package/mtd-utils/patches/patch-lib_libmtd_c       | 38 +++++++++++++
 .../mtd-utils/patches/patch-lib_libmtd_legacy_c    | 11 ++++
 package/mtd-utils/patches/patch-mkfs_jffs2_c       | 15 +++++
 package/mtd-utils/patches/patch-rbtree_h           | 12 ++++
 13 files changed, 261 insertions(+)
 create mode 100644 package/mtd-utils/patches/patch-Makefile
 create mode 100644 package/mtd-utils/patches/patch-common_mk
 create mode 100644 package/mtd-utils/patches/patch-compr_c
 create mode 100644 package/mtd-utils/patches/patch-compr_lzo_c
 create mode 100644 package/mtd-utils/patches/patch-compr_zlib_c
 create mode 100644 package/mtd-utils/patches/patch-include_mtd_jffs2-user_h
 create mode 100644 package/mtd-utils/patches/patch-include_mtd_mtd-abi_h
 create mode 100644 package/mtd-utils/patches/patch-include_mtd_ubi-media_h
 create mode 100644 package/mtd-utils/patches/patch-lib_libfec_c
 create mode 100644 package/mtd-utils/patches/patch-lib_libmtd_c
 create mode 100644 package/mtd-utils/patches/patch-lib_libmtd_legacy_c
 create mode 100644 package/mtd-utils/patches/patch-mkfs_jffs2_c
 create mode 100644 package/mtd-utils/patches/patch-rbtree_h

(limited to 'package/mtd-utils/patches')

diff --git a/package/mtd-utils/patches/patch-Makefile b/package/mtd-utils/patches/patch-Makefile
new file mode 100644
index 000000000..53ed8640e
--- /dev/null
+++ b/package/mtd-utils/patches/patch-Makefile
@@ -0,0 +1,65 @@
+--- mtd-utils-1.5.0.orig/Makefile	2012-05-07 09:19:39.000000000 +0200
++++ mtd-utils-1.5.0/Makefile	2014-03-30 15:49:30.000000000 +0200
+@@ -16,27 +16,13 @@ endif
+ 
+ TESTS = tests
+ 
+-MTD_BINS = \
+-	ftl_format flash_erase nanddump doc_loadbios \
+-	ftl_check mkfs.jffs2 flash_lock flash_unlock \
+-	flash_otp_info flash_otp_dump mtd_debug flashcp nandwrite nandtest \
+-	jffs2dump \
+-	nftldump nftl_format docfdisk \
+-	rfddump rfdformat \
+-	serve_image recv_image \
+-	sumtool jffs2reader
+-UBI_BINS = \
+-	ubiupdatevol ubimkvol ubirmvol ubicrc32 ubinfo ubiattach \
+-	ubidetach ubinize ubiformat ubirename mtdinfo ubirsvol
++MTD_BINS = mkfs.jffs2
+ 
+ BINS = $(MTD_BINS)
+-BINS += mkfs.ubifs/mkfs.ubifs
+-BINS += $(addprefix ubi-utils/,$(UBI_BINS))
+ SCRIPTS = flash_eraseall
+ 
+ TARGETS = $(BINS)
+ TARGETS += lib/libmtd.a
+-TARGETS += ubi-utils/libubi.a
+ 
+ OBJDEPS = $(BUILDDIR)/include/version.h
+ 
+@@ -83,12 +69,12 @@ $(BUILDDIR)/include/version.h.tmp:
+ #
+ # Utils in top level
+ #
+-obj-mkfs.jffs2 = compr_rtime.o compr_zlib.o compr_lzo.o compr.o rbtree.o
+-LDFLAGS_mkfs.jffs2 = $(ZLIBLDFLAGS) $(LZOLDFLAGS)
+-LDLIBS_mkfs.jffs2  = -lz $(LZOLDLIBS)
++obj-mkfs.jffs2 = compr_rtime.o compr_zlib.o compr.o rbtree.o
++LDFLAGS_mkfs.jffs2 = $(ZLIBLDFLAGS)
++LDLIBS_mkfs.jffs2  = -lz
+ 
+-LDFLAGS_jffs2reader = $(ZLIBLDFLAGS) $(LZOLDFLAGS)
+-LDLIBS_jffs2reader  = -lz $(LZOLDLIBS)
++LDFLAGS_jffs2reader = $(ZLIBLDFLAGS)
++LDLIBS_jffs2reader  = -lz
+ 
+ $(foreach v,$(MTD_BINS),$(eval $(call mkdep,,$(v))))
+ 
+@@ -103,7 +89,7 @@ $(call _mkdep,lib/,libmtd.a)
+ #
+ obj-mkfs.ubifs = crc16.o lpt.o compr.o devtable.o \
+ 	hashtable/hashtable.o hashtable/hashtable_itr.o
+-LDLIBS_mkfs.ubifs = -lz -llzo2 -lm -luuid
++LDLIBS_mkfs.ubifs = -lz -lm -luuid
+ $(call mkdep,mkfs.ubifs/,mkfs.ubifs,,ubi-utils/libubi.a)
+ 
+ #
+@@ -117,6 +103,3 @@ obj-libubigen.a    = libubigen.o
+ obj-mtdinfo   = libubigen.a
+ obj-ubinize   = libubigen.a libiniparser.a
+ obj-ubiformat = libubigen.a libscan.a
+-
+-$(foreach v,libubi.a libubigen.a libiniparser.a libscan.a,$(eval $(call _mkdep,ubi-utils/,$(v))))
+-$(foreach v,$(UBI_BINS),$(eval $(call mkdep,ubi-utils/,$(v),libubi.a ubiutils-common.o)))
diff --git a/package/mtd-utils/patches/patch-common_mk b/package/mtd-utils/patches/patch-common_mk
new file mode 100644
index 000000000..6881db87e
--- /dev/null
+++ b/package/mtd-utils/patches/patch-common_mk
@@ -0,0 +1,11 @@
+--- mtd-utils-1.5.0.orig/common.mk	2012-05-07 09:19:39.000000000 +0200
++++ mtd-utils-1.5.0/common.mk	2014-03-30 15:49:26.000000000 +0200
+@@ -13,8 +13,6 @@ WFLAGS := -Wall \
+ 	$(call cc-option,-Wwrite-strings) \
+ 	$(call cc-option,-Wno-sign-compare)
+ CFLAGS += $(WFLAGS)
+-SECTION_CFLAGS := $(call cc-option,-ffunction-sections -fdata-sections -Wl$(comma)--gc-sections)
+-CFLAGS += $(SECTION_CFLAGS)
+ 
+ ifneq ($(WITHOUT_LARGEFILE), 1)
+   CPPFLAGS += -D_FILE_OFFSET_BITS=64
diff --git a/package/mtd-utils/patches/patch-compr_c b/package/mtd-utils/patches/patch-compr_c
new file mode 100644
index 000000000..c69e133b9
--- /dev/null
+++ b/package/mtd-utils/patches/patch-compr_c
@@ -0,0 +1,21 @@
+--- mtd-utils-1.5.0.orig/compr.c	2012-05-07 09:19:39.000000000 +0200
++++ mtd-utils-1.5.0/compr.c	2014-03-30 15:49:30.000000000 +0200
+@@ -517,9 +517,6 @@ int jffs2_compressors_init(void)
+ #ifdef CONFIG_JFFS2_RTIME
+ 	jffs2_rtime_init();
+ #endif
+-#ifdef CONFIG_JFFS2_LZO
+-	jffs2_lzo_init();
+-#endif
+ 	return 0;
+ }
+ 
+@@ -531,8 +528,5 @@ int jffs2_compressors_exit(void)
+ #ifdef CONFIG_JFFS2_ZLIB
+ 	jffs2_zlib_exit();
+ #endif
+-#ifdef CONFIG_JFFS2_LZO
+-	jffs2_lzo_exit();
+-#endif
+ 	return 0;
+ }
diff --git a/package/mtd-utils/patches/patch-compr_lzo_c b/package/mtd-utils/patches/patch-compr_lzo_c
new file mode 100644
index 000000000..98f235c5b
--- /dev/null
+++ b/package/mtd-utils/patches/patch-compr_lzo_c
@@ -0,0 +1,10 @@
+--- mtd-utils-1.5.0.orig/compr_lzo.c	2012-05-07 09:19:39.000000000 +0200
++++ mtd-utils-1.5.0/compr_lzo.c	2014-03-30 15:49:26.000000000 +0200
+@@ -26,7 +26,6 @@
+ #include <string.h>
+ 
+ #ifndef WITHOUT_LZO
+-#include <asm/types.h>
+ #include <linux/jffs2.h>
+ #include <lzo/lzo1x.h>
+ #include "compr.h"
diff --git a/package/mtd-utils/patches/patch-compr_zlib_c b/package/mtd-utils/patches/patch-compr_zlib_c
new file mode 100644
index 000000000..200bb55ce
--- /dev/null
+++ b/package/mtd-utils/patches/patch-compr_zlib_c
@@ -0,0 +1,10 @@
+--- mtd-utils-1.5.0.orig/compr_zlib.c	2012-05-07 09:19:39.000000000 +0200
++++ mtd-utils-1.5.0/compr_zlib.c	2014-03-30 15:49:26.000000000 +0200
+@@ -39,7 +39,6 @@
+ #include <zlib.h>
+ #undef crc32
+ #include <stdio.h>
+-#include <asm/types.h>
+ #include <linux/jffs2.h>
+ #include "common.h"
+ #include "compr.h"
diff --git a/package/mtd-utils/patches/patch-include_mtd_jffs2-user_h b/package/mtd-utils/patches/patch-include_mtd_jffs2-user_h
new file mode 100644
index 000000000..1373b66f2
--- /dev/null
+++ b/package/mtd-utils/patches/patch-include_mtd_jffs2-user_h
@@ -0,0 +1,16 @@
+--- mtd-utils-1.5.0.orig/include/mtd/jffs2-user.h	2012-05-07 09:19:39.000000000 +0200
++++ mtd-utils-1.5.0/include/mtd/jffs2-user.h	2014-03-30 15:49:26.000000000 +0200
+@@ -9,8 +9,13 @@
+ 
+ /* This file is blessed for inclusion by userspace */
+ #include <linux/jffs2.h>
++#if defined(__APPLE__)
++#include "endian.h"
++#include "byteswap.h"
++#else
+ #include <endian.h>
+ #include <byteswap.h>
++#endif
+ 
+ #undef cpu_to_je16
+ #undef cpu_to_je32
diff --git a/package/mtd-utils/patches/patch-include_mtd_mtd-abi_h b/package/mtd-utils/patches/patch-include_mtd_mtd-abi_h
new file mode 100644
index 000000000..9a95c4127
--- /dev/null
+++ b/package/mtd-utils/patches/patch-include_mtd_mtd-abi_h
@@ -0,0 +1,14 @@
+--- mtd-utils-1.5.0.orig/include/mtd/mtd-abi.h	2012-05-07 09:19:39.000000000 +0200
++++ mtd-utils-1.5.0/include/mtd/mtd-abi.h	2014-03-30 15:49:26.000000000 +0200
+@@ -171,9 +171,9 @@ struct otp_info {
+ /* Get info about OOB modes (e.g., RAW, PLACE, AUTO) - legacy interface */
+ #define MEMGETOOBSEL		_IOR('M', 10, struct nand_oobinfo)
+ /* Check if an eraseblock is bad */
+-#define MEMGETBADBLOCK		_IOW('M', 11, __kernel_loff_t)
++#define MEMGETBADBLOCK		_IOW('M', 11, off_t)
+ /* Mark an eraseblock as bad */
+-#define MEMSETBADBLOCK		_IOW('M', 12, __kernel_loff_t)
++#define MEMSETBADBLOCK		_IOW('M', 12, off_t)
+ /* Set OTP (One-Time Programmable) mode (factory vs. user) */
+ #define OTPSELECT		_IOR('M', 13, int)
+ /* Get number of OTP (One-Time Programmable) regions */
diff --git a/package/mtd-utils/patches/patch-include_mtd_ubi-media_h b/package/mtd-utils/patches/patch-include_mtd_ubi-media_h
new file mode 100644
index 000000000..33feabf92
--- /dev/null
+++ b/package/mtd-utils/patches/patch-include_mtd_ubi-media_h
@@ -0,0 +1,18 @@
+--- mtd-utils-1.5.0.orig/include/mtd/ubi-media.h	2012-05-07 09:19:39.000000000 +0200
++++ mtd-utils-1.5.0/include/mtd/ubi-media.h	2014-03-30 15:49:26.000000000 +0200
+@@ -30,7 +30,15 @@
+ #ifndef __UBI_MEDIA_H__
+ #define __UBI_MEDIA_H__
+ 
++#ifdef __linux__
+ #include <asm/byteorder.h>
++#else
++#include <stdint.h> 
++typedef uint8_t __u8; 
++typedef uint16_t __be16; 
++typedef uint32_t __be32; 
++typedef uint64_t __be64; 
++#endif
+ 
+ /* The version of UBI images supported by this implementation */
+ #define UBI_VERSION 1
diff --git a/package/mtd-utils/patches/patch-lib_libfec_c b/package/mtd-utils/patches/patch-lib_libfec_c
new file mode 100644
index 000000000..7b198d0fb
--- /dev/null
+++ b/package/mtd-utils/patches/patch-lib_libfec_c
@@ -0,0 +1,20 @@
+--- mtd-utils-1.5.0.orig/lib/libfec.c	2012-05-07 09:19:39.000000000 +0200
++++ mtd-utils-1.5.0/lib/libfec.c	2014-03-30 15:49:26.000000000 +0200
+@@ -61,8 +61,6 @@ struct timeval {
+ };
+ #define gettimeofday(x, dummy) { (x)->ticks = clock() ; }
+ #define DIFF_T(a,b) (1+ 1000000*(a.ticks - b.ticks) / CLOCKS_PER_SEC )
+-typedef unsigned long u_long ;
+-typedef unsigned short u_short ;
+ #else /* typically, unix systems */
+ #include <sys/time.h>
+ #define DIFF_T(a,b) \
+@@ -625,7 +623,7 @@ init_fec(void)
+ #define FEC_MAGIC	0xFECC0DEC
+ 
+ struct fec_parms {
+-    u_long magic ;
++    unsigned long magic ;
+     int k, n ;		/* parameters of the code */
+     gf *enc_matrix ;
+ } ;
diff --git a/package/mtd-utils/patches/patch-lib_libmtd_c b/package/mtd-utils/patches/patch-lib_libmtd_c
new file mode 100644
index 000000000..af0f9a837
--- /dev/null
+++ b/package/mtd-utils/patches/patch-lib_libmtd_c
@@ -0,0 +1,38 @@
+--- mtd-utils-1.5.0.orig/lib/libmtd.c	2012-05-07 09:19:39.000000000 +0200
++++ mtd-utils-1.5.0/lib/libmtd.c	2014-03-30 15:49:26.000000000 +0200
+@@ -1006,7 +1006,7 @@ out:
+ int mtd_is_bad(const struct mtd_dev_info *mtd, int fd, int eb)
+ {
+ 	int ret;
+-	loff_t seek;
++	off_t seek;
+ 
+ 	ret = mtd_valid_erase_block(mtd, eb);
+ 	if (ret)
+@@ -1015,7 +1015,7 @@ int mtd_is_bad(const struct mtd_dev_info
+ 	if (!mtd->bb_allowed)
+ 		return 0;
+ 
+-	seek = (loff_t)eb * mtd->eb_size;
++	seek = (off_t)eb * mtd->eb_size;
+ 	ret = ioctl(fd, MEMGETBADBLOCK, &seek);
+ 	if (ret == -1)
+ 		return mtd_ioctl_error(mtd, eb, "MEMGETBADBLOCK");
+@@ -1025,7 +1025,7 @@ int mtd_is_bad(const struct mtd_dev_info
+ int mtd_mark_bad(const struct mtd_dev_info *mtd, int fd, int eb)
+ {
+ 	int ret;
+-	loff_t seek;
++	off_t seek;
+ 
+ 	if (!mtd->bb_allowed) {
+ 		errno = EINVAL;
+@@ -1036,7 +1036,7 @@ int mtd_mark_bad(const struct mtd_dev_in
+ 	if (ret)
+ 		return ret;
+ 
+-	seek = (loff_t)eb * mtd->eb_size;
++	seek = (off_t)eb * mtd->eb_size;
+ 	ret = ioctl(fd, MEMSETBADBLOCK, &seek);
+ 	if (ret == -1)
+ 		return mtd_ioctl_error(mtd, eb, "MEMSETBADBLOCK");
diff --git a/package/mtd-utils/patches/patch-lib_libmtd_legacy_c b/package/mtd-utils/patches/patch-lib_libmtd_legacy_c
new file mode 100644
index 000000000..bcd66374f
--- /dev/null
+++ b/package/mtd-utils/patches/patch-lib_libmtd_legacy_c
@@ -0,0 +1,11 @@
+--- mtd-utils-1.5.0.orig/lib/libmtd_legacy.c	2012-05-07 09:19:39.000000000 +0200
++++ mtd-utils-1.5.0/lib/libmtd_legacy.c	2014-03-30 15:49:26.000000000 +0200
+@@ -234,7 +234,7 @@ int legacy_get_dev_info(const char *node
+ 	struct stat st;
+ 	struct mtd_info_user ui;
+ 	int fd, ret;
+-	loff_t offs = 0;
++	off_t offs = 0;
+ 	struct proc_parse_info pi;
+ 
+ 	if (stat(node, &st)) {
diff --git a/package/mtd-utils/patches/patch-mkfs_jffs2_c b/package/mtd-utils/patches/patch-mkfs_jffs2_c
new file mode 100644
index 000000000..766e2204a
--- /dev/null
+++ b/package/mtd-utils/patches/patch-mkfs_jffs2_c
@@ -0,0 +1,15 @@
+--- mtd-utils-1.5.0.orig/mkfs.jffs2.c	2012-05-07 09:19:39.000000000 +0200
++++ mtd-utils-1.5.0/mkfs.jffs2.c	2014-03-30 15:49:26.000000000 +0200
+@@ -70,7 +70,12 @@
+ #include <sys/xattr.h>
+ #include <sys/acl.h>
+ #endif
++#if defined(__APPLE__)
++#include "endian.h"
++#include "byteswap.h"
++#else
+ #include <byteswap.h>
++#endif
+ #include <crc32.h>
+ #include <inttypes.h>
+ 
diff --git a/package/mtd-utils/patches/patch-rbtree_h b/package/mtd-utils/patches/patch-rbtree_h
new file mode 100644
index 000000000..b7d34b937
--- /dev/null
+++ b/package/mtd-utils/patches/patch-rbtree_h
@@ -0,0 +1,12 @@
+--- mtd-utils-1.5.0.orig/rbtree.h	2012-05-07 09:19:39.000000000 +0200
++++ mtd-utils-1.5.0/rbtree.h	2014-03-30 15:49:26.000000000 +0200
+@@ -94,8 +94,7 @@ static inline struct page * rb_insert_pa
+ #ifndef	_LINUX_RBTREE_H
+ #define	_LINUX_RBTREE_H
+ 
+-#include <linux/kernel.h>
+-#include <linux/stddef.h>
++#include <stddef.h>
+ 
+ struct rb_node
+ {
-- 
cgit v1.2.3