89b6a87117c9c393257fb4231bc9ced33490d26e
[openwrt/openwrt.git] / package / utils / lua / Makefile
1 #
2 # Copyright (C) 2006-2014 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_HASH:=2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333
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 <jo@mein.io>
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 define Build/Compile
97 $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \
98 CC="$(TARGET_CROSS)gcc" \
99 AR="$(TARGET_CROSS)ar rcu" \
100 RANLIB="$(TARGET_CROSS)ranlib" \
101 INSTALL_ROOT=/usr \
102 CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
103 MYLDFLAGS="$(TARGET_LDFLAGS)" \
104 PKG_VERSION=$(PKG_VERSION) \
105 linux
106 rm -rf $(PKG_INSTALL_DIR)
107 mkdir -p $(PKG_INSTALL_DIR)
108 $(MAKE) -C $(PKG_BUILD_DIR) \
109 INSTALL_TOP="$(PKG_INSTALL_DIR)/usr" \
110 install
111 endef
112
113 define Host/Configure
114 $(SED) 's,"/usr/local/","$(STAGING_DIR_HOSTPKG)/",' $(HOST_BUILD_DIR)/src/luaconf.h
115 endef
116
117 ifeq ($(HOST_OS),Darwin)
118 LUA_OS:=macosx
119 else
120 ifeq ($(HOST_OS),FreeBSD)
121 LUA_OS:=freebsd
122 else
123 LUA_OS:=linux
124 endif
125 endif
126
127 define Host/Compile
128 $(MAKE) -C $(HOST_BUILD_DIR) \
129 CC="$(HOSTCC) -std=gnu99" \
130 $(LUA_OS)
131 endef
132
133 define Host/Install
134 $(MAKE) -C $(HOST_BUILD_DIR) \
135 INSTALL_TOP="$(STAGING_DIR_HOSTPKG)" \
136 install
137 endef
138
139 define Build/InstallDev
140 $(INSTALL_DIR) $(1)/usr/include
141 $(CP) $(PKG_INSTALL_DIR)/usr/include/lua{,lib,conf}.h $(1)/usr/include/
142 $(CP) $(PKG_INSTALL_DIR)/usr/include/lauxlib.h $(1)/usr/include/
143 $(CP) $(PKG_INSTALL_DIR)/usr/include/lnum_config.h $(1)/usr/include/
144 $(INSTALL_DIR) $(1)/usr/lib
145 $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblua.{a,so*} $(1)/usr/lib/
146 $(LN) liblua.so.$(PKG_VERSION) $(1)/usr/lib/liblualib.so
147 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
148 $(CP) $(PKG_BUILD_DIR)/etc/lua.pc $(1)/usr/lib/pkgconfig/
149 endef
150
151 define Package/liblua/install
152 $(INSTALL_DIR) $(1)/usr/lib
153 $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblua.so.* $(1)/usr/lib/
154 endef
155
156 define Package/lua/install
157 $(INSTALL_DIR) $(1)/usr/bin
158 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/lua $(1)/usr/bin/
159 endef
160
161 define Package/luac/install
162 $(INSTALL_DIR) $(1)/usr/bin
163 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/luac $(1)/usr/bin/
164 endef
165
166 define Package/lua-examples/install
167 $(INSTALL_DIR) $(1)/usr/share/lua/examples
168 $(INSTALL_DATA) $(PKG_BUILD_DIR)/test/*.lua \
169 $(1)/usr/share/lua/examples/
170 endef
171
172 $(eval $(call BuildPackage,liblua))
173 $(eval $(call BuildPackage,lua))
174 $(eval $(call BuildPackage,luac))
175 $(eval $(call BuildPackage,lua-examples))
176 $(eval $(call HostBuild))
177