b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | # |
| 2 | # Copyright (C) 2006-2014 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.5 |
| 12 | PKG_RELEASE:=11 |
| 13 | |
| 14 | PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz |
| 15 | PKG_SOURCE_URL:=https://www.lua.org/ftp/ \ |
| 16 | https://www.tecgraf.puc-rio.br/lua/ftp/ |
| 17 | PKG_HASH:=2640fc56a795f29d28ef15e13c34a47e223960b0240e8cb0a82d9b0738695333 |
| 18 | PKG_BUILD_PARALLEL:=1 |
| 19 | |
| 20 | PKG_LICENSE:=MIT |
| 21 | PKG_LICENSE_FILES:=COPYRIGHT |
| 22 | PKG_CPE_ID:=cpe:/a:lua:lua |
| 23 | |
| 24 | PKG_BUILD_FLAGS:=no-lto |
| 25 | |
| 26 | HOST_PATCH_DIR := ./patches-host |
| 27 | |
| 28 | include $(INCLUDE_DIR)/package.mk |
| 29 | include $(INCLUDE_DIR)/host-build.mk |
| 30 | |
| 31 | define Package/lua/Default |
| 32 | SUBMENU:=Lua |
| 33 | SECTION:=lang |
| 34 | CATEGORY:=Languages |
| 35 | TITLE:=Lua programming language |
| 36 | URL:=https://www.lua.org/ |
| 37 | MAINTAINER:=Jo-Philipp Wich <jo@mein.io> |
| 38 | endef |
| 39 | |
| 40 | define Package/lua/Default/description |
| 41 | Lua is a powerful light-weight programming language designed for extending |
| 42 | applications. Lua is also frequently used as a general-purpose, stand-alone |
| 43 | language. Lua is free software. |
| 44 | endef |
| 45 | |
| 46 | define Package/liblua |
| 47 | $(call Package/lua/Default) |
| 48 | SUBMENU:= |
| 49 | SECTION:=libs |
| 50 | CATEGORY:=Libraries |
| 51 | TITLE+= (libraries) |
| 52 | ABI_VERSION:=5.1.5 |
| 53 | endef |
| 54 | |
| 55 | define Package/liblua/description |
| 56 | $(call Package/lua/Default/description) |
| 57 | This package contains the Lua shared libraries, needed by other programs. |
| 58 | endef |
| 59 | |
| 60 | define Package/lua |
| 61 | $(call Package/lua/Default) |
| 62 | DEPENDS:=+liblua |
| 63 | TITLE+= (interpreter) |
| 64 | endef |
| 65 | |
| 66 | define Package/lua/description |
| 67 | $(call Package/lua/Default/description) |
| 68 | This package contains the Lua language interpreter. |
| 69 | endef |
| 70 | |
| 71 | define Package/luac |
| 72 | $(call Package/lua/Default) |
| 73 | DEPENDS:=+liblua |
| 74 | TITLE+= (compiler) |
| 75 | endef |
| 76 | |
| 77 | define Package/luac/description |
| 78 | $(call Package/lua/Default/description) |
| 79 | This package contains the Lua language compiler. |
| 80 | endef |
| 81 | |
| 82 | define Package/lua-examples |
| 83 | $(call Package/lua/Default) |
| 84 | DEPENDS:=lua |
| 85 | TITLE+= (examples) |
| 86 | endef |
| 87 | |
| 88 | define Package/lua-examples/description |
| 89 | $(call Package/lua/Default/description) |
| 90 | This package contains Lua language examples. |
| 91 | endef |
| 92 | |
| 93 | define Build/Configure |
| 94 | endef |
| 95 | |
| 96 | TARGET_CFLAGS += -DLUA_USE_LINUX $(FPIC) -std=gnu99 |
| 97 | |
| 98 | define Build/Compile |
| 99 | $(MAKE) $(PKG_JOBS) -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_HOSTPKG)/",' $(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) $(HOST_FPIC) -std=gnu99" \ |
| 132 | $(LUA_OS) |
| 133 | endef |
| 134 | |
| 135 | define Host/Install |
| 136 | $(MAKE) -C $(HOST_BUILD_DIR) \ |
| 137 | INSTALL_TOP="$(STAGING_DIR_HOSTPKG)" \ |
| 138 | install |
| 139 | |
| 140 | $(INSTALL_DIR) $(STAGING_DIR_HOSTPKG)/lib/pkgconfig |
| 141 | $(CP) $(HOST_BUILD_DIR)/etc/lua.pc $(STAGING_DIR_HOSTPKG)/lib/pkgconfig/lua5.1.pc |
| 142 | |
| 143 | $(LN) lua5.1 $(STAGING_DIR_HOSTPKG)/bin/lua |
| 144 | $(LN) luac5.1 $(STAGING_DIR_HOSTPKG)/bin/luac |
| 145 | $(LN) lua5.1.pc $(STAGING_DIR_HOSTPKG)/lib/pkgconfig/lua.pc |
| 146 | endef |
| 147 | |
| 148 | define Build/InstallDev |
| 149 | $(INSTALL_DIR) $(1)/usr/include |
| 150 | $(CP) $(PKG_INSTALL_DIR)/usr/include/lua{,lib,conf}.h $(1)/usr/include/ |
| 151 | $(CP) $(PKG_INSTALL_DIR)/usr/include/lua.hpp $(1)/usr/include/ |
| 152 | $(CP) $(PKG_INSTALL_DIR)/usr/include/lauxlib.h $(1)/usr/include/ |
| 153 | $(CP) $(PKG_INSTALL_DIR)/usr/include/lnum_config.h $(1)/usr/include/ |
| 154 | $(INSTALL_DIR) $(1)/usr/lib |
| 155 | $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblua.{a,so*} $(1)/usr/lib/ |
| 156 | $(LN) liblua.so.$(PKG_VERSION) $(1)/usr/lib/liblualib.so |
| 157 | $(INSTALL_DIR) $(1)/usr/lib/pkgconfig |
| 158 | $(CP) $(PKG_BUILD_DIR)/etc/lua.pc $(1)/usr/lib/pkgconfig/ |
| 159 | endef |
| 160 | |
| 161 | define Package/liblua/install |
| 162 | $(INSTALL_DIR) $(1)/usr/lib |
| 163 | $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblua.so.* $(1)/usr/lib/ |
| 164 | endef |
| 165 | |
| 166 | define Package/lua/install |
| 167 | $(INSTALL_DIR) $(1)/usr/bin |
| 168 | $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/lua5.1 $(1)/usr/bin/ |
| 169 | $(LN) lua5.1 $(1)/usr/bin/lua |
| 170 | endef |
| 171 | |
| 172 | define Package/luac/install |
| 173 | $(INSTALL_DIR) $(1)/usr/bin |
| 174 | $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/luac5.1 $(1)/usr/bin/ |
| 175 | $(LN) luac5.1 $(1)/usr/bin/luac |
| 176 | endef |
| 177 | |
| 178 | define Package/lua-examples/install |
| 179 | $(INSTALL_DIR) $(1)/usr/share/lua/examples |
| 180 | $(INSTALL_DATA) $(PKG_BUILD_DIR)/test/*.lua \ |
| 181 | $(1)/usr/share/lua/examples/ |
| 182 | endef |
| 183 | |
| 184 | $(eval $(call BuildPackage,liblua)) |
| 185 | $(eval $(call BuildPackage,lua)) |
| 186 | $(eval $(call BuildPackage,luac)) |
| 187 | $(eval $(call BuildPackage,lua-examples)) |
| 188 | $(eval $(call HostBuild)) |
| 189 | |