kobs-ng: add new package
[openwrt/staging/wigyori.git] / package / utils / lua / Makefile
1 #
2 # Copyright (C) 2006-2012 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9
10 PKG_NAME:=lua
11 PKG_VERSION:=5.1.5
12 PKG_RELEASE:=1
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
15 PKG_SOURCE_URL:=http://www.lua.org/ftp/ \
16 http://ftp.gwdg.de/pub/languages/lua/ \
17 http://mirrors.dotsrc.org/lua/ \
18 http://www.tecgraf.puc-rio.br/lua/ftp/
19 PKG_MD5SUM:=2e115fe26e435e33b0d5c022e4490567
20 PKG_BUILD_PARALLEL:=1
21
22 PKG_LICENSE:=MIT
23 PKG_LICENSE_FILES:=COPYRIGHT
24
25 HOST_PATCH_DIR := ./patches-host
26
27 include $(INCLUDE_DIR)/package.mk
28 include $(INCLUDE_DIR)/host-build.mk
29
30 define Package/lua/Default
31 SUBMENU:=Lua
32 SECTION:=lang
33 CATEGORY:=Languages
34 TITLE:=Lua programming language
35 URL:=http://www.lua.org/
36 MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
37 endef
38
39 define Package/lua/Default/description
40 Lua is a powerful light-weight programming language designed for extending
41 applications. Lua is also frequently used as a general-purpose, stand-alone
42 language. Lua is free software.
43 endef
44
45 define Package/liblua
46 $(call Package/lua/Default)
47 SUBMENU:=
48 SECTION:=libs
49 CATEGORY:=Libraries
50 TITLE+= (libraries)
51 endef
52
53 define Package/liblua/description
54 $(call Package/lua/Default/description)
55 This package contains the Lua shared libraries, needed by other programs.
56 endef
57
58 define Package/lua
59 $(call Package/lua/Default)
60 DEPENDS:=+liblua
61 TITLE+= (interpreter)
62 endef
63
64 define Package/lua/description
65 $(call Package/lua/Default/description)
66 This package contains the Lua language interpreter.
67 endef
68
69 define Package/luac
70 $(call Package/lua/Default)
71 DEPENDS:=+liblua
72 TITLE+= (compiler)
73 endef
74
75 define Package/luac/description
76 $(call Package/lua/Default/description)
77 This package contains the Lua language compiler.
78 endef
79
80 define Package/lua-examples
81 $(call Package/lua/Default)
82 DEPENDS:=lua
83 TITLE+= (examples)
84 endef
85
86 define Package/lua-examples/description
87 $(call Package/lua/Default/description)
88 This package contains Lua language examples.
89 endef
90
91 define Build/Configure
92 endef
93
94 TARGET_CFLAGS += -DLUA_USE_LINUX $(FPIC) -std=gnu99
95
96 ifneq ($(CONFIG_USE_EGLIBC),)
97 ifeq ($(CONFIG_EGLIBC_OPTION_EGLIBC_UTMP),)
98 TARGET_CFLAGS += -DNO_GETLOGIN
99 endif
100 endif
101
102 define Build/Compile
103 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
104 CC="$(TARGET_CROSS)gcc" \
105 AR="$(TARGET_CROSS)ar rcu" \
106 RANLIB="$(TARGET_CROSS)ranlib" \
107 INSTALL_ROOT=/usr \
108 CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
109 MYLDFLAGS="$(TARGET_LDFLAGS)" \
110 PKG_VERSION=$(PKG_VERSION) \
111 linux
112 rm -rf $(PKG_INSTALL_DIR)
113 mkdir -p $(PKG_INSTALL_DIR)
114 $(MAKE) -C $(PKG_BUILD_DIR) \
115 INSTALL_TOP="$(PKG_INSTALL_DIR)/usr" \
116 install
117 endef
118
119 define Host/Configure
120 $(SED) 's,"/usr/local/","$(STAGING_DIR_HOST)/",' $(HOST_BUILD_DIR)/src/luaconf.h
121 endef
122
123 ifeq ($(HOST_OS),Darwin)
124 LUA_OS:=macosx
125 else
126 ifeq ($(HOST_OS),FreeBSD)
127 LUA_OS:=freebsd
128 else
129 LUA_OS:=linux
130 endif
131 endif
132
133 define Host/Compile
134 $(MAKE) -C $(HOST_BUILD_DIR) \
135 CC="$(HOSTCC) -std=gnu99" \
136 $(LUA_OS)
137 endef
138
139 define Host/Install
140 $(MAKE) -C $(HOST_BUILD_DIR) \
141 INSTALL_TOP="$(STAGING_DIR_HOST)" \
142 install
143 endef
144
145 define Build/InstallDev
146 $(INSTALL_DIR) $(1)/usr/include
147 $(CP) $(PKG_INSTALL_DIR)/usr/include/lua{,lib,conf}.h $(1)/usr/include/
148 $(CP) $(PKG_INSTALL_DIR)/usr/include/lauxlib.h $(1)/usr/include/
149 $(CP) $(PKG_INSTALL_DIR)/usr/include/lnum_config.h $(1)/usr/include/
150 $(INSTALL_DIR) $(1)/usr/lib
151 $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblua.{a,so*} $(1)/usr/lib/
152 ln -sf liblua.so.$(PKG_VERSION) $(1)/usr/lib/liblualib.so
153 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
154 $(CP) $(PKG_BUILD_DIR)/etc/lua.pc $(1)/usr/lib/pkgconfig/
155 endef
156
157 define Package/liblua/install
158 $(INSTALL_DIR) $(1)/usr/lib
159 $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblua.so.* $(1)/usr/lib/
160 endef
161
162 define Package/lua/install
163 $(INSTALL_DIR) $(1)/usr/bin
164 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/lua $(1)/usr/bin/
165 endef
166
167 define Package/luac/install
168 $(INSTALL_DIR) $(1)/usr/bin
169 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/luac $(1)/usr/bin/
170 endef
171
172 define Package/lua-examples/install
173 $(INSTALL_DIR) $(1)/usr/share/lua/examples
174 $(INSTALL_DATA) $(PKG_BUILD_DIR)/test/*.lua \
175 $(1)/usr/share/lua/examples/
176 endef
177
178 $(eval $(call BuildPackage,liblua))
179 $(eval $(call BuildPackage,lua))
180 $(eval $(call BuildPackage,luac))
181 $(eval $(call BuildPackage,lua-examples))
182 $(eval $(call HostBuild))
183