3 # Copyright (c) 2010-2013 Dream Multimedia GmbH, Germany
4 # http://www.dream-multimedia-tv.de/
6 # Andreas Oberritter <obi@opendreambox.org>
8 # Permission is hereby granted, free of charge, to any person obtaining a copy
9 # of this software and associated documentation files (the "Software"), to deal
10 # in the Software without restriction, including without limitation the rights
11 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 # copies of the Software, and to permit persons to whom the Software is
13 # furnished to do so, subject to the following conditions:
15 # The above copyright notice and this permission notice shall be included in
16 # all copies or substantial portions of the Software.
18 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
27 # Note: You can override all variables by storing them
28 # in an external file called "make.conf".
29 -include conf/make.conf
32 # dm8000, dm500hd, dm800se, dm7020hd, dm500hdv2, dm800sev2, dm7020hdv2
34 # This only sets the default value. All platforms now use a shared build
35 # directory. Run "MACHINE=dm800se bitbake dreambox-image" to build an image
36 # for the dm800se, if it is not the default.
39 USER_MACHINE := $(MACHINE)
41 ifeq ($(MACHINE),dm7020hdv2)
42 override MACHINE := dm7020hd
43 MAKE_IMAGE_BB ?= dreambox-image-dm7020hdv2
46 MAKE_IMAGE_BB ?= dreambox-image
48 # Adjust according to the number CPU cores to use for parallel build.
49 # Default: Number of processors in /proc/cpuinfo, if present, or 1.
50 NR_CPU := $(shell [ -f /proc/cpuinfo ] && grep -c '^processor\s*:' /proc/cpuinfo || echo 1)
51 BB_NUMBER_THREADS ?= $(NR_CPU)
52 PARALLEL_MAKE ?= -j $(NR_CPU)
56 BUILD_DIR = $(CURDIR)/build
57 TOPDIR = $(BUILD_DIR)/$(MACHINE)
58 DL_DIR = $(CURDIR)/sources
59 PERSISTENT_DIR = $(CURDIR)/persist-cache
60 SSTATE_DIR = $(CURDIR)/sstate-cache
61 TMPDIR = $(TOPDIR)/tmp
62 DEPDIR = $(CURDIR)/.deps
64 BITBAKE = . $(CURDIR)/bitbake.env && cd $(TOPDIR) && bitbake
67 $(wildcard $(CURDIR)/meta-bsp/$(MACHINE)) \
68 $(CURDIR)/meta-bsp/common \
69 $(CURDIR)/meta-opendreambox \
71 $(CURDIR)/meta-openembedded/meta-oe \
72 $(CURDIR)/meta-openembedded/meta-filesystems \
73 $(CURDIR)/meta-openembedded/meta-multimedia \
74 $(CURDIR)/meta-openembedded/meta-networking \
75 $(CURDIR)/meta-openembedded/meta-ruby \
76 $(CURDIR)/openembedded-core/meta
80 conf/opendreambox.conf \
81 $(TOPDIR)/conf/bblayers.conf \
82 $(TOPDIR)/conf/local.conf
85 .cross-compile-$(MACHINE).env
88 $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH) \
89 $(DEPDIR)/.opendreambox.conf.$(OPENDREAMBOX_CONF_HASH) \
90 $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH) \
91 $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH) \
92 $(DEPDIR)/.cross-compile.env.$(MACHINE).$(CROSS_COMPILE_ENV_HASH)
95 $(TOPDIR)/conf/bblayers.conf \
96 $(TOPDIR)/conf/local.conf \
97 conf/opendreambox.conf \
98 openembedded-core/meta/conf/bitbake.conf \
100 conf/bblayers-ext.conf \
101 conf/bblayers-$(MACHINE)-ext.conf \
102 conf/local-ext.conf \
103 conf/local-$(MACHINE)-ext.conf)
106 GIT_REMOTE := $(shell $(GIT) remote)
107 GIT_USER_NAME := $(shell $(GIT) config user.name)
108 GIT_USER_EMAIL := $(shell $(GIT) config user.email)
110 hash = $(shell echo $(1) | $(XSUM) | awk '{print $$1}')
116 [ -d $@ ] || $(MAKE) $(MFLAGS) update
118 init: $(BBLAYERS) $(CONFFILES_AUTO)
121 @echo "Your options:"
123 @echo " * Update the SDK"
124 @echo " $$ $(MAKE) update"
126 @echo " * Build the PDF documentation (doc/opendreambox.pdf, requires pdfTeX):"
127 @echo " $$ $(MAKE) doc"
129 @echo " * View the documentation in text format:"
130 @echo " $$ view doc/opendreambox.txt"
132 @echo " * Select a new target machine:"
133 @echo " $$ echo MACHINE=dm800se >> conf/make.conf"
134 @echo " [Valid values: dm8000, dm500hd, dm800se, dm7020hd, dm7020hdv2, dm800sev2, dm500hdv2]"
136 @echo " * Build a firmware image for the selected target machine:"
137 @echo " $$ $(MAKE) image"
139 @echo " * Build a firmware image for a different target machine:"
140 @echo " $$ $(MAKE) image MACHINE=dm800se"
141 @echo " [Valid values: dm8000, dm500hd, dm800se, dm7020hd, dm7020hdv2, dm800sev2, dm500hdv2]"
143 @echo " * Download all source files at once:"
144 @echo " $$ $(MAKE) download"
146 @echo " * Set up the environment to build recipes manually:"
147 @echo " $$ source bitbake.env"
148 @echo " $$ cd build/$(MACHINE)"
149 @echo " $$ bitbake <target>"
150 @echo " [Replace <target> with a recipe name, e.g. $(MAKE_IMAGE_BB) or enigma2]"
152 @echo "Your current settings:"
153 @echo " MACHINE = $(USER_MACHINE)"
155 @echo " BB_NUMBER_THREADS = $(BB_NUMBER_THREADS)"
156 @echo " PARALLEL_MAKE = $(PARALLEL_MAKE)"
158 @echo "Trouble finding a recipe? Try ./scripts/drepo grep 'search string'"
159 @echo "or ./scripts/drepo find -name \"*recipe*\"."
161 @if [ -z "$(GIT_USER_NAME)" -o -z "$(GIT_USER_EMAIL)" ]; then \
162 echo "Before doing any commits, please configure your name and email"; \
163 echo "address using the following commands:"; \
165 echo " $$ $(GIT) config user.name \"Your Name\""; \
166 echo " $$ $(GIT) config user.email \"mail@example.com\""; \
168 echo "Git has been configured for $(GIT_USER_NAME) <$(GIT_USER_EMAIL)>."; \
169 echo "Please submit patches to <enigma2-devel@lists.elitedvb.net>."; \
173 @echo "[*] Please run '$(MAKE) help' to display further information!"
176 @echo '[*] Deleting generated configuration files'
177 @$(RM) $(CONFFILES_AUTO) $(CONFFILES_MANUAL) $(CONFDEPS)
178 @$(MAKE) $(MFLAGS) -C doc clean
181 @echo '[*] Deleting dependencies directory'
183 @echo '[*] Deleting download directory'
185 @echo '[*] Deleting tmp directory'
187 @echo '[*] Deleting sstate directory'
188 @$(RM) -r $(SSTATE_DIR)
189 @echo '[*] Deleting persistent directory'
190 @$(RM) -r $(PERSISTENT_DIR)
191 @echo '[*] Deleting build directory'
192 @$(RM) -r $(BUILD_DIR)
193 @echo '[*] Deleting git submodules'
194 @$(GIT) submodule foreach 'rm -rf .* * 2>/dev/null || true'
196 # function to convert simple space separated list to csv
200 csv = $(subst $(space),$(comma),$(strip $1))
202 sstate-cache-clean: init
203 @echo '[*] Cleaning up sstate-cache'
204 @. $(CURDIR)/bitbake.env && sstate-cache-management.sh --cache-dir=$(SSTATE_DIR) --stamps-dir=$(call csv,$(wildcard $(CURDIR)/build/*/tmp*/stamps)) -v
207 @$(MAKE) $(MFLAGS) -C doc
209 dreambox-image enigma2 package-index: init
210 @echo '[*] Building $@ for $(USER_MACHINE)'
214 @echo '[*] Building $@ for $(USER_MACHINE)'
215 @$(BITBAKE) $(MAKE_IMAGE_BB)
218 @echo '[*] Downloading sources'
219 @$(BITBAKE) -cfetchall -k $(MAKE_IMAGE_BB)
222 @echo '[*] Updating Git repositories...'
223 @HASH=`$(XSUM) $(MAKEFILE_LIST)`; \
224 if [ -n "$(GIT_REMOTE)" ]; then \
225 $(GIT) pull --ff-only || $(GIT) pull --rebase; \
227 if [ "$$HASH" != "`$(XSUM) $(MAKEFILE_LIST)`" ]; then \
228 echo '[*] Makefile changed. Restarting...'; \
229 $(MAKE) $(MFLAGS) --no-print-directory $(MAKECMDGOALS); \
231 $(GIT) submodule sync && \
232 $(GIT) submodule update --init && \
233 echo "[*] The Dreambox SDK is now up-to-date."; \
236 .PHONY: all clean doc help image init update usage
238 MACHINE_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-$(MACHINE)-ext.conf
239 DISTRO_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-ext.conf
241 BITBAKE_ENV_HASH := $(call hash, \
242 'BITBAKE_ENV_VERSION = "0"' \
243 'CURDIR = "$(CURDIR)"' \
246 bitbake.env: $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH)
247 @echo '[*] Generating $@'
248 @echo '# Automatically generated file. Do not edit!' > $@
249 @echo 'export PATH=$(CURDIR)/openembedded-core/scripts:$(CURDIR)/bitbake/bin:$${PATH}' >> $@
251 OPENDREAMBOX_CONF_HASH := $(call hash, \
252 'OPENDREAMBOX_CONF_VERSION = "2"' \
253 'CURDIR = "$(CURDIR)"' \
254 'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' \
255 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' \
256 'DL_DIR = "$(DL_DIR)"' \
257 'PERSISTENT_DIR = "$(PERSISTENT_DIR)"' \
258 'SSTATE_DIR = "$(SSTATE_DIR)"' \
261 conf/opendreambox.conf: $(DEPDIR)/.opendreambox.conf.$(OPENDREAMBOX_CONF_HASH)
262 @echo '[*] Generating $@'
263 @test -d $(@D) || mkdir -p $(@D)
264 @echo '# Automatically generated file. Do not edit!' > $@
265 @echo 'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' >> $@
266 @echo 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' >> $@
267 @echo 'DL_DIR = "$(DL_DIR)"' >> $@
268 @echo 'PERSISTENT_DIR = "$(PERSISTENT_DIR)"' >> $@
269 @echo 'SSTATE_DIR = "$(SSTATE_DIR)"' >> $@
270 @echo 'BB_GENERATE_MIRROR_TARBALLS = "0"' >> $@
271 @echo 'BBINCLUDELOGS = "yes"' >> $@
272 @echo 'CONF_VERSION = "1"' >> $@
273 @echo 'DISTRO = "opendreambox"' >> $@
274 @echo 'EXTRA_IMAGE_FEATURES = "debug-tweaks"' >> $@
275 @echo 'USER_CLASSES = "buildstats"' >> $@
276 @echo 'PATCHRESOLVE = "noop"' >> $@
277 @echo 'PRSERV_HOST = "localhost:0"' >> $@
279 LOCAL_CONF_HASH := $(call hash, \
280 'LOCAL_CONF_VERSION = "0"' \
281 'CURDIR = "$(CURDIR)"' \
282 'TOPDIR = "$(TOPDIR)"' \
283 'MACHINE = "$(MACHINE)"' \
284 'TMPDIR = "$(TMPDIR)"' \
287 $(TOPDIR)/conf/local.conf: $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH)
288 @echo '[*] Generating $@'
289 @test -d $(@D) || mkdir -p $(@D)
290 @echo '# Automatically generated file. Do not edit!' > $@
291 @echo 'TOPDIR = "$(TOPDIR)"' >> $@
292 @echo 'MACHINE = "$(MACHINE)"' >> $@
293 @echo 'TMPDIR = "$(TMPDIR)"' >> $@
294 @echo 'require $(CURDIR)/conf/opendreambox.conf' >> $@
295 @echo 'include $(DISTRO_INCLUDE_CONF)' >> $@
296 @echo 'include $(MACHINE_INCLUDE_CONF)' >> $@
298 BBLAYERS_CONF_HASH := $(call hash, \
299 'BBLAYERS_CONF_VERSION = "0"' \
300 'CURDIR = "$(CURDIR)"' \
301 'BBLAYERS = "$(BBLAYERS)"' \
304 $(TOPDIR)/conf/bblayers.conf: $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH)
305 @echo '[*] Generating $@'
306 @test -d $(@D) || mkdir -p $(@D)
307 @echo '# Automatically generated file. Do not edit!' > $@
308 @echo 'LCONF_VERSION = "4"' >> $@
309 @echo 'BBFILES = ""' >> $@
310 @echo 'BBLAYERS = "$(BBLAYERS)"' >> $@
311 @echo 'include $(DISTRO_INCLUDE_CONF)' >> $@
312 @echo 'include $(MACHINE_INCLUDE_CONF)' >> $@
314 CROSS_COMPILE_ENV_BLACKLIST = \
315 HOME LOGNAME PWD SHELL SSH_AGENT_PID SSH_AUTH_SOCK TERM USER
317 CROSS_COMPILE_ENV_HASH := $(call hash, \
318 'CROSS_COMPILE_ENV_VERSION = "0"' \
319 'CURDIR = "$(CURDIR)"' \
320 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' \
321 'TMPDIR = "$(TMPDIR)"' \
322 'TOPDIR = "$(TOPDIR)"' \
323 'CROSS_COMPILE_ENV_BLACKLIST = "$(CROSS_COMPILE_ENV_BLACKLIST)"' \
326 .cross-compile-$(MACHINE).env: $(DEPDIR)/.cross-compile.env.$(MACHINE).$(CROSS_COMPILE_ENV_HASH) $(CONFFILES_BITBAKE)
327 @test -d $(TOPDIR) || (echo 'The directory "$(TOPDIR)" does not exist. Is "$(MACHINE)" a valid machine? Try running "make MACHINE=$(MACHINE)" first.' && exit 1)
328 @echo '[*] Generating $@'
329 @echo '# Automatically generated file. Do not edit!' > $@
330 @($(BITBAKE) -e | grep '^\(export\s\)\?[a-zA-Z0-9_]\+=".*"$$' | sed -e 's,^export\s,,' | grep -v $(foreach v,$(CROSS_COMPILE_ENV_BLACKLIST),-e ^$(v)=) | sed -e 's,^,local ,' | sort) >> $@ || ($(RM) $@ && exit 1)
333 @test -d $(@D) || mkdir -p $(@D)
334 @$(RM) $(basename $@).*