ASR_BASE

Change-Id: Icf3719cc0afe3eeb3edc7fa80a2eb5199ca9dda1
diff --git a/package/libs/argp-standalone/Makefile b/package/libs/argp-standalone/Makefile
new file mode 100644
index 0000000..23e5169
--- /dev/null
+++ b/package/libs/argp-standalone/Makefile
@@ -0,0 +1,63 @@
+#
+# Copyright (C) 2007-2014 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:=argp-standalone
+PKG_VERSION:=1.3
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://www.lysator.liu.se/~nisse/misc/
+PKG_HASH:=dec79694da1319acd2238ce95df57f3680fea2482096e483323fddf3d818d8be
+PKG_MAINTAINER:=Ted Hess <thess@kitschensync.net>
+
+PKG_LICENSE:=LGPL-2.1
+PKG_LICENSE:=Makefile.am
+
+PKG_BUILD_FLAGS:=no-lto
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+
+define Package/argp-standalone
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=Hierarchial argument parsing broken out from glibc
+  URL:=http://www.lysator.liu.se/~nisse/misc/
+endef
+
+define Package/argp-standalone/description
+  GNU libc hierarchial argument parsing library broken out from glibc.
+endef
+
+MAKE_FLAGS += \
+	CFLAGS="$(TARGET_CFLAGS) $(FPIC) -std=gnu89"
+
+HOST_MAKE_FLAGS += \
+	CFLAGS="$(HOST_CFLAGS) $(FPIC) -std=gnu89"
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP)   $(PKG_BUILD_DIR)/argp.h \
+		$(1)/usr/include/
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP)   $(PKG_BUILD_DIR)/libargp.a \
+		$(1)/usr/lib/
+endef
+
+define Host/Install
+	$(INSTALL_DIR) $(1)/include
+	$(CP)   $(HOST_BUILD_DIR)/argp.h \
+		$(1)/include/
+	$(INSTALL_DIR) $(1)/lib
+	$(CP)   $(HOST_BUILD_DIR)/libargp.a \
+		$(1)/lib/
+endef
+
+$(eval $(call BuildPackage,argp-standalone))
+$(eval $(call HostBuild))
diff --git a/package/libs/argp-standalone/patches/001-throw-in-funcdef.patch b/package/libs/argp-standalone/patches/001-throw-in-funcdef.patch
new file mode 100644
index 0000000..2dcfe9c
--- /dev/null
+++ b/package/libs/argp-standalone/patches/001-throw-in-funcdef.patch
@@ -0,0 +1,79 @@
+# --- T2-COPYRIGHT-NOTE-BEGIN ---
+# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
+# 
+# T2 SDE: package/.../rng-tools/throw-in-funcdef.patch.argp-standalone
+# Copyright (C) 2006 The T2 SDE Project
+# 
+# More information can be found in the files COPYING and README.
+# 
+# This patch file is dual-licensed. It is available under the license the
+# patched project is licensed under, as long as it is an OpenSource license
+# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
+# of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+# --- T2-COPYRIGHT-NOTE-END ---
+
+
+No __THROW in function implementation.
+	--jsaw
+
+--- a/argp.h
++++ b/argp.h
+@@ -560,17 +560,17 @@ __argp_short_program_name(const struct a
+ # endif
+ 
+ # ifndef ARGP_EI
+-#  define ARGP_EI extern __inline__
++#  define ARGP_EI extern inline
+ # endif
+ 
+ ARGP_EI void
+-__argp_usage (__const struct argp_state *__state) __THROW
++__argp_usage (__const struct argp_state *__state)
+ {
+   __argp_state_help (__state, stderr, ARGP_HELP_STD_USAGE);
+ }
+ 
+ ARGP_EI int
+-__option_is_short (__const struct argp_option *__opt) __THROW
++__option_is_short (__const struct argp_option *__opt)
+ {
+   if (__opt->flags & OPTION_DOC)
+     return 0;
+@@ -582,7 +582,7 @@ __option_is_short (__const struct argp_o
+ }
+ 
+ ARGP_EI int
+-__option_is_end (__const struct argp_option *__opt) __THROW
++__option_is_end (__const struct argp_option *__opt)
+ {
+   return !__opt->key && !__opt->name && !__opt->doc && !__opt->group;
+ }
+--- a/argp-parse.c
++++ b/argp-parse.c
+@@ -1277,13 +1277,13 @@ weak_alias (__argp_input, _argp_input)
+ /* Defined here, in case a user is not inlining the definitions in
+  * argp.h */
+ void
+-__argp_usage (__const struct argp_state *__state) __THROW
++__argp_usage (__const struct argp_state *__state)
+ {
+   __argp_state_help (__state, stderr, ARGP_HELP_STD_USAGE);
+ }
+ 
+ int
+-__option_is_short (__const struct argp_option *__opt) __THROW
++__option_is_short (__const struct argp_option *__opt) 
+ {
+   if (__opt->flags & OPTION_DOC)
+     return 0;
+@@ -1297,7 +1297,7 @@ __option_is_short (__const struct argp_o
+ }
+ 
+ int
+-__option_is_end (__const struct argp_option *__opt) __THROW
++__option_is_end (__const struct argp_option *__opt) 
+ {
+   return !__opt->key && !__opt->name && !__opt->doc && !__opt->group;
+ }
diff --git a/package/libs/argp-standalone/patches/002-no_optimize.patch b/package/libs/argp-standalone/patches/002-no_optimize.patch
new file mode 100644
index 0000000..1da330a
--- /dev/null
+++ b/package/libs/argp-standalone/patches/002-no_optimize.patch
@@ -0,0 +1,11 @@
+--- a/argp-fmtstream.h
++++ b/argp-fmtstream.h
+@@ -192,7 +192,7 @@ extern void __argp_fmtstream_update (arg
+ extern int _argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount);
+ extern int __argp_fmtstream_ensure (argp_fmtstream_t __fs, size_t __amount);
+ 
+-#ifdef __OPTIMIZE__
++#if 0
+ /* Inline versions of above routines.  */
+ 
+ #if !_LIBC
diff --git a/package/libs/argp-standalone/patches/900-fix-segfault-in_canon_doc_option.patch b/package/libs/argp-standalone/patches/900-fix-segfault-in_canon_doc_option.patch
new file mode 100644
index 0000000..46bffbb
--- /dev/null
+++ b/package/libs/argp-standalone/patches/900-fix-segfault-in_canon_doc_option.patch
@@ -0,0 +1,14 @@
+--- a/argp-help.c
++++ b/argp-help.c
+@@ -777,9 +777,9 @@ hol_entry_cmp (const struct hol_entry *e
+       const char *long2 = hol_entry_first_long (entry2);
+ 
+       if (doc1)
+-	doc1 = canon_doc_option (&long1);
++        doc1 = long1 != NULL && canon_doc_option (&long1);
+       if (doc2)
+-	doc2 = canon_doc_option (&long2);
++	doc2 = long2 != NULL && canon_doc_option (&long2);
+ 
+       if (doc1 != doc2)
+ 	/* `documentation' options always follow normal options (or
diff --git a/package/libs/asr_audio/Makefile b/package/libs/asr_audio/Makefile
new file mode 100644
index 0000000..bb34749
--- /dev/null
+++ b/package/libs/asr_audio/Makefile
@@ -0,0 +1,248 @@
+#
+# Copyright (C) 2015 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+PKG_NAME:=audio
+PKG_VERSION:=2015
+PKG_RELEASE:=1
+
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
+SVC_SOURCE_DIR:=$(MRVLDIR)/services/$(PKG_NAME)
+PKG_SOURCE_DIR:=$(SVC_SOURCE_DIR) $(STAGING_DIR)/usr/lib
+PKG_BUILD_PARALLEL:=0
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/asr_audio
+  SECTION:=libs
+  CATEGORY:=Sound
+  SUBMENU:= Marvell Audio solution
+  TITLE:=Audio-Libs
+  DEPENDS+= +lte-telephony
+endef
+
+define Package/asr_audio/description
+  Marvell Audio libraries .so .a, tinyalsa
+   and debug applications (apather_s, apather_c)
+endef
+
+define Package/asr_audio/config
+##menu "Audio Configuration"
+choice
+	prompt "Audio kernel service"
+	default KERNEL_ENABLE_AUDIO
+	help
+	  There are 2 choices:
+	  - ENABLE
+	  - DISABLE
+config KERNEL_ENABLE_AUDIO
+	bool "ENABLE"
+config KERNEL_DISABLE_AUDIO
+	bool "DISABLE"
+endchoice
+
+choice
+	prompt "LINUX ALSA SSP Controller"
+	default KERNEL_LINUX_ALSA_SSP_CONTROLLER_DISABLE
+	help
+	  There are 2 choices:
+	  - ENABLE
+	  - DISABLE
+config KERNEL_LINUX_ALSA_SSP_CONTROLLER_ENABLE
+	bool "ENABLE"
+config KERNEL_LINUX_ALSA_SSP_CONTROLLER_DISABLE
+	bool "DISABLE"
+endchoice
+
+choice
+	prompt "Select Audio Codec Chip"
+	default KERNEL_CODEC_NONE
+	help
+	  There are 5 choices:
+	  - ASR PM812
+	  - ASR PM805
+	  - ASR NAU8810
+	  - ASR ALC5616
+	  - No Codec
+config KERNEL_CODEC_PM812
+	bool "ASR PM812"
+config KERNEL_CODEC_PM805
+	bool "ASR PM805"
+config KERNEL_CODEC_NAU8810
+	bool "ASR NAU8810"
+config KERNEL_CODEC_ALC5616
+	bool "ASR ALC5616"
+config KERNEL_CODEC_NONE
+	bool "No Codec"
+endchoice
+
+choice
+	prompt "Select Role for Audio Codec I2S"
+	default KERNEL_CODEC_I2S_MASTER
+	help
+	  There are 2 choices:
+	  - Master
+	  - Slave
+config KERNEL_CODEC_I2S_MASTER
+	bool "Master"
+config KERNEL_CODEC_I2S_SLAVE
+	bool "Slave"
+endchoice
+
+choice
+	prompt "Select Role for Audio Codec PCM"
+	default KERNEL_CODEC_PCM_SLAVE
+	help
+	  There are 2 choices:
+	  - Master
+	  - Slave
+config KERNEL_CODEC_PCM_MASTER
+	bool "Master"
+config KERNEL_CODEC_PCM_SLAVE
+	bool "Slave"
+endchoice
+
+choice
+	prompt "Select Rate for Audio Codec PCM"
+	default KERNEL_CODEC_PCM_NB
+	help
+	  There are 4 choices:
+	  - NarrowBand
+	  - Wideband
+	  - 32KHz
+	  - 48KHz
+config KERNEL_CODEC_PCM_NB
+	bool "Narrowband"
+config KERNEL_CODEC_PCM_WB
+	bool "Wideband"
+config KERNEL_CODEC_PCM_32KHz
+	bool "32KHz"
+config KERNEL_CODEC_PCM_48KHz
+	bool "48KHz"
+endchoice
+
+choice
+	prompt "Select Controller for Modem Audio"
+	default KERNEL_MODEM_AUDIO_CONTROLLER_GSSP
+	help
+	  There are 3 choices:
+	  - GSSP
+	  - SSPA
+	  - INTERNAL CODEC
+config KERNEL_MODEM_AUDIO_CONTROLLER_GSSP
+	bool "GSSP"
+config KERNEL_MODEM_AUDIO_CONTROLLER_SSPA
+	bool "SSPA"
+config KERNEL_MODEM_AUDIO_INTERNAL_CODEC
+	bool "Internal Codec"
+endchoice
+
+##endmenu
+endef
+
+
+ifeq ($(CONFIG_KERNEL_CODEC_PM812),y)
+TARGET_CFLAGS += -DCODEC_PM812
+endif
+
+ifeq ($(CONFIG_KERNEL_CODEC_PM805),y)
+TARGET_CFLAGS += -DCODEC_PM805
+endif
+
+ifeq ($(CONFIG_KERNEL_CODEC_NAU8810),y)
+TARGET_CFLAGS += -DCODEC_NAU8810
+endif
+
+ifeq ($(CONFIG_KERNEL_CODEC_ALC5616),y)
+TARGET_CFLAGS += -DCODEC_ALC5616
+endif
+
+ifeq ($(CONFIG_KERNEL_CODEC_NONE),y)
+TARGET_CFLAGS += -DCODEC_NONE
+endif
+
+ifeq ($(CONFIG_KERNEL_CODEC_I2S_MASTER),y)
+TARGET_CFLAGS += -DCODEC_I2S_MASTER
+endif
+
+ifeq ($(CONFIG_KERNEL_CODEC_I2S_SLAVE),y)
+TARGET_CFLAGS += -DCODEC_I2S_SLAVE
+endif
+
+ifeq ($(CONFIG_KERNEL_CODEC_PCM_MASTER),y)
+TARGET_CFLAGS += -DCODEC_PCM_MASTER
+endif
+
+ifeq ($(CONFIG_KERNEL_CODEC_PCM_SLAVE),y)
+TARGET_CFLAGS += -DCODEC_PCM_SLAVE
+endif
+
+ifeq ($(CONFIG_KERNEL_CODEC_PCM_NB),y)
+TARGET_CFLAGS += -DCODEC_PCM_NB
+endif
+
+ifeq ($(CONFIG_KERNEL_CODEC_PCM_WB),y)
+TARGET_CFLAGS += -DCODEC_PCM_WB
+endif
+
+ifeq ($(CONFIG_KERNEL_CODEC_PCM_32KHz),y)
+TARGET_CFLAGS += -DCODEC_PCM_32KHz
+endif
+
+ifeq ($(CONFIG_KERNEL_CODEC_PCM_48KHz),y)
+TARGET_CFLAGS += -DCODEC_PCM_48KHz
+endif
+
+TARGET_CFLAGS += -ffunction-sections -fdata-sections
+TARGET_LDFLAGS += -Wl,--gc-sections
+
+define Build/Compile
+	$(MAKE) $(PKG_JOBS) -C $(SVC_SOURCE_DIR) \
+		SUBTARGET="$(SUBTARGET)" \
+		CROSS_COMPILE="$(TARGET_CROSS)" \
+		EXTRA_CFLAGS="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include -I$(TOOLCHAIN_DIR)/include" \
+		LD_FLAGS="$(TARGET_LDFLAGS) -L$(TOOLCHAIN_DIR)/lib/"\
+		INSTALL_DIR="$(PKG_INSTALL_DIR)" \
+		OBJ_DIR="$(PKG_BUILD_DIR)/obj" \
+		PKG_BUILD_DIR="$(PKG_BUILD_DIR)" \
+		compile
+endef
+
+define Build/Clean
+@if [ -d $(PKG_BUILD_DIR) ]; then \
+	$(MAKE) $(PKG_JOBS) -C $(SVC_SOURCE_DIR) \
+		CROSS_COMPILE="$(TARGET_CROSS)" \
+		EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
+		LD_FLAGS="$(TARGET_LDFLAGS)" \
+		INSTALL_DIR="$(PKG_INSTALL_DIR)" \
+		OBJ_DIR="$(PKG_BUILD_DIR)/obj" \
+		PKG_BUILD_DIR="$(PKG_BUILD_DIR)" \
+		clean; \
+fi
+endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) -rf $(PKG_INSTALL_DIR)/lib/libtinyalsa.so $(1)/usr/lib/
+	$(CP) -rf $(SVC_SOURCE_DIR)/tinyalsa/include/asoundlib.h $(1)/usr/include/
+endef
+
+define Package/asr_audio/install
+	$(INSTALL_DIR) $(1)/lib
+	$(INSTALL_DIR) $(1)/bin
+	$(INSTALL_DIR) $(1)/etc
+	$(CP) -rf $(PKG_INSTALL_DIR)/* $(1)/
+	mkdir -p  $(BIN_DIR)/symbol/service
+	cp -rf $(PKG_BUILD_DIR)/obj/symbol/* $(BIN_DIR)/symbol/service/
+
+endef
+
+$(eval $(call BuildPackage,asr_audio))
diff --git a/package/libs/cutils/Makefile b/package/libs/cutils/Makefile
new file mode 100644
index 0000000..425769e
--- /dev/null
+++ b/package/libs/cutils/Makefile
@@ -0,0 +1,40 @@
+#
+# Copyright (C) 2010-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:=libcutils
+PKG_VERSION:=1.0
+PKG_RELEASE=1
+USE_SOURCE_DIR:=$(MRVLDIR)/services/android_wrapper/cutils
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libcutils
+  SECTION:=libs
+  CATEGORY:=Libraries
+  DEPENDS:=@TARGET_mmp +libpthread
+  TITLE:=Marvell Android Property to UCI wrapper library
+endef
+
+define Build/Clean
+	rm -rf $(USE_SOURCE_DIR)/*.so
+	rm -rf $(USE_SOURCE_DIR)/*.a
+	rm -rf $(USE_SOURCE_DIR)/*.o
+endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(USE_SOURCE_DIR)/libcutils.so $(1)/usr/lib/
+endef
+
+define Package/libcutils/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(USE_SOURCE_DIR)/libcutils.so $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libcutils))
diff --git a/package/libs/elfutils/Makefile b/package/libs/elfutils/Makefile
new file mode 100644
index 0000000..8446445
--- /dev/null
+++ b/package/libs/elfutils/Makefile
@@ -0,0 +1,128 @@
+#
+# Copyright (C) 2010-2019 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:=elfutils
+PKG_VERSION:=0.192
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=https://sourceware.org/$(PKG_NAME)/ftp/$(PKG_VERSION) \
+                https://mirrors.kernel.org/sourceware/$(PKG_NAME)/$(PKG_VERSION)
+PKG_HASH:=616099beae24aba11f9b63d86ca6cc8d566d968b802391334c91df54eab416b4
+
+PKG_MAINTAINER:=Luiz Angelo Daros de Luca <luizluca@gmail.com>
+PKG_LICENSE:=GPL-3.0-or-later
+PKG_LICENSE_FILES:=COPYING COPYING-GPLV2 COPYING-LGPLV3
+PKG_CPE_ID:=cpe:/a:elfutils_project:elfutils
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+PKG_BUILD_DEPENDS:=!USE_GLIBC:argp-standalone
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/nls.mk
+
+define Package/elfutils/Default
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=ELF manipulation libraries
+  URL:=https://fedorahosted.org/elfutils/
+  ABI_VERSION:=1
+endef
+
+define Package/libasm
+  $(call Package/elfutils/Default)
+  TITLE+= (libasm)
+  DEPENDS:=+libelf +libdw
+endef
+
+define Package/libdw
+  $(call Package/elfutils/Default)
+  DEPENDS:=+libelf +libbz2 +USE_MUSL:musl-fts
+  TITLE+= (libdw)
+endef
+
+define Package/libelf
+  $(call Package/elfutils/Default)
+  DEPENDS:=$(INTL_DEPENDS) +zlib
+  TITLE+= (libelf)
+  PROVIDES:=libelf1
+endef
+
+ifeq ($(CONFIG_BUILD_NLS),y)
+TARGET_LDFLAGS += -lintl
+else
+CONFIGURE_ARGS += --disable-nls
+endif
+
+HOST_CONFIGURE_ARGS += \
+	--disable-shared \
+	--disable-nls \
+	--disable-debuginfod \
+	--disable-libdebuginfod \
+	--without-bzlib \
+	--without-lzma \
+	--without-zstd
+
+CONFIGURE_ARGS += \
+	--program-prefix=eu- \
+	--disable-debuginfod \
+	--disable-libdebuginfod \
+	--without-bzlib \
+	--without-lzma \
+	--without-zstd
+
+HOST_CONFIGURE_VARS += \
+	ac_cv_search__obstack_free=yes
+
+CONFIGURE_VARS += \
+	ac_cv_search__obstack_free=yes
+
+TARGET_CFLAGS += \
+	-D_GNU_SOURCE \
+	-Wno-unused-result \
+	-Wno-format-nonliteral
+
+TARGET_CPPFLAGS += -DHAVE_ERR_H
+
+ifneq ($(CONFIG_GCC_USE_VERSION_11),y)
+TARGET_CFLAGS += \
+	-Wno-error=use-after-free
+endif
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libasm*.{a,so*} $(1)/usr/lib/
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libdw*.{a,so*} $(1)/usr/lib/
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libelf*.{a,so*} $(1)/usr/lib/
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libelf.pc $(1)/usr/lib/pkgconfig/
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libdw.pc $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libasm/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libasm{-*.so,*.so.*} $(1)/usr/lib/
+endef
+
+define Package/libdw/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libdw{-*.so,*.so.*} $(1)/usr/lib/
+endef
+
+define Package/libelf/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libelf{-*.so,*.so.*} $(1)/usr/lib/
+endef
+
+# these lines need to be ordered by dependency because of ABI versioning
+$(eval $(call BuildPackage,libelf))
+$(eval $(call BuildPackage,libdw))
+$(eval $(call BuildPackage,libasm))
diff --git a/package/libs/elfutils/patches/003-libintl-compatibility.patch b/package/libs/elfutils/patches/003-libintl-compatibility.patch
new file mode 100644
index 0000000..eda9f22
--- /dev/null
+++ b/package/libs/elfutils/patches/003-libintl-compatibility.patch
@@ -0,0 +1,23 @@
+--- a/config/libelf.pc.in
++++ b/config/libelf.pc.in
+@@ -8,7 +8,7 @@ Description: elfutils libelf library to
+ Version: @VERSION@
+ URL: http://elfutils.org/
+ 
+-Libs: -L${libdir} -lelf
++Libs: -L${libdir} -lelf @intl_LDFLAGS@
+ Cflags: -I${includedir}
+ 
+ Requires.private: zlib @LIBZSTD@
+--- a/configure.ac
++++ b/configure.ac
+@@ -728,6 +728,9 @@ dnl AM_GNU_GETTEXT_REQUIRE_VERSION suppo
+ AM_GNU_GETTEXT_VERSION([0.19.6])
+ AM_GNU_GETTEXT_REQUIRE_VERSION([0.19.6])
+ 
++case "$USE_NLS" in yes) intl_LDFLAGS="-lintl" ;; esac
++AC_SUBST([intl_LDFLAGS])
++
+ dnl Appended to the config.h file.
+ dnl We hide all kinds of configuration magic in lib/eu-config.h.
+ AH_BOTTOM([#include <eu-config.h>])
diff --git a/package/libs/elfutils/patches/005-build_only_libs.patch b/package/libs/elfutils/patches/005-build_only_libs.patch
new file mode 100644
index 0000000..177ac65
--- /dev/null
+++ b/package/libs/elfutils/patches/005-build_only_libs.patch
@@ -0,0 +1,11 @@
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -27,7 +27,7 @@ AM_MAKEFLAGS = --no-print-directory
+ pkginclude_HEADERS = version.h
+ 
+ SUBDIRS = config lib libelf libcpu backends libebl libdwelf libdwfl libdw \
+-	  libasm debuginfod src po doc tests
++	  libasm
+ 
+ EXTRA_DIST = elfutils.spec GPG-KEY NOTES CONTRIBUTING SECURITY \
+ 	     COPYING COPYING-GPLV2 COPYING-LGPLV3 CONDUCT
diff --git a/package/libs/elfutils/patches/006-Fix-build-on-aarch64-musl.patch b/package/libs/elfutils/patches/006-Fix-build-on-aarch64-musl.patch
new file mode 100644
index 0000000..a7786ed
--- /dev/null
+++ b/package/libs/elfutils/patches/006-Fix-build-on-aarch64-musl.patch
@@ -0,0 +1,55 @@
+From 578f370c7e7a9f056aefa062b34590b0aa13bce5 Mon Sep 17 00:00:00 2001
+From: Hongxu Jia <hongxu.jia@windriver.com>
+Date: Tue, 15 Aug 2017 17:27:30 +0800
+Subject: [PATCH] Fix build on aarch64/musl
+
+Errors
+
+invalid operands to binary & (have 'long double' and 'unsigned int')
+
+error: redefinition
+ of 'struct iovec'
+ struct iovec { void *iov_base; size_t iov_len; };
+        ^
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+
+Rebase to 0.170
+Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
+
+---
+ backends/aarch64_initreg.c | 4 ++--
+ backends/arm_initreg.c     | 2 +-
+ 2 files changed, 3 insertions(+), 3 deletions(-)
+
+--- a/backends/aarch64_initreg.c
++++ b/backends/aarch64_initreg.c
+@@ -33,7 +33,7 @@
+ #include "system.h"
+ #include <assert.h>
+ #if defined(__aarch64__) && defined(__linux__)
+-# include <linux/uio.h>
++# include <sys/uio.h>
+ # include <sys/user.h>
+ # include <sys/ptrace.h>
+ # include <asm/ptrace.h>
+@@ -94,7 +94,7 @@ aarch64_set_initial_registers_tid (pid_t
+ 
+   Dwarf_Word dwarf_fregs[32];
+   for (int r = 0; r < 32; r++)
+-    dwarf_fregs[r] = fregs.vregs[r] & 0xFFFFFFFF;
++    dwarf_fregs[r] = (unsigned int)fregs.vregs[r] & 0xFFFFFFFF;
+ 
+   if (! setfunc (64, 32, dwarf_fregs, arg))
+     return false;
+--- a/backends/arm_initreg.c
++++ b/backends/arm_initreg.c
+@@ -38,7 +38,7 @@
+ #endif
+ 
+ #ifdef __aarch64__
+-# include <linux/uio.h>
++# include <sys/uio.h>
+ # include <sys/user.h>
+ # include <sys/ptrace.h>
+ /* Deal with old glibc defining user_pt_regs instead of user_regs_struct.  */
diff --git a/package/libs/elfutils/patches/007-add-libeu-symbols-to-libelf.patch b/package/libs/elfutils/patches/007-add-libeu-symbols-to-libelf.patch
new file mode 100644
index 0000000..23489b5
--- /dev/null
+++ b/package/libs/elfutils/patches/007-add-libeu-symbols-to-libelf.patch
@@ -0,0 +1,31 @@
+From f5d6e088f84dd05278c4698a21cbf1ff4569978d Mon Sep 17 00:00:00 2001
+From: Mark Wielaard <mark@klomp.org>
+Date: Tue, 22 Oct 2024 15:03:42 +0200
+Subject: [PATCH] libelf: Add libeu objects to libelf.a static archive
+
+libelf might use some symbols from libeu.a, specifically the eu-search
+wrappers. But we don't ship libeu.a separately. So include the libeu
+objects in the libelf.a archive to facilitate static linking.
+
+	* libelf/Makefile.am (libeu_objects): New variable.
+	(libelf_a_LIBADD): New, add libeu_objects.
+
+https://sourceware.org/bugzilla/show_bug.cgi?id=32293
+
+Signed-off-by: Mark Wielaard <mark@klomp.org>
+---
+ libelf/Makefile.am | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/libelf/Makefile.am
++++ b/libelf/Makefile.am
+@@ -122,6 +122,9 @@ libelf.so: $(srcdir)/libelf.map $(libelf
+ 	@$(textrel_check)
+ 	$(AM_V_at)ln -fs $@ $@.$(VERSION)
+ 
++libeu_objects = $(shell $(AR) t ../lib/libeu.a)
++libelf_a_LIBADD = $(addprefix ../lib/,$(libeu_objects))
++
+ install: install-am libelf.so
+ 	$(mkinstalldirs) $(DESTDIR)$(libdir)
+ 	$(INSTALL_PROGRAM) libelf.so $(DESTDIR)$(libdir)/libelf-$(PACKAGE_VERSION).so
diff --git a/package/libs/elfutils/patches/008-fix-autoconf-ENABLE_IMA_VERIFICATION.patch b/package/libs/elfutils/patches/008-fix-autoconf-ENABLE_IMA_VERIFICATION.patch
new file mode 100644
index 0000000..e5732d2
--- /dev/null
+++ b/package/libs/elfutils/patches/008-fix-autoconf-ENABLE_IMA_VERIFICATION.patch
@@ -0,0 +1,24 @@
+From f3c664d069d81a4872a1ec8241ee709f37c53e9c Mon Sep 17 00:00:00 2001
+From: Aaron Merey <amerey@redhat.com>
+Date: Tue, 29 Oct 2024 14:16:57 -0400
+Subject: [PATCH] configure.ac: Fix ENABLE_IMA_VERIFICATION conditional
+
+Fix test statement for ENABLE_IMA_VERIFICATION always evalutating to
+false due to a missing 'x'.
+
+Signed-off-by: Aaron Merey <amerey@redhat.com>
+---
+ configure.ac | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+--- a/configure.ac
++++ b/configure.ac
+@@ -895,7 +895,7 @@ AS_IF([test "x$enable_debuginfod" != "xn
+ AM_CONDITIONAL([DEBUGINFOD],[test "x$enable_debuginfod" = "xyes"])
+ AS_IF([test "x$enable_debuginfod_ima_verification" = "xyes"],AC_DEFINE([ENABLE_IMA_VERIFICATION],[1],[Build IMA verification]))
+ AS_IF([test "x$have_libarchive" = "xyes"],AC_DEFINE([HAVE_LIBARCHIVE],[1],[Define to 1 if libarchive is available]))
+-AM_CONDITIONAL([ENABLE_IMA_VERIFICATION],[test "$enable_debuginfod_ima_verification" = "xyes"])
++AM_CONDITIONAL([ENABLE_IMA_VERIFICATION],[test "x$enable_debuginfod_ima_verification" = "xyes"])
+ AM_CONDITIONAL([OLD_LIBMICROHTTPD],[test "x$old_libmicrohttpd" = "xyes"])
+ 
+ dnl for /etc/profile.d/elfutils.{csh,sh}
diff --git a/package/libs/elfutils/patches/009-fix-null-dereference-with-lto.patch b/package/libs/elfutils/patches/009-fix-null-dereference-with-lto.patch
new file mode 100644
index 0000000..1179a1e
--- /dev/null
+++ b/package/libs/elfutils/patches/009-fix-null-dereference-with-lto.patch
@@ -0,0 +1,193 @@
+From 8707194a9f2f0b13e53041b03ebfdbdbd2942e43 Mon Sep 17 00:00:00 2001
+From: Mark Wielaard <mark@klomp.org>
+Date: Tue, 5 Nov 2024 23:31:14 +0100
+Subject: [PATCH 1/1] libelf: Only fetch shdr once in elf_compress[_gnu]
+
+Some compilers assume the second call to elf[32|64]_getshdr can fail
+and produce error: potential null pointer dereference. Just store the
+result of the first call and reuse (when not NULL).
+
+       * libelf/elf_compress.c (elf_compress): Store getshdr result in
+       a shdr union var.
+       * libelf/elf_compress_gnu.c (): Likewise
+
+https://sourceware.org/bugzilla/show_bug.cgi?id=32311
+
+Signed-off-by: Mark Wielaard <mark@klomp.org>
+---
+ libelf/elf_compress.c     | 55 +++++++++++++++++++++------------------
+ libelf/elf_compress_gnu.c | 45 ++++++++++++++------------------
+ 2 files changed, 48 insertions(+), 52 deletions(-)
+
+--- a/libelf/elf_compress.c
++++ b/libelf/elf_compress.c
+@@ -584,25 +584,30 @@ elf_compress (Elf_Scn *scn, int type, un
+   Elf64_Xword sh_flags;
+   Elf64_Word sh_type;
+   Elf64_Xword sh_addralign;
++  union shdr
++  {
++    Elf32_Shdr *s32;
++    Elf64_Shdr *s64;
++  } shdr;
+   if (elfclass == ELFCLASS32)
+     {
+-      Elf32_Shdr *shdr = elf32_getshdr (scn);
+-      if (shdr == NULL)
++      shdr.s32 = elf32_getshdr (scn);
++      if (shdr.s32 == NULL)
+ 	return -1;
+ 
+-      sh_flags = shdr->sh_flags;
+-      sh_type = shdr->sh_type;
+-      sh_addralign = shdr->sh_addralign;
++      sh_flags = shdr.s32->sh_flags;
++      sh_type = shdr.s32->sh_type;
++      sh_addralign = shdr.s32->sh_addralign;
+     }
+   else
+     {
+-      Elf64_Shdr *shdr = elf64_getshdr (scn);
+-      if (shdr == NULL)
++      shdr.s64 = elf64_getshdr (scn);
++      if (shdr.s64 == NULL)
+ 	return -1;
+ 
+-      sh_flags = shdr->sh_flags;
+-      sh_type = shdr->sh_type;
+-      sh_addralign = shdr->sh_addralign;
++      sh_flags = shdr.s64->sh_flags;
++      sh_type = shdr.s64->sh_type;
++      sh_addralign = shdr.s64->sh_addralign;
+     }
+ 
+   if ((sh_flags & SHF_ALLOC) != 0)
+@@ -679,17 +684,17 @@ elf_compress (Elf_Scn *scn, int type, un
+ 	 correctly and ignored when SHF_COMPRESSED is set.  */
+       if (elfclass == ELFCLASS32)
+ 	{
+-	  Elf32_Shdr *shdr = elf32_getshdr (scn);
+-	  shdr->sh_size = new_size;
+-	  shdr->sh_addralign = __libelf_type_align (ELFCLASS32, ELF_T_CHDR);
+-	  shdr->sh_flags |= SHF_COMPRESSED;
++	  shdr.s32->sh_size = new_size;
++	  shdr.s32->sh_addralign = __libelf_type_align (ELFCLASS32,
++							ELF_T_CHDR);
++	  shdr.s32->sh_flags |= SHF_COMPRESSED;
+ 	}
+       else
+ 	{
+-	  Elf64_Shdr *shdr = elf64_getshdr (scn);
+-	  shdr->sh_size = new_size;
+-	  shdr->sh_addralign = __libelf_type_align (ELFCLASS64, ELF_T_CHDR);
+-	  shdr->sh_flags |= SHF_COMPRESSED;
++	  shdr.s64->sh_size = new_size;
++	  shdr.s64->sh_addralign = __libelf_type_align (ELFCLASS64,
++							ELF_T_CHDR);
++	  shdr.s64->sh_flags |= SHF_COMPRESSED;
+ 	}
+ 
+       __libelf_reset_rawdata (scn, out_buf, new_size, 1, ELF_T_CHDR);
+@@ -731,17 +736,15 @@ elf_compress (Elf_Scn *scn, int type, un
+ 	 correctly and ignored when SHF_COMPRESSED is set.  */
+       if (elfclass == ELFCLASS32)
+ 	{
+-	  Elf32_Shdr *shdr = elf32_getshdr (scn);
+-	  shdr->sh_size = scn->zdata_size;
+-	  shdr->sh_addralign = scn->zdata_align;
+-	  shdr->sh_flags &= ~SHF_COMPRESSED;
++	  shdr.s32->sh_size = scn->zdata_size;
++	  shdr.s32->sh_addralign = scn->zdata_align;
++	  shdr.s32->sh_flags &= ~SHF_COMPRESSED;
+ 	}
+       else
+ 	{
+-	  Elf64_Shdr *shdr = elf64_getshdr (scn);
+-	  shdr->sh_size = scn->zdata_size;
+-	  shdr->sh_addralign = scn->zdata_align;
+-	  shdr->sh_flags &= ~SHF_COMPRESSED;
++	  shdr.s64->sh_size = scn->zdata_size;
++	  shdr.s64->sh_addralign = scn->zdata_align;
++	  shdr.s64->sh_flags &= ~SHF_COMPRESSED;
+ 	}
+ 
+       __libelf_reset_rawdata (scn, scn->zdata_base,
+--- a/libelf/elf_compress_gnu.c
++++ b/libelf/elf_compress_gnu.c
+@@ -59,25 +59,30 @@ elf_compress_gnu (Elf_Scn *scn, int infl
+   Elf64_Xword sh_flags;
+   Elf64_Word sh_type;
+   Elf64_Xword sh_addralign;
++  union shdr
++  {
++    Elf32_Shdr *s32;
++    Elf64_Shdr *s64;
++  } shdr;
+   if (elfclass == ELFCLASS32)
+     {
+-      Elf32_Shdr *shdr = elf32_getshdr (scn);
+-      if (shdr == NULL)
++      shdr.s32 = elf32_getshdr (scn);
++      if (shdr.s32 == NULL)
+ 	return -1;
+ 
+-      sh_flags = shdr->sh_flags;
+-      sh_type = shdr->sh_type;
+-      sh_addralign = shdr->sh_addralign;
++      sh_flags = shdr.s32->sh_flags;
++      sh_type = shdr.s32->sh_type;
++      sh_addralign = shdr.s32->sh_addralign;
+     }
+   else
+     {
+-      Elf64_Shdr *shdr = elf64_getshdr (scn);
+-      if (shdr == NULL)
++      shdr.s64 = elf64_getshdr (scn);
++      if (shdr.s64 == NULL)
+ 	return -1;
+ 
+-      sh_flags = shdr->sh_flags;
+-      sh_type = shdr->sh_type;
+-      sh_addralign = shdr->sh_addralign;
++      sh_flags = shdr.s64->sh_flags;
++      sh_type = shdr.s64->sh_type;
++      sh_addralign = shdr.s64->sh_addralign;
+     }
+ 
+   /* Allocated sections, or sections that are already are compressed
+@@ -122,15 +127,9 @@ elf_compress_gnu (Elf_Scn *scn, int infl
+ 	 sh_flags won't have a SHF_COMPRESSED hint in the GNU format.
+ 	 Just adjust the sh_size.  */
+       if (elfclass == ELFCLASS32)
+-	{
+-	  Elf32_Shdr *shdr = elf32_getshdr (scn);
+-	  shdr->sh_size = new_size;
+-	}
++	  shdr.s32->sh_size = new_size;
+       else
+-	{
+-	  Elf64_Shdr *shdr = elf64_getshdr (scn);
+-	  shdr->sh_size = new_size;
+-	}
++	  shdr.s64->sh_size = new_size;
+ 
+       __libelf_reset_rawdata (scn, out_buf, new_size, 1, ELF_T_BYTE);
+ 
+@@ -187,15 +186,9 @@ elf_compress_gnu (Elf_Scn *scn, int infl
+ 	 sh_flags won't have a SHF_COMPRESSED hint in the GNU format.
+ 	 Just adjust the sh_size.  */
+       if (elfclass == ELFCLASS32)
+-	{
+-	  Elf32_Shdr *shdr = elf32_getshdr (scn);
+-	  shdr->sh_size = size;
+-	}
++	shdr.s32->sh_size = size;
+       else
+-	{
+-	  Elf64_Shdr *shdr = elf64_getshdr (scn);
+-	  shdr->sh_size = size;
+-	}
++	shdr.s64->sh_size = size;
+ 
+       __libelf_reset_rawdata (scn, buf_out, size, sh_addralign,
+ 			      __libelf_data_type (&ehdr, sh_type,
diff --git a/package/libs/elfutils/patches/100-musl-compat.patch b/package/libs/elfutils/patches/100-musl-compat.patch
new file mode 100644
index 0000000..3fa095b
--- /dev/null
+++ b/package/libs/elfutils/patches/100-musl-compat.patch
@@ -0,0 +1,29 @@
+--- a/libdw/libdw_alloc.c
++++ b/libdw/libdw_alloc.c
+@@ -152,5 +152,5 @@ __attribute ((noreturn)) attribute_hidde
+ __libdw_oom (void)
+ {
+   while (1)
+-    error (EXIT_FAILURE, ENOMEM, "libdw");
++    error (EXIT_FAILURE, errno, gettext ("cannot allocate memory"));
+ }
+--- a/libdwfl/dwfl_error.c
++++ b/libdwfl/dwfl_error.c
+@@ -139,6 +139,7 @@ __libdwfl_seterrno (Dwfl_Error error)
+ static const char *
+ errnomsg(int error)
+ {
++#if defined(__GLIBC__) && !defined(__UCLIBC__)
+   /* Won't be changed by strerror_r, but not const so compiler doesn't throw warning */
+   static char unknown[] = "unknown error";
+ 
+@@ -149,6 +150,9 @@ errnomsg(int error)
+   static __thread char msg[128];
+   return strerror_r (error, msg, sizeof (msg)) ? unknown : msg;
+ #endif
++#else
++  return strerror (error & 0xffff);
++#endif
+ }
+ 
+ const char *
diff --git a/package/libs/elfutils/patches/101-no-fts.patch b/package/libs/elfutils/patches/101-no-fts.patch
new file mode 100644
index 0000000..29a6c4b
--- /dev/null
+++ b/package/libs/elfutils/patches/101-no-fts.patch
@@ -0,0 +1,83 @@
+--- a/libdwfl/argp-std.c
++++ b/libdwfl/argp-std.c
+@@ -51,9 +51,6 @@ static const struct argp_option options[
+   { "linux-process-map", 'M', "FILE", 0,
+     N_("Find addresses in files mapped as read from FILE"
+        " in Linux /proc/PID/maps format"), 0 },
+-  { "kernel", 'k', NULL, 0, N_("Find addresses in the running kernel"), 0 },
+-  { "offline-kernel", 'K', "RELEASE", OPTION_ARG_OPTIONAL,
+-    N_("Kernel with all modules"), 0 },
+   { "debuginfo-path", OPT_DEBUGINFO, "PATH", 0,
+     N_("Search path for separate debuginfo files"), 0 },
+   { NULL, 0, NULL, 0, NULL, 0 }
+@@ -80,15 +77,6 @@ static const Dwfl_Callbacks proc_callbac
+     .find_elf = INTUSE(dwfl_linux_proc_find_elf),
+   };
+ 
+-static const Dwfl_Callbacks kernel_callbacks =
+-  {
+-    .find_debuginfo = INTUSE(dwfl_standard_find_debuginfo),
+-    .debuginfo_path = &debuginfo_path,
+-
+-    .find_elf = INTUSE(dwfl_linux_kernel_find_elf),
+-    .section_address = INTUSE(dwfl_linux_kernel_module_section_address),
+-  };
+-
+ /* Structure held at state->HOOK.  */
+ struct parse_opt
+ {
+@@ -221,43 +209,6 @@ parse_opt (int key, char *arg, struct ar
+       }
+       break;
+ 
+-    case 'k':
+-      {
+-	struct parse_opt *opt = state->hook;
+-	if (opt->dwfl == NULL)
+-	  {
+-	    Dwfl *dwfl = INTUSE(dwfl_begin) (&kernel_callbacks);
+-	    int result = INTUSE(dwfl_linux_kernel_report_kernel) (dwfl);
+-	    if (result != 0)
+-	      return fail (dwfl, result, _("cannot load kernel symbols"), state);
+-	    result = INTUSE(dwfl_linux_kernel_report_modules) (dwfl);
+-	    if (result != 0)
+-	      /* Non-fatal to have no modules since we do have the kernel.  */
+-	      argp_failure (state, 0, result, _("cannot find kernel modules"));
+-	    opt->dwfl = dwfl;
+-	  }
+-	else
+-	  goto toomany;
+-      }
+-      break;
+-
+-    case 'K':
+-      {
+-	struct parse_opt *opt = state->hook;
+-	if (opt->dwfl == NULL)
+-	  {
+-	    Dwfl *dwfl = INTUSE(dwfl_begin) (&offline_callbacks);
+-	    int result = INTUSE(dwfl_linux_kernel_report_offline) (dwfl, arg,
+-								   NULL);
+-	    if (result != 0)
+-	      return fail (dwfl, result, _("cannot find kernel or modules"), state);
+-	    opt->dwfl = dwfl;
+-	  }
+-	else
+-	  goto toomany;
+-      }
+-      break;
+-
+     case ARGP_KEY_SUCCESS:
+       {
+ 	struct parse_opt *opt = state->hook;
+--- a/libdwfl/Makefile.am
++++ b/libdwfl/Makefile.am
+@@ -50,7 +50,7 @@ libdwfl_a_SOURCES = dwfl_begin.c dwfl_en
+ 		    argp-std.c find-debuginfo.c \
+ 		    dwfl_build_id_find_elf.c \
+ 		    dwfl_build_id_find_debuginfo.c \
+-		    linux-kernel-modules.c linux-proc-maps.c \
++		    linux-proc-maps.c \
+ 		    dwfl_addrmodule.c dwfl_addrdwarf.c \
+ 		    cu.c dwfl_module_nextcu.c dwfl_nextcu.c dwfl_cumodule.c \
+ 		    dwfl_module_addrdie.c dwfl_addrdie.c \
diff --git a/package/libs/elfutils/patches/102-fix-potential-deref-of-null-error.patch b/package/libs/elfutils/patches/102-fix-potential-deref-of-null-error.patch
new file mode 100644
index 0000000..6710e4e
--- /dev/null
+++ b/package/libs/elfutils/patches/102-fix-potential-deref-of-null-error.patch
@@ -0,0 +1,55 @@
+strip.c: Pointer `arhdr` created at strip.c:2741 and then dereferenced without NULL-check.
+The same situation for the `arhdr` pointer at the objdump.c:313 and
+the `h` pointer at the readelf.c:13545.
+
+Triggers found by static analyzer Svace.
+
+Signed-off-by: Maks Mishin <maks.mishinFZ@gmail.com>
+---
+ src/objdump.c | 5 +++++
+ src/readelf.c | 5 +++++
+ src/strip.c   | 5 +++++
+ 3 files changed, 15 insertions(+)
+
+--- a/src/objdump.c
++++ b/src/objdump.c
+@@ -311,6 +311,11 @@ handle_ar (int fd, Elf *elf, const char
+     {
+       /* The the header for this element.  */
+       Elf_Arhdr *arhdr = elf_getarhdr (subelf);
++      if (arhdr == NULL)
++	{
++	  printf ("cannot get arhdr: %s\n", elf_errmsg (-1));
++	  exit (1);
++	}
+ 
+       /* Skip over the index entries.  */
+       if (strcmp (arhdr->ar_name, "/") != 0
+--- a/src/readelf.c
++++ b/src/readelf.c
+@@ -13543,6 +13543,11 @@ dump_archive_index (Elf *elf, const char
+ 			  as_off, fname, elf_errmsg (-1));
+ 
+ 	  const Elf_Arhdr *h = elf_getarhdr (subelf);
++	  if (h == NULL)
++	{
++	  printf ("cannot get arhdr: %s\n", elf_errmsg (-1));
++	  exit (1);
++	}
+ 
+ 	  printf (_("Archive member '%s' contains:\n"), h->ar_name);
+ 
+--- a/src/strip.c
++++ b/src/strip.c
+@@ -2739,6 +2739,11 @@ handle_ar (int fd, Elf *elf, const char
+     {
+       /* The the header for this element.  */
+       Elf_Arhdr *arhdr = elf_getarhdr (subelf);
++	  if (arhdr == NULL)
++	{
++	  printf ("cannot get arhdr: %s\n", elf_errmsg (-1));
++	  exit (1);
++	}
+ 
+       if (elf_kind (subelf) == ELF_K_ELF)
+ 	result |= handle_elf (fd, subelf, new_prefix, arhdr->ar_name, 0, NULL);
diff --git a/package/libs/elfutils/patches/200-fix-build-warning.patch b/package/libs/elfutils/patches/200-fix-build-warning.patch
new file mode 100644
index 0000000..3c48b98
--- /dev/null
+++ b/package/libs/elfutils/patches/200-fix-build-warning.patch
@@ -0,0 +1,10 @@
+--- a/lib/xasprintf.c
++++ b/lib/xasprintf.c
+@@ -30,6 +30,7 @@
+ # include <config.h>
+ #endif
+ 
++#include <errno.h>
+ #include <stdarg.h>
+ #include <stdio.h>
+ #include <stdlib.h>
diff --git a/package/libs/gettext-full/Makefile b/package/libs/gettext-full/Makefile
new file mode 100644
index 0000000..0a7782c
--- /dev/null
+++ b/package/libs/gettext-full/Makefile
@@ -0,0 +1,187 @@
+#
+# Copyright (C) 2006-2015 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:=gettext-full
+PKG_VERSION:=0.22.5
+PKG_RELEASE:=1
+
+PKG_SOURCE:=gettext-$(PKG_VERSION).tar.xz
+PKG_SOURCE_URL:=@GNU/gettext
+PKG_HASH:=fe10c37353213d78a5b83d48af231e005c4da84db5ce88037d88355938259640
+PKG_BUILD_DIR:=$(BUILD_DIR)/gettext-$(PKG_VERSION)
+HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/gettext-$(PKG_VERSION)
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
+PKG_LICENSE:=GPL-3.0-or-later
+PKG_CPE_ID:=cpe:/a:gnu:gettext
+
+PKG_INSTALL:=1
+PKG_BUILD_DEPENDS:=gettext-full/host libunistring libxml2
+PKG_BUILD_PARALLEL:=0
+
+PKG_FIXUP:=autoreconf
+
+HOST_BUILD_DEPENDS:=gperf/host libiconv-full/host libunistring/host libxml2/host
+HOST_BUILD_PARALLEL:=0
+
+PKG_SUBDIRS:= \
+	$$$$(foreach dir, \
+		intl \
+		intl-csharp \
+		intl-java \
+		its \
+		gnulib-lib \
+		gnulib-local \
+		lib \
+		$$$$(SUBDIR_libasprintf) \
+		libgettextpo \
+		libgrep \
+		libtextstyle \
+		m4 \
+		misc \
+		po \
+		projects \
+		src \
+		styles \
+		gettext-runtime \
+		gettext-tools \
+	,$$$$(wildcard $$$$(dir)) )
+
+PKG_MAKEFILES_FAKE:= \
+	gnulib-local/m4/Makefile \
+	libtextstyle/gnulib-local/Makefile \
+	libtextstyle/m4/Makefile \
+	m4/Makefile
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+
+define Package/libintl-full
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=GNU Internationalization library
+  URL:=http://www.gnu.org/software/gettext/
+  ABI_VERSION:=8
+endef
+
+export GNULIB_SRCDIR:=$(HOST_GNULIB_SRCDIR)
+
+TARGET_CFLAGS += $(FPIC)
+ifneq ($(HOST_OS),Linux)
+  TARGET_CFLAGS += -I$(STAGING_DIR_HOSTPKG)/include
+endif
+
+CONFIGURE_ARGS += \
+	--enable-shared \
+	--enable-static \
+	--disable-libasprintf \
+	--disable-rpath \
+	--enable-nls \
+	--disable-java \
+	--disable-openmp \
+	--disable-curses \
+	--with-included-gettext \
+	--without-libintl-prefix \
+	--without-libexpat-prefix \
+	--with-libunistring-prefix=$(STAGING_DIR)/usr \
+	--with-libxml2-prefix=$(STAGING_DIR) \
+	--without-emacs
+
+HOST_CONFIGURE_ARGS += \
+	--disable-shared \
+	--enable-static \
+	--disable-libasprintf \
+	--disable-rpath \
+	--disable-java \
+	--disable-openmp \
+	--without-emacs \
+	--with-libiconv-prefix=$(STAGING_DIR_HOSTPKG) \
+	--with-libunistring-prefix=$(STAGING_DIR_HOSTPKG) \
+	--with-libxml2-prefix=$(STAGING_DIR_HOSTPKG)
+
+HOST_CONFIGURE_VARS += \
+	EMACS="no" \
+
+HOST_CFLAGS += $(HOST_FPIC)
+
+define Host/Bootstrap
+	( \
+		cd $(HOST_BUILD_DIR); \
+		$(AM_TOOL_PATHS) \
+		./autogen.sh \
+	)
+endef
+
+define Host/Prepare
+	$(call Host/Prepare/Default)
+	$(if $(QUILT),,$(call Host/Bootstrap))
+endef
+
+define Host/Configure
+	$(if $(QUILT),$(call Host/Bootstrap))
+	$(call Host/Configure/Default)
+endef
+
+define Host/Compile
+	$(foreach makefile,$(PKG_MAKEFILES_FAKE),printf '%s\n%s\n' 'all:' 'install:' > $(HOST_BUILD_DIR)/$(makefile); )
+	$(call Host/Compile/Default,SUBDIRS='$(PKG_SUBDIRS)')
+endef
+
+define Build/Bootstrap
+	( \
+		cd $(PKG_BUILD_DIR); \
+		$(AM_TOOL_PATHS) \
+		./autogen.sh \
+	)
+endef
+
+define Build/Prepare
+	$(call Build/Prepare/Default)
+	$(if $(QUILT),,$(call Build/Bootstrap))
+endef
+
+define Build/Configure
+	$(if $(QUILT),$(call Build/Bootstrap))
+	$(call Build/Configure/Default)
+endef
+
+define Build/Compile
+	$(foreach makefile,$(PKG_MAKEFILES_FAKE),printf '%s\n%s\n' 'all:' 'install:' > $(PKG_BUILD_DIR)/$(makefile); )
+	$(call Build/Compile/Default,SUBDIRS='$(PKG_SUBDIRS)')
+endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/lib/libintl-full/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/libintl.h $(1)/usr/lib/libintl-full/include/
+
+	$(INSTALL_DIR) $(1)/usr/lib/libintl-full/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libintl.{a,so*} $(1)/usr/lib/libintl-full/lib/
+
+	$(INSTALL_DIR) $(1)/usr/share/aclocal
+	$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/aclocal/* $(1)/usr/share/aclocal/
+
+	$(SED) '/read dummy/d' $(STAGING_DIR_HOSTPKG)/bin/gettextize
+endef
+
+define Host/Install
+	$(call Host/Compile/Default,install SUBDIRS='$(PKG_SUBDIRS)')
+	$(LN) msgfmt $(STAGING_DIR_HOSTPKG)/bin/gmsgfmt
+endef
+
+define Build/Install
+	$(call Build/Install/Default,install SUBDIRS='$(PKG_SUBDIRS)')
+endef
+
+define Package/libintl-full/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libintl.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call HostBuild))
+$(eval $(call BuildPackage,libintl-full))
diff --git a/package/libs/gettext-full/patches/000-relocatable.patch b/package/libs/gettext-full/patches/000-relocatable.patch
new file mode 100644
index 0000000..a95c268
--- /dev/null
+++ b/package/libs/gettext-full/patches/000-relocatable.patch
@@ -0,0 +1,30 @@
+--- a/gettext-tools/misc/autopoint.in
++++ b/gettext-tools/misc/autopoint.in
+@@ -27,7 +27,11 @@ archive_version=@ARCHIVE_VERSION@
+ 
+ # Set variables
+ # - gettext_datadir     directory where the data files are stored.
+-prefix="@prefix@"
++if [ -n "$STAGING_DIR_HOSTPKG" ]; then
++	prefix="$STAGING_DIR_HOSTPKG"
++else
++	prefix="@prefix@"
++fi
+ datarootdir="@datarootdir@"
+ : ${gettext_datadir="@datadir@/gettext"}
+ : ${AUTOM4TE=autom4te}
+--- a/gettext-tools/misc/gettextize.in
++++ b/gettext-tools/misc/gettextize.in
+@@ -27,7 +27,11 @@ archive_version=@ARCHIVE_VERSION@
+ 
+ # Set variables
+ # - gettext_datadir     directory where the data files are stored.
+-prefix="@prefix@"
++if [ -n "$STAGING_DIR_HOSTPKG" ]; then
++	prefix="$STAGING_DIR_HOSTPKG"
++else
++	prefix="@prefix@"
++fi
+ datarootdir="@datarootdir@"
+ : ${gettext_datadir="@datadir@/gettext"}
+ : ${AUTOM4TE=autom4te}
diff --git a/package/libs/gettext-full/patches/001-autotools.patch b/package/libs/gettext-full/patches/001-autotools.patch
new file mode 100644
index 0000000..7e1f005
--- /dev/null
+++ b/package/libs/gettext-full/patches/001-autotools.patch
@@ -0,0 +1,24 @@
+--- a/gettext-runtime/man/Makefile.am
++++ b/gettext-runtime/man/Makefile.am
+@@ -176,8 +176,7 @@ textdomain.3.html: textdomain.3.in
+ bindtextdomain.3.html: bindtextdomain.3.in
+ bind_textdomain_codeset.3.html: bind_textdomain_codeset.3.in
+ 
+-install-html-local:
+-	$(MKDIR_P) $(DESTDIR)$(htmldir)
++install-html: installdirs-html
+ 	for file in $(man_HTML); do \
+ 	  if test -f $$file; then dir=.; else dir=$(srcdir); fi; \
+ 	  $(INSTALL_DATA) $$dir/$$file $(DESTDIR)$(htmldir)/$$file; \
+--- a/gettext-tools/man/Makefile.am
++++ b/gettext-tools/man/Makefile.am
+@@ -158,8 +158,7 @@ recode-sr-latin.1.html: recode-sr-latin.
+ gettextize.1.html: gettextize.1
+ autopoint.1.html: autopoint.1
+ 
+-install-html-local:
+-	$(MKDIR_P) $(DESTDIR)$(htmldir)
++install-html: installdirs-html
+ 	for file in $(man_HTML); do \
+ 	  if test -f $$file; then dir=.; else dir=$(srcdir); fi; \
+ 	  $(INSTALL_DATA) $$dir/$$file $(DESTDIR)$(htmldir)/$$file; \
diff --git a/package/libs/gettext-full/patches/100-libxml-no-force-included.patch b/package/libs/gettext-full/patches/100-libxml-no-force-included.patch
new file mode 100644
index 0000000..af5c0a4
--- /dev/null
+++ b/package/libs/gettext-full/patches/100-libxml-no-force-included.patch
@@ -0,0 +1,31 @@
+--- a/libtextstyle/gnulib-local/modules/libxml.diff
++++ /dev/null
+@@ -1,28 +0,0 @@
+-*** libxml.orig	2018-10-28 14:37:07.007164889 +0100
+---- libxml	2019-02-14 22:19:29.994771110 +0100
+-***************
+-*** 118,124 ****
+-  fabs
+-  
+-  configure.ac:
+-! gl_LIBXML
+-  
+-  Makefile.am:
+-  if INCLUDED_LIBXML
+---- 118,133 ----
+-  fabs
+-  
+-  configure.ac:
+-! # In libtextstyle, we don't want to use an external libxml, because its
+-! # dependencies and their dynamic relocations have an impact on the startup
+-! # time of a program that is linked with it. As you can see by using
+-! # 'readelf -r ... | wc -l' and 'readelf -d ... | grep NEEDED':
+-! # - libxml2.so has more than 3300 relocations and depends on libicuuc.
+-! #   - libicuuc.so has more than 4900 relocations and depends on libstdc++.
+-! #     - libstdc++.so has more than 4600 relocations.
+-! # These are more than 12800 relocations, to perform at program startup.
+-! # So, force the use of the included libxml part.
+-! gl_LIBXML([yes])
+-  
+-  Makefile.am:
+-  if INCLUDED_LIBXML
diff --git a/package/libs/gettext-full/patches/200-libunistring-missing-link.patch b/package/libs/gettext-full/patches/200-libunistring-missing-link.patch
new file mode 100644
index 0000000..19a1ae1
--- /dev/null
+++ b/package/libs/gettext-full/patches/200-libunistring-missing-link.patch
@@ -0,0 +1,21 @@
+--- a/autogen.sh
++++ b/autogen.sh
+@@ -81,6 +81,7 @@ if ! $skip_gnulib; then
+     getopt-gnu
+     gettext-h
+     havelib
++    libunistring-optional
+     memmove
+     noreturn
+     progname
+--- a/gettext-runtime/src/Makefile.am
++++ b/gettext-runtime/src/Makefile.am
+@@ -43,7 +43,7 @@ envsubst_SOURCES = envsubst.c
+ 
+ # Link dependencies.
+ # Need @LTLIBICONV@ because striconv.c uses iconv().
+-LDADD = ../gnulib-lib/libgrt.a @LTLIBINTL@ @LTLIBICONV@ $(WOE32_LDADD)
++LDADD = ../gnulib-lib/libgrt.a $(LTLIBUNISTRING) @LTLIBINTL@ @LTLIBICONV@ $(WOE32_LDADD)
+ 
+ # Specify installation directory, for --enable-relocatable.
+ gettext_CFLAGS = -DINSTALLDIR=\"$(bindir)\"
diff --git a/package/libs/gmp/Makefile b/package/libs/gmp/Makefile
new file mode 100644
index 0000000..5e5882c
--- /dev/null
+++ b/package/libs/gmp/Makefile
@@ -0,0 +1,71 @@
+#
+# Copyright (C) 2006-2016 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:=gmp
+PKG_VERSION:=6.3.0
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
+PKG_SOURCE_URL:=@GNU/gmp/
+PKG_HASH:=a3c2b80201b89e68616f4ad30bc66aee4927c3ce50e33929ca819d5c43538898
+
+PKG_BUILD_PARALLEL:=0
+PKG_INSTALL:=1
+PKG_FIXUP:=autoreconf
+PKG_LICENSE:=GPL-2.0-or-later
+PKG_CPE_ID:=cpe:/a:gmplib:gmp
+
+PKG_BUILD_FLAGS:=no-mips16
+
+include $(INCLUDE_DIR)/host-build.mk
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libgmp
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=GNU multiprecision arithmetic library
+  URL:=http://gmplib.org/
+  ABI_VERSION:=10
+endef
+
+define Package/libgmp/description
+	GMP is a free library for arbitrary precision arithmetic, operating on
+	signed integers, rational numbers, and floating point numbers.
+endef
+
+TARGET_CFLAGS += $(FPIC)
+CONFIGURE_VARS += CC="$(TARGET_CROSS)gcc"
+CONFIGURE_ARGS += \
+	--enable-shared \
+	--enable-static \
+	--without-readline \
+	--disable-fft \
+
+define Build/Compile
+	$(call Build/Compile/Default, \
+		DESTDIR="$(PKG_INSTALL_DIR)" \
+		CC="$(TARGET_CC)" \
+		all \
+	)
+endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/gmp* $(1)/usr/include/
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libgmp.{a,so*} $(1)/usr/lib/
+endef
+
+define Package/libgmp/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libgmp.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libgmp))
+$(eval $(call HostBuild))
diff --git a/package/libs/jansson/Makefile b/package/libs/jansson/Makefile
new file mode 100644
index 0000000..e2b5206
--- /dev/null
+++ b/package/libs/jansson/Makefile
@@ -0,0 +1,51 @@
+#
+# Copyright (C) 2011-2017 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:=jansson
+PKG_VERSION:=2.14
+PKG_RELEASE:=3
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://codeload.github.com/akheron/$(PKG_NAME)/tar.gz/v$(PKG_VERSION)?
+PKG_HASH:=c739578bf6b764aa0752db9a2fdadcfe921c78f1228c7ec0bb47fa804c55d17b
+
+PKG_LICENSE:=MIT
+PKG_LICENSE_FILES:=LICENSE
+PKG_CPE_ID:=cpe:/a:jansson_project:jansson
+
+PKG_BUILD_FLAGS:=lto
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+CMAKE_INSTALL:=1
+CMAKE_OPTIONS += \
+	-DJANSSON_BUILD_DOCS:BOOL=OFF \
+	-DJANSSON_BUILD_SHARED_LIBS:BOOL=ON \
+	-DJANSSON_EXAMPLES:BOOL=OFF \
+	-DJANSSON_WITHOUT_TESTS:BOOL=ON
+
+define Package/jansson
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=Jansson library
+  URL:=http://www.digip.org/jansson/
+  ABI_VERSION:=4
+endef
+
+define Package/jansson/description
+  Jansson is a C library for encoding, decoding and manipulating JSON data
+endef
+
+define Package/jansson/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libjansson*so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,jansson))
diff --git a/package/libs/keyutils/Makefile b/package/libs/keyutils/Makefile
new file mode 100644
index 0000000..888b70f
--- /dev/null
+++ b/package/libs/keyutils/Makefile
@@ -0,0 +1,92 @@
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=keyutils
+PKG_VERSION:=1.6.3
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/keyutils.git/snapshot/
+PKG_HASH:=a61d5706136ae4c05bd48f86186bcfdbd88dd8bd5107e3e195c924cfc1b39bb4
+PKG_CPE_ID:=cpe:/a:keyutils_project:keyutils
+
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libkeyutils
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=Key utilities library
+  URL:=https://people.redhat.com/dhowells/keyutils/
+  LICENSE:=LGPL-2.1-or-later
+  LICENSE_FILES:=LICENSE.LGPL
+  ABI_VERSION:=1
+endef
+
+define Package/keyctl
+  SECTION:=utils
+  CATEGORY:=Utilities
+  SUBMENU:=Encryption
+  TITLE:=keyctl
+  DEPENDS:=+libkeyutils
+  LICENSE:=GPL-2.0-or-later
+  LICENSE_FILES:=LICENSE.GPL
+endef
+
+define Package/keyutils
+  SECTION:=utils
+  CATEGORY:=Utilities
+  SUBMENU:=Encryption
+  TITLE:=keyutils (request-key and key.dns_resolver)
+  DEPENDS:=+libkeyutils
+  LICENSE:=GPL-2.0-or-later
+  LICENSE_FILES:=LICENSE.GPL
+endef
+
+define Package/keyutils/description
+  Key utilities
+endef
+
+MAKE_FLAGS += \
+	BINDIR=/bin \
+	LIBDIR=/usr/lib \
+	SBINDIR=/sbin \
+	CFLAGS="$(TARGET_CFLAGS) $(FPIC)"
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
+
+	$(INSTALL_DIR) $(1)/usr/lib/
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libkeyutils.a $(1)/usr/lib/
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libkeyutils.so.$(ABI_VERSION)* $(1)/usr/lib/
+endef
+
+define Package/libkeyutils/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libkeyutils.so.$(ABI_VERSION)* $(1)/usr/lib/
+endef
+
+define Package/keyutils/install
+	$(INSTALL_DIR) $(1)/sbin
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/request-key $(1)/sbin/
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/sbin/key.dns_resolver $(1)/sbin/
+
+	$(INSTALL_DIR) $(1)/etc/keyutils $(1)/etc/request-key.d
+	$(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/request-key.conf $(1)/etc/
+endef
+
+define Package/keyctl/install
+	$(INSTALL_DIR) $(1)/bin
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/bin/keyctl $(1)/bin
+endef
+
+$(eval $(call BuildPackage,libkeyutils))
+$(eval $(call BuildPackage,keyutils))
+$(eval $(call BuildPackage,keyctl))
diff --git a/package/libs/keyutils/patches/010-reproducible-build.patch b/package/libs/keyutils/patches/010-reproducible-build.patch
new file mode 100644
index 0000000..0507f91
--- /dev/null
+++ b/package/libs/keyutils/patches/010-reproducible-build.patch
@@ -0,0 +1,11 @@
+--- a/Makefile
++++ b/Makefile
+@@ -109,7 +109,7 @@ all: keyctl request-key key.dns_resolver
+ ###############################################################################
+ #RPATH = -Wl,-rpath,$(LIBDIR)
+ 
+-VCPPFLAGS	:= -DPKGBUILD="\"$(shell date -u +%F)\""
++VCPPFLAGS	:= -DPKGBUILD="\"for OpenWrt"\"
+ VCPPFLAGS	+= -DPKGVERSION="\"keyutils-$(VERSION)\""
+ VCPPFLAGS	+= -DAPIVERSION="\"libkeyutils-$(APIVERSION)\""
+ 
diff --git a/package/libs/keyutils/patches/020-rindex.patch b/package/libs/keyutils/patches/020-rindex.patch
new file mode 100644
index 0000000..5137518
--- /dev/null
+++ b/package/libs/keyutils/patches/020-rindex.patch
@@ -0,0 +1,17 @@
+--- a/key.dns_resolver.c
++++ b/key.dns_resolver.c
+@@ -717,12 +717,12 @@ int main(int argc, char *argv[])
+ 	keyend = buf + ktlen + 1;
+ 
+ 	/* the actual key description follows the last semicolon */
+-	keyend = rindex(keyend, ';');
++	keyend = strrchr(keyend, ';');
+ 	if (!keyend)
+ 		error("Invalid key description: %s", buf);
+ 	keyend++;
+ 
+-	name = index(keyend, ':');
++	name = strchr(keyend, ':');
+ 	if (!name)
+ 		dns_query_a_or_aaaa(keyend, callout_info);
+ 
diff --git a/package/libs/libagpstp/Config.in b/package/libs/libagpstp/Config.in
new file mode 100644
index 0000000..8ef1e17
--- /dev/null
+++ b/package/libs/libagpstp/Config.in
@@ -0,0 +1,39 @@
+# IMS configuration
+
+menu "Configuration"
+	depends on PACKAGE_agpstp
+
+config AGPSTP_PREBUILT
+	bool "agpstp prebuilt"
+	default y
+	help
+		use prebuilt agpstp image
+
+if !AGPSTP_PREBUILT
+
+config AGPSTP_PREBUILT_OVERRIDE
+	bool "prebuilt override"
+	default n
+	help
+		Force prebuilt override - when enabled, the build process
+		will also copy the output image to the prebuilt directory even if
+		it exists. As a byproduct, the package will be compiled from scratch
+		even if there are no changes in the sources, as the package
+		directory is always updated.
+
+
+config AGPSTP_LOCAL_CODE
+	bool "compile local code(dev only)"
+	default n
+	help
+	    agpstp local_code
+
+config AGPSTP_DEBUG_MODE
+	bool "debug_mode"
+	default n
+	help
+		agpstp debug_mode
+
+
+endif
+endmenu
diff --git a/package/libs/libagpstp/Makefile b/package/libs/libagpstp/Makefile
new file mode 100644
index 0000000..79b0f81
--- /dev/null
+++ b/package/libs/libagpstp/Makefile
@@ -0,0 +1,116 @@
+#
+# Copyright (C) 2010-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+define Package/agpstp/config
+    source "$(SOURCE)/Config.in"
+endef
+ifeq ($(CONFIG_USE_GLIBC),y)
+toolchain:=-glibc
+endif
+PKG_NAME:=agpstp
+PKG_VERSION:=2024-11-08
+PKG_REV_LONG:=f1b1863caff7e284ed7b7d97d74fb84076929b59
+
+GCC_MAJOR := $(shell echo $(CONFIG_GCC_VERSION) | cut -d. -f1)
+ifneq ($(GCC_MAJOR),)
+ifeq ($(shell [ $(GCC_MAJOR) -gt 12 ] && echo 1 || echo 0), 1)
+    $(info GCC_MAJOR is greater than 12)
+    gccversion:=-gcc$(GCC_MAJOR)
+else
+    $(info GCC_MAJOR is not greater than 12)
+endif
+endif
+
+PKG_REV:=$(shell echo $(PKG_REV_LONG) | cut -c1-7)
+PKG_TAG:=$(PKG_NAME)-v21$(gccversion)$(toolchain)-v$(PKG_VERSION)-r$(PKG_REV)
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_TAG)
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=ssh://$(USER)@source.asrmicro.com:29418/asr/lbs/agpstp -b master
+PKG_SOURCE_SUBDIR:=$(PKG_TAG)
+PKG_SOURCE_VERSION:=$(PKG_REV)
+PKG_SOURCE:=$(PKG_TAG).tar.gz
+
+PREBUILT_FNAME:=prebuilt-$(PKG_TAG)
+PREBUILT_FPATH:=$(CURDIR)/prebuilt/$(PREBUILT_FNAME).tar.gz
+
+ifeq ($(CONFIG_AGPSTP_LOCAL_CODE),y)
+	USE_SOURCE_DIR:=$(MRVLDIR)/agpstp
+endif
+
+PKG_INSTALL:=1
+
+PKG_MAINTAINER:=Hui Zhang <huizhang@asrmicro.com>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/agpstp
+  SECTION:=libs
+  CATEGORY:=Libraries
+  DEPENDS:=+libpthread +liblog 
+  TITLE:=ASR AGPSTP Library
+endef
+
+define Package/agpstp/description
+  ASR AGPSTP Library support
+endef
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_TAG)
+
+ifneq ($(CONFIG_AGPSTP_PREBUILT),)
+define Download
+endef
+define Build/Prepare
+    $(if $(wildcard $(PREBUILT_FPATH)),,@echo "Error: $(PREBUILT_FPATH) not found"; false)
+endef
+define Build/Configure
+endef
+define Build/Compile
+endef
+define Build/Install
+	$(INSTALL_DIR) $(PKG_INSTALL_DIR)
+	echo "Unpacking prebuilt..." && \
+	$(TAR) -zxvf $(PREBUILT_FPATH) -C $(TMP_DIR) && \
+	$(CP) $(TMP_DIR)/$(PREBUILT_FNAME)/* $(PKG_INSTALL_DIR) && \
+	rm -rf $(TMP_DIR)/$(PREBUILT_FNAME);
+endef
+
+else
+ifeq ($(CONFIG_AGPSTP_LOCAL_CODE),y)
+define Package/agpstp/Prepare
+    rm -rf $(PKG_BUILD_DIR)
+    ln -s $(USE_SOURCE_DIR) $(PKG_BUILD_DIR)
+endef
+endif
+endif
+
+define Prebuilt/Pack
+    echo "Packing prebuilt..." && \
+    mkdir -p $(TMP_DIR)/$(PREBUILT_FNAME) && \
+    cd $(TMP_DIR) && \
+    $(CP) $(PKG_INSTALL_DIR)/* ./$(PREBUILT_FNAME) && \
+    $(TAR) czf $(PREBUILT_FNAME).tar.gz $(PREBUILT_FNAME) && \
+    mv $(TMP_DIR)/$(PREBUILT_FNAME).tar.gz $(PREBUILT_FPATH) && \
+    rm -rf $(TMP_DIR)/$(PREBUILT_FNAME);
+endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/lib $(1)/usr/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include
+endef
+
+define Package/agpstp/install
+	$(INSTALL_DIR) $(1)/usr/lib $(1)/usr/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/*.h $(1)/usr/include
+	$(if $(wildcard $(PREBUILT_FPATH)),$(if $(CONFIG_AGPSTP_PREBUILT_OVERRIDE),@echo "WARNING: prebuilt override!"; $(call Prebuilt/Pack)),$(call Prebuilt/Pack))
+endef
+
+$(eval $(call BuildPackage,agpstp))
diff --git a/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-gcc13-glibc-v2024-09-04-r4691352.tar.gz b/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-gcc13-glibc-v2024-09-04-r4691352.tar.gz
new file mode 100644
index 0000000..372dbc9
--- /dev/null
+++ b/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-gcc13-glibc-v2024-09-04-r4691352.tar.gz
Binary files differ
diff --git a/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-gcc13-v2024-09-04-r4691352.tar.gz b/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-gcc13-v2024-09-04-r4691352.tar.gz
new file mode 100644
index 0000000..ac08798
--- /dev/null
+++ b/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-gcc13-v2024-09-04-r4691352.tar.gz
Binary files differ
diff --git a/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-gcc13-v2024-10-22-r31e8a01.tar.gz b/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-gcc13-v2024-10-22-r31e8a01.tar.gz
new file mode 100644
index 0000000..685a9e9
--- /dev/null
+++ b/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-gcc13-v2024-10-22-r31e8a01.tar.gz
Binary files differ
diff --git a/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-gcc13-v2024-11-08-rf1b1863.tar.gz b/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-gcc13-v2024-11-08-rf1b1863.tar.gz
new file mode 100644
index 0000000..ef6ef33
--- /dev/null
+++ b/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-gcc13-v2024-11-08-rf1b1863.tar.gz
Binary files differ
diff --git a/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-v2023-02-23-r5908adb.tar.gz b/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-v2023-02-23-r5908adb.tar.gz
new file mode 100644
index 0000000..b959fd5
--- /dev/null
+++ b/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-v2023-02-23-r5908adb.tar.gz
Binary files differ
diff --git a/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-v2023-03-23-rc8a015e.tar.gz b/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-v2023-03-23-rc8a015e.tar.gz
new file mode 100644
index 0000000..84e3544
--- /dev/null
+++ b/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-v2023-03-23-rc8a015e.tar.gz
Binary files differ
diff --git a/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-v2023-04-24-r2e06d0e.tar.gz b/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-v2023-04-24-r2e06d0e.tar.gz
new file mode 100644
index 0000000..97dc83e
--- /dev/null
+++ b/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-v2023-04-24-r2e06d0e.tar.gz
Binary files differ
diff --git a/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-v2023-05-05-r809419f.tar.gz b/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-v2023-05-05-r809419f.tar.gz
new file mode 100644
index 0000000..cdf2223
--- /dev/null
+++ b/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-v2023-05-05-r809419f.tar.gz
Binary files differ
diff --git a/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-v2023-05-17-r2a3e174.tar.gz b/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-v2023-05-17-r2a3e174.tar.gz
new file mode 100644
index 0000000..6948efe
--- /dev/null
+++ b/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-v2023-05-17-r2a3e174.tar.gz
Binary files differ
diff --git a/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-v2023-10-12-rce6c9d3.tar.gz b/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-v2023-10-12-rce6c9d3.tar.gz
new file mode 100644
index 0000000..97481ea
--- /dev/null
+++ b/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-v2023-10-12-rce6c9d3.tar.gz
Binary files differ
diff --git a/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-v2024-09-04-r4691352.tar.gz b/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-v2024-09-04-r4691352.tar.gz
new file mode 100644
index 0000000..a162b3d
--- /dev/null
+++ b/package/libs/libagpstp/prebuilt/prebuilt-agpstp-v21-v2024-09-04-r4691352.tar.gz
Binary files differ
diff --git a/package/libs/libbpf/Makefile b/package/libs/libbpf/Makefile
new file mode 100644
index 0000000..3a3d11f
--- /dev/null
+++ b/package/libs/libbpf/Makefile
@@ -0,0 +1,72 @@
+#
+# Copyright (C) 2020-2024 Tony Ambardar <itugrok@yahoo.com>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libbpf
+PKG_VERSION:=1.5.0
+PKG_RELEASE:=1
+
+PKG_SOURCE_URL:=https://github.com/libbpf/libbpf
+PKG_MIRROR_HASH:=e8a4407459b2ee49626aba9ae3ed8d7b8eaef1d03a67b6d0c38404afccb4989d
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_VERSION:=v$(PKG_VERSION)
+PKG_ABI_VERSION:=$(firstword $(subst .,$(space),$(PKG_VERSION)))
+
+PKG_MAINTAINER:=Tony Ambardar <itugrok@yahoo.com>
+PKG_CPE_ID:=cpe:/a:libbpf_project:libbpf
+
+PKG_BUILD_FLAGS:=no-mips16 no-gc-sections no-lto
+PKG_BUILD_PARALLEL:=1
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/nls.mk
+
+define Package/libbpf
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=libbpf - eBPF helper library
+  LICENSE:=LGPL-2.1 OR BSD-2-Clause
+  ABI_VERSION:=$(PKG_ABI_VERSION)
+  URL:=http://www.kernel.org
+  DEPENDS:=+libelf
+endef
+
+define Package/libbpf/description
+  libbpf is a library for loading eBPF programs and reading and manipulating eBPF objects from user-space.
+endef
+
+MAKE_FLAGS += \
+	$(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='') \
+	LIBSUBDIR=lib
+
+MAKE_PATH = src
+
+define Build/InstallDev/libbpf
+	$(INSTALL_DIR) $(1)/usr/include/bpf
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/bpf/*.h $(1)/usr/include/bpf/
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libbpf.{a,so*} \
+		$(1)/usr/lib/
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libbpf.pc \
+		$(1)/usr/lib/pkgconfig/
+	$(SED) 's,/usr/include,$$$${prefix}/include,g' \
+		$(1)/usr/lib/pkgconfig/libbpf.pc
+	$(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' \
+		$(1)/usr/lib/pkgconfig/libbpf.pc
+endef
+
+Build/InstallDev=$(Build/InstallDev/libbpf)
+
+define Package/libbpf/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libbpf.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libbpf))
diff --git a/package/libs/libbsd/Makefile b/package/libs/libbsd/Makefile
new file mode 100644
index 0000000..3c42d64
--- /dev/null
+++ b/package/libs/libbsd/Makefile
@@ -0,0 +1,49 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libbsd
+PKG_VERSION:=0.11.8
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
+PKG_SOURCE_URL:=https://libbsd.freedesktop.org/releases
+PKG_HASH:=55fdfa2696fb4d55a592fa9ad14a9df897c7b0008ddb3b30c419914841f85f33
+
+PKG_LICENSE:=BSD-4-Clause
+PKG_LICENSE_FILES:=COPYING
+PKG_CPE_ID:=cpe:/a:freedesktop:libbsd
+
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+PKG_BUILD_DEPENDS := libmd
+PKG_FIXUP:=autoreconf
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libbsd
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=common BSD library
+  ABI_VERSION:=0
+endef
+
+define Package/libbsd/description
+ This library provides useful functions commonly found on BSD systems, and lacking on others like GNU systems, thus making it easier to port projects with strong BSD origins, without needing to embed the same code over and over again on each project.
+endef
+
+TARGET_CFLAGS += -D_LARGEFILE64_SOURCE
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libbsd.{la,so*} $(1)/usr/lib/
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libbsd*.pc $(1)/usr/lib/pkgconfig/
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
+endef
+
+define Package/libbsd/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libbsd.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libbsd))
diff --git a/package/libs/libbsd/patches/001-fix-libpath.patch b/package/libs/libbsd/patches/001-fix-libpath.patch
new file mode 100644
index 0000000..ec72f77
--- /dev/null
+++ b/package/libs/libbsd/patches/001-fix-libpath.patch
@@ -0,0 +1,13 @@
+do not use host path to fix cross compiling
+
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -230,7 +230,7 @@ if NEED_TRANSPARENT_LIBMD
+ 	(echo '/* GNU ld script'; \
+ 	 echo ' * The MD5 functions are provided by the libmd library. */'; \
+ 	 cat format.ld; \
+-	 echo "GROUP($(runtimelibdir)/$$soname AS_NEEDED($(MD5_LIBS)))"; \
++	 echo "GROUP($$soname AS_NEEDED($(MD5_LIBS)))"; \
+ 	)>$(DESTDIR)$(libdir)/libbsd.so
+ else
+ 	if [ "$(libdir)" != "$(runtimelibdir)" ]; then \
diff --git a/package/libs/libcap/Makefile b/package/libs/libcap/Makefile
new file mode 100644
index 0000000..9892093
--- /dev/null
+++ b/package/libs/libcap/Makefile
@@ -0,0 +1,117 @@
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libcap
+PKG_VERSION:=2.69
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
+PKG_SOURCE_URL:=@KERNEL/linux/libs/security/linux-privs/libcap2
+PKG_HASH:=f311f8f3dad84699d0566d1d6f7ec943a9298b28f714cae3c931dfd57492d7eb
+
+PKG_MAINTAINER:=Paul Wassi <p.wassi@gmx.at>
+PKG_LICENSE:=GPL-2.0-only
+PKG_LICENSE_FILES:=License
+PKG_CPE_ID:=cpe:/a:libcap_project:libcap
+
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/kernel.mk
+
+define Package/libcap/Default
+  TITLE:=Linux capabilities library
+  SECTION:=libs
+  CATEGORY:=Libraries
+  URL:=https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/
+endef
+
+define Package/libcap/description/Default
+  Linux capabilities
+endef
+
+define Package/libcap
+  $(call Package/libcap/Default)
+  TITLE += library
+endef
+
+define Package/libcap-bin
+  $(call Package/libcap/Default)
+  TITLE += binaries
+  DEPENDS += libcap
+endef
+
+define Package/libcap-bin/description
+  $(call Package/libcap/description/Default)
+  .
+  This package contains the libcap utilities.
+endef
+
+define Package/libcap-bin/config
+  if PACKAGE_libcap-bin
+  config PACKAGE_libcap-bin-capsh-shell
+    string "capsh shell"
+    help
+      Set the capsh shell.
+    default "/bin/sh"
+  endif
+endef
+
+MAKE_FLAGS += \
+    BUILD_CC="$(CC)" \
+    BUILD_CFLAGS="$(FPIC) -I$(PKG_BUILD_DIR)/libcap/include" \
+    CFLAGS="$(TARGET_CFLAGS)" \
+    LD="$(TARGET_CC) -Wl,-x -shared" \
+    LDFLAGS="$(TARGET_LDFLAGS)" \
+    INDENT="| true" \
+    GOLANG="no" \
+    PAM_CAP="no" \
+    RAISE_SETFCAP="no" \
+    DYNAMIC="yes" \
+    lib="lib"
+
+TARGET_CFLAGS += $(FPIC)
+
+ifneq ($(CONFIG_PACKAGE_libcap-bin-capsh-shell),)
+TARGET_CFLAGS += -DSHELL='\"$(CONFIG_PACKAGE_libcap-bin-capsh-shell)\"'
+endif
+
+TARGET_CFLAGS += $(if $(CONFIG_USE_MUSL),-Dpthread_yield=sched_yield)
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include/sys
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/sys/*.h $(1)/usr/include/sys/
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/lib/libcap.{so*,a} $(1)/usr/lib/
+	$(INSTALL_DATA) $(PKG_INSTALL_DIR)/lib/libpsx.a $(1)/usr/lib/
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(INSTALL_DATA) $(PKG_INSTALL_DIR)/lib/pkgconfig/libcap.pc $(1)/usr/lib/pkgconfig/
+	$(SED) 's,exec_prefix=,exec_prefix=/usr,g' $(1)/usr/lib/pkgconfig/libcap.pc
+	$(SED) 's,/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/libcap.pc
+	$(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/libcap.pc
+	$(INSTALL_DATA) $(PKG_INSTALL_DIR)/lib/pkgconfig/libpsx.pc $(1)/usr/lib/pkgconfig/
+	$(SED) 's,exec_prefix=,exec_prefix=/usr,g' $(1)/usr/lib/pkgconfig/libpsx.pc
+	$(SED) 's,/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/libpsx.pc
+	$(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/libpsx.pc
+endef
+
+define Package/libcap/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/lib/libcap.so* $(1)/usr/lib/
+endef
+
+define Package/libcap-bin/install
+	$(INSTALL_DIR) $(1)/usr/sbin
+	$(CP) $(PKG_INSTALL_DIR)/sbin/capsh     $(1)/usr/sbin/
+	$(CP) $(PKG_INSTALL_DIR)/sbin/getcap    $(1)/usr/sbin/
+	$(CP) $(PKG_INSTALL_DIR)/sbin/getpcaps  $(1)/usr/sbin/
+	$(CP) $(PKG_INSTALL_DIR)/sbin/setcap    $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,libcap))
+$(eval $(call BuildPackage,libcap-bin))
diff --git a/package/libs/libcap/patches/300-disable-tests.patch b/package/libs/libcap/patches/300-disable-tests.patch
new file mode 100644
index 0000000..1cf9cc4
--- /dev/null
+++ b/package/libs/libcap/patches/300-disable-tests.patch
@@ -0,0 +1,10 @@
+--- a/Makefile
++++ b/Makefile
+@@ -17,7 +17,6 @@ ifeq ($(GOLANG),yes)
+ 	$(MAKE) -C go $@
+ 	rm -f cap/go.sum
+ endif
+-	$(MAKE) -C tests $@
+ 	$(MAKE) -C progs $@
+ 	$(MAKE) -C doc $@
+ 
diff --git a/package/libs/libcap/patches/900-use-more-compatible-shebang.patch b/package/libs/libcap/patches/900-use-more-compatible-shebang.patch
new file mode 100644
index 0000000..454c703
--- /dev/null
+++ b/package/libs/libcap/patches/900-use-more-compatible-shebang.patch
@@ -0,0 +1,8 @@
+--- a/progs/mkcapshdoc.sh
++++ b/progs/mkcapshdoc.sh
+@@ -1,4 +1,4 @@
+-#!/bin/bash
++#!/usr/bin/env bash
+ # This script generates some C code for inclusion in the capsh binary.
+ # The Makefile generally only generates the .c code and compares it
+ # with the checked in code in the progs directory.
diff --git a/package/libs/libcgi/Makefile b/package/libs/libcgi/Makefile
new file mode 100755
index 0000000..8ec68da
--- /dev/null
+++ b/package/libs/libcgi/Makefile
@@ -0,0 +1,56 @@
+#
+# Copyright (C) 2006-2014 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:=libcgi
+PKG_VERSION:=1.0
+#PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+#PKG_SOURCE_URL:=https://s3.amazonaws.com/json-c_releases/releases/
+#PKG_MD5SUM:=aa02367d2f7a830bf1e3376f77881e98
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+PKG_LICENSE:=MIT
+PKG_LICENSE_FILES:=COPYING
+
+#PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+
+#PKG_MAINTAINER:=Felix Fietkau <nbd@openwrt.org>
+#USE_SOURCE_DIR:=$(TOPDIR)/marvell/services/web/cgi/libs/libcgi/$(PKG_NAME)-$(PKG_VERSION)
+CGI_SOURCE_DIR:=$(TOPDIR)/marvell/services/web/cgi/libs/libcgi/$(PKG_NAME)-$(PKG_VERSION)
+
+include $(INCLUDE_DIR)/package.mk
+
+TARGET_CFLAGS += $(FPIC)
+
+define Package/libcgi
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:= CGI library for C
+endef
+
+#define Build/Prepare
+#	mkdir -p $(PKG_BUILD_DIR)
+#	cp -rf $(CGI_SOURCE_DIR)/* $(PKG_BUILD_DIR)
+#endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) $(PKG_BUILD_DIR)/src/cgi.h $(1)/usr/include/
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_BUILD_DIR)/src/${PKG_NAME}.{a,so*} $(1)/usr/lib/
+endef
+
+define Package/libcgi/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_BUILD_DIR)/src/${PKG_NAME}.so $(1)/usr/lib/
+endef
+
+
+$(eval $(call BuildPackage,libcgi))
diff --git a/package/libs/libcgi/patches/001-add_check_session.patch b/package/libs/libcgi/patches/001-add_check_session.patch
new file mode 100644
index 0000000..d4c8b7e
--- /dev/null
+++ b/package/libs/libcgi/patches/001-add_check_session.patch
@@ -0,0 +1,230 @@
+diff -r -u libcgi-back-1.0/libcgi-1.0/src/cgi.c libcgi-1.0/src/cgi.c
+--- libcgi-back-1.0/libcgi-1.0/src/cgi.c	2014-10-28 15:16:27.000000000 +0800
++++ libcgi-1.0/src/cgi.c	2015-05-11 16:19:55.980570364 +0800
+@@ -143,16 +143,18 @@
+ 	char *method;
+ 
+ 	method = getenv("REQUEST_METHOD");
+-
++	system("echo \"cgi_process_form!\" > /tmp/my_debug");
+ 	// When METHOD has no contents, the default action is to process it as GET method
+-	if (method == NULL || !strcasecmp("GET", method)) {
++	if (method == NULL || !strcasecmp("GET", method) || !strcasecmp("POST", method)) {
+ 		char *dados; 
+ 		dados =	getenv("QUERY_STRING");
+-
++		
+ 		// Sometimes, GET comes with not any data
+-		if (dados == NULL || strlen(dados) < 1)
+-			return NULL;
+-
++		if (dados == NULL || strlen(dados) < 1) {
++				system("echo \"query string is null!\" > /tmp/my_debug");
++				return NULL;
++		}
++		system("echo \"query string is not null!\" > /tmp/my_debug");
+ 		return process_data(dados, &formvars_start, &formvars_last, '=', '&');
+ 	}
+ 	else if (!strcasecmp("POST", method)) {
+diff -r -u libcgi-back-1.0/libcgi-1.0/src/cgi.h libcgi-1.0/src/cgi.h
+--- libcgi-back-1.0/libcgi-1.0/src/cgi.h	2014-10-28 15:16:27.000000000 +0800
++++ libcgi-1.0/src/cgi.h	2015-05-08 16:56:51.865844100 +0800
+@@ -25,6 +25,14 @@
+ extern "C" {
+ #endif
+ 
++#define LAST_ACCESS_TIME "last_time"
++#define LOG_STATUS "log_status"
++#define USER_ID "user_name"
++#define USER_PSWD "user_pswd"
++//second
++#define MAX_SESSION_TIMEOUT 600 
++//tmp buffer size
++#define TMP_BUF_MAX 256
+ 
+ // general purpose linked list. Actualy isn't very portable
+ // because uses only 'name' and 'value' variables to store data.
+@@ -36,6 +44,15 @@
+         struct formvarsA *next;
+ } formvars;
+ 
++enum {
++	SESS_VALID,
++	SESS_NO_COOKIE,
++	SESS_NO_ACCESS_TIME,
++	SESS_NOT_FOUND,
++	SESS_INVALID,
++	SESS_TIMEOUT
++};
++
+ extern formvars *formvars_start;
+ extern formvars *formvars_last;
+ extern formvars *cookies_start;
+diff -r -u libcgi-back-1.0/libcgi-1.0/src/cookie.c libcgi-1.0/src/cookie.c
+--- libcgi-back-1.0/libcgi-1.0/src/cookie.c	2014-10-28 15:16:27.000000000 +0800
++++ libcgi-1.0/src/cookie.c	2015-05-12 10:27:11.335231627 +0800
+@@ -92,14 +92,30 @@
+ 	aux = cookies;
+ 
+ 	while (cookies) {
+-		position = 0;
++start:	position = 0;
++		
+ 		data = (formvars *)malloc(sizeof(formvars));
+ 		if (!data)
+ 			libcgi_error(E_MEMORY, "%s, line %s", __FILE__, __LINE__);
+ 
+-		while (*aux++ != '=')
+-			position++;
+ 
++		if ((strchr(cookies, '=')) == NULL) {
++			aux = NULL;
++			free(data);
++			cookies = aux;
++			goto end;
++		}
++		
++		while (*aux++ != '=') {
++			if (*(aux-1) != ';') {
++				position++;
++			} else {
++				position = 0;
++				free(data);
++				cookies = aux;
++				goto start;
++			}
++		}
+ 		data->name = (char *)malloc(position+1);
+ 		if (!data->name) {
+ 			libcgi_error(E_MEMORY, "%s, line %s", __FILE__, __LINE__);
+@@ -120,7 +136,8 @@
+ 			while (*aux++ != ';') 
+ 				position++;
+ 			// Eliminate the blank space after ';'
+-			aux++;
++			while(*aux == ' ')
++				aux++;
+ 		}
+ 
+ 		data->value = (char *)malloc(position + 1);
+@@ -134,7 +151,7 @@
+ 		slist_add(data, &cookies_start, &cookies_last);
+ 		cookies = aux;
+ 	}
+-
++end:
+ 	return cookies_start;
+ }
+ 
+diff -r -u libcgi-back-1.0/libcgi-1.0/src/session.c libcgi-1.0/src/session.c
+--- libcgi-back-1.0/libcgi-1.0/src/session.c	2014-10-28 15:16:27.000000000 +0800
++++ libcgi-1.0/src/session.c	2015-05-12 14:23:44.854940353 +0800
+@@ -124,6 +124,7 @@
+ 	SESS_OPEN_FILE
+ } sess_error;
+ 
++
+ // This variables are used to control the linked list of all
+ // session objects. Most of time you don't need to use them
+ // directly
+@@ -214,8 +215,6 @@
+ {
+ 	formvars *data;
+ 	
+-	cgi_init_headers();
+-	
+ 	// Rewrites all data to session file
+ 	sess_file = fopen(sess_fname, "w");
+ 
+@@ -547,10 +546,90 @@
+ 	fclose(fp);
+ 	sess_initialized = 1;
+ 	free(buf);
+-
+ 	return 1;
+ }
+ 
++/**
++* check the request validation.
++* This function is responsible for reading a exist session file and  
++* validate the request. It no session file found will return session_invalid
++* if file found but session timeout will return session_timeout, meanwhile
++* destroy the session file anyway
++* if seesion is valid will return session_valid and refresh the session access time
++* @see session_destroy()
++*/
++int cgi_session_check()
++{
++	char *buf = NULL, *sid = NULL, *value = NULL;;
++	struct stat st;
++	FILE *fp;
++	struct timeval cur_tv;
++	time_t last_time;
++	char tmp[TMP_BUF_MAX] = { 0 };
++
++	// Get the session ID
++	sid = cgi_cookie_value(SESSION_COOKIE_NAME);
++	
++	// If there isn't a session ID
++	if (sid == NULL) {
++		return SESS_NO_COOKIE;
++	}
++
++	save_path_len = strlen(SESSION_SAVE_PATH) + strlen(SESSION_FILE_PREFIX);
++		
++	sess_fname = (char *)malloc(save_path_len + SESS_ID_LEN + 1);
++	if (!sess_fname)
++		libcgi_error(E_MEMORY, "File %s, line %s", __FILE__, __LINE__);
++
++	snprintf(sess_fname, (SESS_ID_LEN + save_path_len + 1), "%s%s%s", SESSION_SAVE_PATH, SESSION_FILE_PREFIX, sid);
++	sess_fname[SESS_ID_LEN + save_path_len] = '\0';
++	
++	errno = 0;		
++	fp = fopen(sess_fname, "r");
++	if (errno == ENOENT) { 
++		// The file doesn't exists
++		return SESS_NOT_FOUND;
++	}
++
++	strncpy(sess_id, sid, SESS_ID_LEN);
++	sess_id[SESS_ID_LEN] = '\0';
++
++	stat(sess_fname, &st);
++	buf = (char *)malloc(st.st_size + 2);
++	if (!buf)
++		libcgi_error(E_MEMORY, "File %s, line %s", __FILE__, __LINE__);
++		
++	fgets(buf, st.st_size+1, fp);
++	if (buf != NULL && strlen(buf) > 1)
++		process_data(buf, &sess_list_start, &sess_list_last, '=', ';');
++
++	fclose(fp);
++	sess_initialized = 1;
++	free(buf);
++	
++	gettimeofday(&cur_tv, NULL);
++	value = cgi_session_var(LAST_ACCESS_TIME);
++	if (!value) {
++		return SESS_NO_ACCESS_TIME;
++	}
++
++	last_time = (time_t)atol(value);
++
++	if (cur_tv.tv_sec - last_time > MAX_SESSION_TIMEOUT) {
++		cgi_session_destroy();
++		return SESS_TIMEOUT;
++	}
++
++	//refresh last access time
++	memset(tmp, 0, TMP_BUF_MAX);
++	snprintf(tmp, TMP_BUF_MAX - 1, "%u", cur_tv.tv_sec );
++	if ( cgi_session_alter_var(LAST_ACCESS_TIME, tmp)) {
++		return SESS_VALID;
++	}
++	else {
++		return SESS_INVALID;
++	}
++}
+ /** 
+ * @}
+ */
diff --git a/package/libs/libcgi/patches/002-fix_md5_bug.patch b/package/libs/libcgi/patches/002-fix_md5_bug.patch
new file mode 100644
index 0000000..94e0466
--- /dev/null
+++ b/package/libs/libcgi/patches/002-fix_md5_bug.patch
@@ -0,0 +1,38 @@
+--- ../libcgi-1.0-last/libcgi-1.0/src/md5.c	2014-10-28 15:16:27.000000000 +0800
++++ libcgi-1.0/src/md5.c	2015-05-20 15:36:47.000000000 +0800
+@@ -65,17 +65,18 @@
+ **/
+ char *md5(const char *str)
+ {
+-	char *tmp, buf[32];
++	char *tmp, buf[32] = { 0 };
+ 	int i, str_size;
+ 	unsigned char md[16];
+ 	MD5_CTX context;
+ 
+ 	// allocating a pointer to the string
+ 	str_size = strlen(str) + 1;
+-	tmp = (char *)malloc(str_size);
++	tmp = (char *)malloc(32 + 1);
+ 	if (tmp == NULL)
+ 		libcgi_error(E_MEMORY, "%s, line %s", __FILE__, __LINE__);
+ 
++	memset(tmp, 0, 32 + 1);
+ 	// initializing a context that will content the encrypted string
+ 	MD5Init(&context);
+ 	MD5Update(&context, str, strlen(str));
+@@ -85,12 +86,12 @@
+ 	
+ 	// here, the loop is less than 32 because a md5 string can content
+ 	// just 32 bytes
+-	for(i = 0; i < 32; i++) {
++	for(i = 0; i <16; i++) {
+ 		snprintf(buf, sizeof(float), "%02x", md[i]);
+ 		strncat(tmp, buf, sizeof(float));
+ 	}
+ 
+-	tmp[i] = '\0';
++	tmp[32] = '\0';
+ 
+ 	// returning a encrypted string
+ 	return tmp;
diff --git a/package/libs/libcgi/patches/003-fix_y2038.patch b/package/libs/libcgi/patches/003-fix_y2038.patch
new file mode 100644
index 0000000..496401c
--- /dev/null
+++ b/package/libs/libcgi/patches/003-fix_y2038.patch
@@ -0,0 +1,21 @@
+diff -r -u libcgi-1.0_back/src/session.c libcgi-1.0/src/session.c
+--- libcgi-1.0_back/src/session.c	2024-10-24 13:02:58.302808361 +0800
++++ libcgi-1.0/src/session.c	2024-10-24 13:04:34.088241739 +0800
+@@ -613,7 +613,7 @@
+ 		return SESS_NO_ACCESS_TIME;
+ 	}
+ 
+-	last_time = (time_t)atol(value);
++	last_time = (time_t)atoll(value);
+ 
+ 	if (cur_tv.tv_sec - last_time > MAX_SESSION_TIMEOUT) {
+ 		cgi_session_destroy();
+@@ -622,7 +622,7 @@
+ 
+ 	//refresh last access time
+ 	memset(tmp, 0, TMP_BUF_MAX);
+-	snprintf(tmp, TMP_BUF_MAX - 1, "%u", cur_tv.tv_sec );
++	snprintf(tmp, TMP_BUF_MAX - 1, "%lld", cur_tv.tv_sec );
+ 	if ( cgi_session_alter_var(LAST_ACCESS_TIME, tmp)) {
+ 		return SESS_VALID;
+ 	}
diff --git a/package/libs/libedit/Makefile b/package/libs/libedit/Makefile
new file mode 100644
index 0000000..56852bc
--- /dev/null
+++ b/package/libs/libedit/Makefile
@@ -0,0 +1,60 @@
+#
+# Copyright (C) 2016-2018 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+VERSION:=3.1
+RELEASE_DATE:=20240808
+
+PKG_NAME:=libedit
+PKG_VERSION:=$(RELEASE_DATE).$(VERSION)
+PKG_RELEASE:=1
+
+PKG_MAINTAINER:=Daniel Salzman <daniel.salzman@nic.cz>
+PKG_LICENSE:=BSD-3-Clause
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(RELEASE_DATE)-$(VERSION)
+PKG_SOURCE:=$(PKG_NAME)-$(RELEASE_DATE)-$(VERSION).tar.gz
+PKG_SOURCE_URL:=https://thrysoee.dk/editline/
+PKG_HASH:=5f0573349d77c4a48967191cdd6634dd7aa5f6398c6a57fe037cc02696d6099f
+
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libedit
+	SECTION:=libs
+	CATEGORY:=Libraries
+	TITLE:=BSD editline and history library
+	URL:=http://thrysoee.dk/editline/
+	DEPENDS:=+libncurses
+endef
+
+define Package/libedit/description
+	Generic line editing, history, and tokenization functions similar to GNU Readline.
+endef
+
+define Build/InstallDev
+	$(INSTALL_DIR)						$(1)/usr/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/*.h		$(1)/usr/include/
+
+	$(INSTALL_DIR)						$(1)/usr/include/editline
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/editline/*.h	$(1)/usr/include/editline/
+	
+	$(INSTALL_DIR)						$(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libedit.{a,so*}	$(1)/usr/lib/
+
+	$(INSTALL_DIR)						$(1)/usr/lib/pkgconfig
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libedit.pc	$(1)/usr/lib/pkgconfig
+endef
+
+define Package/libedit/install
+	$(INSTALL_DIR)					$(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libedit.so.*	$(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libedit))
diff --git a/package/libs/libev/Makefile b/package/libs/libev/Makefile
new file mode 100644
index 0000000..92c4377
--- /dev/null
+++ b/package/libs/libev/Makefile
@@ -0,0 +1,60 @@
+#
+# Copyright (C) 2014-2015 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:=libev
+PKG_VERSION:=4.33
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://dist.schmorp.de/libev/Attic/
+PKG_HASH:=507eb7b8d1015fbec5b935f34ebed15bf346bed04a11ab82b8eee848c4205aea
+PKG_LICENSE:=BSD-2-Clause or GPL-2.0-or-later
+PKG_LICENSE_FILES:=LICENSE
+PKG_MAINTAINER:=Karl Palsson <karlp@tweak.net.au>
+
+PKG_BUILD_PARALLEL:=1
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+PKG_BUILD_FLAGS:=no-mips16
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libev
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=High-performance event loop
+  URL:=http://software.schmorp.de/pkg/libev.html
+endef
+
+define Package/libev/description
+ A full-featured and high-performance event loop that is loosely modelled after
+ libevent, but without its limitations and bugs.
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+CONFIGURE_ARGS += \
+	--enable-shared \
+	--enable-static \
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/event.h $(1)/usr/include/ev_event_compat.h
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/ev.h $(1)/usr/include/
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/ev++.h $(1)/usr/include/
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libev.{a,so*} $(1)/usr/lib/
+endef
+
+define Package/libev/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libev.so* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libev))
diff --git a/package/libs/libevent2/Makefile b/package/libs/libevent2/Makefile
new file mode 100644
index 0000000..e0a080d
--- /dev/null
+++ b/package/libs/libevent2/Makefile
@@ -0,0 +1,165 @@
+#
+# Copyright (C) 2011-2015 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:=libevent2
+PKG_VERSION:=2.1.12
+PKG_RELEASE:=2
+
+PKG_SOURCE:=libevent-$(PKG_VERSION)-stable.tar.gz
+PKG_SOURCE_URL:=https://github.com/libevent/libevent/releases/download/release-$(PKG_VERSION)-stable
+PKG_HASH:=92e6de1be9ec176428fd2367677e61ceffc2ee1cb119035037a27d346b0403bb
+PKG_BUILD_DIR:=$(BUILD_DIR)/libevent-$(PKG_VERSION)-stable
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
+PKG_LICENSE:=BSD-3-Clause
+PKG_LICENSE_FILES:=LICENSE
+PKG_CPE_ID:=cpe:/a:libevent_project:libevent
+
+PKG_CONFIG_DEPENDS:= \
+	CONFIG_PACKAGE_libevent2-openssl \
+	CONFIG_PACKAGE_libevent2-pthreads \
+	CONFIG_PACKAGE_libevent2-mbedtls
+
+PKG_BUILD_FLAGS:=gc-sections lto
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/libevent2/Default
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=Event notification
+  URL:=http://libevent.org
+  ABI_VERSION:=7
+endef
+
+define Package/libevent2/Default/description
+	The libevent API provides a mechanism to execute a callback function
+	when a specific event occurs on a file descriptor or after a timeout
+	has been reached. Furthermore, libevent also support callbacks due
+	to signals or regular timeouts.
+
+	libevent is meant to replace the event loop found in event driven
+	network servers. An application just needs to call event_dispatch()
+	and then add or remove events dynamically without having to change
+	the event loop.
+endef
+
+define Package/libevent2
+  $(call Package/libevent2/Default)
+  TITLE+= library (version 2.1)
+endef
+
+define Package/libevent2/description
+	$(call Package/libevent2/Default/description)
+
+	This package contains the libevent shared library historically
+	containing both the core & extra libraries.
+endef
+
+define Package/libevent2-core
+  $(call Package/libevent2/Default)
+  TITLE+= core library (version 2.1)
+endef
+
+define Package/libevent2-core/description
+	$(call Package/libevent2/Default/description)
+
+	This package contains the libevent core shared library for the event,
+	buffer & utility functions.
+endef
+
+define Package/libevent2-extra
+  $(call Package/libevent2/Default)
+  TITLE+= extra library (version 2.1)
+  DEPENDS+=+libevent2-core
+endef
+
+define Package/libevent2-extra/description
+	$(call Package/libevent2/Default/description)
+
+	This package contains the libevent extra shared library for specific
+	protocols including HTTP, DNS & RPC.
+endef
+
+define Package/libevent2-openssl
+  $(call Package/libevent2/Default)
+  TITLE+= OpenSSL library (version 2.1)
+  DEPENDS+=+libopenssl +libevent2-core
+endef
+
+define Package/libevent2-openssl/description
+	$(call Package/libevent2/Default/description)
+
+	This package contains the libevent OpenSSL shared library for encrypted
+	bufferevents.
+endef
+
+define Package/libevent2-pthreads
+  $(call Package/libevent2/Default)
+  TITLE+= Pthreads library (version 2.1)
+  DEPENDS+=+libpthread +libevent2-core
+endef
+
+define Package/libevent2-pthreads/description
+	$(call Package/libevent2/Default/description)
+
+	This package contains the libevent Pthreads shared library for
+	threading & locking.
+endef
+
+TARGET_CFLAGS += $(FPIC)
+TARGET_LDFLAGS += -Wl,--as-needed
+
+CMAKE_OPTIONS += \
+	-DEVENT__DISABLE_BENCHMARK:BOOL=ON \
+	-DEVENT__DISABLE_DEBUG_MODE:BOOL=ON \
+	-DEVENT__DISABLE_REGRESS:BOOL=ON \
+	-DEVENT__DISABLE_SAMPLES:BOOL=ON \
+	$(if $(CONFIG_PACKAGE_libevent2-openssl),-DEVENT__DISABLE_OPENSSL:BOOL=OFF,-DEVENT__DISABLE_OPENSSL:BOOL=ON) \
+	$(if $(CONFIG_PACKAGE_libevent2-pthreads),-DEVENT__DISABLE_THREAD_SUPPORT:BOOL=OFF,-DEVENT__DISABLE_THREAD_SUPPORT:BOOL=ON) \
+	-DEVENT__DISABLE_TESTS:BOOL=ON \
+	-DBUILD_TESTING:BOOL=OFF
+
+define Build/InstallDev
+	$(call Build/InstallDev/cmake,$(1))
+	$(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/libevent*.pc
+	$(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/libevent*.pc
+endef
+
+define Package/libevent2/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libevent-2.1.so.* $(1)/usr/lib/
+endef
+
+define Package/libevent2-core/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libevent_core-2.1.so.* $(1)/usr/lib/
+endef
+
+define Package/libevent2-extra/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libevent_extra-2.1.so.* $(1)/usr/lib/
+endef
+
+define Package/libevent2-openssl/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libevent_openssl-2.1.so.* $(1)/usr/lib/
+endef
+
+define Package/libevent2-pthreads/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libevent_pthreads-2.1.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libevent2))
+$(eval $(call BuildPackage,libevent2-core))
+$(eval $(call BuildPackage,libevent2-extra))
+$(eval $(call BuildPackage,libevent2-openssl))
+$(eval $(call BuildPackage,libevent2-pthreads))
diff --git a/package/libs/libevent2/patches/001-relative-cmake.patch b/package/libs/libevent2/patches/001-relative-cmake.patch
new file mode 100644
index 0000000..38dc187
--- /dev/null
+++ b/package/libs/libevent2/patches/001-relative-cmake.patch
@@ -0,0 +1,58 @@
+From 81c6b8823c1b58d7837e827bb1098aa5f9e5956b Mon Sep 17 00:00:00 2001
+From: "Jeremy W. Murphy" <jeremy.william.murphy@gmail.com>
+Date: Tue, 16 May 2023 05:07:36 +1000
+Subject: [PATCH] cmake: Only use relative paths for install DESTINATION option
+ (#1405)
+
+As described in #1404, the explicit use of CMAKE_INSTALL_PREFIX conflicts with using command-line --prefix.
+
+This simply removes all explicit use of CMAKE_INSTALL_PREFIX.
+
+Otherwise this path will be duplicated:
+
+    $ cmake -DCMAKE_BUILD_TYPE=debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_INSTALL_PREFIX=inst ..
+    $ DESTDIR=inst ninja install
+    ...
+    -- Installing: inst/src/le/libevent/.cmake-debug/inst/include/event2/util.h
+    -- Installing: inst/src/le/libevent/.cmake-debug/inst/include/event2/ws.h
+    ...
+
+Fixes: #1404
+Co-authored-by: Jeremy Murphy <jeremymu@blackmagicdesign.com>
+---
+ CMakeLists.txt              | 3 +--
+ cmake/AddEventLibrary.cmake | 4 ++--
+ 2 files changed, 3 insertions(+), 4 deletions(-)
+
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -1452,8 +1452,7 @@ endif()
+ # Installation preparation.
+ #
+ 
+-set(EVENT_INSTALL_CMAKE_DIR
+-    "${CMAKE_INSTALL_PREFIX}/lib/cmake/libevent")
++set(EVENT_INSTALL_CMAKE_DIR "lib/cmake/libevent")
+ 
+ export(PACKAGE libevent)
+ 
+--- a/cmake/AddEventLibrary.cmake
++++ b/cmake/AddEventLibrary.cmake
+@@ -31,7 +31,7 @@ macro(generate_pkgconfig LIB_NAME)
+     configure_file("lib${LIB_NAME}.pc.in" "lib${LIB_NAME}.pc" @ONLY)
+     install(
+         FILES "${CMAKE_CURRENT_BINARY_DIR}/lib${LIB_NAME}.pc"
+-        DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig"
++        DESTINATION "lib/pkgconfig"
+     )
+ endmacro()
+ 
+@@ -150,7 +150,7 @@ macro(add_event_library LIB_NAME)
+             set_target_properties(
+                 "${LIB_NAME}_shared" PROPERTIES
+                 OUTPUT_NAME "${LIB_NAME}-${EVENT_PACKAGE_RELEASE}.${CURRENT_MINUS_AGE}"
+-                INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib"
++                INSTALL_NAME_DIR "lib"
+                 LINK_FLAGS "-compatibility_version ${COMPATIBILITY_VERSION} -current_version ${COMPATIBILITY_VERSION}.${EVENT_ABI_LIBVERSION_REVISION}")
+         else()
+             math(EXPR CURRENT_MINUS_AGE "${EVENT_ABI_LIBVERSION_CURRENT}-${EVENT_ABI_LIBVERSION_AGE}")
diff --git a/package/libs/libiconv-full/Makefile b/package/libs/libiconv-full/Makefile
new file mode 100644
index 0000000..0c79397
--- /dev/null
+++ b/package/libs/libiconv-full/Makefile
@@ -0,0 +1,97 @@
+#
+# Copyright (C) 2006-2015 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:=libiconv-full
+PKG_VERSION:=1.17
+PKG_RELEASE:=1
+
+PKG_SOURCE:=libiconv-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@GNU/libiconv
+PKG_HASH:=8f74213b56238c85a50a5329f77e06198771e70dd9a739779f4c02f65d971313
+PKG_BUILD_DIR:=$(BUILD_DIR)/libiconv-$(PKG_VERSION)
+HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/libiconv-$(PKG_VERSION)
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
+PKG_LICENSE:=LGPL-2.1-or-later
+PKG_LICENSE_FILES:=COPYING.LIB
+
+PKG_FIXUP:=patch-libtool
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+
+define Package/libiconv-full/Default
+  URL:=https://www.gnu.org/software/libiconv/
+  TITLE:=Character set conversion
+endef
+
+define Package/libiconv-full
+  $(call Package/libiconv-full/Default)
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE+= library
+  ABI_VERSION:=2
+endef
+
+define Package/libcharset
+  $(call Package/libiconv-full/Default)
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE+= library
+  ABI_VERSION:=1
+endef
+
+define Package/iconv
+  $(call Package/libiconv-full/Default)
+  DEPENDS:=+libiconv-full +libcharset
+  SECTION:=utils
+  CATEGORY:=Utilities
+  TITLE+= utility
+endef
+
+CONFIGURE_ARGS += \
+	--enable-shared \
+	--enable-static \
+	--disable-rpath \
+	--enable-relocatable
+
+HOST_CONFIGURE_ARGS += \
+	--disable-shared \
+	--with-pic
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/lib/libiconv-full/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/iconv.h $(1)/usr/lib/libiconv-full/include/
+
+	$(INSTALL_DIR) $(1)/usr/lib/libiconv-full/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libcharset.{a,so*} $(1)/usr/lib/libiconv-full/lib/
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libiconv.{a,so*} $(1)/usr/lib/libiconv-full/lib/
+endef
+
+define Package/libcharset/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libcharset.so.* $(1)/usr/lib/
+endef
+
+define Package/libiconv-full/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libiconv.so.* $(1)/usr/lib/
+endef
+
+define Package/iconv/install
+	$(INSTALL_DIR) $(1)/usr/bin
+	$(CP) $(PKG_INSTALL_DIR)/usr/bin/iconv $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,libcharset))
+$(eval $(call BuildPackage,libiconv-full))
+$(eval $(call BuildPackage,iconv))
+$(eval $(call HostBuild))
diff --git a/package/libs/libjson-c/Makefile b/package/libs/libjson-c/Makefile
new file mode 100644
index 0000000..9c32ca5
--- /dev/null
+++ b/package/libs/libjson-c/Makefile
@@ -0,0 +1,60 @@
+#
+# Copyright (C) 2006-2014 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:=json-c
+PKG_VERSION:=0.18
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION)-nodoc.tar.gz
+PKG_SOURCE_URL:=https://s3.amazonaws.com/json-c_releases/releases/
+PKG_HASH:=602cdefc1d2aab8318fc0814b7ce7d59e72514d4276ca3eff92f35f86cf1c160
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
+PKG_LICENSE:=MIT
+PKG_LICENSE_FILES:=COPYING
+PKG_CPE_ID:=cpe:/a:json-c:json-c
+
+HOST_BUILD_PREFIX:=$(STAGING_DIR_HOST)
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+CMAKE_HOST_OPTIONS += \
+	-DDISABLE_EXTRA_LIBS=TRUE \
+	-DBUILD_SHARED_LIBS=FALSE
+
+CMAKE_OPTIONS += \
+	-DDISABLE_EXTRA_LIBS=TRUE
+
+define Package/libjson-c
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=javascript object notation
+  URL:=https://json-c.github.io/json-c/
+  ABI_VERSION:=5
+endef
+
+define Package/libjson-c/description
+ This package contains a library for javascript object notation backends.
+endef
+
+define Build/InstallDev
+	$(call Build/InstallDev/cmake,$(1))
+	$(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/json-c.pc
+	$(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/json-c.pc
+endef
+
+define Package/libjson-c/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libjson-c.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libjson-c))
+$(eval $(call HostBuild))
diff --git a/package/libs/libjson-c/patches/001-dont-build-docs.patch b/package/libs/libjson-c/patches/001-dont-build-docs.patch
new file mode 100644
index 0000000..68fbc17
--- /dev/null
+++ b/package/libs/libjson-c/patches/001-dont-build-docs.patch
@@ -0,0 +1,11 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -449,8 +449,6 @@ configure_file(json.h.cmakein ${PROJECT_
+ include_directories(${PROJECT_SOURCE_DIR})
+ include_directories(${PROJECT_BINARY_DIR})
+ 
+-add_subdirectory(doc)
+-
+ # "uninstall" custom target for make generators in unix like operating systems
+ # and if that target is not present
+ if (CMAKE_GENERATOR STREQUAL "Unix Makefiles")
diff --git a/package/libs/liblog/Makefile b/package/libs/liblog/Makefile
new file mode 100644
index 0000000..3e8030a
--- /dev/null
+++ b/package/libs/liblog/Makefile
@@ -0,0 +1,83 @@
+#
+# Copyright (C) 2010-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:=liblog
+PKG_VERSION:=1.0
+PKG_RELEASE=1
+
+PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
+SVC_LOG_DIR:=$(MRVLDIR)/services/android_wrapper/log
+SVC_SOURCE_DIR:=$(SVC_LOG_DIR)/liblog
+PKG_SOURCE_DIR:=$(SVC_SOURCE_DIR) $(STAGING_DIR)/usr/lib
+PKG_BUILD_PARALLEL:=0
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/liblog
+  SECTION:=libs
+  CATEGORY:=Libraries
+  DEPENDS:=+libprop2uci +libpthread
+  TITLE:=Marvell implementation for liblog (Android logging)
+endef
+
+define Package/liblog/description
+  Marvell implementation for liblog
+endef
+
+TARGET_CFLAGS += -ffunction-sections -fdata-sections
+TARGET_LDFLAGS += -Wl,--gc-sections
+
+ifeq "$(CONFIG_TARGET_mmp_asr1803_FALCON403)" "y"
+TARGET_CFLAGS += -DNO_LOGCAT_SUPPORT
+endif
+ifeq "$(CONFIG_TARGET_mmp_asr1903_LAPW503)" "y"
+TARGET_CFLAGS += -DNO_LOGCAT_SUPPORT
+endif
+
+define Build/Compile
+	$(MAKE) $(PKG_JOBS) -C $(SVC_SOURCE_DIR) \
+		SUBTARGET="$(SUBTARGET)" \
+		CROSS_COMPILE="$(TARGET_CROSS)" \
+		EXTRA_CFLAGS="$(TARGET_CFLAGS) -I$(STAGING_DIR)/usr/include -I$(TOOLCHAIN_DIR)/include" \
+		LD_FLAGS="$(TARGET_LDFLAGS) -L$(TOOLCHAIN_DIR)/lib/"\
+		INSTALL_DIR="$(PKG_INSTALL_DIR)" \
+		OBJ_DIR="$(PKG_BUILD_DIR)/obj" \
+		compile
+endef
+
+define Build/Clean
+@if [ -d $(PKG_BUILD_DIR) ]; then \
+	$(MAKE) $(PKG_JOBS) -C $(SVC_SOURCE_DIR) \
+		CROSS_COMPILE="$(TARGET_CROSS)" \
+		EXTRA_CFLAGS="$(TARGET_CFLAGS)" \
+		LD_FLAGS="$(TARGET_LDFLAGS)" \
+		INSTALL_DIR="$(PKG_INSTALL_DIR)" \
+		OBJ_DIR="$(PKG_BUILD_DIR)/obj" \
+		clean; \
+fi
+endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(INSTALL_DIR) $(1)/usr/include	
+	$(CP) -rf $(PKG_INSTALL_DIR)/lib/liblog.so $(1)/usr/lib/
+	$(CP) $(SVC_LOG_DIR)/cutils $(1)/usr/include
+	$(CP) $(SVC_LOG_DIR)/include $(1)/usr/include
+	$(CP) $(SVC_LOG_DIR)/android $(1)/usr/include
+endef
+
+define Package/liblog/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/lib/liblog.so $(1)/usr/lib/
+	mkdir -p $(BIN_DIR)/symbol/libs/liblog/lib
+	cp -rf $(PKG_BUILD_DIR)/obj/symbol/lib/liblog.so $(BIN_DIR)/symbol/libs/liblog/lib/
+endef
+
+$(eval $(call BuildPackage,liblog))
diff --git a/package/libs/libmd/Makefile b/package/libs/libmd/Makefile
new file mode 100644
index 0000000..06e516c
--- /dev/null
+++ b/package/libs/libmd/Makefile
@@ -0,0 +1,47 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libmd
+PKG_VERSION:=1.1.0
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
+PKG_SOURCE_URL:=https://archive.hadrons.org/software/libmd/
+PKG_HASH:=1bd6aa42275313af3141c7cf2e5b964e8b1fd488025caf2f971f43b00776b332
+
+PKG_LICENSE:=BSD-3-Clause
+PKG_LICENSE_FILES:=COPYING
+
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+TARGET_CFLAGS += $(FPIC)
+
+CONFIGURE_ARGS += \
+	--enable-static
+
+define Package/libmd
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=Message Digest functions from BSD systems
+  ABI_VERSION:=0
+endef
+
+define Package/libmd/description
+  This library provides message digest functions found on BSD systems either
+  on their libc or libmd libraries and lacking on others like GNU systems,
+  thus making it easier to port projects with strong BSD origins, without
+  needing to embed the same code over and over again on each project.
+endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libmd.a $(1)/usr/lib/
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libmd*.pc $(1)/usr/lib/pkgconfig/
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
+endef
+
+$(eval $(call BuildPackage,libmd))
diff --git a/package/libs/libml_utils/Makefile b/package/libs/libml_utils/Makefile
new file mode 100644
index 0000000..0ad7c65
--- /dev/null
+++ b/package/libs/libml_utils/Makefile
@@ -0,0 +1,41 @@
+#
+# Copyright (C) 2010-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:=ml_utils
+PKG_VERSION:=1.0
+PKG_RELEASE=1
+USE_SOURCE_DIR:=$(MRVLDIR)/services/android_wrapper/ml_utilset
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libml_utils
+  SECTION:=libs
+  CATEGORY:=Libraries
+  DEPENDS:=+libpthread +prop2uci +liblog
+  TITLE:=Marvell utils
+  DEFAULT:=y
+endef
+
+define Build/Clean
+	rm -rf $(USE_SOURCE_DIR)/*.so
+	rm -rf $(USE_SOURCE_DIR)/*.a
+	rm -rf $(USE_SOURCE_DIR)/*.o
+endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(USE_SOURCE_DIR)/libml_utils.so $(1)/usr/lib
+endef
+
+define Package/libml_utils/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(USE_SOURCE_DIR)/libml_utils.so $(1)/usr/lib
+endef
+
+$(eval $(call BuildPackage,libml_utils))
diff --git a/package/libs/libmnl/Makefile b/package/libs/libmnl/Makefile
new file mode 100644
index 0000000..06f79d5
--- /dev/null
+++ b/package/libs/libmnl/Makefile
@@ -0,0 +1,79 @@
+#
+# Copyright (C) 2011-2012 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:=libmnl
+PKG_VERSION:=1.0.5
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:= \
+	http://www.netfilter.org/projects/libmnl/files \
+	ftp://ftp.netfilter.org/pub/libmnl
+PKG_HASH:=274b9b919ef3152bfb3da3a13c950dd60d6e2bcd54230ffeca298d03b40d0525
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+PKG_LICENSE:=LGPL-2.1+
+PKG_CPE_ID:=cpe:/a:netfilter:libmnl
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libmnl
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=Minimalistic user-space library for Netlink
+  URL:=http://www.netfilter.org/projects/libmnl/
+  ABI_VERSION:=0
+endef
+
+define Package/libmnl/description
+ libmnl is a minimalistic user-space library oriented to Netlink developers.
+ There are a lot of common tasks in parsing, validating, constructing of
+ both the Netlink header and TLVs that are repetitive and easy to get wrong.
+ This library aims to provide simple helpers that allows you to re-use code
+ and to avoid re-inventing the wheel. The main features of this library are:
+ .
+ * Small: the shared library requires around 30KB for an x86-based computer.
+ .
+ * Simple: this library avoids complexity and elaborated abstractions that
+   tend to hide Netlink details.
+ .
+ * Easy to use: the library simplifies the work for Netlink-wise developers.
+   It provides functions to make socket handling, message building, validating,
+   parsing and sequence tracking, easier.
+ .
+ * Easy to re-use: you can use the library to build your own abstraction layer
+   on top of this library.
+ .
+ * Decoupling: the interdependency of the main bricks that compose the library
+   is reduced, i.e. the library provides many helpers, but the programmer is not
+   forced to use them.
+endef
+
+CONFIGURE_ARGS+= \
+	--enable-shared \
+	--enable-static \
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/libmnl $(1)/usr/include/
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libmnl.{a,so*} $(1)/usr/lib/
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libmnl.pc $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libmnl/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libmnl.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libmnl))
diff --git a/package/libs/libmnl/patches/001-fix_build.patch b/package/libs/libmnl/patches/001-fix_build.patch
new file mode 100644
index 0000000..d095ec8
--- /dev/null
+++ b/package/libs/libmnl/patches/001-fix_build.patch
@@ -0,0 +1,11 @@
+--- a/doxygen/Makefile.am
++++ b/doxygen/Makefile.am
+@@ -21,7 +21,7 @@ doxyfile.stamp: $(doc_srcs) Makefile.am
+ # The command has to be a single line so the functions work
+ # and so `make` gives all lines to `bash -c`
+ # (hence ";\" at the end of every line but the last).
+-	/bin/bash -p -c 'declare -A renamed_page;\
++	bash -p -c 'declare -A renamed_page;\
+ main(){ set -e; cd man/man3; rm -f _*;\
+   count_real_pages;\
+   rename_real_pages;\
diff --git a/package/libs/libmxml/Makefile b/package/libs/libmxml/Makefile
new file mode 100755
index 0000000..f39d761
--- /dev/null
+++ b/package/libs/libmxml/Makefile
@@ -0,0 +1,50 @@
+#
+# Copyright (C) 2006-2014 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:=mxml
+PKG_VERSION:=2.8
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
+
+#USE_SOURCE_DIR:=$(TOPDIR)/marvell/services/web/cgi/libs/libmxml/$(PKG_NAME)-$(PKG_VERSION)
+MXML_SOURCE_DIR:=$(MRVLDIR)/services/web/cgi/libs/libmxml/$(PKG_NAME)-$(PKG_VERSION)
+
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+TARGET_CFLAGS += $(FPIC)
+
+define Package/libmxml
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:= mini xml parser library
+endef
+
+#define Build/Prepare
+#	mkdir -p $(PKG_BUILD_DIR)
+#	cp -rf	$(MXML_SOURCE_DIR)/* $(PKG_BUILD_DIR)/	
+#endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) $(PKG_BUILD_DIR)/*.h $(1)/usr/include/
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_BUILD_DIR)/libmxml.{a,so*} $(1)/usr/lib/
+endef
+
+define Package/libmxml/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_BUILD_DIR)/libmxml.so.* $(1)/usr/lib/
+endef
+
+
+$(eval $(call BuildPackage,libmxml))
diff --git a/package/libs/libnetfilter-conntrack/Makefile b/package/libs/libnetfilter-conntrack/Makefile
new file mode 100644
index 0000000..97197b4
--- /dev/null
+++ b/package/libs/libnetfilter-conntrack/Makefile
@@ -0,0 +1,75 @@
+#
+# Copyright (C) 2009-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:=libnetfilter_conntrack
+PKG_VERSION:=1.0.9
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=https://www.netfilter.org/projects/libnetfilter_conntrack/files
+PKG_HASH:=67bd9df49fe34e8b82144f6dfb93b320f384a8ea59727e92ff8d18b5f4b579a8
+
+PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
+PKG_LICENSE:=GPL-2.0-or-later
+PKG_LICENSE_FILES:=COPYING
+PKG_CPE_ID:=cpe:/a:netfilter:libnetfilter_conntrack
+
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libnetfilter-conntrack
+  SECTION:=libs
+  CATEGORY:=Libraries
+  DEPENDS:=+libnfnetlink +kmod-nf-conntrack-netlink +libmnl
+  TITLE:=API to the in-kernel connection tracking state table
+  URL:=http://www.netfilter.org/projects/libnetfilter_conntrack/
+  ABI_VERSION:=3
+endef
+
+define Package/libnetfilter-conntrack/description
+ libnetfilter_conntrack is a userspace library providing a programming
+ interface (API) to the in-kernel connection tracking state table. The
+ library libnetfilter_conntrack has been previously known as
+ libnfnetlink_conntrack and libctnetlink. This library is currently
+ used by conntrack-tools among many other applications.
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+CONFIGURE_ARGS += \
+	--enable-static \
+	--enable-shared \
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include/libnetfilter_conntrack
+	$(CP) \
+		$(PKG_INSTALL_DIR)/usr/include/libnetfilter_conntrack/*.h \
+		$(1)/usr/include/libnetfilter_conntrack/
+
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) \
+		$(PKG_INSTALL_DIR)/usr/lib/libnetfilter_conntrack.{so*,a,la} \
+		$(1)/usr/lib/
+
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(CP) \
+		$(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libnetfilter_conntrack.pc \
+		$(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libnetfilter-conntrack/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) \
+		$(PKG_INSTALL_DIR)/usr/lib/libnetfilter_conntrack.so.* \
+		$(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libnetfilter-conntrack))
diff --git a/package/libs/libnetfilter-conntrack/patches/0001-conntrack-fix-build-with-kernel-5_15-and-musl.patch b/package/libs/libnetfilter-conntrack/patches/0001-conntrack-fix-build-with-kernel-5_15-and-musl.patch
new file mode 100644
index 0000000..d04f4b5
--- /dev/null
+++ b/package/libs/libnetfilter-conntrack/patches/0001-conntrack-fix-build-with-kernel-5_15-and-musl.patch
@@ -0,0 +1,49 @@
+From 21ee35dde73aec5eba35290587d479218c6dd824 Mon Sep 17 00:00:00 2001
+From: Robert Marko <robimarko@gmail.com>
+Date: Thu, 24 Feb 2022 15:01:11 +0100
+Subject: conntrack: fix build with kernel 5.15 and musl
+
+Currently, with kernel 5.15 headers and musl building is failing with
+redefinition errors due to a conflict between the kernel and musl headers.
+
+Musl is able to suppres the conflicting kernel header definitions if they
+are included after the standard libc ones, however since ICMP definitions
+were moved into a separate internal header to avoid duplication this has
+stopped working and is breaking the builds.
+
+It seems that the issue is that <netinet/in.h> which contains the UAPI
+suppression defines is included in the internal.h header and not in the
+proto.h which actually includes the kernel ICMP headers and thus UAPI
+supression defines are not present.
+
+Solve this by moving the <netinet/in.h> include before the ICMP kernel
+includes in the proto.h
+
+Fixes: bc1cb4b11403 ("conntrack: Move icmp request>reply type mapping to common file")
+Signed-off-by: Robert Marko <robimarko@gmail.com>
+Signed-off-by: Florian Westphal <fw@strlen.de>
+---
+ include/internal/internal.h | 1 -
+ include/internal/proto.h    | 1 +
+ 2 files changed, 1 insertion(+), 1 deletion(-)
+
+--- a/include/internal/internal.h
++++ b/include/internal/internal.h
+@@ -14,7 +14,6 @@
+ #include <arpa/inet.h>
+ #include <time.h>
+ #include <errno.h>
+-#include <netinet/in.h>
+ 
+ #include <libnfnetlink/libnfnetlink.h>
+ #include <libnetfilter_conntrack/libnetfilter_conntrack.h>
+--- a/include/internal/proto.h
++++ b/include/internal/proto.h
+@@ -2,6 +2,7 @@
+ #define _NFCT_PROTO_H_
+ 
+ #include <stdint.h>
++#include <netinet/in.h>
+ #include <linux/icmp.h>
+ #include <linux/icmpv6.h>
+ 
diff --git a/package/libs/libnfnetlink/Makefile b/package/libs/libnfnetlink/Makefile
new file mode 100644
index 0000000..be1eba6
--- /dev/null
+++ b/package/libs/libnfnetlink/Makefile
@@ -0,0 +1,73 @@
+#
+# Copyright (C) 2007-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:=libnfnetlink
+PKG_VERSION:=1.0.2
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:= \
+	http://www.netfilter.org/projects/libnfnetlink/files/ \
+	ftp://ftp.netfilter.org/pub/libnfnetlink/
+PKG_HASH:=b064c7c3d426efb4786e60a8e6859b82ee2f2c5e49ffeea640cfe4fe33cbc376
+PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
+PKG_LICENSE:=GPL-2.0+
+PKG_CPE_ID:=cpe:/a:netfilter:libnfnetlink
+
+PKG_FIXUP:=autoreconf
+
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libnfnetlink
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=A low-level library for netfilter related kernel/userspace communication
+  URL:=http://netfilter.org/projects/libnfnetlink/
+  ABI_VERSION:=0
+endef
+
+define Package/libnfnetlink/description
+ libnfnetlink is is the low-level library for netfilter related kernel/userspace communication.
+ It provides a generic messaging infrastructure for in-kernel netfilter subsystems
+ (such as nfnetlink_log, nfnetlink_queue, nfnetlink_conntrack) and their respective users
+ and/or management tools in userspace.
+endef
+
+CONFIGURE_ARGS += \
+	--enable-static \
+	--enable-shared
+
+CONFIGURE_VARS += \
+	lt_prog_compiler_pic="$(FPIC)"
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include/libnfnetlink
+	$(CP) \
+		$(PKG_INSTALL_DIR)/usr/include/libnfnetlink/{libnfnetlink,linux_nfnetlink,linux_nfnetlink_compat}.h \
+		$(1)/usr/include/libnfnetlink/
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) \
+		$(PKG_INSTALL_DIR)/usr/lib/libnfnetlink.{a,so*} \
+		$(1)/usr/lib/
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(CP) \
+		$(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libnfnetlink.pc \
+		$(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libnfnetlink/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) \
+		$(PKG_INSTALL_DIR)/usr/lib/libnfnetlink.so.* \
+		$(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libnfnetlink))
diff --git a/package/libs/libnftnl/Makefile b/package/libs/libnftnl/Makefile
new file mode 100644
index 0000000..f06b223
--- /dev/null
+++ b/package/libs/libnftnl/Makefile
@@ -0,0 +1,75 @@
+#
+# Copyright (C) 2014 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:=libnftnl
+PKG_CPE_ID:=cpe:/a:netfilter:libnftnl
+PKG_VERSION:=1.2.8
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
+PKG_SOURCE_URL:=https://netfilter.org/projects/$(PKG_NAME)/files
+PKG_HASH:=37fea5d6b5c9b08de7920d298de3cdc942e7ae64b1a3e8b880b2d390ae67ad95
+
+PKG_MAINTAINER:=Steven Barth <steven@midlink.org>
+PKG_LICENSE:=GPL-2.0-or-later
+PKG_LICENSE_FILES:=COPYING
+
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+PKG_BUILD_FLAGS:=lto
+
+include $(INCLUDE_DIR)/package.mk
+
+DISABLE_NLS:=
+
+define Package/libnftnl
+  SECTION:=libs
+  CATEGORY:=Libraries
+  DEPENDS:=+libmnl
+  TITLE:=Low-level netlink library for the nf_tables subsystem
+  URL:=http://www.netfilter.org/projects/libnftnl
+  ABI_VERSION:=11
+endef
+
+define Package/libnftnl/description
+ libnftnl is a userspace library providing a low-level netlink
+ programming interface (API) to the in-kernel nf_tables subsystem.
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+CONFIGURE_ARGS += \
+	--enable-static \
+	--enable-shared
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include/libnftnl
+	$(CP) \
+		$(PKG_INSTALL_DIR)/usr/include/libnftnl/*.h \
+		$(1)/usr/include/libnftnl/
+
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) \
+		$(PKG_INSTALL_DIR)/usr/lib/libnftnl.{so*,a,la} \
+		$(1)/usr/lib/
+
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(CP) \
+		$(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libnftnl.pc \
+		$(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libnftnl/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) \
+		$(PKG_INSTALL_DIR)/usr/lib/libnftnl.so.* \
+		$(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libnftnl))
diff --git a/package/libs/libnl-tiny/Makefile b/package/libs/libnl-tiny/Makefile
new file mode 100644
index 0000000..093c058
--- /dev/null
+++ b/package/libs/libnl-tiny/Makefile
@@ -0,0 +1,49 @@
+#
+# Copyright (C) 2006-2012 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:=libnl-tiny
+PKG_RELEASE:=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL=$(PROJECT_GIT)/project/libnl-tiny.git
+PKG_SOURCE_DATE:=2023-12-05
+PKG_SOURCE_VERSION:=965c4bf49658342ced0bd6e7cb069571b4a1ddff
+PKG_MIRROR_HASH:=4e166d01533aaaea5e01a2e3605ae224c3d632264936b6c40c07335e11e6b51b
+CMAKE_INSTALL:=1
+
+PKG_LICENSE:=LGPL-2.1
+PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/libnl-tiny
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=netlink socket library
+  ABI_VERSION:=1
+endef
+
+define Package/libnl-tiny/description
+ This package contains a stripped down version of libnl
+endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig $(1)/usr/include/libnl-tiny
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/libnl-tiny/* $(1)/usr/include/libnl-tiny
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-tiny.so* $(1)/usr/lib/
+	$(INSTALL_DATA) $(PKG_BUILD_DIR)/libnl-tiny.pc $(1)/usr/lib/pkgconfig
+endef
+
+define Package/libnl-tiny/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-tiny.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libnl-tiny))
diff --git a/package/libs/libnl/Makefile b/package/libs/libnl/Makefile
new file mode 100644
index 0000000..f8f45e0
--- /dev/null
+++ b/package/libs/libnl/Makefile
@@ -0,0 +1,148 @@
+# SPDX-License-Identifier: GPL-2.0-only
+#
+# Copyright (C) 2006-2013 OpenWrt.org
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libnl
+PKG_VERSION:=3.10.0
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://github.com/thom311/libnl/releases/download/libnl$(subst .,_,$(PKG_VERSION))
+PKG_HASH:=49b3e2235fdb58f5910bbb3ed0de8143b71ffc220571540502eb6c2471f204f5
+
+PKG_LICENSE:=LGPL-2.1
+PKG_LICENSE_FILES:=COPYING
+PKG_CPE_ID:=cpe:/a:libnl_project:libnl
+
+PKG_INSTALL:=1
+PKG_FIXUP:=autoreconf
+
+PKG_BUILD_FLAGS:=gc-sections
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libnl/default
+  SECTION:=libs
+  CATEGORY:=Libraries
+  URL:=http://www.infradead.org/~tgr/libnl/
+  ABI_VERSION:=200
+endef
+
+define Package/libnl-core
+$(call Package/libnl/default)
+  TITLE:=Core Netlink Library
+  DEPENDS:=+libpthread
+endef
+
+define Package/libnl-genl
+$(call Package/libnl/default)
+  TITLE:=Generic Netlink Library
+  DEPENDS:=+libnl-core
+endef
+
+define Package/libnl-route
+$(call Package/libnl/default)
+  TITLE:=Routing Netlink Library
+  DEPENDS:=+libnl-core
+endef
+
+define Package/libnl-nf
+$(call Package/libnl/default)
+  TITLE:=Netfilter Netlink Library
+  DEPENDS:=+libnl-route
+endef
+
+define Package/libnl-cli
+$(call Package/libnl/default)
+  TITLE:=CLI Netlink Library
+  DEPENDS:=+libnl-genl +libnl-nf
+endef
+
+define Package/libnl
+$(call Package/libnl/default)
+  TITLE:=Full Netlink Library
+  DEPENDS:=+libnl-genl +libnl-route +libnl-nf +libnl-cli
+endef
+
+define Package/libnl-core/description
+ Common code for all netlink libraries
+endef
+
+define Package/libnl-genl/description
+ Generic Netlink Library Functions
+endef
+
+define Package/libnl-route/description
+ Routing Netlink Library Functions
+endef
+
+define Package/libnl-nf/description
+ Netfilter Netlink Library Functions
+endef
+
+define Package/libnl-cli/description
+ CLI Netlink Library Functions
+endef
+
+define Package/libnl/description
+ Socket handling, connection management, sending and receiving of data,
+ message construction and parsing, object caching system, etc.
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+CONFIGURE_ARGS += \
+	--disable-debug
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include/libnl3 $(1)/usr/lib/pkgconfig
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/libnl3/* $(1)/usr/include/libnl3/
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/* $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/*.pc $(1)/usr/lib/pkgconfig
+
+	# Copy symlinks
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-3.so $(1)/usr/lib/libnl.so
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-genl-3.so $(1)/usr/lib/libnl-genl.so
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-nf-3.so $(1)/usr/lib/libnl-nf.so
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-route-3.so $(1)/usr/lib/libnl-route.so
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-cli-3.so $(1)/usr/lib/libnl-cli.so
+endef
+
+define Package/libnl-core/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-3.so.* $(1)/usr/lib/
+endef
+
+define Package/libnl-genl/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-genl-3.so.* $(1)/usr/lib/
+endef
+
+define Package/libnl-route/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-route-3.so.* $(1)/usr/lib/
+endef
+
+define Package/libnl-nf/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-nf-3.so.* $(1)/usr/lib/
+endef
+
+define Package/libnl-cli/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libnl-cli-3.so.* $(1)/usr/lib/
+endef
+
+define Package/libnl/install
+	:
+endef
+
+$(eval $(call BuildPackage,libnl-core))
+$(eval $(call BuildPackage,libnl-genl))
+$(eval $(call BuildPackage,libnl-route))
+$(eval $(call BuildPackage,libnl-nf))
+$(eval $(call BuildPackage,libnl-cli))
+$(eval $(call BuildPackage,libnl))
diff --git a/package/libs/libpam/Makefile b/package/libs/libpam/Makefile
new file mode 100644
index 0000000..abe7904
--- /dev/null
+++ b/package/libs/libpam/Makefile
@@ -0,0 +1,83 @@
+#
+# Copyright (C) 2006-2014 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:=libpam
+PKG_VERSION:=1.5.2
+PKG_RELEASE:=1
+
+PKG_SOURCE:=Linux-PAM-$(PKG_VERSION).tar.xz
+PKG_SOURCE_URL:=https://github.com/linux-pam/linux-pam/releases/download/v$(PKG_VERSION)
+PKG_HASH:=e4ec7131a91da44512574268f493c6d8ca105c87091691b8e9b56ca685d4f94d
+PKG_BUILD_DIR:=$(BUILD_DIR)/Linux-PAM-$(PKG_VERSION)
+
+PKG_MAINTAINER:=Nikos Mavrogiannopoulos <n.mavrogiannopoulos@gmail.com>
+PKG_LICENSE:=BSD-3c GPL
+PKG_LICENSE_FILES:=COPYING Copyright
+PKG_CPE_ID:=cpe:/a:linux-pam:linux-pam
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libpam
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=the Linux-PAM libraries and modules.
+  URL:=http://www.kernel.org/pub/linux/libs/pam
+endef
+
+define Package/libpam/description
+	The Linux-PAM Pluggable Authentication Modules.
+endef
+
+CONFIGURE_ARGS += \
+	--enable-pamlocking \
+	--enable-shared \
+	--enable-static \
+	--disable-audit \
+	--disable-cracklib \
+	--disable-db \
+	--disable-debug \
+	--disable-doc \
+	--disable-econf \
+	--disable-lckpwdf \
+	--disable-nis \
+	--disable-prelude \
+	--disable-regenerate-docu \
+	--disable-rpath \
+	--disable-selinux \
+	--disable-Werror \
+	--with-gnu-ld \
+	--without-mailspool \
+	--without-xauth
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/* $(1)/usr/lib/
+endef
+
+define Package/libpam/install
+	$(INSTALL_DIR) $(1)/etc $(1)/etc/pam.d
+	$(INSTALL_DIR) $(1)/usr/lib $(1)/usr/lib/security $(1)/usr/lib/security/pam_filter
+	$(INSTALL_DIR) $(1)/usr/sbin
+	$(CP) $(PKG_INSTALL_DIR)/etc/* $(1)/etc/
+	$(CP) ./files/* $(1)/etc/
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so* $(1)/usr/lib/
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/security/*.so* $(1)/usr/lib/security/
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/security/pam_filter/* $(1)/usr/lib/security/pam_filter/
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/* $(1)/usr/sbin/
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/*.pc $(1)/usr/lib/pkgconfig/
+endef
+
+$(eval $(call BuildPackage,libpam))
diff --git a/package/libs/libpam/files/pam.conf b/package/libs/libpam/files/pam.conf
new file mode 100644
index 0000000..3eeb72d
--- /dev/null
+++ b/package/libs/libpam/files/pam.conf
@@ -0,0 +1,15 @@
+# ---------------------------------------------------------------------------#
+# /etc/pam.conf								     #
+# ---------------------------------------------------------------------------#
+#
+# NOTE
+# ----
+#
+# NOTE: Most program use a file under the /etc/pam.d/ directory to setup their
+# PAM service modules. This file is used only if that directory does not exist.
+# ---------------------------------------------------------------------------#
+
+# Format:
+# serv.	module	   ctrl	      module [path]	...[args..]		     #
+# name	type	   flag							     #
+
diff --git a/package/libs/libpam/files/pam.d/common-account b/package/libs/libpam/files/pam.d/common-account
new file mode 100644
index 0000000..7162548
--- /dev/null
+++ b/package/libs/libpam/files/pam.d/common-account
@@ -0,0 +1,20 @@
+#
+# /etc/pam.d/common-account - authorization settings common to all services
+#
+# This file is included from other service-specific PAM config files,
+# and should contain a list of the authorization modules that define
+# the central access policy for use on the system.  The default is to
+# only deny service to users whose accounts are expired in /etc/shadow.
+#
+
+# here are the per-package modules (the "Primary" block)
+account	[success=1 new_authtok_reqd=done default=ignore]	pam_unix.so 
+# here's the fallback if no module succeeds
+account	requisite			pam_deny.so
+# prime the stack with a positive return value if there isn't one already;
+# this avoids us returning an error just because nothing sets a success code
+# since the modules above will each just jump around
+account	required			pam_permit.so
+# and here are more per-package modules (the "Additional" block)
+
+# end of pam-auth-update config
diff --git a/package/libs/libpam/files/pam.d/common-auth b/package/libs/libpam/files/pam.d/common-auth
new file mode 100644
index 0000000..8fc529d
--- /dev/null
+++ b/package/libs/libpam/files/pam.d/common-auth
@@ -0,0 +1,21 @@
+#
+# /etc/pam.d/common-auth - authentication settings common to all services
+#
+# This file is included from other service-specific PAM config files,
+# and should contain a list of the authentication modules that define
+# the central authentication scheme for use on the system
+# (e.g., /etc/shadow, LDAP, Kerberos, etc.).  The default is to use the
+# traditional Unix authentication mechanisms.
+#
+
+# here are the per-package modules (the "Primary" block)
+auth	[success=1 default=ignore]	pam_unix.so nullok_secure
+# here's the fallback if no module succeeds
+auth	requisite			pam_deny.so
+# prime the stack with a positive return value if there isn't one already;
+# this avoids us returning an error just because nothing sets a success code
+# since the modules above will each just jump around
+auth	required			pam_permit.so
+# and here are more per-package modules (the "Additional" block)
+
+# end of pam-auth-update config
diff --git a/package/libs/libpam/files/pam.d/common-password b/package/libs/libpam/files/pam.d/common-password
new file mode 100644
index 0000000..5d0dee0
--- /dev/null
+++ b/package/libs/libpam/files/pam.d/common-password
@@ -0,0 +1,28 @@
+#
+# /etc/pam.d/common-password - password-related modules common to all services
+#
+# This file is included from other service-specific PAM config files,
+# and should contain a list of modules that define the services to be
+# used to change user passwords.  The default is pam_unix.
+
+# Explanation of pam_unix options:
+#
+# The "sha512" option enables salted SHA512 passwords.  Without this option,
+# the default is Unix crypt.  Prior releases used the option "md5".
+#
+# The "obscure" option replaces the old `OBSCURE_CHECKS_ENAB' option in
+# login.defs.
+#
+# See the pam_unix manpage for other options.
+
+# here are the per-package modules (the "Primary" block)
+password	[success=1 default=ignore]	pam_unix.so obscure sha512
+# here's the fallback if no module succeeds
+password	requisite			pam_deny.so
+# prime the stack with a positive return value if there isn't one already;
+# this avoids us returning an error just because nothing sets a success code
+# since the modules above will each just jump around
+password	required			pam_permit.so
+# and here are more per-package modules (the "Additional" block)
+
+# end of pam-auth-update config
diff --git a/package/libs/libpam/files/pam.d/common-session b/package/libs/libpam/files/pam.d/common-session
new file mode 100644
index 0000000..f0d41cc
--- /dev/null
+++ b/package/libs/libpam/files/pam.d/common-session
@@ -0,0 +1,25 @@
+#
+# /etc/pam.d/common-session - session-related modules common to all services
+#
+# This file is included from other service-specific PAM config files,
+# and should contain a list of modules that define tasks to be performed
+# at the start and end of sessions of *any* kind (both interactive and
+# non-interactive).
+#
+
+# here are the per-package modules (the "Primary" block)
+session	[default=1]			pam_permit.so
+# here's the fallback if no module succeeds
+session	requisite			pam_deny.so
+# prime the stack with a positive return value if there isn't one already;
+# this avoids us returning an error just because nothing sets a success code
+# since the modules above will each just jump around
+session	required			pam_permit.so
+# The pam_umask module will set the umask according to the system default in
+# /etc/login.defs and user settings, solving the problem of different
+# umask settings with different shells, display managers, remote sessions etc.
+# See "man pam_umask".
+session optional			pam_umask.so
+# and here are more per-package modules (the "Additional" block)
+session	required			pam_unix.so 
+# end of pam-auth-update config
diff --git a/package/libs/libpam/files/pam.d/common-session-noninteractive b/package/libs/libpam/files/pam.d/common-session-noninteractive
new file mode 100644
index 0000000..f4943e1
--- /dev/null
+++ b/package/libs/libpam/files/pam.d/common-session-noninteractive
@@ -0,0 +1,25 @@
+#
+# /etc/pam.d/common-session-noninteractive - session-related modules
+# common to all non-interactive services
+#
+# This file is included from other service-specific PAM config files,
+# and should contain a list of modules that define tasks to be performed
+# at the start and end of all non-interactive sessions.
+#
+
+# here are the per-package modules (the "Primary" block)
+session	[default=1]			pam_permit.so
+# here's the fallback if no module succeeds
+session	requisite			pam_deny.so
+# prime the stack with a positive return value if there isn't one already;
+# this avoids us returning an error just because nothing sets a success code
+# since the modules above will each just jump around
+session	required			pam_permit.so
+# The pam_umask module will set the umask according to the system default in
+# /etc/login.defs and user settings, solving the problem of different
+# umask settings with different shells, display managers, remote sessions etc.
+# See "man pam_umask".
+session optional			pam_umask.so
+# and here are more per-package modules (the "Additional" block)
+session	required			pam_unix.so 
+# end of pam-auth-update config
diff --git a/package/libs/libpam/files/pam.d/other b/package/libs/libpam/files/pam.d/other
new file mode 100644
index 0000000..6679e4f
--- /dev/null
+++ b/package/libs/libpam/files/pam.d/other
@@ -0,0 +1,16 @@
+#
+# /etc/pam.d/other - specify the PAM fallback behaviour
+#
+# Note that this file is used for any unspecified service; for example
+#if /etc/pam.d/cron  specifies no session modules but cron calls
+#pam_open_session, the session module out of /etc/pam.d/other is
+#used.  If you really want nothing to happen then use pam_permit.so or
+#pam_deny.so as appropriate.
+
+# We fall back to the system default in /etc/pam.d/common-*
+# 
+
+auth       include      common-auth
+account    include      common-account
+password   include      common-password
+session    include      common-session
diff --git a/package/libs/libpam/patches/0001-build-always-use-lib-instead-of-lib64.patch b/package/libs/libpam/patches/0001-build-always-use-lib-instead-of-lib64.patch
new file mode 100644
index 0000000..a40274f
--- /dev/null
+++ b/package/libs/libpam/patches/0001-build-always-use-lib-instead-of-lib64.patch
@@ -0,0 +1,11 @@
+--- a/configure.ac
++++ b/configure.ac
+@@ -25,7 +25,7 @@ dnl If we use /usr as prefix, use /etc f
+         then
+                 sysconfdir="/etc"
+         fi
+-	if test ${libdir} = '${exec_prefix}/lib'
++	if false
+ 	then
+ 		case "$host_cpu" in
+ 		    x86_64|ppc64|s390x|sparc64)
diff --git a/package/libs/libpcap/Config.in b/package/libs/libpcap/Config.in
new file mode 100644
index 0000000..1159927
--- /dev/null
+++ b/package/libs/libpcap/Config.in
@@ -0,0 +1,17 @@
+menu "Configuration"
+	depends on PACKAGE_libpcap
+
+config PCAP_HAS_USB
+	bool "Include USB support"
+	default n
+
+config PCAP_HAS_BT
+	bool "Include bluetooth support"
+	depends on BROKEN
+	default n
+
+config PCAP_HAS_NETFILTER
+	bool "Include netfilter support"
+	default n
+
+endmenu
diff --git a/package/libs/libpcap/Makefile b/package/libs/libpcap/Makefile
new file mode 100644
index 0000000..09aab09
--- /dev/null
+++ b/package/libs/libpcap/Makefile
@@ -0,0 +1,105 @@
+#
+# Copyright (C) 2006-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:=libpcap
+PKG_VERSION:=1.10.5
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://www.tcpdump.org/release/
+PKG_HASH:=37ced90a19a302a7f32e458224a00c365c117905c2cd35ac544b6880a81488f0
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
+PKG_LICENSE:=BSD-3-Clause
+PKG_LICENSE_FILES:=LICENSE
+PKG_CPE_ID:=cpe:/a:tcpdump:libpcap
+
+PKG_ASLR_PIE_REGULAR:=1
+
+PKG_CONFIG_DEPENDS := CONFIG_PACKAGE_rpcapd
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/libpcap
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=Low-level packet capture library
+  URL:=http://www.tcpdump.org/
+  MENU:=1
+  ABI_VERSION:=1
+endef
+
+define Package/libpcap/description
+This package contains a system-independent library for user-level network packet
+capture.
+endef
+
+define Package/libpcap/config
+	source "$(SOURCE)/Config.in"
+endef
+
+define Package/rpcapd
+  SECTION:=net
+  CATEGORY:=Network
+  TITLE:=Capture daemon to be controlled by a remote libpcap application
+  URL:=http://www.tcpdump.org/
+  DEPENDS+= +libpcap
+endef
+
+ifdef CONFIG_PACKAGE_rpcapd
+	CMAKE_OPTIONS += \
+		-DENABLE_REMOTE=ON
+endif
+
+CMAKE_OPTIONS += \
+	-DBUILD_SHARED_LIBS=ON \
+	-DBUILD_WITH_LIBNL=OFF \
+	-DINET6=O$(if $(CONFIG_IPV6),N,FF) \
+	-DPCAP_SUPPORT_NETFILTER=O$(if $(CONFIG_PCAP_HAS_NETFILTER),N,FF)
+
+# grep 'option(DISABLE_' CMakeLists.txt | cut -f2 -d'(' | cut -f1 -d' ' | sort --unique
+CMAKE_OPTIONS += \
+	-DDISABLE_BLUETOOTH=O$(if $(CONFIG_PCAP_HAS_BT),FF,N) \
+	-DDISABLE_DAG=ON \
+	-DDISABLE_DBUS=ON \
+	-DDISABLE_DPDK=ON \
+	-DDISABLE_LINUX_USBMON=O$(if $(CONFIG_PCAP_HAS_USB),FF,N) \
+	-DDISABLE_NETMAP=ON \
+	-DDISABLE_RDMA=ON \
+	-DDISABLE_SEPTEL=ON \
+	-DDISABLE_SNF=ON \
+	-DDISABLE_TC=ON \
+
+# Debugging options
+CMAKE_OPTIONS += \
+	-DBDEBUG=OFF \
+	-DYYDEBUG=OFF \
+
+define Build/InstallDev
+	$(call Build/InstallDev/cmake,$(1))
+	$(SED) \
+		's,^\(prefix\|exec_prefix\)=.*,\1=$(STAGING_DIR)/usr,g' \
+		$(1)/usr/bin/pcap-config
+	$(INSTALL_DIR) $(2)/bin
+	$(LN) ../../usr/bin/pcap-config $(2)/bin/pcap-config
+endef
+
+define Package/libpcap/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcap.so.* $(1)/usr/lib/
+endef
+
+define Package/rpcapd/install
+	$(INSTALL_DIR) $(1)/usr/sbin
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/rpcapd $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,libpcap))
+$(eval $(call BuildPackage,rpcapd))
diff --git a/package/libs/libpcap/patches/100-no-openssl.patch b/package/libs/libpcap/patches/100-no-openssl.patch
new file mode 100644
index 0000000..1f5dac8
--- /dev/null
+++ b/package/libs/libpcap/patches/100-no-openssl.patch
@@ -0,0 +1,10 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -1441,7 +1441,6 @@ if(ENABLE_REMOTE)
+   #
+   # OpenSSL/libressl.
+   #
+-  find_package(OpenSSL)
+   if(OPENSSL_FOUND)
+     #
+     # We have OpenSSL.
diff --git a/package/libs/libpcap/patches/102-skip-manpages.patch b/package/libs/libpcap/patches/102-skip-manpages.patch
new file mode 100644
index 0000000..7ab6511
--- /dev/null
+++ b/package/libs/libpcap/patches/102-skip-manpages.patch
@@ -0,0 +1,69 @@
+From f172e36e436d714f4def1439b13efd147a6a8411 Mon Sep 17 00:00:00 2001
+From: Yousong Zhou <yszhou4tech@gmail.com>
+Date: Fri, 18 Oct 2019 12:43:22 +0000
+Subject: [PATCH] skip manpages
+
+---
+ CMakeLists.txt | 55 --------------------------------------------------
+ 1 file changed, 55 deletions(-)
+
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -3548,57 +3548,6 @@ if(NOT MSVC)
+     if(MINGW)
+         find_program(LINK_EXECUTABLE ln)
+     endif(MINGW)
+-    if(UNIX OR (MINGW AND LINK_EXECUTABLE))
+-        set(MAN1 "")
+-        foreach(MANPAGE ${MAN1_NOEXPAND})
+-            set(MAN1 ${MAN1} ${CMAKE_CURRENT_SOURCE_DIR}/${MANPAGE})
+-        endforeach(MANPAGE)
+-        install(FILES ${MAN1} DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
+-
+-        set(MAN3PCAP "")
+-        foreach(MANPAGE ${MAN3PCAP_NOEXPAND})
+-            set(MAN3PCAP ${MAN3PCAP} ${CMAKE_CURRENT_SOURCE_DIR}/${MANPAGE})
+-        endforeach(MANPAGE)
+-        foreach(TEMPLATE_MANPAGE ${MAN3PCAP_EXPAND})
+-            string(REPLACE ".in" "" MANPAGE ${TEMPLATE_MANPAGE})
+-            configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY)
+-            set(MAN3PCAP ${MAN3PCAP} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE})
+-        endforeach(TEMPLATE_MANPAGE)
+-        install(FILES ${MAN3PCAP} DESTINATION ${CMAKE_INSTALL_MANDIR}/man3)
+-        install_manpage_symlink(pcap_datalink_val_to_name.3pcap pcap_datalink_val_to_description.3pcap ${CMAKE_INSTALL_MANDIR}/man3)
+-        install_manpage_symlink(pcap_datalink_val_to_name.3pcap pcap_datalink_val_to_description_or_dlt.3pcap ${CMAKE_INSTALL_MANDIR}/man3)
+-        install_manpage_symlink(pcap_dump_open.3pcap pcap_dump_fopen.3pcap ${CMAKE_INSTALL_MANDIR}/man3)
+-        install_manpage_symlink(pcap_findalldevs.3pcap pcap_freealldevs.3pcap ${CMAKE_INSTALL_MANDIR}/man3)
+-        install_manpage_symlink(pcap_geterr.3pcap pcap_perror.3pcap ${CMAKE_INSTALL_MANDIR}/man3)
+-        install_manpage_symlink(pcap_inject.3pcap pcap_sendpacket.3pcap ${CMAKE_INSTALL_MANDIR}/man3)
+-        install_manpage_symlink(pcap_list_datalinks.3pcap pcap_free_datalinks.3pcap ${CMAKE_INSTALL_MANDIR}/man3)
+-        install_manpage_symlink(pcap_list_tstamp_types.3pcap pcap_free_tstamp_types.3pcap ${CMAKE_INSTALL_MANDIR}/man3)
+-        install_manpage_symlink(pcap_loop.3pcap pcap_dispatch.3pcap ${CMAKE_INSTALL_MANDIR}/man3)
+-        install_manpage_symlink(pcap_major_version.3pcap pcap_minor_version.3pcap ${CMAKE_INSTALL_MANDIR}/man3)
+-        install_manpage_symlink(pcap_next_ex.3pcap pcap_next.3pcap ${CMAKE_INSTALL_MANDIR}/man3)
+-        install_manpage_symlink(pcap_open_dead.3pcap pcap_open_dead_with_tstamp_precision.3pcap ${CMAKE_INSTALL_MANDIR}/man3)
+-        install_manpage_symlink(pcap_open_offline.3pcap pcap_open_offline_with_tstamp_precision.3pcap ${CMAKE_INSTALL_MANDIR}/man3)
+-        install_manpage_symlink(pcap_open_offline.3pcap pcap_fopen_offline.3pcap ${CMAKE_INSTALL_MANDIR}/man3)
+-        install_manpage_symlink(pcap_open_offline.3pcap pcap_fopen_offline_with_tstamp_precision.3pcap ${CMAKE_INSTALL_MANDIR}/man3)
+-        install_manpage_symlink(pcap_tstamp_type_val_to_name.3pcap pcap_tstamp_type_val_to_description.3pcap ${CMAKE_INSTALL_MANDIR}/man3)
+-        install_manpage_symlink(pcap_setnonblock.3pcap pcap_getnonblock.3pcap ${CMAKE_INSTALL_MANDIR}/man3)
+-
+-        set(MANFILE "")
+-        foreach(TEMPLATE_MANPAGE ${MANFILE_EXPAND})
+-            string(REPLACE ".manfile.in" ".${MAN_FILE_FORMATS}" MANPAGE ${TEMPLATE_MANPAGE})
+-            configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY)
+-            set(MANFILE ${MANFILE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE})
+-        endforeach(TEMPLATE_MANPAGE)
+-        install(FILES ${MANFILE} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${MAN_FILE_FORMATS})
+-
+-        set(MANMISC "")
+-        foreach(TEMPLATE_MANPAGE ${MANMISC_EXPAND})
+-            string(REPLACE ".manmisc.in" ".${MAN_MISC_INFO}" MANPAGE ${TEMPLATE_MANPAGE})
+-            configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY)
+-            set(MANMISC ${MANMISC} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE})
+-        endforeach(TEMPLATE_MANPAGE)
+-        install(FILES ${MANMISC} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${MAN_MISC_INFO})
+-    endif(UNIX OR (MINGW AND LINK_EXECUTABLE))
+ endif(NOT MSVC)
+ 
+ # uninstall target
diff --git a/package/libs/libpcap/patches/300-Add-support-for-B.A.T.M.A.N.-Advanced.patch b/package/libs/libpcap/patches/300-Add-support-for-B.A.T.M.A.N.-Advanced.patch
new file mode 100644
index 0000000..0b998fa
--- /dev/null
+++ b/package/libs/libpcap/patches/300-Add-support-for-B.A.T.M.A.N.-Advanced.patch
@@ -0,0 +1,642 @@
+From 3d8d268320d2381021a409ff8d03533698dd6242 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Linus=20L=C3=BCssing?= <linus.luessing@c0d3.blue>
+Date: Mon, 23 Nov 2020 00:38:22 +0100
+Subject: [PATCH] Add support for B.A.T.M.A.N. Advanced
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This adds support for the layer 2 mesh routing protocol
+B.A.T.M.A.N. Advanced. "batadv" can be used to filter on batman-adv
+packets. It also allows later filters to look at frames inside the
+tunnel when both "version" and "type" are specified.
+
+Documentation for the batman-adv protocol can be found at the following
+locations:
+
+https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/networking/batman-adv.rst
+https://www.open-mesh.org/
+
+Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
+---
+ Makefile.in            |   2 +
+ batadv_legacy_packet.h |  77 +++++++++++++++++++
+ batadv_packet.h        |  78 ++++++++++++++++++++
+ ethertype.h            |   3 +
+ gencode.c              | 164 +++++++++++++++++++++++++++++++++++++++++
+ gencode.h              |   3 +
+ grammar.y.in           |  32 +++++++-
+ nametoaddr.c           |  59 +++++++++++++++
+ pcap-filter.manmisc.in |  35 ++++++++-
+ pcap/namedb.h          |   2 +
+ scanner.l              |   1 +
+ 11 files changed, 453 insertions(+), 3 deletions(-)
+ create mode 100644 batadv_legacy_packet.h
+ create mode 100644 batadv_packet.h
+
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -130,6 +130,8 @@ PUBHDR = \
+ HDR = $(PUBHDR) \
+ 	arcnet.h \
+ 	atmuni31.h \
++	batadv_legacy_packet.h \
++	batadv_packet.h \
+ 	diag-control.h \
+ 	ethertype.h \
+ 	extract.h \
+--- /dev/null
++++ b/batadv_legacy_packet.h
+@@ -0,0 +1,77 @@
++/* SPDX-License-Identifier: BSD-3 */
++/* Copyright (C) 2020  Linus Lüssing */
++
++#ifndef _BATADV_LEGACY_PACKET_H_
++#define _BATADV_LEGACY_PACKET_H_
++
++enum batadv_legacy_packettype {
++	BATADV_LEGACY_IV_OGM		= 0x01,
++	BATADV_LEGACY_ICMP		= 0x02,
++	BATADV_LEGACY_UNICAST		= 0x03,
++	BATADV_LEGACY_BCAST		= 0x04,
++	BATADV_LEGACY_VIS		= 0x05,
++	BATADV_LEGACY_UNICAST_FRAG	= 0x06,
++	BATADV_LEGACY_TT_QUERY		= 0x07,
++	BATADV_LEGACY_ROAM_ADV		= 0x08,
++	BATADV_LEGACY_UNICAST_4ADDR	= 0x09,
++	BATADV_LEGACY_CODED		= 0x0a,
++};
++
++#define ETH_ALEN	6
++
++struct batadv_legacy_unicast_packet {
++	uint8_t packet_type;
++	uint8_t version;
++	uint8_t ttl;
++	uint8_t ttvn;
++	uint8_t dest[ETH_ALEN];
++};
++
++struct batadv_legacy_unicast_4addr_packet {
++	uint8_t packet_type;
++	uint8_t version;
++	uint8_t ttl;
++	uint8_t src[ETH_ALEN];
++	uint8_t subtype;
++	uint8_t reserved;
++};
++
++struct batadv_legacy_unicast_frag_packet {
++	uint8_t packet_type;
++	uint8_t version;
++	uint8_t ttl;
++	uint8_t ttvn;
++	uint8_t dest[ETH_ALEN];
++	uint8_t flags;
++	uint8_t align;
++	uint8_t orig[ETH_ALEN];
++	uint8_t seqno[2];		/* 2-byte integral value */
++};
++
++struct batadv_legacy_bcast_packet {
++	uint8_t packet_type;
++	uint8_t version;
++	uint8_t ttl;
++	uint8_t reserved;
++	uint8_t seqno[4];		/* 4-byte integral value */
++	uint8_t orig[ETH_ALEN];
++};
++
++struct batadv_legacy_coded_packet {
++	uint8_t packet_type;
++	uint8_t version;
++	uint8_t ttl;
++	uint8_t first_ttvn;
++	uint8_t first_source[ETH_ALEN];
++	uint8_t first_orig_dest[ETH_ALEN];
++	uint8_t first_crc[4];		/* 4-byte integral value */
++	uint8_t second_ttl;
++	uint8_t second_ttvn;
++	uint8_t second_dest[ETH_ALEN];
++	uint8_t second_source[ETH_ALEN];
++	uint8_t second_orig_dest[ETH_ALEN];
++	uint8_t second_crc[4];		/* 4-byte integral value */
++	uint8_t coded_len[2];		/* 2-byte integral value */
++};
++
++#endif /* _BATADV_LEGACY_PACKET_H_ */
+--- /dev/null
++++ b/batadv_packet.h
+@@ -0,0 +1,78 @@
++/* SPDX-License-Identifier: BSD-3 */
++/* Copyright (C) 2020  Linus Lüssing */
++
++#ifndef _BATADV_PACKET_H_
++#define _BATADV_PACKET_H_
++
++/* For the definitive and most recent packet format definition,
++ * see the batadv_packet.h in the Linux kernel.
++ */
++
++enum batadv_packettype {
++	BATADV_IV_OGM           = 0x00,
++	BATADV_BCAST            = 0x01,
++	BATADV_CODED            = 0x02,
++	BATADV_ELP		= 0x03,
++	BATADV_OGM2		= 0x04,
++	BATADV_UNICAST          = 0x40,
++	BATADV_UNICAST_FRAG     = 0x41,
++	BATADV_UNICAST_4ADDR    = 0x42,
++	BATADV_ICMP             = 0x43,
++	BATADV_UNICAST_TVLV     = 0x44,
++};
++
++#define ETH_ALEN	6
++
++struct batadv_unicast_packet {
++	uint8_t packet_type;
++	uint8_t version;
++	uint8_t ttl;
++	uint8_t ttvn;
++	uint8_t dest[ETH_ALEN];
++};
++
++struct batadv_unicast_4addr_packet {
++	struct batadv_unicast_packet u;
++	uint8_t src[ETH_ALEN];
++	uint8_t subtype;
++	uint8_t reserved;
++};
++
++struct batadv_frag_packet {
++	uint8_t packet_type;
++	uint8_t version;
++	uint8_t ttl;
++	uint8_t num_pri;	/* number and priority */
++	uint8_t dest[ETH_ALEN];
++	uint8_t orig[ETH_ALEN];
++	uint8_t seqno[2];	/* 2-byte integral value */
++	uint8_t total_size[2];	/* 2-byte integral value */
++};
++
++struct batadv_bcast_packet {
++	uint8_t packet_type;
++	uint8_t version;
++	uint8_t ttl;
++	uint8_t reserved;
++	uint8_t seqno[4];	/* 4-byte integral value */
++	uint8_t orig[ETH_ALEN];
++};
++
++struct batadv_coded_packet {
++	uint8_t packet_type;
++	uint8_t version;
++	uint8_t ttl;
++	uint8_t first_ttvn;
++	uint8_t first_source[ETH_ALEN];
++	uint8_t first_orig_dest[ETH_ALEN];
++	uint8_t first_crc[4];	/* 4-byte integral value */
++	uint8_t second_ttl;
++	uint8_t second_ttvn;
++	uint8_t second_dest[ETH_ALEN];
++	uint8_t second_source[ETH_ALEN];
++	uint8_t second_orig_dest[ETH_ALEN];
++	uint8_t second_crc[4];	/* 4-byte integral value */
++	uint8_t coded_len[2];	/* 2-byte integral value */
++};
++
++#endif /* _BATADV_PACKET_H_ */
+--- a/ethertype.h
++++ b/ethertype.h
+@@ -49,6 +49,9 @@
+ #ifndef ETHERTYPE_TRAIL
+ #define ETHERTYPE_TRAIL		0x1000
+ #endif
++#ifndef ETHERTYPE_BATMAN
++#define ETHERTYPE_BATMAN	0x4305 /* B.A.T.M.A.N. Advanced */
++#endif
+ #ifndef	ETHERTYPE_MOPDL
+ #define ETHERTYPE_MOPDL		0x6001
+ #endif
+--- a/gencode.c
++++ b/gencode.c
+@@ -58,6 +58,8 @@
+ #include "sunatmpos.h"
+ #include "pflog.h"
+ #include "ppp.h"
++#include "batadv_packet.h"
++#include "batadv_legacy_packet.h"
+ #include "pcap/sll.h"
+ #include "pcap/ipnet.h"
+ #include "arcnet.h"
+@@ -9704,6 +9706,168 @@ gen_geneve(compiler_state_t *cstate, bpf
+ 	return b1;
+ }
+ 
++static struct block *
++gen_batadv_check_version(compiler_state_t *cstate, struct block *b0, bpf_u_int32 version)
++{
++	struct block *b1;
++
++	if (version > UINT8_MAX)
++		bpf_error(cstate,
++			  "batman-adv compatibility version number %u unsupported",
++			  version);
++
++	b1 = gen_cmp(cstate, OR_LINKPL, 1, BPF_B, version);
++	gen_and(b0, b1);
++
++	return b1;
++}
++
++static struct block *
++gen_batadv_check_type(compiler_state_t *cstate, struct block *b0,
++		      bpf_u_int32 version, bpf_u_int32 type)
++{
++	struct block *b1;
++
++	switch (version) {
++	case 14:
++	case 15:
++		if (type > UINT8_MAX)
++			bpf_error(cstate,
++				  "batman-adv packet type %u unsupported for compatibility version %u",
++				  type, version);
++
++		b1 = gen_cmp(cstate, OR_LINKPL, 0, BPF_B, type);
++		gen_and(b0, b1);
++		b0 = b1;
++
++		break;
++	default:
++		bpf_error(cstate,
++			  "batman-adv compatibility version number %u unsupported",
++			  version);
++	}
++
++	return b0;
++}
++
++
++static void gen_batadv_push_offset(compiler_state_t *cstate, u_int offset)
++{
++	PUSH_LINKHDR(cstate, DLT_EN10MB, cstate->off_linkpl.is_variable,
++		     cstate->off_linkpl.constant_part + cstate->off_nl + offset,
++		     cstate->off_linkpl.reg);
++
++	cstate->off_linktype.constant_part += cstate->off_linkhdr.constant_part;
++	cstate->off_linkpl.constant_part += cstate->off_linkhdr.constant_part;
++
++	cstate->off_nl = 0;
++	cstate->off_nl_nosnap = 0;	/* no 802.2 LLC */
++}
++
++static void
++gen_batadv_offsets_v14(compiler_state_t *cstate, bpf_u_int32 type)
++{
++	size_t offset;
++
++	switch (type) {
++	case BATADV_LEGACY_UNICAST:		/* 0x03 */
++		offset = sizeof(struct batadv_legacy_unicast_packet);
++		break;
++	case BATADV_LEGACY_BCAST:		/* 0x04 */
++		offset = sizeof(struct batadv_legacy_bcast_packet);
++		break;
++	case BATADV_LEGACY_UNICAST_FRAG:	/* 0x06 */
++		offset = sizeof(struct batadv_legacy_unicast_frag_packet);
++		break;
++	case BATADV_LEGACY_UNICAST_4ADDR:	/* 0x09 */
++		offset = sizeof(struct batadv_legacy_unicast_4addr_packet);
++		break;
++	case BATADV_LEGACY_CODED:		/* 0x0a */
++		offset = sizeof(struct batadv_legacy_coded_packet);
++		break;
++	default:
++		offset = 0;
++	}
++
++	if (offset)
++		gen_batadv_push_offset(cstate, (u_int)offset);
++}
++
++static void
++gen_batadv_offsets_v15(compiler_state_t *cstate, bpf_u_int32 type)
++{
++	size_t offset;
++
++	switch (type) {
++	case BATADV_BCAST:		/* 0x01 */
++		offset = sizeof(struct batadv_bcast_packet);
++		break;
++	case BATADV_CODED:		/* 0x02 */
++		offset = sizeof(struct batadv_coded_packet);
++		break;
++	case BATADV_UNICAST:		/* 0x40 */
++		offset = sizeof(struct batadv_unicast_packet);
++		break;
++	case BATADV_UNICAST_FRAG:	/* 0x41 */
++		offset = sizeof(struct batadv_frag_packet);
++		break;
++	case BATADV_UNICAST_4ADDR:	/* 0x42 */
++		offset = sizeof(struct batadv_unicast_4addr_packet);
++		break;
++	case BATADV_UNICAST_TVLV:
++		/* unsupported for now, needs variable offset to
++		 * take tvlv_len into account
++		 */
++		/* fall through */
++	default:
++		offset = 0;
++	}
++
++	if (offset)
++		gen_batadv_push_offset(cstate, (u_int)offset);
++}
++
++static void
++gen_batadv_offsets(compiler_state_t *cstate, bpf_u_int32 version, bpf_u_int32 type)
++{
++	switch (version) {
++	case 14:
++		gen_batadv_offsets_v14(cstate, type);
++		break;
++	case 15:
++		gen_batadv_offsets_v15(cstate, type);
++		break;
++	default:
++		break;
++	}
++}
++
++struct block *
++gen_batadv(compiler_state_t *cstate, bpf_u_int32 version, int has_version,
++	   bpf_u_int32 type, int has_type)
++{
++	struct block *b0;
++
++	/*
++	 * Catch errors reported by us and routines below us, and return NULL
++	 * on an error.
++	 */
++	if (setjmp(cstate->top_ctx))
++		return (NULL);
++
++	b0 = gen_linktype(cstate, ETHERTYPE_BATMAN);
++
++	if (has_version)
++		b0 = gen_batadv_check_version(cstate, b0, version);
++
++	if (has_type) {
++		b0 = gen_batadv_check_type(cstate, b0, version, type);
++		gen_batadv_offsets(cstate, version, type);
++	}
++
++	return b0;
++}
++
+ /* Check that the encapsulated frame has a link layer header
+  * for Ethernet filters. */
+ static struct block *
+--- a/gencode.h
++++ b/gencode.h
+@@ -358,6 +358,9 @@ struct block *gen_pppoes(compiler_state_
+ 
+ struct block *gen_geneve(compiler_state_t *, bpf_u_int32, int);
+ 
++struct block *gen_batadv(compiler_state_t *, bpf_u_int32, int,
++			 bpf_u_int32, int);
++
+ struct block *gen_atmfield_code(compiler_state_t *, int, bpf_u_int32,
+     int, int);
+ struct block *gen_atmtype_abbrev(compiler_state_t *, int);
+--- a/grammar.y.in
++++ b/grammar.y.in
+@@ -383,6 +383,7 @@ DIAG_OFF_BISON_BYACC
+ %type	<i>	mtp2type
+ %type	<blk>	mtp3field
+ %type	<blk>	mtp3fieldvalue mtp3value mtp3listvalue
++%type	<rblk>	pbatadv
+ 
+ 
+ %token  DST SRC HOST GATEWAY
+@@ -401,7 +402,7 @@ DIAG_OFF_BISON_BYACC
+ %token  LEN
+ %token  IPV6 ICMPV6 AH ESP
+ %token	VLAN MPLS
+-%token	PPPOED PPPOES GENEVE
++%token	PPPOED PPPOES GENEVE BATADV
+ %token  ISO ESIS CLNP ISIS L1 L2 IIH LSP SNP CSNP PSNP
+ %token  STP
+ %token  IPX
+@@ -698,11 +699,40 @@ other:	  pqual TK_BROADCAST	{ CHECK_PTR_
+ 	| PPPOES		{ CHECK_PTR_VAL(($$ = gen_pppoes(cstate, 0, 0))); }
+ 	| GENEVE pnum		{ CHECK_PTR_VAL(($$ = gen_geneve(cstate, $2, 1))); }
+ 	| GENEVE		{ CHECK_PTR_VAL(($$ = gen_geneve(cstate, 0, 0))); }
++	| BATADV pbatadv	{ $$ = $2; }
+ 	| pfvar			{ $$ = $1; }
+ 	| pqual p80211		{ $$ = $2; }
+ 	| pllc			{ $$ = $1; }
+ 	;
+ 
++pbatadv:		{ CHECK_PTR_VAL(($$ = gen_batadv(cstate, 0, 0, 0, 0))); }
++	| pnum		{ CHECK_PTR_VAL(($$ = gen_batadv(cstate, $1, 1, 0, 0))); }
++	| pnum pnum	{ CHECK_PTR_VAL(($$ = gen_batadv(cstate, $1, 1, $2, 1))); }
++	| pnum ID
++		{
++			int type;
++
++			switch ($1) {
++			case 14:
++				type = pcap_nametobatadvtype_v14($2);
++				break;
++			case 15:
++				type = pcap_nametobatadvtype_v15($2);
++				break;
++			default:
++				bpf_set_error(cstate, "batman-adv compatibility version number %u unsupported", $1);
++				YYABORT;
++			}
++
++			if (type == PROTO_UNDEF) {
++				bpf_set_error(cstate, "invalid batman-adv packet type value \"%s\"", $2);
++				YYABORT;
++			}
++
++			CHECK_PTR_VAL(($$ = gen_batadv(cstate, $1, 1, type, 1)));
++		}
++	;
++
+ pfvar:	  PF_IFNAME ID		{ CHECK_PTR_VAL($2); CHECK_PTR_VAL(($$ = gen_pf_ifname(cstate, $2))); }
+ 	| PF_RSET ID		{ CHECK_PTR_VAL($2); CHECK_PTR_VAL(($$ = gen_pf_ruleset(cstate, $2))); }
+ 	| PF_RNR NUM		{ CHECK_PTR_VAL(($$ = gen_pf_rnr(cstate, $2))); }
+--- a/nametoaddr.c
++++ b/nametoaddr.c
+@@ -134,8 +134,12 @@
+ 
+ #include "diag-control.h"
+ 
++#include "batadv_packet.h"
++#include "batadv_legacy_packet.h"
++
+ #include "gencode.h"
+ #include <pcap/namedb.h>
++
+ #include "nametoaddr.h"
+ 
+ #include "thread-local.h"
+@@ -597,6 +601,7 @@ PCAP_API_DEF struct eproto eproto_db[] =
+ 	{ "moprc", ETHERTYPE_MOPRC },
+ 	{ "rarp", ETHERTYPE_REVARP },
+ 	{ "sca", ETHERTYPE_SCA },
++	{ "batadv", ETHERTYPE_BATMAN },
+ 	{ (char *)0, 0 }
+ };
+ 
+@@ -631,6 +636,60 @@ pcap_nametollc(const char *s)
+ 
+ 	while (p->s != 0) {
+ 		if (strcmp(p->s, s) == 0)
++			return p->p;
++		p += 1;
++	}
++	return PROTO_UNDEF;
++}
++
++/* Static data base of batman-adv v14 packet type values. */
++static struct eproto batadv_type_db_v14[] = {
++	{ "iv_ogm",		BATADV_LEGACY_IV_OGM },
++	{ "icmp",		BATADV_LEGACY_ICMP },
++	{ "unicast",		BATADV_LEGACY_UNICAST },
++	{ "bcast",		BATADV_LEGACY_BCAST },
++	{ "vis",		BATADV_LEGACY_VIS },
++	{ "unicast_frag",	BATADV_LEGACY_UNICAST_FRAG },
++	{ "tt_query",		BATADV_LEGACY_TT_QUERY },
++	{ "roam_adv",		BATADV_LEGACY_ROAM_ADV },
++	{ "unicast_4addr",	BATADV_LEGACY_UNICAST_4ADDR },
++	{ "coded",		BATADV_LEGACY_CODED },
++	{ (char *)0, 0 }
++};
++
++int pcap_nametobatadvtype_v14(const char *s)
++{
++	struct eproto *p = batadv_type_db_v14;
++
++	while (p->s != 0) {
++		if (strcmp(p->s, s) == 0)
++			return p->p;
++		p += 1;
++	}
++	return PROTO_UNDEF;
++}
++
++/* Static data base of batman-adv v15 packet type values. */
++static struct eproto batadv_type_db_v15[] = {
++	{ "iv_ogm",		BATADV_IV_OGM },
++	{ "bcast",		BATADV_BCAST },
++	{ "coded",		BATADV_CODED },
++	{ "elp",		BATADV_ELP },
++	{ "ogm2",		BATADV_OGM2 },
++	{ "unicast",		BATADV_UNICAST },
++	{ "unicast_frag",	BATADV_UNICAST_FRAG },
++	{ "unicast_4addr",	BATADV_UNICAST_4ADDR },
++	{ "icmp",		BATADV_ICMP },
++	{ "unicast_tvlv",	BATADV_UNICAST_TVLV },
++	{ (char *)0, 0 }
++};
++
++int pcap_nametobatadvtype_v15(const char *s)
++{
++	struct eproto *p = batadv_type_db_v15;
++
++	while (p->s != 0) {
++		if (strcmp(p->s, s) == 0)
+ 			return p->p;
+ 		p += 1;
+ 	}
+--- a/pcap-filter.manmisc.in
++++ b/pcap-filter.manmisc.in
+@@ -98,6 +98,7 @@ protocols are:
+ .BR arp ,
+ .BR rarp ,
+ .BR decnet ,
++.BR batadv ,
+ .BR sctp ,
+ .B tcp
+ and
+@@ -400,7 +401,7 @@ True if the packet is an IPv6 multicast
+ .IP  "\fBether proto \fIprotocol\fR"
+ True if the packet is of ether type \fIprotocol\fR.
+ \fIProtocol\fP can be a number or one of the names
+-\fBaarp\fP, \fBarp\fP, \fBatalk\fP, \fBdecnet\fP, \fBip\fP, \fBip6\fP,
++\fBaarp\fP, \fBarp\fP, \fBatalk\fP, \fBbatadv\fP, \fBdecnet\fP, \fBip\fP, \fBip6\fP,
+ \fBipx\fP, \fBiso\fP, \fBlat\fP, \fBloopback\fP, \fBmopdl\fP, \fBmoprc\fP, \fBnetbeui\fP,
+ \fBrarp\fP, \fBsca\fP or \fBstp\fP.
+ Note these identifiers (except \fBloopback\fP) are also keywords
+@@ -454,7 +455,7 @@ the filter checks for the IPX etype in a
+ DSAP in the LLC header, the 802.3-with-no-LLC-header encapsulation of
+ IPX, and the IPX etype in a SNAP frame.
+ .RE
+-.IP "\fBip\fR, \fBip6\fR, \fBarp\fR, \fBrarp\fR, \fBatalk\fR, \fBaarp\fR, \fBdecnet\fR, \fBiso\fR, \fBstp\fR, \fBipx\fR, \fBnetbeui\fP"
++.IP "\fBip\fR, \fBip6\fR, \fBarp\fR, \fBrarp\fR, \fBatalk\fR, \fBaarp\fR, \fBdecnet\fR, \fBiso\fR, \fBstp\fR, \fBipx\fR, \fBnetbeui\fP, \fBbatadv\fP"
+ Abbreviations for:
+ .in +.5i
+ .nf
+@@ -795,6 +796,36 @@ For example:
+ filters IPv4 protocol encapsulated in Geneve with VNI 0xb. This will
+ match both IPv4 directly encapsulated in Geneve as well as IPv4 contained
+ inside an Ethernet frame.
++.IP "\fBbatadv \fI[version] \fI[type]\fR"
++True if the packet is a B.A.T.M.A.N. Advanced packet (Ethernet type 0x4305).
++If the optional \fIversion\fR is specified, only true if the packet has the
++specified batman-adv compatibility \fIversion\fR. If the optional \fIversion\fR
++and \fItype\fR are specified, only true if the packet has both the specified
++batman-adv compatibility \fIversion\fR and batman-adv packet \fItype\fR.
++.IP
++\fIversion\fR may be a number from 0 to 255, though only compatibility version
++14 and 15 were actually deployed in the wild. Version 15 is the current version,
++14 is considered deprecated.
++.IP
++\fItype\fR is currently only defined for compatibility \fIversion\fR 14 and 15.
++\fItype\fR may be a number from 0 to 255 for compatibility \fIversion\fR 14 and 15.
++.IP
++The following packet \fItype\fR aliases are available for compat \fIversion\fR 14:
++\fBiv_ogm\fP, \fBicmp\fP, \fBunicast\fP, \fBbcast\fP, \fBvis\fP, \fBunicast-frag\fP,
++\fBtt_query\fP, \fBroam_adv\fP, \fBunicast_4addr\fP, \fPcoded\fP.
++.IP
++The following packet \fItype\fR aliases are available for compat \fIversion\fR 15:
++\fBiv_ogm\fP, \fBbcast\fP, \fBcoded\fP, \fBelp\fP, \fBogm2\fP, \fBunicast\fP,
++\fBunicast_frag\fP, \fBunicast_4addr\fP, \fBicmp\fP, \fPunicast_tvlv\fP.
++.IP
++Note that when the \fBbatadv\fR keyword is encountered in an expression and
++a batman-adv packet \fItype\fR is provided which specifies an encapsulating
++packet type then it changes the decoding offsets for the remainder of the
++expression on the assumption that the packet is a batman-adv packet. For compat
++\fIversion\fR 14 these are packet \fItype\fRs \fBunicast\fP, \fBbcast\fP,
++\fBunicast_frag\fP, \fBunicast_4addr\fP and \fBcoded\fP. For compat \fIversion\fR
++15 these are currently packet \fItype\fRs \fBbcast\fP, \fBcoded\fP, \fBunicast\fP,
++\fBunicast_frag\fP and \fBunicast_4addr\fP.
+ .IP "\fBiso proto \fIprotocol\fR"
+ True if the packet is an OSI packet of protocol type \fIprotocol\fP.
+ \fIProtocol\fP can be a number or one of the names
+--- a/pcap/namedb.h
++++ b/pcap/namedb.h
+@@ -94,6 +94,8 @@ PCAP_API int	pcap_nametoeproto(const cha
+ 
+ PCAP_AVAILABLE_0_9
+ PCAP_API int	pcap_nametollc(const char *);
++PCAP_API int	pcap_nametobatadvtype_v14(const char *);
++PCAP_API int	pcap_nametobatadvtype_v15(const char *);
+ 
+ /*
+  * If a protocol is unknown, PROTO_UNDEF is returned.
+--- a/scanner.l
++++ b/scanner.l
+@@ -365,6 +365,7 @@ mpls		return MPLS;
+ pppoed		return PPPOED;
+ pppoes		return PPPOES;
+ geneve		return GENEVE;
++batadv		return BATADV;
+ 
+ lane		return LANE;
+ llc		return LLC;
diff --git a/package/libs/libprop2uci/Makefile b/package/libs/libprop2uci/Makefile
new file mode 100644
index 0000000..87d3e35
--- /dev/null
+++ b/package/libs/libprop2uci/Makefile
@@ -0,0 +1,62 @@
+#
+# Copyright (C) 2010-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:=prop2uci
+PKG_VERSION:=1.0
+PKG_RELEASE=1
+USE_SOURCE_DIR:=$(MRVLDIR)/services/android_wrapper/prop2uci
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/prop2uci
+  SECTION:=sys
+  CATEGORY:=Base system
+  DEPENDS:=+libprop2uci
+  TITLE:=Marvell Android Application to UCI wrapper application
+endef
+
+define Package/libprop2uci
+  SECTION:=libs
+  CATEGORY:=Libraries
+  DEPENDS:=@TARGET_mmp +libuci
+  TITLE:=Marvell Android Property to UCI wrapper library
+endef
+
+define Build/Clean
+	rm -rf $(USE_SOURCE_DIR)/*.so
+	rm -rf $(USE_SOURCE_DIR)/*.a
+	rm -rf $(USE_SOURCE_DIR)/*.o
+endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/lib $(1)/usr/bin $(1)/usr/include/libprop2uci $(1)/usr/include/cutils
+	$(CP) $(USE_SOURCE_DIR)/getprop $(1)/usr/bin/
+	$(CP) $(USE_SOURCE_DIR)/setprop $(1)/usr/bin/
+	$(CP) $(USE_SOURCE_DIR)/delprop $(1)/usr/bin/
+	$(CP) $(USE_SOURCE_DIR)/include/* $(1)/usr/include/libprop2uci/
+	$(CP) $(USE_SOURCE_DIR)/include/* $(1)/usr/include/cutils/
+	$(CP) $(USE_SOURCE_DIR)/libprop2uci.so $(1)/usr/lib/
+endef
+
+define Package/prop2uci/install
+	$(INSTALL_DIR) $(1)/usr/bin
+	$(CP) $(USE_SOURCE_DIR)/getprop $(1)/usr/bin/
+	$(CP) $(USE_SOURCE_DIR)/setprop $(1)/usr/bin/
+	$(CP) $(USE_SOURCE_DIR)/delprop $(1)/usr/bin/
+endef
+
+define Package/libprop2uci/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(USE_SOURCE_DIR)/libprop2uci.so $(1)/usr/lib/
+	mkdir -p $(BIN_DIR)/symbol/libs/libprop2uci/lib
+	$(CP) $(USE_SOURCE_DIR)/libprop2uci.so $(BIN_DIR)/symbol/libs/libprop2uci/lib/
+endef
+
+$(eval $(call BuildPackage,prop2uci))
+$(eval $(call BuildPackage,libprop2uci))
diff --git a/package/libs/libselinux/Makefile b/package/libs/libselinux/Makefile
new file mode 100644
index 0000000..f90d499
--- /dev/null
+++ b/package/libs/libselinux/Makefile
@@ -0,0 +1,161 @@
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libselinux
+PKG_VERSION:=3.5
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://github.com/SELinuxProject/selinux/releases/download/$(PKG_VERSION)
+PKG_HASH:=9a3a3705ac13a2ccca2de6d652b6356fead10f36fb33115c185c5ccdf29eec19
+
+PKG_LICENSE:=libselinux-1.0
+PKG_LICENSE_FILES:=LICENSE
+PKG_MAINTAINER:=Thomas Petazzoni <thomas.petazzoni@bootlin.com>
+PKG_CPE_ID:=cpe:/a:selinuxproject:libselinux
+
+PKG_BUILD_FLAGS:=no-lto
+
+HOST_BUILD_DEPENDS:=libsepol/host musl-fts/host pcre2/host
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+
+LIBSELINUX_UTILS := \
+	avcstat \
+	compute_av \
+	compute_create \
+	compute_member \
+	compute_relabel \
+	getconlist \
+	getdefaultcon \
+	getenforce \
+	getfilecon \
+	getpidcon \
+	getsebool \
+	getseuser \
+	matchpathcon \
+	policyvers \
+	sefcontext_compile \
+	selabel_digest \
+	selabel_get_digests_all_partial_matches \
+	selabel_lookup \
+	selabel_lookup_best_match \
+	selabel_partial_match \
+	selinux_check_access \
+	selinux_check_securetty_context \
+	selinuxenabled \
+	selinuxexeccon \
+	setenforce \
+	setfilecon \
+	togglesebool \
+	validatetrans
+
+LIBSELINUX_ALTS := \
+	getenforce \
+	getsebool \
+	matchpathcon \
+	selinuxenabled \
+	setenforce
+
+$(eval $(foreach a,$(LIBSELINUX_ALTS),ALTS_$(a):=300:/usr/sbin/$(a):/usr/sbin/libselinux-$(a)$(newline)))
+
+define Package/libselinux/Default
+  TITLE:=Runtime SELinux library
+  URL:=http://selinuxproject.org/page/Main_Page
+endef
+
+define Package/libselinux
+  $(call Package/libselinux/Default)
+  SECTION:=libs
+  CATEGORY:=Libraries
+  DEPENDS:=+libsepol +libpcre2 +USE_MUSL:musl-fts
+endef
+
+define Package/libselinux/description
+	libselinux is the runtime SELinux library that provides
+	interfaces (e.g. library functions for the SELinux kernel
+	APIs like getcon(), other support functions like
+	getseuserbyname()) to SELinux-aware applications. libselinux
+	may use the shared libsepol to manipulate the binary policy
+	if necessary (e.g. to downgrade the policy format to an
+	older version supported by the kernel) when loading policy.
+endef
+
+define GenUtilPkg
+ define Package/$(1)
+   $(call Package/libselinux/Default)
+   TITLE+= $(2) utility
+   SECTION:=utils
+   DEPENDS:=+libselinux
+   CATEGORY:=Utilities
+   SUBMENU:=libselinux tools
+   ALTERNATIVES:=$(ALTS_$(2))
+ endef
+
+ define Package/$(1)/description
+  libselinux version of the $(2) utility.
+ endef
+endef
+
+$(foreach a,$(LIBSELINUX_UTILS),$(eval $(call GenUtilPkg,libselinux-$(a),$(a))))
+
+# Needed to link libselinux utilities, which link against
+# libselinux.so, which indirectly depends on libpcre2.so, installed in
+# $(STAGING_DIR_HOSTPKG).
+HOST_LDFLAGS += -Wl,-rpath="$(STAGING_DIR_HOSTPKG)/lib"
+
+HOST_MAKE_FLAGS += \
+	PREFIX=$(STAGING_DIR_HOSTPKG) \
+	SHLIBDIR=$(STAGING_DIR_HOSTPKG)/lib \
+	FTS_LDLIBS=-lfts
+
+ifeq ($(CONFIG_USE_MUSL),y)
+MAKE_FLAGS += FTS_LDLIBS=-lfts
+TARGET_CFLAGS += -D_LARGEFILE64_SOURCE
+endif
+
+MAKE_FLAGS += \
+	SHLIBDIR=/usr/lib \
+	OS=Linux
+
+define Build/Compile
+	$(call Build/Compile/Default,all)
+endef
+
+define Build/Install
+	$(call Build/Install/Default,install)
+endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/* $(1)/usr/lib/
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libselinux.pc $(1)/usr/lib/pkgconfig/
+	$(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/libselinux.pc
+	$(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/libselinux.pc
+endef
+
+define Package/libselinux/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libselinux.so.* $(1)/usr/lib/
+endef
+
+define BuildUtil
+  define Package/$(1)/install
+	$(INSTALL_DIR) $$(1)/usr/sbin
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/$(2) $$(1)/usr/sbin/$(if $(ALTS_$(2)),libselinux-$(2),$(2))
+  endef
+
+  $$(eval $$(call BuildPackage,$(1)))
+endef
+
+$(eval $(call HostBuild))
+$(eval $(call BuildPackage,libselinux))
+$(foreach a,$(LIBSELINUX_UTILS),$(eval $(call BuildUtil,libselinux-$(a),$(a))))
diff --git a/package/libs/libsemanage/Makefile b/package/libs/libsemanage/Makefile
new file mode 100644
index 0000000..9ebf9a6
--- /dev/null
+++ b/package/libs/libsemanage/Makefile
@@ -0,0 +1,73 @@
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libsemanage
+PKG_VERSION:=3.5
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://github.com/SELinuxProject/selinux/releases/download/$(PKG_VERSION)
+PKG_HASH:=f53534e50247538280ed0d76c6ce81d8fb3939bd64cadb89da10dba42e40dd9c
+PKG_MAINTAINER:=Thomas Petazzoni <thomas.petazzoni@bootlin.com>
+PKG_LICENSE:=LGPL-2.1
+PKG_LICENSE_FILES:=COPYING
+PKG_CPE_ID:=cpe:/a:selinuxproject:libsemanage
+
+
+HOST_BUILD_DEPENDS:=audit/host libselinux/host bzip2/host
+
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+
+PKG_INSTALL:=1
+
+define Package/libsemanage
+  SECTION:=libs
+  DEPENDS:=+libaudit +libselinux +libbz2
+  CATEGORY:=Libraries
+  TITLE:=SELinux policy management library
+  URL:=http://selinuxproject.org/page/Main_Page
+endef
+
+define Package/libsemanage/description
+	libsemanage is the policy management library. It uses
+	libsepol for binary policy manipulation and libselinux for
+	interacting with the SELinux system. It also exec's helper
+	programs for loading policy and for checking whether the
+	file_contexts configuration is valid (load_policy and
+	setfiles from policycoreutils) presently, although this may
+	change at least for the bootstrapping case (for rpm).
+endef #'
+
+
+HOST_MAKE_FLAGS += \
+	DESTDIR=$(STAGING_DIR_HOSTPKG) \
+	PREFIX=""
+
+
+define Build/Configure
+endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libsemanage.pc $(1)/usr/lib/pkgconfig/
+	$(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/libsemanage.pc
+	$(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/libsemanage.pc
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/* $(1)/usr/lib/
+endef
+
+define Package/libsemanage/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libsemanage.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call HostBuild))
+$(eval $(call BuildPackage,libsemanage))
diff --git a/package/libs/libsepol/Makefile b/package/libs/libsepol/Makefile
new file mode 100644
index 0000000..7930414
--- /dev/null
+++ b/package/libs/libsepol/Makefile
@@ -0,0 +1,88 @@
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libsepol
+PKG_VERSION:=3.5
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://github.com/SELinuxProject/selinux/releases/download/$(PKG_VERSION)
+PKG_HASH:=78fdaf69924db780bac78546e43d9c44074bad798c2c415d0b9bb96d065ee8a2
+
+PKG_MAINTAINER:=Thomas Petazzoni <thomas.petazzoni@bootlin.com>
+PKG_CPE_ID:=cpe:/a:selinuxproject:libsepol
+
+PKG_BUILD_FLAGS:=no-lto
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+
+define Package/libsepol
+  SECTION:=libs
+  CATEGORY:=Libraries
+  DEPENDS:=@SELINUX
+  TITLE:=SELinux binary policy manipulation library
+  URL:=http://selinuxproject.org/page/Main_Page
+endef
+
+define Package/libsepol/description
+	Libsepol is the binary policy manipulation library. It doesn't
+	depend upon or use any of the other SELinux components.
+endef
+
+define Package/chkcon
+  SECTION:=utils
+  CATEGORY:=Utilities
+  DEPENDS:=+libsepol
+  TITLE:=libsepol chkcon security context validation tool
+  URL:=http://selinuxproject.org/page/Main_Page
+endef
+
+define Package/chkcon/description
+	chkcon - determine if a security context is valid for a given binary policy
+endef
+
+HOST_MAKE_FLAGS += \
+	PREFIX=$(STAGING_DIR_HOSTPKG) \
+	SHLIBDIR=$(STAGING_DIR_HOSTPKG)/lib
+
+MAKE_FLAGS += \
+	SHLIBDIR=/usr/lib \
+	OS=Linux
+
+define Build/Compile
+	$(call Build/Compile/Default,all)
+endef
+
+define Build/Install
+	$(call Build/Install/Default,install)
+endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/* $(1)/usr/lib/
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libsepol.pc $(1)/usr/lib/pkgconfig/
+	$(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/libsepol.pc
+	$(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/libsepol.pc
+endef
+
+define Package/libsepol/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libsepol.so.* $(1)/usr/lib/
+endef
+
+define Package/chkcon/install
+	$(INSTALL_DIR) $(1)/usr/bin
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/chkcon $(1)/usr/bin/
+endef
+
+$(eval $(call HostBuild))
+$(eval $(call BuildPackage,libsepol))
+$(eval $(call BuildPackage,chkcon))
diff --git a/package/libs/libstreamingmedia/Config.in b/package/libs/libstreamingmedia/Config.in
new file mode 100644
index 0000000..a6ca0e3
--- /dev/null
+++ b/package/libs/libstreamingmedia/Config.in
@@ -0,0 +1,39 @@
+# IMS configuration
+
+menu "Configuration"
+	depends on PACKAGE_streamingmedia
+
+config STREAMINGMEDIA_PREBUILT
+	bool "streamingmedia prebuilt"
+	default y
+	help
+		use prebuilt streamingmedia image
+
+if !STREAMINGMEDIA_PREBUILT
+
+config STREAMINGMEDIA_PREBUILT_OVERRIDE
+	bool "prebuilt override"
+	default n
+	help
+		Force prebuilt override - when enabled, the build process
+		will also copy the output image to the prebuilt directory even if
+		it exists. As a byproduct, the package will be compiled from scratch
+		even if there are no changes in the sources, as the package
+		directory is always updated.
+
+
+config STREAMINGMEDIA_LOCAL_CODE
+	bool "compile local code(dev only)"
+	default n
+	help
+		streamingmedia local_code
+
+config STREAMINGMEDIA_DEBUG_MODE
+	bool "debug_mode"
+	default n
+	help
+		streamingmedia debug_mode
+
+
+endif
+endmenu
diff --git a/package/libs/libstreamingmedia/Makefile b/package/libs/libstreamingmedia/Makefile
new file mode 100644
index 0000000..5bb9750
--- /dev/null
+++ b/package/libs/libstreamingmedia/Makefile
@@ -0,0 +1,119 @@
+#
+# Copyright (C) 2010-2011 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+define Package/streamingmedia/config
+    source "$(SOURCE)/Config.in"
+endef
+ifeq ($(CONFIG_USE_GLIBC),y)
+toolchain:=-glibc
+endif
+PKG_NAME:=streamingmedia
+PKG_VERSION:=2024-10-22
+PKG_REV_LONG:=f6e945cb3fac63a1912d26f4e71fc9f8896b1a75
+GCC_MAJOR := $(shell echo $(CONFIG_GCC_VERSION) | cut -d. -f1)
+ifneq ($(GCC_MAJOR),)
+ifeq ($(shell [ $(GCC_MAJOR) -gt 12 ] && echo 1 || echo 0), 1)
+    $(info GCC_MAJOR is greater than 12)
+    gccversion:=-gcc$(GCC_MAJOR)
+	imsthumb:=0
+else
+    $(info GCC_MAJOR is not greater than 12)
+endif
+endif
+
+PKG_REV:=$(shell echo $(PKG_REV_LONG) | cut -c1-7)
+PKG_TAG:=$(PKG_NAME)-v2102$(gccversion)$(toolchain)-v$(PKG_VERSION)-r$(PKG_REV)
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_TAG)
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=ssh://$(USER)@10.26.132.102:29418/android_l/vendor/marvell/generic/streamingmedia_hf -b codedev5.1
+PKG_SOURCE_SUBDIR:=$(PKG_TAG)
+PKG_SOURCE_VERSION:=$(PKG_REV)
+PKG_SOURCE:=$(PKG_TAG).tar.gz
+
+PREBUILT_FNAME:=prebuilt-$(PKG_TAG)
+PREBUILT_FPATH:=$(CURDIR)/prebuilt/$(PREBUILT_FNAME).tar.gz
+
+ifeq ($(CONFIG_STREAMINGMEDIA_LOCAL_CODE),y)
+	USE_SOURCE_DIR:=$(MRVLDIR)/streamingmedia
+endif
+
+PKG_INSTALL:=1
+
+PKG_MAINTAINER:=Hui Zhang <huizhang@asrmicro.com>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/streamingmedia
+  SECTION:=libs
+  CATEGORY:=Libraries
+  DEPENDS:=+libpthread +libstdcpp +liblog +lte-telephony
+  TITLE:=Marvell IMS Streaming Media Library
+endef
+
+define Package/streamingmedia/description
+  Marvell IMS Streaming Media Library support
+endef
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_TAG)
+
+CMAKE_OPTIONS += -DOPT_NO_OPTIMIZING=ON
+
+ifneq ($(CONFIG_STREAMINGMEDIA_PREBUILT),)
+define Download
+endef
+define Build/Prepare
+    $(if $(wildcard $(PREBUILT_FPATH)),,@echo "Error: $(PREBUILT_FPATH) not found"; false)
+endef
+define Build/Configure
+endef
+define Build/Compile
+endef
+define Build/Install
+	$(INSTALL_DIR) $(PKG_INSTALL_DIR)
+	echo "Unpacking prebuilt..." && \
+	$(TAR) -zxvf $(PREBUILT_FPATH) -C $(TMP_DIR) && \
+	$(CP) $(TMP_DIR)/$(PREBUILT_FNAME)/* $(PKG_INSTALL_DIR) && \
+	rm -rf $(TMP_DIR)/$(PREBUILT_FNAME);
+endef
+
+else
+ifeq ($(CONFIG_STREAMINGMEDIA_LOCAL_CODE),y)
+define Package/streamingmedia/Prepare
+    rm -rf $(PKG_BUILD_DIR)
+    cp -rf $(USE_SOURCE_DIR) $(PKG_BUILD_DIR)
+endef
+endif
+endif
+
+define Prebuilt/Pack
+    echo "Packing prebuilt..." && \
+    mkdir -p $(TMP_DIR)/$(PREBUILT_FNAME) && \
+    cd $(TMP_DIR) && \
+    $(CP) $(PKG_INSTALL_DIR)/* ./$(PREBUILT_FNAME) && \
+    $(TAR) czf $(PREBUILT_FNAME).tar.gz $(PREBUILT_FNAME) && \
+    mv $(TMP_DIR)/$(PREBUILT_FNAME).tar.gz $(PREBUILT_FPATH) && \
+    rm -rf $(TMP_DIR)/$(PREBUILT_FNAME);
+endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/lib $(1)/usr/include/streamingmedia
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so $(1)/usr/lib
+	$(CP) -rf $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/streamingmedia
+endef
+
+define Package/streamingmedia/install
+	$(INSTALL_DIR) $(1)/usr/lib $(1)/usr/bin $(1)/usr/include/streamingmedia
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin
+	$(CP) -rf $(PKG_INSTALL_DIR)/usr/include/*.h $(1)/usr/include/streamingmedia
+	$(if $(wildcard $(PREBUILT_FPATH)),$(if $(CONFIG_STREAMINGMEDIA_PREBUILT_OVERRIDE),@echo "WARNING: prebuilt override!"; $(call Prebuilt/Pack)),$(call Prebuilt/Pack))
+endef
+
+$(eval $(call BuildPackage,streamingmedia))
diff --git a/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2021-09-28-r1732fc7.tar.gz b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2021-09-28-r1732fc7.tar.gz
new file mode 100644
index 0000000..88a63c8
--- /dev/null
+++ b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2021-09-28-r1732fc7.tar.gz
Binary files differ
diff --git a/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2021-11-02-r8cd2a62.tar.gz b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2021-11-02-r8cd2a62.tar.gz
new file mode 100644
index 0000000..6564584
--- /dev/null
+++ b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2021-11-02-r8cd2a62.tar.gz
Binary files differ
diff --git a/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2022-03-10-r9a0c80e.tar.gz b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2022-03-10-r9a0c80e.tar.gz
new file mode 100644
index 0000000..ffa3fae
--- /dev/null
+++ b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2022-03-10-r9a0c80e.tar.gz
Binary files differ
diff --git a/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2022-04-14-red0c2c6.tar.gz b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2022-04-14-red0c2c6.tar.gz
new file mode 100644
index 0000000..90ecd41
--- /dev/null
+++ b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2022-04-14-red0c2c6.tar.gz
Binary files differ
diff --git a/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2022-09-21-ra404ea7.tar.gz b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2022-09-21-ra404ea7.tar.gz
new file mode 100644
index 0000000..cdac9b7
--- /dev/null
+++ b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2022-09-21-ra404ea7.tar.gz
Binary files differ
diff --git a/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2022-10-17-r71f9f53.tar.gz b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2022-10-17-r71f9f53.tar.gz
new file mode 100644
index 0000000..1e0a39c
--- /dev/null
+++ b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2022-10-17-r71f9f53.tar.gz
Binary files differ
diff --git a/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2022-11-07-rf5255ad.tar.gz b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2022-11-07-rf5255ad.tar.gz
new file mode 100644
index 0000000..8719450
--- /dev/null
+++ b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2022-11-07-rf5255ad.tar.gz
Binary files differ
diff --git a/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-01-03-ra05a50c.tar.gz b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-01-03-ra05a50c.tar.gz
new file mode 100644
index 0000000..b0adc04
--- /dev/null
+++ b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-01-03-ra05a50c.tar.gz
Binary files differ
diff --git a/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-01-13-r1d4ab72.tar.gz b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-01-13-r1d4ab72.tar.gz
new file mode 100644
index 0000000..7a49ccd
--- /dev/null
+++ b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-01-13-r1d4ab72.tar.gz
Binary files differ
diff --git a/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-01-16-rc01aa2c.tar.gz b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-01-16-rc01aa2c.tar.gz
new file mode 100644
index 0000000..d962ca7
--- /dev/null
+++ b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-01-16-rc01aa2c.tar.gz
Binary files differ
diff --git a/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-02-01-r4115cbd.tar.gz b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-02-01-r4115cbd.tar.gz
new file mode 100644
index 0000000..048a7a8
--- /dev/null
+++ b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-02-01-r4115cbd.tar.gz
Binary files differ
diff --git a/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-02-03-r7b3b592.tar.gz b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-02-03-r7b3b592.tar.gz
new file mode 100644
index 0000000..a11706c
--- /dev/null
+++ b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-02-03-r7b3b592.tar.gz
Binary files differ
diff --git a/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-02-10-r5750fa8.tar.gz b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-02-10-r5750fa8.tar.gz
new file mode 100644
index 0000000..80e0048
--- /dev/null
+++ b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-02-10-r5750fa8.tar.gz
Binary files differ
diff --git a/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-02-17-ra750af4.tar.gz b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-02-17-ra750af4.tar.gz
new file mode 100644
index 0000000..821dd31
--- /dev/null
+++ b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-02-17-ra750af4.tar.gz
Binary files differ
diff --git a/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-03-09-rfaa9505.tar.gz b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-03-09-rfaa9505.tar.gz
new file mode 100644
index 0000000..b14f792
--- /dev/null
+++ b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-03-09-rfaa9505.tar.gz
Binary files differ
diff --git a/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-03-22-r6c21a02.tar.gz b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-03-22-r6c21a02.tar.gz
new file mode 100644
index 0000000..118e9cd
--- /dev/null
+++ b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2023-03-22-r6c21a02.tar.gz
Binary files differ
diff --git a/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-gcc13-glibc-v2024-04-09-ra5811c1.tar.gz b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-gcc13-glibc-v2024-04-09-ra5811c1.tar.gz
new file mode 100644
index 0000000..2d10a9f
--- /dev/null
+++ b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-gcc13-glibc-v2024-04-09-ra5811c1.tar.gz
Binary files differ
diff --git a/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-gcc13-glibc-v2024-10-22-rf6e945c.tar.gz b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-gcc13-glibc-v2024-10-22-rf6e945c.tar.gz
new file mode 100644
index 0000000..b651696
--- /dev/null
+++ b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-gcc13-glibc-v2024-10-22-rf6e945c.tar.gz
Binary files differ
diff --git a/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-gcc13-v2024-04-09-ra5811c1.tar.gz b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-gcc13-v2024-04-09-ra5811c1.tar.gz
new file mode 100644
index 0000000..010ba2b
--- /dev/null
+++ b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-gcc13-v2024-04-09-ra5811c1.tar.gz
Binary files differ
diff --git a/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-gcc13-v2024-10-22-rf6e945c.tar.gz b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-gcc13-v2024-10-22-rf6e945c.tar.gz
new file mode 100644
index 0000000..8321afc
--- /dev/null
+++ b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-gcc13-v2024-10-22-rf6e945c.tar.gz
Binary files differ
diff --git a/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-glibc-v2023-03-31-r10fcbc4.tar.gz b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-glibc-v2023-03-31-r10fcbc4.tar.gz
new file mode 100644
index 0000000..315734d
--- /dev/null
+++ b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-glibc-v2023-03-31-r10fcbc4.tar.gz
Binary files differ
diff --git a/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-glibc-v2023-07-27-ra5811c1.tar.gz b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-glibc-v2023-07-27-ra5811c1.tar.gz
new file mode 100644
index 0000000..c26c3f4
--- /dev/null
+++ b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-glibc-v2023-07-27-ra5811c1.tar.gz
Binary files differ
diff --git a/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-glibc-v2024-04-09-ra5811c1.tar.gz b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-glibc-v2024-04-09-ra5811c1.tar.gz
new file mode 100644
index 0000000..5d32740
--- /dev/null
+++ b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-glibc-v2024-04-09-ra5811c1.tar.gz
Binary files differ
diff --git a/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-v2023-03-31-r10fcbc4.tar.gz b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-v2023-03-31-r10fcbc4.tar.gz
new file mode 100644
index 0000000..a0943f7
--- /dev/null
+++ b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-v2023-03-31-r10fcbc4.tar.gz
Binary files differ
diff --git a/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-v2023-07-27-ra5811c1.tar.gz b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-v2023-07-27-ra5811c1.tar.gz
new file mode 100644
index 0000000..c53b1aa
--- /dev/null
+++ b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-v2023-07-27-ra5811c1.tar.gz
Binary files differ
diff --git a/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-v2024-04-09-ra5811c1.tar.gz b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-v2024-04-09-ra5811c1.tar.gz
new file mode 100644
index 0000000..d7f07d3
--- /dev/null
+++ b/package/libs/libstreamingmedia/prebuilt/prebuilt-streamingmedia-v2102-v2024-04-09-ra5811c1.tar.gz
Binary files differ
diff --git a/package/libs/libtool/Makefile b/package/libs/libtool/Makefile
new file mode 100644
index 0000000..f897f98
--- /dev/null
+++ b/package/libs/libtool/Makefile
@@ -0,0 +1,54 @@
+#
+# Copyright (C) 2006 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:=libtool
+PKG_VERSION:=2.4.7
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
+PKG_SOURCE_URL:=@GNU/libtool
+PKG_HASH:=4f7f217f057ce655ff22559ad221a0fd8ef84ad1fc5fcb6990cecc333aa1635d
+
+PKG_LICENSE:=GPL-2.0+
+PKG_LICENSE_FILES:=COPYING
+PKG_CPE_ID:=cpe:/a:gnu:libtool
+
+PKG_BUILD_PARALLEL:=0
+
+include $(INCLUDE_DIR)/package.mk
+
+CONFIGURE_PREFIX=$(STAGING_DIR_HOSTPKG)
+export GLOBAL_LIBDIR=$(STAGING_DIR)/usr/lib
+
+define Package/libltdl
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=A generic dynamic object loading library
+  URL:=http://www.gnu.org/software/libtool/
+  ABI_VERSION:=7
+endef
+
+define Build/InstallDev
+	$(MAKE) -C $(PKG_BUILD_DIR) \
+		bindir="$(2)/libltdl/bin" \
+		datadir="$(2)/libltdl/share" \
+		prefix="$(2)/libltdl" \
+		exec_prefix="$(2)/libltdl" \
+		install
+	$(INSTALL_DIR) $(1)/usr/lib $(1)/usr/include
+	mv $(2)/libltdl/lib/* $(1)/usr/lib/
+	mv $(2)/libltdl/include/* $(1)/usr/include/
+endef
+
+define Package/libltdl/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_BUILD_DIR)/libltdl/.libs/libltdl.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libltdl))
diff --git a/package/libs/libtraceevent/Makefile b/package/libs/libtraceevent/Makefile
new file mode 100644
index 0000000..54e8652
--- /dev/null
+++ b/package/libs/libtraceevent/Makefile
@@ -0,0 +1,74 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libtraceevent
+PKG_VERSION:=1.8.2
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git/snapshot/
+PKG_HASH:=919f0c024c7b5059eace52d854d4df00ae7e361a4033e1b4d6fe01d97064a1b9
+
+PKG_MAINTAINER:=Nick Hainke <vincent@systemli.org>
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libtraceevent
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=Linux kernel trace event library
+  URL:=https://git.kernel.org/pub/scm/libs/libtrace/libtraceevent.git
+  ABI_VERSION:=0
+endef
+
+define Package/libtraceevent/description
+The libtraceevent library provides APIs to access kernel tracepoint events, located in
+the tracefs file system under the events directory.
+endef
+
+define Package/libtraceevent-extra
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=Extra plugins for libtraceevent
+  DEPENDS:=
+endef
+
+CONFIGURE_ARGS+= \
+	--enable-shared \
+	--enable-static
+
+PLUGINS_DIR := $(PKG_BUILD_DIR)/plugins
+PLUGINS_MAIN := function hrtimer mac80211 sched_switch
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) $(PKG_BUILD_DIR)/include/traceevent $(1)/usr/include/
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_BUILD_DIR)/lib/libtraceevent.{a,so*} $(1)/usr/lib/
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(CP) $(PKG_BUILD_DIR)/libtraceevent.pc $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libtraceevent/install
+	$(INSTALL_DIR) $(1)/usr/lib/traceevent/plugins
+	$(CP) $(PKG_BUILD_DIR)/lib/libtraceevent.so.* $(1)/usr/lib/
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) \
+		$(patsubst %,$(PLUGINS_DIR)/plugin_%.so,$(PLUGINS_MAIN)) \
+		$(1)/usr/lib/traceevent/plugins
+endef
+
+define Package/libtraceevent-extra/install
+	$(INSTALL_DIR) $(1)/usr/lib/traceevent/plugins
+	$(CP) \
+		$$(patsubst %,$(PLUGINS_DIR)/plugin_%.so, \
+			$$(filter-out $(PLUGINS_MAIN), \
+				$$(patsubst $(PLUGINS_DIR)/plugin_%.so,%, \
+					$$(wildcard $(PLUGINS_DIR)/plugin_*.so)))) \
+		$(1)/usr/lib/traceevent/plugins
+endef
+
+$(eval $(call BuildPackage,libtraceevent))
+$(eval $(call BuildPackage,libtraceevent-extra))
diff --git a/package/libs/libtracefs/Makefile b/package/libs/libtracefs/Makefile
new file mode 100644
index 0000000..0496f59
--- /dev/null
+++ b/package/libs/libtracefs/Makefile
@@ -0,0 +1,49 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libtracefs
+PKG_VERSION:=1.8.0
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git/snapshot/
+PKG_HASH:=f92475d5c4cb509983697fb359ee615bef4f08ed8bdc9c690f6118ba68886de0
+
+PKG_MAINTAINER:=Nick Hainke <vincent@systemli.org>
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libtracefs
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=Linux kernel trace file system library
+  URL:=https://git.kernel.org/pub/scm/libs/libtrace/libtracefs.git
+  DEPENDS+=+libpthread +libtraceevent
+  ABI_VERSION:=0
+endef
+
+define Package/libtracefs/description
+The libtracefs library provides APIs to access kernel trace file system.
+endef
+
+CONFIGURE_ARGS+= \
+	--enable-shared \
+	--enable-static \
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) $(PKG_BUILD_DIR)/include/* $(1)/usr/include/
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_BUILD_DIR)/lib/libtracefs.{a,so*} $(1)/usr/lib/
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(CP) $(PKG_BUILD_DIR)/libtracefs.pc $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libtracefs/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_BUILD_DIR)/lib/libtracefs.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libtracefs))
diff --git a/package/libs/libubox/Makefile b/package/libs/libubox/Makefile
new file mode 100644
index 0000000..88884fb
--- /dev/null
+++ b/package/libs/libubox/Makefile
@@ -0,0 +1,115 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libubox
+PKG_RELEASE=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL=$(PROJECT_GIT)/project/libubox.git
+PKG_MIRROR_HASH:=7fbaa84cfb553bebd780194fe7b8b502b7745e709e45912bce192cd1c8380016
+PKG_SOURCE_DATE:=2024-03-29
+PKG_SOURCE_VERSION:=eb9bcb64185ac155c02cc1a604692c4b00368324
+PKG_ABI_VERSION:=$(call abi_version_str,$(PKG_SOURCE_DATE))
+CMAKE_INSTALL:=1
+
+PKG_LICENSE:=ISC
+PKG_LICENSE_FILES:=
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
+
+PKG_BUILD_DEPENDS:=lua
+HOST_BUILD_DEPENDS:=libjson-c/host
+HOST_BUILD_PREFIX:=$(STAGING_DIR_HOST)
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/libubox
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=Basic utility library
+  ABI_VERSION:=$(PKG_ABI_VERSION)
+  DEPENDS:=
+endef
+
+define Package/libblobmsg-json
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=blobmsg <-> json conversion library
+  ABI_VERSION:=$(PKG_ABI_VERSION)
+  DEPENDS:=+libjson-c +libubox
+endef
+
+define Package/jshn
+  SECTION:=utils
+  CATEGORY:=Utilities
+  DEPENDS:=+libjson-c +libubox +libblobmsg-json
+  TITLE:=JSON SHell Notation
+endef
+
+define Package/jshn/description
+  Library for parsing and generating JSON from shell scripts
+endef
+
+define Package/libjson-script
+  SECTION:=utils
+  CATEGORY:=Utilities
+  DEPENDS:=+libubox
+  ABI_VERSION:=$(PKG_ABI_VERSION)
+  TITLE:=Minimalistic JSON based scripting engine
+endef
+
+define Package/libubox-lua
+  SECTION:=libs
+  CATEGORY:=Libraries
+  DEPENDS:=+libubox +liblua
+  TITLE:=Lua binding for the OpenWrt Basic utility library
+endef
+
+TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include
+CMAKE_OPTIONS += \
+	-DLUAPATH=/usr/lib/lua \
+	-DABIVERSION="$(PKG_ABI_VERSION)"
+
+define Package/libubox/install
+	$(INSTALL_DIR) $(1)/lib/
+	$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libubox.so.* $(1)/lib/
+	mkdir -p $(BIN_DIR)/symbol/libs/libubox/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libubox.so.* $(BIN_DIR)/symbol/libs/libubox/lib/
+endef
+
+define Package/libblobmsg-json/install
+	$(INSTALL_DIR) $(1)/lib/
+	$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libblobmsg_json.so.* $(1)/lib/
+endef
+
+define Package/jshn/install
+	$(INSTALL_DIR) $(1)/usr/bin $(1)/usr/share/libubox
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/jshn $(1)/usr/bin
+	$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/libubox/jshn.sh $(1)/usr/share/libubox
+endef
+
+define Package/libjson-script/install
+	$(INSTALL_DIR) $(1)/lib/
+	$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libjson_script.so.* $(1)/lib/
+endef
+
+define Package/libubox-lua/install
+	$(INSTALL_DIR) $(1)/usr/lib/lua
+	$(CP) $(PKG_BUILD_DIR)/lua/uloop.so $(1)/usr/lib/lua/
+endef
+
+
+CMAKE_HOST_OPTIONS += \
+	-DBUILD_LUA=OFF \
+	-DBUILD_EXAMPLES=OFF \
+	-DCMAKE_SKIP_RPATH=FALSE \
+	-DCMAKE_MACOSX_RPATH=1 \
+	-DCMAKE_INSTALL_RPATH="${STAGING_DIR_HOST}/lib" \
+
+$(eval $(call BuildPackage,libubox))
+$(eval $(call BuildPackage,libblobmsg-json))
+$(eval $(call BuildPackage,jshn))
+$(eval $(call BuildPackage,libjson-script))
+$(eval $(call BuildPackage,libubox-lua))
+$(eval $(call HostBuild))
diff --git a/package/libs/libunistring/Makefile b/package/libs/libunistring/Makefile
new file mode 100644
index 0000000..f53b50a
--- /dev/null
+++ b/package/libs/libunistring/Makefile
@@ -0,0 +1,64 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libunistring
+PKG_VERSION:=1.2
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
+PKG_SOURCE_URL:=@GNU/$(PKG_NAME)
+PKG_HASH:=632bd65ed74a881ca8a0309a1001c428bd1cbd5cd7ddbf8cedcd2e65f4dcdc44
+
+PKG_BUILD_PARALLEL:=1
+PKG_INSTALL:=1
+
+PKG_LICENSE:=GPL-3.0
+PKG_LICENSE_FILES:=COPYING
+PKG_CPE_ID:=cpe:/a:gnu:$(PKG_NAME)
+
+include $(INCLUDE_DIR)/host-build.mk
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libunistring
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=libunistring
+  URL:=https://www.gnu.org/software/libunistring
+endef
+
+define Package/libunistring/description
+  This library provides functions for manipulating Unicode strings
+  and for manipulating C strings according to the Unicode standard.
+endef
+
+HOST_CFLAGS += $(HOST_FPIC)
+
+TARGET_CFLAGS += $(FPIC)
+
+HOST_CONFIGURE_ARGS += \
+	--enable-static \
+	--disable-shared \
+	--without-libiconv-prefix \
+	--with-pic
+
+CONFIGURE_ARGS += \
+	--enable-static \
+	--enable-shared \
+	--without-libiconv-prefix \
+	--with-pic
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/*.h $(1)/usr/include/
+	$(INSTALL_DIR) $(1)/usr/include/unistring
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/unistring/*.h $(1)/usr/include/unistring/
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libunistring.{a,so*} $(1)/usr/lib/
+endef
+
+define Package/libunistring/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libunistring.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call HostBuild))
+$(eval $(call BuildPackage,libunistring))
diff --git a/package/libs/libunwind/Makefile b/package/libs/libunwind/Makefile
new file mode 100644
index 0000000..7bd3c5a
--- /dev/null
+++ b/package/libs/libunwind/Makefile
@@ -0,0 +1,62 @@
+#
+# Copyright (C) 2008-2013 OpenWrt.org
+# Copyright (C) 2017-2019 Yousong Zhou <yszhou4tech@gmail.com>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libunwind
+PKG_VERSION:=1.8.1
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=https://github.com/$(PKG_NAME)/$(PKG_NAME)/releases/download/v$(PKG_VERSION)/
+PKG_HASH:=ddf0e32dd5fafe5283198d37e4bf9decf7ba1770b6e7e006c33e6df79e6a6157
+
+PKG_MAINTAINER:=Yousong Zhou <yszhou4tech@gmail.com>
+PKG_LICENSE:=X11
+PKG_LICENSE_FILES:=LICENSE
+PKG_CPE_ID:=cpe:/a:libunwind_project:libunwind
+
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libunwind
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=The libunwind project
+  URL:=http://www.nongnu.org/libunwind/
+  DEPENDS:=@((mips||mipsel||mips64||powerpc64||x86_64||arm||aarch64||loongarch64)||(USE_GLIBC&&(powerpc||i386))) +zlib
+  ABI_VERSION:=8
+endef
+
+define Package/libunwind/description
+  Libunwind defines a portable and efficient C programming interface (API) to determine the call-chain of a program.
+endef
+
+CONFIGURE_ARGS += \
+	--disable-documentation \
+	--disable-tests \
+	--disable-minidebuginfo
+
+TARGET_LDFLAGS += $(if $(CONFIG_USE_MUSL),-lssp_nonshared)
+
+define Package/libunwind/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libunwin*.so.* $(1)/usr/lib/
+endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include $(1)/usr/lib/pkgconfig
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/*.h $(1)/usr/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libunwin*.so* $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/* $(1)/usr/lib/pkgconfig/
+endef
+
+$(eval $(call BuildPackage,libunwind))
diff --git a/package/libs/libunwind/patches/002-fix-building-getcontext_S.patch b/package/libs/libunwind/patches/002-fix-building-getcontext_S.patch
new file mode 100644
index 0000000..d88594e
--- /dev/null
+++ b/package/libs/libunwind/patches/002-fix-building-getcontext_S.patch
@@ -0,0 +1,17 @@
+--- a/src/mips/getcontext.S
++++ b/src/mips/getcontext.S
+@@ -24,12 +24,12 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
+ 
+ #include "offsets.h"
+-#include <endian.h>
+ 
+ 	.text
++	.set nomips16
+ 
+ #if _MIPS_SIM == _ABIO32
+-# if __BYTE_ORDER == __BIG_ENDIAN
++# if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+ #  define OFFSET 4
+ # else
+ #  define OFFSET 0
diff --git a/package/libs/libunwind/patches/003-fix-missing-ef_reg-defs-with-musl.patch b/package/libs/libunwind/patches/003-fix-missing-ef_reg-defs-with-musl.patch
new file mode 100644
index 0000000..c68e4b9
--- /dev/null
+++ b/package/libs/libunwind/patches/003-fix-missing-ef_reg-defs-with-musl.patch
@@ -0,0 +1,45 @@
+--- a/include/libunwind-mips.h
++++ b/include/libunwind-mips.h
+@@ -121,6 +121,42 @@ typedef enum
+   }
+ mips_regnum_t;
+ 
++#ifndef __GLIBC__
++#include <sys/reg.h>
++
++/* musl as of 1.1.14 does not export these */
++#define EF_REG0			6
++#define EF_REG1			7
++#define EF_REG2			8
++#define EF_REG3			9
++#define EF_REG4			10
++#define EF_REG5			11
++#define EF_REG6			12
++#define EF_REG7			13
++#define EF_REG8			14
++#define EF_REG9			15
++#define EF_REG10		16
++#define EF_REG11		17
++#define EF_REG12		18
++#define EF_REG13		19
++#define EF_REG14		20
++#define EF_REG15		21
++#define EF_REG16		22
++#define EF_REG17		23
++#define EF_REG18		24
++#define EF_REG19		25
++#define EF_REG20		26
++#define EF_REG21		27
++#define EF_REG22		28
++#define EF_REG23		29
++#define EF_REG24		30
++#define EF_REG25		31
++#define EF_REG28		34
++#define EF_REG29		35
++#define EF_REG30		36
++#define EF_REG31		37
++#endif
++
+ typedef enum
+   {
+     UNW_MIPS_ABI_O32,
diff --git a/package/libs/libunwind/patches/004-ppc-musl.patch b/package/libs/libunwind/patches/004-ppc-musl.patch
new file mode 100644
index 0000000..5ea79e1
--- /dev/null
+++ b/package/libs/libunwind/patches/004-ppc-musl.patch
@@ -0,0 +1,235 @@
+--- a/include/libunwind-ppc32.h
++++ b/include/libunwind-ppc32.h
+@@ -81,6 +81,88 @@ typedef int64_t unw_sword_t;
+ 
+ typedef long double unw_tdep_fpreg_t;
+ 
++#ifndef __GLIBC__
++
++/* We can't include asm/ptrace.h here, as it conflicts with musl's definitions */
++
++#define PT_R0	0
++#define PT_R1	1
++#define PT_R2	2
++#define PT_R3	3
++#define PT_R4	4
++#define PT_R5	5
++#define PT_R6	6
++#define PT_R7	7
++#define PT_R8	8
++#define PT_R9	9
++#define PT_R10	10
++#define PT_R11	11
++#define PT_R12	12
++#define PT_R13	13
++#define PT_R14	14
++#define PT_R15	15
++#define PT_R16	16
++#define PT_R17	17
++#define PT_R18	18
++#define PT_R19	19
++#define PT_R20	20
++#define PT_R21	21
++#define PT_R22	22
++#define PT_R23	23
++#define PT_R24	24
++#define PT_R25	25
++#define PT_R26	26
++#define PT_R27	27
++#define PT_R28	28
++#define PT_R29	29
++#define PT_R30	30
++#define PT_R31	31
++
++#define PT_NIP	32
++#define PT_MSR	33
++#define PT_ORIG_R3 34
++#define PT_CTR	35
++#define PT_LNK	36
++#define PT_XER	37
++#define PT_CCR	38
++#ifndef __powerpc64__
++#define PT_MQ	39
++#else
++#define PT_SOFTE 39
++#endif
++#define PT_TRAP	40
++#define PT_DAR	41
++#define PT_DSISR 42
++#define PT_RESULT 43
++#define PT_DSCR 44
++#define PT_REGS_COUNT 44
++
++#define PT_FPR0	48	/* each FP reg occupies 2 slots in this space */
++
++#ifndef __powerpc64__
++
++#define PT_FPR31 (PT_FPR0 + 2*31)
++#define PT_FPSCR (PT_FPR0 + 2*32 + 1)
++
++#else /* __powerpc64__ */
++
++#define PT_FPSCR (PT_FPR0 + 32)	/* each FP reg occupies 1 slot in 64-bit space */
++
++
++#define PT_VR0 82	/* each Vector reg occupies 2 slots in 64-bit */
++#define PT_VSCR (PT_VR0 + 32*2 + 1)
++#define PT_VRSAVE (PT_VR0 + 33*2)
++
++
++/*
++ * Only store first 32 VSRs here. The second 32 VSRs in VR0-31
++ */
++#define PT_VSR0 150	/* each VSR reg occupies 2 slots in 64-bit */
++#define PT_VSR31 (PT_VSR0 + 2*31)
++#endif /* __powerpc64__ */
++
++#endif /* !__GLIBC__ */
++
+ typedef enum
+   {
+     UNW_PPC32_R0,
+--- a/include/libunwind-ppc64.h
++++ b/include/libunwind-ppc64.h
+@@ -88,6 +88,88 @@ typedef struct {
+     uint64_t halves[2];
+ } unw_tdep_vreg_t;
+ 
++#ifndef __GLIBC__
++
++/* We can't include asm/ptrace.h here, as it conflicts with musl's definitions */
++
++#define PT_R0	0
++#define PT_R1	1
++#define PT_R2	2
++#define PT_R3	3
++#define PT_R4	4
++#define PT_R5	5
++#define PT_R6	6
++#define PT_R7	7
++#define PT_R8	8
++#define PT_R9	9
++#define PT_R10	10
++#define PT_R11	11
++#define PT_R12	12
++#define PT_R13	13
++#define PT_R14	14
++#define PT_R15	15
++#define PT_R16	16
++#define PT_R17	17
++#define PT_R18	18
++#define PT_R19	19
++#define PT_R20	20
++#define PT_R21	21
++#define PT_R22	22
++#define PT_R23	23
++#define PT_R24	24
++#define PT_R25	25
++#define PT_R26	26
++#define PT_R27	27
++#define PT_R28	28
++#define PT_R29	29
++#define PT_R30	30
++#define PT_R31	31
++
++#define PT_NIP	32
++#define PT_MSR	33
++#define PT_ORIG_R3 34
++#define PT_CTR	35
++#define PT_LNK	36
++#define PT_XER	37
++#define PT_CCR	38
++#ifndef __powerpc64__
++#define PT_MQ	39
++#else
++#define PT_SOFTE 39
++#endif
++#define PT_TRAP	40
++#define PT_DAR	41
++#define PT_DSISR 42
++#define PT_RESULT 43
++#define PT_DSCR 44
++#define PT_REGS_COUNT 44
++
++#define PT_FPR0	48	/* each FP reg occupies 2 slots in this space */
++
++#ifndef __powerpc64__
++
++#define PT_FPR31 (PT_FPR0 + 2*31)
++#define PT_FPSCR (PT_FPR0 + 2*32 + 1)
++
++#else /* __powerpc64__ */
++
++#define PT_FPSCR (PT_FPR0 + 32)	/* each FP reg occupies 1 slot in 64-bit space */
++
++
++#define PT_VR0 82	/* each Vector reg occupies 2 slots in 64-bit */
++#define PT_VSCR (PT_VR0 + 32*2 + 1)
++#define PT_VRSAVE (PT_VR0 + 33*2)
++
++
++/*
++ * Only store first 32 VSRs here. The second 32 VSRs in VR0-31
++ */
++#define PT_VSR0 150	/* each VSR reg occupies 2 slots in 64-bit */
++#define PT_VSR31 (PT_VSR0 + 2*31)
++#endif /* __powerpc64__ */
++
++#endif /* !__GLIBC__ */
++
+ typedef enum
+   {
+     UNW_PPC64_R0,
+--- a/src/ppc32/Ginit.c
++++ b/src/ppc32/Ginit.c
+@@ -46,10 +46,15 @@ static void *
+ uc_addr (ucontext_t *uc, int reg)
+ {
+   void *addr;
++#ifdef __GLIBC__
++  mcontext_t *mc = uc->uc_mcontext.uc_regs;
++#else
++  mcontext_t *mc = &uc->uc_mcontext;
++#endif
+ 
+   if ((unsigned) (reg - UNW_PPC32_R0) < 32)
+ #if defined(__linux__)
+-    addr = &uc->uc_mcontext.uc_regs->gregs[reg - UNW_PPC32_R0];
++    addr = &mc->gregs[reg - UNW_PPC32_R0];
+ #elif defined(__FreeBSD__)
+     addr = &uc->uc_mcontext.mc_gpr[reg - UNW_PPC32_R0];
+ #endif
+@@ -58,7 +63,7 @@ uc_addr (ucontext_t *uc, int reg)
+   if ( ((unsigned) (reg - UNW_PPC32_F0) < 32) &&
+        ((unsigned) (reg - UNW_PPC32_F0) >= 0) )
+ #if defined(__linux__)
+-    addr = &uc->uc_mcontext.uc_regs->fpregs.fpregs[reg - UNW_PPC32_F0];
++    addr = &mc->fpregs.fpregs[reg - UNW_PPC32_F0];
+  #elif defined(__FreeBSD__)
+     addr = &uc->uc_mcontext.mc_fpreg[reg - UNW_PPC32_F0];
+ #endif
+@@ -85,7 +90,7 @@ uc_addr (ucontext_t *uc, int reg)
+           return NULL;
+         }
+ #if defined(__linux__)
+-      addr = &uc->uc_mcontext.uc_regs->gregs[gregs_idx];
++      addr = &mc->gregs[gregs_idx];
+ #elif defined(__FreeBSD__)
+       addr = &uc->uc_mcontext.mc_gpr[gregs_idx];
+ #endif
+--- a/src/ppc32/ucontext_i.h
++++ b/src/ppc32/ucontext_i.h
+@@ -44,8 +44,13 @@ WITH THE SOFTWARE OR THE USE OR OTHER DE
+ //#define MQ_IDX                36
+ #define LINK_IDX        36
+ 
++#ifdef __GLIBC__
+ #define _UC_MCONTEXT_GPR(x) ( ((void *)&dmy_ctxt.uc_mcontext.uc_regs->gregs[x] - (void *)&dmy_ctxt) )
+ #define _UC_MCONTEXT_FPR(x) ( ((void *)&dmy_ctxt.uc_mcontext.uc_regs->fpregs.fpregs[x] - (void *)&dmy_ctxt) )
++#else
++#define _UC_MCONTEXT_GPR(x) ( ((void *)&dmy_ctxt.uc_mcontext.gregs[x] - (void *)&dmy_ctxt) )
++#define _UC_MCONTEXT_FPR(x) ( ((void *)&dmy_ctxt.uc_mcontext.fpregs.fpregs[x] - (void *)&dmy_ctxt) )
++#endif
+ 
+ /* These are dummy structures used only for obtaining the offsets of the
+    various structure members. */
diff --git a/package/libs/libunwind/patches/005-loongarch64-musl.pattch b/package/libs/libunwind/patches/005-loongarch64-musl.pattch
new file mode 100644
index 0000000..bb961bd
--- /dev/null
+++ b/package/libs/libunwind/patches/005-loongarch64-musl.pattch
@@ -0,0 +1,12 @@
+--- a/src/loongarch64/getcontext.S
++++ b/src/loongarch64/getcontext.S
+@@ -25,7 +25,9 @@ OF CONTRACT, TORT OR OTHERWISE, ARISING
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.  */
+ 
+ #include "offsets.h"
++#ifdef __GLIBC__
+ #include <endian.h>
++#endif
+ 	.text
+ 
+ #define SREG(X) st.d $r##X, $r4, (LINUX_UC_MCONTEXT_GREGS + 8 * X)
diff --git a/package/libs/libusb/Makefile b/package/libs/libusb/Makefile
new file mode 100644
index 0000000..6171c31
--- /dev/null
+++ b/package/libs/libusb/Makefile
@@ -0,0 +1,83 @@
+#
+# Copyright (C) 2010-2016 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:=libusb
+PKG_VERSION:=1.0.27
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=https://github.com/libusb/libusb/releases/download/v$(PKG_VERSION)
+PKG_HASH:=ffaa41d741a8a3bee244ac8e54a72ea05bf2879663c098c82fc5757853441575
+
+PKG_MAINTAINER:= Felix Fietkau <nbd@nbd.name>
+PKG_LICENSE:=LGPL-2.1-or-later
+PKG_LICENSE_FILES:=COPYING
+PKG_CPE_ID:=cpe:/a:libusb:libusb
+
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libusb-1.0
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=A library for accessing Linux USB devices
+  DEPENDS:=+libpthread +librt +libatomic
+  URL:=https://libusb.info/
+  ABI_VERSION:=0
+endef
+
+define Package/libusb-1.0/description
+  libusb is a C library that gives applications easy access to USB devices on
+  many different operating systems.
+endef
+
+define Package/fxload
+  SECTION:=utils
+  CATEGORY:=Utilities
+  TITLE:=fxload firmware loader
+  URL:=https://linux-hotplug.sourceforge.net
+  DEPENDS:=+libusb-1.0
+endef
+
+define Package/fxload/description
+This program is conveniently able to download firmware into FX, FX2,
+and FX2LP EZ-USB devices, as well as the original AnchorChips EZ-USB.
+It is intended to be invoked by hotplug scripts when the unprogrammed
+device appears on the bus.
+endef
+
+TARGET_CFLAGS += $(FPIC)
+CONFIGURE_ARGS += \
+	--enable-examples-build \
+	--disable-log \
+	--disable-udev
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include/libusb-1.0
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/libusb-1.0/libusb.h $(1)/usr/include/libusb-1.0/
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libusb-1.0.* $(1)/usr/lib/
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libusb-1.0.pc $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libusb-1.0/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libusb-1.0.so* $(1)/usr/lib/
+endef
+
+define Package/fxload/install
+	$(INSTALL_DIR) $(1)/usr/sbin
+	$(INSTALL_BIN) $(PKG_BUILD_DIR)/examples/.libs/fxload $(1)/usr/sbin
+endef
+
+$(eval $(call BuildPackage,libusb-1.0))
+$(eval $(call BuildPackage,fxload))
diff --git a/package/libs/libxml2/Makefile b/package/libs/libxml2/Makefile
new file mode 100644
index 0000000..c2a804b
--- /dev/null
+++ b/package/libs/libxml2/Makefile
@@ -0,0 +1,207 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=libxml2
+PKG_VERSION:=2.13.4
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
+PKG_SOURCE_URL:=@GNOME/libxml2/$(basename $(PKG_VERSION))
+PKG_HASH:=65d042e1c8010243e617efb02afda20b85c2160acdbfbcb5b26b80cec6515650
+
+PKG_LICENSE:=MIT
+PKG_LICENSE_FILES:=COPYING
+PKG_CPE_ID:=cpe:/a:xmlsoft:libxml2
+HOST_BUILD_DEPENDS := libiconv-full/host
+
+include $(INCLUDE_DIR)/host-build.mk
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+include $(INCLUDE_DIR)/nls.mk
+
+define Package/libxml2
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=Gnome XML library
+  URL:=http://xmlsoft.org/
+  DEPENDS:=+libpthread +zlib $(ICONV_DEPENDS)
+endef
+
+define Package/libxml2/description
+ A library for manipulating XML and HTML resources.
+endef
+
+define Package/libxml2-dev
+  SECTION:=devel
+  CATEGORY:=Development
+  SUBMENU:=Libraries
+  TITLE:=Development files for libxml2
+  URL:=http://xmlsoft.org/
+  DEPENDS:=+libxml2
+endef
+
+define Package/libxml2-dev/description
+  A library for manipulating XML and HTML resources.
+
+  This package contains the headers and xml2-config binary.
+endef
+
+define Package/libxml2-utils
+  SECTION:=utils
+  CATEGORY:=Utilities
+  TITLE:=XML command line utilities (xmllint...)
+  URL:=http://xmlsoft.org/
+  DEPENDS:=+libxml2
+endef
+
+define Package/libxml2-utils/description
+  This package contains the binaries xmllint and xmlcatalog
+  from libxml2, a library for manipulating XML and HTML resources.
+endef
+
+CMAKE_HOST_OPTIONS += \
+	-DBUILD_SHARED_LIBS=OFF \
+	-DLIBXML2_WITH_C14N=ON \
+	-DLIBXML2_WITH_CATALOG=OFF \
+	-DLIBXML2_WITH_DEBUG=ON \
+	-DLIBXML2_WITH_FTP=OFF \
+	-DLIBXML2_WITH_HTML=ON \
+	-DLIBXML2_WITH_HTTP=OFF \
+	-DLIBXML2_WITH_ICONV=ON \
+	-DLIBXML2_WITH_ICU=OFF \
+	-DLIBXML2_WITH_ISO8859X=OFF \
+	-DLIBXML2_WITH_LEGACY=OFF \
+	-DLIBXML2_WITH_LZMA=OFF \
+	-DLIBXML2_WITH_MEM_DEBUG=OFF \
+	-DLIBXML2_WITH_MODULES=OFF \
+	-DLIBXML2_WITH_OUTPUT=ON \
+	-DLIBXML2_WITH_PATTERN=ON \
+	-DLIBXML2_WITH_PROGRAMS=OFF \
+	-DLIBXML2_WITH_PUSH=ON \
+	-DLIBXML2_WITH_PYTHON=OFF \
+	-DLIBXML2_WITH_READER=ON \
+	-DLIBXML2_WITH_REGEXPS=ON \
+	-DLIBXML2_WITH_RUN_DEBUG=OFF \
+	-DLIBXML2_WITH_SAX1=ON \
+	-DLIBXML2_WITH_SCHEMAS=ON \
+	-DLIBXML2_WITH_SCHEMATRON=OFF \
+	-DLIBXML2_WITH_TESTS=OFF \
+	-DLIBXML2_WITH_THREADS=ON \
+	-DLIBXML2_WITH_THREAD_ALLOC=OFF \
+	-DLIBXML2_WITH_TREE=ON \
+	-DLIBXML2_WITH_VALID=ON \
+	-DLIBXML2_WITH_WRITER=ON \
+	-DLIBXML2_WITH_XINCLUDE=ON \
+	-DLIBXML2_WITH_XPATH=ON \
+	-DLIBXML2_WITH_XPTR=ON \
+	-DLIBXML2_WITH_XPTR_LOCS=ON \
+	-DLIBXML2_WITH_ZLIB=ON
+
+CMAKE_OPTIONS += \
+	-DBUILD_SHARED_LIBS=ON \
+	-DLIBXML2_WITH_C14N=ON \
+	-DLIBXML2_WITH_CATALOG=OFF \
+	-DLIBXML2_WITH_DEBUG=ON \
+	-DLIBXML2_WITH_FTP=OFF \
+	-DLIBXML2_WITH_HTML=ON \
+	-DLIBXML2_WITH_HTTP=OFF \
+	-DLIBXML2_WITH_ICONV=ON \
+	-DLIBXML2_WITH_ICU=OFF \
+	-DLIBXML2_WITH_ISO8859X=OFF \
+	-DLIBXML2_WITH_LEGACY=OFF \
+	-DLIBXML2_WITH_LZMA=OFF \
+	-DLIBXML2_WITH_MEM_DEBUG=OFF \
+	-DLIBXML2_WITH_MODULES=OFF \
+	-DLIBXML2_WITH_OUTPUT=ON \
+	-DLIBXML2_WITH_PATTERN=ON \
+	-DLIBXML2_WITH_PROGRAMS=ON \
+	-DLIBXML2_WITH_PUSH=ON \
+	-DLIBXML2_WITH_PYTHON=OFF \
+	-DLIBXML2_WITH_READER=ON \
+	-DLIBXML2_WITH_REGEXPS=ON \
+	-DLIBXML2_WITH_RUN_DEBUG=OFF \
+	-DLIBXML2_WITH_SAX1=ON \
+	-DLIBXML2_WITH_SCHEMAS=ON \
+	-DLIBXML2_WITH_SCHEMATRON=OFF \
+	-DLIBXML2_WITH_TESTS=OFF \
+	-DLIBXML2_WITH_THREADS=ON \
+	-DLIBXML2_WITH_THREAD_ALLOC=OFF \
+	-DLIBXML2_WITH_TREE=ON \
+	-DLIBXML2_WITH_VALID=ON \
+	-DLIBXML2_WITH_WRITER=ON \
+	-DLIBXML2_WITH_XINCLUDE=ON \
+	-DLIBXML2_WITH_XPATH=ON \
+	-DLIBXML2_WITH_XPTR=ON \
+	-DLIBXML2_WITH_XPTR_LOCS=ON \
+	-DLIBXML2_WITH_ZLIB=ON \
+	-DHAVE_LIBHISTORY=OFF \
+	-DHAVE_LIBREADLINE=OFF
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(2)/bin
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/xml2-config \
+		$(2)/bin/$(GNU_TARGET_NAME)-xml2-config
+	$(SED) 's,^\(prefix\|exec_prefix\)=.*,\1=$(STAGING_DIR)/usr,g' \
+		$(2)/bin/$(GNU_TARGET_NAME)-xml2-config
+	$(LN) $(GNU_TARGET_NAME)-xml2-config $(2)/bin/xml2-config
+
+	$(INSTALL_DIR) $(1)/usr/bin
+	$(CP) $(PKG_INSTALL_DIR)/usr/bin/xmlcatalog $(1)/usr/bin/
+	$(CP) $(PKG_INSTALL_DIR)/usr/bin/xmllint $(1)/usr/bin/
+
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/libxml2 $(1)/usr/include/
+
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libxml2.so* $(1)/usr/lib/
+
+	$(INSTALL_DIR) $(1)/usr/lib/cmake/libxml2
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/cmake/libxml2-$(PKG_VERSION)/*.cmake \
+		$(1)/usr/lib/cmake/libxml2
+
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libxml-2.0.pc $(1)/usr/lib/pkgconfig/
+
+	$(INSTALL_DIR) $(2)/share/aclocal/
+	$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/aclocal/* $(2)/share/aclocal
+endef
+
+define Host/Install
+	$(call Host/Install/Default)
+	mv $(1)/bin/xml2-config $(1)/bin/$(GNU_HOST_NAME)-xml2-config
+	$(LN) $(GNU_HOST_NAME)-xml2-config $(1)/bin/xml2-config
+endef
+
+define Package/libxml2/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libxml2.so.* $(1)/usr/lib/
+endef
+
+define Package/libxml2-dev/install
+	$(INSTALL_DIR) $(1)/usr/bin
+	$(CP) $(PKG_INSTALL_DIR)/usr/bin/xml2-config $(1)/usr/bin/
+	$(SED) "s,$(STAGING_DIR),,g" $(1)/usr/bin/xml2-config
+
+	$(INSTALL_DIR) $(1)/usr/include/
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
+
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libxml2.so $(1)/usr/lib/
+
+	$(INSTALL_DIR) $(1)/usr/lib/{cmake,pkgconfig}
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/{cmake,pkgconfig} $(1)/usr/lib/
+	$(SED) "s,$(STAGING_DIR),,g" $(1)/usr/lib/pkgconfig/*.pc
+
+	$(INSTALL_DIR) $(1)/usr/share/aclocal
+	$(CP) $(PKG_INSTALL_DIR)/usr/share/aclocal/* $(1)/usr/share/aclocal
+endef
+
+define Package/libxml2-utils/install
+	$(INSTALL_DIR) $(1)/usr/bin
+	$(CP) $(PKG_INSTALL_DIR)/usr/bin/xmllint $(1)/usr/bin/
+	$(CP) $(PKG_INSTALL_DIR)/usr/bin/xmlcatalog $(1)/usr/bin/
+endef
+
+$(eval $(call HostBuild))
+$(eval $(call BuildPackage,libxml2))
+$(eval $(call BuildPackage,libxml2-dev))
+$(eval $(call BuildPackage,libxml2-utils))
diff --git a/package/libs/mbedtls/Config.in b/package/libs/mbedtls/Config.in
new file mode 100644
index 0000000..0a760ed
--- /dev/null
+++ b/package/libs/mbedtls/Config.in
@@ -0,0 +1,230 @@
+if PACKAGE_libmbedtls
+
+comment "Option details in source code: include/mbedtls/mbedtls_config.h"
+
+comment "Ciphers - unselect old or less-used ciphers to reduce binary size"
+
+config MBEDTLS_AES_C
+	bool "MBEDTLS_AES_C"
+	default y
+
+config MBEDTLS_ARIA_C
+	bool "MBEDTLS_ARIA_C"
+	default n
+
+config MBEDTLS_CAMELLIA_C
+	bool "MBEDTLS_CAMELLIA_C"
+	default n
+
+config MBEDTLS_CCM_C
+	bool "MBEDTLS_CCM_C"
+	default n
+
+config MBEDTLS_CMAC_C
+	bool "MBEDTLS_CMAC_C (old but used by hostapd)"
+	default y
+
+config MBEDTLS_DES_C
+	bool "MBEDTLS_DES_C (old but used by hostapd)"
+	default y
+
+config MBEDTLS_GCM_C
+	bool "MBEDTLS_GCM_C"
+	default y
+
+config MBEDTLS_NIST_KW_C
+	bool "MBEDTLS_NIST_KW_C (old but used by hostapd)"
+	default y
+
+config MBEDTLS_RIPEMD160_C
+	bool "MBEDTLS_RIPEMD160_C"
+	default n
+
+config MBEDTLS_RSA_NO_CRT
+	bool "MBEDTLS_RSA_NO_CRT"
+	default y
+
+config MBEDTLS_KEY_EXCHANGE_PSK_ENABLED
+	bool "MBEDTLS_KEY_EXCHANGE_PSK_ENABLED"
+	default y
+
+config MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED
+	bool "MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED"
+	default n
+
+config MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED
+	bool "MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED"
+	default y
+
+config MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED
+	bool "MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED"
+	default n
+
+config MBEDTLS_KEY_EXCHANGE_RSA_ENABLED
+	bool "MBEDTLS_KEY_EXCHANGE_RSA_ENABLED"
+	default n
+
+config MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED
+	bool "MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED"
+	default n
+
+config MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED
+	bool "MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED"
+	default y
+
+config MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED
+	bool "MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED"
+	default y
+
+config MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED
+	bool "MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED"
+	default n
+
+config MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED
+	bool "MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED"
+	default n
+
+comment "Curves - unselect old or less-used curves to reduce binary size"
+
+config MBEDTLS_ECP_DP_SECP192R1_ENABLED
+	bool "MBEDTLS_ECP_DP_SECP192R1_ENABLED"
+	default n
+
+config MBEDTLS_ECP_DP_SECP224R1_ENABLED
+	bool "MBEDTLS_ECP_DP_SECP224R1_ENABLED"
+	default n
+
+config MBEDTLS_ECP_DP_SECP256R1_ENABLED
+	bool "MBEDTLS_ECP_DP_SECP256R1_ENABLED"
+	default y
+
+config MBEDTLS_ECP_DP_SECP384R1_ENABLED
+	bool "MBEDTLS_ECP_DP_SECP384R1_ENABLED"
+	default y
+
+config MBEDTLS_ECP_DP_SECP521R1_ENABLED
+	bool "MBEDTLS_ECP_DP_SECP521R1_ENABLED"
+	default y
+
+config MBEDTLS_ECP_DP_SECP192K1_ENABLED
+	bool "MBEDTLS_ECP_DP_SECP192K1_ENABLED"
+	default n
+
+config MBEDTLS_ECP_DP_SECP224K1_ENABLED
+	bool "MBEDTLS_ECP_DP_SECP224K1_ENABLED"
+	default n
+
+config MBEDTLS_ECP_DP_SECP256K1_ENABLED
+	bool "MBEDTLS_ECP_DP_SECP256K1_ENABLED"
+	default y
+
+config MBEDTLS_ECP_DP_BP256R1_ENABLED
+	bool "MBEDTLS_ECP_DP_BP256R1_ENABLED"
+	default n
+
+config MBEDTLS_ECP_DP_BP384R1_ENABLED
+	bool "MBEDTLS_ECP_DP_BP384R1_ENABLED"
+	default n
+
+config MBEDTLS_ECP_DP_BP512R1_ENABLED
+	bool "MBEDTLS_ECP_DP_BP512R1_ENABLED"
+	default n
+
+config MBEDTLS_ECP_DP_CURVE25519_ENABLED
+	bool "MBEDTLS_ECP_DP_CURVE25519_ENABLED"
+	default y
+
+config MBEDTLS_ECP_DP_CURVE448_ENABLED
+	bool "MBEDTLS_ECP_DP_CURVE448_ENABLED"
+	default n
+
+comment "Build Options - unselect features to reduce binary size"
+
+config MBEDTLS_CIPHER_MODE_OFB
+	bool "MBEDTLS_CIPHER_MODE_OFB"
+	default n
+
+config MBEDTLS_CIPHER_MODE_XTS
+	bool "MBEDTLS_CIPHER_MODE_XTS"
+	default n
+
+config MBEDTLS_DEBUG_C
+	bool "MBEDTLS_DEBUG_C"
+	default n
+
+config MBEDTLS_HKDF_C
+	bool "MBEDTLS_HKDF_C"
+	default n
+
+config MBEDTLS_PLATFORM_C
+	bool "MBEDTLS_PLATFORM_C"
+	default n
+
+config MBEDTLS_SELF_TEST
+	bool "MBEDTLS_SELF_TEST"
+	default n
+
+config MBEDTLS_THREADING_C
+	bool "MBEDTLS_THREADING_C"
+	default y
+
+config MBEDTLS_THREADING_PTHREAD
+	def_bool MBEDTLS_THREADING_C
+
+config MBEDTLS_VERSION_C
+	bool "MBEDTLS_VERSION_C"
+	default n
+
+config MBEDTLS_VERSION_FEATURES
+	bool "MBEDTLS_VERSION_FEATURES"
+	default n
+
+config MBEDTLS_PSA_CRYPTO_CLIENT
+	bool "MBEDTLS_PSA_CRYPTO_CLIENT"
+
+config MBEDTLS_DEPRECATED_WARNING
+	bool "MBEDTLS_DEPRECATED_WARNING"
+	default n
+
+config MBEDTLS_SSL_PROTO_TLS1_2
+	bool "MBEDTLS_SSL_PROTO_TLS1_2"
+	default y
+
+config MBEDTLS_SSL_PROTO_TLS1_3
+	bool "MBEDTLS_SSL_PROTO_TLS1_3"
+	select MBEDTLS_PSA_CRYPTO_CLIENT
+	select MBEDTLS_HKDF_C
+	default y
+
+config MBEDTLS_SSL_TLS1_3_COMPATIBILITY_MODE
+	bool "MBEDTLS_SSL_TLS1_3_COMPATIBILITY_MODE"
+	depends on MBEDTLS_SSL_PROTO_TLS1_3
+	default y
+
+config MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED
+	bool "MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED"
+	depends on MBEDTLS_SSL_PROTO_TLS1_3
+	default y
+
+config MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED
+	bool "MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED"
+	depends on MBEDTLS_SSL_PROTO_TLS1_3
+	default y
+
+config MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED
+	bool "MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED"
+	depends on MBEDTLS_SSL_PROTO_TLS1_3
+	default y
+
+comment "Build Options"
+
+config MBEDTLS_ENTROPY_FORCE_SHA256
+	bool "MBEDTLS_ENTROPY_FORCE_SHA256"
+	default y
+
+config MBEDTLS_SSL_RENEGOTIATION
+	bool "MBEDTLS_SSL_RENEGOTIATION"
+	depends on MBEDTLS_SSL_PROTO_TLS1_2
+	default n
+
+endif
diff --git a/package/libs/mbedtls/Makefile b/package/libs/mbedtls/Makefile
new file mode 100644
index 0000000..f5bff13
--- /dev/null
+++ b/package/libs/mbedtls/Makefile
@@ -0,0 +1,180 @@
+#
+# Copyright (C) 2011-2015 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:=mbedtls
+PKG_VERSION:=3.6.2
+PKG_RELEASE:=1
+PKG_BUILD_FLAGS:=no-mips16 gc-sections no-lto
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL=https://github.com/Mbed-TLS/$(PKG_NAME)/releases/download/$(PKG_NAME)-$(PKG_VERSION)
+PKG_HASH:=8b54fb9bcf4d5a7078028e0520acddefb7900b3e66fec7f7175bb5b7d85ccdca
+
+PKG_LICENSE:=GPL-2.0-or-later
+PKG_LICENSE_FILES:=LICENSE
+PKG_CPE_ID:=cpe:/a:arm:mbed_tls
+
+MBEDTLS_BUILD_OPTS_CURVES= \
+  CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED \
+  CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED \
+  CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED \
+  CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED \
+  CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED \
+  CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED \
+  CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED \
+  CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED \
+  CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED \
+  CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED \
+  CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED \
+  CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED \
+  CONFIG_MBEDTLS_ECP_DP_CURVE448_ENABLED
+
+MBEDTLS_BUILD_OPTS_CIPHERS= \
+  CONFIG_MBEDTLS_AES_C \
+  CONFIG_MBEDTLS_ARIA_C \
+  CONFIG_MBEDTLS_CAMELLIA_C \
+  CONFIG_MBEDTLS_CCM_C \
+  CONFIG_MBEDTLS_CMAC_C \
+  CONFIG_MBEDTLS_DES_C \
+  CONFIG_MBEDTLS_GCM_C \
+  CONFIG_MBEDTLS_KEY_EXCHANGE_PSK_ENABLED \
+  CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_PSK_ENABLED \
+  CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_PSK_ENABLED \
+  CONFIG_MBEDTLS_KEY_EXCHANGE_RSA_PSK_ENABLED \
+  CONFIG_MBEDTLS_KEY_EXCHANGE_RSA_ENABLED \
+  CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED \
+  CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED \
+  CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED \
+  CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED \
+  CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED \
+  CONFIG_MBEDTLS_NIST_KW_C \
+  CONFIG_MBEDTLS_RIPEMD160_C \
+  CONFIG_MBEDTLS_RSA_NO_CRT \
+  CONFIG_MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_ENABLED \
+  CONFIG_MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_EPHEMERAL_ENABLED \
+  CONFIG_MBEDTLS_SSL_TLS1_3_KEY_EXCHANGE_MODE_PSK_EPHEMERAL_ENABLED
+
+MBEDTLS_BUILD_OPTS= \
+  $(MBEDTLS_BUILD_OPTS_CURVES) \
+  $(MBEDTLS_BUILD_OPTS_CIPHERS) \
+  CONFIG_MBEDTLS_CIPHER_MODE_OFB \
+  CONFIG_MBEDTLS_CIPHER_MODE_XTS \
+  CONFIG_MBEDTLS_DEBUG_C \
+  CONFIG_MBEDTLS_ENTROPY_FORCE_SHA256 \
+  CONFIG_MBEDTLS_HKDF_C \
+  CONFIG_MBEDTLS_PLATFORM_C \
+  CONFIG_MBEDTLS_SELF_TEST \
+  CONFIG_MBEDTLS_SSL_RENEGOTIATION \
+  CONFIG_MBEDTLS_THREADING_C \
+  CONFIG_MBEDTLS_THREADING_PTHREAD \
+  CONFIG_MBEDTLS_VERSION_C \
+  CONFIG_MBEDTLS_VERSION_FEATURES \
+  CONFIG_MBEDTLS_PSA_CRYPTO_CLIENT \
+  CONFIG_MBEDTLS_DEPRECATED_WARNING \
+  CONFIG_MBEDTLS_SSL_PROTO_TLS1_2 \
+  CONFIG_MBEDTLS_SSL_PROTO_TLS1_3 \
+  CONFIG_MBEDTLS_SSL_TLS1_3_COMPATIBILITY_MODE
+
+PKG_CONFIG_DEPENDS := $(MBEDTLS_BUILD_OPTS)
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/mbedtls/Default
+  TITLE:=Embedded SSL
+  URL:=https://www.trustedfirmware.org/projects/mbed-tls/
+endef
+
+define Package/mbedtls/Default/description
+The aim of the mbedtls project is to provide a quality, open-source
+cryptographic library written in C and targeted at embedded systems.
+endef
+
+define Package/libmbedtls
+$(call Package/mbedtls/Default)
+  SECTION:=libs
+  CATEGORY:=Libraries
+  SUBMENU:=SSL
+  TITLE+= (library)
+  ABI_VERSION:=21
+  MENU:=1
+endef
+
+define Package/libmbedtls/config
+	source "$(SOURCE)/Config.in"
+endef
+
+define Package/mbedtls-util
+$(call Package/mbedtls/Default)
+  SECTION:=utils
+  CATEGORY:=Utilities
+  TITLE+= (utilities)
+  DEPENDS:=+libmbedtls
+endef
+
+define Package/libmbedtls/description
+$(call Package/mbedtls/Default/description)
+This package contains the mbedtls library.
+endef
+
+define Package/mbedtls-util/description
+$(call Package/mbedtls/Default/description)
+This package contains mbedtls helper programs for private key and
+CSR generation (gen_key, cert_req)
+endef
+
+TARGET_CFLAGS := $(filter-out -O%,$(TARGET_CFLAGS))
+
+CMAKE_OPTIONS += \
+	-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
+	-DUSE_SHARED_MBEDTLS_LIBRARY:Bool=ON \
+	-DENABLE_TESTING:Bool=OFF \
+	-DENABLE_PROGRAMS:Bool=ON
+
+define Build/Prepare
+       $(call Build/Prepare/Default)
+
+       $(if $(strip $(foreach opt,$(MBEDTLS_BUILD_OPTS),$($(opt)))),
+	 $(foreach opt,$(MBEDTLS_BUILD_OPTS),
+	 $(PKG_BUILD_DIR)/scripts/config.py \
+	 -f $(PKG_BUILD_DIR)/include/mbedtls/mbedtls_config.h \
+	 $(if $($(opt)),set,unset) $(patsubst CONFIG_%,%,$(opt))),)
+endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) \
+		$(PKG_INSTALL_DIR)/usr/include/mbedtls \
+		$(PKG_INSTALL_DIR)/usr/include/psa \
+		$(1)/usr/include/
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.so* $(1)/usr/lib/
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.a $(1)/usr/lib/
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/cmake $(1)/usr/lib/
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(CP) \
+		$(PKG_INSTALL_DIR)/usr/lib/pkgconfig/mbedcrypto.pc \
+		$(PKG_INSTALL_DIR)/usr/lib/pkgconfig/mbedtls.pc \
+		$(PKG_INSTALL_DIR)/usr/lib/pkgconfig/mbedx509.pc \
+		$(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libmbedtls/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/lib*.so.* $(1)/usr/lib/
+endef
+
+define Package/mbedtls-util/install
+	$(INSTALL_DIR) $(1)/usr/bin
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/gen_key $(1)/usr/bin/
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/cert_req $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,libmbedtls))
+$(eval $(call BuildPackage,mbedtls-util))
diff --git a/package/libs/mbedtls/patches/100-fix-gcc14-build.patch b/package/libs/mbedtls/patches/100-fix-gcc14-build.patch
new file mode 100644
index 0000000..656e605
--- /dev/null
+++ b/package/libs/mbedtls/patches/100-fix-gcc14-build.patch
@@ -0,0 +1,11 @@
+--- a/library/common.h
++++ b/library/common.h
+@@ -199,7 +199,7 @@ static inline void mbedtls_xor(unsigned
+         uint8x16_t x = veorq_u8(v1, v2);
+         vst1q_u8(r + i, x);
+     }
+-#if defined(__IAR_SYSTEMS_ICC__)
++#if defined(__IAR_SYSTEMS_ICC__) || (defined(MBEDTLS_COMPILER_IS_GCC) && MBEDTLS_GCC_VERSION >= 140100)
+     /* This if statement helps some compilers (e.g., IAR) optimise out the byte-by-byte tail case
+      * where n is a constant multiple of 16.
+      * For other compilers (e.g. recent gcc and clang) it makes no difference if n is a compile-time
diff --git a/package/libs/mbedtls/patches/101-remove-test.patch b/package/libs/mbedtls/patches/101-remove-test.patch
new file mode 100644
index 0000000..5ac5e7c
--- /dev/null
+++ b/package/libs/mbedtls/patches/101-remove-test.patch
@@ -0,0 +1,16 @@
+--- a/programs/CMakeLists.txt
++++ b/programs/CMakeLists.txt
+@@ -1,13 +1,9 @@
+ add_subdirectory(aes)
+ add_subdirectory(cipher)
+-if (NOT WIN32)
+-    add_subdirectory(fuzz)
+-endif()
+ add_subdirectory(hash)
+ add_subdirectory(pkey)
+ add_subdirectory(psa)
+ add_subdirectory(random)
+ add_subdirectory(ssl)
+-add_subdirectory(test)
+ add_subdirectory(util)
+ add_subdirectory(x509)
diff --git a/package/libs/mpfr/Makefile b/package/libs/mpfr/Makefile
new file mode 100644
index 0000000..39d6a03
--- /dev/null
+++ b/package/libs/mpfr/Makefile
@@ -0,0 +1,64 @@
+#
+# Copyright (C) 2023 Jeffery To
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=mpfr
+PKG_VERSION:=4.2.1
+PKG_RELEASE:=1
+
+PKG_SOURCE_URL:=@GNU/mpfr http://www.mpfr.org/mpfr-$(PKG_VERSION)
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
+PKG_HASH:=277807353a6726978996945af13e52829e3abd7a9a5b7fb2793894e18f1fcbb2
+
+PKG_LICENSE:=LGPL-3.0-or-later
+PKG_LICENSE_FILES:=COPYING.LESSER
+PKG_MAINTAINER:=Jeffery To <jeffery.to@gmail.com>
+PKG_CPE_ID:=cpe:/a:mpfr:gnu_mpfr
+
+PKG_BUILD_PARALLEL:=1
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libmpfr
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=GNU MPFR library
+  URL:=https://www.mpfr.org/
+  DEPENDS:=+libgmp
+  ABI_VERSION:=6
+endef
+
+define Package/libmpfr/description
+MPFR is a portable library written in C for arbitrary precision
+arithmetic on floating-point numbers. It is based on the GNU MP library.
+It aims to provide a class of floating-point numbers with precise
+semantics.
+endef
+
+CONFIGURE_ARGS += \
+	--enable-thread-safe
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/mpf* $(1)/usr/include/
+
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libmpfr.{a,so*} $(1)/usr/lib/
+
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/mpfr.pc $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libmpfr/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libmpfr.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libmpfr))
diff --git a/package/libs/mpfr/patches/001-only-src.patch b/package/libs/mpfr/patches/001-only-src.patch
new file mode 100644
index 0000000..bd9e38a
--- /dev/null
+++ b/package/libs/mpfr/patches/001-only-src.patch
@@ -0,0 +1,22 @@
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -38,7 +38,7 @@ AUTOMAKE_OPTIONS = gnu
+ # old Automake version.
+ ACLOCAL_AMFLAGS = -I m4
+ 
+-SUBDIRS = doc src tests tune tools/bench
++SUBDIRS = src
+ 
+ pkgconfigdir = $(libdir)/pkgconfig
+ pkgconfig_DATA = mpfr.pc
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -401,7 +401,7 @@ AUTOMAKE_OPTIONS = gnu
+ # libtoolize and in case some developer needs to switch back to an
+ # old Automake version.
+ ACLOCAL_AMFLAGS = -I m4
+-SUBDIRS = doc src tests tune tools/bench
++SUBDIRS = src
+ pkgconfigdir = $(libdir)/pkgconfig
+ pkgconfig_DATA = mpfr.pc
+ nobase_dist_doc_DATA = AUTHORS BUGS COPYING COPYING.LESSER NEWS TODO \
diff --git a/package/libs/musl-fts/Makefile b/package/libs/musl-fts/Makefile
new file mode 100644
index 0000000..72341cd
--- /dev/null
+++ b/package/libs/musl-fts/Makefile
@@ -0,0 +1,63 @@
+#
+# Copyright (C) 2017 Lucian Cristian <lucian.cristian@gmail.com>
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+# updated to work with latest source from abrasive
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=musl-fts
+PKG_VERSION:=1.2.7
+PKG_RELEASE:=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=https://github.com/pullmoll/musl-fts.git
+PKG_SOURCE_VERSION:=0bde52df588e8969879a2cae51c3a4774ec62472
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
+PKG_MIRROR_HASH:=29c62a600128e9189b1b2e1aea568546178eedf739527f657873b3b773072ecb
+
+PKG_MAINTAINER:=Lucian Cristian <lucian.cristian@gmail.com>
+
+PKG_LICENSE:=LGPL-2.1
+PKG_LICENSE_FILES:=COPYING AUTHORS
+
+PKG_FIXUP:=autoreconf
+PKG_REMOVE_FILES:=autogen.sh
+
+PKG_BUILD_PARALLEL:=1
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+
+define Package/musl-fts
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=fts implementation for musl libc
+  URL:=https://github.com/pullmoll/musl-fts
+  DEPENDS:= +libpthread
+endef
+
+define Package/musl-fts/description
+  The musl-fts package implements the fts(3) functions fts_open, fts_read, fts_children, fts_set and fts_close, which are missing in musl libc.
+endef
+
+HOST_CONFIGURE_ARGS += --disable-shared --with-pic
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/fts.h $(1)/usr/include/
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libfts.so* $(1)/usr/lib/
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/musl-fts.pc $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/musl-fts/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libfts.so* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,musl-fts))
+$(eval $(call HostBuild))
diff --git a/package/libs/ncurses/Makefile b/package/libs/ncurses/Makefile
new file mode 100644
index 0000000..0fcc388
--- /dev/null
+++ b/package/libs/ncurses/Makefile
@@ -0,0 +1,196 @@
+#
+# Copyright (C) 2006-2015 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:=ncurses
+PKG_CPE_ID:=cpe:/a:gnu:ncurses
+PKG_VERSION:=6.4
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@GNU/$(PKG_NAME)
+PKG_HASH:=6931283d9ac87c5073f30b6290c4c75f21632bb4fc3603ac8100812bed248159
+
+PKG_LICENSE:=MIT
+PKG_LICENSE_FILES:=README
+
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+PKG_BUILD_DEPENDS:=ncurses/host
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+
+define Package/terminfo
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=Terminal Info Database (ncurses)
+  URL:=http://www.gnu.org/software/ncurses/
+endef
+
+define Package/libncurses
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=Terminal handling library (Unicode)
+  URL:=http://www.gnu.org/software/ncurses/
+  PROVIDES:=libncursesw
+  DEPENDS:= +terminfo
+  ABI_VERSION:=6
+endef
+
+define Package/libncurses-dev
+  SECTION:=devel
+  CATEGORY:=Development
+  SUBMENU:=Libraries
+  DEPENDS:=zlib
+  TITLE:=Development files for the ncurses library
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+CONFIGURE_ARGS += \
+	--enable-echo \
+	--enable-const \
+	--enable-overwrite \
+	--enable-pc-files \
+	--disable-rpath \
+	--without-ada \
+	--without-debug \
+	--without-manpages \
+	--without-profile \
+	--without-progs \
+	--without-tests \
+	--disable-big-core \
+	--disable-home-terminfo \
+	--with-normal \
+	--with-shared \
+	--with-terminfo-dirs=/usr/share/terminfo \
+	--with-default-terminfo-dir=/usr/share/terminfo \
+	--with-pkg-config-libdir=/usr/lib/pkgconfig \
+	--enable-widec \
+	--with-build-cppflags=-D_GNU_SOURCE
+
+CONFIGURE_VARS += \
+	cf_try_fPIC=no
+
+HOST_CFLAGS += $(HOST_FPIC)
+
+HOST_CONFIGURE_ARGS += \
+	--enable-pc-files \
+	--without-cxx \
+	--without-cxx-binding \
+	--without-ada \
+	--without-debug \
+	--without-manpages \
+	--without-profile \
+	--without-tests \
+	--without-curses-h
+
+
+ifeq ($(HOST_OS),FreeBSD)
+	CONFIGURE_ARGS +=
+		--with-terminfo=/usr/share/terminfo.db 
+endif
+
+MAKE_FLAGS += \
+	BUILD_CC="$(HOSTCC)" \
+	HOSTCC="$(HOSTCC)" \
+	HOSTCCFLAGS="" \
+	PKG_CONFIG_LIBDIR=/usr/lib/pkgconfig \
+	libs
+
+define Build/Install/Default
+	$(MAKE_VARS) \
+	$(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
+		$(MAKE_INSTALL_FLAGS) \
+		$(1) install.libs install.data;
+endef
+
+define Package/terminfo/install
+	echo ""
+ifneq ($(HOST_OS),FreeBSD)
+	$(INSTALL_DIR) $(1)/usr/share/terminfo
+	(cd $(PKG_INSTALL_DIR)/usr/share/terminfo; \
+		for dir in ??; do \
+			[ -d "$$$$dir" ] || continue; \
+			mv $$$$dir $$$$(echo -ne "\x$$$$dir"); \
+		done \
+	)
+	for file in \
+		a/ansi \
+		a/alacritty \
+		d/dumb \
+		f/foot \
+		l/linux \
+		r/rxvt \
+		r/rxvt-unicode \
+		s/screen \
+		s/screen-256color \
+		t/tmux \
+		t/tmux-256color \
+		v/vt100 \
+		v/vt102 \
+		x/xterm \
+		x/xterm-color \
+		x/xterm-256color; do \
+		$(INSTALL_DIR) $(1)/usr/share/terminfo/`dirname $$$$file`; \
+		$(CP) $(PKG_INSTALL_DIR)/usr/share/terminfo/$$$$file \
+			$(1)/usr/share/terminfo/$$$$file; \
+	done
+endif
+endef
+
+define Package/libncurses/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	for lib in ncurses panel menu form; do \
+		$(CP) $(PKG_INSTALL_DIR)/usr/lib/lib$$$${lib}w.so.* $(1)/usr/lib/; \
+		for so in $(1)/usr/lib/lib$$$${lib}w.so.*; do \
+			ln -s $$$${so##*/} $$$${so%w.so*}.so$$$${so##*w.so}; \
+		done; \
+	done
+endef
+
+define Package/libncurses-dev/install
+	$(INSTALL_DIR) $(1)/usr/bin
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin/
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/*.h $(1)/usr/include/
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/*.a $(1)/usr/lib/
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/*.pc $(1)/usr/lib/pkgconfig/
+endef
+
+define Build/InstallDev
+	$(CP) $(PKG_INSTALL_DIR)/* $(1)
+	for lib in ncurses panel menu form; do \
+		for so in $(1)/usr/lib/lib$$$${lib}w.so*; do \
+			ln -s $$$${so##*/} $$$${so%w.so*}.so$$$${so##*w.so}; \
+		done; \
+	done
+	ln -s . $(1)/usr/include/ncursesw
+	$(TARGET_CROSS)ar rc $(1)/usr/lib/libtinfo.a
+	$(INSTALL_DIR) $(2)/bin
+	$(CP) $(PKG_INSTALL_DIR)/usr/bin/ncursesw6-config $(2)/bin/
+	$(SED) 's,^\(prefix\|exec_prefix\)=.*,\1=$(STAGING_DIR)/usr,g' -e 's/$$$$INCS //g' \
+		$(2)/bin/ncursesw6-config
+	ln -sf $(STAGING_DIR)/host/bin/ncursesw6-config $(1)/usr/bin/ncursesw6-config
+	$(SED) 's,$(TOOLCHAIN_DIR),$(STAGING_DIR),g' \
+		$(1)/usr/lib/pkgconfig/ncursesw.pc
+endef
+
+define Host/Compile
+	$(MAKE) -C $(HOST_BUILD_DIR) libs
+	$(MAKE) -C $(HOST_BUILD_DIR)/progs tic
+endef
+
+$(eval $(call HostBuild))
+$(eval $(call BuildPackage,terminfo))
+$(eval $(call BuildPackage,libncurses))
+$(eval $(call BuildPackage,libncurses-dev))
diff --git a/package/libs/ncurses/patches/100-ncurses-5.6-20080112-urxvt.patch b/package/libs/ncurses/patches/100-ncurses-5.6-20080112-urxvt.patch
new file mode 100644
index 0000000..70d64bd
--- /dev/null
+++ b/package/libs/ncurses/patches/100-ncurses-5.6-20080112-urxvt.patch
@@ -0,0 +1,175 @@
+--- a/misc/terminfo.src
++++ b/misc/terminfo.src
+@@ -6886,6 +6886,172 @@ rxvt-cygwin-native|rxvt terminal emulato
+ rxvt-16color|rxvt with 16 colors like aixterm,
+ 	ncv#32, use=ibm+16color, use=rxvt,
+ 
++# rxvt-unicode
++# http://cvs.schmorp.de/rxvt-unicode/doc/etc/rxvt-unicode.terminfo?revision=1.20
++# From: Thomas Dickey <dickey@clark.net> 04 Oct 1997
++# Updated: Özgür Kesim <kesim@math.fu-berlin.de> 02 Nov 1997
++# Updated: Marc Lehmann <pcg@goof.com>, 17 Feb 2005
++rxvt-unicode|rxvt-unicode terminal (X Window System),
++	am,
++	bce,
++	eo,
++	km,
++	msgr,
++	xenl,
++	hs,
++	cols#80,
++	it#8,
++	lines#24,
++	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~-A.B+C\,D0EhFiG,
++	bel=^G,
++	blink=\E[5m,
++	bold=\E[1m,
++	civis=\E[?25l,
++	clear=\E[H\E[2J,
++	cnorm=\E[?25h,
++	cr=^M,
++	csr=\E[%i%p1%d;%p2%dr,
++	cub=\E[%p1%dD,
++	cub1=^H,
++	cud=\E[%p1%dB,
++	cud1=^J,
++	cuf=\E[%p1%dC,
++	cuf1=\E[C,
++	cup=\E[%i%p1%d;%p2%dH,
++	cuu=\E[%p1%dA,
++	cuu1=\E[A,
++	cvvis=\E[?25h,
++	dch=\E[%p1%dP,
++	dch1=\E[P,
++	dl=\E[%p1%dM,
++	dl1=\E[M,
++	ed=\E[J,
++	el=\E[K,
++	el1=\E[1K,
++	flash=\E[?5h$<20/>\E[?5l,
++	home=\E[H,
++	hpa=\E[%i%p1%dG,
++	ht=^I,
++	hts=\EH,
++	ich=\E[%p1%d@,
++	ich1=\E[@,
++	il=\E[%p1%dL,
++	il1=\E[L,
++	ind=^J,
++	is1=\E[?47l\E=\E[?1l,
++	is2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l,
++	kDC=\E[3$,
++	kIC=\E2$,
++	kEND=\E[8$,
++	kHOM=\E[7$,
++	kLFT=\E[d,
++	kNXT=\E[6$,
++	kPRV=\E[5$,
++	kRIT=\E[c,
++	kbs=\177,
++	ka1=\EOw,
++	ka3=\EOy,
++	kb2=\EOu,
++	kc1=\EOq,
++	kc3=\EOs,
++	kcbt=\E[Z,
++	kcub1=\E[D,
++	kcud1=\E[B,
++	kcuf1=\E[C,
++	kcuu1=\E[A,
++	kdch1=\E[3~,
++	kel=\E[8\^,
++	kend=\E[8~,
++	kent=\EOM,
++	kf1=\E[11~,
++	kf10=\E[21~,
++	kf11=\E[23~,
++	kf12=\E[24~,
++	kf13=\E[25~,
++	kf14=\E[26~,
++	kf15=\E[28~,
++	kf16=\E[29~,
++	kf17=\E[31~,
++	kf18=\E[32~,
++	kf19=\E[33~,
++	kf2=\E[12~,
++	kf20=\E[34~,
++	kf3=\E[13~,
++	kf4=\E[14~,
++	kf5=\E[15~,
++	kf6=\E[17~,
++	kf7=\E[18~,
++	kf8=\E[19~,
++	kf9=\E[20~,
++	kfnd=\E[1~,
++	khome=\E[7~,
++	kich1=\E[2~,
++	kmous=\E[M,
++	knp=\E[6~,
++	kpp=\E[5~,
++	kslt=\E[4~,
++	rc=\E8,
++	rev=\E[7m,
++	ri=\EM,
++	rmso=\E[27m,
++	rmul=\E[24m,
++	rs1=\Ec,
++	rs2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l\E>,
++	sgr0=\E[m\017,
++	enacs=,
++	smacs=\E(0,
++	rmacs=\E(B,
++	smso=\E[7m,
++	smul=\E[4m,
++	tbc=\E[3g,
++	vpa=\E[%i%p1%dd,
++	colors#88,
++	pairs#256,
++	btns#5,
++	lm#0,
++	ccc,
++	npc,
++	mc5i,
++	ncv#0,
++	mir,
++	xon,
++	bw,
++	ech=\E[%p1%dX,
++	mc0=\E[i,
++	mc4=\E[4i,
++	mc5=\E[5i,
++	sitm=\E[3m,
++	ritm=\E[23m,
++	smam=\E[?7h,
++	rmam=\E[?7l,
++	smir=\E[4h,
++	rmir=\E[4l,
++	smcup=\E[?1049h,
++	rmcup=\E[r\E[?1049l,
++	smkx=\E=,
++	rmkx=\E>,
++	indn=\E[%p1%dS,
++	rin=\E[%p1%dT,
++	sgr=\E[0%?%p6%t;1%;%?%p2%t;4%;%?%p1%p3%|%t;7%;%?%p4%t;5%;%?%p7%t;8%;m%?%p9%t\E(0%e\E(B%;,
++	op=\E[39;49m,
++	setaf=\E[38;5;%p1%dm,
++	setab=\E[48;5;%p1%dm,
++	setf=%?%p1%{7}%>%t\E[38;5;%p1%dm%e\E[3%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m%;,
++	setb=%?%p1%{7}%>%t\E[48;5;%p1%dm%e\E[4%?%p1%{1}%=%t4%e%p1%{3}%=%t6%e%p1%{4}%=%t1%e%p1%{6}%=%t3%e%p1%d%;m%;,
++	initc=\E]4;%p1%d;rgb\:%p2%{65535}%*%{1000}%/%4.4X/%p3%{65535}%*%{1000}%/%4.4X/%p4%{65535}%*%{1000}%/%4.4X\E\\,
++	sc=\E7,
++	s0ds=\E(B,
++	s1ds=\E(0,
++	s2ds=\E*B,
++	s3ds=\E+B,
++	u6=\E[%i%d;%dR,
++	u7=\E[6n,
++	u8=\E[?1;2c,
++	u9=\E[c,
++	tsl=\E]2;,
++	fsl=\007,
++	dsl=\E]2;\007,
++
+ #### MRXVT
+ # mrxvt 0.5.4
+ #
diff --git a/package/libs/ncurses/patches/101-ncurses-5.6-20080628-kbs.patch b/package/libs/ncurses/patches/101-ncurses-5.6-20080628-kbs.patch
new file mode 100644
index 0000000..9f00350
--- /dev/null
+++ b/package/libs/ncurses/patches/101-ncurses-5.6-20080628-kbs.patch
@@ -0,0 +1,52 @@
+--- a/misc/terminfo.src
++++ b/misc/terminfo.src
+@@ -4984,6 +4984,7 @@ xterm-xfree86|xterm terminal emulator (X
+ 
+ xterm+nofkeys|building block for xterm fkey-variants,
+ 	npc,
++	kbs=\177,
+ 	kcbt=\E[Z, kent=\EOM, nel=\EE, use=ecma+index,
+ 	use=ansi+rep, use=ecma+strikeout, use=vt420+lrmm,
+ 	use=xterm+sm+1006, use=xterm+tmux, use=ecma+italics,
+@@ -6689,6 +6690,7 @@ mlterm-256color|mlterm 3.0 with xterm 25
+ rxvt-basic|rxvt terminal base (X Window System),
+ 	OTbs, am, bce, eo, mir, msgr, xenl, xon, XT,
+ 	cols#80, it#8, lines#24,
++	kbs=\177,
+ 	acsc=``aaffggjjkkllmmnnooppqqrrssttuuvvwwxxyyzz{{||}}~~,
+ 	bel=^G, blink=\E[5m, bold=\E[1m, clear=\E[H\E[2J, cr=\r,
+ 	csr=\E[%i%p1%d;%p2%dr, cub=\E[%p1%dD, cub1=^H,
+@@ -6698,7 +6700,7 @@ rxvt-basic|rxvt terminal base (X Window
+ 	enacs=\E(B\E)0, flash=\E[?5h$<100/>\E[?5l, home=\E[H,
+ 	ht=^I, hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L,
+ 	ind=\n, is1=\E[?47l\E=\E[?1l,
+-	is2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l, kbs=^H,
++	is2=\E[r\E[m\E[2J\E[H\E[?7h\E[?1;3;4;6l\E[4l,
+ 	kcbt=\E[Z, kmous=\E[M, rc=\E8, rev=\E[7m, ri=\EM, rmacs=^O,
+ 	rmir=\E[4l, rmkx=\E>, rmso=\E[27m, rmul=\E[24m,
+ 	rs1=\E>\E[1;3;4;5;6l\E[?7h\E[m\E[r\E[2J\E[H,
+@@ -8347,6 +8349,7 @@ dumb-emacs-ansi|Emacs dumb terminal with
+ screen-base|VT 100/ANSI X3.64 virtual terminal (base),
+ 	OTbs, OTpt, am, km, mir, msgr, xenl, G0,
+ 	colors#8, cols#80, it#8, lines#24, ncv@, pairs#64, U8#1,
++	kbs=\177,
+ 	acsc=++\,\,--..00``aaffgghhiijjkkllmmnnooppqqrrssttuuvvwwxxy
+ 	     yzz{{||}}~~,
+ 	bel=^G, blink=\E[5m, bold=\E[1m, cbt=\E[Z, civis=\E[?25l,
+@@ -8358,7 +8361,7 @@ screen-base|VT 100/ANSI X3.64 virtual te
+ 	dl=\E[%p1%dM, dl1=\E[M, ed=\E[J, el=\E[K, el1=\E[1K,
+ 	enacs=\E(B\E)0, flash=\Eg, home=\E[H, hpa=\E[%i%p1%dG,
+ 	ht=^I, hts=\EH, ich=\E[%p1%d@, il=\E[%p1%dL, il1=\E[L,
+-	ind=\n, indn=\E[%p1%dS, is2=\E)0, kbs=^H, kcbt=\E[Z,
++	ind=\n, indn=\E[%p1%dS, is2=\E)0, kcbt=\E[Z,
+ 	kcub1=\EOD, kcud1=\EOB, kcuf1=\EOC, kcuu1=\EOA, kf1=\EOP,
+ 	kf10=\E[21~, kf11=\E[23~, kf12=\E[24~, kf2=\EOQ, kf3=\EOR,
+ 	kf4=\EOS, kf5=\E[15~, kf6=\E[17~, kf7=\E[18~, kf8=\E[19~,
+@@ -8500,6 +8503,7 @@ screen.xterm-r6|screen customized for X1
+ # on Solaris because Sun's curses implementation gets confused.
+ screen.teraterm|disable ncv in teraterm,
+ 	ncv#127,
++	kbs=^H,
+ 	acsc=+\020\,\021-\030.^Y0\333`\004a\261f\370g\361h\260i
+ 	     \316j\331k\277l\332m\300n\305o~p\304q\304r\304s_t\303u
+ 	     \264v\301w\302x\263y\363z\362{\343|\330}\234~\376,
diff --git a/package/libs/ncurses/patches/102-ncurses-5.9-gcc-5.patch b/package/libs/ncurses/patches/102-ncurses-5.9-gcc-5.patch
new file mode 100644
index 0000000..5f1461b
--- /dev/null
+++ b/package/libs/ncurses/patches/102-ncurses-5.9-gcc-5.patch
@@ -0,0 +1,44 @@
+https://bugs.gentoo.org/545114
+
+extracted from the upstream change (which had many unrelated commits in one)
+
+From 97bb4678dc03e753290b39bbff30ba2825df9517 Mon Sep 17 00:00:00 2001
+From: "Thomas E. Dickey" <dickey@invisible-island.net>
+Date: Sun, 7 Dec 2014 03:10:09 +0000
+Subject: [PATCH] ncurses 5.9 - patch 20141206
+
++ modify MKlib_gen.sh to work around change in development version of
+  gcc introduced here:
+	  https://gcc.gnu.org/ml/gcc-patches/2014-06/msg02185.html
+	  https://gcc.gnu.org/ml/gcc-patches/2014-07/msg00236.html
+  (reports by Marcus Shawcroft, Maohui Lei).
+
+--- a/ncurses/base/MKlib_gen.sh
++++ b/ncurses/base/MKlib_gen.sh
+@@ -512,11 +512,22 @@ sed -n -f $ED1 \
+ 	-e 's/gen_$//' \
+ 	-e 's/  / /g' >>$TMP
+ 
++cat >$ED1 <<EOF
++s/  / /g
++s/^ //
++s/ $//
++s/P_NCURSES_BOOL/NCURSES_BOOL/g
++EOF
++
++# A patch discussed here:
++#	https://gcc.gnu.org/ml/gcc-patches/2014-06/msg02185.html
++# introduces spurious #line markers.  Work around that by ignoring the system's
++# attempt to define "bool" and using our own symbol here.
++sed -e 's/bool/P_NCURSES_BOOL/g' $TMP > $ED2
++cat $ED2 >$TMP
++
+ $preprocessor $TMP 2>/dev/null \
+-| sed \
+-	-e 's/  / /g' \
+-	-e 's/^ //' \
+-	-e 's/_Bool/NCURSES_BOOL/g' \
++| sed -f $ED1 \
+ | "$AWK" -f $AW2 \
+ | sed -f $ED3 \
+ | sed \
diff --git a/package/libs/ncurses/patches/103-ncurses-ar-determinism.patch b/package/libs/ncurses/patches/103-ncurses-ar-determinism.patch
new file mode 100644
index 0000000..a459913
--- /dev/null
+++ b/package/libs/ncurses/patches/103-ncurses-ar-determinism.patch
@@ -0,0 +1,22 @@
+--- a/aclocal.m4
++++ b/aclocal.m4
+@@ -523,7 +523,7 @@ AC_CACHE_CHECK(for options to update arc
+ 		;;
+ 	(*)
+ 		cf_cv_ar_flags=unknown
+-		for cf_ar_flags in -curvU -curv curv -crv crv -cqv cqv -rv rv
++		for cf_ar_flags in -curvD -curv curv -crv crv -cqv cqv -rv rv
+ 		do
+ 
+ 			# check if $ARFLAGS already contains this choice
+--- a/configure
++++ b/configure
+@@ -5110,7 +5110,7 @@ else
+ 		;;
+ 	(*)
+ 		cf_cv_ar_flags=unknown
+-		for cf_ar_flags in -curvU -curv curv -crv crv -cqv cqv -rv rv
++		for cf_ar_flags in -curvD -curv curv -crv crv -cqv cqv -rv rv
+ 		do
+ 
+ 			# check if $ARFLAGS already contains this choice
diff --git a/package/libs/ncurses/patches/200-fix_missing_include.patch b/package/libs/ncurses/patches/200-fix_missing_include.patch
new file mode 100644
index 0000000..3c4a0d1
--- /dev/null
+++ b/package/libs/ncurses/patches/200-fix_missing_include.patch
@@ -0,0 +1,14 @@
+--- a/ncurses/curses.priv.h
++++ b/ncurses/curses.priv.h
+@@ -56,6 +56,11 @@ extern "C" {
+ 
+ #include <ncurses_cfg.h>
+ 
++#if NEED_WCHAR_H
++#include <stdarg.h>
++#include <wchar.h>
++#endif
++
+ #if USE_RCS_IDS
+ #define MODULE_ID(id) static const char Ident[] = id;
+ #else
diff --git a/package/libs/ncurses/patches/900-terminfo.patch b/package/libs/ncurses/patches/900-terminfo.patch
new file mode 100644
index 0000000..86e3bc1
--- /dev/null
+++ b/package/libs/ncurses/patches/900-terminfo.patch
@@ -0,0 +1,20 @@
+--- a/misc/terminfo.src
++++ b/misc/terminfo.src
+@@ -6514,12 +6514,11 @@ konsole-xf3x|KDE console window with key
+ # The value for kbs (see konsole-vt100) reflects local customization rather
+ # than the settings used for XFree86 xterm.
+ konsole-xf4x|KDE console window with keyboard for XFree86 4.x xterm,
+-	kend=\EOF, khome=\EOH, use=konsole+pcfkeys,
+-	use=konsole-vt100,
+-
+-konsole+pcfkeys|konsole subset of xterm+pcfkeys,
+-	kcbt=\E[Z, use=xterm+pcc2, use=xterm+pcf0,
+-	use=xterm+pce2,
++	kend=\EOF, kf1=\EOP, kf13=\EO2P, kf14=\EO2Q, kf15=\EO2R,
++	kf16=\EO2S, kf17=\E[15;2~, kf18=\E[17;2~, kf19=\E[18;2~,
++	kf2=\EOQ, kf20=\E[19;2~, kf21=\E[20;2~, kf22=\E[21;2~,
++	kf23=\E[23;2~, kf24=\E[24;2~, kf3=\EOR, kf4=\EOS,
++	khome=\EOH, use=konsole-vt100,
+ 
+ # Obsolete: vt100.keymap
+ # KDE's "vt100" keyboard has no relationship to any terminal that DEC made, but
diff --git a/package/libs/nettle/Config.in b/package/libs/nettle/Config.in
new file mode 100644
index 0000000..0d4806a
--- /dev/null
+++ b/package/libs/nettle/Config.in
@@ -0,0 +1,9 @@
+# nettle avanced configuration
+
+menu "Configuration"
+	depends on PACKAGE_libnettle
+
+config LIBNETTLE_MINI
+	bool "use mini-gmp instead of gmp; the library will be much smaller at a 10x performance penalty. Note that this option may have side effects to programs that link to both nettle and gmp."
+
+endmenu
diff --git a/package/libs/nettle/Makefile b/package/libs/nettle/Makefile
new file mode 100644
index 0000000..e8dcb8b
--- /dev/null
+++ b/package/libs/nettle/Makefile
@@ -0,0 +1,94 @@
+#
+# Copyright (C) 2014 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:=nettle
+PKG_VERSION:=3.9.1
+PKG_RELEASE:=1
+PKG_BUILD_FLAGS:=no-mips16
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@GNU/nettle
+PKG_HASH:=ccfeff981b0ca71bbd6fbcb054f407c60ffb644389a5be80d6716d5b550c6ce3
+
+PKG_LICENSE:=GPL-2.0-or-later
+PKG_LICENSE_FILES:=COPYING
+PKG_CPE_ID:=cpe:/a:nettle_project:nettle
+PKG_BUILD_PARALLEL:=1
+
+PKG_CONFIG_DEPENDS := CONFIG_LIBNETTLE_MINI
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libnettle
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=GNU crypto library
+  URL:=http://www.lysator.liu.se/~nisse/nettle/
+  DEPENDS+= +!LIBNETTLE_MINI:libgmp
+  ABI_VERSION:=8
+endef
+
+define Package/libnettle/config
+	source "$(SOURCE)/Config.in"
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+CONFIGURE_ARGS += \
+	--enable-shared \
+	--enable-fat \
+	--disable-openssl \
+	--disable-documentation \
+	--enable-static \
+	$(if $(CONFIG_powerpc64), $(if $(CONFIG_USE_MUSL),--disable-assembler))
+
+ifeq ($(CONFIG_LIBNETTLE_MINI),y)
+CONFIGURE_ARGS += --enable-mini-gmp
+endif
+
+ifeq ($(CONFIG_CPU_SUBTYPE),neon)
+CONFIGURE_ARGS += \
+	--enable-arm-neon
+endif
+
+ifeq ($(ARCH),armeb)
+CONFIGURE_ARGS += \
+	--disable-assembler
+endif
+
+define Build/Compile
+	$(call Build/Compile/Default, \
+		DESTDIR="$(PKG_INSTALL_DIR)" \
+		CC="$(TARGET_CC)" \
+		libnettle.so libhogweed.so
+	+$(MAKE) -i $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
+		DESTDIR="$(PKG_INSTALL_DIR)" \
+		install)
+endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include/nettle
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/nettle/*.h $(1)/usr/include/nettle/
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libnettle.{a,so*} $(1)/usr/lib/
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libhogweed.{a,so*} $(1)/usr/lib/
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(CP) \
+		$(PKG_INSTALL_DIR)/usr/lib/pkgconfig/nettle.pc \
+		$(PKG_INSTALL_DIR)/usr/lib/pkgconfig/hogweed.pc \
+		$(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libnettle/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libnettle.so.* $(1)/usr/lib/
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libhogweed.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libnettle))
diff --git a/package/libs/nettle/patches/100-portability.patch b/package/libs/nettle/patches/100-portability.patch
new file mode 100644
index 0000000..a44baa2
--- /dev/null
+++ b/package/libs/nettle/patches/100-portability.patch
@@ -0,0 +1,34 @@
+--- a/configure
++++ b/configure
+@@ -4719,6 +4719,7 @@ $as_echo_n "checking build system compil
+ # remove anything that might look like compiler output to our "||" expression
+ rm -f conftest* a.out b.out a.exe a_out.exe
+ cat >conftest.c <<EOF
++#include <stdlib.h>
+ int
+ main ()
+ {
+@@ -4751,6 +4752,7 @@ $as_echo_n "checking build system compil
+ # remove anything that might look like compiler output to our "||" expression
+ rm -f conftest* a.out b.out a.exe a_out.exe
+ cat >conftest.c <<EOF
++#include <stdlib.h>
+ int
+ main ()
+ {
+@@ -4787,6 +4789,7 @@ $as_echo_n "checking build system compil
+ # remove anything that might look like compiler output to our "||" expression
+ rm -f conftest* a.out b.out a.exe a_out.exe
+ cat >conftest.c <<EOF
++#include <stdlib.h>
+ int
+ main ()
+ {
+@@ -4837,6 +4840,7 @@ else
+   gmp_cv_prog_exeext_for_build="$EXEEXT"
+ else
+   cat >conftest.c <<EOF
++#include <stdlib.h>
+ int
+ main ()
+ {
diff --git a/package/libs/openssl/Config.in b/package/libs/openssl/Config.in
new file mode 100644
index 0000000..871080a
--- /dev/null
+++ b/package/libs/openssl/Config.in
@@ -0,0 +1,310 @@
+if PACKAGE_libopenssl
+
+comment "Build Options"
+
+config OPENSSL_OPTIMIZE_SPEED
+	bool
+	default y if x86_64 || i386
+	prompt "Enable optimization for speed instead of size"
+	select OPENSSL_WITH_ASM
+	help
+		Enabling this option increases code size and performance.
+		The increase in performance and size depends on the
+		target CPU. EC and AES seem to benefit the most.
+
+config OPENSSL_SMALL_FOOTPRINT
+	bool
+	depends on !OPENSSL_OPTIMIZE_SPEED
+	default y if SMALL_FLASH || LOW_MEMORY_FOOTPRINT
+	prompt "Build with OPENSSL_SMALL_FOOTPRINT (read help)"
+	help
+		This turns on -DOPENSSL_SMALL_FOOTPRINT.  This will save only
+		1-3% of of the ipk size.  The performance drop depends on
+		architecture and algorithm.  MIPS drops 13% of performance for
+		a 3% decrease in ipk size.  On Aarch64, for a 1% reduction in
+		size, ghash and GCM performance decreases 90%, while
+		Chacha20-Poly1305 is 15% slower.  X86_64 drops 1% of its size
+		for 3% of performance.  Other arches have not been tested.
+
+config OPENSSL_WITH_ASM
+	bool
+	default y
+	prompt "Compile with optimized assembly code"
+	depends on !arc
+	help
+		Disabling this option will reduce code size and performance.
+		The increase in performance and size depends on the target
+		CPU and on the algorithms being optimized.
+
+config OPENSSL_WITH_SSE2
+	bool
+	default y if !TARGET_x86_legacy && !TARGET_x86_geode
+	prompt "Enable use of x86 SSE2 instructions"
+	depends on OPENSSL_WITH_ASM && i386
+	help
+		Use of SSE2 instructions greatly increase performance with a
+		minimum increase in package size, but it will bring no benefit
+		if your hardware does not support them, such as Geode GX and LX.
+		AMD Geode NX, and Intel Pentium 4 and above support SSE2.
+
+config OPENSSL_WITH_DEPRECATED
+	bool
+	default y
+	prompt "Include deprecated APIs"
+	help
+		This drops all deprecated API, including engine support.
+
+config OPENSSL_NO_DEPRECATED
+	bool
+	default !OPENSSL_WITH_DEPRECATED
+
+config OPENSSL_WITH_ERROR_MESSAGES
+	bool
+	default y if !OPENSSL_SMALL_FOOTPRINT || (!SMALL_FLASH && !LOW_MEMORY_FOOTPRINT)
+	prompt "Include error messages"
+	help
+		This option aids debugging, but increases package size and
+		memory usage.
+
+comment "Protocol Support"
+
+config OPENSSL_WITH_TLS13
+	bool
+	default y
+	prompt "Enable support for TLS 1.3"
+	help
+		TLS 1.3 is the newest version of the TLS specification.
+		It aims:
+		 * to increase the overall security of the protocol,
+		   removing outdated algorithms, and encrypting more of the
+		   protocol;
+		 * to increase performance by reducing the number of round-trips
+		   when performing a full handshake.
+
+config OPENSSL_WITH_DTLS
+	bool
+	prompt "Enable DTLS support"
+	help
+		Datagram Transport Layer Security (DTLS) provides TLS-like security
+		for datagram-based (UDP, DCCP, CAPWAP, SCTP & SRTP) applications.
+
+config OPENSSL_WITH_NPN
+	bool
+	prompt "Enable NPN support"
+	help
+		NPN is a TLS extension, obsoleted and replaced with ALPN,
+		used to negotiate SPDY, and HTTP/2.
+
+config OPENSSL_WITH_SRP
+	bool
+	default y
+	prompt "Enable SRP support"
+	help
+		The Secure Remote Password protocol (SRP) is an augmented
+		password-authenticated key agreement (PAKE) protocol, specifically
+		designed to work around existing patents.
+
+config OPENSSL_WITH_CMS
+	bool
+	default y
+	prompt "Enable CMS (RFC 5652) support"
+	help
+		Cryptographic Message Syntax (CMS) is used to digitally sign,
+		digest, authenticate, or encrypt arbitrary message content.
+
+comment "Algorithm Selection"
+
+config OPENSSL_WITH_EC2M
+	bool
+	prompt "Enable ec2m support"
+	help
+		This option enables the more efficient, yet less common, binary
+		field elliptic curves.
+
+config OPENSSL_WITH_CHACHA_POLY1305
+	bool
+	default y
+	prompt "Enable ChaCha20-Poly1305 ciphersuite support"
+	help
+		ChaCha20-Poly1305 is an AEAD ciphersuite with 256-bit keys,
+		combining ChaCha stream cipher with Poly1305 MAC.
+		It is 3x faster than AES, when not using a CPU with AES-specific
+		instructions, as is the case of most embedded devices.
+
+config OPENSSL_PREFER_CHACHA_OVER_GCM
+	bool
+	default y if !x86_64 && !aarch64
+	prompt "Prefer ChaCha20-Poly1305 over AES-GCM by default"
+	depends on OPENSSL_WITH_CHACHA_POLY1305
+	help
+		The default openssl preference is for AES-GCM before ChaCha, but
+		that takes into account AES-NI capable chips.  It is not the
+		case with most embedded chips, so it may be better to invert
+		that preference.  This is just for the default case. The
+		application can always override this.
+
+config OPENSSL_WITH_PSK
+	bool
+	default y
+	prompt "Enable PSK support"
+	help
+		Build support for Pre-Shared Key based cipher suites.
+
+comment "Less commonly used build options"
+
+config OPENSSL_WITH_ARIA
+	bool
+	prompt "Enable ARIA support"
+	help
+		ARIA is a block cipher developed in South Korea, based on AES.
+
+config OPENSSL_WITH_CAMELLIA
+	bool
+	prompt "Enable Camellia cipher support"
+	help
+		Camellia is a bock cipher with security levels and processing
+		abilities comparable to AES.
+
+config OPENSSL_WITH_IDEA
+	bool
+	default y if !SMALL_FLASH
+	prompt "Enable IDEA cipher support (needs legacy provider)"
+	help
+		IDEA is a block cipher with 128-bit keys.
+		To use the cipher, one must install the libopenssl-legacy
+		package, using a main libopenssl package compiled with this
+		option enabled as well.
+
+config OPENSSL_WITH_SEED
+	bool
+	default y if !SMALL_FLASH
+	prompt "Enable SEED cipher support (needs legacy provider)"
+	help
+		SEED is a block cipher with 128-bit keys broadly used in
+		South Korea, but seldom found elsewhere.
+		To use the cipher, one must install the libopenssl-legacy
+		package, using a main libopenssl package compiled with this
+		option enabled as well.
+
+config OPENSSL_WITH_SM234
+	bool
+	prompt "Enable SM2/3/4 algorithms support"
+	help
+		These algorithms are a set of "Commercial Cryptography"
+		algorithms approved for use in China.
+		  * SM2 is an EC algorithm equivalent to ECDSA P-256
+		  * SM3 is a hash function equivalent to SHA-256
+		  * SM4 is a 128-block cipher equivalent to AES-128
+
+config OPENSSL_WITH_BLAKE2
+	bool
+	prompt "Enable BLAKE2 digest support"
+	help
+		BLAKE2 is a cryptographic hash function based on the ChaCha
+		stream cipher.
+
+config OPENSSL_WITH_MDC2
+	bool
+	default y if !SMALL_FLASH
+	prompt "Enable MDC2 digest support (needs legacy provider)"
+	help
+		To use the digest, one must install the libopenssl-legacy
+		package, using a main libopenssl package compiled with this
+		option enabled as well.
+
+config OPENSSL_WITH_WHIRLPOOL
+	bool
+	default y if !SMALL_FLASH
+	prompt "Enable Whirlpool digest support (needs legacy provider)"
+	help
+		To use the digest, one must install the libopenssl-legacy
+		package, using a main libopenssl package compiled with this
+		option enabled as well.
+
+config OPENSSL_WITH_COMPRESSION
+	bool
+	prompt "Enable compression support"
+	help
+		TLS compression is not recommended, as it is deemed insecure.
+		The CRIME attack exploits this weakness.
+		Even with this option turned on, it is disabled by default, and the
+		application must explicitly turn it on.
+
+config OPENSSL_WITH_RFC3779
+	bool
+	prompt "Enable RFC3779 support (BGP)"
+	help
+		RFC 3779 defines two X.509 v3 certificate extensions.  The first
+		binds a list of IP address blocks, or prefixes, to the subject of a
+		certificate.  The second binds a list of autonomous system
+		identifiers to the subject of a certificate.  These extensions may be
+		used to convey the authorization of the subject to use the IP
+		addresses and autonomous system identifiers contained in the
+		extensions.
+
+comment "Engine/Hardware Support"
+
+config OPENSSL_ENGINE
+	bool "Enable engine support"
+	select OPENSSL_WITH_DEPRECATED
+	default y
+	help
+		This enables alternative cryptography implementations,
+		most commonly for interfacing with external crypto devices,
+		or supporting new/alternative ciphers and digests.
+		If you compile the library with this option disabled, packages built
+		using an engine-enabled library (i.e. from the official repo) may
+		fail to run.  Compile and install the packages with engine support
+		disabled, and you should be fine.
+		Note that you need to enable KERNEL_AIO to be able to build the
+		afalg engine package.
+
+config OPENSSL_ENGINE_BUILTIN
+	bool "Build chosen engines into libcrypto"
+	depends on OPENSSL_ENGINE
+	help
+		This builds all chosen engines into libcrypto.so, instead of building
+		them as dynamic engines in separate packages.
+		The benefit of building the engines into libcrypto is that they won't
+		require any configuration to be used by default.
+
+config OPENSSL_ENGINE_BUILTIN_AFALG
+	bool
+	prompt "Acceleration support through AF_ALG sockets engine"
+	depends on OPENSSL_ENGINE_BUILTIN && KERNEL_AIO
+	select PACKAGE_libopenssl-conf
+	help
+		This enables use of hardware acceleration through the
+		AF_ALG kernel interface.
+
+config OPENSSL_ENGINE_BUILTIN_DEVCRYPTO
+	bool
+	prompt "Acceleration support through /dev/crypto"
+	depends on OPENSSL_ENGINE_BUILTIN
+	select PACKAGE_libopenssl-conf
+	help
+		This enables use of hardware acceleration through OpenBSD
+		Cryptodev API (/dev/crypto) interface.
+		Even though configuration is not strictly needed, it is worth seeing
+		https://openwrt.org/docs/techref/hardware/cryptographic.hardware.accelerators
+		for information on how to configure the engine.
+
+config OPENSSL_ENGINE_BUILTIN_PADLOCK
+	bool
+	prompt "VIA Padlock Acceleration support engine"
+	depends on OPENSSL_ENGINE_BUILTIN && TARGET_x86
+	select PACKAGE_libopenssl-conf
+	help
+		This enables use of hardware acceleration through the
+		VIA Padlock module.
+
+config OPENSSL_WITH_ASYNC
+	bool
+	prompt "Enable asynchronous jobs support"
+	depends on OPENSSL_ENGINE && USE_GLIBC
+	help
+		Enables async-aware applications to be able to use OpenSSL to
+		initiate crypto operations asynchronously. In order to work
+		this will require the presence of an async capable engine.
+
+endif
diff --git a/package/libs/openssl/Makefile b/package/libs/openssl/Makefile
new file mode 100644
index 0000000..4829670
--- /dev/null
+++ b/package/libs/openssl/Makefile
@@ -0,0 +1,437 @@
+#
+# Copyright (C) 2006-2016 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:=openssl
+PKG_VERSION:=3.0.16
+PKG_RELEASE:=1
+PKG_BUILD_FLAGS:=no-mips16 gc-sections no-lto
+
+PKG_BUILD_PARALLEL:=1
+
+PKG_BASE:=$(subst $(space),.,$(wordlist 1,2,$(subst .,$(space),$(PKG_VERSION))))
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:= \
+	https://www.openssl.org/source/ \
+	https://www.openssl.org/source/old/$(PKG_BASE)/ \
+	https://github.com/openssl/openssl/releases/download/$(PKG_NAME)-$(PKG_VERSION)/
+
+PKG_HASH:=57e03c50feab5d31b152af2b764f10379aecd8ee92f16c985983ce4a99f7ef86
+
+PKG_LICENSE:=Apache-2.0
+PKG_LICENSE_FILES:=LICENSE
+PKG_MAINTAINER:=Eneas U de Queiroz <cotequeiroz@gmail.com>
+PKG_CPE_ID:=cpe:/a:openssl:openssl
+PKG_CONFIG_DEPENDS:= \
+	CONFIG_OPENSSL_ENGINE \
+	CONFIG_OPENSSL_ENGINE_BUILTIN \
+	CONFIG_OPENSSL_ENGINE_BUILTIN_AFALG \
+	CONFIG_OPENSSL_ENGINE_BUILTIN_DEVCRYPTO \
+	CONFIG_OPENSSL_ENGINE_BUILTIN_PADLOCK \
+	CONFIG_OPENSSL_NO_DEPRECATED \
+	CONFIG_OPENSSL_OPTIMIZE_SPEED \
+	CONFIG_OPENSSL_PREFER_CHACHA_OVER_GCM \
+	CONFIG_OPENSSL_SMALL_FOOTPRINT \
+	CONFIG_OPENSSL_WITH_ARIA \
+	CONFIG_OPENSSL_WITH_ASM \
+	CONFIG_OPENSSL_WITH_ASYNC \
+	CONFIG_OPENSSL_WITH_BLAKE2 \
+	CONFIG_OPENSSL_WITH_CAMELLIA \
+	CONFIG_OPENSSL_WITH_CHACHA_POLY1305 \
+	CONFIG_OPENSSL_WITH_CMS \
+	CONFIG_OPENSSL_WITH_COMPRESSION \
+	CONFIG_OPENSSL_WITH_DTLS \
+	CONFIG_OPENSSL_WITH_EC2M \
+	CONFIG_OPENSSL_WITH_ERROR_MESSAGES \
+	CONFIG_OPENSSL_WITH_IDEA \
+	CONFIG_OPENSSL_WITH_MDC2 \
+	CONFIG_OPENSSL_WITH_NPN \
+	CONFIG_OPENSSL_WITH_PSK \
+	CONFIG_OPENSSL_WITH_RFC3779 \
+	CONFIG_OPENSSL_WITH_SEED \
+	CONFIG_OPENSSL_WITH_SM234 \
+	CONFIG_OPENSSL_WITH_SRP \
+	CONFIG_OPENSSL_WITH_SSE2 \
+	CONFIG_OPENSSL_WITH_TLS13 \
+	CONFIG_OPENSSL_WITH_WHIRLPOOL
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/openssl-module.mk
+
+ifneq ($(CONFIG_CCACHE),)
+HOSTCC=$(HOSTCC_NOCACHE)
+HOSTCXX=$(HOSTCXX_NOCACHE)
+endif
+
+define Package/openssl/Default
+  TITLE:=Open source SSL toolkit
+  URL:=https://www.openssl.org/
+  SECTION:=libs
+  CATEGORY:=Libraries
+endef
+
+define Package/libopenssl/config
+source "$(SOURCE)/Config.in"
+endef
+
+define Package/openssl/Default/description
+The OpenSSL Project is a collaborative effort to develop a robust,
+commercial-grade, full-featured, and Open Source toolkit implementing the
+Transport Layer Security (TLS) protocol as well as a full-strength
+general-purpose cryptography library.
+endef
+
+define Package/libopenssl
+$(call Package/openssl/Default)
+  SUBMENU:=SSL
+  DEPENDS:=+OPENSSL_WITH_COMPRESSION:zlib \
+	   +OPENSSL_ENGINE_BUILTIN_AFALG:kmod-crypto-user \
+	   +OPENSSL_ENGINE_BUILTIN_DEVCRYPTO:kmod-cryptodev \
+	   +OPENSSL_ENGINE_BUILTIN_PADLOCK:kmod-crypto-hw-padlock \
+	   +(arm||armeb||mips||mipsel||powerpc||arc):libatomic
+  TITLE+= (libraries)
+  ABI_VERSION:=$(firstword $(subst .,$(space),$(PKG_VERSION)))
+  MENU:=1
+endef
+
+define Package/libopenssl/description
+$(call Package/openssl/Default/description)
+This package contains the OpenSSL shared libraries, needed by other programs.
+endef
+
+define Package/openssl-util
+  $(call Package/openssl/Default)
+  SECTION:=utils
+  CATEGORY:=Utilities
+  DEPENDS:=+libopenssl +libopenssl-conf
+  TITLE+= (utility)
+endef
+
+define Package/openssl-util/description
+$(call Package/openssl/Default/description)
+This package contains the OpenSSL command-line utility.
+endef
+
+define Package/libopenssl-conf
+  $(call Package/openssl/Default)
+  SUBMENU:=SSL
+  TITLE:=/etc/ssl/openssl.cnf config file
+  DEPENDS:=libopenssl
+endef
+
+define Package/libopenssl-conf/conffiles
+/etc/ssl/openssl.cnf
+$(if $(CONFIG_OPENSSL_ENGINE_BUILTIN_DEVCRYPTO),/etc/ssl/modules.cnf.d/devcrypto.cnf)
+$(if $(CONFIG_OPENSSL_ENGINE_BUILTIN_PADLOCK),/etc/ssl/modules.cnf.d/padlock.cnf)
+endef
+
+define Package/libopenssl-conf/description
+$(call Package/openssl/Default/description)
+This package installs the OpenSSL configuration file /etc/ssl/openssl.cnf.
+endef
+
+ifneq ($(CONFIG_OPENSSL_ENGINE_BUILTIN_PADLOCK)$(CONFIG_OPENSSL_ENGINE_BUILTIN_DEVCRYPTO),)
+define Package/libopenssl-conf/postinst
+#!/bin/sh
+
+add_engine_config() {
+	if [ -z "$${IPKG_INSTROOT}" ] && uci -q get "openssl.$$1" >/dev/null; then
+		[ "$$(uci -q get "openssl.$$1.builtin")" = 1 ] && return
+		uci set "openssl.$$1.builtin=1" && uci commit openssl
+		return
+	fi
+}
+
+$(if $(CONFIG_OPENSSL_ENGINE_BUILTIN_DEVCRYPTO),add_engine_config devcrypto)
+$(if $(CONFIG_OPENSSL_ENGINE_BUILTIN_PADLOCK),add_engine_config padlock)
+endef
+endif
+
+$(eval $(call Package/openssl/add-provider,legacy))
+define Package/libopenssl-legacy
+  $(call Package/openssl/Default)
+  $(call Package/openssl/module/Default)
+  TITLE:=OpenSSL legacy provider
+endef
+
+define Package/libopenssl-legacy/description
+The OpenSSL legacy provider supplies OpenSSL implementations of algorithms that
+have been deemed legacy. Such algorithms have commonly fallen out of use, have
+been deemed insecure by the cryptography community, or something similar.  See
+https://www.openssl.org/docs/man3.0/man7/OSSL_PROVIDER-legacy.html
+endef
+
+$(eval $(call Package/openssl/add-engine,afalg))
+define Package/libopenssl-afalg
+  $(call Package/openssl/Default)
+  $(call Package/openssl/engine/Default)
+  TITLE:=AFALG hardware acceleration engine
+  DEPENDS += @KERNEL_AIO +PACKAGE_libopenssl-afalg:kmod-crypto-user \
+	     @!OPENSSL_ENGINE_BUILTIN
+endef
+
+define Package/libopenssl-afalg/description
+This package adds an engine that enables hardware acceleration
+through the AF_ALG kernel interface.
+See https://www.openssl.org/docs/man3.0/man5/config.html#Engine-Configuration
+and https://openwrt.org/docs/techref/hardware/cryptographic.hardware.accelerators
+The engine_id is "afalg"
+endef
+
+$(eval $(call Package/openssl/add-engine,devcrypto))
+define Package/libopenssl-devcrypto
+  $(call Package/openssl/Default)
+  $(call Package/openssl/engine/Default)
+  TITLE:=/dev/crypto hardware acceleration engine
+  DEPENDS += +PACKAGE_libopenssl-devcrypto:kmod-cryptodev @!OPENSSL_ENGINE_BUILTIN
+endef
+
+define Package/libopenssl-devcrypto/description
+This package adds an engine that enables hardware acceleration
+through the /dev/crypto kernel interface.
+See https://www.openssl.org/docs/man3.0/man5/config.html#Engine-Configuration
+and https://openwrt.org/docs/techref/hardware/cryptographic.hardware.accelerators
+The engine_id is "devcrypto"
+endef
+
+$(eval $(call Package/openssl/add-engine,padlock))
+define Package/libopenssl-padlock
+  $(call Package/openssl/Default)
+  $(call Package/openssl/engine/Default)
+  TITLE:=VIA Padlock hardware acceleration engine
+  DEPENDS += @TARGET_x86 +PACKAGE_libopenssl-padlock:kmod-crypto-hw-padlock \
+	     @!OPENSSL_ENGINE_BUILTIN
+endef
+
+define Package/libopenssl-padlock/description
+This package adds an engine that enables VIA Padlock hardware acceleration.
+See https://www.openssl.org/docs/man3.0/man5/config.html#Engine-Configuration
+and https://openwrt.org/docs/techref/hardware/cryptographic.hardware.accelerators
+The engine_id is "padlock"
+endef
+
+OPENSSL_OPTIONS:= shared no-tests
+
+ifndef CONFIG_OPENSSL_WITH_BLAKE2
+  OPENSSL_OPTIONS += no-blake2
+endif
+
+ifndef CONFIG_OPENSSL_WITH_CHACHA_POLY1305
+  OPENSSL_OPTIONS += no-chacha no-poly1305
+else
+  ifdef CONFIG_OPENSSL_PREFER_CHACHA_OVER_GCM
+    OPENSSL_OPTIONS += -DOPENSSL_PREFER_CHACHA_OVER_GCM
+  endif
+endif
+
+ifndef CONFIG_OPENSSL_WITH_ASYNC
+  OPENSSL_OPTIONS += no-async
+endif
+
+ifndef CONFIG_OPENSSL_WITH_EC2M
+  OPENSSL_OPTIONS += no-ec2m
+endif
+
+ifndef CONFIG_OPENSSL_WITH_ERROR_MESSAGES
+  OPENSSL_OPTIONS += no-err
+endif
+
+ifndef CONFIG_OPENSSL_WITH_TLS13
+  OPENSSL_OPTIONS += no-tls1_3
+endif
+
+ifndef CONFIG_OPENSSL_WITH_ARIA
+  OPENSSL_OPTIONS += no-aria
+endif
+
+ifndef CONFIG_OPENSSL_WITH_SM234
+  OPENSSL_OPTIONS += no-sm2 no-sm3 no-sm4
+endif
+
+ifndef CONFIG_OPENSSL_WITH_CAMELLIA
+  OPENSSL_OPTIONS += no-camellia
+endif
+
+ifndef CONFIG_OPENSSL_WITH_IDEA
+  OPENSSL_OPTIONS += no-idea
+endif
+
+ifndef CONFIG_OPENSSL_WITH_SEED
+  OPENSSL_OPTIONS += no-seed
+endif
+
+ifndef CONFIG_OPENSSL_WITH_MDC2
+  OPENSSL_OPTIONS += no-mdc2
+endif
+
+ifndef CONFIG_OPENSSL_WITH_WHIRLPOOL
+  OPENSSL_OPTIONS += no-whirlpool
+endif
+
+ifndef CONFIG_OPENSSL_WITH_CMS
+  OPENSSL_OPTIONS += no-cms
+endif
+
+ifndef CONFIG_OPENSSL_WITH_RFC3779
+  OPENSSL_OPTIONS += no-rfc3779
+endif
+
+ifdef CONFIG_OPENSSL_NO_DEPRECATED
+  OPENSSL_OPTIONS += no-deprecated
+endif
+
+ifeq ($(CONFIG_OPENSSL_OPTIMIZE_SPEED),y)
+  TARGET_CFLAGS := $(filter-out -O%,$(TARGET_CFLAGS)) -O3
+endif
+
+ifeq ($(CONFIG_OPENSSL_SMALL_FOOTPRINT),y)
+  OPENSSL_OPTIONS += -DOPENSSL_SMALL_FOOTPRINT
+endif
+
+ifdef CONFIG_OPENSSL_ENGINE
+  ifdef CONFIG_OPENSSL_ENGINE_BUILTIN
+    OPENSSL_OPTIONS += disable-dynamic-engine
+    ifndef CONFIG_OPENSSL_ENGINE_BUILTIN_AFALG
+      OPENSSL_OPTIONS += no-afalgeng
+    endif
+    ifdef CONFIG_OPENSSL_ENGINE_BUILTIN_DEVCRYPTO
+      OPENSSL_OPTIONS += enable-devcryptoeng
+    endif
+    ifndef CONFIG_OPENSSL_ENGINE_BUILTIN_PADLOCK
+      OPENSSL_OPTIONS += no-padlockeng
+    endif
+  else
+    ifdef CONFIG_PACKAGE_libopenssl-devcrypto
+      OPENSSL_OPTIONS += enable-devcryptoeng
+    endif
+    ifndef CONFIG_PACKAGE_libopenssl-afalg
+      OPENSSL_OPTIONS += no-afalgeng
+    endif
+    ifndef CONFIG_PACKAGE_libopenssl-padlock
+      OPENSSL_OPTIONS += no-padlockeng
+    endif
+  endif
+else
+  OPENSSL_OPTIONS += no-engine
+endif
+
+ifndef CONFIG_OPENSSL_WITH_DTLS
+  OPENSSL_OPTIONS += no-dtls
+endif
+
+ifdef CONFIG_OPENSSL_WITH_COMPRESSION
+  OPENSSL_OPTIONS += zlib-dynamic
+else
+  OPENSSL_OPTIONS += no-comp
+endif
+
+ifndef CONFIG_OPENSSL_WITH_NPN
+  OPENSSL_OPTIONS += no-nextprotoneg
+endif
+
+ifndef CONFIG_OPENSSL_WITH_PSK
+  OPENSSL_OPTIONS += no-psk
+endif
+
+ifndef CONFIG_OPENSSL_WITH_SRP
+  OPENSSL_OPTIONS += no-srp
+endif
+
+ifndef CONFIG_OPENSSL_WITH_ASM
+  OPENSSL_OPTIONS += no-asm
+endif
+
+ifdef CONFIG_i386
+  ifndef CONFIG_OPENSSL_WITH_SSE2
+    OPENSSL_OPTIONS += no-sse2
+  endif
+endif
+
+OPENSSL_TARGET:=linux-$(call qstrip,$(CONFIG_ARCH))-openwrt
+
+STAMP_CONFIGURED := $(STAMP_CONFIGURED)_$(shell echo $(OPENSSL_OPTIONS) | $(MKHASH) md5)
+
+define Build/Configure
+	(cd $(PKG_BUILD_DIR); \
+		./Configure $(OPENSSL_TARGET) \
+			--prefix=/usr \
+			--libdir=lib \
+			--openssldir=/etc/ssl \
+			--cross-compile-prefix="$(TARGET_CROSS)" \
+			$(TARGET_CFLAGS) \
+			$(TARGET_CPPFLAGS) \
+			$(TARGET_LDFLAGS) \
+			$(OPENSSL_OPTIONS) && \
+		{ [ -f $(STAMP_CONFIGURED) ] || make clean; } \
+	)
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+define Build/Compile
+	+$(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
+		CC="$(TARGET_CC)" \
+		SOURCE_DATE_EPOCH=$(SOURCE_DATE_EPOCH) \
+		OPENWRT_OPTIMIZATION_FLAGS="$(TARGET_CFLAGS)" \
+		$(OPENSSL_MAKEFLAGS) \
+		all
+	$(MAKE) -C $(PKG_BUILD_DIR) \
+		CC="$(TARGET_CC)" \
+		DESTDIR="$(PKG_INSTALL_DIR)" \
+		$(OPENSSL_MAKEFLAGS) \
+		install_sw install_ssldirs
+endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/openssl $(1)/usr/include/
+	$(INSTALL_DIR) $(1)/usr/lib/
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{crypto,ssl}.{a,so*} $(1)/usr/lib/
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc $(1)/usr/lib/pkgconfig/
+	[ -n "$(TARGET_LDFLAGS)" ] && $(SED) 's#$(TARGET_LDFLAGS)##g' $(1)/usr/lib/pkgconfig/{openssl,libcrypto,libssl}.pc || true
+endef
+
+define Package/libopenssl/install
+	$(INSTALL_DIR) $(1)/etc/ssl/certs
+	$(INSTALL_DIR) $(1)/etc/ssl/private
+	chmod 0700 $(1)/etc/ssl/private
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libcrypto.so.* $(1)/usr/lib/
+	$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libssl.so.* $(1)/usr/lib/
+	$(if $(CONFIG_OPENSSL_ENGINE),$(INSTALL_DIR) $(1)/usr/lib/$(ENGINES_DIR))
+endef
+
+define Package/libopenssl-conf/install
+	$(INSTALL_DIR) $(1)/etc/ssl/modules.cnf.d $(1)/etc/config $(1)/etc/init.d
+	$(CP) $(PKG_INSTALL_DIR)/etc/ssl/openssl.cnf $(1)/etc/ssl/
+	$(INSTALL_BIN) ./files/openssl.init $(1)/etc/init.d/openssl
+	$(SED) 's!%ENGINES_DIR%!/usr/lib/$(ENGINES_DIR)!' $(1)/etc/init.d/openssl
+	touch $(1)/etc/config/openssl
+	$(if $(CONFIG_OPENSSL_ENGINE),,
+		$(SED) 's!engines = engines_sect!#&!' $(1)/etc/ssl/openssl.cnf)
+	$(if $(CONFIG_OPENSSL_ENGINE_BUILTIN_DEVCRYPTO),
+		$(CP) ./files/devcrypto.cnf $(1)/etc/ssl/modules.cnf.d/
+		echo -e "config engine 'devcrypto'\n\toption enabled '1'\n\toption builtin '1'" >> $(1)/etc/config/openssl)
+	$(if $(CONFIG_OPENSSL_ENGINE_BUILTIN_PADLOCK),
+		$(CP) ./files/padlock.cnf $(1)/etc/ssl/modules.cnf.d/
+		echo -e "\nconfig engine 'padlock'\n\toption enabled '1'\n\toption builtin '1'" >> $(1)/etc/config/openssl)
+endef
+
+define Package/openssl-util/install
+	$(INSTALL_DIR) $(1)/usr/bin
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/openssl $(1)/usr/bin/
+endef
+
+$(eval $(call BuildPackage,libopenssl))
+$(eval $(call BuildPackage,libopenssl-conf))
+$(eval $(call BuildPackage,libopenssl-afalg))
+$(eval $(call BuildPackage,libopenssl-devcrypto))
+$(eval $(call BuildPackage,libopenssl-legacy))
+$(eval $(call BuildPackage,libopenssl-padlock))
+$(eval $(call BuildPackage,openssl-util))
diff --git a/package/libs/openssl/files/afalg.cnf b/package/libs/openssl/files/afalg.cnf
new file mode 100644
index 0000000..fd20636
--- /dev/null
+++ b/package/libs/openssl/files/afalg.cnf
@@ -0,0 +1,3 @@
+[afalg_sect]
+default_algorithms = ALL
+
diff --git a/package/libs/openssl/files/devcrypto.cnf b/package/libs/openssl/files/devcrypto.cnf
new file mode 100644
index 0000000..91d0eee
--- /dev/null
+++ b/package/libs/openssl/files/devcrypto.cnf
@@ -0,0 +1,34 @@
+[devcrypto_sect]
+# Leave this alone and configure algorithms with CIPERS/DIGESTS below
+default_algorithms = ALL
+
+# Configuration commands:
+# Run 'openssl engine -t -c -vv -pre DUMP_INFO devcrypto' to see a
+# list of supported algorithms, along with their driver, whether they
+# are hw accelerated or not, and the engine's configuration commands.
+
+# USE_SOFTDRIVERS: specifies whether to use software (not accelerated)
+# drivers (0=use only accelerated drivers, 1=allow all drivers, 2=use
+# if acceleration can't be determined) [default=2]
+#USE_SOFTDRIVERS = 2
+
+# CIPHERS: either ALL, NONE, or a comma-separated list of ciphers to
+# enable [default=ALL]
+# It is recommended to disable the ECB ciphers; in most cases, it will
+# only be used for PRNG, in small blocks, where performance is poor,
+# and there may be problems with apps forking with open crypto
+# contexts, leading to failures.  The CBC ciphers work well.
+CIPHERS=DES-CBC, DES-EDE3-CBC, AES-128-CBC, AES-192-CBC, AES-256-CBC, \
+	AES-128-CTR, AES-192-CTR, AES-256-CTR
+
+# DIGESTS: either ALL, NONE, or a comma-separated list of digests to
+# enable [default=NONE]
+# It is strongly recommended not to enable digests; their performance
+# is poor, and there are many cases in which they will not work,
+# especially when calling fork with open crypto contexts.  Openssh,
+# for example, does this, and you may not be able to login.
+# Sysupgrade will fail as well.  If you're adventurous enough to change
+# this, you should change it back to NONE, and reboot before running
+# sysupgrade!
+DIGESTS = NONE
+
diff --git a/package/libs/openssl/files/legacy.cnf b/package/libs/openssl/files/legacy.cnf
new file mode 100644
index 0000000..4c20617
--- /dev/null
+++ b/package/libs/openssl/files/legacy.cnf
@@ -0,0 +1,3 @@
+[legacy_sect]
+activate = 1
+
diff --git a/package/libs/openssl/files/openssl.init b/package/libs/openssl/files/openssl.init
new file mode 100755
index 0000000..1c1e874
--- /dev/null
+++ b/package/libs/openssl/files/openssl.init
@@ -0,0 +1,72 @@
+#!/bin/sh /etc/rc.common
+
+START=13
+ENGINES_CNF=/var/etc/ssl/engines.cnf
+ENGINES_DIR=%ENGINES_DIR%
+MODULES_DIR=/usr/lib/ossl-modules
+PROVIDERS_CNF=/var/etc/ssl/providers.cnf
+
+#1: cnf file
+write_cnf_header() {
+	mkdir -p "$(dirname "$1")" && \
+	echo "# This file is automatically generated from /etc/config/openssl." >"$1" || {
+		echo "Error writing to $1."
+		return 1
+	}
+}
+
+
+#1: module name
+#2: output cnf file
+#3: module.so
+enable_module() {
+	local builtin enabled force
+
+	config_get_bool builtin "$1" builtin 0
+	config_get_bool enabled "$1" enabled 1
+	config_get_bool force "$1" force 0
+
+	if [ "$enabled" = 0 ]; then
+		[ "$builtin" = 0 ] && return 1
+		echo "Engine $1 is built into the libcrypto library and can't be disabled through UCI."
+		echo "If the engine was not built-in, remove 'config builtin' from /etc/config/openssl."
+	elif [ "$force" = 1 ]; then
+		printf "[Forced] "
+	elif ! grep -q "\\[ *$1_sect *]" /etc/ssl/modules.cnf.d/*; then
+		echo "$1: Could not find section [$1] in config files."
+		return 1
+	elif [ "$builtin" = 1 ]; then
+		printf "[Builtin] "
+	elif [ ! -f "$3" ];then
+		echo "Skipping $1: $3 not found."
+		return 1
+	fi
+	echo "Enabling $1"
+	echo "$1=$1_sect" >>"$2"
+}
+
+config_engine() {
+	enable_module "$1" "$ENGINES_CNF" \
+		      "${ENGINES_DIR}/${1}.so"
+}
+
+config_provider() {
+	enable_module "$1" "$PROVIDERS_CNF" \
+		      "${MODULES_DIR}/${1}.so"
+}
+
+start() {
+	local ret=0
+
+        config_load openssl
+
+	echo Generating engines.cnf
+	write_cnf_header "${ENGINES_CNF}" && \
+	config_foreach config_engine engine || ret=$?
+
+	echo Generating providers.cnf
+	write_cnf_header "${PROVIDERS_CNF}" && \
+	config_foreach config_provider provider || ret=$?
+
+	return $ret
+}
diff --git a/package/libs/openssl/files/padlock.cnf b/package/libs/openssl/files/padlock.cnf
new file mode 100644
index 0000000..f4085d9
--- /dev/null
+++ b/package/libs/openssl/files/padlock.cnf
@@ -0,0 +1,3 @@
+[padlock_sect]
+default_algorithms = ALL
+
diff --git a/package/libs/openssl/patches/100-Configure-afalg-support.patch b/package/libs/openssl/patches/100-Configure-afalg-support.patch
new file mode 100644
index 0000000..e9cd7bf
--- /dev/null
+++ b/package/libs/openssl/patches/100-Configure-afalg-support.patch
@@ -0,0 +1,23 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Eneas U de Queiroz <cote2004-github@yahoo.com>
+Date: Thu, 27 Sep 2018 08:29:21 -0300
+Subject: Do not use host kernel version to disable AFALG
+
+This patch prevents the Configure script from using the host kernel
+version to disable building the AFALG engine on openwrt targets.
+
+Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
+
+--- a/Configure
++++ b/Configure
+@@ -1677,7 +1677,9 @@ $config{CFLAGS} = [ map { $_ eq '--ossl-
+ 
+ unless ($disabled{afalgeng}) {
+     $config{afalgeng}="";
+-    if (grep { $_ eq 'afalgeng' } @{$target{enable}}) {
++    if ($target =~ m/openwrt$/) {
++        push @{$config{engdirs}}, "afalg";
++    } elsif (grep { $_ eq 'afalgeng' } @{$target{enable}}) {
+         my $minver = 4*10000 + 1*100 + 0;
+         if ($config{CROSS_COMPILE} eq "") {
+             my $verstr = `uname -r`;
diff --git a/package/libs/openssl/patches/110-openwrt_targets.patch b/package/libs/openssl/patches/110-openwrt_targets.patch
new file mode 100644
index 0000000..d02bc03
--- /dev/null
+++ b/package/libs/openssl/patches/110-openwrt_targets.patch
@@ -0,0 +1,71 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Eneas U de Queiroz <cote2004-github@yahoo.com>
+Date: Thu, 27 Sep 2018 08:30:24 -0300
+Subject: Add openwrt targets
+
+Targets are named: linux-$(CONFIG_ARCH)-openwrt
+
+Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
+
+--- /dev/null
++++ b/Configurations/25-openwrt.conf
+@@ -0,0 +1,59 @@
++## Openwrt "CONFIG_ARCH" matching targets.
++
++# The targets need to end in '-openwrt' for the AFALG patch to work
++
++my %targets = (
++    "openwrt" => {
++	template	=> 1,
++	CFLAGS		=> add("\$(OPENWRT_OPTIMIZATION_FLAGS)"),
++    },
++    "linux-aarch64-openwrt" => {
++        inherit_from    => [ "linux-aarch64", "openwrt" ],
++    },
++    "linux-arc-openwrt" => {
++        inherit_from    => [ "linux-latomic", "openwrt" ],
++    },
++    "linux-arm-openwrt" => {
++        inherit_from    => [ "linux-armv4", "openwrt" ],
++    },
++    "linux-armeb-openwrt" => {
++        inherit_from    => [ "linux-armv4", "openwrt" ],
++    },
++    "linux-i386-openwrt" => {
++        inherit_from    => [ "linux-x86", "openwrt" ],
++    },
++    "linux-loongarch64-openwrt" => {
++        inherit_from    => [ "linux64-loongarch64", "openwrt" ],
++    },
++    "linux-mips-openwrt" => {
++        inherit_from    => [ "linux-mips32", "openwrt" ],
++    },
++    "linux-mips64-openwrt" => {
++        inherit_from    => [ "linux64-mips64", "openwrt" ],
++    },
++    "linux-mips64el-openwrt" => {
++        inherit_from    => [ "linux64-mips64", "openwrt" ],
++    },
++    "linux-mipsel-openwrt" => {
++        inherit_from    => [ "linux-mips32", "openwrt" ],
++    },
++    "linux-powerpc-openwrt" => {
++        inherit_from    => [ "linux-ppc", "openwrt" ],
++    },
++    "linux-powerpc64-openwrt" => {
++        inherit_from    => [ "linux-ppc64", "openwrt" ],
++        perlasm_scheme  => "linux64v2",
++    },
++    "linux-riscv64-openwrt" => {
++        inherit_from    => [ "linux-generic64", "openwrt" ],
++        perlasm_scheme   => "linux64",
++    },
++    "linux-x86_64-openwrt" => {
++        inherit_from    => [ "linux-x86_64", "openwrt" ],
++    },
++
++### Basic default option
++    "linux-generic32-openwrt" => {
++        inherit_from    => [ "linux-generic32", "openwrt" ],
++    },
++);
diff --git a/package/libs/openssl/patches/120-strip-cflags-from-binary.patch b/package/libs/openssl/patches/120-strip-cflags-from-binary.patch
new file mode 100644
index 0000000..ebdb940
--- /dev/null
+++ b/package/libs/openssl/patches/120-strip-cflags-from-binary.patch
@@ -0,0 +1,21 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Eneas U de Queiroz <cote2004-github@yahoo.com>
+Date: Thu, 27 Sep 2018 08:31:38 -0300
+Subject: Avoid exposing build directories
+
+The CFLAGS contain the build directories, and are shown by calling
+OpenSSL_version(OPENSSL_CFLAGS), or running openssl version -a
+
+Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
+
+--- a/crypto/build.info
++++ b/crypto/build.info
+@@ -109,7 +109,7 @@ DEFINE[../libcrypto]=$UPLINKDEF
+ 
+ DEPEND[info.o]=buildinf.h
+ DEPEND[cversion.o]=buildinf.h
+-GENERATE[buildinf.h]=../util/mkbuildinf.pl "$(CC) $(LIB_CFLAGS) $(CPPFLAGS_Q)" "$(PLATFORM)"
++GENERATE[buildinf.h]=../util/mkbuildinf.pl "$(filter-out -I% -iremap% -fmacro-prefix-map% -ffile-prefix-map%,$(CC) $(LIB_CFLAGS) $(CPPFLAGS_Q))" "$(PLATFORM)"
+ 
+ GENERATE[uplink-x86.S]=../ms/uplink-x86.pl
+ GENERATE[uplink-x86_64.s]=../ms/uplink-x86_64.pl
diff --git a/package/libs/openssl/patches/130-dont-build-fuzz-docs.patch b/package/libs/openssl/patches/130-dont-build-fuzz-docs.patch
new file mode 100644
index 0000000..60c4663
--- /dev/null
+++ b/package/libs/openssl/patches/130-dont-build-fuzz-docs.patch
@@ -0,0 +1,20 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Eneas U de Queiroz <cote2004-github@yahoo.com>
+Date: Thu, 27 Sep 2018 08:34:38 -0300
+Subject: Do not build tests and fuzz directories
+
+This shortens build time.
+
+Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
+
+--- a/build.info
++++ b/build.info
+@@ -1,7 +1,7 @@
+ # Note that some of these directories are filtered in Configure.  Look for
+ # %skipdir there for further explanations.
+ 
+-SUBDIRS=crypto ssl apps util tools fuzz providers doc
++SUBDIRS=crypto ssl apps util tools providers
+ IF[{- !$disabled{tests} -}]
+   SUBDIRS=test
+ ENDIF
diff --git a/package/libs/openssl/patches/140-allow-prefer-chacha20.patch b/package/libs/openssl/patches/140-allow-prefer-chacha20.patch
new file mode 100644
index 0000000..fb7bc84
--- /dev/null
+++ b/package/libs/openssl/patches/140-allow-prefer-chacha20.patch
@@ -0,0 +1,92 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Eneas U de Queiroz <cote2004-github@yahoo.com>
+Date: Thu, 27 Sep 2018 08:44:39 -0300
+Subject: Add OPENSSL_PREFER_CHACHA_OVER_GCM option
+
+This enables a compile-time option to prefer ChaCha20-Poly1305 over
+AES-GCM in the openssl default ciphersuite, which is useful in systems
+without AES specific CPU instructions.
+OPENSSL_PREFER_CHACHA_OVER_GCM must be defined to enable it.
+
+Note that this does not have the same effect as the
+SL_OP_PRIORITIZE_CHACHA option, which prioritizes ChaCha20-Poly1305 only
+when the client has it on top of its ciphersuite preference.
+
+Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
+
+--- a/ssl/ssl_ciph.c
++++ b/ssl/ssl_ciph.c
+@@ -1506,11 +1506,29 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_
+     ssl_cipher_apply_rule(0, SSL_kECDHE, 0, 0, 0, 0, 0, CIPHER_DEL, -1, &head,
+                           &tail);
+ 
++    /*
++     * If OPENSSL_PREFER_CHACHA_OVER_GCM is defined, ChaCha20_Poly1305
++     * will be placed before AES-256.  Otherwise, the default behavior of
++     * preferring GCM over CHACHA is used.
++     * This is useful for systems that do not have AES-specific CPU
++     * instructions, where ChaCha20-Poly1305 is 3 times faster than AES.
++     * Note that this does not have the same effect as the SSL_OP_PRIORITIZE_CHACHA
++     * option, which prioritizes ChaCha20-Poly1305 only when the client has it on top
++     * of its ciphersuite preference.
++     */
++
++#ifdef OPENSSL_PREFER_CHACHA_OVER_GCM
++    ssl_cipher_apply_rule(0, 0, 0, SSL_CHACHA20, 0, 0, 0, CIPHER_ADD, -1,
++                          &head, &tail);
++    ssl_cipher_apply_rule(0, 0, 0, SSL_AESGCM, 0, 0, 0, CIPHER_ADD, -1,
++                          &head, &tail);
++#else
+     /* Within each strength group, we prefer GCM over CHACHA... */
+     ssl_cipher_apply_rule(0, 0, 0, SSL_AESGCM, 0, 0, 0, CIPHER_ADD, -1,
+                           &head, &tail);
+     ssl_cipher_apply_rule(0, 0, 0, SSL_CHACHA20, 0, 0, 0, CIPHER_ADD, -1,
+                           &head, &tail);
++#endif
+ 
+     /*
+      * ...and generally, our preferred cipher is AES.
+@@ -1565,7 +1583,7 @@ STACK_OF(SSL_CIPHER) *ssl_create_cipher_
+      * Within each group, ciphers remain sorted by strength and previous
+      * preference, i.e.,
+      * 1) ECDHE > DHE
+-     * 2) GCM > CHACHA
++     * 2) GCM > CHACHA, reversed if OPENSSL_PREFER_CHACHA_OVER_GCM is defined
+      * 3) AES > rest
+      * 4) TLS 1.2 > legacy
+      *
+@@ -2236,7 +2254,13 @@ const char *OSSL_default_cipher_list(voi
+  */
+ const char *OSSL_default_ciphersuites(void)
+ {
++#ifdef OPENSSL_PREFER_CHACHA_OVER_GCM
++    return "TLS_CHACHA20_POLY1305_SHA256:"
++           "TLS_AES_256_GCM_SHA384:"
++           "TLS_AES_128_GCM_SHA256";
++#else
+     return "TLS_AES_256_GCM_SHA384:"
+            "TLS_CHACHA20_POLY1305_SHA256:"
+            "TLS_AES_128_GCM_SHA256";
++#endif
+ }
+--- a/include/openssl/ssl.h.in
++++ b/include/openssl/ssl.h.in
+@@ -195,9 +195,15 @@ extern "C" {
+  * DEPRECATED IN 3.0.0, in favor of OSSL_default_ciphersuites()
+  * Update both macro and function simultaneously
+  */
+-#  define TLS_DEFAULT_CIPHERSUITES "TLS_AES_256_GCM_SHA384:" \
+-                                   "TLS_CHACHA20_POLY1305_SHA256:" \
+-                                   "TLS_AES_128_GCM_SHA256"
++#  ifdef OPENSSL_PREFER_CHACHA_OVER_GCM
++#   define TLS_DEFAULT_CIPHERSUITES "TLS_CHACHA20_POLY1305_SHA256:" \
++                                    "TLS_AES_256_GCM_SHA384:" \
++                                    "TLS_AES_128_GCM_SHA256"
++#  else
++#   define TLS_DEFAULT_CIPHERSUITES "TLS_AES_256_GCM_SHA384:" \
++                                    "TLS_CHACHA20_POLY1305_SHA256:" \
++                                    "TLS_AES_128_GCM_SHA256"
++#  endif
+ # endif
+ /*
+  * As of OpenSSL 1.0.0, ssl_create_cipher_list() in ssl/ssl_ciph.c always
diff --git a/package/libs/openssl/patches/150-openssl.cnf-add-engines-conf.patch b/package/libs/openssl/patches/150-openssl.cnf-add-engines-conf.patch
new file mode 100644
index 0000000..9fe9cdf
--- /dev/null
+++ b/package/libs/openssl/patches/150-openssl.cnf-add-engines-conf.patch
@@ -0,0 +1,41 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Eneas U de Queiroz <cotequeiroz@gmail.com>
+Date: Sat, 27 Mar 2021 17:43:25 -0300
+Subject: openssl.cnf: add engine configuration
+
+This adds configuration options for engines, loading all cnf files under
+/etc/ssl/engines.cnf.d/.
+
+Signed-off-by: Eneas U de Queiroz <cotequeiroz@gmail.com>
+
+--- a/apps/openssl.cnf
++++ b/apps/openssl.cnf
+@@ -52,10 +52,13 @@ tsa_policy3 = 1.2.3.4.5.7
+ 
+ [openssl_init]
+ providers = provider_sect
++engines = engines_sect
+ 
+ # List of providers to load
+ [provider_sect]
+ default = default_sect
++.include /var/etc/ssl/providers.cnf
++
+ # The fips section name should match the section name inside the
+ # included fipsmodule.cnf.
+ # fips = fips_sect
+@@ -69,7 +72,13 @@ default = default_sect
+ # OpenSSL may not work correctly which could lead to significant system
+ # problems including inability to remotely access the system.
+ [default_sect]
+-# activate = 1
++activate = 1
++
++[engines_sect]
++.include /var/etc/ssl/engines.cnf
++
++.include /etc/ssl/modules.cnf.d
++
+ 
+ 
+ ####################################################################
diff --git a/package/libs/openssl/patches/500-e_devcrypto-default-to-not-use-digests-in-engine.patch b/package/libs/openssl/patches/500-e_devcrypto-default-to-not-use-digests-in-engine.patch
new file mode 100644
index 0000000..f183263
--- /dev/null
+++ b/package/libs/openssl/patches/500-e_devcrypto-default-to-not-use-digests-in-engine.patch
@@ -0,0 +1,41 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Eneas U de Queiroz <cote2004-github@yahoo.com>
+Date: Mon, 11 Mar 2019 09:29:13 -0300
+Subject: e_devcrypto: default to not use digests in engine
+
+Digests are almost always slower when using /dev/crypto because of the
+cost of the context switches.  Only for large blocks it is worth it.
+
+Also, when forking, the open context structures are duplicated, but the
+internal kernel sessions are still shared between forks, which means an
+update/close operation in one fork affects all processes using that
+session.
+
+This affects digests, especially for HMAC, where the session with the
+key hash is used as a source for subsequent operations.  At least one
+popular application does this across a fork.  Disabling digests by
+default will mitigate the problem, while still allowing the user to
+turn them on if it is safe and fast enough.
+
+Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
+
+--- a/engines/e_devcrypto.c
++++ b/engines/e_devcrypto.c
+@@ -905,7 +905,7 @@ static void prepare_digest_methods(void)
+     for (i = 0, known_digest_nids_amount = 0; i < OSSL_NELEM(digest_data);
+          i++) {
+ 
+-        selected_digests[i] = 1;
++        selected_digests[i] = 0;
+ 
+         /*
+          * Check that the digest is usable
+@@ -1119,7 +1119,7 @@ static const ENGINE_CMD_DEFN devcrypto_c
+ #ifdef IMPLEMENT_DIGEST
+    {DEVCRYPTO_CMD_DIGESTS,
+     "DIGESTS",
+-    "either ALL, NONE, or a comma-separated list of digests to enable [default=ALL]",
++    "either ALL, NONE, or a comma-separated list of digests to enable [default=NONE]",
+     ENGINE_CMD_FLAG_STRING},
+ #endif
+ 
diff --git a/package/libs/openssl/patches/510-e_devcrypto-ignore-error-when-closing-session.patch b/package/libs/openssl/patches/510-e_devcrypto-ignore-error-when-closing-session.patch
new file mode 100644
index 0000000..40b1dc7
--- /dev/null
+++ b/package/libs/openssl/patches/510-e_devcrypto-ignore-error-when-closing-session.patch
@@ -0,0 +1,24 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Eneas U de Queiroz <cote2004-github@yahoo.com>
+Date: Mon, 11 Mar 2019 10:15:14 -0300
+Subject: e_devcrypto: ignore error when closing session
+
+In cipher_init, ignore an eventual error when closing the previous
+session.  It may have been closed by another process after a fork.
+
+Signed-off-by: Eneas U de Queiroz <cote2004-github@yahoo.com>
+
+--- a/engines/e_devcrypto.c
++++ b/engines/e_devcrypto.c
+@@ -211,9 +211,8 @@ static int cipher_init(EVP_CIPHER_CTX *c
+     int ret;
+ 
+     /* cleanup a previous session */
+-    if (cipher_ctx->sess.ses != 0 &&
+-        clean_devcrypto_session(&cipher_ctx->sess) == 0)
+-        return 0;
++    if (cipher_ctx->sess.ses != 0)
++        clean_devcrypto_session(&cipher_ctx->sess);
+ 
+     cipher_ctx->sess.cipher = cipher_d->devcryptoid;
+     cipher_ctx->sess.keylen = cipher_d->keylen;
diff --git a/package/libs/pcre/Config.in b/package/libs/pcre/Config.in
new file mode 100644
index 0000000..15e75fc
--- /dev/null
+++ b/package/libs/pcre/Config.in
@@ -0,0 +1,11 @@
+config PCRE_JIT_ENABLED
+	bool
+	depends on PACKAGE_libpcre && (arm || i386 || i686 || x86_64 || mips || mipsel || powerpc || sparc)
+	default y if (arm || i686 || x86_64)
+	prompt "Enable JIT compiler support"
+	help
+		Enable JIT (Just-In-Time) compiler support.
+
+		Enabling this option can give an about 10x performance increase on JIT operations. It can be desireable for e.g. high performance Apache mod_rewrite or HA-Proxy reqrep operations.
+
+		However, JIT should _only_ be enabled on architectures that are supported. Enabling JIT on unsupported platforms will result in a compilation failure. A list of supported architectures can be found here: https://pcre.org/original/doc/html/pcrejit.html#SEC3 .
diff --git a/package/libs/pcre/Makefile b/package/libs/pcre/Makefile
new file mode 100644
index 0000000..894f39b
--- /dev/null
+++ b/package/libs/pcre/Makefile
@@ -0,0 +1,129 @@
+#
+# Copyright (C) 2006-2015 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:=pcre
+PKG_VERSION:=8.45
+PKG_RELEASE:=$(AUTORELEASE)
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=@SF/$(PKG_NAME)
+PKG_HASH:=4dae6fdcd2bb0bb6c37b5f97c33c2be954da743985369cddac3546e3218bffb8
+
+PKG_MAINTAINER:=Thomas Heil <heil@terminal-consulting.de>
+PKG_LICENSE:=BSD-3-Clause
+PKG_LICENSE_FILES:=LICENCE
+PKG_CPE_ID:=cpe:/a:pcre:pcre
+
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+PKG_CONFIG_DEPENDS:=\
+	CONFIG_PACKAGE_libpcrecpp \
+	CONFIG_PCRE_JIT_ENABLED
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+
+define Package/libpcre/default
+  SECTION:=libs
+  CATEGORY:=Libraries
+  URL:=https://www.pcre.org/
+endef
+
+define Package/libpcre/config
+  source "$(SOURCE)/Config.in"
+endef
+
+define Package/libpcre
+  $(call Package/libpcre/default)
+  TITLE:=A Perl Compatible Regular Expression library
+endef
+
+define Package/libpcre16
+  $(call Package/libpcre/default)
+  TITLE:=A Perl Compatible Regular Expression library (16bit support)
+endef
+
+define Package/libpcre32
+  $(call Package/libpcre/default)
+  TITLE:=A Perl Compatible Regular Expression library (32bit support)
+endef
+
+define Package/libpcrecpp
+  $(call Package/libpcre/default)
+  TITLE:=C++ wrapper for Perl Compatible Regular Expression library
+  DEPENDS:=+libpcre +libstdcpp
+endef
+
+HOST_CONFIGURE_ARGS += \
+	--disable-shared \
+	--enable-utf8 \
+	--enable-unicode-properties \
+	--enable-pcre16 \
+	--with-match-limit-recursion=16000 \
+	--enable-cpp \
+	--with-pic
+
+CONFIGURE_ARGS += \
+	--enable-utf8 \
+	--enable-unicode-properties \
+	--enable-pcre16 \
+	--enable-pcre32 \
+	$(if $(CONFIG_PCRE_JIT_ENABLED),--enable-jit,--disable-jit) \
+	--with-match-limit-recursion=16000 \
+	--$(if $(CONFIG_PACKAGE_libpcrecpp),en,dis)able-cpp \
+	--with-pic
+
+MAKE_FLAGS += \
+	CFLAGS="$(TARGET_CFLAGS)"
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/bin
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/pcre-config $(1)/usr/bin/
+	$(SED) 's,^\(prefix\|exec_prefix\)=.*,\1=$(STAGING_DIR)/usr,g' $(1)/usr/bin/pcre-config
+
+	$(INSTALL_DIR) $(2)/bin
+	$(LN) $(STAGING_DIR)/usr/bin/pcre-config $(2)/bin
+
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/pcre*.h $(1)/usr/include/
+
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcre*.{a,so*} $(1)/usr/lib/
+
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libpcre*.pc $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libpcre/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcre{,posix}.so.* $(1)/usr/lib/
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcre.so $(1)/usr/lib/
+endef
+
+define Package/libpcre16/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcre16.so* $(1)/usr/lib/
+endef
+
+define Package/libpcre32/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcre32.so* $(1)/usr/lib/
+endef
+
+define Package/libpcrecpp/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcrecpp.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libpcre))
+$(eval $(call BuildPackage,libpcre16))
+$(eval $(call BuildPackage,libpcre32))
+$(eval $(call BuildPackage,libpcrecpp))
+$(eval $(call HostBuild))
diff --git a/package/libs/pcre2/Config.in b/package/libs/pcre2/Config.in
new file mode 100644
index 0000000..8777a4e
--- /dev/null
+++ b/package/libs/pcre2/Config.in
@@ -0,0 +1,30 @@
+config PCRE2_JIT_ENABLED
+	bool
+	depends on PACKAGE_libpcre2 && (aarch64 || aarch64_be || arm || i386 || i686 || x86_64 || mips || mipsel || mips64 || mips64el || powerpc || powerpc64 || powerpcle || sparc)
+	default y if (arm || i686 || x86_64)
+	prompt "Enable JIT compiler support"
+	help
+		Enable JIT (Just-In-Time) compiler support.
+
+		Just-in-time compiling is a heavyweight optimization that can greatly
+		speed up pattern matching. However, it comes at the cost of extra
+		processing before the match is performed, so it is of most benefit when
+		the same pattern is going to be matched many times. This does not
+		necessarily mean many calls of a matching function; if the pattern is
+		not anchored, matching attempts may take place many times at various
+		positions in the subject, even for a single call. Therefore, if the
+		subject string is very long, it may still pay to use JIT even for
+		one-off matches. JIT support is available for all of the 8-bit, 16-bit
+		and 32-bit PCRE2 libraries and adds about 100KB to the resulting
+		libpcre2.so. JIT support applies only to the traditional Perl-compatible
+		matching function. It does not apply when the DFA matching function is
+		being used.
+
+		Enabling this option can give an about 10x performance increase on JIT
+		operations. It can be desireable for e.g. high performance Apache
+		mod_rewrite or HA-Proxy reqrep operations.
+
+		However, JIT should _only_ be enabled on architectures that are supported.
+		Enabling JIT on unsupported platforms will result in a compilation
+		failure. A list of supported architectures can be found here:
+		https://pcre.org/current/doc/html/pcre2jit.html#SEC2
diff --git a/package/libs/pcre2/Makefile b/package/libs/pcre2/Makefile
new file mode 100644
index 0000000..084a63c
--- /dev/null
+++ b/package/libs/pcre2/Makefile
@@ -0,0 +1,109 @@
+#
+# Copyright (C) 2017 Shane Peelar
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=pcre2
+PKG_VERSION:=10.42
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_SOURCE_URL:=https://github.com/PCRE2Project/pcre2/releases/download/$(PKG_NAME)-$(PKG_VERSION)
+PKG_HASH:=8d36cd8cb6ea2a4c2bb358ff6411b0c788633a2a45dabbf1aeb4b701d1b5e840
+
+PKG_MAINTAINER:=Shane Peelar <lookatyouhacker@gmail.com>
+PKG_LICENSE:=BSD-3-Clause
+PKG_LICENSE_FILES:=LICENCE
+PKG_CPE_ID:=cpe:/a:pcre:pcre2
+
+PKG_CONFIG_DEPENDS:=\
+	CONFIG_PACKAGE_libpcre2-16 \
+	CONFIG_PACKAGE_libpcre2-32 \
+	CONFIG_PCRE2_JIT_ENABLED
+
+PKG_BUILD_DEPENDS:=zlib
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/libpcre2/default
+  SECTION:=libs
+  CATEGORY:=Libraries
+  URL:=https://www.pcre.org/
+endef
+
+define Package/libpcre2/config
+  source "$(SOURCE)/Config.in"
+endef
+
+define Package/libpcre2
+  $(call Package/libpcre2/default)
+  TITLE:=A Perl Compatible Regular Expression library
+endef
+
+define Package/libpcre2-16
+  $(call Package/libpcre2/default)
+  TITLE:=A Perl Compatible Regular Expression library (16bit support)
+endef
+
+define Package/libpcre2-32
+  $(call Package/libpcre2/default)
+  TITLE:=A Perl Compatible Regular Expression library (32bit support)
+endef
+
+CMAKE_HOST_OPTIONS += \
+	-DBUILD_SHARED_LIBS=OFF \
+	-DPCRE2_BUILD_PCRE2_8=ON \
+	-DPCRE2_BUILD_PCRE2_16=ON \
+	-DPCRE2_BUILD_PCRE2_32=ON \
+	-DPCRE2_DEBUG=OFF \
+	-DPCRE2_DISABLE_PERCENT_ZT=ON \
+	-DPCRE2_SUPPORT_JIT=OFF \
+	-DPCRE2_SHOW_REPORT=OFF \
+	-DPCRE2_BUILD_PCRE2GREP=OFF \
+	-DPCRE2_BUILD_TESTS=OFF \
+	-DPCRE2_STATIC_PIC=ON
+
+CMAKE_OPTIONS += \
+	-DBUILD_SHARED_LIBS=ON \
+	-DPCRE2_BUILD_PCRE2_8=ON \
+	-DPCRE2_BUILD_PCRE2_16=O$(if $(CONFIG_PACKAGE_libpcre2-16),N,FF) \
+	-DPCRE2_BUILD_PCRE2_32=O$(if $(CONFIG_PACKAGE_libpcre2-32),N,FF) \
+	-DPCRE2_DEBUG=OFF \
+	-DPCRE2_DISABLE_PERCENT_ZT=ON \
+	-DPCRE2_SUPPORT_JIT=O$(if $(CONFIG_PCRE2_JIT_ENABLED),N,FF) \
+	-DPCRE2_SHOW_REPORT=OFF \
+	-DPCRE2_BUILD_PCRE2GREP=OFF \
+	-DPCRE2_BUILD_TESTS=OFF
+
+define Build/InstallDev
+	$(call Build/InstallDev/cmake,$(1))
+	$(SED) 	's,^\(prefix\|exec_prefix\)=.*,\1=$(STAGING_DIR)/usr,g' $(1)/usr/bin/pcre2-config
+	$(INSTALL_DIR) $(2)/bin
+	$(LN) ../../usr/bin/pcre2-config $(2)/bin/pcre2-config
+endef
+
+define Package/libpcre2/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcre2-{8,posix}.so* $(1)/usr/lib/
+endef
+
+define Package/libpcre2-16/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcre2-16.so* $(1)/usr/lib/
+endef
+
+define Package/libpcre2-32/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpcre2-32.so* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libpcre2))
+$(eval $(call BuildPackage,libpcre2-16))
+$(eval $(call BuildPackage,libpcre2-32))
+$(eval $(call HostBuild))
diff --git a/package/libs/popt/Makefile b/package/libs/popt/Makefile
new file mode 100644
index 0000000..ba9c823
--- /dev/null
+++ b/package/libs/popt/Makefile
@@ -0,0 +1,55 @@
+#
+# Copyright (C) 2006-2010 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:=popt
+PKG_VERSION:=1.19
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://ftp.rpm.org/popt/releases/popt-1.x/
+PKG_HASH:=c25a4838fc8e4c1c8aacb8bd620edb3084a3d63bf8987fdad3ca2758c63240f9
+PKG_LICENSE:=MIT
+PKG_CPE_ID:=cpe:/a:popt_project:popt
+
+PKG_FIXUP:=autoreconf
+PKG_REMOVE_FILES:=autogen.sh aclocal.m4
+
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+TARGET_CFLAGS += $(FPIC)
+
+define Package/libpopt
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=A command line option parsing library
+  URL:=https://github.com/rpm-software-management/popt
+  ABI_VERSION:=0
+endef
+
+CONFIGURE_ARGS += --enable-shared --enable-static
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/popt.h $(1)/usr/include/
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpopt.{a,so*} $(1)/usr/lib/
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/popt.pc $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libpopt/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libpopt.so.* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,libpopt))
+
diff --git a/package/libs/popt/patches/100-configure.ac-remove-require-gettext-version.patch b/package/libs/popt/patches/100-configure.ac-remove-require-gettext-version.patch
new file mode 100644
index 0000000..24ad076
--- /dev/null
+++ b/package/libs/popt/patches/100-configure.ac-remove-require-gettext-version.patch
@@ -0,0 +1,26 @@
+From 19d21b2d9e5aea5f73b1709b3c7803f920471146 Mon Sep 17 00:00:00 2001
+From: Nick Hainke <vincent@systemli.org>
+Date: Sun, 25 Sep 2022 11:52:29 +0200
+Subject: [PATCH] configure.ac: remove require gettext version
+
+This breaks compilation with OpenWrt:
+./configure: line 13059: syntax error near unexpected token `0.19.8'
+./configure: line 13059: `AM_GNU_GETTEXT_REQUIRE_VERSION(0.19.8)'
+
+Fixes: bf8dd64e8aa0 ("Update gettext autoconf usage")
+
+Signed-off-by: Nick Hainke <vincent@systemli.org>
+---
+ configure.ac | 1 -
+ 1 file changed, 1 deletion(-)
+
+--- a/configure.ac
++++ b/configure.ac
+@@ -53,7 +53,6 @@ AC_SEARCH_LIBS([setreuid], [ucb])
+ AC_CHECK_FUNCS([getuid geteuid iconv mtrace secure_getenv __secure_getenv setreuid setuid stpcpy strerror vasprintf srandom glob_pattern_p mbsrtowcs])
+ 
+ AM_GNU_GETTEXT_VERSION([0.19.8])
+-AM_GNU_GETTEXT_REQUIRE_VERSION([0.19.8])
+ AM_GNU_GETTEXT([external])
+ AM_ICONV_LINK
+ 
diff --git a/package/libs/readline/Makefile b/package/libs/readline/Makefile
new file mode 100644
index 0000000..03e56f3
--- /dev/null
+++ b/package/libs/readline/Makefile
@@ -0,0 +1,76 @@
+#
+# Copyright (C) 2006-2014 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:=readline
+PKG_VERSION:=8.2
+PKG_RELEASE:=2
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@GNU/readline
+PKG_HASH:=3feb7171f16a84ee82ca18a36d7b9be109a52c04f492a053331d7d1095007c35
+
+PKG_LICENSE:=GPL-3.0-or-later
+PKG_LICENSE_FILES:=COPYING
+PKG_CPE_ID:=cpe:/a:gnu:readline
+
+PKG_BUILD_PARALLEL:=1
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/host-build.mk
+
+HOST_BUILD_DEPENDS:=ncurses/host
+
+define Package/libreadline
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=Command lines edition library
+  DEPENDS:=+libncursesw
+  URL:=http://cnswww.cns.cwru.edu/php/chet/readline/rltop.html
+  ABI_VERSION:=8
+endef
+
+define Package/libreadline/description
+	The Readline library provides a set of functions for use by applications
+	that allow users to edit command lines as they are typed in. Both Emacs
+	and vi editing modes are available. The Readline library includes
+	additional functions to maintain a list of previously-entered command
+	lines, to recall and perhaps reedit those lines, and perform csh-like
+	history expansion on previous commands.
+endef
+
+HOST_CONFIGURE_ARGS += --disable-shared --with-pic
+CONFIGURE_ARGS += --with-curses --disable-install-examples
+
+HOST_CONFIGURE_VARS += \
+	bash_cv_termcap_lib=libncurses
+
+CONFIGURE_VARS += \
+	bash_cv_wcwidth_broken=no \
+	bash_cv_func_sigsetjmp=yes \
+	bash_cv_termcap_lib=libncursesw
+
+TARGET_CFLAGS += $(FPIC)
+HOST_CFLAGS += $(FPIC)
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/readline $(1)/usr/include/
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{history,readline}.{a,so*} $(1)/usr/lib/
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/readline.pc $(1)/usr/lib/pkgconfig/
+endef
+
+define Package/libreadline/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/lib{history,readline}.so* $(1)/usr/lib/
+endef
+
+$(eval $(call HostBuild))
+$(eval $(call BuildPackage,libreadline))
diff --git a/package/libs/readline/patches/001-curses-link.patch b/package/libs/readline/patches/001-curses-link.patch
new file mode 100644
index 0000000..dc18931
--- /dev/null
+++ b/package/libs/readline/patches/001-curses-link.patch
@@ -0,0 +1,16 @@
+link readline directly to ncurses since it needs symbols from it
+
+upstream readline does this on purpose (no direct linking), but
+it doesn't make much sense in a Linux world
+
+--- a/support/shobj-conf
++++ b/support/shobj-conf
+@@ -42,7 +42,7 @@ SHOBJ_XLDFLAGS=
+ SHOBJ_LIBS=
+ 
+ SHLIB_XLDFLAGS=
+-SHLIB_LIBS=
++SHLIB_LIBS=-lncurses
+ 
+ SHLIB_DOT='.'
+ SHLIB_LIBPREF='lib'
diff --git a/package/libs/readline/patches/010-ncursesw-first.patch b/package/libs/readline/patches/010-ncursesw-first.patch
new file mode 100644
index 0000000..d66cc04
--- /dev/null
+++ b/package/libs/readline/patches/010-ncursesw-first.patch
@@ -0,0 +1,20 @@
+--- a/configure
++++ b/configure
+@@ -7305,6 +7305,9 @@ TERMCAP_DEP=
+ elif test $bash_cv_termcap_lib = libncurses; then
+ TERMCAP_LIB=-lncurses
+ TERMCAP_DEP=
++elif test $bash_cv_termcap_lib = libncursesw; then
++TERMCAP_LIB=-lncursesw
++TERMCAP_DEP=
+ elif test $bash_cv_termcap_lib = libc; then
+ TERMCAP_LIB=
+ TERMCAP_DEP=
+@@ -7340,6 +7343,7 @@ case "$TERMCAP_LIB" in
+ -ltinfo)  TERMCAP_PKG_CONFIG_LIB=tinfo ;;
+ -lcurses) TERMCAP_PKG_CONFIG_LIB=ncurses ;;
+ -lncurses) TERMCAP_PKG_CONFIG_LIB=ncurses ;;
++-lncursesw) TERMCAP_PKG_CONFIG_LIB=ncursesw ;;
+ -ltermcap) TERMCAP_PKG_CONFIG_LIB=termcap ;;
+ *) TERMCAP_PKG_CONFIG_LIB=termcap ;;
+ esac
diff --git a/package/libs/sysfsutils/Makefile b/package/libs/sysfsutils/Makefile
new file mode 100644
index 0000000..61dbc6e
--- /dev/null
+++ b/package/libs/sysfsutils/Makefile
@@ -0,0 +1,88 @@
+#
+# Copyright (C) 2006-2012 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:=sysfsutils
+PKG_VERSION:=2.1.0
+PKG_RELEASE:=4
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=@SF/linux-diag
+PKG_HASH:=e865de2c1f559fff0d3fc936e660c0efaf7afe662064f2fb97ccad1ec28d208a
+PKG_MAINTAINER:=Jo-Philipp Wich <jo@mein.io>
+PKG_CPE_ID:=cpe:/a:sysfsutils_project:sysfsutils
+
+PKG_LICENSE:=LGPL-2.1
+PKG_LICENSE_FILES:=COPYING cmd/GPL lib/LGPL
+
+PKG_FIXUP:=autoreconf
+
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=0
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/libsysfs
+  SECTION:=libs
+  CATEGORY:=Libraries
+  SUBMENU:=Filesystem
+  TITLE:=Sysfs library
+  URL:=http://linux-diag.sourceforge.net/Sysfsutils.html
+  ABI_VERSION:=2
+endef
+
+define Package/sysfsutils
+  SECTION:=utils
+  CATEGORY:=Utilities
+  SUBMENU:=Filesystem
+  DEPENDS:=+libsysfs
+  TITLE:=System Utilities Based on Sysfs
+  URL:=http://linux-diag.sourceforge.net/Sysfsutils.html
+endef
+
+define Package/libsysfs/description
+The library's purpose is to provide a consistant and stable interface for
+querying system device information exposed through sysfs.
+endef
+
+define Package/sysfsutils/description
+A utility built upon libsysfs that lists devices by bus, class, and topology.
+endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/sysfs $(1)/usr/include/
+
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libsysfs.{a,so*,la} $(1)/usr/lib/
+endef
+
+define Package/libsysfs/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libsysfs.so.* $(1)/usr/lib/
+endef
+
+define Package/sysfsutils/install
+	$(INSTALL_DIR) $(1)/etc/init.d
+	$(INSTALL_BIN) ./files/sysfsutils $(1)/etc/init.d/
+
+	$(INSTALL_DATA) ./files/sysfs.conf $(1)/etc/
+	$(INSTALL_DIR) $(1)/etc/sysfs.d
+	$(INSTALL_DATA) ./files/local.conf $(1)/etc/sysfs.d/
+
+	$(INSTALL_DIR) $(1)/usr/bin
+	$(CP) $(PKG_INSTALL_DIR)/usr/bin/systool $(1)/usr/bin/
+endef
+
+define Package/sysfsutils/conffiles
+/etc/sysfs.conf
+/etc/sysfs.d/local.conf
+endef
+
+$(eval $(call BuildPackage,libsysfs))
+$(eval $(call BuildPackage,sysfsutils))
diff --git a/package/libs/sysfsutils/files/local.conf b/package/libs/sysfsutils/files/local.conf
new file mode 100644
index 0000000..891da73
--- /dev/null
+++ b/package/libs/sysfsutils/files/local.conf
@@ -0,0 +1 @@
+# local sysctl settings can be stored in this directory
diff --git a/package/libs/sysfsutils/files/sysfs.conf b/package/libs/sysfsutils/files/sysfs.conf
new file mode 100644
index 0000000..f032462
--- /dev/null
+++ b/package/libs/sysfsutils/files/sysfs.conf
@@ -0,0 +1,22 @@
+#
+# /etc/sysfs.conf - Configuration file for setting sysfs attributes.
+#
+# The sysfs mount directory is automatically prepended to the attribute paths.
+#
+# Syntax:
+# attribute = value
+# mode attribute = 0600 # (any valid argument for chmod)
+# owner attribute = root:wheel # (any valid argument for chown)
+#
+# Examples:
+#
+# Always use the powersave CPU frequency governor
+# devices/system/cpu/cpu0/cpufreq/scaling_governor = powersave
+#
+# Use userspace CPU frequency governor and set initial speed
+# devices/system/cpu/cpu0/cpufreq/scaling_governor = userspace
+# devices/system/cpu/cpu0/cpufreq/scaling_setspeed = 600000
+#
+# Set permissions of suspend control file
+# mode power/state = 0660
+# owner power/state = root:power
diff --git a/package/libs/sysfsutils/files/sysfsutils b/package/libs/sysfsutils/files/sysfsutils
new file mode 100644
index 0000000..3c5b35e
--- /dev/null
+++ b/package/libs/sysfsutils/files/sysfsutils
@@ -0,0 +1,49 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2017 Rodolfo Giometti <giometti@enneenne.com>
+#
+# Based on Debian's script /etc/init.d/sysfsutils by
+# Martin Pitt <mpitt@debian.org>
+
+START=11
+
+load_conffile() {
+	FILE="$1"
+	sed  's/#.*$//; /^[[:space:]]*$/d;
+	  s/^[[:space:]]*\([^=[:space:]]*\)[[:space:]]*\([^=[:space:]]*\)[[:space:]]*=[[:space:]]*\(.*\)/\1 \2 \3/' \
+	  $FILE | {
+	while read f1 f2 f3; do
+		if [ "$f1" = "mode" -a -n "$f2" -a -n "$f3" ]; then
+			if [ -f "/sys/$f2" ] || [ -d "/sys/$f2" ]; then
+				chmod "$f3" "/sys/$f2"
+			else
+				echo "unknown attribute $f2"
+			fi
+		elif [ "$f1" = "owner" -a -n "$f2" -a -n "$f3" ]; then
+			if [ -f "/sys/$f2" ]; then
+				chown "$f3" "/sys/$f2"
+			else
+				echo "unknown attribute $f2"
+			fi
+		elif [ "$f1" -a -n "$f2" -a -z "$f3" ]; then
+			if [ -f "/sys/$f1" ]; then
+				# Some fields need a terminating newline, others
+				# need the terminating newline to be absent :-(
+				echo -n "$f2" > "/sys/$f1" 2>/dev/null ||
+					echo "$f2" > "/sys/$f1"
+			else
+				echo "unknown attribute $f1"
+			fi
+		else
+			echo "syntax error in $CONFFILE: '$f1' '$f2' '$f3'"
+			exit 1
+		fi
+	done
+	}
+}
+
+start() {
+	for file in /etc/sysfs.conf /etc/sysfs.d/*.conf; do
+		[ -r "$file" ] || continue
+		load_conffile "$file"
+	done
+}
diff --git a/package/libs/sysfsutils/patches/200-mnt_path_check.patch b/package/libs/sysfsutils/patches/200-mnt_path_check.patch
new file mode 100644
index 0000000..8710578
--- /dev/null
+++ b/package/libs/sysfsutils/patches/200-mnt_path_check.patch
@@ -0,0 +1,55 @@
+--- a/lib/sysfs_utils.c
++++ b/lib/sysfs_utils.c
+@@ -22,6 +22,7 @@
+  */
+ #include "libsysfs.h"
+ #include "sysfs.h"
++#include <mntent.h>
+ 
+ /**
+  * sysfs_remove_trailing_slash: Removes any trailing '/' in the given path
+@@ -53,6 +54,9 @@ int sysfs_get_mnt_path(char *mnt_path, s
+ {
+ 	static char sysfs_path[SYSFS_PATH_MAX] = "";
+ 	const char *sysfs_path_env;
++	FILE *mnt;
++	struct mntent *mntent;
++	int ret;
+ 
+ 	if (len == 0 || mnt_path == NULL)
+ 		return -1;
+@@ -64,12 +68,31 @@ int sysfs_get_mnt_path(char *mnt_path, s
+ 		if (sysfs_path_env != NULL) {
+ 			safestrcpymax(mnt_path, sysfs_path_env, len);
+ 			sysfs_remove_trailing_slash(mnt_path);
+-			return 0;
++		} else {
++			safestrcpymax(mnt_path, SYSFS_MNT_PATH, len);
+ 		}
+-		safestrcpymax(mnt_path, SYSFS_MNT_PATH, len);
+ 	}
+ 
+-	return 0;
++	/* check that mount point is indeed mounted */
++	ret = -1;
++	if ((mnt = setmntent(SYSFS_PROC_MNTS, "r")) == NULL) {
++		dprintf("Error getting mount information\n");
++		return -1;
++	}
++	while ((mntent = getmntent(mnt)) != NULL) {
++		if (strcmp(mntent->mnt_type, SYSFS_FSTYPE_NAME) == 0 &&
++			strcmp(mntent->mnt_dir, mnt_path) == 0) {
++			ret = 0;
++			break;
++		}
++	}
++	
++	endmntent(mnt);
++
++	if (ret < 0)
++		errno = ENOENT;
++
++	return ret;
+ }
+ 
+ /**
diff --git a/package/libs/toolchain/Makefile b/package/libs/toolchain/Makefile
new file mode 100644
index 0000000..764fa2f
--- /dev/null
+++ b/package/libs/toolchain/Makefile
@@ -0,0 +1,809 @@
+#
+# Copyright (C) 2007-2014 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:=toolchain
+PKG_RELEASE:=4
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
+PKG_LICENSE:=GPL-3.0-with-GCC-exception
+
+PKG_FLAGS:=hold essential nonshared
+
+include $(INCLUDE_DIR)/package.mk
+
+ifneq ($(DUMP),1)
+  LIBGCC_VERSION:=$(GCC_VERSION)
+else
+  LIBC_VERSION:=<LIBC_VERSION>
+  LIBGCC_VERSION:=<LIBGCC_VERSION>
+endif
+
+define Package/gcc/Default
+  SECTION:=libs
+  CATEGORY:=Base system
+  URL:=http://gcc.gnu.org/
+  VERSION:=$(LIBGCC_VERSION)-r$(PKG_RELEASE)
+endef
+
+define Package/libgcc
+$(call Package/gcc/Default)
+  TITLE:=GCC support library
+  ABI_VERSION:=1
+endef
+
+define Package/libgcc/config
+	menu "Configuration"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
+
+	config LIBGCC_ROOT_DIR
+		string
+		prompt "libgcc shared library base directory"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
+		default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
+		default "/"  if NATIVE_TOOLCHAIN
+
+	config LIBGCC_FILE_SPEC
+		string
+		prompt "libgcc shared library files (use wildcards)"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgcc
+		default "./lib/libgcc_s.so.*"
+
+	endmenu
+endef
+
+define Package/libatomic
+$(call Package/gcc/Default)
+  DEPENDS:=+libgcc
+  TITLE:=Atomic support library
+  ABI_VERSION:=1
+endef
+
+define Package/libatomic/config
+	menu "Configuration"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libatomic
+
+	config LIBATOMIC_ROOT_DIR
+		string
+		prompt "libatomic shared library base directory"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libatomic
+		default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
+		default "/"  if NATIVE_TOOLCHAIN
+
+	config LIBATOMIC_FILE_SPEC
+		string
+		prompt "libatomic shared library files (use wildcards)"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libatomic
+		default "./lib/libatomic.so.*"
+
+	endmenu
+endef
+
+define Package/libquadmath
+$(call Package/gcc/Default)
+  DEPENDS:=@TARGET_x86||TARGET_x86_64 +libgcc
+  TITLE:=Quadmath support library
+  ABI_VERSION:=1
+endef
+
+define Package/libquadmath/config
+	menu "Configuration"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libquadmath
+
+	config LIBQUADMATH_ROOT_DIR
+		string
+		prompt "libquadmath shared library base directory"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libquadmath
+		default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
+		default "/"  if NATIVE_TOOLCHAIN
+
+	config LIBQUADMATH_FILE_SPEC
+		string
+		prompt "libquadmath shared library files (use wildcards)"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libquadmath
+		default "./lib/libquadmath.so.*"
+
+	endmenu
+endef
+
+define Package/libstdcpp
+$(call Package/gcc/Default)
+  NAME:=libstdc++
+  TITLE:=GNU Standard C++ Library v3
+  ABI_VERSION:=6
+endef
+
+define Package/libstdcpp/config
+	menu "Configuration"
+	depends on EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
+
+	config LIBSTDCPP_ROOT_DIR
+		string
+		prompt "libstdcpp shared library base directory"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
+		default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
+		default "/"  if NATIVE_TOOLCHAIN
+
+	config LIBSTDCPP_FILE_SPEC
+		string
+		prompt "libstdc++ shared library files (use wildcards)"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libstdcpp
+		default "./lib/libstdc++.so.*"
+
+	endmenu
+endef
+
+
+define Package/libasan
+$(call Package/gcc/Default)
+  NAME:=libasan
+  TITLE:=Runtime library for AddressSanitizer in GCC
+  DEPENDS:=@USE_GLIBC +librt +libstdcpp @!mips64 @!mips64el @!arc
+  ABI_VERSION:=5
+endef
+
+define Package/libasan/config
+	menu "Configuration"
+	depends on EXTERNAL_TOOLCHAIN && PACKAGE_libasan
+
+	config LIBASAN_ROOT_DIR
+		string
+		prompt "libasan shared library base directory"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libasan
+		default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
+		default "/"  if NATIVE_TOOLCHAIN
+
+	config LIBASAN_FILE_SPEC
+		string
+		prompt "libasan shared library files (use wildcards)"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libasan
+		default "./lib/libasan.so.*"
+
+	endmenu
+endef
+
+
+define Package/libtsan
+$(call Package/gcc/Default)
+  NAME:=libtsan
+  TITLE:=Runtime library for ThreadSanitizer in GCC
+  DEPENDS:=@USE_GLIBC +librt +libstdcpp @!loongarch64 @!mips @!mipsel @!mips64 @!mips64el @!arc
+  ABI_VERSION:=0
+endef
+
+define Package/libtsan/config
+	menu "Configuration"
+	depends on EXTERNAL_TOOLCHAIN && PACKAGE_libtsan
+
+	config LIBTSAN_ROOT_DIR
+		string
+		prompt "libtsan shared library base directory"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libtsan
+		default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
+		default "/"  if NATIVE_TOOLCHAIN
+
+	config LIBTSAN_FILE_SPEC
+		string
+		prompt "libtsan shared library files (use wildcards)"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libtsan
+		default "./lib/libtsan.so.*"
+
+	endmenu
+endef
+
+
+define Package/liblsan
+$(call Package/gcc/Default)
+  NAME:=liblsan
+  TITLE:=Runtime library for LeakSanitizer in GCC
+  DEPENDS:=@USE_GLIBC +librt +libstdcpp @!loongarch64 @!mips @!mipsel @!mips64 @!mips64el @!arc
+  ABI_VERSION:=0
+endef
+
+define Package/liblsan/config
+	menu "Configuration"
+	depends on EXTERNAL_TOOLCHAIN && PACKAGE_liblsan
+
+	config LIBLSAN_ROOT_DIR
+		string
+		prompt "liblsan shared library base directory"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_liblsan
+		default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
+		default "/"  if NATIVE_TOOLCHAIN
+
+	config LIBLSAN_FILE_SPEC
+		string
+		prompt "liblsan shared library files (use wildcards)"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_liblsan
+		default "./lib/liblsan.so.*"
+
+	endmenu
+endef
+
+
+define Package/libubsan
+$(call Package/gcc/Default)
+  NAME:=libubsan
+  TITLE:=Runtime library for UndefinedBehaviorSanitizer in GCC
+  DEPENDS:=@USE_GLIBC +librt +libstdcpp @!mips64 @!mips64el @!arc
+  ABI_VERSION:=1
+endef
+
+define Package/libubsan/config
+	menu "Configuration"
+	depends on EXTERNAL_TOOLCHAIN && PACKAGE_libubsan
+
+	config LIBUBSAN_ROOT_DIR
+		string
+		prompt "libubsan shared library base directory"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libubsan
+		default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
+		default "/"  if NATIVE_TOOLCHAIN
+
+	config LIBUBSAN_FILE_SPEC
+		string
+		prompt "libubsan shared library files (use wildcards)"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libubsan
+		default "./lib/libubsan.so.*"
+
+	endmenu
+endef
+
+
+define Package/libc/Default
+  SECTION:=libs
+  CATEGORY:=Base system
+  VERSION:=$(LIBC_VERSION)-r$(PKG_RELEASE)
+  DEPENDS:=+libgcc
+  URL:=$(LIBC_URL)
+endef
+
+
+define Package/libc
+$(call Package/libc/Default)
+  TITLE:=C library
+endef
+
+define Package/libc/config
+	menu "Configuration"
+	depends on EXTERNAL_TOOLCHAIN && PACKAGE_libc
+
+	config LIBC_ROOT_DIR
+		string
+		prompt "libc shared library base directory"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libc
+		default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
+		default "/"  if NATIVE_TOOLCHAIN
+
+	config LIBC_FILE_SPEC
+		string
+		prompt "libc shared library files (use wildcards)"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libc
+		default "./lib/ld{*.so*,-linux*.so.*} ./lib/lib{anl,c,cidn,crypt,dl,m,nsl,nss_dns,nss_files,resolv,util}{-*.so,.so.*,.so}"
+
+	endmenu
+endef
+
+
+define Package/libpthread
+$(call Package/libc/Default)
+  TITLE:=POSIX thread library
+endef
+
+define Package/libpthread/config
+	menu "Configuration"
+	depends on EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
+
+	config LIBPTHREAD_ROOT_DIR
+		string
+		prompt "libpthread shared library base directory"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
+		default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
+		default "/"  if NATIVE_TOOLCHAIN
+
+	config LIBPTHREAD_FILE_SPEC
+		string
+		prompt "libpthread shared library files (use wildcards)"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libpthread
+		default "./lib/libpthread{-*.so,.so.*}"
+
+	endmenu
+endef
+
+
+define Package/libthread-db
+$(call Package/libc/Default)
+  DEPENDS:=@!USE_MUSL
+  TITLE:=POSIX thread library debugging support
+endef
+
+define Package/libthread-db/config
+	menu "Configuration"
+	depends on EXTERNAL_TOOLCHAIN && PACKAGE_libthread-db
+
+	config LIBTHREAD_DB_ROOT_DIR
+		string
+		prompt "POSIX thread debugging shared library base directory"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libthread-db
+		default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
+		default "/"  if NATIVE_TOOLCHAIN
+
+	config LIBTHREAD_DB_FILE_SPEC
+		string
+		prompt "POSIX thread debugging shared library files (use wildcards)"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libthread-db
+		default "./lib/libthread_db{-*.so,.so.*}"
+
+	endmenu
+endef
+
+define Package/librt
+$(call Package/libc/Default)
+  TITLE:=POSIX.1b RealTime extension library
+  DEPENDS:=+libpthread
+endef
+
+define Package/librt/config
+	menu "Configuration"
+	depends on EXTERNAL_TOOLCHAIN && PACKAGE_librt
+
+	config LIBRT_ROOT_DIR
+		string
+		prompt "librt shared library base directory"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_librt
+		default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
+		default "/"  if NATIVE_TOOLCHAIN
+
+	config LIBRT_FILE_SPEC
+		string
+		prompt "librt shared library files (use wildcards)"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_librt
+		default "./lib/librt{-*.so,.so.*}"
+
+	endmenu
+endef
+
+
+define Package/libgfortran
+$(call Package/gcc/Default)
+  TITLE:=GFortran support library
+  DEPENDS+=@INSTALL_GFORTRAN
+endef
+
+define Package/libgfortran/config
+	menu "Configuration"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
+
+	config LIBGFORTRAN_ROOT_DIR
+		string
+		prompt "libgfortran shared library base directory"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
+		default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
+		default "/"  if NATIVE_TOOLCHAIN
+
+	config LIBGFORTRAN_FILE_SPEC
+		string
+		prompt "libgfortran shared library files (use wildcards)"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgfortran
+		default "./usr/lib/libgfortran.so.*"
+
+	endmenu
+endef
+
+define Package/libgomp
+$(call Package/gcc/Default)
+  TITLE:=OpenMP support library
+endef
+
+define Package/libgomp/config
+	menu "Configuration"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgomp
+
+	config LIBGOMP_ROOT_DIR
+		string
+		prompt "libgomp shared library base directory"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgomp
+		default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
+		default "/"  if NATIVE_TOOLCHAIN
+
+	config LIBGOMP_FILE_SPEC
+		string
+		prompt "libgomp shared library files (use wildcards)"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_libgomp
+		default "./lib/libgomp.so*"
+
+	endmenu
+endef
+
+
+define Package/ldd
+$(call Package/libc/Default)
+  DEPENDS:=@!USE_MUSL
+  SECTION:=utils
+  CATEGORY:=Utilities
+  TITLE:=LDD trace utility
+endef
+
+define Package/ldd/config
+	menu "Configuration"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_ldd
+
+	config LDD_ROOT_DIR
+		string
+		prompt "ldd trace utility base directory"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_ldd
+		default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
+		default "/"  if NATIVE_TOOLCHAIN
+
+	config LDD_FILE_SPEC
+		string
+		prompt "ldd trace utility file"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_ldd
+		default "./usr/bin/ldd"
+
+	endmenu
+endef
+
+
+define Package/ldconfig
+$(call Package/libc/Default)
+  DEPENDS:=@!USE_MUSL
+  SECTION:=utils
+  CATEGORY:=Utilities
+  TITLE:=Shared library path configuration
+endef
+
+define Package/ldconfig/config
+	menu "Configuration"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
+
+	config LDCONFIG_ROOT_DIR
+		string
+		prompt "ldconfig base directory"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
+		default TOOLCHAIN_ROOT  if !NATIVE_TOOLCHAIN
+		default "/"  if NATIVE_TOOLCHAIN
+
+	config LDCONFIG_FILE_SPEC
+		string
+		prompt "ldconfig file"
+		depends on EXTERNAL_TOOLCHAIN && PACKAGE_ldconfig
+		default "./sbin/ldconfig"
+
+	endmenu
+endef
+
+define Build/Prepare
+	mkdir -p $(PKG_BUILD_DIR)
+endef
+
+define Build/Quilt
+endef
+
+LIBGCC_A=$(lastword $(wildcard $(TOOLCHAIN_DIR)/lib/gcc/*/*/libgcc_pic.a))
+LIBGCC_MAP=$(lastword $(wildcard $(TOOLCHAIN_DIR)/lib/gcc/*/*/libgcc.map))
+LIBGCC_SO=$(lastword $(wildcard $(TOOLCHAIN_DIR)/lib/libgcc_s.so.*))
+
+ifneq ($(LIBGCC_SO),)
+    define Build/Compile/libgcc
+	$(CP) $(LIBGCC_SO) $(PKG_BUILD_DIR)/
+    endef
+endif
+
+define Build/Compile/Default
+	$(call Build/Compile/libgcc)
+	$(call Build/Compile/$(LIBC))
+endef
+Build/Compile = $(Build/Compile/Default)
+
+ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
+
+  define Package/libgcc/install
+	$(INSTALL_DIR) $(1)/lib
+	$(CP) $(TOOLCHAIN_DIR)/lib/libgcc_s.so.* $(1)/lib/
+  endef
+
+  define Package/libatomic/install
+	$(INSTALL_DIR) $(1)/lib
+	$(CP) $(TOOLCHAIN_DIR)/lib/libatomic.so.* $(1)/lib/
+  endef
+
+  define Package/libquadmath/install
+	$(INSTALL_DIR) $(1)/lib
+	$(CP) $(TOOLCHAIN_DIR)/lib/libquadmath.so.* $(1)/lib/
+  endef
+
+  define Package/libgfortran/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(TOOLCHAIN_DIR)/lib/libgfortran.so.* $(1)/usr/lib/
+  endef
+
+  define Package/libstdcpp/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(TOOLCHAIN_DIR)/lib/libstdc++.so.* $(1)/usr/lib/
+	rm -rf $(1)/usr/lib/*-gdb.py
+  endef
+
+  define Package/libasan/install
+	$(INSTALL_DIR) $(1)/lib
+	$(CP) $(TOOLCHAIN_DIR)/lib/libasan.so.* $(1)/lib/
+  endef
+
+  define Package/libtsan/install
+	$(INSTALL_DIR) $(1)/lib
+	$(CP) $(TOOLCHAIN_DIR)/lib/libtsan.so.* $(1)/lib/
+  endef
+
+  define Package/liblsan/install
+	$(INSTALL_DIR) $(1)/lib
+	$(CP) $(TOOLCHAIN_DIR)/lib/liblsan.so.* $(1)/lib/
+  endef
+
+  define Package/libubsan/install
+	$(INSTALL_DIR) $(1)/lib
+	$(CP) $(TOOLCHAIN_DIR)/lib/libubsan.so.* $(1)/lib/
+  endef
+
+  define Package/glibc/install
+	$(CP) ./glibc-files/* $(1)/
+	rm -f $(1)/etc/localtime
+	$(INSTALL_DIR) $(1)/lib
+	mkdir -p $(BIN_DIR)/symbol/libs/glibc/lib
+	$(CP) \
+		$(TOOLCHAIN_DIR)/lib/ld*.so.* \
+		$(BIN_DIR)/symbol/libs/glibc/lib/
+	$(CP) \
+		$(TOOLCHAIN_DIR)/lib/ld*.so.* \
+		$(1)/lib/
+	for file in libanl libc libcidn libcrypt libdl libm libnsl libnss_dns libnss_files libresolv libutil; do \
+		for file in $(TOOLCHAIN_DIR)/lib/$$$$file.so.*; do \
+			if [ -e "$$$$file" ]; then \
+				$(CP) $$$$file $(1)/lib/; \
+				$(CP) $$$$file $(BIN_DIR)/symbol/libs/glibc/lib/; \
+			fi; \
+		done; \
+	done
+  endef
+
+  LD_MUSL_NAME = $(notdir $(firstword $(wildcard $(TOOLCHAIN_DIR)/lib/libc.so*)))
+
+  define Package/musl/install
+	$(INSTALL_DIR) $(1)/lib $(1)/usr/bin
+	$(CP) \
+		$(TOOLCHAIN_DIR)/lib/ld-musl-*.so* \
+		$(1)/lib/
+	$(CP) \
+		$(TOOLCHAIN_DIR)/lib/libc.so* \
+		$(1)/lib/
+	$(LN) ../../lib/$(LD_MUSL_NAME) $(1)/usr/bin/ldd
+
+	mkdir -p $(BIN_DIR)/symbol/libs/musl/lib
+	$(CP) \
+		$(TOOLCHAIN_DIR)/lib/ld-musl-*.so* \
+		$(BIN_DIR)/symbol/libs/musl/lib/
+	$(CP) \
+		$(TOOLCHAIN_DIR)/lib/libc.so* \
+		$(BIN_DIR)/symbol/libs/musl/lib/
+  endef
+
+  define Package/libc/install
+    $(call Package/$(LIBC)/install,$1)
+  endef
+
+  define Package/libc/install_lib
+	$(CP) $(filter-out %/libdl_pic.a %/libpthread_pic.a %/libresolv_pic.a,$(wildcard $(TOOLCHAIN_DIR)/lib/lib*.a)) $(1)/lib/
+	$(if $(wildcard $(TOOLCHAIN_DIR)/lib/libc_so.a),$(CP) $(TOOLCHAIN_DIR)/lib/libc_so.a $(1)/lib/libc_pic.a)
+	$(if $(LIBGCC_MAP), \
+		$(CP) $(LIBGCC_A) $(1)/lib/libgcc_s_pic.a; \
+		$(CP) $(LIBGCC_MAP) $(1)/lib/libgcc_s_pic.map \
+	)
+  endef
+
+  define Package/libpthread/install
+	$(INSTALL_DIR) $(1)/lib
+  ifneq ($(CONFIG_USE_MUSL),y)
+	$(CP) \
+		$(TOOLCHAIN_DIR)/lib/libpthread.so.* \
+		$(1)/lib/
+	mkdir -p $(BIN_DIR)/symbol/libs/libpthread/lib
+	$(CP) \
+		$(TOOLCHAIN_DIR)/lib/libpthread.so.* \
+		$(BIN_DIR)/symbol/libs/libpthread/lib/
+	
+  endif
+  endef
+
+  define Package/libthread-db/install
+	$(INSTALL_DIR) $(1)/lib
+	$(CP) \
+		$(TOOLCHAIN_DIR)/lib/libthread_db.so.* $(1)/lib
+  endef
+
+  define Package/libpthread/install_lib
+	$(if $(wildcard $(TOOLCHAIN_DIR)/lib/libpthread_so.a),$(CP) $(TOOLCHAIN_DIR)/lib/libpthread_so.a $(1)/lib/libpthread_pic.a)
+  endef
+
+  define Package/librt/install
+	$(INSTALL_DIR) $(1)/lib
+  ifneq ($(CONFIG_USE_MUSL),y)
+	$(CP) \
+		$(TOOLCHAIN_DIR)/lib/librt.so.* \
+		$(1)/lib/
+  endif
+  endef
+
+  define Package/ldd/install
+	$(INSTALL_DIR) $(1)/usr/bin/
+	$(CP) $(TOOLCHAIN_DIR)/bin/ldd $(1)/usr/bin/
+	sed -i 's,^#!.*,#!/bin/sh,' $(1)/usr/bin/ldd
+  endef
+
+  define Package/ldconfig/install
+	$(INSTALL_DIR) $(1)/sbin/
+	$(CP) $(TOOLCHAIN_DIR)/sbin/ldconfig $(1)/sbin/
+  endef
+
+else
+
+  define Package/libgcc/install
+	for file in $(call qstrip,$(CONFIG_LIBGCC_FILE_SPEC)); do \
+		$(INSTALL_DIR) $(1)/lib ; \
+		$(CP) $(call qstrip,$(CONFIG_LIBGCC_ROOT_DIR))/$$$$file $(1)/lib/ ; \
+	done ; \
+	exit 0
+  endef
+
+  define Package/libgfortran/install
+	for file in $(call qstrip,$(CONFIG_LIBGFORTRAN_FILE_SPEC)); do \
+		$(INSTALL_DIR) $(1)/lib ; \
+		$(CP) $(call qstrip,$(CONFIG_LIBGFORTRAN_ROOT_DIR))/$$$$file $(1)/lib/ ; \
+	done
+  endef
+
+  define Package/libstdcpp/install
+	for file in $(call qstrip,$(CONFIG_LIBSTDCPP_FILE_SPEC)); do \
+		$(INSTALL_DIR) $(1)/lib ; \
+		$(CP) $(call qstrip,$(CONFIG_LIBSTDCPP_ROOT_DIR))/$$$$file $(1)/lib/ ; \
+	done ; \
+	exit 0
+  endef
+
+  define Package/libasan/install
+	for file in $(call qstrip,$(CONFIG_LIBASAN_FILE_SPEC)); do \
+		$(INSTALL_DIR) $(1)/lib ; \
+		$(CP) $(call qstrip,$(CONFIG_LIBASAN_ROOT_DIR))/$$$$file $(1)/lib/ ; \
+	done ; \
+	exit 0
+  endef
+
+  define Package/libtsan/install
+	for file in $(call qstrip,$(CONFIG_LIBTSAN_FILE_SPEC)); do \
+		$(INSTALL_DIR) $(1)/lib ; \
+		$(CP) $(call qstrip,$(CONFIG_LIBTSAN_ROOT_DIR))/$$$$file $(1)/lib/ ; \
+	done ; \
+	exit 0
+  endef
+
+  define Package/liblsan/install
+	for file in $(call qstrip,$(CONFIG_LIBLSAN_FILE_SPEC)); do \
+		$(INSTALL_DIR) $(1)/lib ; \
+		$(CP) $(call qstrip,$(CONFIG_LIBLSAN_ROOT_DIR))/$$$$file $(1)/lib/ ; \
+	done ; \
+	exit 0
+  endef
+
+  define Package/libubsan/install
+	for file in $(call qstrip,$(CONFIG_LIBUBSAN_FILE_SPEC)); do \
+		$(INSTALL_DIR) $(1)/lib ; \
+		$(CP) $(call qstrip,$(CONFIG_LIBUBSAN_ROOT_DIR))/$$$$file $(1)/lib/ ; \
+	done ; \
+	exit 0
+  endef
+
+  define Package/glibc/install
+  endef
+
+  LD_MUSL_NAME = $(notdir $(firstword $(wildcard $(TOOLCHAIN_ROOT_DIR)/lib/libc.so*)))
+
+  define Package/musl/install
+	$(INSTALL_DIR) $(1)/usr/bin
+	$(LN) ../../lib/$(LD_MUSL_NAME) $(1)/usr/bin/ldd
+  endef
+
+  define Package/libc/install
+	for file in $(call qstrip,$(CONFIG_LIBC_FILE_SPEC)); do \
+		$(INSTALL_DIR) $(1)/lib ; \
+		$(CP) $(call qstrip,$(CONFIG_LIBC_ROOT_DIR))/$$$$file $(1)/lib/ ; \
+	done ; \
+	exit 0
+	$(call Package/$(LIBC)/install,$1)
+  endef
+
+  define Package/libpthread/install
+	for file in $(call qstrip,$(CONFIG_LIBPTHREAD_FILE_SPEC)); do \
+		$(INSTALL_DIR) $(1)/lib ; \
+		$(CP) $(call qstrip,$(CONFIG_LIBPTHREAD_ROOT_DIR))/$$$$file $(1)/lib/ ; \
+	done ; \
+	exit 0
+  endef
+
+  define Package/libthread-db/install
+	for file in $(call qstrip,$(CONFIG_LIBTHREAD_DB_FILE_SPEC)); do \
+		$(INSTALL_DIR) $(1)/lib ; \
+		$(CP) $(call qstrip,$(CONFIG_LIBTHREAD_DB_ROOT_DIR))/$$$$file $(1)/lib/ ; \
+	done ; \
+	exit 0
+  endef
+
+  define Package/librt/install
+	for file in $(call qstrip,$(CONFIG_LIBRT_FILE_SPEC)); do \
+		$(INSTALL_DIR) $(1)/lib ; \
+		$(CP) $(call qstrip,$(CONFIG_LIBRT_ROOT_DIR))/$$$$file $(1)/lib/ ; \
+	done ; \
+	exit 0
+  endef
+
+  define Package/libatomic/install
+	for file in $(call qstrip,$(CONFIG_LIBATOMIC_FILE_SPEC)); do \
+		$(INSTALL_DIR) $(1)/lib ; \
+		$(CP) $(call qstrip,$(CONFIG_LIBATOMIC_ROOT_DIR))/$$$$file $(1)/lib/ ; \
+	done ; \
+	exit 0
+  endef
+
+  define Package/libquadmath/install
+	for file in $(call qstrip,$(CONFIG_LIBQUADMATH_FILE_SPEC)); do \
+		$(INSTALL_DIR) $(1)/lib ; \
+		$(CP) $(call qstrip,$(CONFIG_LIBQUADMATH_ROOT_DIR))/$$$$file $(1)/lib/ ; \
+	done ; \
+	exit 0
+  endef
+
+  define Package/libgomp/install
+	for file in $(call qstrip,$(CONFIG_LIBGOMP_FILE_SPEC)); do \
+		$(INSTALL_DIR) $(1)/lib ; \
+		$(CP) $(call qstrip,$(CONFIG_LIBGOMP_ROOT_DIR))/$$$$file $(1)/lib/ ; \
+	done ; \
+	exit 0
+  endef
+
+  define Package/ldd/install
+	for file in $(call qstrip,$(CONFIG_LDD_FILE_SPEC)); do \
+		dir=`dirname $$$$file` ; \
+		$(INSTALL_DIR) $(1)/$$$$dir ; \
+		$(CP) $(call qstrip,$(CONFIG_LDD_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+	done ; \
+	exit 0
+  endef
+
+  define Package/ldconfig/install
+	for file in $(call qstrip,$(CONFIG_LDCONFIG_FILE_SPEC)); do \
+		dir=`dirname $$$$file` ; \
+		$(INSTALL_DIR) $(1)/$$$$dir ; \
+		$(CP) $(call qstrip,$(CONFIG_LDCONFIG_ROOT_DIR))/$$$$file $(1)/$$$$dir/ ; \
+	done ; \
+	exit 0
+  endef
+
+endif
+
+$(eval $(call BuildPackage,libc))
+$(eval $(call BuildPackage,libgcc))
+$(eval $(call BuildPackage,libatomic))
+$(eval $(call BuildPackage,libquadmath))
+$(eval $(call BuildPackage,libstdcpp))
+$(eval $(call BuildPackage,libasan))
+$(eval $(call BuildPackage,libtsan))
+$(eval $(call BuildPackage,liblsan))
+$(eval $(call BuildPackage,libubsan))
+$(eval $(call BuildPackage,libpthread))
+$(eval $(call BuildPackage,libthread-db))
+$(eval $(call BuildPackage,librt))
+$(eval $(call BuildPackage,libgfortran))
+$(eval $(call BuildPackage,libgomp))
+$(eval $(call BuildPackage,ldd))
+$(eval $(call BuildPackage,ldconfig))
diff --git a/package/libs/toolchain/glibc-files/etc/nsswitch.conf b/package/libs/toolchain/glibc-files/etc/nsswitch.conf
new file mode 100644
index 0000000..981c425
--- /dev/null
+++ b/package/libs/toolchain/glibc-files/etc/nsswitch.conf
@@ -0,0 +1,13 @@
+passwd:files
+shadow:files
+group:files
+hosts:dns files
+bootparams:files
+ethers:files
+netmasks:files
+networks:files
+protocols:files
+rpc:files
+services:files
+automount:files
+aliases:files
diff --git a/package/libs/tslib/Makefile b/package/libs/tslib/Makefile
new file mode 100644
index 0000000..3407e19
--- /dev/null
+++ b/package/libs/tslib/Makefile
@@ -0,0 +1,36 @@
+#
+# Copyright (C) 2009-2010 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:=tslib
+PKG_VERSION:=1.22
+
+PKG_SOURCE_URL:=https://github.com/libts/tslib/releases/download/$(PKG_VERSION)/
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
+PKG_BUILD_DIR=$(BUILD_DIR)/$(PKG_NAME)/$(PKG_NAME)-$(PKG_VERSION)/
+PKG_MD5SUM:=aa0f409d6f4a7ccdbeee9d869558d6ee
+
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/tslib
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=tslib
+  URL:=https://github.com/libts/tslib/
+endef
+
+define Package/tslib/install
+	$(INSTALL_DIR) $(1)/usr/lib/ $(1)/usr/bin $(1)/etc
+	$(CP) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin/
+	$(CP) $(PKG_INSTALL_DIR)/etc/* $(1)/etc
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/* $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,tslib))
diff --git a/package/libs/uclibc++/Makefile b/package/libs/uclibc++/Makefile
new file mode 100644
index 0000000..0e3210a
--- /dev/null
+++ b/package/libs/uclibc++/Makefile
@@ -0,0 +1,105 @@
+#
+# Copyright (C) 2006-2012 OpenWrt.org
+# Copyright (c) 2016 LEDE project
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=uclibc++
+PKG_VERSION:=0.2.5
+PKG_RELEASE:=3
+
+PKG_SOURCE:=uClibc++-$(PKG_VERSION).tar.xz
+PKG_SOURCE_URL:=https://cxx.uclibc.org/src/
+PKG_HASH:=596fb9ed7295564ce4c70ae6076a18f92e72f70310d70c98520bbca85c77895a
+PKG_BUILD_DIR:=$(BUILD_DIR)/uClibc++-$(PKG_VERSION)
+
+PKG_LICENSE:=LGPL-2.1-or-later
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+PKG_USE_MIPS16:=0
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/uclibcxx
+  NAME:=uclibc++
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=C++ library for embedded systems
+  URL:=https://cxx.uclibc.org/
+endef
+
+UCLIBC_TARGET_ARCH:=$(shell echo $(ARCH) | sed -e s'/-.*//' \
+	-e 's/i.86/i386/' \
+	-e 's/sparc.*/sparc/' \
+	-e 's/m68k.*/m68k/' \
+	-e 's/ppc/powerpc/g' \
+	-e 's/v850.*/v850/g' \
+	-e 's/sh64/sh/' \
+	-e 's/sh[234].*/sh/' \
+	-e 's/mips.*/mips/' \
+	-e 's/mipsel.*/mips/' \
+)
+
+TARGET_CFLAGS += $(FPIC) -nostdinc++ -std=c++11
+TARGET_LDFLAGS += -Wl,--gc-sections
+
+ifneq ($(CONFIG_CCACHE),)
+TARGET_CXX=$(TARGET_CXX_NOCACHE)
+endif
+
+ifeq ($(CONFIG_USE_MUSL),y)
+SSP_LIB=-lssp_nonshared
+endif
+
+ifeq (${V}, s)
+MAKE_VARS+= \
+	V=1
+else ifeq (${V}, sc)
+MAKE_VARS+= \
+	V=2
+endif
+
+MAKE_FLAGS:= \
+	$(TARGET_CONFIGURE_OPTS) \
+	CPU_CFLAGS="$(TARGET_CFLAGS)" \
+	CROSS_COMPILE="$(TARGET_CROSS)" \
+	LDFLAGS="$(TARGET_LDFLAGS)" \
+	GEN_LIBS="-lc $(LIBGCC_S) $(SSP_LIB)" \
+	check_as_needed=
+
+# check_as_needed overrides dependency on libgcc_s
+
+define Build/Configure
+	if [ -f ./files/config.$(UCLIBC_TARGET_ARCH) ]; then \
+		cp ./files/config.$(UCLIBC_TARGET_ARCH) $(PKG_BUILD_DIR)/.config; \
+	else \
+		cp ./files/config.default $(PKG_BUILD_DIR)/.config; \
+	fi
+endef
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(2)/bin $(1)/usr/include/uClibc++ $(1)/usr/lib
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/bin/g++-uc $(TOOLCHAIN_DIR)/bin/
+	$(CP) $(PKG_INSTALL_DIR)/include/* $(1)/usr/include/uClibc++/
+	$(CP) $(PKG_INSTALL_DIR)/lib/libuClibc++*.{a,so}* $(1)/usr/lib/
+	$(SED) 's!\(^\|[[:space:]]\)-[IL]$(TOOLCHAIN_DIR)/[^[:space:]]*!!g' $(TOOLCHAIN_DIR)/bin/g++-uc
+	$(SED) 's|-I/include/|-I$$$${STAGING_DIR:-$(STAGING_DIR)}/usr/include/uClibc++/|g' $(TOOLCHAIN_DIR)/bin/g++-uc
+	$(SED) 's|-L/lib/|-L$$$${STAGING_DIR:-$(STAGING_DIR)}/lib/|g' $(TOOLCHAIN_DIR)/bin/g++-uc
+# add another wrapper which links against both uClibc++ and libstdc++
+	$(INSTALL_BIN) $(TOOLCHAIN_DIR)/bin/g++-uc $(TOOLCHAIN_DIR)/bin/g++-uc+std
+	$(SED) 's|^WRAPPER_INCLUDEDIR=.*||g' $(TOOLCHAIN_DIR)/bin/g++-uc+std
+	$(SED) 's|-luClibc++|-Wl,-Bdynamic,-luClibc++,-Bstatic,-lstdc++,-Bdynamic|g' $(TOOLCHAIN_DIR)/bin/g++-uc+std
+	$(SED) 's|-nostdinc++||g' $(TOOLCHAIN_DIR)/bin/g++-uc+std
+endef
+
+define Package/uclibcxx/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/lib/libuClibc++.so.* $(1)/usr/lib/
+	$(CP) $(PKG_INSTALL_DIR)/lib/libuClibc++-*.so $(1)/usr/lib/
+endef
+
+$(eval $(call BuildPackage,uclibcxx))
diff --git a/package/libs/uclibc++/files/config.default b/package/libs/uclibc++/files/config.default
new file mode 100644
index 0000000..d76670e
--- /dev/null
+++ b/package/libs/uclibc++/files/config.default
@@ -0,0 +1,58 @@
+#
+# Automatically generated make config: don't edit
+#
+
+#
+# Target Features and Options
+#
+UCLIBCXX_HAS_FLOATS=y
+# UCLIBCXX_HAS_LONG_DOUBLE is not set
+# UCLIBCXX_HAS_TLS is not set
+UCLIBCXX_WARNINGS=""
+BUILD_EXTRA_LIBRARIES=""
+HAVE_DOT_CONFIG=y
+
+#
+# String and I/O Stream Support
+#
+UCLIBCXX_HAS_WCHAR=y
+UCLIBCXX_IOSTREAM_BUFSIZE=32
+UCLIBCXX_HAS_LFS=y
+UCLIBCXX_SUPPORT_CDIR=y
+UCLIBCXX_SUPPORT_CIN=y
+UCLIBCXX_SUPPORT_COUT=y
+UCLIBCXX_SUPPORT_CERR=y
+UCLIBCXX_SUPPORT_CLOG=y
+# UCLIBCXX_SUPPORT_WCIN is not set
+# UCLIBCXX_SUPPORT_WCOUT is not set
+# UCLIBCXX_SUPPORT_WCERR is not set
+# UCLIBCXX_SUPPORT_WCLOG is not set
+
+#
+# STL and Code Expansion
+#
+UCLIBCXX_STL_BUFFER_SIZE=32
+UCLIBCXX_CODE_EXPANSION=y
+UCLIBCXX_EXPAND_CONSTRUCTORS_DESTRUCTORS=y
+UCLIBCXX_EXPAND_STRING_CHAR=y
+UCLIBCXX_EXPAND_VECTOR_BASIC=y
+UCLIBCXX_EXPAND_IOS_CHAR=y
+UCLIBCXX_EXPAND_STREAMBUF_CHAR=y
+UCLIBCXX_EXPAND_ISTREAM_CHAR=y
+UCLIBCXX_EXPAND_OSTREAM_CHAR=y
+UCLIBCXX_EXPAND_FSTREAM_CHAR=y
+UCLIBCXX_EXPAND_SSTREAM_CHAR=y
+
+#
+# Library Installation Options
+#
+UCLIBCXX_RUNTIME_PREFIX=""
+UCLIBCXX_RUNTIME_INCLUDE_SUBDIR="/include"
+UCLIBCXX_RUNTIME_LIB_SUBDIR="/lib"
+UCLIBCXX_RUNTIME_BIN_SUBDIR="/bin"
+UCLIBCXX_EXCEPTION_SUPPORT=y
+IMPORT_LIBSUP=y
+# IMPORT_LIBGCC_EH is not set
+BUILD_STATIC_LIB=y
+# BUILD_ONLY_STATIC_LIB is not set
+# DODEBUG is not set
diff --git a/package/libs/uclibc++/patches/001-no-ansi.patch b/package/libs/uclibc++/patches/001-no-ansi.patch
new file mode 100644
index 0000000..7ddbf52
--- /dev/null
+++ b/package/libs/uclibc++/patches/001-no-ansi.patch
@@ -0,0 +1,10 @@
+--- a/Rules.mak
++++ b/Rules.mak
+@@ -232,7 +232,6 @@ endif
+ GEN_CXXFLAGS:=-nostdinc++
+ GEN_CXXFLAGS+=$(if $(CXXFLAG_-fvisibility-inlines-hidden),-DGCC_HASCLASSVISIBILITY)
+ CXXFLAGS:=$(CFLAGS)
+-CFLAGS += -ansi
+ 
+ LIBGCC:=$(shell $(CC) -print-libgcc-file-name)
+ LIBGCC_DIR:=$(dir $(LIBGCC))
diff --git a/package/libs/uclibc++/patches/002-undef-functions.patch b/package/libs/uclibc++/patches/002-undef-functions.patch
new file mode 100644
index 0000000..47fa158
--- /dev/null
+++ b/package/libs/uclibc++/patches/002-undef-functions.patch
@@ -0,0 +1,35 @@
+From 8245f62c1e7aba150f666b3c3a1dda646dee6d4b Mon Sep 17 00:00:00 2001
+From: Rosen Penev <rosenp@gmail.com>
+Date: Fri, 27 Sep 2019 13:12:44 -0700
+Subject: [PATCH] cstdio: Add undef for four functions
+
+When compiling with uClibc-ng, these functions get defined as macros and
+become unavailable for std.
+
+Fixes programs that use the std versions of these functions.
+
+This matches libstdcpp behavior.
+
+Signed-off-by: Rosen Penev <rosenp@gmail.com>
+---
+ include/cstdio | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+--- a/include/cstdio
++++ b/include/cstdio
+@@ -21,6 +21,15 @@
+ #ifndef __HEADER_CSTDIO
+ #define __HEADER_CSTDIO 1
+ 
++#undef clearerr
++#undef feof
++#undef ferror
++#undef fgetc
++#undef fputc
++#undef getc
++#undef getchar
++#undef putc
++#undef putchar
+ 
+ namespace std{
+ 	using ::FILE;
diff --git a/package/libs/uclibc++/patches/003-no-fPIC.patch b/package/libs/uclibc++/patches/003-no-fPIC.patch
new file mode 100644
index 0000000..dfd8833
--- /dev/null
+++ b/package/libs/uclibc++/patches/003-no-fPIC.patch
@@ -0,0 +1,10 @@
+--- a/Rules.mak
++++ b/Rules.mak
+@@ -185,7 +185,6 @@ export UCLIBCXX_RUNTIME_PREFIX UCLIBCXX_
+ 
+ WRAPPER = $(top_builddir)bin/g++-uc
+ OPTIMIZATION:=
+-PICFLAG:=-fPIC
+ 
+ # use '-Os' optimization if available, else use -O2, allow Config to override
+ $(eval $(call check-gcc-var,-Os))
diff --git a/package/libs/uclibc++/patches/004-uClibc-Make-long-long-available-to-C-11.patch b/package/libs/uclibc++/patches/004-uClibc-Make-long-long-available-to-C-11.patch
new file mode 100644
index 0000000..6e13f22
--- /dev/null
+++ b/package/libs/uclibc++/patches/004-uClibc-Make-long-long-available-to-C-11.patch
@@ -0,0 +1,143 @@
+From 8151579eb36d9366632242415ff3f5177fa5e1e2 Mon Sep 17 00:00:00 2001
+From: Rosen Penev <rosenp@gmail.com>
+Date: Thu, 3 Oct 2019 18:58:43 -0700
+Subject: [PATCH] uClibc++: Make long long available to C++11
+
+C++11 makes long long available. It is no longer a GNU extension.
+
+Signed-off-by: Rosen Penev <rosenp@gmail.com>
+---
+ include/istream         | 4 ++--
+ include/istream_helpers | 2 +-
+ include/ostream         | 8 ++++----
+ include/ostream_helpers | 8 ++++----
+ tests/sstreamtest.cpp   | 4 ++--
+ 5 files changed, 13 insertions(+), 13 deletions(-)
+
+--- a/include/istream
++++ b/include/istream
+@@ -72,7 +72,7 @@ namespace std{
+ 		basic_istream<charT,traits>& operator>>(void*& p);
+ 		basic_istream<charT,traits>& operator>>(basic_streambuf<char_type,traits>* sb);
+ 
+-#ifndef __STRICT_ANSI__
++#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+ 		basic_istream<charT,traits>& operator>>(long long& n);
+ 		basic_istream<charT,traits>& operator>>(unsigned long long& n);
+ #endif
+@@ -455,7 +455,7 @@ namespace std{
+ 		return *this;
+ 	}
+ 
+-#ifndef __STRICT_ANSI__
++#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+ 	template <class charT, class traits> _UCXXEXPORT basic_istream<charT,traits>&
+ 		basic_istream<charT,traits>::operator>>(long long& n)
+ 	{
+--- a/include/istream_helpers
++++ b/include/istream_helpers
+@@ -301,7 +301,7 @@ namespace std{
+ 	};
+ 
+ 
+-#ifndef __STRICT_ANSI__
++#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+ 	template <class traits> class _UCXXEXPORT __istream_readin<traits, char, long long>{
+ 	public:
+ 		inline static void readin(basic_istream<char, traits >& stream, long long & var)
+--- a/include/ostream
++++ b/include/ostream
+@@ -85,7 +85,7 @@ namespace std {
+ 		basic_ostream<charT,traits>& operator<<(long double f);
+ 		basic_ostream<charT,traits>& operator<<(void* p);
+ 		basic_ostream<charT,traits>& operator<<(basic_streambuf<char_type,traits>* sb);
+-#ifndef __STRICT_ANSI__
++#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+ 		basic_ostream<charT,traits>& operator<<(long long n);
+ 		basic_ostream<charT,traits>& operator<<(unsigned long long n);
+ #endif
+@@ -221,7 +221,7 @@ namespace std {
+ 		return *this;
+ 	}
+ 
+-#ifndef __STRICT_ANSI__
++#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+ 	template <class charT, class traits> _UCXXEXPORT basic_ostream<charT,traits>& basic_ostream<charT, traits>::operator<<(long long n)
+ 	{
+ 		sentry s(*this);
+@@ -487,7 +487,7 @@ namespace std {
+ #endif
+ 
+ 
+-#ifndef __STRICT_ANSI__
++#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+ 
+ //Support for output of long long data types
+ 
+@@ -509,7 +509,7 @@ template<class Ch, class Tr> _UCXXEXPORT
+ }
+ 
+ 
+-#endif	//__STRICT_ANSI__
++#endif // !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+ 
+ 
+ 
+--- a/include/ostream_helpers
++++ b/include/ostream_helpers
+@@ -142,7 +142,7 @@ namespace std{
+ 		}
+ 	};
+ 
+-#ifndef __STRICT_ANSI__
++#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+ 
+ 	template <class traits> class _UCXXEXPORT __ostream_printout<traits, char, signed long long int>{
+ 	public:
+@@ -237,7 +237,7 @@ namespace std{
+ 	};
+ 
+ 
+-#endif	//__STRICT_ANSI__
++#endif // !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+ 
+ 	template <class traits> class _UCXXEXPORT __ostream_printout<traits, char, double>{
+ 	public:
+@@ -357,7 +357,7 @@ namespace std{
+ 		}
+ 	};
+ 
+-#ifndef __STRICT_ANSI__
++#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+ 
+ 	template <class traits> class _UCXXEXPORT __ostream_printout<traits, wchar_t, signed long long int>{
+ 	public:
+@@ -428,7 +428,7 @@ namespace std{
+ 	};
+ 
+ 
+-#endif	//__STRICT_ANSI__
++#endif // !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+ 
+ 	template <class traits> class _UCXXEXPORT __ostream_printout<traits, wchar_t, double>{
+ 	public:
+--- a/tests/sstreamtest.cpp
++++ b/tests/sstreamtest.cpp
+@@ -9,7 +9,7 @@ int main(){
+ 	int i;
+ 	std::string s;
+ 	char c;
+-#ifndef __STRICT_ANSI__
++#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+ 	long long ll;
+ 	unsigned long long ull;
+ #endif
+@@ -32,7 +32,7 @@ int main(){
+ 
+ 
+ 
+-#ifndef __STRICT_ANSI__
++#if !defined(__STRICT_ANSI__) || (__cplusplus >= 201103L)
+ 	a.str("678 76 54");
+ 	a >> ll >> ull >> s;
+ 	std::cout << "ll (should be 678): " << ll << std::endl;
diff --git a/package/libs/uclibc++/patches/005-istream_helpers-Fix-sscanf-typo.patch b/package/libs/uclibc++/patches/005-istream_helpers-Fix-sscanf-typo.patch
new file mode 100644
index 0000000..66b62c1
--- /dev/null
+++ b/package/libs/uclibc++/patches/005-istream_helpers-Fix-sscanf-typo.patch
@@ -0,0 +1,37 @@
+From 7f6dd860818512c0eb313320308b22ba7e2c7205 Mon Sep 17 00:00:00 2001
+From: Rosen Penev <rosenp@gmail.com>
+Date: Fri, 4 Oct 2019 20:06:53 -0700
+Subject: [PATCH] istream_helpers: Fix sscanf typo
+
+This caused readin not to work properly with long long types.
+
+Found accidentally through a glibc warning
+(declared with warn_unused_result).
+
+Tested with gptfdisk on OpenWrt.
+
+Signed-off-by: Rosen Penev <rosenp@gmail.com>
+---
+ include/istream_helpers | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/include/istream_helpers
++++ b/include/istream_helpers
+@@ -317,7 +317,7 @@ namespace std{
+ 					sscanf(temp.c_str(), "%llo", (unsigned long long *)&var );
+ 				}else if(stream.flags() & ios_base::hex){
+ 					if(stream.flags() & ios_base::uppercase){
+-						scanf(temp.c_str(), "%llX", (unsigned long long *)&var );
++						sscanf(temp.c_str(), "%llX", (unsigned long long *)&var );
+ 					}else{
+ 						sscanf(temp.c_str(), "%llx", (unsigned long long *)&var);
+ 					}
+@@ -344,7 +344,7 @@ namespace std{
+ 					sscanf(temp.c_str(), "%llo", &var );
+ 				}else if(stream.flags() & ios_base::hex){
+ 					if(stream.flags() & ios_base::uppercase){
+-						scanf(temp.c_str(), "%llX", &var );
++						sscanf(temp.c_str(), "%llX", &var );
+ 					}else{
+ 						sscanf(temp.c_str(), "%llx", &var);
+ 					}
diff --git a/package/libs/uclient/Makefile b/package/libs/uclient/Makefile
new file mode 100644
index 0000000..390d551
--- /dev/null
+++ b/package/libs/uclient/Makefile
@@ -0,0 +1,68 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=uclient
+PKG_RELEASE=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL=$(PROJECT_GIT)/project/uclient.git
+PKG_MIRROR_HASH:=a4b000ad3a0803789d72f6a54b4fd51dd6709fb8fe4d7b6e201d752172e50b07
+PKG_SOURCE_DATE:=2024-10-22
+PKG_SOURCE_VERSION:=88ae8f208dd313f69e268234f7db55956aef1cb9
+CMAKE_INSTALL:=1
+
+PKG_BUILD_DEPENDS:=ustream-ssl
+
+PKG_LICENSE:=ISC
+PKG_LICENSE_FILES:=
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
+PKG_CONFIG_DEPENDS := CONFIG_PACKAGE_ucode-mod-uclient
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/libuclient
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=HTTP/1.1 client library
+  ABI_VERSION:=20201210
+  DEPENDS:=+libubox
+endef
+
+define Package/uclient-fetch
+  SECTION:=net
+  CATEGORY:=Network
+  TITLE:=Tiny wget replacement using libuclient
+  ALTERNATIVES:=200:/usr/bin/wget:/bin/uclient-fetch
+  PROVIDES:=wget
+  DEPENDS:=+libuclient
+endef
+
+define Package/ucode-mod-uclient
+  SECTION:=utils
+  CATEGORY:=Utilities
+  TITLE:=ucode uclient module
+  DEPENDS:=+libucode +libuclient
+endef
+
+CMAKE_OPTIONS += \
+	-DBUILD_UCODE=$(if $(CONFIG_PACKAGE_ucode-mod-uclient),ON,OFF)
+
+define Package/libuclient/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libuclient.so $(1)/usr/lib/
+endef
+
+define Package/uclient-fetch/install
+	$(INSTALL_DIR) $(1)/bin
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/uclient-fetch $(1)/bin/
+endef
+
+define Package/ucode-mod-uclient/install
+	$(INSTALL_DIR) $(1)/usr/lib/ucode
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/lib/ucode/*.so $(1)/usr/lib/ucode
+endef
+
+$(eval $(call BuildPackage,libuclient))
+$(eval $(call BuildPackage,uclient-fetch))
+$(eval $(call BuildPackage,ucode-mod-uclient))
diff --git a/package/libs/udebug/Makefile b/package/libs/udebug/Makefile
new file mode 100644
index 0000000..5c665f2
--- /dev/null
+++ b/package/libs/udebug/Makefile
@@ -0,0 +1,82 @@
+#
+# Copyright (C) 2023 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:=udebug
+CMAKE_INSTALL:=1
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL=$(PROJECT_GIT)/project/udebug.git
+PKG_MIRROR_HASH:=62d470ad4a3c4a0138c3102ad2e21dd56e93e9c0c7ec466d591c14e7b8af9a97
+PKG_SOURCE_DATE:=2023-12-06
+PKG_SOURCE_VERSION:=6d3f51f9fda706f0cf4732c762e4dbe8c21e12cf
+PKG_ABI_VERSION:=$(call abi_version_str,$(PKG_SOURCE_DATE))
+
+PKG_LICENSE:=GPL-2.0
+PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/libudebug
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=udebug client library
+  DEPENDS:=+libubox +libubus
+endef
+
+define Package/udebugd
+  SECTION:=utils
+  CATEGORY:=Utilities
+  TITLE:=OpenWrt debug service
+  DEPENDS:=+libudebug
+endef
+
+define Package/udebugd/conffiles
+/etc/config/udebug
+endef
+
+define Package/ucode-mod-udebug
+  SECTION:=utils
+  CATEGORY:=Utilities
+  TITLE:=ucode udebug module
+  DEPENDS:=+libucode +libudebug
+endef
+
+define Package/udebug-cli
+  SECTION:=utils
+  CATEGORY:=Utilities
+  TITLE:=OpenWrt debug service CLI
+  DEPENDS:=+udebugd +ucode-mod-udebug
+endef
+
+define Package/libudebug/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/*.so* $(1)/usr/lib
+endef
+
+define Package/ucode-mod-udebug/install
+	$(INSTALL_DIR) $(1)/usr/lib/ucode
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/ucode/*.so $(1)/usr/lib/ucode
+endef
+
+define Package/udebugd/install
+	$(INSTALL_DIR) $(1)/usr/sbin $(1)/etc/init.d $(1)/etc/config
+	$(INSTALL_BIN) ./files/udebug.config $(1)/etc/config/udebug
+	$(INSTALL_BIN) ./files/udebug.init $(1)/etc/init.d/udebug
+	$(CP) $(PKG_INSTALL_DIR)/usr/sbin/udebugd $(1)/usr/sbin
+endef
+
+define Package/udebug-cli/install
+	$(INSTALL_DIR) $(1)/usr/sbin
+	$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/udebug-cli $(1)/usr/sbin/udebug
+endef
+
+$(eval $(call BuildPackage,libudebug))
+$(eval $(call BuildPackage,udebugd))
+$(eval $(call BuildPackage,ucode-mod-udebug))
+$(eval $(call BuildPackage,udebug-cli))
diff --git a/package/libs/udebug/files/udebug.config b/package/libs/udebug/files/udebug.config
new file mode 100644
index 0000000..68ddefe
--- /dev/null
+++ b/package/libs/udebug/files/udebug.config
@@ -0,0 +1,30 @@
+config service procd
+	option enabled 0
+
+config service log
+	option enabled 0
+	option debug 0
+	option kernel 1
+	option syslog 1
+
+config service hostapd
+	option enabled 0
+	option wpa_log 1
+	option wpa_nl_rx 0
+	option wpa_nl_tx 0
+	option wpa_nl_ctrl 0
+
+config service wpa_supplicant
+	option enabled 0
+	option wpa_log 1
+	option wpa_nl_rx 0
+	option wpa_nl_tx 0
+	option wpa_nl_ctrl 0
+
+config service netifd
+	option enabled 0
+	option netifd_log 1
+	option netifd_nl 0
+
+config service umdns
+	option enabled 0
diff --git a/package/libs/udebug/files/udebug.init b/package/libs/udebug/files/udebug.init
new file mode 100755
index 0000000..b57e962
--- /dev/null
+++ b/package/libs/udebug/files/udebug.init
@@ -0,0 +1,55 @@
+#!/bin/sh /etc/rc.common
+# Copyright (c) 2021 OpenWrt.org
+
+START=11
+
+USE_PROCD=1
+PROG=/usr/sbin/udebugd
+
+start_service() {
+	procd_open_instance
+	procd_set_param command "$PROG"
+	procd_set_param respawn
+	procd_close_instance
+}
+
+get_vars() {
+	local cfg="$1"
+	uci show "udebug.$cfg" | while read LINE; do
+		cur="${LINE##udebug.$1.}"
+		[[ "$cur" = "$LINE" ]] && continue
+		var="${cur%%=*}"
+		[[ "$cur" = "$var" ]] && continue
+		echo "$var"
+	done
+}
+
+add_debug_service() {
+	local cfg="$1"
+
+	json_add_object "$cfg"
+	for var in $(get_vars "$cfg"); do
+		config_get val "$cfg" "$var"
+		json_add_string "$var" "$val"
+	done
+	json_close_object "$cfg"
+}
+
+reload_service() {
+	config_load udebug
+
+	json_init
+	json_add_object service
+	config_foreach add_debug_service service
+	json_close_object
+	ubus call udebug set_config "$(json_dump)"
+}
+
+service_triggers() {
+	procd_add_reload_trigger udebug
+}
+
+service_started() {
+	ubus -t 10 wait_for udebug
+	[ $? = 0 ] && reload_service
+}
diff --git a/package/libs/ustream-ssl/Makefile b/package/libs/ustream-ssl/Makefile
new file mode 100644
index 0000000..6945d9e
--- /dev/null
+++ b/package/libs/ustream-ssl/Makefile
@@ -0,0 +1,72 @@
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=ustream-ssl
+PKG_RELEASE:=1
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL=$(PROJECT_GIT)/project/ustream-ssl.git
+PKG_SOURCE_DATE:=2024-07-28
+PKG_SOURCE_VERSION:=99bd3d2b167ccdffb6de072d02c380cb37b23e33
+PKG_MIRROR_HASH:=8197788d00dfdcb8ad6bbb3ce1840497e31c44a56a03a4d16ae7adccebf0828f
+CMAKE_INSTALL:=1
+
+PKG_LICENSE:=ISC
+PKG_LICENSE_FILES:=
+
+PKG_MAINTAINER:=Felix Fietkau <nbd@nbd.name>
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/libustream/default
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=ustream SSL Library
+  DEPENDS:=+libubox
+  ABI_VERSION:=20201210
+endef
+
+define Package/libustream-openssl
+  $(Package/libustream/default)
+  TITLE += (openssl)
+  DEPENDS += +PACKAGE_libustream-openssl:libopenssl
+  VARIANT:=openssl
+endef
+
+define Package/libustream-wolfssl
+  $(Package/libustream/default)
+  TITLE += (wolfssl)
+  DEPENDS += +PACKAGE_libustream-wolfssl:libwolfssl
+  CONFLICTS := libustream-openssl
+  VARIANT:=wolfssl
+endef
+
+define Package/libustream-mbedtls
+  $(Package/libustream/default)
+  TITLE += (mbedtls)
+  DEPENDS += +PACKAGE_libustream-mbedtls:libmbedtls
+  CONFLICTS := libustream-openssl libustream-wolfssl
+  VARIANT:=mbedtls
+  DEFAULT_VARIANT:=1
+endef
+
+ifeq ($(BUILD_VARIANT),wolfssl)
+  TARGET_CFLAGS += -I$(STAGING_DIR)/usr/include/wolfssl
+  CMAKE_OPTIONS += -DWOLFSSL=on
+endif
+ifeq ($(BUILD_VARIANT),mbedtls)
+  CMAKE_OPTIONS += -DMBEDTLS=on
+endif
+
+define Package/libustream/default/install
+	$(INSTALL_DIR) $(1)/lib/
+	$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/libustream-ssl.so $(1)/lib/
+endef
+
+Package/libustream-openssl/install = $(Package/libustream/default/install)
+Package/libustream-wolfssl/install = $(Package/libustream/default/install)
+Package/libustream-mbedtls/install = $(Package/libustream/default/install)
+
+$(eval $(call BuildPackage,libustream-mbedtls))
+$(eval $(call BuildPackage,libustream-wolfssl))
+$(eval $(call BuildPackage,libustream-openssl))
diff --git a/package/libs/wolfssl/Config.in b/package/libs/wolfssl/Config.in
new file mode 100644
index 0000000..e1c1919
--- /dev/null
+++ b/package/libs/wolfssl/Config.in
@@ -0,0 +1,97 @@
+if PACKAGE_libwolfssl
+
+comment "wolfSSL Library Configuration"
+
+config WOLFSSL_HAS_AES_CCM
+	bool "Include AES-CCM support"
+	default y
+
+config WOLFSSL_HAS_CHACHA_POLY
+	bool "Include ChaCha20-Poly1305 cipher suite support"
+	default y
+
+config WOLFSSL_HAS_DH
+	bool "Include DH (Diffie-Hellman) support"
+	default y
+
+config WOLFSSL_HAS_ARC4
+	bool "Include ARC4 support"
+	default y
+
+config WOLFSSL_HAS_CERTGEN
+	bool "Include certificate generation support"
+	default y
+
+config WOLFSSL_HAS_TLSV10
+	bool "Include TLS 1.0 support"
+	default y
+
+config WOLFSSL_HAS_TLSV13
+	bool "Include TLS 1.3 support"
+	default y
+
+config WOLFSSL_HAS_SESSION_TICKET
+	bool "Include session ticket support"
+	default y
+
+config WOLFSSL_HAS_DTLS
+	bool "Include DTLS support"
+	default n
+
+config WOLFSSL_HAS_OCSP
+	bool "Include OSCP stapling support"
+	default y
+
+config WOLFSSL_HAS_WPAS
+	bool "Include wpa_supplicant support"
+	select WOLFSSL_HAS_ARC4
+	select WOLFSSL_HAS_DH
+	select WOLFSSL_HAS_OCSP
+	select WOLFSSL_HAS_SESSION_TICKET
+	default y
+
+config WOLFSSL_HAS_ECC25519
+	bool "Include ECC Curve 25519 support"
+	default y
+
+config WOLFSSL_HAS_ECC448
+	bool "Include ECC Curve 448 support"
+
+config WOLFSSL_HAS_OPENVPN
+	bool "Include OpenVPN support"
+	default y
+
+config WOLFSSL_ALT_NAMES
+	bool "Include SAN (Subject Alternative Name) support"
+	default y
+
+config WOLFSSL_HAS_DEVCRYPTO
+	bool
+
+	if PACKAGE_libwolfsslcpu-crypto
+		comment "Hardware Acceleration does not apply to libwolfsslcpu-crypto"
+	endif
+	choice
+		prompt "Hardware Acceleration"
+		default WOLFSSL_HAS_NO_HW
+
+		config WOLFSSL_HAS_NO_HW
+			bool "None"
+
+		config WOLFSSL_HAS_AFALG
+			bool "AF_ALG"
+
+		config WOLFSSL_HAS_DEVCRYPTO_CBC
+			bool "/dev/crypto - AES-CBC-only"
+			select WOLFSSL_HAS_DEVCRYPTO
+
+		config WOLFSSL_HAS_DEVCRYPTO_AES
+			bool "/dev/crypto - AES-only (all supported modes)"
+			select WOLFSSL_HAS_DEVCRYPTO
+
+		config WOLFSSL_HAS_DEVCRYPTO_FULL
+			bool "/dev/crypto - full"
+			select WOLFSSL_HAS_DEVCRYPTO
+	endchoice
+
+endif
diff --git a/package/libs/wolfssl/Makefile b/package/libs/wolfssl/Makefile
new file mode 100644
index 0000000..00ddf79
--- /dev/null
+++ b/package/libs/wolfssl/Makefile
@@ -0,0 +1,236 @@
+#
+# Copyright (C) 2006-2017 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:=wolfssl
+PKG_VERSION:=5.7.6
+PKG_REAL_VERSION:=$(PKG_VERSION)-stable
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_REAL_VERSION).tar.gz
+PKG_SOURCE_URL:=https://github.com/wolfSSL/wolfssl/archive/v$(PKG_REAL_VERSION)
+PKG_HASH:=52b1e439e30d1ed8162a16308a8525a862183b67aa30373b11166ecbab000d63
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(BUILD_VARIANT)/$(PKG_NAME)-$(PKG_REAL_VERSION)
+
+PKG_FIXUP:=libtool libtool-abiver
+PKG_INSTALL:=1
+PKG_BUILD_FLAGS:=no-mips16 lto
+PKG_BUILD_PARALLEL:=1
+PKG_LICENSE:=GPL-2.0-or-later
+PKG_LICENSE_FILES:=LICENSING COPYING
+PKG_MAINTAINER:=Eneas U de Queiroz <cotequeiroz@gmail.com>
+PKG_CPE_ID:=cpe:/a:wolfssl:wolfssl
+
+PKG_CONFIG_DEPENDS:=\
+	CONFIG_WOLFSSL_HAS_AES_CCM \
+	CONFIG_WOLFSSL_HAS_ARC4 \
+	CONFIG_WOLFSSL_HAS_CERTGEN \
+	CONFIG_WOLFSSL_HAS_CHACHA_POLY \
+	CONFIG_WOLFSSL_HAS_DH \
+	CONFIG_WOLFSSL_HAS_DTLS \
+	CONFIG_WOLFSSL_HAS_ECC25519 \
+	CONFIG_WOLFSSL_HAS_ECC448 \
+	CONFIG_WOLFSSL_HAS_OCSP \
+	CONFIG_WOLFSSL_HAS_OPENVPN CONFIG_WOLFSSL_ALT_NAMES \
+	CONFIG_WOLFSSL_HAS_SESSION_TICKET \
+	CONFIG_WOLFSSL_HAS_TLSV10 \
+	CONFIG_WOLFSSL_HAS_TLSV13 \
+	CONFIG_WOLFSSL_HAS_WPAS
+
+PKG_ABI_VERSION:=$(PKG_VERSION)
+
+PKG_CONFIG_DEPENDS+=\
+	CONFIG_PACKAGE_libwolfssl-benchmark \
+	CONFIG_WOLFSSL_HAS_AFALG \
+	CONFIG_WOLFSSL_HAS_DEVCRYPTO_AES \
+	CONFIG_WOLFSSL_HAS_DEVCRYPTO_CBC \
+	CONFIG_WOLFSSL_HAS_DEVCRYPTO_FULL
+
+include $(INCLUDE_DIR)/package.mk
+
+DISABLE_NLS:=
+
+define Package/libwolfssl/Default
+  SECTION:=libs
+  SUBMENU:=SSL
+  CATEGORY:=Libraries
+  URL:=http://www.wolfssl.com/
+endef
+
+define Package/libwolfssl
+$(call Package/libwolfssl/Default)
+  TITLE:=wolfSSL library
+  MENU:=1
+  PROVIDES:=libcyassl
+  DEPENDS:=+WOLFSSL_HAS_DEVCRYPTO:kmod-cryptodev +WOLFSSL_HAS_AFALG:kmod-crypto-user
+  ABI_VERSION:=$(PKG_ABI_VERSION)
+  VARIANT:=regular
+  DEFAULT_VARIANT:=1
+  CONFLICTS:=libwolfsslcpu-crypto
+endef
+
+define Package/libwolfssl/description
+wolfSSL (formerly CyaSSL) is an SSL library optimized for small
+footprint, both on disk and for memory use.
+endef
+
+define Package/libwolfssl/config
+	source "$(SOURCE)/Config.in"
+endef
+
+define Package/libwolfsslcpu-crypto
+$(call Package/libwolfssl/Default)
+  TITLE:=wolfSSL library with AES CPU instructions
+  PROVIDES:=libwolfssl libcyassl
+  DEPENDS:=@((aarch64||x86_64)&&(m||!TARGET_bcm27xx))
+  ABI_VERSION:=$(PKG_ABI_VERSION)
+  VARIANT:=cpu-crypto
+endef
+
+define Package/libwolfssl-benchmark
+$(call Package/libwolfssl/Default)
+  TITLE:=wolfSSL Benchmark Utility
+  DEPENDS:=libwolfssl
+endef
+
+define Package/libwolfsslcpu-crypto/description
+$(call Package/libwolfssl/description)
+This variant uses AES CPU instructions (Intel AESNI or ARMv8 Crypto Extension)
+endef
+
+define Package/libwolfsslcpu-crypto/config
+    if TARGET_armsr && PACKAGE_libwolfsslcpu-crypto = y
+	comment "You are about to build libwolfsslcpu-crypto into an armsr_64 image."
+	comment "Ensure all of your installation targets support the Crypto Extension. "
+	comment "Look for the 'aes' feature in /proc/cpuinfo. This library does not do "
+	comment "run-time detection and will crash if the CPU does not support it.     "
+    endif
+    if TARGET_bcm27xx && PACKAGE_libwolfsslcpu-crypto
+	comment "Beware that libwolfsslcpu-crypto will not run in a bcm27xx target.   "
+    endif
+endef
+
+define Package/libwolfssl-benchmark/description
+This is the wolfssl benchmark utility.
+endef
+
+TARGET_CFLAGS += \
+	$(FPIC) \
+	-fomit-frame-pointer \
+	-DFP_MAX_BITS=8192 \
+	$(if $(CONFIG_WOLFSSL_ALT_NAMES),-DWOLFSSL_ALT_NAMES)
+
+# --enable-stunnel needed for OpenSSL API compatibility bits
+CONFIGURE_ARGS += \
+	--enable-reproducible-build \
+	--enable-lighty \
+	--enable-opensslall \
+	--enable-opensslextra \
+	--enable-sni \
+	--enable-stunnel \
+	--enable-altcertchains \
+	--$(if $(CONFIG_PACKAGE_libwolfssl-benchmark),enable,disable)-crypttests \
+	--enable-sp \
+	--disable-examples \
+	--disable-jobserver \
+	--$(if $(CONFIG_IPV6),enable,disable)-ipv6 \
+	--$(if $(CONFIG_WOLFSSL_HAS_AES_CCM),enable,disable)-aesccm \
+	--$(if $(CONFIG_WOLFSSL_HAS_CERTGEN),enable,disable)-certgen \
+	--$(if $(CONFIG_WOLFSSL_HAS_CHACHA_POLY),enable,disable)-chacha \
+	--$(if $(CONFIG_WOLFSSL_HAS_CHACHA_POLY),enable,disable)-poly1305 \
+	--$(if $(CONFIG_WOLFSSL_HAS_DH),enable,disable)-dh \
+	--$(if $(CONFIG_WOLFSSL_HAS_ARC4),enable,disable)-arc4 \
+	--$(if $(CONFIG_WOLFSSL_HAS_TLSV10),enable,disable)-tlsv10 \
+	--$(if $(CONFIG_WOLFSSL_HAS_TLSV13),enable,disable)-tls13 \
+	--$(if $(CONFIG_WOLFSSL_HAS_SESSION_TICKET),enable,disable)-session-ticket \
+	--$(if $(CONFIG_WOLFSSL_HAS_DTLS),enable,disable)-dtls \
+	--$(if $(CONFIG_WOLFSSL_HAS_ECC25519),enable,disable)-curve25519 \
+	--$(if $(CONFIG_WOLFSSL_HAS_ECC448),enable,disable)-curve448 \
+	--$(if $(CONFIG_WOLFSSL_HAS_OPENVPN),enable,disable)-openvpn
+
+define Package/libwolfsslcpu-crypto/preinst-aarch64
+#!/bin/sh
+exec >&2
+printf "[libwolfsslcpu-crypto] Checking for Arm v8-A Cryptographic Extension support: "
+if [ -n "$${IPKG_INSTROOT}" ]; then
+    printf "...[offline]... "
+    eval "$$(grep '^DISTRIB_TARGET=' "$${IPKG_INSTROOT}/etc/openwrt_release")"
+    echo "$${DISTRIB_TARGET}" | grep '^bcm27xx/.*' > /dev/null && {
+	echo "not supported"
+	echo "Error: Target $${DISTRIB_TARGET} does not support Arm Cryptographic Extension."
+	echo "Install the regular libwolfssl package instead of libwolfsslcpu-crypto."
+	exit 1
+    }
+else
+    grep -q '^Features.*\baes\b' /proc/cpuinfo || {
+	echo "not supported"
+	echo "Error: Arm v8-A Cryptographic Extension not supported."
+	echo "Install the regular libwolfssl package instead of libwolfsslcpu-crypto."
+	echo "Contents of /proc/cpuinfo:"
+	cat /proc/cpuinfo
+	exit 1
+    }
+fi
+echo OK
+exit 0
+endef
+
+ifeq ($(BUILD_VARIANT),regular)
+CONFIGURE_ARGS += \
+	--$(if $(CONFIG_WOLFSSL_HAS_AFALG),enable,disable)-afalg \
+	--enable-devcrypto=$(if $(CONFIG_WOLFSSL_HAS_DEVCRYPTO_CBC),cbc\
+			  ,$(if $(CONFIG_WOLFSSL_HAS_DEVCRYPTO_AES),aes\
+			  ,$(if $(CONFIG_WOLFSSL_HAS_DEVCRYPTO_FULL),yes,no)))
+else ifdef CONFIG_aarch64
+    CONFIGURE_ARGS += --enable-armasm
+    TARGET_CFLAGS:=$(TARGET_CFLAGS:-mcpu%=-mcpu%+crypto)
+    Package/libwolfsslcpu-crypto/preinst=$(Package/libwolfsslcpu-crypto/preinst-aarch64)
+else ifdef CONFIG_TARGET_x86_64
+	CONFIGURE_ARGS += --enable-intelasm
+endif
+
+ifeq ($(CONFIG_WOLFSSL_HAS_OCSP),y)
+CONFIGURE_ARGS += \
+	--enable-ocsp --enable-ocspstapling --enable-ocspstapling2
+endif
+
+ifeq ($(CONFIG_WOLFSSL_HAS_WPAS),y)
+CONFIGURE_ARGS += \
+	--enable-wpas --enable-fortress --enable-fastmath
+endif
+
+CONFIGURE_ARGS := $(filter-out --enable-year2038,$(CONFIGURE_ARGS))
+
+define Build/InstallDev
+	$(INSTALL_DIR) $(1)/usr/include $(1)/usr/lib/pkgconfig
+	$(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include/
+
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libwolfssl.{so*,la} $(1)/usr/lib/
+	ln -s libwolfssl.so $(1)/usr/lib/libcyassl.so
+	ln -s libwolfssl.la $(1)/usr/lib/libcyassl.la
+
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/*.pc $(1)/usr/lib/pkgconfig
+endef
+
+define Package/libwolfssl/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libwolfssl.so.* $(1)/usr/lib/
+endef
+
+Package/libwolfsslcpu-crypto/install=$(Package/libwolfssl/install)
+
+define Package/libwolfssl-benchmark/install
+	$(INSTALL_DIR) $(1)/usr/bin
+	$(CP) $(PKG_BUILD_DIR)/wolfcrypt/benchmark/.libs/benchmark $(1)/usr/bin/wolfssl-benchmark
+endef
+
+$(eval $(call BuildPackage,libwolfssl))
+$(eval $(call BuildPackage,libwolfsslcpu-crypto))
+$(eval $(call BuildPackage,libwolfssl-benchmark))
diff --git a/package/libs/wolfssl/patches/100-disable-hardening-check.patch b/package/libs/wolfssl/patches/100-disable-hardening-check.patch
new file mode 100644
index 0000000..ab695d3
--- /dev/null
+++ b/package/libs/wolfssl/patches/100-disable-hardening-check.patch
@@ -0,0 +1,11 @@
+--- a/wolfssl/wolfcrypt/settings.h
++++ b/wolfssl/wolfcrypt/settings.h
+@@ -3722,7 +3722,7 @@ extern void uITRON4_free(void *p) ;
+ 
+ /* warning for not using harden build options (default with ./configure) */
+ /* do not warn if big integer support is disabled */
+-#if !defined(WC_NO_HARDEN) && !defined(NO_BIG_INT)
++#if 0
+     #if (defined(USE_FAST_MATH) && !defined(TFM_TIMING_RESISTANT)) || \
+         (defined(HAVE_ECC) && !defined(ECC_TIMING_RESISTANT)) || \
+         (!defined(NO_RSA) && !defined(WC_RSA_BLINDING) && !defined(HAVE_FIPS) && \
diff --git a/package/libs/zlib/Config.in b/package/libs/zlib/Config.in
new file mode 100644
index 0000000..64b835e
--- /dev/null
+++ b/package/libs/zlib/Config.in
@@ -0,0 +1,11 @@
+menu "Configuration"
+	depends on PACKAGE_zlib
+
+config ZLIB_OPTIMIZE_SPEED
+	bool "Optimize for speed"
+	help
+		This enables additional optimization and 
+		increases performance considerably at 
+		the expense of binary size.
+
+endmenu
diff --git a/package/libs/zlib/Makefile b/package/libs/zlib/Makefile
new file mode 100644
index 0000000..2559fbb
--- /dev/null
+++ b/package/libs/zlib/Makefile
@@ -0,0 +1,98 @@
+#
+# Copyright (C) 2006-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:=zlib
+PKG_VERSION:=1.3.1
+PKG_RELEASE:=1
+
+PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
+PKG_SOURCE_URL:=https://github.com/madler/zlib/releases/download/v$(PKG_VERSION)
+PKG_HASH:=38ef96b8dfe510d42707d9c781877914792541133e1870841463bfa73f883e32
+
+PKG_LICENSE:=Zlib
+PKG_LICENSE_FILES:=README
+PKG_CPE_ID:=cpe:/a:gnu:zlib
+
+PKG_CONFIG_DEPENDS:= CONFIG_ZLIB_OPTIMIZE_SPEED
+
+include $(INCLUDE_DIR)/package.mk
+include $(INCLUDE_DIR)/cmake.mk
+
+define Package/zlib
+  SECTION:=libs
+  CATEGORY:=Libraries
+  TITLE:=Library implementing the deflate compression method
+  URL:=http://www.zlib.net/
+endef
+
+define Package/zlib-dev
+  SECTION:=devel
+  CATEGORY:=Development
+  SUBMENU:=Libraries
+  DEPENDS:=zlib
+  TITLE:=Development files for the zlib library
+endef
+
+define Package/zlib/description
+ zlib is a lossless data-compression library.
+ This package includes the shared library.
+endef
+
+define Package/zlib-dev/description
+ zlib is a lossless data-compression library.
+ This package includes the development support files.
+endef
+
+define Package/zlib/config
+	source "$(SOURCE)/Config.in"
+endef
+
+TARGET_CFLAGS += $(FPIC)
+
+ifeq ($(CONFIG_ZLIB_OPTIMIZE_SPEED),y)
+	TARGET_CFLAGS := $(filter-out -O%,$(TARGET_CFLAGS)) -O3
+endif
+
+CMAKE_OPTIONS += \
+	-DARMv8=$$$$(echo -e '\#ifdef __ARM_NEON__\nON\n\#else\nOFF\n\#endif' | $$(TARGET_CC) $$(TARGET_CFLAGS) -x c -E - | grep -xE 'ON|OFF')
+
+define Build/InstallDev
+	mkdir -p $(1)/usr/include
+	$(CP)	$(PKG_INSTALL_DIR)/usr/include/z{conf,lib}.h \
+		$(1)/usr/include/
+	mkdir -p $(1)/usr/lib
+	$(CP)	$(PKG_INSTALL_DIR)/usr/lib/libz.{a,so*} \
+		$(1)/usr/lib/
+	mkdir -p $(1)/usr/lib/pkgconfig
+	$(CP)	$(PKG_INSTALL_DIR)/usr/share/pkgconfig/zlib.pc \
+		$(1)/usr/lib/pkgconfig/
+endef
+
+# libz.so is needed for openssl (zlib-dynamic)
+define Package/zlib/install
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libz.so $(1)/usr/lib/
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libz.so.* $(1)/usr/lib/
+endef
+
+define Package/zlib-dev/install
+	$(INSTALL_DIR) $(1)/usr/include
+	$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/include/zconf.h \
+	  $(1)/usr/include/
+	$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/include/zlib.h \
+	  $(1)/usr/include/
+	$(INSTALL_DIR) $(1)/usr/lib
+	$(CP) $(PKG_INSTALL_DIR)/usr/lib/libz.a $(1)/usr/lib/
+	$(INSTALL_DIR) $(1)/usr/lib/pkgconfig
+	$(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/share/pkgconfig/zlib.pc \
+	  $(1)/usr/lib/pkgconfig/
+endef
+
+$(eval $(call BuildPackage,zlib))
+$(eval $(call BuildPackage,zlib-dev))
diff --git a/package/libs/zlib/patches/002-arm-specific-optimisations-for-inflate.patch b/package/libs/zlib/patches/002-arm-specific-optimisations-for-inflate.patch
new file mode 100644
index 0000000..04e6662
--- /dev/null
+++ b/package/libs/zlib/patches/002-arm-specific-optimisations-for-inflate.patch
@@ -0,0 +1,1903 @@
+From 6bac7a3e0ebcd3147294b73acb34606eba18ae7f Mon Sep 17 00:00:00 2001
+From: Simon Hosie <simon.hosie@arm.com>
+Date: Wed, 12 Apr 2017 12:52:33 -0700
+Subject: [PATCH 1/2] Prepare ARM-specific contrib directory.
+
+Change-Id: Id4cda552b39bfb39ab35ec499dbe122b43b6d1a1
+---
+ contrib/arm/inffast.c |  323 ++++++++++
+ contrib/arm/inflate.c | 1561 +++++++++++++++++++++++++++++++++++++++++++++++++
+ 2 files changed, 1884 insertions(+)
+ create mode 100644 contrib/arm/inffast.c
+ create mode 100644 contrib/arm/inflate.c
+
+--- /dev/null
++++ b/contrib/arm/inffast.c
+@@ -0,0 +1,323 @@
++/* inffast.c -- fast decoding
++ * Copyright (C) 1995-2017 Mark Adler
++ * For conditions of distribution and use, see copyright notice in zlib.h
++ */
++
++#include "zutil.h"
++#include "inftrees.h"
++#include "inflate.h"
++#include "inffast.h"
++
++#ifdef ASMINF
++#  pragma message("Assembler code may have bugs -- use at your own risk")
++#else
++
++/*
++   Decode literal, length, and distance codes and write out the resulting
++   literal and match bytes until either not enough input or output is
++   available, an end-of-block is encountered, or a data error is encountered.
++   When large enough input and output buffers are supplied to inflate(), for
++   example, a 16K input buffer and a 64K output buffer, more than 95% of the
++   inflate execution time is spent in this routine.
++
++   Entry assumptions:
++
++        state->mode == LEN
++        strm->avail_in >= 6
++        strm->avail_out >= 258
++        start >= strm->avail_out
++        state->bits < 8
++
++   On return, state->mode is one of:
++
++        LEN -- ran out of enough output space or enough available input
++        TYPE -- reached end of block code, inflate() to interpret next block
++        BAD -- error in block data
++
++   Notes:
++
++    - The maximum input bits used by a length/distance pair is 15 bits for the
++      length code, 5 bits for the length extra, 15 bits for the distance code,
++      and 13 bits for the distance extra.  This totals 48 bits, or six bytes.
++      Therefore if strm->avail_in >= 6, then there is enough input to avoid
++      checking for available input while decoding.
++
++    - The maximum bytes that a single length/distance pair can output is 258
++      bytes, which is the maximum length that can be coded.  inflate_fast()
++      requires strm->avail_out >= 258 for each loop to avoid checking for
++      output space.
++ */
++void ZLIB_INTERNAL inflate_fast(strm, start)
++z_streamp strm;
++unsigned start;         /* inflate()'s starting value for strm->avail_out */
++{
++    struct inflate_state FAR *state;
++    z_const unsigned char FAR *in;      /* local strm->next_in */
++    z_const unsigned char FAR *last;    /* have enough input while in < last */
++    unsigned char FAR *out;     /* local strm->next_out */
++    unsigned char FAR *beg;     /* inflate()'s initial strm->next_out */
++    unsigned char FAR *end;     /* while out < end, enough space available */
++#ifdef INFLATE_STRICT
++    unsigned dmax;              /* maximum distance from zlib header */
++#endif
++    unsigned wsize;             /* window size or zero if not using window */
++    unsigned whave;             /* valid bytes in the window */
++    unsigned wnext;             /* window write index */
++    unsigned char FAR *window;  /* allocated sliding window, if wsize != 0 */
++    unsigned long hold;         /* local strm->hold */
++    unsigned bits;              /* local strm->bits */
++    code const FAR *lcode;      /* local strm->lencode */
++    code const FAR *dcode;      /* local strm->distcode */
++    unsigned lmask;             /* mask for first level of length codes */
++    unsigned dmask;             /* mask for first level of distance codes */
++    code here;                  /* retrieved table entry */
++    unsigned op;                /* code bits, operation, extra bits, or */
++                                /*  window position, window bytes to copy */
++    unsigned len;               /* match length, unused bytes */
++    unsigned dist;              /* match distance */
++    unsigned char FAR *from;    /* where to copy match from */
++
++    /* copy state to local variables */
++    state = (struct inflate_state FAR *)strm->state;
++    in = strm->next_in;
++    last = in + (strm->avail_in - 5);
++    out = strm->next_out;
++    beg = out - (start - strm->avail_out);
++    end = out + (strm->avail_out - 257);
++#ifdef INFLATE_STRICT
++    dmax = state->dmax;
++#endif
++    wsize = state->wsize;
++    whave = state->whave;
++    wnext = state->wnext;
++    window = state->window;
++    hold = state->hold;
++    bits = state->bits;
++    lcode = state->lencode;
++    dcode = state->distcode;
++    lmask = (1U << state->lenbits) - 1;
++    dmask = (1U << state->distbits) - 1;
++
++    /* decode literals and length/distances until end-of-block or not enough
++       input data or output space */
++    do {
++        if (bits < 15) {
++            hold += (unsigned long)(*in++) << bits;
++            bits += 8;
++            hold += (unsigned long)(*in++) << bits;
++            bits += 8;
++        }
++        here = lcode[hold & lmask];
++      dolen:
++        op = (unsigned)(here.bits);
++        hold >>= op;
++        bits -= op;
++        op = (unsigned)(here.op);
++        if (op == 0) {                          /* literal */
++            Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
++                    "inflate:         literal '%c'\n" :
++                    "inflate:         literal 0x%02x\n", here.val));
++            *out++ = (unsigned char)(here.val);
++        }
++        else if (op & 16) {                     /* length base */
++            len = (unsigned)(here.val);
++            op &= 15;                           /* number of extra bits */
++            if (op) {
++                if (bits < op) {
++                    hold += (unsigned long)(*in++) << bits;
++                    bits += 8;
++                }
++                len += (unsigned)hold & ((1U << op) - 1);
++                hold >>= op;
++                bits -= op;
++            }
++            Tracevv((stderr, "inflate:         length %u\n", len));
++            if (bits < 15) {
++                hold += (unsigned long)(*in++) << bits;
++                bits += 8;
++                hold += (unsigned long)(*in++) << bits;
++                bits += 8;
++            }
++            here = dcode[hold & dmask];
++          dodist:
++            op = (unsigned)(here.bits);
++            hold >>= op;
++            bits -= op;
++            op = (unsigned)(here.op);
++            if (op & 16) {                      /* distance base */
++                dist = (unsigned)(here.val);
++                op &= 15;                       /* number of extra bits */
++                if (bits < op) {
++                    hold += (unsigned long)(*in++) << bits;
++                    bits += 8;
++                    if (bits < op) {
++                        hold += (unsigned long)(*in++) << bits;
++                        bits += 8;
++                    }
++                }
++                dist += (unsigned)hold & ((1U << op) - 1);
++#ifdef INFLATE_STRICT
++                if (dist > dmax) {
++                    strm->msg = (char *)"invalid distance too far back";
++                    state->mode = BAD;
++                    break;
++                }
++#endif
++                hold >>= op;
++                bits -= op;
++                Tracevv((stderr, "inflate:         distance %u\n", dist));
++                op = (unsigned)(out - beg);     /* max distance in output */
++                if (dist > op) {                /* see if copy from window */
++                    op = dist - op;             /* distance back in window */
++                    if (op > whave) {
++                        if (state->sane) {
++                            strm->msg =
++                                (char *)"invalid distance too far back";
++                            state->mode = BAD;
++                            break;
++                        }
++#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
++                        if (len <= op - whave) {
++                            do {
++                                *out++ = 0;
++                            } while (--len);
++                            continue;
++                        }
++                        len -= op - whave;
++                        do {
++                            *out++ = 0;
++                        } while (--op > whave);
++                        if (op == 0) {
++                            from = out - dist;
++                            do {
++                                *out++ = *from++;
++                            } while (--len);
++                            continue;
++                        }
++#endif
++                    }
++                    from = window;
++                    if (wnext == 0) {           /* very common case */
++                        from += wsize - op;
++                        if (op < len) {         /* some from window */
++                            len -= op;
++                            do {
++                                *out++ = *from++;
++                            } while (--op);
++                            from = out - dist;  /* rest from output */
++                        }
++                    }
++                    else if (wnext < op) {      /* wrap around window */
++                        from += wsize + wnext - op;
++                        op -= wnext;
++                        if (op < len) {         /* some from end of window */
++                            len -= op;
++                            do {
++                                *out++ = *from++;
++                            } while (--op);
++                            from = window;
++                            if (wnext < len) {  /* some from start of window */
++                                op = wnext;
++                                len -= op;
++                                do {
++                                    *out++ = *from++;
++                                } while (--op);
++                                from = out - dist;      /* rest from output */
++                            }
++                        }
++                    }
++                    else {                      /* contiguous in window */
++                        from += wnext - op;
++                        if (op < len) {         /* some from window */
++                            len -= op;
++                            do {
++                                *out++ = *from++;
++                            } while (--op);
++                            from = out - dist;  /* rest from output */
++                        }
++                    }
++                    while (len > 2) {
++                        *out++ = *from++;
++                        *out++ = *from++;
++                        *out++ = *from++;
++                        len -= 3;
++                    }
++                    if (len) {
++                        *out++ = *from++;
++                        if (len > 1)
++                            *out++ = *from++;
++                    }
++                }
++                else {
++                    from = out - dist;          /* copy direct from output */
++                    do {                        /* minimum length is three */
++                        *out++ = *from++;
++                        *out++ = *from++;
++                        *out++ = *from++;
++                        len -= 3;
++                    } while (len > 2);
++                    if (len) {
++                        *out++ = *from++;
++                        if (len > 1)
++                            *out++ = *from++;
++                    }
++                }
++            }
++            else if ((op & 64) == 0) {          /* 2nd level distance code */
++                here = dcode[here.val + (hold & ((1U << op) - 1))];
++                goto dodist;
++            }
++            else {
++                strm->msg = (char *)"invalid distance code";
++                state->mode = BAD;
++                break;
++            }
++        }
++        else if ((op & 64) == 0) {              /* 2nd level length code */
++            here = lcode[here.val + (hold & ((1U << op) - 1))];
++            goto dolen;
++        }
++        else if (op & 32) {                     /* end-of-block */
++            Tracevv((stderr, "inflate:         end of block\n"));
++            state->mode = TYPE;
++            break;
++        }
++        else {
++            strm->msg = (char *)"invalid literal/length code";
++            state->mode = BAD;
++            break;
++        }
++    } while (in < last && out < end);
++
++    /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
++    len = bits >> 3;
++    in -= len;
++    bits -= len << 3;
++    hold &= (1U << bits) - 1;
++
++    /* update state and return */
++    strm->next_in = in;
++    strm->next_out = out;
++    strm->avail_in = (unsigned)(in < last ? 5 + (last - in) : 5 - (in - last));
++    strm->avail_out = (unsigned)(out < end ?
++                                 257 + (end - out) : 257 - (out - end));
++    state->hold = hold;
++    state->bits = bits;
++    return;
++}
++
++/*
++   inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):
++   - Using bit fields for code structure
++   - Different op definition to avoid & for extra bits (do & for table bits)
++   - Three separate decoding do-loops for direct, window, and wnext == 0
++   - Special case for distance > 1 copies to do overlapped load and store copy
++   - Explicit branch predictions (based on measured branch probabilities)
++   - Deferring match copy and interspersed it with decoding subsequent codes
++   - Swapping literal/length else
++   - Swapping window/direct else
++   - Larger unrolled copy loops (three is about right)
++   - Moving len -= 3 statement into middle of loop
++ */
++
++#endif /* !ASMINF */
+--- /dev/null
++++ b/contrib/arm/inflate.c
+@@ -0,0 +1,1561 @@
++/* inflate.c -- zlib decompression
++ * Copyright (C) 1995-2016 Mark Adler
++ * For conditions of distribution and use, see copyright notice in zlib.h
++ */
++
++/*
++ * Change history:
++ *
++ * 1.2.beta0    24 Nov 2002
++ * - First version -- complete rewrite of inflate to simplify code, avoid
++ *   creation of window when not needed, minimize use of window when it is
++ *   needed, make inffast.c even faster, implement gzip decoding, and to
++ *   improve code readability and style over the previous zlib inflate code
++ *
++ * 1.2.beta1    25 Nov 2002
++ * - Use pointers for available input and output checking in inffast.c
++ * - Remove input and output counters in inffast.c
++ * - Change inffast.c entry and loop from avail_in >= 7 to >= 6
++ * - Remove unnecessary second byte pull from length extra in inffast.c
++ * - Unroll direct copy to three copies per loop in inffast.c
++ *
++ * 1.2.beta2    4 Dec 2002
++ * - Change external routine names to reduce potential conflicts
++ * - Correct filename to inffixed.h for fixed tables in inflate.c
++ * - Make hbuf[] unsigned char to match parameter type in inflate.c
++ * - Change strm->next_out[-state->offset] to *(strm->next_out - state->offset)
++ *   to avoid negation problem on Alphas (64 bit) in inflate.c
++ *
++ * 1.2.beta3    22 Dec 2002
++ * - Add comments on state->bits assertion in inffast.c
++ * - Add comments on op field in inftrees.h
++ * - Fix bug in reuse of allocated window after inflateReset()
++ * - Remove bit fields--back to byte structure for speed
++ * - Remove distance extra == 0 check in inflate_fast()--only helps for lengths
++ * - Change post-increments to pre-increments in inflate_fast(), PPC biased?
++ * - Add compile time option, POSTINC, to use post-increments instead (Intel?)
++ * - Make MATCH copy in inflate() much faster for when inflate_fast() not used
++ * - Use local copies of stream next and avail values, as well as local bit
++ *   buffer and bit count in inflate()--for speed when inflate_fast() not used
++ *
++ * 1.2.beta4    1 Jan 2003
++ * - Split ptr - 257 statements in inflate_table() to avoid compiler warnings
++ * - Move a comment on output buffer sizes from inffast.c to inflate.c
++ * - Add comments in inffast.c to introduce the inflate_fast() routine
++ * - Rearrange window copies in inflate_fast() for speed and simplification
++ * - Unroll last copy for window match in inflate_fast()
++ * - Use local copies of window variables in inflate_fast() for speed
++ * - Pull out common wnext == 0 case for speed in inflate_fast()
++ * - Make op and len in inflate_fast() unsigned for consistency
++ * - Add FAR to lcode and dcode declarations in inflate_fast()
++ * - Simplified bad distance check in inflate_fast()
++ * - Added inflateBackInit(), inflateBack(), and inflateBackEnd() in new
++ *   source file infback.c to provide a call-back interface to inflate for
++ *   programs like gzip and unzip -- uses window as output buffer to avoid
++ *   window copying
++ *
++ * 1.2.beta5    1 Jan 2003
++ * - Improved inflateBack() interface to allow the caller to provide initial
++ *   input in strm.
++ * - Fixed stored blocks bug in inflateBack()
++ *
++ * 1.2.beta6    4 Jan 2003
++ * - Added comments in inffast.c on effectiveness of POSTINC
++ * - Typecasting all around to reduce compiler warnings
++ * - Changed loops from while (1) or do {} while (1) to for (;;), again to
++ *   make compilers happy
++ * - Changed type of window in inflateBackInit() to unsigned char *
++ *
++ * 1.2.beta7    27 Jan 2003
++ * - Changed many types to unsigned or unsigned short to avoid warnings
++ * - Added inflateCopy() function
++ *
++ * 1.2.0        9 Mar 2003
++ * - Changed inflateBack() interface to provide separate opaque descriptors
++ *   for the in() and out() functions
++ * - Changed inflateBack() argument and in_func typedef to swap the length
++ *   and buffer address return values for the input function
++ * - Check next_in and next_out for Z_NULL on entry to inflate()
++ *
++ * The history for versions after 1.2.0 are in ChangeLog in zlib distribution.
++ */
++
++#include "zutil.h"
++#include "inftrees.h"
++#include "inflate.h"
++#include "inffast.h"
++
++#ifdef MAKEFIXED
++#  ifndef BUILDFIXED
++#    define BUILDFIXED
++#  endif
++#endif
++
++/* function prototypes */
++local int inflateStateCheck OF((z_streamp strm));
++local void fixedtables OF((struct inflate_state FAR *state));
++local int updatewindow OF((z_streamp strm, const unsigned char FAR *end,
++                           unsigned copy));
++#ifdef BUILDFIXED
++   void makefixed OF((void));
++#endif
++local unsigned syncsearch OF((unsigned FAR *have, const unsigned char FAR *buf,
++                              unsigned len));
++
++local int inflateStateCheck(strm)
++z_streamp strm;
++{
++    struct inflate_state FAR *state;
++    if (strm == Z_NULL ||
++        strm->zalloc == (alloc_func)0 || strm->zfree == (free_func)0)
++        return 1;
++    state = (struct inflate_state FAR *)strm->state;
++    if (state == Z_NULL || state->strm != strm ||
++        state->mode < HEAD || state->mode > SYNC)
++        return 1;
++    return 0;
++}
++
++int ZEXPORT inflateResetKeep(strm)
++z_streamp strm;
++{
++    struct inflate_state FAR *state;
++
++    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
++    state = (struct inflate_state FAR *)strm->state;
++    strm->total_in = strm->total_out = state->total = 0;
++    strm->msg = Z_NULL;
++    if (state->wrap)        /* to support ill-conceived Java test suite */
++        strm->adler = state->wrap & 1;
++    state->mode = HEAD;
++    state->last = 0;
++    state->havedict = 0;
++    state->dmax = 32768U;
++    state->head = Z_NULL;
++    state->hold = 0;
++    state->bits = 0;
++    state->lencode = state->distcode = state->next = state->codes;
++    state->sane = 1;
++    state->back = -1;
++    Tracev((stderr, "inflate: reset\n"));
++    return Z_OK;
++}
++
++int ZEXPORT inflateReset(strm)
++z_streamp strm;
++{
++    struct inflate_state FAR *state;
++
++    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
++    state = (struct inflate_state FAR *)strm->state;
++    state->wsize = 0;
++    state->whave = 0;
++    state->wnext = 0;
++    return inflateResetKeep(strm);
++}
++
++int ZEXPORT inflateReset2(strm, windowBits)
++z_streamp strm;
++int windowBits;
++{
++    int wrap;
++    struct inflate_state FAR *state;
++
++    /* get the state */
++    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
++    state = (struct inflate_state FAR *)strm->state;
++
++    /* extract wrap request from windowBits parameter */
++    if (windowBits < 0) {
++        wrap = 0;
++        windowBits = -windowBits;
++    }
++    else {
++        wrap = (windowBits >> 4) + 5;
++#ifdef GUNZIP
++        if (windowBits < 48)
++            windowBits &= 15;
++#endif
++    }
++
++    /* set number of window bits, free window if different */
++    if (windowBits && (windowBits < 8 || windowBits > 15))
++        return Z_STREAM_ERROR;
++    if (state->window != Z_NULL && state->wbits != (unsigned)windowBits) {
++        ZFREE(strm, state->window);
++        state->window = Z_NULL;
++    }
++
++    /* update state and reset the rest of it */
++    state->wrap = wrap;
++    state->wbits = (unsigned)windowBits;
++    return inflateReset(strm);
++}
++
++int ZEXPORT inflateInit2_(strm, windowBits, version, stream_size)
++z_streamp strm;
++int windowBits;
++const char *version;
++int stream_size;
++{
++    int ret;
++    struct inflate_state FAR *state;
++
++    if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
++        stream_size != (int)(sizeof(z_stream)))
++        return Z_VERSION_ERROR;
++    if (strm == Z_NULL) return Z_STREAM_ERROR;
++    strm->msg = Z_NULL;                 /* in case we return an error */
++    if (strm->zalloc == (alloc_func)0) {
++#ifdef Z_SOLO
++        return Z_STREAM_ERROR;
++#else
++        strm->zalloc = zcalloc;
++        strm->opaque = (voidpf)0;
++#endif
++    }
++    if (strm->zfree == (free_func)0)
++#ifdef Z_SOLO
++        return Z_STREAM_ERROR;
++#else
++        strm->zfree = zcfree;
++#endif
++    state = (struct inflate_state FAR *)
++            ZALLOC(strm, 1, sizeof(struct inflate_state));
++    if (state == Z_NULL) return Z_MEM_ERROR;
++    Tracev((stderr, "inflate: allocated\n"));
++    strm->state = (struct internal_state FAR *)state;
++    state->strm = strm;
++    state->window = Z_NULL;
++    state->mode = HEAD;     /* to pass state test in inflateReset2() */
++    ret = inflateReset2(strm, windowBits);
++    if (ret != Z_OK) {
++        ZFREE(strm, state);
++        strm->state = Z_NULL;
++    }
++    return ret;
++}
++
++int ZEXPORT inflateInit_(strm, version, stream_size)
++z_streamp strm;
++const char *version;
++int stream_size;
++{
++    return inflateInit2_(strm, DEF_WBITS, version, stream_size);
++}
++
++int ZEXPORT inflatePrime(strm, bits, value)
++z_streamp strm;
++int bits;
++int value;
++{
++    struct inflate_state FAR *state;
++
++    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
++    state = (struct inflate_state FAR *)strm->state;
++    if (bits < 0) {
++        state->hold = 0;
++        state->bits = 0;
++        return Z_OK;
++    }
++    if (bits > 16 || state->bits + (uInt)bits > 32) return Z_STREAM_ERROR;
++    value &= (1L << bits) - 1;
++    state->hold += (unsigned)value << state->bits;
++    state->bits += (uInt)bits;
++    return Z_OK;
++}
++
++/*
++   Return state with length and distance decoding tables and index sizes set to
++   fixed code decoding.  Normally this returns fixed tables from inffixed.h.
++   If BUILDFIXED is defined, then instead this routine builds the tables the
++   first time it's called, and returns those tables the first time and
++   thereafter.  This reduces the size of the code by about 2K bytes, in
++   exchange for a little execution time.  However, BUILDFIXED should not be
++   used for threaded applications, since the rewriting of the tables and virgin
++   may not be thread-safe.
++ */
++local void fixedtables(state)
++struct inflate_state FAR *state;
++{
++#ifdef BUILDFIXED
++    static int virgin = 1;
++    static code *lenfix, *distfix;
++    static code fixed[544];
++
++    /* build fixed huffman tables if first call (may not be thread safe) */
++    if (virgin) {
++        unsigned sym, bits;
++        static code *next;
++
++        /* literal/length table */
++        sym = 0;
++        while (sym < 144) state->lens[sym++] = 8;
++        while (sym < 256) state->lens[sym++] = 9;
++        while (sym < 280) state->lens[sym++] = 7;
++        while (sym < 288) state->lens[sym++] = 8;
++        next = fixed;
++        lenfix = next;
++        bits = 9;
++        inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
++
++        /* distance table */
++        sym = 0;
++        while (sym < 32) state->lens[sym++] = 5;
++        distfix = next;
++        bits = 5;
++        inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
++
++        /* do this just once */
++        virgin = 0;
++    }
++#else /* !BUILDFIXED */
++#   include "inffixed.h"
++#endif /* BUILDFIXED */
++    state->lencode = lenfix;
++    state->lenbits = 9;
++    state->distcode = distfix;
++    state->distbits = 5;
++}
++
++#ifdef MAKEFIXED
++#include <stdio.h>
++
++/*
++   Write out the inffixed.h that is #include'd above.  Defining MAKEFIXED also
++   defines BUILDFIXED, so the tables are built on the fly.  makefixed() writes
++   those tables to stdout, which would be piped to inffixed.h.  A small program
++   can simply call makefixed to do this:
++
++    void makefixed(void);
++
++    int main(void)
++    {
++        makefixed();
++        return 0;
++    }
++
++   Then that can be linked with zlib built with MAKEFIXED defined and run:
++
++    a.out > inffixed.h
++ */
++void makefixed()
++{
++    unsigned low, size;
++    struct inflate_state state;
++
++    fixedtables(&state);
++    puts("    /* inffixed.h -- table for decoding fixed codes");
++    puts("     * Generated automatically by makefixed().");
++    puts("     */");
++    puts("");
++    puts("    /* WARNING: this file should *not* be used by applications.");
++    puts("       It is part of the implementation of this library and is");
++    puts("       subject to change. Applications should only use zlib.h.");
++    puts("     */");
++    puts("");
++    size = 1U << 9;
++    printf("    static const code lenfix[%u] = {", size);
++    low = 0;
++    for (;;) {
++        if ((low % 7) == 0) printf("\n        ");
++        printf("{%u,%u,%d}", (low & 127) == 99 ? 64 : state.lencode[low].op,
++               state.lencode[low].bits, state.lencode[low].val);
++        if (++low == size) break;
++        putchar(',');
++    }
++    puts("\n    };");
++    size = 1U << 5;
++    printf("\n    static const code distfix[%u] = {", size);
++    low = 0;
++    for (;;) {
++        if ((low % 6) == 0) printf("\n        ");
++        printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits,
++               state.distcode[low].val);
++        if (++low == size) break;
++        putchar(',');
++    }
++    puts("\n    };");
++}
++#endif /* MAKEFIXED */
++
++/*
++   Update the window with the last wsize (normally 32K) bytes written before
++   returning.  If window does not exist yet, create it.  This is only called
++   when a window is already in use, or when output has been written during this
++   inflate call, but the end of the deflate stream has not been reached yet.
++   It is also called to create a window for dictionary data when a dictionary
++   is loaded.
++
++   Providing output buffers larger than 32K to inflate() should provide a speed
++   advantage, since only the last 32K of output is copied to the sliding window
++   upon return from inflate(), and since all distances after the first 32K of
++   output will fall in the output data, making match copies simpler and faster.
++   The advantage may be dependent on the size of the processor's data caches.
++ */
++local int updatewindow(strm, end, copy)
++z_streamp strm;
++const Bytef *end;
++unsigned copy;
++{
++    struct inflate_state FAR *state;
++    unsigned dist;
++
++    state = (struct inflate_state FAR *)strm->state;
++
++    /* if it hasn't been done already, allocate space for the window */
++    if (state->window == Z_NULL) {
++        state->window = (unsigned char FAR *)
++                        ZALLOC(strm, 1U << state->wbits,
++                               sizeof(unsigned char));
++        if (state->window == Z_NULL) return 1;
++    }
++
++    /* if window not in use yet, initialize */
++    if (state->wsize == 0) {
++        state->wsize = 1U << state->wbits;
++        state->wnext = 0;
++        state->whave = 0;
++    }
++
++    /* copy state->wsize or less output bytes into the circular window */
++    if (copy >= state->wsize) {
++        zmemcpy(state->window, end - state->wsize, state->wsize);
++        state->wnext = 0;
++        state->whave = state->wsize;
++    }
++    else {
++        dist = state->wsize - state->wnext;
++        if (dist > copy) dist = copy;
++        zmemcpy(state->window + state->wnext, end - copy, dist);
++        copy -= dist;
++        if (copy) {
++            zmemcpy(state->window, end - copy, copy);
++            state->wnext = copy;
++            state->whave = state->wsize;
++        }
++        else {
++            state->wnext += dist;
++            if (state->wnext == state->wsize) state->wnext = 0;
++            if (state->whave < state->wsize) state->whave += dist;
++        }
++    }
++    return 0;
++}
++
++/* Macros for inflate(): */
++
++/* check function to use adler32() for zlib or crc32() for gzip */
++#ifdef GUNZIP
++#  define UPDATE(check, buf, len) \
++    (state->flags ? crc32(check, buf, len) : adler32(check, buf, len))
++#else
++#  define UPDATE(check, buf, len) adler32(check, buf, len)
++#endif
++
++/* check macros for header crc */
++#ifdef GUNZIP
++#  define CRC2(check, word) \
++    do { \
++        hbuf[0] = (unsigned char)(word); \
++        hbuf[1] = (unsigned char)((word) >> 8); \
++        check = crc32(check, hbuf, 2); \
++    } while (0)
++
++#  define CRC4(check, word) \
++    do { \
++        hbuf[0] = (unsigned char)(word); \
++        hbuf[1] = (unsigned char)((word) >> 8); \
++        hbuf[2] = (unsigned char)((word) >> 16); \
++        hbuf[3] = (unsigned char)((word) >> 24); \
++        check = crc32(check, hbuf, 4); \
++    } while (0)
++#endif
++
++/* Load registers with state in inflate() for speed */
++#define LOAD() \
++    do { \
++        put = strm->next_out; \
++        left = strm->avail_out; \
++        next = strm->next_in; \
++        have = strm->avail_in; \
++        hold = state->hold; \
++        bits = state->bits; \
++    } while (0)
++
++/* Restore state from registers in inflate() */
++#define RESTORE() \
++    do { \
++        strm->next_out = put; \
++        strm->avail_out = left; \
++        strm->next_in = next; \
++        strm->avail_in = have; \
++        state->hold = hold; \
++        state->bits = bits; \
++    } while (0)
++
++/* Clear the input bit accumulator */
++#define INITBITS() \
++    do { \
++        hold = 0; \
++        bits = 0; \
++    } while (0)
++
++/* Get a byte of input into the bit accumulator, or return from inflate()
++   if there is no input available. */
++#define PULLBYTE() \
++    do { \
++        if (have == 0) goto inf_leave; \
++        have--; \
++        hold += (unsigned long)(*next++) << bits; \
++        bits += 8; \
++    } while (0)
++
++/* Assure that there are at least n bits in the bit accumulator.  If there is
++   not enough available input to do that, then return from inflate(). */
++#define NEEDBITS(n) \
++    do { \
++        while (bits < (unsigned)(n)) \
++            PULLBYTE(); \
++    } while (0)
++
++/* Return the low n bits of the bit accumulator (n < 16) */
++#define BITS(n) \
++    ((unsigned)hold & ((1U << (n)) - 1))
++
++/* Remove n bits from the bit accumulator */
++#define DROPBITS(n) \
++    do { \
++        hold >>= (n); \
++        bits -= (unsigned)(n); \
++    } while (0)
++
++/* Remove zero to seven bits as needed to go to a byte boundary */
++#define BYTEBITS() \
++    do { \
++        hold >>= bits & 7; \
++        bits -= bits & 7; \
++    } while (0)
++
++/*
++   inflate() uses a state machine to process as much input data and generate as
++   much output data as possible before returning.  The state machine is
++   structured roughly as follows:
++
++    for (;;) switch (state) {
++    ...
++    case STATEn:
++        if (not enough input data or output space to make progress)
++            return;
++        ... make progress ...
++        state = STATEm;
++        break;
++    ...
++    }
++
++   so when inflate() is called again, the same case is attempted again, and
++   if the appropriate resources are provided, the machine proceeds to the
++   next state.  The NEEDBITS() macro is usually the way the state evaluates
++   whether it can proceed or should return.  NEEDBITS() does the return if
++   the requested bits are not available.  The typical use of the BITS macros
++   is:
++
++        NEEDBITS(n);
++        ... do something with BITS(n) ...
++        DROPBITS(n);
++
++   where NEEDBITS(n) either returns from inflate() if there isn't enough
++   input left to load n bits into the accumulator, or it continues.  BITS(n)
++   gives the low n bits in the accumulator.  When done, DROPBITS(n) drops
++   the low n bits off the accumulator.  INITBITS() clears the accumulator
++   and sets the number of available bits to zero.  BYTEBITS() discards just
++   enough bits to put the accumulator on a byte boundary.  After BYTEBITS()
++   and a NEEDBITS(8), then BITS(8) would return the next byte in the stream.
++
++   NEEDBITS(n) uses PULLBYTE() to get an available byte of input, or to return
++   if there is no input available.  The decoding of variable length codes uses
++   PULLBYTE() directly in order to pull just enough bytes to decode the next
++   code, and no more.
++
++   Some states loop until they get enough input, making sure that enough
++   state information is maintained to continue the loop where it left off
++   if NEEDBITS() returns in the loop.  For example, want, need, and keep
++   would all have to actually be part of the saved state in case NEEDBITS()
++   returns:
++
++    case STATEw:
++        while (want < need) {
++            NEEDBITS(n);
++            keep[want++] = BITS(n);
++            DROPBITS(n);
++        }
++        state = STATEx;
++    case STATEx:
++
++   As shown above, if the next state is also the next case, then the break
++   is omitted.
++
++   A state may also return if there is not enough output space available to
++   complete that state.  Those states are copying stored data, writing a
++   literal byte, and copying a matching string.
++
++   When returning, a "goto inf_leave" is used to update the total counters,
++   update the check value, and determine whether any progress has been made
++   during that inflate() call in order to return the proper return code.
++   Progress is defined as a change in either strm->avail_in or strm->avail_out.
++   When there is a window, goto inf_leave will update the window with the last
++   output written.  If a goto inf_leave occurs in the middle of decompression
++   and there is no window currently, goto inf_leave will create one and copy
++   output to the window for the next call of inflate().
++
++   In this implementation, the flush parameter of inflate() only affects the
++   return code (per zlib.h).  inflate() always writes as much as possible to
++   strm->next_out, given the space available and the provided input--the effect
++   documented in zlib.h of Z_SYNC_FLUSH.  Furthermore, inflate() always defers
++   the allocation of and copying into a sliding window until necessary, which
++   provides the effect documented in zlib.h for Z_FINISH when the entire input
++   stream available.  So the only thing the flush parameter actually does is:
++   when flush is set to Z_FINISH, inflate() cannot return Z_OK.  Instead it
++   will return Z_BUF_ERROR if it has not reached the end of the stream.
++ */
++
++int ZEXPORT inflate(strm, flush)
++z_streamp strm;
++int flush;
++{
++    struct inflate_state FAR *state;
++    z_const unsigned char FAR *next;    /* next input */
++    unsigned char FAR *put;     /* next output */
++    unsigned have, left;        /* available input and output */
++    unsigned long hold;         /* bit buffer */
++    unsigned bits;              /* bits in bit buffer */
++    unsigned in, out;           /* save starting available input and output */
++    unsigned copy;              /* number of stored or match bytes to copy */
++    unsigned char FAR *from;    /* where to copy match bytes from */
++    code here;                  /* current decoding table entry */
++    code last;                  /* parent table entry */
++    unsigned len;               /* length to copy for repeats, bits to drop */
++    int ret;                    /* return code */
++#ifdef GUNZIP
++    unsigned char hbuf[4];      /* buffer for gzip header crc calculation */
++#endif
++    static const unsigned short order[19] = /* permutation of code lengths */
++        {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
++
++    if (inflateStateCheck(strm) || strm->next_out == Z_NULL ||
++        (strm->next_in == Z_NULL && strm->avail_in != 0))
++        return Z_STREAM_ERROR;
++
++    state = (struct inflate_state FAR *)strm->state;
++    if (state->mode == TYPE) state->mode = TYPEDO;      /* skip check */
++    LOAD();
++    in = have;
++    out = left;
++    ret = Z_OK;
++    for (;;)
++        switch (state->mode) {
++        case HEAD:
++            if (state->wrap == 0) {
++                state->mode = TYPEDO;
++                break;
++            }
++            NEEDBITS(16);
++#ifdef GUNZIP
++            if ((state->wrap & 2) && hold == 0x8b1f) {  /* gzip header */
++                if (state->wbits == 0)
++                    state->wbits = 15;
++                state->check = crc32(0L, Z_NULL, 0);
++                CRC2(state->check, hold);
++                INITBITS();
++                state->mode = FLAGS;
++                break;
++            }
++            state->flags = 0;           /* expect zlib header */
++            if (state->head != Z_NULL)
++                state->head->done = -1;
++            if (!(state->wrap & 1) ||   /* check if zlib header allowed */
++#else
++            if (
++#endif
++                ((BITS(8) << 8) + (hold >> 8)) % 31) {
++                strm->msg = (char *)"incorrect header check";
++                state->mode = BAD;
++                break;
++            }
++            if (BITS(4) != Z_DEFLATED) {
++                strm->msg = (char *)"unknown compression method";
++                state->mode = BAD;
++                break;
++            }
++            DROPBITS(4);
++            len = BITS(4) + 8;
++            if (state->wbits == 0)
++                state->wbits = len;
++            if (len > 15 || len > state->wbits) {
++                strm->msg = (char *)"invalid window size";
++                state->mode = BAD;
++                break;
++            }
++            state->dmax = 1U << len;
++            Tracev((stderr, "inflate:   zlib header ok\n"));
++            strm->adler = state->check = adler32(0L, Z_NULL, 0);
++            state->mode = hold & 0x200 ? DICTID : TYPE;
++            INITBITS();
++            break;
++#ifdef GUNZIP
++        case FLAGS:
++            NEEDBITS(16);
++            state->flags = (int)(hold);
++            if ((state->flags & 0xff) != Z_DEFLATED) {
++                strm->msg = (char *)"unknown compression method";
++                state->mode = BAD;
++                break;
++            }
++            if (state->flags & 0xe000) {
++                strm->msg = (char *)"unknown header flags set";
++                state->mode = BAD;
++                break;
++            }
++            if (state->head != Z_NULL)
++                state->head->text = (int)((hold >> 8) & 1);
++            if ((state->flags & 0x0200) && (state->wrap & 4))
++                CRC2(state->check, hold);
++            INITBITS();
++            state->mode = TIME;
++        case TIME:
++            NEEDBITS(32);
++            if (state->head != Z_NULL)
++                state->head->time = hold;
++            if ((state->flags & 0x0200) && (state->wrap & 4))
++                CRC4(state->check, hold);
++            INITBITS();
++            state->mode = OS;
++        case OS:
++            NEEDBITS(16);
++            if (state->head != Z_NULL) {
++                state->head->xflags = (int)(hold & 0xff);
++                state->head->os = (int)(hold >> 8);
++            }
++            if ((state->flags & 0x0200) && (state->wrap & 4))
++                CRC2(state->check, hold);
++            INITBITS();
++            state->mode = EXLEN;
++        case EXLEN:
++            if (state->flags & 0x0400) {
++                NEEDBITS(16);
++                state->length = (unsigned)(hold);
++                if (state->head != Z_NULL)
++                    state->head->extra_len = (unsigned)hold;
++                if ((state->flags & 0x0200) && (state->wrap & 4))
++                    CRC2(state->check, hold);
++                INITBITS();
++            }
++            else if (state->head != Z_NULL)
++                state->head->extra = Z_NULL;
++            state->mode = EXTRA;
++        case EXTRA:
++            if (state->flags & 0x0400) {
++                copy = state->length;
++                if (copy > have) copy = have;
++                if (copy) {
++                    if (state->head != Z_NULL &&
++                        state->head->extra != Z_NULL) {
++                        len = state->head->extra_len - state->length;
++                        zmemcpy(state->head->extra + len, next,
++                                len + copy > state->head->extra_max ?
++                                state->head->extra_max - len : copy);
++                    }
++                    if ((state->flags & 0x0200) && (state->wrap & 4))
++                        state->check = crc32(state->check, next, copy);
++                    have -= copy;
++                    next += copy;
++                    state->length -= copy;
++                }
++                if (state->length) goto inf_leave;
++            }
++            state->length = 0;
++            state->mode = NAME;
++        case NAME:
++            if (state->flags & 0x0800) {
++                if (have == 0) goto inf_leave;
++                copy = 0;
++                do {
++                    len = (unsigned)(next[copy++]);
++                    if (state->head != Z_NULL &&
++                            state->head->name != Z_NULL &&
++                            state->length < state->head->name_max)
++                        state->head->name[state->length++] = (Bytef)len;
++                } while (len && copy < have);
++                if ((state->flags & 0x0200) && (state->wrap & 4))
++                    state->check = crc32(state->check, next, copy);
++                have -= copy;
++                next += copy;
++                if (len) goto inf_leave;
++            }
++            else if (state->head != Z_NULL)
++                state->head->name = Z_NULL;
++            state->length = 0;
++            state->mode = COMMENT;
++        case COMMENT:
++            if (state->flags & 0x1000) {
++                if (have == 0) goto inf_leave;
++                copy = 0;
++                do {
++                    len = (unsigned)(next[copy++]);
++                    if (state->head != Z_NULL &&
++                            state->head->comment != Z_NULL &&
++                            state->length < state->head->comm_max)
++                        state->head->comment[state->length++] = (Bytef)len;
++                } while (len && copy < have);
++                if ((state->flags & 0x0200) && (state->wrap & 4))
++                    state->check = crc32(state->check, next, copy);
++                have -= copy;
++                next += copy;
++                if (len) goto inf_leave;
++            }
++            else if (state->head != Z_NULL)
++                state->head->comment = Z_NULL;
++            state->mode = HCRC;
++        case HCRC:
++            if (state->flags & 0x0200) {
++                NEEDBITS(16);
++                if ((state->wrap & 4) && hold != (state->check & 0xffff)) {
++                    strm->msg = (char *)"header crc mismatch";
++                    state->mode = BAD;
++                    break;
++                }
++                INITBITS();
++            }
++            if (state->head != Z_NULL) {
++                state->head->hcrc = (int)((state->flags >> 9) & 1);
++                state->head->done = 1;
++            }
++            strm->adler = state->check = crc32(0L, Z_NULL, 0);
++            state->mode = TYPE;
++            break;
++#endif
++        case DICTID:
++            NEEDBITS(32);
++            strm->adler = state->check = ZSWAP32(hold);
++            INITBITS();
++            state->mode = DICT;
++        case DICT:
++            if (state->havedict == 0) {
++                RESTORE();
++                return Z_NEED_DICT;
++            }
++            strm->adler = state->check = adler32(0L, Z_NULL, 0);
++            state->mode = TYPE;
++        case TYPE:
++            if (flush == Z_BLOCK || flush == Z_TREES) goto inf_leave;
++        case TYPEDO:
++            if (state->last) {
++                BYTEBITS();
++                state->mode = CHECK;
++                break;
++            }
++            NEEDBITS(3);
++            state->last = BITS(1);
++            DROPBITS(1);
++            switch (BITS(2)) {
++            case 0:                             /* stored block */
++                Tracev((stderr, "inflate:     stored block%s\n",
++                        state->last ? " (last)" : ""));
++                state->mode = STORED;
++                break;
++            case 1:                             /* fixed block */
++                fixedtables(state);
++                Tracev((stderr, "inflate:     fixed codes block%s\n",
++                        state->last ? " (last)" : ""));
++                state->mode = LEN_;             /* decode codes */
++                if (flush == Z_TREES) {
++                    DROPBITS(2);
++                    goto inf_leave;
++                }
++                break;
++            case 2:                             /* dynamic block */
++                Tracev((stderr, "inflate:     dynamic codes block%s\n",
++                        state->last ? " (last)" : ""));
++                state->mode = TABLE;
++                break;
++            case 3:
++                strm->msg = (char *)"invalid block type";
++                state->mode = BAD;
++            }
++            DROPBITS(2);
++            break;
++        case STORED:
++            BYTEBITS();                         /* go to byte boundary */
++            NEEDBITS(32);
++            if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
++                strm->msg = (char *)"invalid stored block lengths";
++                state->mode = BAD;
++                break;
++            }
++            state->length = (unsigned)hold & 0xffff;
++            Tracev((stderr, "inflate:       stored length %u\n",
++                    state->length));
++            INITBITS();
++            state->mode = COPY_;
++            if (flush == Z_TREES) goto inf_leave;
++        case COPY_:
++            state->mode = COPY;
++        case COPY:
++            copy = state->length;
++            if (copy) {
++                if (copy > have) copy = have;
++                if (copy > left) copy = left;
++                if (copy == 0) goto inf_leave;
++                zmemcpy(put, next, copy);
++                have -= copy;
++                next += copy;
++                left -= copy;
++                put += copy;
++                state->length -= copy;
++                break;
++            }
++            Tracev((stderr, "inflate:       stored end\n"));
++            state->mode = TYPE;
++            break;
++        case TABLE:
++            NEEDBITS(14);
++            state->nlen = BITS(5) + 257;
++            DROPBITS(5);
++            state->ndist = BITS(5) + 1;
++            DROPBITS(5);
++            state->ncode = BITS(4) + 4;
++            DROPBITS(4);
++#ifndef PKZIP_BUG_WORKAROUND
++            if (state->nlen > 286 || state->ndist > 30) {
++                strm->msg = (char *)"too many length or distance symbols";
++                state->mode = BAD;
++                break;
++            }
++#endif
++            Tracev((stderr, "inflate:       table sizes ok\n"));
++            state->have = 0;
++            state->mode = LENLENS;
++        case LENLENS:
++            while (state->have < state->ncode) {
++                NEEDBITS(3);
++                state->lens[order[state->have++]] = (unsigned short)BITS(3);
++                DROPBITS(3);
++            }
++            while (state->have < 19)
++                state->lens[order[state->have++]] = 0;
++            state->next = state->codes;
++            state->lencode = (const code FAR *)(state->next);
++            state->lenbits = 7;
++            ret = inflate_table(CODES, state->lens, 19, &(state->next),
++                                &(state->lenbits), state->work);
++            if (ret) {
++                strm->msg = (char *)"invalid code lengths set";
++                state->mode = BAD;
++                break;
++            }
++            Tracev((stderr, "inflate:       code lengths ok\n"));
++            state->have = 0;
++            state->mode = CODELENS;
++        case CODELENS:
++            while (state->have < state->nlen + state->ndist) {
++                for (;;) {
++                    here = state->lencode[BITS(state->lenbits)];
++                    if ((unsigned)(here.bits) <= bits) break;
++                    PULLBYTE();
++                }
++                if (here.val < 16) {
++                    DROPBITS(here.bits);
++                    state->lens[state->have++] = here.val;
++                }
++                else {
++                    if (here.val == 16) {
++                        NEEDBITS(here.bits + 2);
++                        DROPBITS(here.bits);
++                        if (state->have == 0) {
++                            strm->msg = (char *)"invalid bit length repeat";
++                            state->mode = BAD;
++                            break;
++                        }
++                        len = state->lens[state->have - 1];
++                        copy = 3 + BITS(2);
++                        DROPBITS(2);
++                    }
++                    else if (here.val == 17) {
++                        NEEDBITS(here.bits + 3);
++                        DROPBITS(here.bits);
++                        len = 0;
++                        copy = 3 + BITS(3);
++                        DROPBITS(3);
++                    }
++                    else {
++                        NEEDBITS(here.bits + 7);
++                        DROPBITS(here.bits);
++                        len = 0;
++                        copy = 11 + BITS(7);
++                        DROPBITS(7);
++                    }
++                    if (state->have + copy > state->nlen + state->ndist) {
++                        strm->msg = (char *)"invalid bit length repeat";
++                        state->mode = BAD;
++                        break;
++                    }
++                    while (copy--)
++                        state->lens[state->have++] = (unsigned short)len;
++                }
++            }
++
++            /* handle error breaks in while */
++            if (state->mode == BAD) break;
++
++            /* check for end-of-block code (better have one) */
++            if (state->lens[256] == 0) {
++                strm->msg = (char *)"invalid code -- missing end-of-block";
++                state->mode = BAD;
++                break;
++            }
++
++            /* build code tables -- note: do not change the lenbits or distbits
++               values here (9 and 6) without reading the comments in inftrees.h
++               concerning the ENOUGH constants, which depend on those values */
++            state->next = state->codes;
++            state->lencode = (const code FAR *)(state->next);
++            state->lenbits = 9;
++            ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
++                                &(state->lenbits), state->work);
++            if (ret) {
++                strm->msg = (char *)"invalid literal/lengths set";
++                state->mode = BAD;
++                break;
++            }
++            state->distcode = (const code FAR *)(state->next);
++            state->distbits = 6;
++            ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
++                            &(state->next), &(state->distbits), state->work);
++            if (ret) {
++                strm->msg = (char *)"invalid distances set";
++                state->mode = BAD;
++                break;
++            }
++            Tracev((stderr, "inflate:       codes ok\n"));
++            state->mode = LEN_;
++            if (flush == Z_TREES) goto inf_leave;
++        case LEN_:
++            state->mode = LEN;
++        case LEN:
++            if (have >= 6 && left >= 258) {
++                RESTORE();
++                inflate_fast(strm, out);
++                LOAD();
++                if (state->mode == TYPE)
++                    state->back = -1;
++                break;
++            }
++            state->back = 0;
++            for (;;) {
++                here = state->lencode[BITS(state->lenbits)];
++                if ((unsigned)(here.bits) <= bits) break;
++                PULLBYTE();
++            }
++            if (here.op && (here.op & 0xf0) == 0) {
++                last = here;
++                for (;;) {
++                    here = state->lencode[last.val +
++                            (BITS(last.bits + last.op) >> last.bits)];
++                    if ((unsigned)(last.bits + here.bits) <= bits) break;
++                    PULLBYTE();
++                }
++                DROPBITS(last.bits);
++                state->back += last.bits;
++            }
++            DROPBITS(here.bits);
++            state->back += here.bits;
++            state->length = (unsigned)here.val;
++            if ((int)(here.op) == 0) {
++                Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
++                        "inflate:         literal '%c'\n" :
++                        "inflate:         literal 0x%02x\n", here.val));
++                state->mode = LIT;
++                break;
++            }
++            if (here.op & 32) {
++                Tracevv((stderr, "inflate:         end of block\n"));
++                state->back = -1;
++                state->mode = TYPE;
++                break;
++            }
++            if (here.op & 64) {
++                strm->msg = (char *)"invalid literal/length code";
++                state->mode = BAD;
++                break;
++            }
++            state->extra = (unsigned)(here.op) & 15;
++            state->mode = LENEXT;
++        case LENEXT:
++            if (state->extra) {
++                NEEDBITS(state->extra);
++                state->length += BITS(state->extra);
++                DROPBITS(state->extra);
++                state->back += state->extra;
++            }
++            Tracevv((stderr, "inflate:         length %u\n", state->length));
++            state->was = state->length;
++            state->mode = DIST;
++        case DIST:
++            for (;;) {
++                here = state->distcode[BITS(state->distbits)];
++                if ((unsigned)(here.bits) <= bits) break;
++                PULLBYTE();
++            }
++            if ((here.op & 0xf0) == 0) {
++                last = here;
++                for (;;) {
++                    here = state->distcode[last.val +
++                            (BITS(last.bits + last.op) >> last.bits)];
++                    if ((unsigned)(last.bits + here.bits) <= bits) break;
++                    PULLBYTE();
++                }
++                DROPBITS(last.bits);
++                state->back += last.bits;
++            }
++            DROPBITS(here.bits);
++            state->back += here.bits;
++            if (here.op & 64) {
++                strm->msg = (char *)"invalid distance code";
++                state->mode = BAD;
++                break;
++            }
++            state->offset = (unsigned)here.val;
++            state->extra = (unsigned)(here.op) & 15;
++            state->mode = DISTEXT;
++        case DISTEXT:
++            if (state->extra) {
++                NEEDBITS(state->extra);
++                state->offset += BITS(state->extra);
++                DROPBITS(state->extra);
++                state->back += state->extra;
++            }
++#ifdef INFLATE_STRICT
++            if (state->offset > state->dmax) {
++                strm->msg = (char *)"invalid distance too far back";
++                state->mode = BAD;
++                break;
++            }
++#endif
++            Tracevv((stderr, "inflate:         distance %u\n", state->offset));
++            state->mode = MATCH;
++        case MATCH:
++            if (left == 0) goto inf_leave;
++            copy = out - left;
++            if (state->offset > copy) {         /* copy from window */
++                copy = state->offset - copy;
++                if (copy > state->whave) {
++                    if (state->sane) {
++                        strm->msg = (char *)"invalid distance too far back";
++                        state->mode = BAD;
++                        break;
++                    }
++#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
++                    Trace((stderr, "inflate.c too far\n"));
++                    copy -= state->whave;
++                    if (copy > state->length) copy = state->length;
++                    if (copy > left) copy = left;
++                    left -= copy;
++                    state->length -= copy;
++                    do {
++                        *put++ = 0;
++                    } while (--copy);
++                    if (state->length == 0) state->mode = LEN;
++                    break;
++#endif
++                }
++                if (copy > state->wnext) {
++                    copy -= state->wnext;
++                    from = state->window + (state->wsize - copy);
++                }
++                else
++                    from = state->window + (state->wnext - copy);
++                if (copy > state->length) copy = state->length;
++            }
++            else {                              /* copy from output */
++                from = put - state->offset;
++                copy = state->length;
++            }
++            if (copy > left) copy = left;
++            left -= copy;
++            state->length -= copy;
++            do {
++                *put++ = *from++;
++            } while (--copy);
++            if (state->length == 0) state->mode = LEN;
++            break;
++        case LIT:
++            if (left == 0) goto inf_leave;
++            *put++ = (unsigned char)(state->length);
++            left--;
++            state->mode = LEN;
++            break;
++        case CHECK:
++            if (state->wrap) {
++                NEEDBITS(32);
++                out -= left;
++                strm->total_out += out;
++                state->total += out;
++                if ((state->wrap & 4) && out)
++                    strm->adler = state->check =
++                        UPDATE(state->check, put - out, out);
++                out = left;
++                if ((state->wrap & 4) && (
++#ifdef GUNZIP
++                     state->flags ? hold :
++#endif
++                     ZSWAP32(hold)) != state->check) {
++                    strm->msg = (char *)"incorrect data check";
++                    state->mode = BAD;
++                    break;
++                }
++                INITBITS();
++                Tracev((stderr, "inflate:   check matches trailer\n"));
++            }
++#ifdef GUNZIP
++            state->mode = LENGTH;
++        case LENGTH:
++            if (state->wrap && state->flags) {
++                NEEDBITS(32);
++                if (hold != (state->total & 0xffffffffUL)) {
++                    strm->msg = (char *)"incorrect length check";
++                    state->mode = BAD;
++                    break;
++                }
++                INITBITS();
++                Tracev((stderr, "inflate:   length matches trailer\n"));
++            }
++#endif
++            state->mode = DONE;
++        case DONE:
++            ret = Z_STREAM_END;
++            goto inf_leave;
++        case BAD:
++            ret = Z_DATA_ERROR;
++            goto inf_leave;
++        case MEM:
++            return Z_MEM_ERROR;
++        case SYNC:
++        default:
++            return Z_STREAM_ERROR;
++        }
++
++    /*
++       Return from inflate(), updating the total counts and the check value.
++       If there was no progress during the inflate() call, return a buffer
++       error.  Call updatewindow() to create and/or update the window state.
++       Note: a memory error from inflate() is non-recoverable.
++     */
++  inf_leave:
++    RESTORE();
++    if (state->wsize || (out != strm->avail_out && state->mode < BAD &&
++            (state->mode < CHECK || flush != Z_FINISH)))
++        if (updatewindow(strm, strm->next_out, out - strm->avail_out)) {
++            state->mode = MEM;
++            return Z_MEM_ERROR;
++        }
++    in -= strm->avail_in;
++    out -= strm->avail_out;
++    strm->total_in += in;
++    strm->total_out += out;
++    state->total += out;
++    if ((state->wrap & 4) && out)
++        strm->adler = state->check =
++            UPDATE(state->check, strm->next_out - out, out);
++    strm->data_type = (int)state->bits + (state->last ? 64 : 0) +
++                      (state->mode == TYPE ? 128 : 0) +
++                      (state->mode == LEN_ || state->mode == COPY_ ? 256 : 0);
++    if (((in == 0 && out == 0) || flush == Z_FINISH) && ret == Z_OK)
++        ret = Z_BUF_ERROR;
++    return ret;
++}
++
++int ZEXPORT inflateEnd(strm)
++z_streamp strm;
++{
++    struct inflate_state FAR *state;
++    if (inflateStateCheck(strm))
++        return Z_STREAM_ERROR;
++    state = (struct inflate_state FAR *)strm->state;
++    if (state->window != Z_NULL) ZFREE(strm, state->window);
++    ZFREE(strm, strm->state);
++    strm->state = Z_NULL;
++    Tracev((stderr, "inflate: end\n"));
++    return Z_OK;
++}
++
++int ZEXPORT inflateGetDictionary(strm, dictionary, dictLength)
++z_streamp strm;
++Bytef *dictionary;
++uInt *dictLength;
++{
++    struct inflate_state FAR *state;
++
++    /* check state */
++    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
++    state = (struct inflate_state FAR *)strm->state;
++
++    /* copy dictionary */
++    if (state->whave && dictionary != Z_NULL) {
++        zmemcpy(dictionary, state->window + state->wnext,
++                state->whave - state->wnext);
++        zmemcpy(dictionary + state->whave - state->wnext,
++                state->window, state->wnext);
++    }
++    if (dictLength != Z_NULL)
++        *dictLength = state->whave;
++    return Z_OK;
++}
++
++int ZEXPORT inflateSetDictionary(strm, dictionary, dictLength)
++z_streamp strm;
++const Bytef *dictionary;
++uInt dictLength;
++{
++    struct inflate_state FAR *state;
++    unsigned long dictid;
++    int ret;
++
++    /* check state */
++    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
++    state = (struct inflate_state FAR *)strm->state;
++    if (state->wrap != 0 && state->mode != DICT)
++        return Z_STREAM_ERROR;
++
++    /* check for correct dictionary identifier */
++    if (state->mode == DICT) {
++        dictid = adler32(0L, Z_NULL, 0);
++        dictid = adler32(dictid, dictionary, dictLength);
++        if (dictid != state->check)
++            return Z_DATA_ERROR;
++    }
++
++    /* copy dictionary to window using updatewindow(), which will amend the
++       existing dictionary if appropriate */
++    ret = updatewindow(strm, dictionary + dictLength, dictLength);
++    if (ret) {
++        state->mode = MEM;
++        return Z_MEM_ERROR;
++    }
++    state->havedict = 1;
++    Tracev((stderr, "inflate:   dictionary set\n"));
++    return Z_OK;
++}
++
++int ZEXPORT inflateGetHeader(strm, head)
++z_streamp strm;
++gz_headerp head;
++{
++    struct inflate_state FAR *state;
++
++    /* check state */
++    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
++    state = (struct inflate_state FAR *)strm->state;
++    if ((state->wrap & 2) == 0) return Z_STREAM_ERROR;
++
++    /* save header structure */
++    state->head = head;
++    head->done = 0;
++    return Z_OK;
++}
++
++/*
++   Search buf[0..len-1] for the pattern: 0, 0, 0xff, 0xff.  Return when found
++   or when out of input.  When called, *have is the number of pattern bytes
++   found in order so far, in 0..3.  On return *have is updated to the new
++   state.  If on return *have equals four, then the pattern was found and the
++   return value is how many bytes were read including the last byte of the
++   pattern.  If *have is less than four, then the pattern has not been found
++   yet and the return value is len.  In the latter case, syncsearch() can be
++   called again with more data and the *have state.  *have is initialized to
++   zero for the first call.
++ */
++local unsigned syncsearch(have, buf, len)
++unsigned FAR *have;
++const unsigned char FAR *buf;
++unsigned len;
++{
++    unsigned got;
++    unsigned next;
++
++    got = *have;
++    next = 0;
++    while (next < len && got < 4) {
++        if ((int)(buf[next]) == (got < 2 ? 0 : 0xff))
++            got++;
++        else if (buf[next])
++            got = 0;
++        else
++            got = 4 - got;
++        next++;
++    }
++    *have = got;
++    return next;
++}
++
++int ZEXPORT inflateSync(strm)
++z_streamp strm;
++{
++    unsigned len;               /* number of bytes to look at or looked at */
++    unsigned long in, out;      /* temporary to save total_in and total_out */
++    unsigned char buf[4];       /* to restore bit buffer to byte string */
++    struct inflate_state FAR *state;
++
++    /* check parameters */
++    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
++    state = (struct inflate_state FAR *)strm->state;
++    if (strm->avail_in == 0 && state->bits < 8) return Z_BUF_ERROR;
++
++    /* if first time, start search in bit buffer */
++    if (state->mode != SYNC) {
++        state->mode = SYNC;
++        state->hold <<= state->bits & 7;
++        state->bits -= state->bits & 7;
++        len = 0;
++        while (state->bits >= 8) {
++            buf[len++] = (unsigned char)(state->hold);
++            state->hold >>= 8;
++            state->bits -= 8;
++        }
++        state->have = 0;
++        syncsearch(&(state->have), buf, len);
++    }
++
++    /* search available input */
++    len = syncsearch(&(state->have), strm->next_in, strm->avail_in);
++    strm->avail_in -= len;
++    strm->next_in += len;
++    strm->total_in += len;
++
++    /* return no joy or set up to restart inflate() on a new block */
++    if (state->have != 4) return Z_DATA_ERROR;
++    in = strm->total_in;  out = strm->total_out;
++    inflateReset(strm);
++    strm->total_in = in;  strm->total_out = out;
++    state->mode = TYPE;
++    return Z_OK;
++}
++
++/*
++   Returns true if inflate is currently at the end of a block generated by
++   Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
++   implementation to provide an additional safety check. PPP uses
++   Z_SYNC_FLUSH but removes the length bytes of the resulting empty stored
++   block. When decompressing, PPP checks that at the end of input packet,
++   inflate is waiting for these length bytes.
++ */
++int ZEXPORT inflateSyncPoint(strm)
++z_streamp strm;
++{
++    struct inflate_state FAR *state;
++
++    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
++    state = (struct inflate_state FAR *)strm->state;
++    return state->mode == STORED && state->bits == 0;
++}
++
++int ZEXPORT inflateCopy(dest, source)
++z_streamp dest;
++z_streamp source;
++{
++    struct inflate_state FAR *state;
++    struct inflate_state FAR *copy;
++    unsigned char FAR *window;
++    unsigned wsize;
++
++    /* check input */
++    if (inflateStateCheck(source) || dest == Z_NULL)
++        return Z_STREAM_ERROR;
++    state = (struct inflate_state FAR *)source->state;
++
++    /* allocate space */
++    copy = (struct inflate_state FAR *)
++           ZALLOC(source, 1, sizeof(struct inflate_state));
++    if (copy == Z_NULL) return Z_MEM_ERROR;
++    window = Z_NULL;
++    if (state->window != Z_NULL) {
++        window = (unsigned char FAR *)
++                 ZALLOC(source, 1U << state->wbits, sizeof(unsigned char));
++        if (window == Z_NULL) {
++            ZFREE(source, copy);
++            return Z_MEM_ERROR;
++        }
++    }
++
++    /* copy state */
++    zmemcpy((voidpf)dest, (voidpf)source, sizeof(z_stream));
++    zmemcpy((voidpf)copy, (voidpf)state, sizeof(struct inflate_state));
++    copy->strm = dest;
++    if (state->lencode >= state->codes &&
++        state->lencode <= state->codes + ENOUGH - 1) {
++        copy->lencode = copy->codes + (state->lencode - state->codes);
++        copy->distcode = copy->codes + (state->distcode - state->codes);
++    }
++    copy->next = copy->codes + (state->next - state->codes);
++    if (window != Z_NULL) {
++        wsize = 1U << state->wbits;
++        zmemcpy(window, state->window, wsize);
++    }
++    copy->window = window;
++    dest->state = (struct internal_state FAR *)copy;
++    return Z_OK;
++}
++
++int ZEXPORT inflateUndermine(strm, subvert)
++z_streamp strm;
++int subvert;
++{
++    struct inflate_state FAR *state;
++
++    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
++    state = (struct inflate_state FAR *)strm->state;
++#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
++    state->sane = !subvert;
++    return Z_OK;
++#else
++    (void)subvert;
++    state->sane = 1;
++    return Z_DATA_ERROR;
++#endif
++}
++
++int ZEXPORT inflateValidate(strm, check)
++z_streamp strm;
++int check;
++{
++    struct inflate_state FAR *state;
++
++    if (inflateStateCheck(strm)) return Z_STREAM_ERROR;
++    state = (struct inflate_state FAR *)strm->state;
++    if (check)
++        state->wrap |= 4;
++    else
++        state->wrap &= ~4;
++    return Z_OK;
++}
++
++long ZEXPORT inflateMark(strm)
++z_streamp strm;
++{
++    struct inflate_state FAR *state;
++
++    if (inflateStateCheck(strm))
++        return -(1L << 16);
++    state = (struct inflate_state FAR *)strm->state;
++    return (long)(((unsigned long)((long)state->back)) << 16) +
++        (state->mode == COPY ? state->length :
++            (state->mode == MATCH ? state->was - state->length : 0));
++}
++
++unsigned long ZEXPORT inflateCodesUsed(strm)
++z_streamp strm;
++{
++    struct inflate_state FAR *state;
++    if (inflateStateCheck(strm)) return (unsigned long)-1;
++    state = (struct inflate_state FAR *)strm->state;
++    return (unsigned long)(state->next - state->codes);
++}
diff --git a/package/libs/zlib/patches/003-arm-specific-optimisations-for-inflate.patch b/package/libs/zlib/patches/003-arm-specific-optimisations-for-inflate.patch
new file mode 100644
index 0000000..1f83b50
--- /dev/null
+++ b/package/libs/zlib/patches/003-arm-specific-optimisations-for-inflate.patch
@@ -0,0 +1,496 @@
+From 247147654fe5cd11cf15d8dff91440405ea57040 Mon Sep 17 00:00:00 2001
+From: Simon Hosie <simon.hosie@arm.com>
+Date: Wed, 12 Apr 2017 15:44:21 -0700
+Subject: [PATCH 2/2] Inflate using wider loads and stores
+
+In inflate_fast() the output pointer always has plenty of room to write. This
+means that so long as the target is capable, wide un-aligned loads and stores
+can be used to transfer several bytes at once. When the reference distance is
+too short simply unroll the data a little to increase the distance.
+
+Change-Id: I59854eb25d2b1e43561c8a2afaf9175bf10cf674
+---
+ contrib/arm/chunkcopy.h | 279 ++++++++++++++++++++++++++++++++++++++++++++++++
+ contrib/arm/inffast.c   |  96 +++++++----------
+ contrib/arm/inflate.c   |  22 ++--
+ 3 files changed, 335 insertions(+), 62 deletions(-)
+ create mode 100644 contrib/arm/chunkcopy.h
+
+--- /dev/null
++++ b/contrib/arm/chunkcopy.h
+@@ -0,0 +1,279 @@
++/* chunkcopy.h -- fast copies and sets
++ * Copyright (C) 2017 ARM, Inc.
++ * For conditions of distribution and use, see copyright notice in zlib.h
++ */
++
++#ifndef CHUNKCOPY_H
++#define CHUNKCOPY_H
++
++#include "zutil.h"
++#include <arm_neon.h>
++
++#if __STDC_VERSION__ >= 199901L
++#define Z_RESTRICT restrict
++#else
++#define Z_RESTRICT
++#endif
++
++typedef uint8x16_t chunkcopy_chunk_t;
++#define CHUNKCOPY_CHUNK_SIZE sizeof(chunkcopy_chunk_t)
++
++/*
++   Ask the compiler to perform a wide, unaligned load with an machine
++   instruction appropriate for the chunkcopy_chunk_t type.
++ */
++static inline chunkcopy_chunk_t loadchunk(const unsigned char FAR *s) {
++    chunkcopy_chunk_t c;
++    __builtin_memcpy(&c, s, sizeof(c));
++    return c;
++}
++
++/*
++   Ask the compiler to perform a wide, unaligned store with an machine
++   instruction appropriate for the chunkcopy_chunk_t type.
++ */
++static inline void storechunk(unsigned char FAR *d, chunkcopy_chunk_t c) {
++    __builtin_memcpy(d, &c, sizeof(c));
++}
++
++/*
++   Perform a memcpy-like operation, but assume that length is non-zero and that
++   it's OK to overwrite at least CHUNKCOPY_CHUNK_SIZE bytes of output even if
++   the length is shorter than this.
++
++   It also guarantees that it will properly unroll the data if the distance
++   between `out` and `from` is at least CHUNKCOPY_CHUNK_SIZE, which we rely on
++   in chunkcopy_relaxed().
++
++   Aside from better memory bus utilisation, this means that short copies
++   (CHUNKCOPY_CHUNK_SIZE bytes or fewer) will fall straight through the loop
++   without iteration, which will hopefully make the branch prediction more
++   reliable.
++ */
++static inline unsigned char FAR *chunkcopy_core(unsigned char FAR *out,
++                                                const unsigned char FAR *from,
++                                                unsigned len) {
++    int bump = (--len % CHUNKCOPY_CHUNK_SIZE) + 1;
++    storechunk(out, loadchunk(from));
++    out += bump;
++    from += bump;
++    len /= CHUNKCOPY_CHUNK_SIZE;
++    while (len-- > 0) {
++        storechunk(out, loadchunk(from));
++        out += CHUNKCOPY_CHUNK_SIZE;
++        from += CHUNKCOPY_CHUNK_SIZE;
++    }
++    return out;
++}
++
++/*
++   Like chunkcopy_core, but avoid writing beyond of legal output.
++
++   Accepts an additional pointer to the end of safe output.  A generic safe
++   copy would use (out + len), but it's normally the case that the end of the
++   output buffer is beyond the end of the current copy, and this can still be
++   exploited.
++ */
++static inline unsigned char FAR *chunkcopy_core_safe(unsigned char FAR *out,
++                                                     const unsigned char FAR * from,
++                                                     unsigned len,
++                                                     unsigned char FAR *limit) {
++    Assert(out + len <= limit, "chunk copy exceeds safety limit");
++    if (limit - out < CHUNKCOPY_CHUNK_SIZE) {
++        const unsigned char FAR * Z_RESTRICT rfrom = from;
++        if (len & 8) { __builtin_memcpy(out, rfrom, 8); out += 8; rfrom += 8; }
++        if (len & 4) { __builtin_memcpy(out, rfrom, 4); out += 4; rfrom += 4; }
++        if (len & 2) { __builtin_memcpy(out, rfrom, 2); out += 2; rfrom += 2; }
++        if (len & 1) { *out++ = *rfrom++; }
++        return out;
++    }
++    return chunkcopy_core(out, from, len);
++}
++
++/*
++   Perform short copies until distance can be rewritten as being at least
++   CHUNKCOPY_CHUNK_SIZE.
++
++   This assumes that it's OK to overwrite at least the first
++   2*CHUNKCOPY_CHUNK_SIZE bytes of output even if the copy is shorter than
++   this.  This assumption holds within inflate_fast() which starts every
++   iteration with at least 258 bytes of output space available (258 being the
++   maximum length output from a single token; see inffast.c).
++ */
++static inline unsigned char FAR *chunkunroll_relaxed(unsigned char FAR *out,
++                                                     unsigned FAR *dist,
++                                                     unsigned FAR *len) {
++    const unsigned char FAR *from = out - *dist;
++    while (*dist < *len && *dist < CHUNKCOPY_CHUNK_SIZE) {
++        storechunk(out, loadchunk(from));
++        out += *dist;
++        *len -= *dist;
++        *dist += *dist;
++    }
++    return out;
++}
++
++
++static inline uint8x16_t chunkset_vld1q_dup_u8x8(const unsigned char FAR * Z_RESTRICT from) {
++#if defined(__clang__) || defined(__aarch64__)
++    return vreinterpretq_u8_u64(vld1q_dup_u64((void *)from));
++#else
++    /* 32-bit GCC uses an alignment hint for vld1q_dup_u64, even when given a
++     * void pointer, so here's an alternate implementation.
++     */
++    uint8x8_t h = vld1_u8(from);
++    return vcombine_u8(h, h);
++#endif
++}
++
++/*
++   Perform an overlapping copy which behaves as a memset() operation, but
++   supporting periods other than one, and assume that length is non-zero and
++   that it's OK to overwrite at least CHUNKCOPY_CHUNK_SIZE*3 bytes of output
++   even if the length is shorter than this.
++ */
++static inline unsigned char FAR *chunkset_core(unsigned char FAR *out,
++                                               unsigned period,
++                                               unsigned len) {
++    uint8x16_t f;
++    int bump = ((len - 1) % sizeof(f)) + 1;
++
++    switch (period) {
++    case 1:
++        f = vld1q_dup_u8(out - 1);
++        vst1q_u8(out, f);
++        out += bump;
++        len -= bump;
++        while (len > 0) {
++            vst1q_u8(out, f);
++            out += sizeof(f);
++            len -= sizeof(f);
++        }
++        return out;
++    case 2:
++        f = vreinterpretq_u8_u16(vld1q_dup_u16((void *)(out - 2)));
++        vst1q_u8(out, f);
++        out += bump;
++        len -= bump;
++        if (len > 0) {
++            f = vreinterpretq_u8_u16(vld1q_dup_u16((void *)(out - 2)));
++            do {
++                vst1q_u8(out, f);
++                out += sizeof(f);
++                len -= sizeof(f);
++            } while (len > 0);
++        }
++        return out;
++    case 4:
++        f = vreinterpretq_u8_u32(vld1q_dup_u32((void *)(out - 4)));
++        vst1q_u8(out, f);
++        out += bump;
++        len -= bump;
++        if (len > 0) {
++            f = vreinterpretq_u8_u32(vld1q_dup_u32((void *)(out - 4)));
++            do {
++                vst1q_u8(out, f);
++                out += sizeof(f);
++                len -= sizeof(f);
++            } while (len > 0);
++        }
++        return out;
++    case 8:
++        f = chunkset_vld1q_dup_u8x8(out - 8);
++        vst1q_u8(out, f);
++        out += bump;
++        len -= bump;
++        if (len > 0) {
++            f = chunkset_vld1q_dup_u8x8(out - 8);
++            do {
++                vst1q_u8(out, f);
++                out += sizeof(f);
++                len -= sizeof(f);
++            } while (len > 0);
++        }
++        return out;
++    }
++    out = chunkunroll_relaxed(out, &period, &len);
++    return chunkcopy_core(out, out - period, len);
++}
++
++/*
++   Perform a memcpy-like operation, but assume that length is non-zero and that
++   it's OK to overwrite at least CHUNKCOPY_CHUNK_SIZE bytes of output even if
++   the length is shorter than this.
++
++   Unlike chunkcopy_core() above, no guarantee is made regarding the behaviour
++   of overlapping buffers, regardless of the distance between the pointers.
++   This is reflected in the `restrict`-qualified pointers, allowing the
++   compiler to reorder loads and stores.
++ */
++static inline unsigned char FAR *chunkcopy_relaxed(unsigned char FAR * Z_RESTRICT out,
++                                                   const unsigned char FAR * Z_RESTRICT from,
++                                                   unsigned len) {
++    return chunkcopy_core(out, from, len);
++}
++
++/*
++   Like chunkcopy_relaxed, but avoid writing beyond of legal output.
++
++   Unlike chunkcopy_core_safe() above, no guarantee is made regarding the
++   behaviour of overlapping buffers, regardless of the distance between the
++   pointers.  This is reflected in the `restrict`-qualified pointers, allowing
++   the compiler to reorder loads and stores.
++
++   Accepts an additional pointer to the end of safe output.  A generic safe
++   copy would use (out + len), but it's normally the case that the end of the
++   output buffer is beyond the end of the current copy, and this can still be
++   exploited.
++ */
++static inline unsigned char FAR *chunkcopy_safe(unsigned char FAR *out,
++                                                const unsigned char FAR * Z_RESTRICT from,
++                                                unsigned len,
++                                                unsigned char FAR *limit) {
++    Assert(out + len <= limit, "chunk copy exceeds safety limit");
++    return chunkcopy_core_safe(out, from, len, limit);
++}
++
++/*
++   Perform chunky copy within the same buffer, where the source and destination
++   may potentially overlap.
++
++   Assumes that len > 0 on entry, and that it's safe to write at least
++   CHUNKCOPY_CHUNK_SIZE*3 bytes to the output.
++ */
++static inline unsigned char FAR *chunkcopy_lapped_relaxed(unsigned char FAR *out,
++                                                          unsigned dist,
++                                                          unsigned len) {
++    if (dist < len && dist < CHUNKCOPY_CHUNK_SIZE) {
++        return chunkset_core(out, dist, len);
++    }
++    return chunkcopy_core(out, out - dist, len);
++}
++
++/*
++   Behave like chunkcopy_lapped_relaxed, but avoid writing beyond of legal output.
++
++   Accepts an additional pointer to the end of safe output.  A generic safe
++   copy would use (out + len), but it's normally the case that the end of the
++   output buffer is beyond the end of the current copy, and this can still be
++   exploited.
++ */
++static inline unsigned char FAR *chunkcopy_lapped_safe(unsigned char FAR *out,
++                                                       unsigned dist,
++                                                       unsigned len,
++                                                       unsigned char FAR *limit) {
++    Assert(out + len <= limit, "chunk copy exceeds safety limit");
++    if (limit - out < CHUNKCOPY_CHUNK_SIZE * 3) {
++        /* TODO: try harder to optimise this */
++        while (len-- > 0) {
++            *out = *(out - dist);
++            out++;
++        }
++        return out;
++    }
++    return chunkcopy_lapped_relaxed(out, dist, len);
++}
++
++#undef Z_RESTRICT
++
++#endif /* CHUNKCOPY_H */
+--- a/contrib/arm/inffast.c
++++ b/contrib/arm/inffast.c
+@@ -7,6 +7,7 @@
+ #include "inftrees.h"
+ #include "inflate.h"
+ #include "inffast.h"
++#include "chunkcopy.h"
+ 
+ #ifdef ASMINF
+ #  pragma message("Assembler code may have bugs -- use at your own risk")
+@@ -57,6 +58,7 @@ unsigned start;         /* inflate()'s s
+     unsigned char FAR *out;     /* local strm->next_out */
+     unsigned char FAR *beg;     /* inflate()'s initial strm->next_out */
+     unsigned char FAR *end;     /* while out < end, enough space available */
++    unsigned char FAR *limit;   /* safety limit for chunky copies */
+ #ifdef INFLATE_STRICT
+     unsigned dmax;              /* maximum distance from zlib header */
+ #endif
+@@ -84,12 +86,13 @@ unsigned start;         /* inflate()'s s
+     out = strm->next_out;
+     beg = out - (start - strm->avail_out);
+     end = out + (strm->avail_out - 257);
++    limit = out + strm->avail_out;
+ #ifdef INFLATE_STRICT
+     dmax = state->dmax;
+ #endif
+     wsize = state->wsize;
+     whave = state->whave;
+-    wnext = state->wnext;
++    wnext = (state->wnext == 0 && whave >= wsize) ? wsize : state->wnext;
+     window = state->window;
+     hold = state->hold;
+     bits = state->bits;
+@@ -197,70 +200,51 @@ unsigned start;         /* inflate()'s s
+ #endif
+                     }
+                     from = window;
+-                    if (wnext == 0) {           /* very common case */
+-                        from += wsize - op;
+-                        if (op < len) {         /* some from window */
+-                            len -= op;
+-                            do {
+-                                *out++ = *from++;
+-                            } while (--op);
+-                            from = out - dist;  /* rest from output */
+-                        }
++                    if (wnext >= op) {          /* contiguous in window */
++                        from += wnext - op;
+                     }
+-                    else if (wnext < op) {      /* wrap around window */
+-                        from += wsize + wnext - op;
++                    else {                      /* wrap around window */
+                         op -= wnext;
++                        from += wsize - op;
+                         if (op < len) {         /* some from end of window */
+                             len -= op;
+-                            do {
+-                                *out++ = *from++;
+-                            } while (--op);
+-                            from = window;
+-                            if (wnext < len) {  /* some from start of window */
+-                                op = wnext;
+-                                len -= op;
+-                                do {
+-                                    *out++ = *from++;
+-                                } while (--op);
+-                                from = out - dist;      /* rest from output */
+-                            }
+-                        }
+-                    }
+-                    else {                      /* contiguous in window */
+-                        from += wnext - op;
+-                        if (op < len) {         /* some from window */
+-                            len -= op;
+-                            do {
+-                                *out++ = *from++;
+-                            } while (--op);
+-                            from = out - dist;  /* rest from output */
+-                        }
+-                    }
+-                    while (len > 2) {
+-                        *out++ = *from++;
+-                        *out++ = *from++;
+-                        *out++ = *from++;
+-                        len -= 3;
+-                    }
+-                    if (len) {
+-                        *out++ = *from++;
+-                        if (len > 1)
+-                            *out++ = *from++;
++                            out = chunkcopy_safe(out, from, op, limit);
++                            from = window;      /* more from start of window */
++                            op = wnext;
++                            /* This (rare) case can create a situation where
++                               the first chunkcopy below must be checked.
++                             */
++                        }
++                    }
++                    if (op < len) {             /* still need some from output */
++                        out = chunkcopy_safe(out, from, op, limit);
++                        len -= op;
++                        /* When dist is small the amount of data that can be
++                           copied from the window is also small, and progress
++                           towards the dangerous end of the output buffer is
++                           also small.  This means that for trivial memsets and
++                           for chunkunroll_relaxed() a safety check is
++                           unnecessary.  However, these conditions may not be
++                           entered at all, and in that case it's possible that
++                           the main copy is near the end.
++                          */
++                        out = chunkunroll_relaxed(out, &dist, &len);
++                        out = chunkcopy_safe(out, out - dist, len, limit);
++                    } else {
++                        /* from points to window, so there is no risk of
++                           overlapping pointers requiring memset-like behaviour
++                         */
++                        out = chunkcopy_safe(out, from, len, limit);
+                     }
+                 }
+                 else {
+-                    from = out - dist;          /* copy direct from output */
+-                    do {                        /* minimum length is three */
+-                        *out++ = *from++;
+-                        *out++ = *from++;
+-                        *out++ = *from++;
+-                        len -= 3;
+-                    } while (len > 2);
+-                    if (len) {
+-                        *out++ = *from++;
+-                        if (len > 1)
+-                            *out++ = *from++;
+-                    }
++                    /* Whole reference is in range of current output.  No
++                       range checks are necessary because we start with room
++                       for at least 258 bytes of output, so unroll and roundoff
++                       operations can write beyond `out+len` so long as they
++                       stay within 258 bytes of `out`.
++                     */
++                    out = chunkcopy_lapped_relaxed(out, dist, len);
+                 }
+             }
+             else if ((op & 64) == 0) {          /* 2nd level distance code */
+--- a/contrib/arm/inflate.c
++++ b/contrib/arm/inflate.c
+@@ -84,6 +84,7 @@
+ #include "inftrees.h"
+ #include "inflate.h"
+ #include "inffast.h"
++#include "contrib/arm/chunkcopy.h"
+ 
+ #ifdef MAKEFIXED
+ #  ifndef BUILDFIXED
+@@ -405,10 +406,20 @@ unsigned copy;
+ 
+     /* if it hasn't been done already, allocate space for the window */
+     if (state->window == Z_NULL) {
++        unsigned wsize = 1U << state->wbits;
+         state->window = (unsigned char FAR *)
+-                        ZALLOC(strm, 1U << state->wbits,
++                        ZALLOC(strm, wsize + CHUNKCOPY_CHUNK_SIZE,
+                                sizeof(unsigned char));
+         if (state->window == Z_NULL) return 1;
++#ifdef INFLATE_CLEAR_UNUSED_UNDEFINED
++        /* Copies from the overflow portion of this buffer are undefined and
++           may cause analysis tools to raise a warning if we don't initialize
++           it.  However, this undefined data overwrites other undefined data
++           and is subsequently either overwritten or left deliberately
++           undefined at the end of decode; so there's really no point.
++         */
++        memset(state->window + wsize, 0, CHUNKCOPY_CHUNK_SIZE);
++#endif
+     }
+ 
+     /* if window not in use yet, initialize */
+@@ -1175,17 +1186,16 @@ int flush;
+                 else
+                     from = state->window + (state->wnext - copy);
+                 if (copy > state->length) copy = state->length;
++                if (copy > left) copy = left;
++                put = chunkcopy_safe(put, from, copy, put + left);
+             }
+             else {                              /* copy from output */
+-                from = put - state->offset;
+                 copy = state->length;
++                if (copy > left) copy = left;
++                put = chunkcopy_lapped_safe(put, state->offset, copy, put + left);
+             }
+-            if (copy > left) copy = left;
+             left -= copy;
+             state->length -= copy;
+-            do {
+-                *put++ = *from++;
+-            } while (--copy);
+             if (state->length == 0) state->mode = LEN;
+             break;
+         case LIT:
diff --git a/package/libs/zlib/patches/004-attach-sourcefiles-in-patch-002-to-buildsystem.patch b/package/libs/zlib/patches/004-attach-sourcefiles-in-patch-002-to-buildsystem.patch
new file mode 100644
index 0000000..5181dcf
--- /dev/null
+++ b/package/libs/zlib/patches/004-attach-sourcefiles-in-patch-002-to-buildsystem.patch
@@ -0,0 +1,98 @@
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -93,34 +93,67 @@ set(ZLIB_PUBLIC_HDRS
+     ${CMAKE_CURRENT_BINARY_DIR}/zconf.h
+     zlib.h
+ )
+-set(ZLIB_PRIVATE_HDRS
+-    crc32.h
+-    deflate.h
+-    gzguts.h
+-    inffast.h
+-    inffixed.h
+-    inflate.h
+-    inftrees.h
+-    trees.h
+-    zutil.h
+-)
+-set(ZLIB_SRCS
+-    adler32.c
+-    compress.c
+-    crc32.c
+-    deflate.c
+-    gzclose.c
+-    gzlib.c
+-    gzread.c
+-    gzwrite.c
+-    inflate.c
+-    infback.c
+-    inftrees.c
+-    inffast.c
+-    trees.c
+-    uncompr.c
+-    zutil.c
+-)
++
++if(ARMv8)
++    set(ZLIB_PRIVATE_HDRS
++	crc32.h
++	deflate.h
++	gzguts.h
++	inffast.h
++	inffixed.h
++	inflate.h
++	inftrees.h
++	trees.h
++	zutil.h
++	contrib/arm/chunkcopy.h
++    )
++    set(ZLIB_SRCS
++	adler32.c
++	compress.c
++	crc32.c
++	deflate.c
++	gzclose.c
++	gzlib.c
++	gzread.c
++	gzwrite.c
++	infback.c
++	inftrees.c
++	contrib/arm/inflate.c
++	contrib/arm/inffast.c
++	trees.c
++	uncompr.c
++	zutil.c
++    )
++    else()
++    set(ZLIB_PRIVATE_HDRS
++	crc32.h
++	deflate.h
++	gzguts.h
++	inffast.h
++	inffixed.h
++	inflate.h
++	inftrees.h
++	trees.h
++	zutil.h
++    )
++    set(ZLIB_SRCS
++	adler32.c
++	compress.c
++	crc32.c
++	deflate.c
++	gzclose.c
++	gzlib.c
++	gzread.c
++	gzwrite.c
++	inflate.c
++	infback.c
++	inftrees.c
++	inffast.c
++	trees.c
++	uncompr.c
++	zutil.c
++    )
++endif()
+ 
+ if(NOT MINGW)
+     set(ZLIB_DLL_SRCS
diff --git a/package/libs/zlib/patches/005-relative-pkg-config-paths.patch b/package/libs/zlib/patches/005-relative-pkg-config-paths.patch
new file mode 100644
index 0000000..c86d19b
--- /dev/null
+++ b/package/libs/zlib/patches/005-relative-pkg-config-paths.patch
@@ -0,0 +1,14 @@
+--- a/zlib.pc.cmakein
++++ b/zlib.pc.cmakein
+@@ -1,8 +1,8 @@
+ prefix=@CMAKE_INSTALL_PREFIX@
+ exec_prefix=@CMAKE_INSTALL_PREFIX@
+-libdir=@INSTALL_LIB_DIR@
+-sharedlibdir=@INSTALL_LIB_DIR@
+-includedir=@INSTALL_INC_DIR@
++libdir=${exec_prefix}/lib
++sharedlibdir=${exec_prefix}/lib
++includedir=${prefix}/include
+ 
+ Name: zlib
+ Description: zlib compression library