53acdde9fdf9a7c404cba430334fe0b513f78ece
[openwrt/svn-archive/archive.git] / package / lua / Makefile
1 #
2 # Copyright (C) 2006-2011 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:=8
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
23 include $(INCLUDE_DIR)/package.mk
24 include $(INCLUDE_DIR)/host-build.mk
25
26 define Package/lua/Default
27 SUBMENU:=Lua
28 SECTION:=lang
29 CATEGORY:=Languages
30 TITLE:=Lua programming language
31 URL:=http://www.lua.org/
32 MAINTAINER:=Jo-Philipp Wich <jow@openwrt.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 define Build/Configure
88 endef
89
90 TARGET_CFLAGS += -DLUA_USE_LINUX $(FPIC) -std=gnu99
91
92 ifneq ($(CONFIG_USE_EGLIBC),)
93 ifeq ($(CONFIG_EGLIBC_OPTION_EGLIBC_UTMP),)
94 TARGET_CFLAGS += -DNO_GETLOGIN
95 endif
96 endif
97
98 define Build/Compile
99 $(MAKE) -C $(PKG_BUILD_DIR) \
100 CC="$(TARGET_CROSS)gcc" \
101 AR="$(TARGET_CROSS)ar rcu" \
102 RANLIB="$(TARGET_CROSS)ranlib" \
103 INSTALL_ROOT=/usr \
104 CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
105 MYLDFLAGS="$(TARGET_LDFLAGS)" \
106 PKG_VERSION=$(PKG_VERSION) \
107 linux
108 rm -rf $(PKG_INSTALL_DIR)
109 mkdir -p $(PKG_INSTALL_DIR)
110 $(MAKE) -C $(PKG_BUILD_DIR) \
111 INSTALL_TOP="$(PKG_INSTALL_DIR)/usr" \
112 install
113 endef
114
115 define Host/Configure
116 $(SED) 's,"/usr/local/","$(STAGING_DIR_HOST)/",' $(HOST_BUILD_DIR)/src/luaconf.h
117 endef
118
119 ifeq ($(HOST_OS),Darwin)
120 LUA_OS:=macosx
121 else
122 ifeq ($(HOST_OS),FreeBSD)
123 LUA_OS:=freebsd
124 else
125 LUA_OS:=linux
126 endif
127 endif
128
129 define Host/Compile
130 $(MAKE) -C $(HOST_BUILD_DIR) \
131 CC="$(HOSTCC) -std=gnu99" \
132 $(LUA_OS)
133 endef
134
135 define Host/Install
136 $(MAKE) -C $(HOST_BUILD_DIR) \
137 INSTALL_TOP="$(STAGING_DIR_HOST)" \
138 install
139 endef
140
141 define Build/InstallDev
142 $(INSTALL_DIR) $(1)/usr/include
143 $(CP) $(PKG_INSTALL_DIR)/usr/include/lua{,lib,conf}.h $(1)/usr/include/
144 $(CP) $(PKG_INSTALL_DIR)/usr/include/lauxlib.h $(1)/usr/include/
145 $(CP) $(PKG_INSTALL_DIR)/usr/include/lnum_config.h $(1)/usr/include/
146 $(INSTALL_DIR) $(1)/usr/lib
147 $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblua.{a,so*} $(1)/usr/lib/
148 ln -sf liblua.so.$(PKG_VERSION) $(1)/usr/lib/liblualib.so
149 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
150 $(CP) $(PKG_BUILD_DIR)/etc/lua.pc $(1)/usr/lib/pkgconfig/
151 endef
152
153 define Package/liblua/install
154 $(INSTALL_DIR) $(1)/usr/lib
155 $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblua.so.* $(1)/usr/lib/
156 endef
157
158 define Package/lua/install
159 $(INSTALL_DIR) $(1)/usr/bin
160 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/lua $(1)/usr/bin/
161 endef
162
163 define Package/luac/install
164 $(INSTALL_DIR) $(1)/usr/bin
165 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/luac $(1)/usr/bin/
166 endef
167
168 define Package/lua-examples/install
169 $(INSTALL_DIR) $(1)/usr/share/lua/examples
170 $(INSTALL_DATA) $(PKG_BUILD_DIR)/test/*.lua \
171 $(1)/usr/share/lua/examples/
172 endef
173
174 $(eval $(call BuildPackage,liblua))
175 $(eval $(call BuildPackage,lua))
176 $(eval $(call BuildPackage,luac))
177 $(eval $(call BuildPackage,lua-examples))
178 $(eval $(call HostBuild))
179