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