-PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
-PKG_CAT:=zcat
-
-PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
-PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
-
-include $(TOPDIR)/package/rules.mk
-
-$(eval $(call PKG_template,LIBLUA,liblua,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
-$(eval $(call PKG_template,LUA,lua,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
-$(eval $(call PKG_template,LUAC,luac,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
-$(eval $(call PKG_template,LUA_EXAMPLES,lua-examples,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
-
-$(PKG_BUILD_DIR)/.configured:
- touch $@
-
-$(PKG_BUILD_DIR)/.built: $(PKG_BUILD_DIR)/.configured
- $(MAKE) -C $(PKG_BUILD_DIR) \
- CC="$(TARGET_CROSS)gcc" \
- LD="$(TARGET_CROSS)ld" \
- AR="$(TARGET_CROSS)ar rcu" \
- RANLIB="$(TARGET_CROSS)ranlib" \
- INSTALL_ROOT=/usr \
- MYCFLAGS="-I$(STAGING_DIR)/usr/include $(TARGET_CFLAGS)" \
- MYLDFLAGS="-L$(STAGING_DIR)/usr/lib" \
- all so
- # remove statically linked binaries, so that they will get linked against shlib this time
- rm -f $(PKG_BUILD_DIR)/bin/lua{,c}
+PKG_MD5SUM:=d0870f2de55d59c1c8419f36e8fac150
+
+HOST_PATCH_DIR=./patches-host
+include $(INCLUDE_DIR)/host-build.mk
+include $(INCLUDE_DIR)/package.mk
+
+define Package/lua/Default
+ SUBMENU:=LUA
+ SECTION:=lang
+ CATEGORY:=Languages
+ TITLE:=LUA programming language
+ URL:=http://www.lua.org/
+endef
+
+define Package/lua/Default/description
+ Lua is a powerful light-weight programming language designed for extending
+ applications. Lua is also frequently used as a general-purpose, stand-alone
+ language. Lua is free software.
+endef
+
+define Package/liblua
+$(call Package/lua/Default)
+ SUBMENU:=
+ SECTION:=libs
+ CATEGORY:=Libraries
+ TITLE+= (libraries)
+endef
+
+define Package/liblua/description
+$(call Package/lua/Default/description)
+ This package contains the LUA shared libraries, needed by other programs.
+endef
+
+define Package/lua
+$(call Package/lua/Default)
+ DEPENDS:=+liblua
+ TITLE+= (interpreter)
+endef
+
+define Package/lua/description
+$(call Package/lua/Default/description)
+ This package contains the LUA language interpreter.
+endef
+
+define Package/luac
+$(call Package/lua/Default)
+ DEPENDS:=+liblua
+ TITLE+= (compiler)
+endef
+
+define Package/luac/description
+$(call Package/lua/Default/description)
+ This package contains the LUA language compiler.
+endef
+
+define Package/lua-examples
+$(call Package/lua/Default)
+ DEPENDS:=lua
+ TITLE+= (examples)
+endef
+
+define Package/lua-examples/description
+$(call Package/lua/Default/description)
+ This package contains LUA language examples.
+endef
+
+# Host build
+define Host/Configure
+
+endef
+
+define Host/Compile
+ $(MAKE) -C $(HOST_BUILD_DIR)/src luac-host
+endef
+
+define Host/Install
+ $(INSTALL_BIN) $(HOST_BUILD_DIR)/src/luac-host $(STAGING_DIR_HOST)/bin/luac
+endef
+
+# Target build
+
+TARGET_CFLAGS += -DLUA_USE_LINUX $(FPIC)
+
+ifneq ($(CONFIG_USE_EGLIBC),)
+ ifeq ($(CONFIG_EGLIBC_OPTION_EGLIBC_UTMP),)
+ TARGET_CFLAGS += -DNO_GETLOGIN
+ endif
+endif
+
+Build/Configure=$(Host/Configure)
+
+define Build/Compile