From 5342a1a2ea5ce8c7ece7c0f2f4fdf4c4d202f045 Mon Sep 17 00:00:00 2001
From: Luka Perkov <luka@openwrt.org>
Date: Wed, 21 May 2014 09:42:33 +0000
Subject: [PATCH] mkimage: update to 2014.04

Signed-off-by: Luka Perkov <luka@openwrt.org>

SVN-Revision: 40807
---
 tools/mkimage/Makefile                        | 11 +++++---
 .../patches/010-freebsd-ulong-fix.patch       |  2 +-
 tools/mkimage/patches/020-openbsd_fixes.patch |  4 +--
 .../030-allow-to-use-different-magic.patch    | 28 +++++++++----------
 tools/mkimage/patches/040-include_order.patch | 17 +++++------
 .../patches/050-image_h_portability.patch     |  4 +--
 .../patches/060-remove_kernel_includes.patch  |  4 +--
 .../mkimage/patches/070-avoid_ENOMEDIUM.patch | 11 --------
 8 files changed, 35 insertions(+), 46 deletions(-)
 delete mode 100644 tools/mkimage/patches/070-avoid_ENOMEDIUM.patch

diff --git a/tools/mkimage/Makefile b/tools/mkimage/Makefile
index d2efd62d23..47e918a5a2 100644
--- a/tools/mkimage/Makefile
+++ b/tools/mkimage/Makefile
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2006-2013 OpenWrt.org
+# Copyright (C) 2006-2014 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
@@ -7,11 +7,11 @@
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=mkimage
-PKG_VERSION:=2013.07-rc1
+PKG_VERSION:=2014.04
 
 PKG_SOURCE:=u-boot-$(PKG_VERSION).tar.bz2
 PKG_SOURCE_URL:=ftp://ftp.denx.de/pub/u-boot
-PKG_MD5SUM:=9b14d9a8981ce2e429956af7cc96996e
+PKG_MD5SUM:=6d2116d1385a66e9a59742caa9d62a54
 PKG_CAT:=bzcat
 
 HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/u-boot-$(PKG_VERSION)
@@ -24,11 +24,14 @@ define Host/Prepare
 		$(HOST_BUILD_DIR)/include/errno.h \
 		$(HOST_BUILD_DIR)/include/malloc.h \
 		$(HOST_BUILD_DIR)/tools/.depend
+	touch $(HOST_BUILD_DIR)/include/config.mk
 	touch $(HOST_BUILD_DIR)/include/config.h
 endef
 
 define Host/Compile
-	$(MAKE) -C $(HOST_BUILD_DIR) BUILD_DIR= BIN_FILES-y="mkimage" HOSTLDFLAGS="$(HOST_STATIC_LINKING)" tools
+	$(MAKE) -C $(HOST_BUILD_DIR) \
+		HOSTLDFLAGS="$(HOST_STATIC_LINKING)" \
+		tools-only
 endef
 
 define Host/Install
diff --git a/tools/mkimage/patches/010-freebsd-ulong-fix.patch b/tools/mkimage/patches/010-freebsd-ulong-fix.patch
index b4951b0e25..154346d8be 100644
--- a/tools/mkimage/patches/010-freebsd-ulong-fix.patch
+++ b/tools/mkimage/patches/010-freebsd-ulong-fix.patch
@@ -1,6 +1,6 @@
 --- a/include/image.h
 +++ b/include/image.h
-@@ -61,6 +61,10 @@
+@@ -44,6 +44,10 @@
  
  #endif /* USE_HOSTCC */
  
diff --git a/tools/mkimage/patches/020-openbsd_fixes.patch b/tools/mkimage/patches/020-openbsd_fixes.patch
index 17232360d2..7a762d91f7 100644
--- a/tools/mkimage/patches/020-openbsd_fixes.patch
+++ b/tools/mkimage/patches/020-openbsd_fixes.patch
@@ -1,6 +1,6 @@
 --- a/tools/mkimage.c
 +++ b/tools/mkimage.c
-@@ -464,6 +464,7 @@
+@@ -458,6 +458,7 @@
  #if defined(_POSIX_SYNCHRONIZED_IO) && \
     !defined(__sun__) && \
     !defined(__FreeBSD__) && \
@@ -8,7 +8,7 @@
     !defined(__APPLE__)
  	(void) fdatasync (ifd);
  #else
-@@ -507,6 +508,7 @@
+@@ -501,6 +502,7 @@
  #if defined(_POSIX_SYNCHRONIZED_IO) && \
     !defined(__sun__) && \
     !defined(__FreeBSD__) && \
diff --git a/tools/mkimage/patches/030-allow-to-use-different-magic.patch b/tools/mkimage/patches/030-allow-to-use-different-magic.patch
index afc3f21a81..d5afdd35b2 100644
--- a/tools/mkimage/patches/030-allow-to-use-different-magic.patch
+++ b/tools/mkimage/patches/030-allow-to-use-different-magic.patch
@@ -1,6 +1,6 @@
 --- a/tools/mkimage.c
 +++ b/tools/mkimage.c
-@@ -37,6 +37,7 @@
+@@ -24,6 +24,7 @@
  	.arch = IH_ARCH_PPC,
  	.type = IH_TYPE_KERNEL,
  	.comp = IH_COMP_GZIP,
@@ -8,7 +8,7 @@
  	.dtc = MKIMAGE_DEFAULT_DTC_OPTIONS,
  	.imagename = "",
  	.imagename2 = "",
-@@ -189,6 +190,16 @@
+@@ -168,6 +169,16 @@
  					genimg_get_comp_id (*++argv)) < 0)
  					usage ();
  				goto NXTARG;
@@ -25,7 +25,7 @@
  			case 'D':
  				if (--argc <= 0)
  					usage ();
-@@ -613,12 +624,13 @@
+@@ -623,12 +634,13 @@
  	fprintf (stderr, "Usage: %s -l image\n"
  			 "          -l ==> list image header information\n",
  		params.cmdname);
@@ -40,19 +40,9 @@
  			 "          -a ==> set load address to 'addr' (hex)\n"
  			 "          -e ==> set entry point to 'ep' (hex)\n"
  			 "          -n ==> set image name to 'name'\n"
---- a/tools/mkimage.h
-+++ b/tools/mkimage.h
-@@ -79,6 +79,7 @@
- 	int arch;
- 	int type;
- 	int comp;
-+	unsigned int magic;
- 	char *dtc;
- 	unsigned int addr;
- 	unsigned int ep;
 --- a/tools/default_image.c
 +++ b/tools/default_image.c
-@@ -111,7 +111,7 @@
+@@ -98,7 +98,7 @@
  			sbuf->st_size - sizeof(image_header_t));
  
  	/* Build new header */
@@ -61,3 +51,13 @@
  	image_set_time(hdr, sbuf->st_mtime);
  	image_set_size(hdr, sbuf->st_size - sizeof(image_header_t));
  	image_set_load(hdr, params->addr);
+--- a/tools/imagetool.h
++++ b/tools/imagetool.h
+@@ -44,6 +44,7 @@
+ 	int arch;
+ 	int type;
+ 	int comp;
++	unsigned int magic;
+ 	char *dtc;
+ 	unsigned int addr;
+ 	unsigned int ep;
diff --git a/tools/mkimage/patches/040-include_order.patch b/tools/mkimage/patches/040-include_order.patch
index e4dc78ef27..f4fbbaf757 100644
--- a/tools/mkimage/patches/040-include_order.patch
+++ b/tools/mkimage/patches/040-include_order.patch
@@ -1,14 +1,11 @@
 --- a/tools/Makefile
 +++ b/tools/Makefile
-@@ -160,9 +160,9 @@
- # Define __KERNEL_STRICT_NAMES to prevent typedef overlaps
+@@ -173,7 +173,7 @@
+ # Define _GNU_SOURCE to obtain the getline prototype from stdio.h
  #
- HOSTCPPFLAGS =	-include $(SRCTREE)/include/libfdt_env.h \
--		-idirafter $(SRCTREE)/include \
-+		-I $(SRCTREE)/include \
- 		-idirafter $(OBJTREE)/include2 \
--		-idirafter $(OBJTREE)/include \
-+		-I $(OBJTREE)/include \
- 	        -I $(SRCTREE)/lib/libfdt \
- 		-I $(SRCTREE)/tools \
+ HOST_EXTRACFLAGS += -include $(srctree)/include/libfdt_env.h \
+-		$(patsubst -I%,-idirafter%, $(UBOOTINCLUDE)) \
++		-I$(srctree)/include \
+ 		-I$(srctree)/lib/libfdt \
+ 		-I$(srctree)/tools \
  		-DCONFIG_SYS_TEXT_BASE=$(CONFIG_SYS_TEXT_BASE) \
diff --git a/tools/mkimage/patches/050-image_h_portability.patch b/tools/mkimage/patches/050-image_h_portability.patch
index 86d5226982..767a8b8713 100644
--- a/tools/mkimage/patches/050-image_h_portability.patch
+++ b/tools/mkimage/patches/050-image_h_portability.patch
@@ -1,6 +1,6 @@
 --- a/include/image.h
 +++ b/include/image.h
-@@ -34,7 +34,6 @@
+@@ -17,7 +17,6 @@
  #define __IMAGE_H__
  
  #include "compiler.h"
@@ -8,7 +8,7 @@
  
  /* Define this to avoid #ifdefs later on */
  struct lmb;
-@@ -254,13 +253,13 @@
+@@ -240,13 +239,13 @@
   * all data in network byte order (aka natural aka bigendian).
   */
  typedef struct image_header {
diff --git a/tools/mkimage/patches/060-remove_kernel_includes.patch b/tools/mkimage/patches/060-remove_kernel_includes.patch
index b408bb10f2..9462ca6aa8 100644
--- a/tools/mkimage/patches/060-remove_kernel_includes.patch
+++ b/tools/mkimage/patches/060-remove_kernel_includes.patch
@@ -25,8 +25,8 @@
  #endif /* _LINUX_POSIX_TYPES_H */
 --- a/include/linux/types.h
 +++ b/include/linux/types.h
-@@ -6,7 +6,6 @@
- #endif
+@@ -2,7 +2,6 @@
+ #define _LINUX_TYPES_H
  
  #include <linux/posix_types.h>
 -#include <asm/types.h>
diff --git a/tools/mkimage/patches/070-avoid_ENOMEDIUM.patch b/tools/mkimage/patches/070-avoid_ENOMEDIUM.patch
deleted file mode 100644
index 53b3aa62c3..0000000000
--- a/tools/mkimage/patches/070-avoid_ENOMEDIUM.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- a/common/image-fit.c
-+++ b/common/image-fit.c
-@@ -1557,7 +1557,7 @@ int fit_image_load(bootm_headers_t *imag
- 	if (fit_image_get_data(fit, noffset, &buf, &size)) {
- 		printf("Could not find %s subimage data!\n", prop_name);
- 		bootstage_error(bootstage_id + BOOTSTAGE_SUB_GET_DATA);
--		return -ENOMEDIUM;
-+		return -EIO;
- 	}
- 	len = (ulong)size;
- 
-- 
2.30.2