add PKGMANAGE
[vuplus_openvuplus_3.0] / Makefile
1 #!/usr/bin/make -f
2 #
3 # Permission is hereby granted, free of charge, to any person obtaining a copy
4 # of this software and associated documentation files (the "Software"), to deal
5 # in the Software without restriction, including without limitation the rights
6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 # copies of the Software, and to permit persons to whom the Software is
8 # furnished to do so, subject to the following conditions:
9 #
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
12 #
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 # THE SOFTWARE.
20 #
21
22 # Note: You can override all variables by storing them
23 # in an external file called "make.conf".
24 -include conf/make.conf
25
26 # Target platform:
27 # vusolo, bm750, vuuno, vuultimo, vuduo2
28 #
29 # This only sets the default value. All platforms now use a shared build
30 # directory. Run "MACHINE=vuultimo bitbake vuplus-image" to build an image
31 # for the vuultimo, if it is not the default.
32 MACHINE ?= bm750
33
34 MULTI_TEMPORARILY ?=
35
36 # Adjust according to the number CPU cores to use for parallel build.
37 # Default: Number of processors in /proc/cpuinfo, if present, or 1.
38 NR_CPU := $(shell [ -f /proc/cpuinfo ] && grep -c '^processor\s*:' /proc/cpuinfo || echo 1)
39 BB_NUMBER_THREADS ?= $(NR_CPU)
40 PARALLEL_MAKE ?= -j $(NR_CPU)
41
42 XSUM ?= md5sum
43
44 BUILD_DIR = $(CURDIR)/build
45 TOPDIR = $(BUILD_DIR)/$(MACHINE)
46 DL_DIR = $(CURDIR)/sources
47
48 ifeq ($(MULTI_TEMPORARILY), YES)
49 SSTATE_DIR = $(TOPDIR)/sstate-cache
50 TMPDIR = $(TOPDIR)/tmp
51 DEPDIR = $(TOPDIR)/.deps
52 else
53 SSTATE_DIR = $(BUILD_DIR)/sstate-cache
54 TMPDIR = $(BUILD_DIR)/tmp
55 DEPDIR = $(BUILD_DIR)/.deps
56 endif
57
58 BBLAYERS ?= \
59         $(CURDIR)/meta-bsp/$(MACHINE) \
60         $(CURDIR)/meta-bsp/common \
61         $(CURDIR)/meta-openvuplus \
62         $(CURDIR)/meta-openembedded/meta-oe \
63         $(CURDIR)/openembedded-core/meta
64
65 CONFFILES = \
66         bitbake.env \
67         $(TOPDIR)/conf/bblayers.conf \
68         $(TOPDIR)/conf/local.conf
69
70 CONFDEPS = \
71         $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH) \
72         $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH) \
73         $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH)
74
75 GIT ?= git
76 GIT_REMOTE := $(shell $(GIT) remote)
77 GIT_USER_NAME := $(shell $(GIT) config user.name)
78 GIT_USER_EMAIL := $(shell $(GIT) config user.email)
79
80 hash = $(shell echo $(1) | $(XSUM) | awk '{print $$1}')
81
82 .DEFAULT_GOAL := all
83 all: init usage
84
85 $(BBLAYERS):
86         [ -d $@ ] || $(MAKE) $(MFLAGS) update
87
88 init: $(BBLAYERS) $(CONFFILES)
89
90 help:
91         @echo "Your options:"
92         @echo
93         @echo "  * Update the SDK"
94         @echo "      $$ $(MAKE) update"
95         @echo
96         @echo "  * Select a new target machine:"
97         @echo "      $$ echo MACHINE=vuultimo >> conf/make.conf"
98         @echo "    [Valid values: vusolo, bm750, vuuno, vuultimo, vuduo2]"
99         @echo
100         @echo "  * Build a firmware image for the selected target machine:"
101         @echo "      $$ $(MAKE) image"
102         @echo
103         @echo "  * Build a firmware image for a different target machine:"
104         @echo "      $$ $(MAKE) image MACHINE=vuultimo"
105         @echo "    [Valid values: vusolo, bm750, vuuno, vuultimo, vuduo2]"
106         @echo
107         @echo "  * Download all source files at once:"
108         @echo "      $$ $(MAKE) download"
109         @echo
110         @echo "  * Set up the environment to build recipes manually:"
111         @echo "      $$ source bitbake.env"
112         @echo "      $$ cd build/$(MACHINE)"
113         @echo "      $$ bitbake <target>"
114         @echo "    [Replace <target> with a recipe name, e.g. vuplus-image or enigma2]"
115         @echo
116         @echo "Your current settings:"
117         @echo "  MACHINE = $(MACHINE)"
118         @echo
119         @echo "  BB_NUMBER_THREADS = $(BB_NUMBER_THREADS)"
120         @echo "  PARALLEL_MAKE = $(PARALLEL_MAKE)"
121         @echo
122         @echo "Trouble finding a recipe? Try ./scripts/drepo grep 'search string'"
123         @echo "or ./scripts/drepo find -name \"*recipe*\"."
124         @echo
125         @if [ -z "$(GIT_USER_NAME)" -o -z "$(GIT_USER_EMAIL)" ]; then \
126                 echo "Before doing any commits, please configure your name and email"; \
127                 echo "address using the following commands:"; \
128                 echo; \
129                 echo "  $$ $(GIT) config user.name \"Your Name\""; \
130                 echo "  $$ $(GIT) config user.email \"mail@example.com\""; \
131         else \
132                 echo "Git has been configured for $(GIT_USER_NAME) <$(GIT_USER_EMAIL)>."; \
133                 echo "Please submit patches to <enigma2-devel@lists.elitedvb.net>."; \
134         fi
135
136 usage:
137         @echo "[*] Please run '$(MAKE) help' to display further information!"
138
139 clean:
140         @echo '[*] Deleting generated configuration files'
141         @$(RM) $(CONFFILES) $(CONFDEPS)
142
143 distclean: clean
144         @echo '[*] Deleting dependencies directory'
145         @$(RM) -r $(DEPDIR)
146         @echo '[*] Deleting download directory'
147         @$(RM) -r $(DL_DIR)
148         @echo '[*] Deleting tmp directory'
149         @$(RM) -r $(TMPDIR)
150         @echo '[*] Deleting sstate directory'
151         @$(RM) -r $(SSTATE_DIR)
152         @echo '[*] Deleting build directory'
153         @$(RM) -r $(BUILD_DIR)
154         @echo '[*] Deleting git submodules'
155         @$(GIT) submodule foreach 'rm -rf .* * 2>/dev/null || true'
156
157 image: init
158         @echo '[*] Building image for $(MACHINE)'
159         @. $(CURDIR)/bitbake.env && cd $(TOPDIR) && bitbake vuplus-image
160
161 download: init
162         @echo '[*] Downloading sources'
163         @. $(CURDIR)/bitbake.env && cd $(TOPDIR) && bitbake -cfetchall -k vuplus-image
164
165 update:
166         @echo '[*] Updating Git repositories...'
167         @HASH=`$(XSUM) $(MAKEFILE_LIST)`; \
168         if [ -n "$(GIT_REMOTE)" ]; then \
169                 $(GIT) pull --ff-only || $(GIT) pull --rebase; \
170         fi; \
171         if [ "$$HASH" != "`$(XSUM) $(MAKEFILE_LIST)`" ]; then \
172                 echo '[*] Makefile changed. Restarting...'; \
173                 $(MAKE) $(MFLAGS) --no-print-directory $(MAKECMDGOALS); \
174         else \
175                 $(GIT) submodule sync && \
176                 $(GIT) submodule update --init && \
177                 echo "[*] The Vuplus SDK is now up-to-date."; \
178         fi
179
180 .PHONY: all clean help image init update usage
181
182 MACHINE_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-$(MACHINE)-ext.conf
183 DISTRO_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-ext.conf
184
185 BITBAKE_ENV_HASH := $(call hash, \
186         'BITBAKE_ENV_VERSION = "0"' \
187         'CURDIR = "$(CURDIR)"' \
188         )
189
190 bitbake.env: $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH)
191         @echo '[*] Generating $@'
192         @echo '# Automatically generated file. Do not edit!' > $@
193         @echo 'export PATH=$(CURDIR)/openembedded-core/scripts:$(CURDIR)/bitbake/bin:$${PATH}' >> $@
194
195 LOCAL_CONF_HASH := $(call hash, \
196         'LOCAL_CONF_VERSION = "0"' \
197         'CURDIR = "$(CURDIR)"' \
198         'TOPDIR = "$(TOPDIR)"' \
199         'MACHINE = "$(MACHINE)"' \
200         'OPENVUPLUS_CONF_VERSION = "1"' \
201         'CURDIR = "$(CURDIR)"' \
202         'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' \
203         'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' \
204         'DL_DIR = "$(DL_DIR)"' \
205         'SSTATE_DIR = "$(SSTATE_DIR)"' \
206         'TMPDIR = "$(TMPDIR)"' \
207         )
208
209 $(TOPDIR)/conf/local.conf: $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH)
210         @echo '[*] Generating $@'
211         @test -d $(@D) || mkdir -p $(@D)
212         @echo '# Automatically generated file. Do not edit!' > $@
213         @echo 'TOPDIR = "$(TOPDIR)"' >> $@
214         @echo 'MACHINE = "$(MACHINE)"' >> $@
215         @echo 'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' >> $@
216         @echo 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' >> $@
217         @echo 'DL_DIR = "$(DL_DIR)"' >> $@
218         @echo 'SSTATE_DIR = "$(SSTATE_DIR)"' >> $@
219         @echo 'TMPDIR = "$(TMPDIR)"' >> $@
220         @echo 'BB_GENERATE_MIRROR_TARBALLS = "0"' >> $@
221         @echo 'BBINCLUDELOGS = "yes"' >> $@
222         @echo 'CONF_VERSION = "1"' >> $@
223         @echo 'DISTRO = "vuplus"' >> $@
224         @echo 'EXTRA_IMAGE_FEATURES = "debug-tweaks"' >> $@
225         @echo 'USER_CLASSES = "buildstats"' >> $@
226         @echo 'include $(DISTRO_INCLUDE_CONF)' >> $@
227         @echo 'include $(MACHINE_INCLUDE_CONF)' >> $@
228
229 BBLAYERS_CONF_HASH := $(call hash, \
230         'BBLAYERS_CONF_VERSION = "0"' \
231         'CURDIR = "$(CURDIR)"' \
232         'BBLAYERS = "$(BBLAYERS)"' \
233         )
234
235 $(TOPDIR)/conf/bblayers.conf: $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH)
236         @echo '[*] Generating $@'
237         @test -d $(@D) || mkdir -p $(@D)
238         @echo '# Automatically generated file. Do not edit!' > $@
239         @echo 'LCONF_VERSION = "4"' >> $@
240         @echo 'BBFILES = ""' >> $@
241         @echo 'BBLAYERS = "$(BBLAYERS)"' >> $@
242         @echo 'include $(DISTRO_INCLUDE_CONF)' >> $@
243         @echo 'include $(MACHINE_INCLUDE_CONF)' >> $@
244
245 $(CONFDEPS):
246         @test -d $(@D) || mkdir -p $(@D)
247         @$(RM) $(basename $@).*
248         @touch $@