Skip to content

Commit

Permalink
luastruct: openwrt packaging of luastruct
Browse files Browse the repository at this point in the history
The upstream package has no top level directory in the tarball, and
needs patches to properly allow specifying the C compiler and include
paths, but otherwise straightforward.
  • Loading branch information
karlp committed Mar 11, 2014
1 parent 3897b8a commit d243c7d
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
56 changes: 56 additions & 0 deletions luastruct/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#
# 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:=luastruct
PKG_VERSION:=0.2
PKG_RELEASE:=1

PKG_SOURCE:=struct-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=http://www.inf.puc-rio.br/~roberto/struct
PKG_MD5_SUM:=99384bf1f54457ec9f796ad0b539d19c
# Workaround original tarball not having a parent directory
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_UNPACK:=gzip -dc $(DL_DIR)/$(PKG_SOURCE) | $(TAR) -C $(PKG_BUILD_DIR) -xf -

include $(INCLUDE_DIR)/package.mk

define Package/$(PKG_NAME)
SUBMENU:=Lua
SECTION:=lang
CATEGORY:=Languages
TITLE:=LuaStruct
URL:=http://www.inf.puc-rio.br/~roberto/struct/
DEPENDS:=+lua
MAINTAINER:=Karl Palsson <karlp@remake.is>
endef

define Package/$(PKG_NAME)/description
This library offers basic facilities to convert Lua values to and from
C structs. Its main functions are struct.pack, which packs multiple Lua
values into a struct-like string; and struct.unpack, which unpacks
multiple Lua values from a given struct-like string.
endef

define Build/Configure
endef

define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR)/ \
LUADIR="$(STAGING_DIR)/usr/include/" \
CC="$(TARGET_CC) $(TARGET_CFLAGS) $(TARGET_CPPFLAGS) -std=gnu99" \
LD="$(TARGET_CROSS)ld -shared"
endef


define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/usr/lib/lua
$(INSTALL_BIN) $(PKG_BUILD_DIR)/struct.so $(1)/usr/lib/lua
endef

$(eval $(call BuildPackage,$(PKG_NAME)))
17 changes: 17 additions & 0 deletions luastruct/patches/001-remove-hardcoded-paths.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--- a/makefile 2012-07-04 15:55:36.000000000 +0000
+++ b/makefile 2014-03-10 18:47:03.694896629 +0000
@@ -1,6 +1,5 @@
# point it to where the compiler can find the Lua header files (lua.h, etc.)
# LUADIR = ../lua
-LUADIR = /usr/include/lua5.1/

# define your own "large" integer type; not defining a proper type
# will default to 'long', which may cause problems with 'size_t'
@@ -17,7 +16,6 @@
-Wwrite-strings

CFLAGS = -D_POSIX_SOURCE $(CWARNS) $(INTTYPE) -O2 -I$(LUADIR)
-CC = gcc

struct.so: struct.c makefile
$(CC) $(CFLAGS) -shared -fpic -o struct.so struct.c

0 comments on commit d243c7d

Please sign in to comment.