c4747f236f9b2a04f0ef825a135cb805271b78c6
[lede.git] / include / version.mk
1 #
2 # Copyright (C) 2012 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 # Substituted by SDK, do not remove
9 # REVISION:=x
10
11 PKG_CONFIG_DEPENDS += \
12         CONFIG_VERSION_NUMBER \
13         CONFIG_VERSION_NICK \
14         CONFIG_VERSION_REPO \
15         CONFIG_VERSION_DIST \
16         CONFIG_VERSION_MANUFACTURER \
17         CONFIG_VERSION_PRODUCT \
18         CONFIG_VERSION_HWREV \
19
20 qstrip_escape=$(subst ','\'',$(call qstrip,$(1)))
21 #'
22
23 VERSION_NUMBER:=$(call qstrip_escape,$(CONFIG_VERSION_NUMBER))
24 VERSION_NUMBER:=$(if $(VERSION_NUMBER),$(VERSION_NUMBER),$(REVISION))
25
26 VERSION_CODE:=$(call qstrip_escape,$(CONFIG_VERSION_NUMBER))
27 VERSION_CODE:=$(if $(VERSION_CODE),$(VERSION_CODE),Bleeding Edge)
28
29 VERSION_NICK:=$(call qstrip_escape,$(CONFIG_VERSION_NICK))
30 VERSION_NICK:=$(if $(VERSION_NICK),$(VERSION_NICK),$(RELEASE))
31
32 VERSION_REPO:=$(call qstrip_escape,$(CONFIG_VERSION_REPO))
33 VERSION_REPO:=$(if $(VERSION_REPO),$(VERSION_REPO),http://downloads.openwrt.org/snapshots/trunk/%T/packages)
34
35 VERSION_DIST:=$(call qstrip_escape,$(CONFIG_VERSION_DIST))
36 VERSION_DIST:=$(if $(VERSION_DIST),$(VERSION_DIST),OpenWrt)
37
38 VERSION_MANUFACTURER:=$(call qstrip_escape,$(CONFIG_VERSION_MANUFACTURER))
39 VERSION_MANUFACTURER:=$(if $(VERSION_MANUFACTURER),$(VERSION_MANUFACTURER),OpenWrt)
40
41 VERSION_PRODUCT:=$(call qstrip_escape,$(CONFIG_VERSION_PRODUCT))
42 VERSION_PRODUCT:=$(if $(VERSION_PRODUCT),$(VERSION_PRODUCT),Generic)
43
44 VERSION_HWREV:=$(call qstrip_escape,$(CONFIG_VERSION_HWREV))
45 VERSION_HWREV:=$(if $(VERSION_HWREV),$(VERSION_HWREV),v0)
46
47 define taint2sym
48 $(CONFIG_$(firstword $(subst :, ,$(subst +,,$(subst -,,$(1))))))
49 endef
50
51 define taint2name
52 $(lastword $(subst :, ,$(1)))
53 endef
54
55 VERSION_TAINT_SPECS := \
56         -ALL:no-all \
57         -IPV6:no-ipv6 \
58         +USE_EGLIBC:eglibc \
59         +USE_MKLIBS:mklibs \
60         +BUSYBOX_CUSTOM:busybox \
61
62 VERSION_TAINTS := $(strip $(foreach taint,$(VERSION_TAINT_SPECS), \
63         $(if $(findstring +,$(taint)), \
64                 $(if $(call taint2sym,$(taint)),$(call taint2name,$(taint))), \
65                 $(if $(call taint2sym,$(taint)),,$(call taint2name,$(taint))) \
66         )))
67
68 PKG_CONFIG_DEPENDS += $(foreach taint,$(VERSION_TAINT_SPECS),$(call taint2sym,$(taint)))
69
70 VERSION_SED:=$(SED) 's,%U,$(VERSION_REPO),g' \
71         -e 's,%V,$(VERSION_NUMBER),g' \
72         -e 's,%v,\L$(subst $(space),_,$(VERSION_NUMBER)),g' \
73         -e 's,%C,$(VERSION_CODE),g' \
74         -e 's,%c,\L$(subst $(space),_,$(VERSION_CODE)),g' \
75         -e 's,%N,$(VERSION_NICK),g' \
76         -e 's,%n,\L$(subst $(space),_,$(VERSION_NICK)),g' \
77         -e 's,%D,$(VERSION_DIST),g' \
78         -e 's,%d,\L$(subst $(space),_,$(VERSION_DIST)),g' \
79         -e 's,%R,$(REVISION),g' \
80         -e 's,%T,$(BOARD),g' \
81         -e 's,%S,$(BOARD)/$(if $(SUBTARGET),$(SUBTARGET),generic),g' \
82         -e 's,%t,$(VERSION_TAINTS),g' \
83         -e 's,%M,$(VERSION_MANUFACTURER),g' \
84         -e 's,%P,$(VERSION_PRODUCT),g' \
85         -e 's,%h,$(VERSION_HWREV),g'
86
87 VERSION_SED_SCRIPT:=$(subst '\'','\'\\\\\'\'',$(VERSION_SED))