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