small-packages/upx-static/Makefile
2026-06-15 17:57:28 +08:00

99 lines
3.1 KiB
Makefile
Executable File

# SPDX-License-Identifier: GPL-2.0-only
# Copyright (C) kenzok8 <https://github.com/kenzok8>
include $(TOPDIR)/rules.mk
PKG_NAME:=upx-static
PKG_VERSION:=5.2.0
PKG_RELEASE:=1
PKG_SOURCE_VERSION:=v5.2.0
# Map OpenWrt $(ARCH) to UPX pre-built binary arch name.
# NOTE: OpenWrt uses "aarch64", UPX tarball uses "arm64".
UPX_ARCH:=$(ARCH)
ifeq ($(findstring x86_64,$(ARCH)),x86_64)
UPX_ARCH:=amd64
else ifeq ($(findstring i386,$(ARCH)),i386)
UPX_ARCH:=i386
else ifeq ($(findstring aarch64,$(ARCH)),aarch64)
UPX_ARCH:=arm64
else ifeq ($(findstring arm,$(ARCH)),arm)
UPX_ARCH:=arm
else ifeq ($(findstring armeb,$(ARCH)),armeb)
UPX_ARCH:=armeb
else ifeq ($(findstring mipsel,$(ARCH)),mipsel)
UPX_ARCH:=mipsel
else ifeq ($(findstring mips,$(ARCH)),mips)
UPX_ARCH:=mips
else ifeq ($(findstring powerpc,$(ARCH)),powerpc)
UPX_ARCH:=powerpc
else ifeq ($(findstring powerpc64,$(ARCH)),powerpc64)
UPX_ARCH:=powerpc64le
else ifeq ($(findstring riscv64,$(ARCH)),riscv64)
UPX_ARCH:=riscv64
endif
PKG_SOURCE:=upx-$(PKG_VERSION)-$(UPX_ARCH)_linux.tar.xz
PKG_SOURCE_URL:=https://github.com/upx/upx/releases/download/$(PKG_SOURCE_VERSION)
# AUTO-GENERATED HASHES BEGIN
ifeq ($(UPX_ARCH),amd64)
PKG_HASH:=3db5d3294707439db97866feab8d75d800f028f48481a40547411824da4288a1
else ifeq ($(UPX_ARCH),i386)
PKG_HASH:=cde78cdb67bd70cf3edd29c029849a029760a4bca8331a9fe382675029747039
else ifeq ($(UPX_ARCH),arm64)
PKG_HASH:=55d48a61e8ffd17152db871c855376cba7f08e830b37799d0947a16dff8ec36c
else ifeq ($(UPX_ARCH),arm)
PKG_HASH:=6675c2481c995447a5169ff9c4f7e303bef9372b26645c06f10016b36e649eac
else ifeq ($(UPX_ARCH),armeb)
PKG_HASH:=c63e70a62c8dd58e5f4c72b1f34c1bb20cc2e76922f86275d78251ed5ac99042
else ifeq ($(UPX_ARCH),mipsel)
PKG_HASH:=20d7af4fab1acf2395e4553c0c640454141781b584469e74031c61f80184fd7d
else ifeq ($(UPX_ARCH),mips)
PKG_HASH:=52316cc55fa6abe3a6298423b654c2349085d20d03ac3b51d065bfa66273f47e
else ifeq ($(UPX_ARCH),powerpc)
PKG_HASH:=8815df50a5a1827873e35c0d4694e21bc789b6cf764b2433c787e8925f1da652
else ifeq ($(UPX_ARCH),powerpc64le)
PKG_HASH:=d9f9fe0f474dc9d4319a6ce205219075cb9b53f4f1ab9ab393b0a79c5261d050
else ifeq ($(UPX_ARCH),riscv64)
PKG_HASH:=6d16f1817a9df1ae41e4facfb2eb3a7cc69a67f9bb05c2e6b83ade453c3384e3
else
$(error Unsupported UPX_ARCH '$(UPX_ARCH)' for upx-static)
endif
# AUTO-GENERATED HASHES END
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/package.mk
define Package/$(PKG_NAME)
SUBMENU:=Compression
SECTION:=utils
CATEGORY:=Utilities
TITLE:=UPX - The Ultimate Packer for eXecutables
URL:=https://upx.github.io
endef
define Package/$(PKG_NAME)/description
UPX is a free, portable, extendable, high-performance executable
packer for several executable formats. This package installs the
statically-linked pre-built binary from the official upstream release.
endef
define Build/Prepare
rm -rf $(PKG_BUILD_DIR)
mkdir -p $(PKG_BUILD_DIR)
tar -xJf $(DL_DIR)/$(PKG_SOURCE) -C $(PKG_BUILD_DIR) --strip-components=1
endef
define Build/Compile
endef
define Package/$(PKG_NAME)/install
$(INSTALL_DIR) $(1)/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/upx $(1)/bin/upx
endef
$(eval $(call BuildPackage,$(PKG_NAME)))