13eb4a518a88e87d2d4fe2c65f7224117616d49b
[openwrt/openwrt.git] / package / lua / Makefile
1 #
2 # Copyright (C) 2006-2009 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.4
12 PKG_RELEASE:=4
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:=d0870f2de55d59c1c8419f36e8fac150
20
21 HOST_PATCH_DIR=./patches-host
22 PKG_BUILD_DEPENDS:=lua/host zlib
23
24 include $(INCLUDE_DIR)/host-build.mk
25 include $(INCLUDE_DIR)/package.mk
26
27 define Package/lua/Default
28 SUBMENU:=LUA
29 SECTION:=lang
30 CATEGORY:=Languages
31 TITLE:=LUA programming language
32 URL:=http://www.lua.org/
33 endef
34
35 define Package/lua/Default/description
36 Lua is a powerful light-weight programming language designed for extending
37 applications. Lua is also frequently used as a general-purpose, stand-alone
38 language. Lua is free software.
39 endef
40
41 define Package/liblua
42 $(call Package/lua/Default)
43 SUBMENU:=
44 SECTION:=libs
45 CATEGORY:=Libraries
46 TITLE+= (libraries)
47 endef
48
49 define Package/liblua/description
50 $(call Package/lua/Default/description)
51 This package contains the LUA shared libraries, needed by other programs.
52 endef
53
54 define Package/lua
55 $(call Package/lua/Default)
56 DEPENDS:=+liblua
57 TITLE+= (interpreter)
58 endef
59
60 define Package/lua/description
61 $(call Package/lua/Default/description)
62 This package contains the LUA language interpreter.
63 endef
64
65 define Package/luac
66 $(call Package/lua/Default)
67 DEPENDS:=+liblua
68 TITLE+= (compiler)
69 endef
70
71 define Package/luac/description
72 $(call Package/lua/Default/description)
73 This package contains the LUA language compiler.
74 endef
75
76 define Package/lua-examples
77 $(call Package/lua/Default)
78 DEPENDS:=lua
79 TITLE+= (examples)
80 endef
81
82 define Package/lua-examples/description
83 $(call Package/lua/Default/description)
84 This package contains LUA language examples.
85 endef
86
87 # Host build
88 define Host/Configure
89
90 endef
91
92 define Host/Compile
93 $(MAKE) -C $(HOST_BUILD_DIR)/src luac-host
94 endef
95
96 define Host/Install
97 $(INSTALL_BIN) $(HOST_BUILD_DIR)/src/luac-host $(STAGING_DIR_HOST)/bin/luac
98 endef
99
100 # Target build
101
102 TARGET_CFLAGS += -DLUA_USE_LINUX $(FPIC)
103
104 ifneq ($(CONFIG_USE_EGLIBC),)
105 ifeq ($(CONFIG_EGLIBC_OPTION_EGLIBC_UTMP),)
106 TARGET_CFLAGS += -DNO_GETLOGIN
107 endif
108 endif
109
110 Build/Configure=$(Host/Configure)
111
112 define Build/Compile
113 $(MAKE) -C $(PKG_BUILD_DIR) \
114 CC="$(TARGET_CROSS)gcc" \
115 AR="$(TARGET_CROSS)ar rcu" \
116 RANLIB="$(TARGET_CROSS)ranlib" \
117 INSTALL_ROOT=/usr \
118 CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
119 MYLDFLAGS="$(TARGET_LDFLAGS)" \
120 PKG_VERSION=$(PKG_VERSION) \
121 linux
122 rm -rf $(PKG_INSTALL_DIR)
123 mkdir -p $(PKG_INSTALL_DIR)
124 $(MAKE) -C $(PKG_BUILD_DIR) \
125 INSTALL_TOP="$(PKG_INSTALL_DIR)/usr" \
126 install
127 endef
128
129 define Build/InstallDev
130 mkdir -p $(1)/usr/include
131 $(CP) $(PKG_INSTALL_DIR)/usr/include/lua{,lib,conf}.h $(1)/usr/include/
132 $(CP) $(PKG_INSTALL_DIR)/usr/include/lauxlib.h $(1)/usr/include/
133 $(CP) $(PKG_INSTALL_DIR)/usr/include/lnum_config.h $(1)/usr/include/
134 mkdir -p $(1)/usr/lib
135 $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblua.{a,so*} $(1)/usr/lib/
136 ln -sf liblua.so.$(PKG_VERSION) $(1)/usr/lib/liblualib.so
137 endef
138
139 define Package/liblua/install
140 $(INSTALL_DIR) $(1)/usr/lib
141 $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblua.so.* $(1)/usr/lib/
142 endef
143
144 define Package/lua/install
145 $(INSTALL_DIR) $(1)/usr/bin
146 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/lua $(1)/usr/bin/
147 endef
148
149 define Package/luac/install
150 $(INSTALL_DIR) $(1)/usr/bin
151 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/luac $(1)/usr/bin/
152 endef
153
154 define Package/lua-examples/install
155 $(INSTALL_DIR) $(1)/usr/share/lua/examples
156 $(INSTALL_DATA) $(PKG_BUILD_DIR)/test/*.lua \
157 $(1)/usr/share/lua/examples/
158 endef
159
160 $(eval $(call HostBuild))
161 $(eval $(call BuildPackage,liblua))
162 $(eval $(call BuildPackage,lua))
163 $(eval $(call BuildPackage,luac))
164 $(eval $(call BuildPackage,lua-examples))