<div>This library offers basic facilities to convert Lua values to and from C structs.</div><div>This is very similar to Python's struct.pack/unpack.</div><div> </div><div>Signed-off-by: Anton D. Kachalov <mouse@yandex-team.ru></div><div>---</div><div>lang/lua-struct/Makefile                  | 62 ++++++++++++++++++++++++++++++</div><div>lang/lua-struct/patches/001-makefile.patch | 48 +++++++++++++++++++++++</div><div>2 files changed, 110 insertions(+)</div><div>create mode 100644 lang/lua-struct/Makefile</div><div>create mode 100644 lang/lua-struct/patches/001-makefile.patch</div><div> </div><div>diff --git a/lang/lua-struct/Makefile b/lang/lua-struct/Makefile</div><div>new file mode 100644</div><div>index 0000000..ba25f98</div><div>--- /dev/null</div><div>+++ b/lang/lua-struct/Makefile</div><div>@@ -0,0 +1,62 @@</div><div>+#</div><div>+# Copyright (C) 2016 OpenWrt.org</div><div>+#</div><div>+# This is free software, licensed under the GNU General Public License v2.</div><div>+# See /LICENSE for more information.</div><div>+#</div><div>+</div><div>+include $(TOPDIR)/rules.mk</div><div>+</div><div>+PKG_NAME:=lua-struct</div><div>+PKG_VERSION:=0.2</div><div>+PKG_RELEASE:=1</div><div>+</div><div>+_BASENAME:=struct</div><div>+</div><div>+PKG_SOURCE:=$(_BASENAME)-$(PKG_VERSION).tar.gz</div><div>+PKG_SOURCE_URL:=http://www.inf.puc-rio.br/~roberto/struct</div><div>+PKG_MD5SUM:=99384bf1f54457ec9f796ad0b539d19c</div><div>+PKG_MAINTAINER:=Anton D. Kachalov <mouse@yandex-team.ru></div><div>+PKG_LICENSE:=MIT</div><div>+</div><div>+PKG_INSTALL:=1</div><div>+</div><div>+UNPACK_CMD=tar -C $(1) -xf "$(DL_DIR)/$(PKG_SOURCE)"</div><div>+</div><div>+include $(INCLUDE_DIR)/package.mk</div><div>+</div><div>+define Package/lua-struct</div><div>+  SUBMENU:=Lua</div><div>+  SECTION:=lang</div><div>+  CATEGORY:=Languages</div><div>+  TITLE:=Lua binary struct pack/unpack</div><div>+  URL:=http://www.inf.puc-rio.br/~roberto/struct/</div><div>+  DEPENDS:=+lua</div><div>+endef</div><div>+</div><div>+define Package/lua-struct/description</div><div>+  This library offers basic facilities to convert Lua values to and from C structs.</div><div>+endef</div><div>+</div><div>+TARGET_CFLAGS += $(FPIC)</div><div>+</div><div>+define Build/Compile</div><div>+      $(MAKE) -C $(PKG_BUILD_DIR) \</div><div>+      PREFIX="$(STAGING_DIR)/usr" \</div><div>+      LUA_LIBDIR="$(STAGING_DIR)/usr/lib/lua" \</div><div>+      clean</div><div>+      $(MAKE) -C $(PKG_BUILD_DIR) \</div><div>+      PREFIX="$(STAGING_DIR)/usr" \</div><div>+      LUA_LIBDIR="$(STAGING_DIR)/usr/lib/lua" \</div><div>+      LIB_OPTION="-shared" \</div><div>+      CC="$(TARGET_CROSS)gcc" \</div><div>+      CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \</div><div>+      all</div><div>+endef</div><div>+</div><div>+define Package/lua-struct/install</div><div>+      $(INSTALL_DIR) $(1)/usr/lib/lua</div><div>+      $(INSTALL_BIN) $(PKG_BUILD_DIR)/struct.so $(1)/usr/lib/lua/struct.so</div><div>+endef</div><div>+</div><div>+$(eval $(call BuildPackage,lua-struct))</div><div>diff --git a/lang/lua-struct/patches/001-makefile.patch b/lang/lua-struct/patches/001-makefile.patch</div><div>new file mode 100644</div><div>index 0000000..ddd06b9</div><div>--- /dev/null</div><div>+++ b/lang/lua-struct/patches/001-makefile.patch</div><div>@@ -0,0 +1,48 @@</div><div>+--- a/makefile 2012-07-04 19:55:36.000000000 +0400</div><div>++++ b/makefile 2016-08-24 11:16:54.991229269 +0300</div><div>+@@ -1,24 +1,24 @@</div><div>+-# point it to where the compiler can find the Lua header files (lua.h, etc.)</div><div>+-# LUADIR = ../lua</div><div>+-LUADIR = /usr/include/lua5.1/</div><div>+-</div><div>+-# define your own "large" integer type; not defining a proper type</div><div>+-# will default to 'long', which may cause problems with 'size_t'</div><div>+-INTTYPE = -DSTRUCT_INT="long long"</div><div>+-</div><div>+-</div><div>+-CWARNS = -Wall -W -pedantic \</div><div>+-        -Waggregate-return \</div><div>+-        -Wcast-align \</div><div>+-        -Wmissing-prototypes \</div><div>+-        -Wnested-externs \</div><div>+-        -Wpointer-arith \</div><div>+-        -Wshadow \</div><div>+-        -Wwrite-strings</div><div>++LUA=/usr/lib/lua</div><div>++LUAINC=$(LUA)/include</div><div>++LUALIB=$(LUA)/lib</div><div>++LUABIB=$(LUA)/bin</div><div>+</div><div>+-CFLAGS = -D_POSIX_SOURCE $(CWARNS) $(INTTYPE) -O2 -I$(LUADIR)</div><div>+-CC = gcc</div><div>++OFLAGS = -O0</div><div>+</div><div>+-struct.so: struct.c makefile</div><div>+-    $(CC) $(CFLAGS) -shared -fpic -o struct.so struct.c</div><div>++STRUCT_CFLAGS = -I$(LUAINC) -std=gnu99 -DSTRUCT_INT="long long"</div><div>++STRUCT_LDFLAGS = -L$(LUALIB) -llua</div><div>++STRUCT_OBJ = struct.o</div><div>++STRUCT_LIB = struct.so</div><div>+</div><div>++all: $(STRUCT_LIB)</div><div>++</div><div>++%.o: %.c</div><div>++    $(CC) $(CPPFLAGS) $(CFLAGS) $(OFLAGS) $(LUA_CFLAGS) $(STRUCT_CFLAGS) $(FPIC) -c -o $@ $<</div><div>++</div><div>++$(STRUCT_LIB): $(STRUCT_OBJ)</div><div>++    $(CC) $(LDFLAGS) -shared -o $(STRUCT_LIB) $(STRUCT_OBJ) $(STRUCT_LDFLAGS)</div><div>++</div><div>++install: $(STRUCT_LIB)</div><div>++</div><div>++clean:</div><div>++    rm -f *.o *.so</div><div>--</div><div>1.9.1</div><div> </div>