add libmenu to ncurses package
[openwrt.git] / package / lua / Makefile
1 # $Id$
2
3 include $(TOPDIR)/rules.mk
4
5 PKG_NAME:=lua
6 PKG_VERSION:=5.0.2
7 PKG_RELEASE:=1
8 PKG_MD5SUM:= dea74646b7e5c621fef7174df83c34b1
9
10 PKG_SOURCE_URL:=http://www.lua.org/ftp/ \
11         http://ftp.gwdg.de/pub/languages/lua/ \
12         http://mirrors.dotsrc.org/lua/ \
13         http://www.tecgraf.puc-rio.br/lua/ftp/
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
15 PKG_CAT:=zcat
16
17 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
18 PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
19
20 include $(TOPDIR)/package/rules.mk
21
22 $(eval $(call PKG_template,LIBLUA,liblua,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
23 $(eval $(call PKG_template,LUA_INTERPRETER,lua,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
24 $(eval $(call PKG_template,LUA_COMPILER,luac,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
25 $(eval $(call PKG_template,LUA_EXAMPLES,lua-examples,$(PKG_VERSION)-$(PKG_RELEASE),$(ARCH)))
26
27 $(PKG_BUILD_DIR)/.configured:
28         touch $@
29
30 $(PKG_BUILD_DIR)/.built:
31         $(MAKE) -C $(PKG_BUILD_DIR) \
32                 CC="$(TARGET_CROSS)gcc" \
33                 LD="$(TARGET_CROSS)ld" \
34                 AR="$(TARGET_CROSS)ar rcu" \
35                 RANLIB="$(TARGET_CROSS)ranlib" \
36                 INSTALL_ROOT=/usr \
37                 MYCFLAGS="-I$(STAGING_DIR)/usr/include $(TARGET_CFLAGS)" \
38                 MYLDFLAGS="-L$(STAGING_DIR)/usr/lib" \
39                 all so
40         # remove statically linked binaries, so that they will get linked against shlib this time
41         rm -f $(PKG_BUILD_DIR)/bin/lua{,c}
42         $(MAKE) -C $(PKG_BUILD_DIR) \
43                 CC="$(TARGET_CROSS)gcc" \
44                 LD="$(TARGET_CROSS)ld" \
45                 AR="$(TARGET_CROSS)ar rcu" \
46                 RANLIB="$(TARGET_CROSS)ranlib" \
47                 INSTALL_ROOT=/usr \
48                 MYCFLAGS="-I$(STAGING_DIR)/usr/include $(TARGET_CFLAGS)" \
49                 MYLDFLAGS="-L$(STAGING_DIR)/usr/lib" \
50                 all
51         rm -rf $(PKG_INSTALL_DIR)
52         mkdir -p $(PKG_INSTALL_DIR)
53         $(MAKE) -C $(PKG_BUILD_DIR) \
54                 INSTALL_ROOT="$(PKG_INSTALL_DIR)/usr" \
55                 install soinstall
56         touch $@
57
58 $(IPKG_LIBLUA):
59         install -d -m0755 $(IDIR_LIBLUA)/usr/lib
60         cp -fpR $(PKG_INSTALL_DIR)/usr/lib/liblua{,lib}.so.* $(IDIR_LIBLUA)/usr/lib/
61         $(RSTRIP) $(IDIR_LIBLUA)
62         $(IPKG_BUILD) $(IDIR_LIBLUA) $(PACKAGE_DIR)
63
64 $(IPKG_LUA_INTERPRETER):
65         install -d -m0755 $(IDIR_LUA_INTERPRETER)/usr/bin
66         cp -fpR $(PKG_INSTALL_DIR)/usr/bin/lua $(IDIR_LUA_INTERPRETER)/usr/bin/
67         $(RSTRIP) $(IDIR_LUA_INTERPRETER)
68         $(IPKG_BUILD) $(IDIR_LUA_INTERPRETER) $(PACKAGE_DIR)
69
70 $(IPKG_LUA_COMPILER):
71         install -d -m0755 $(IDIR_LUA_COMPILER)/usr/bin
72         cp -fpR $(PKG_INSTALL_DIR)/usr/bin/luac $(IDIR_LUA_COMPILER)/usr/bin/
73         $(RSTRIP) $(IDIR_LUA_COMPILER)
74         $(IPKG_BUILD) $(IDIR_LUA_COMPILER) $(PACKAGE_DIR)
75
76 $(IPKG_LUA_EXAMPLES):
77         install -d -m0755 $(IDIR_LUA_EXAMPLES)/usr/share/lua/examples
78         install -m0644 $(PKG_BUILD_DIR)/test/*.lua \
79                 $(IDIR_LUA_EXAMPLES)/usr/share/lua/examples/
80         $(RSTRIP) $(IDIR_LUA_EXAMPLES)
81         $(IPKG_BUILD) $(IDIR_LUA_EXAMPLES) $(PACKAGE_DIR)
82
83 $(STAGING_DIR)/usr/lib/liblua.so: $(PKG_BUILD_DIR)/.built
84         mkdir -p $(STAGING_DIR)/usr/include
85         cp -fpR $(PKG_INSTALL_DIR)/usr/include/lua{,lib}.h $(STAGING_DIR)/usr/include/
86         cp -fpR $(PKG_INSTALL_DIR)/usr/include/lauxlib.h $(STAGING_DIR)/usr/include/
87         mkdir -p $(STAGING_DIR)/usr/lib
88         cp -fpR $(PKG_INSTALL_DIR)/usr/lib/liblua{,lib}.{a,so*} $(STAGING_DIR)/usr/lib/
89         touch $@
90
91 install-dev: $(STAGING_DIR)/usr/lib/liblua.so
92
93 uninstall-dev:
94         rm -rf \
95                 $(STAGING_DIR)/usr/include/lua{,lib}.h \
96                 $(STAGING_DIR)/usr/include/lauxlib.h \
97                 $(STAGING_DIR)/usr/lib/liblua{,lib}.{a,so*} \
98
99 compile: install-dev
100 clean: uninstall-dev