| 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.3.5 |
| 12 | PKG_RELEASE:=6 |
| 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:=0c2eed3f960446e1a3e4b9a1ca2f3ff893b6ce41942cf54d5dd59ab4b3b058ac |
| 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 | HOST_PATCH_DIR := ./patches-host |
| 25 | |
| 26 | include $(INCLUDE_DIR)/package.mk |
| 27 | include $(INCLUDE_DIR)/host-build.mk |
| 28 | |
| 29 | define Package/lua5.3/Default |
| 30 | SUBMENU:=Lua |
| 31 | SECTION:=lang |
| 32 | CATEGORY:=Languages |
| 33 | TITLE:=Lua programming language (version 5.3) |
| 34 | URL:=https://www.lua.org/ |
| 35 | MAINTAINER:=Jo-Philipp Wich <jo@mein.io> |
| 36 | endef |
| 37 | |
| 38 | define Package/lua5.3/Default/description |
| 39 | Lua is a powerful, efficient, lightweight, embeddable scripting language. It |
| 40 | supports procedural programming, object-oriented programming, functional |
| 41 | programming, data-driven programming, and data description. |
| 42 | endef |
| 43 | |
| 44 | define Package/liblua5.3 |
| 45 | $(call Package/lua5.3/Default) |
| 46 | SUBMENU:= |
| 47 | SECTION:=libs |
| 48 | CATEGORY:=Libraries |
| 49 | TITLE+= (libraries) |
| 50 | ABI_VERSION:=5.3 |
| 51 | endef |
| 52 | |
| 53 | define Package/liblua5.3/description |
| 54 | $(call Package/lua5.3/Default/description) |
| 55 | This package contains the Lua shared libraries, needed by other programs. |
| 56 | endef |
| 57 | |
| 58 | define Package/lua5.3 |
| 59 | $(call Package/lua5.3/Default) |
| 60 | DEPENDS:=+liblua5.3 |
| 61 | TITLE+= (interpreter) |
| 62 | endef |
| 63 | |
| 64 | define Package/lua5.3/description |
| 65 | $(call Package/lua5.3/Default/description) |
| 66 | This package contains the Lua language interpreter. |
| 67 | endef |
| 68 | |
| 69 | define Package/luac5.3 |
| 70 | $(call Package/lua5.3/Default) |
| 71 | DEPENDS:=+liblua5.3 |
| 72 | TITLE+= (compiler) |
| 73 | endef |
| 74 | |
| 75 | define Package/luac5.3/description |
| 76 | $(call Package/lua5.3/Default/description) |
| 77 | This package contains the Lua language compiler. |
| 78 | endef |
| 79 | |
| 80 | TARGET_CFLAGS += -DLUA_USE_LINUX $(FPIC) -std=gnu99 |
| 81 | |
| 82 | define Build/Compile |
| 83 | $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) \ |
| 84 | CC="$(TARGET_CROSS)gcc" \ |
| 85 | AR="$(TARGET_CROSS)ar rcu" \ |
| 86 | RANLIB="$(TARGET_CROSS)ranlib" \ |
| 87 | INSTALL_ROOT=/usr \ |
| 88 | CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" \ |
| 89 | PKG_VERSION=$(PKG_VERSION) \ |
| 90 | linux |
| 91 | rm -rf $(PKG_INSTALL_DIR) |
| 92 | mkdir -p $(PKG_INSTALL_DIR) |
| 93 | $(MAKE) -C $(PKG_BUILD_DIR) \ |
| 94 | INSTALL_TOP="$(PKG_INSTALL_DIR)/usr" \ |
| 95 | install |
| 96 | endef |
| 97 | |
| 98 | define Host/Configure |
| 99 | $(SED) 's,"/usr/local/","$(STAGING_DIR_HOSTPKG)/",' $(HOST_BUILD_DIR)/src/luaconf.h |
| 100 | endef |
| 101 | |
| 102 | ifeq ($(HOST_OS),Darwin) |
| 103 | LUA_OS:=macosx |
| 104 | else |
| 105 | ifeq ($(HOST_OS),FreeBSD) |
| 106 | LUA_OS:=freebsd |
| 107 | else |
| 108 | LUA_OS:=linux |
| 109 | endif |
| 110 | endif |
| 111 | |
| 112 | define Host/Compile |
| 113 | $(MAKE) -C $(HOST_BUILD_DIR) \ |
| 114 | CC="$(HOSTCC) $(HOST_FPIC) -std=gnu99" \ |
| 115 | $(LUA_OS) |
| 116 | endef |
| 117 | |
| 118 | define Host/Install |
| 119 | $(MAKE) -C $(HOST_BUILD_DIR) \ |
| 120 | INSTALL_TOP="$(STAGING_DIR_HOSTPKG)" \ |
| 121 | install |
| 122 | endef |
| 123 | |
| 124 | define Build/InstallDev |
| 125 | $(INSTALL_DIR) $(1)/usr/include/lua5.3 $(1)/usr/lib |
| 126 | $(CP) $(PKG_INSTALL_DIR)/usr/include/lua5.3/lua{,lib,conf}.h $(1)/usr/include/lua5.3/ |
| 127 | $(CP) $(PKG_INSTALL_DIR)/usr/include/lua5.3/lua.hpp $(1)/usr/include/lua5.3/ |
| 128 | $(CP) $(PKG_INSTALL_DIR)/usr/include/lua5.3/lauxlib.h $(1)/usr/include/lua5.3/ |
| 129 | $(INSTALL_DIR) $(1)/usr/lib |
| 130 | $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblua5.3.{a,so*} $(1)/usr/lib/ |
| 131 | $(LN) liblua5.3.so.0.0.0 $(1)/usr/lib/liblualib5.3.so |
| 132 | endef |
| 133 | |
| 134 | define Package/liblua5.3/install |
| 135 | $(INSTALL_DIR) $(1)/usr/lib |
| 136 | $(CP) $(PKG_INSTALL_DIR)/usr/lib/liblua5.3.so* $(1)/usr/lib/ |
| 137 | endef |
| 138 | |
| 139 | define Package/lua5.3/install |
| 140 | $(INSTALL_DIR) $(1)/usr/bin |
| 141 | $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/lua5.3 $(1)/usr/bin/ |
| 142 | endef |
| 143 | |
| 144 | define Package/luac5.3/install |
| 145 | $(INSTALL_DIR) $(1)/usr/bin |
| 146 | $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/luac5.3 $(1)/usr/bin/ |
| 147 | endef |
| 148 | |
| 149 | $(eval $(call BuildPackage,liblua5.3)) |
| 150 | $(eval $(call BuildPackage,lua5.3)) |
| 151 | $(eval $(call BuildPackage,luac5.3)) |
| 152 | $(eval $(call HostBuild)) |