b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0-only |
| 2 | # |
| 3 | # Copyright (C) 2012-2015 OpenWrt.org |
| 4 | # Copyright (C) 2016 LEDE Project |
| 5 | |
| 6 | # Substituted by SDK, do not remove |
| 7 | # REVISION:=x |
| 8 | # SOURCE_DATE_EPOCH:=x |
| 9 | |
| 10 | PKG_CONFIG_DEPENDS += \ |
| 11 | CONFIG_VERSION_HOME_URL \ |
| 12 | CONFIG_VERSION_BUG_URL \ |
| 13 | CONFIG_VERSION_NUMBER \ |
| 14 | CONFIG_VERSION_CODE \ |
| 15 | CONFIG_VERSION_REPO \ |
| 16 | CONFIG_VERSION_DIST \ |
| 17 | CONFIG_VERSION_MANUFACTURER \ |
| 18 | CONFIG_VERSION_MANUFACTURER_URL \ |
| 19 | CONFIG_VERSION_PRODUCT \ |
| 20 | CONFIG_VERSION_SUPPORT_URL \ |
| 21 | CONFIG_VERSION_HWREV \ |
| 22 | |
| 23 | sanitize = $(call tolower,$(subst _,-,$(subst $(space),-,$(1)))) |
| 24 | |
| 25 | VERSION_NUMBER:=$(call qstrip,$(CONFIG_VERSION_NUMBER)) |
| 26 | VERSION_NUMBER:=$(if $(VERSION_NUMBER),$(VERSION_NUMBER),24.10-SNAPSHOT) |
| 27 | |
| 28 | VERSION_CODE:=$(call qstrip,$(CONFIG_VERSION_CODE)) |
| 29 | VERSION_CODE:=$(if $(VERSION_CODE),$(VERSION_CODE),$(REVISION)) |
| 30 | |
| 31 | VERSION_REPO:=$(call qstrip,$(CONFIG_VERSION_REPO)) |
| 32 | VERSION_REPO:=$(if $(VERSION_REPO),$(VERSION_REPO),https://downloads.openwrt.org/releases/24.10-SNAPSHOT) |
| 33 | |
| 34 | VERSION_DIST:=$(call qstrip,$(CONFIG_VERSION_DIST)) |
| 35 | VERSION_DIST:=$(if $(VERSION_DIST),$(VERSION_DIST),OpenWrt) |
| 36 | VERSION_DIST_SANITIZED:=$(call sanitize,$(VERSION_DIST)) |
| 37 | |
| 38 | VERSION_MANUFACTURER:=$(call qstrip,$(CONFIG_VERSION_MANUFACTURER)) |
| 39 | VERSION_MANUFACTURER:=$(if $(VERSION_MANUFACTURER),$(VERSION_MANUFACTURER),OpenWrt) |
| 40 | |
| 41 | VERSION_MANUFACTURER_URL:=$(call qstrip,$(CONFIG_VERSION_MANUFACTURER_URL)) |
| 42 | VERSION_MANUFACTURER_URL:=$(if $(VERSION_MANUFACTURER_URL),$(VERSION_MANUFACTURER_URL),https://openwrt.org/) |
| 43 | |
| 44 | VERSION_BUG_URL:=$(call qstrip,$(CONFIG_VERSION_BUG_URL)) |
| 45 | VERSION_BUG_URL:=$(if $(VERSION_BUG_URL),$(VERSION_BUG_URL),https://bugs.openwrt.org/) |
| 46 | |
| 47 | VERSION_HOME_URL:=$(call qstrip,$(CONFIG_VERSION_HOME_URL)) |
| 48 | VERSION_HOME_URL:=$(if $(VERSION_HOME_URL),$(VERSION_HOME_URL),https://openwrt.org/) |
| 49 | |
| 50 | VERSION_SUPPORT_URL:=$(call qstrip,$(CONFIG_VERSION_SUPPORT_URL)) |
| 51 | VERSION_SUPPORT_URL:=$(if $(VERSION_SUPPORT_URL),$(VERSION_SUPPORT_URL),https://forum.openwrt.org/) |
| 52 | |
| 53 | VERSION_PRODUCT:=$(call qstrip,$(CONFIG_VERSION_PRODUCT)) |
| 54 | VERSION_PRODUCT:=$(if $(VERSION_PRODUCT),$(VERSION_PRODUCT),Generic) |
| 55 | |
| 56 | VERSION_HWREV:=$(call qstrip,$(CONFIG_VERSION_HWREV)) |
| 57 | VERSION_HWREV:=$(if $(VERSION_HWREV),$(VERSION_HWREV),v0) |
| 58 | |
| 59 | define taint2sym |
| 60 | $(CONFIG_$(firstword $(subst :, ,$(subst +,,$(subst -,,$(1)))))) |
| 61 | endef |
| 62 | |
| 63 | define taint2name |
| 64 | $(lastword $(subst :, ,$(1))) |
| 65 | endef |
| 66 | |
| 67 | VERSION_TAINT_SPECS := \ |
| 68 | -ALL_KMODS:no-all \ |
| 69 | -IPV6:no-ipv6 \ |
| 70 | +USE_GLIBC:glibc \ |
| 71 | +USE_MKLIBS:mklibs \ |
| 72 | +BUSYBOX_CUSTOM:busybox \ |
| 73 | +OVERRIDE_PKGS:override \ |
| 74 | |
| 75 | VERSION_TAINTS := $(strip $(foreach taint,$(VERSION_TAINT_SPECS), \ |
| 76 | $(if $(findstring +,$(taint)), \ |
| 77 | $(if $(call taint2sym,$(taint)),$(call taint2name,$(taint))), \ |
| 78 | $(if $(call taint2sym,$(taint)),,$(call taint2name,$(taint))) \ |
| 79 | ))) |
| 80 | |
| 81 | PKG_CONFIG_DEPENDS += $(foreach taint,$(VERSION_TAINT_SPECS),$(call taint2sym,$(taint))) |
| 82 | |
| 83 | # escape commas, backslashes, squotes, and ampersands for sed |
| 84 | define sed_escape |
| 85 | $(subst &,\&,$(subst $(comma),\$(comma),$(subst ','\'',$(subst \,\\,$(1))))) |
| 86 | endef |
| 87 | #' |
| 88 | |
| 89 | VERSION_SED_SCRIPT:=$(SED) 's,%U,$(call sed_escape,$(VERSION_REPO)),g' \ |
| 90 | -e 's,%V,$(call sed_escape,$(VERSION_NUMBER)),g' \ |
| 91 | -e 's,%v,\L$(call sed_escape,$(subst $(space),_,$(VERSION_NUMBER))),g' \ |
| 92 | -e 's,%C,$(call sed_escape,$(VERSION_CODE)),g' \ |
| 93 | -e 's,%c,\L$(call sed_escape,$(subst $(space),_,$(VERSION_CODE))),g' \ |
| 94 | -e 's,%D,$(call sed_escape,$(VERSION_DIST)),g' \ |
| 95 | -e 's,%d,\L$(call sed_escape,$(subst $(space),_,$(VERSION_DIST))),g' \ |
| 96 | -e 's,%R,$(call sed_escape,$(REVISION)),g' \ |
| 97 | -e 's,%T,$(call sed_escape,$(BOARD)),g' \ |
| 98 | -e 's,%S,$(call sed_escape,$(BOARD)/$(SUBTARGET)),g' \ |
| 99 | -e 's,%A,$(call sed_escape,$(ARCH_PACKAGES)),g' \ |
| 100 | -e 's,%t,$(call sed_escape,$(VERSION_TAINTS)),g' \ |
| 101 | -e 's,%M,$(call sed_escape,$(VERSION_MANUFACTURER)),g' \ |
| 102 | -e 's,%m,$(call sed_escape,$(VERSION_MANUFACTURER_URL)),g' \ |
| 103 | -e 's,%b,$(call sed_escape,$(VERSION_BUG_URL)),g' \ |
| 104 | -e 's,%u,$(call sed_escape,$(VERSION_HOME_URL)),g' \ |
| 105 | -e 's,%s,$(call sed_escape,$(VERSION_SUPPORT_URL)),g' \ |
| 106 | -e 's,%P,$(call sed_escape,$(VERSION_PRODUCT)),g' \ |
| 107 | -e 's,%h,$(call sed_escape,$(VERSION_HWREV)),g' \ |
| 108 | -e 's,%B,$(call sed_escape,$(SOURCE_DATE_EPOCH)),g' |
| 109 | |