--- /dev/null
+#
+# Copyright (C) 2013 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=xz
+PKG_VERSION:=5.0.4
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=http://tukaani.org/xz
+PKG_MD5SUM:=741cd3a5f64b23b7bac56ec5b2258715
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+XZ_UTILS := \
+ lzcat lzcmp lzdiff lzegrep lzfgrep lzgrep lzless lzma lzmadec lzmainfo \
+ lzmore unlzma unxz xz xzcat xzcmp xzdec xzdiff xzegrep xzfgrep xzgrep \
+ xzless xzmore
+
+DEPENDS_lzmadec = +libpthread +liblzma
+DEPENDS_lzmainfo = +libpthread +liblzma
+DEPENDS_xz = +libpthread +liblzma
+DEPENDS_xzdec = +libpthread +liblzma
+
+XZ_DEPENDS_lzcat = xz
+XZ_DEPENDS_lzcmp = xzdiff
+XZ_DEPENDS_lzcat = xz
+XZ_DEPENDS_lzcmp = xzdiff
+XZ_DEPENDS_lzdiff = xzdiff
+XZ_DEPENDS_lzegrep = xzgrep
+XZ_DEPENDS_lzfgrep = xzgrep
+XZ_DEPENDS_lzgrep = xzgrep
+XZ_DEPENDS_lzless = xzless
+XZ_DEPENDS_lzma = xz
+XZ_DEPENDS_lzmore = xzmore
+XZ_DEPENDS_unlzma = xz
+XZ_DEPENDS_unxz = xz
+XZ_DEPENDS_xzcat = xz
+XZ_DEPENDS_xzcmp = xzdiff
+XZ_DEPENDS_xzegrep = xzgrep
+XZ_DEPENDS_xzfgrep = xzgrep
+
+define Package/xz/Default
+ SECTION:=utils
+ CATEGORY:=Utilities
+endef
+
+define Package/xz
+ $(call Package/xz/Default)
+ TITLE:=XZ Utils
+ MENU:=1
+endef
+
+define Package/liblzma
+ SECTION:=libs
+ CATEGORY:=Libraries
+ DEPENDS:=xz +libpthread
+ TITLE:=liblzma library from XZ Utils
+endef
+
+define GenPlugin
+ define Package/$(1)
+ $(call Package/xz/Default)
+ DEPENDS:=xz +$(DEPENDS_$(2)) $(if $(XZ_DEPENDS_$(2)),+xz-$(XZ_DEPENDS_$(2)))
+ TITLE:=$(2) utility from XZ Utils
+ endef
+endef
+
+$(foreach i,$(XZ_UTILS),$(eval $(call GenPlugin,xz-$(i),$(i))))
+
+CONFIGURE_ARGS += \
+ --enable-small \
+ --enable-assume-ram=4 \
+ --disable-assembler \
+ --disable-werror
+
+define Build/InstallDev
+ $(INSTALL_DIR) $(1)/usr/include/lzma
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/include/lzma.h \
+ $(1)/usr/include/
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/include/lzma/*.h \
+ $(1)/usr/include/lzma/
+ $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/liblzma.pc \
+ $(1)/usr/lib/pkgconfig/
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/liblzma.* \
+ $(1)/usr/lib/
+endef
+
+define Package/xz/install
+ true
+endef
+
+define BuildPlugin
+ define Package/$(1)/install
+ $(INSTALL_DIR) $$(1)/usr/bin
+ifneq ($(XZ_DEPENDS_$(2)),)
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/bin/$(2) \
+ $$(1)/usr/bin/
+else
+ $(INSTALL_BIN) \
+ $(PKG_INSTALL_DIR)/usr/bin/$(2) \
+ $$(1)/usr/bin/
+endif
+ endef
+
+ $$(eval $$(call BuildPackage,$(1)))
+endef
+
+define Package/liblzma/install
+ $(INSTALL_DIR) $(1)/usr/lib
+ $(CP) \
+ $(PKG_INSTALL_DIR)/usr/lib/liblzma.so* \
+ $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,xz))
+$(eval $(call BuildPackage,liblzma))
+$(foreach i,$(XZ_UTILS),$(eval $(call BuildPlugin,xz-$(i),$(i))))
--- /dev/null
+--- a/src/lzmainfo/Makefile.am
++++ b/src/lzmainfo/Makefile.am
+@@ -20,7 +20,8 @@ lzmainfo_CPPFLAGS = \
+ -DLOCALEDIR=\"$(localedir)\" \
+ -I$(top_srcdir)/src/common \
+ -I$(top_srcdir)/src/liblzma/api \
+- -I$(top_builddir)/lib
++ -I$(top_builddir)/lib \
++ -std=gnu99
+
+ lzmainfo_LDADD = $(top_builddir)/src/liblzma/liblzma.la
+
+--- a/src/liblzma/common/common.h
++++ b/src/liblzma/common/common.h
+@@ -89,9 +89,9 @@ typedef lzma_ret (*lzma_init_function)(
+ /// function prototype.
+ typedef lzma_ret (*lzma_code_function)(
+ lzma_coder *coder, lzma_allocator *allocator,
+- const uint8_t *restrict in, size_t *restrict in_pos,
+- size_t in_size, uint8_t *restrict out,
+- size_t *restrict out_pos, size_t out_size,
++ const uint8_t *in, size_t *in_pos,
++ size_t in_size, uint8_t *out,
++ size_t *out_pos, size_t out_size,
+ lzma_action action);
+
+ /// Type of a function to free the memory allocated for the coder
+@@ -235,9 +235,9 @@ extern void lzma_next_end(lzma_next_code
+
+ /// Copy as much data as possible from in[] to out[] and update *in_pos
+ /// and *out_pos accordingly. Returns the number of bytes copied.
+-extern size_t lzma_bufcpy(const uint8_t *restrict in, size_t *restrict in_pos,
+- size_t in_size, uint8_t *restrict out,
+- size_t *restrict out_pos, size_t out_size);
++extern size_t lzma_bufcpy(const uint8_t *in, size_t *in_pos,
++ size_t in_size, uint8_t *out,
++ size_t *out_pos, size_t out_size);
+
+
+ /// \brief Return if expression doesn't evaluate to LZMA_OK
+--- a/src/liblzma/common/common.c
++++ b/src/liblzma/common/common.c
+@@ -70,9 +70,9 @@ lzma_free(void *ptr, lzma_allocator *all
+ //////////
+
+ extern size_t
+-lzma_bufcpy(const uint8_t *restrict in, size_t *restrict in_pos,
+- size_t in_size, uint8_t *restrict out,
+- size_t *restrict out_pos, size_t out_size)
++lzma_bufcpy(const uint8_t *in, size_t *in_pos,
++ size_t in_size, uint8_t *out,
++ size_t *out_pos, size_t out_size)
+ {
+ const size_t in_avail = in_size - *in_pos;
+ const size_t out_avail = out_size - *out_pos;
+--- a/src/liblzma/Makefile.am
++++ b/src/liblzma/Makefile.am
+@@ -23,7 +23,8 @@ liblzma_la_CPPFLAGS = \
+ -I$(top_srcdir)/src/liblzma/delta \
+ -I$(top_srcdir)/src/liblzma/simple \
+ -I$(top_srcdir)/src/common \
+- -DTUKLIB_SYMBOL_PREFIX=lzma_
++ -DTUKLIB_SYMBOL_PREFIX=lzma_ \
++ -std=gnu99
+ liblzma_la_LDFLAGS = -no-undefined -version-info 5:4:0
+
+ include $(srcdir)/common/Makefile.inc
+--- a/src/xz/Makefile.am
++++ b/src/xz/Makefile.am
+@@ -46,7 +46,8 @@ xz_CPPFLAGS = \
+ -DLOCALEDIR=\"$(localedir)\" \
+ -I$(top_srcdir)/src/common \
+ -I$(top_srcdir)/src/liblzma/api \
+- -I$(top_builddir)/lib
++ -I$(top_builddir)/lib \
++ -std=gnu99
+
+ xz_LDADD = $(top_builddir)/src/liblzma/liblzma.la
+