[backfire] revert unrelated change in previous commit
[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
8 include $(TOPDIR)/rules.mk
9
10 PKG_NAME:=lua
11 PKG_VERSION:=5.1.4
12 PKG_RELEASE:=7
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 endef
33
34 define Package/lua/Default/description
35  Lua is a powerful light-weight programming language designed for extending 
36  applications. Lua is also frequently used as a general-purpose, stand-alone 
37  language. Lua is free software.
38 endef
39
40 define Package/liblua
41 $(call Package/lua/Default)
42   SUBMENU:=
43   SECTION:=libs
44   CATEGORY:=Libraries
45   TITLE+= (libraries)
46 endef
47
48 define Package/liblua/description
49 $(call Package/lua/Default/description)
50  This package contains the Lua shared libraries, needed by other programs.
51 endef
52
53 define Package/lua
54 $(call Package/lua/Default)
55   DEPENDS:=+liblua
56   TITLE+= (interpreter)
57 endef
58
59 define Package/lua/description
60 $(call Package/lua/Default/description)
61  This package contains the Lua language interpreter.
62 endef
63
64 define Package/luac
65 $(call Package/lua/Default)
66   DEPENDS:=+liblua
67   TITLE+= (compiler)
68 endef
69
70 define Package/luac/description
71 $(call Package/lua/Default/description)
72  This package contains the Lua language compiler.
73 endef
74
75 define Package/lua-examples
76 $(call Package/lua/Default)
77   DEPENDS:=lua
78   TITLE+= (examples)
79 endef
80
81 define Package/lua-examples/description
82 $(call Package/lua/Default/description)
83  This package contains Lua language examples.
84 endef
85
86 define Build/Configure
87 endef
88
89 TARGET_CFLAGS += -DLUA_USE_LINUX $(FPIC) -std=gnu99
90
91 ifneq ($(CONFIG_USE_EGLIBC),)
92   ifeq ($(CONFIG_EGLIBC_OPTION_EGLIBC_UTMP),)
93     TARGET_CFLAGS += -DNO_GETLOGIN
94   endif
95 endif
96
97 define Build/Compile
98         $(MAKE) -C $(PKG_BUILD_DIR) \
99                 CC="$(TARGET_CROSS)gcc" \
100                 AR="$(TARGET_CROSS)ar rcu" \
101                 RANLIB="$(TARGET_CROSS)ranlib" \
102                 INSTALL_ROOT=/usr \
103                 CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \
104                 MYLDFLAGS="$(TARGET_LDFLAGS)" \
105                 PKG_VERSION=$(PKG_VERSION) \
106                 linux
107         rm -rf $(PKG_INSTALL_DIR)
108         mkdir -p $(PKG_INSTALL_DIR)
109         $(MAKE) -C $(PKG_BUILD_DIR) \
110                 INSTALL_TOP="$(PKG_INSTALL_DIR)/usr" \
111                 install
112 endef
113
114 define Host/Configure
115         $(SED) 's,"/usr/local/","$(STAGING_DIR_HOST)/",' $(HOST_BUILD_DIR)/src/luaconf.h
116 endef
117
118 ifeq ($(HOST_OS),Darwin)
119         LUA_OS:=macosx
120 else
121         ifeq ($(HOST_OS),FreeBSD)
122                 LUA_OS:=freebsd
123         else
124                 LUA_OS:=linux
125         endif
126 endif
127
128 define Host/Compile
129         $(MAKE) -C $(HOST_BUILD_DIR) \
130                 CC="$(HOSTCC) -std=gnu99" \
131                 $(LUA_OS)
132 endef
133
134 define Host/Install
135         $(MAKE) -C $(HOST_BUILD_DIR) \
136                 INSTALL_TOP="$(STAGING_DIR_HOST)" \
137                 install
138 endef
139
140 define Build/InstallDev
141         $(INSTALL_DIR) $(1)/usr/include
142         $(CP) $(PKG_INSTALL_DIR)/usr/include/lua{,lib,conf}.h $(1)/usr/include/
143         $(CP) $(PKG_INSTALL_DIR)/usr/include/lauxlib.h $(1)/usr/include/
144         $(CP) $(PKG_INSTALL_DIR)/usr/include/lnum_config.h $(1)/usr/include/
145         $(INSTALL_DIR) $(1)/usr/lib
146         $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblua.{a,so*} $(1)/usr/lib/
147         ln -sf liblua.so.$(PKG_VERSION) $(1)/usr/lib/liblualib.so
148         $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
149         $(CP) $(PKG_BUILD_DIR)/etc/lua.pc $(1)/usr/lib/pkgconfig/
150 endef
151
152 define Package/liblua/install
153         $(INSTALL_DIR) $(1)/usr/lib
154         $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblua.so.* $(1)/usr/lib/
155 endef
156
157 define Package/lua/install
158         $(INSTALL_DIR) $(1)/usr/bin
159         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/lua $(1)/usr/bin/
160 endef
161
162 define Package/luac/install
163         $(INSTALL_DIR) $(1)/usr/bin
164         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/luac $(1)/usr/bin/
165 endef
166
167 define Package/lua-examples/install
168         $(INSTALL_DIR) $(1)/usr/share/lua/examples
169         $(INSTALL_DATA) $(PKG_BUILD_DIR)/test/*.lua \
170                 $(1)/usr/share/lua/examples/
171 endef
172
173 $(eval $(call BuildPackage,liblua))
174 $(eval $(call BuildPackage,lua))
175 $(eval $(call BuildPackage,luac))
176 $(eval $(call BuildPackage,lua-examples))
177 $(eval $(call HostBuild))
178