3 # Copyright (c) 2010-2012 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 # dm800, 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 \
70 $(CURDIR)/meta-openembedded/meta-oe \
71 $(CURDIR)/meta-openembedded/meta-multimedia \
72 $(CURDIR)/meta-openembedded/meta-networking \
73 $(CURDIR)/openembedded-core/meta
77 conf/opendreambox.conf \
78 $(TOPDIR)/conf/bblayers.conf \
79 $(TOPDIR)/conf/local.conf
82 .cross-compile-$(MACHINE).env
85 $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH) \
86 $(DEPDIR)/.opendreambox.conf.$(OPENDREAMBOX_CONF_HASH) \
87 $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH) \
88 $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH) \
89 $(DEPDIR)/.cross-compile.env.$(MACHINE).$(CROSS_COMPILE_ENV_HASH)
92 $(TOPDIR)/conf/bblayers.conf \
93 $(TOPDIR)/conf/local.conf \
94 conf/opendreambox.conf \
95 openembedded-core/meta/conf/bitbake.conf \
97 conf/bblayers-ext.conf \
98 conf/bblayers-$(MACHINE)-ext.conf \
100 conf/local-$(MACHINE)-ext.conf)
103 GIT_REMOTE := $(shell $(GIT) remote)
104 GIT_USER_NAME := $(shell $(GIT) config user.name)
105 GIT_USER_EMAIL := $(shell $(GIT) config user.email)
107 hash = $(shell echo $(1) | $(XSUM) | awk '{print $$1}')
113 [ -d $@ ] || $(MAKE) $(MFLAGS) update
115 init: $(BBLAYERS) $(CONFFILES_AUTO)
118 @echo "Your options:"
120 @echo " * Update the SDK"
121 @echo " $$ $(MAKE) update"
123 @echo " * Build the PDF documentation (doc/opendreambox.pdf, requires pdfTeX):"
124 @echo " $$ $(MAKE) doc"
126 @echo " * View the documentation in text format:"
127 @echo " $$ view doc/opendreambox.txt"
129 @echo " * Select a new target machine:"
130 @echo " $$ echo MACHINE=dm800se >> conf/make.conf"
131 @echo " [Valid values: dm800, dm8000, dm500hd, dm800se, dm7020hd, dm7020hdv2, dm800sev2, dm500hdv2]"
133 @echo " * Build a firmware image for the selected target machine:"
134 @echo " $$ $(MAKE) image"
136 @echo " * Build a firmware image for a different target machine:"
137 @echo " $$ $(MAKE) image MACHINE=dm800se"
138 @echo " [Valid values: dm800, dm8000, dm500hd, dm800se, dm7020hd, dm7020hdv2, dm800sev2, dm500hdv2]"
140 @echo " * Download all source files at once:"
141 @echo " $$ $(MAKE) download"
143 @echo " * Set up the environment to build recipes manually:"
144 @echo " $$ source bitbake.env"
145 @echo " $$ cd build/$(MACHINE)"
146 @echo " $$ bitbake <target>"
147 @echo " [Replace <target> with a recipe name, e.g. $(MAKE_IMAGE_BB) or enigma2]"
149 @echo "Your current settings:"
150 @echo " MACHINE = $(USER_MACHINE)"
152 @echo " BB_NUMBER_THREADS = $(BB_NUMBER_THREADS)"
153 @echo " PARALLEL_MAKE = $(PARALLEL_MAKE)"
155 @echo "Trouble finding a recipe? Try ./scripts/drepo grep 'search string'"
156 @echo "or ./scripts/drepo find -name \"*recipe*\"."
158 @if [ -z "$(GIT_USER_NAME)" -o -z "$(GIT_USER_EMAIL)" ]; then \
159 echo "Before doing any commits, please configure your name and email"; \
160 echo "address using the following commands:"; \
162 echo " $$ $(GIT) config user.name \"Your Name\""; \
163 echo " $$ $(GIT) config user.email \"mail@example.com\""; \
165 echo "Git has been configured for $(GIT_USER_NAME) <$(GIT_USER_EMAIL)>."; \
166 echo "Please submit patches to <enigma2-devel@lists.elitedvb.net>."; \
170 @echo "[*] Please run '$(MAKE) help' to display further information!"
173 @echo '[*] Deleting generated configuration files'
174 @$(RM) $(CONFFILES_AUTO) $(CONFFILES_MANUAL) $(CONFDEPS)
175 @$(MAKE) $(MFLAGS) -C doc clean
178 @echo '[*] Deleting dependencies directory'
180 @echo '[*] Deleting download directory'
182 @echo '[*] Deleting tmp directory'
184 @echo '[*] Deleting sstate directory'
185 @$(RM) -r $(SSTATE_DIR)
186 @echo '[*] Deleting persistent directory'
187 @$(RM) -r $(PERSISTENT_DIR)
188 @echo '[*] Deleting build directory'
189 @$(RM) -r $(BUILD_DIR)
190 @echo '[*] Deleting git submodules'
191 @$(GIT) submodule foreach 'rm -rf .* * 2>/dev/null || true'
193 sstate-cache-clean: init
194 @echo '[*] Cleaning up sstate-cache'
195 @. $(CURDIR)/bitbake.env && sstate-cache-management.sh --cache-dir=$(SSTATE_DIR) --stamps-dir=$(TMPDIR)/stamps -v || true
198 @$(MAKE) $(MFLAGS) -C doc
201 @echo '[*] Building image for $(USER_MACHINE)'
202 @$(BITBAKE) $(MAKE_IMAGE_BB)
205 @echo '[*] Downloading sources'
206 @$(BITBAKE) -cfetchall -k $(MAKE_IMAGE_BB)
209 @echo '[*] Updating Git repositories...'
210 @HASH=`$(XSUM) $(MAKEFILE_LIST)`; \
211 if [ -n "$(GIT_REMOTE)" ]; then \
212 $(GIT) pull --ff-only || $(GIT) pull --rebase; \
214 if [ "$$HASH" != "`$(XSUM) $(MAKEFILE_LIST)`" ]; then \
215 echo '[*] Makefile changed. Restarting...'; \
216 $(MAKE) $(MFLAGS) --no-print-directory $(MAKECMDGOALS); \
218 $(GIT) submodule sync && \
219 $(GIT) submodule update --init && \
220 echo "[*] The Dreambox SDK is now up-to-date."; \
223 .PHONY: all clean doc help image init update usage
225 MACHINE_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-$(MACHINE)-ext.conf
226 DISTRO_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-ext.conf
228 BITBAKE_ENV_HASH := $(call hash, \
229 'BITBAKE_ENV_VERSION = "0"' \
230 'CURDIR = "$(CURDIR)"' \
233 bitbake.env: $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH)
234 @echo '[*] Generating $@'
235 @echo '# Automatically generated file. Do not edit!' > $@
236 @echo 'export PATH=$(CURDIR)/openembedded-core/scripts:$(CURDIR)/bitbake/bin:$${PATH}' >> $@
238 OPENDREAMBOX_CONF_HASH := $(call hash, \
239 'OPENDREAMBOX_CONF_VERSION = "2"' \
240 'CURDIR = "$(CURDIR)"' \
241 'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' \
242 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' \
243 'DL_DIR = "$(DL_DIR)"' \
244 'PERSISTENT_DIR = "$(PERSISTENT_DIR)"' \
245 'SSTATE_DIR = "$(SSTATE_DIR)"' \
248 conf/opendreambox.conf: $(DEPDIR)/.opendreambox.conf.$(OPENDREAMBOX_CONF_HASH)
249 @echo '[*] Generating $@'
250 @test -d $(@D) || mkdir -p $(@D)
251 @echo '# Automatically generated file. Do not edit!' > $@
252 @echo 'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' >> $@
253 @echo 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' >> $@
254 @echo 'DL_DIR = "$(DL_DIR)"' >> $@
255 @echo 'PERSISTENT_DIR = "$(PERSISTENT_DIR)"' >> $@
256 @echo 'SSTATE_DIR = "$(SSTATE_DIR)"' >> $@
257 @echo 'BB_GENERATE_MIRROR_TARBALLS = "0"' >> $@
258 @echo 'BBINCLUDELOGS = "yes"' >> $@
259 @echo 'CONF_VERSION = "1"' >> $@
260 @echo 'DISTRO = "opendreambox"' >> $@
261 @echo 'EXTRA_IMAGE_FEATURES = "debug-tweaks"' >> $@
262 @echo 'USER_CLASSES = "buildstats"' >> $@
263 @echo 'PATCHRESOLVE = "noop"' >> $@
264 @echo 'PRSERV_HOST = "localhost:0"' >> $@
266 LOCAL_CONF_HASH := $(call hash, \
267 'LOCAL_CONF_VERSION = "0"' \
268 'CURDIR = "$(CURDIR)"' \
269 'TOPDIR = "$(TOPDIR)"' \
270 'MACHINE = "$(MACHINE)"' \
271 'TMPDIR = "$(TMPDIR)"' \
274 $(TOPDIR)/conf/local.conf: $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH)
275 @echo '[*] Generating $@'
276 @test -d $(@D) || mkdir -p $(@D)
277 @echo '# Automatically generated file. Do not edit!' > $@
278 @echo 'TOPDIR = "$(TOPDIR)"' >> $@
279 @echo 'MACHINE = "$(MACHINE)"' >> $@
280 @echo 'TMPDIR = "$(TMPDIR)"' >> $@
281 @echo 'require $(CURDIR)/conf/opendreambox.conf' >> $@
282 @echo 'include $(DISTRO_INCLUDE_CONF)' >> $@
283 @echo 'include $(MACHINE_INCLUDE_CONF)' >> $@
285 BBLAYERS_CONF_HASH := $(call hash, \
286 'BBLAYERS_CONF_VERSION = "0"' \
287 'CURDIR = "$(CURDIR)"' \
288 'BBLAYERS = "$(BBLAYERS)"' \
291 $(TOPDIR)/conf/bblayers.conf: $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH)
292 @echo '[*] Generating $@'
293 @test -d $(@D) || mkdir -p $(@D)
294 @echo '# Automatically generated file. Do not edit!' > $@
295 @echo 'LCONF_VERSION = "4"' >> $@
296 @echo 'BBFILES = ""' >> $@
297 @echo 'BBLAYERS = "$(BBLAYERS)"' >> $@
298 @echo 'include $(DISTRO_INCLUDE_CONF)' >> $@
299 @echo 'include $(MACHINE_INCLUDE_CONF)' >> $@
301 CROSS_COMPILE_ENV_BLACKLIST = \
302 HOME LOGNAME PWD SHELL SSH_AGENT_PID SSH_AUTH_SOCK TERM USER
304 CROSS_COMPILE_ENV_HASH := $(call hash, \
305 'CROSS_COMPILE_ENV_VERSION = "0"' \
306 'CURDIR = "$(CURDIR)"' \
307 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' \
308 'TMPDIR = "$(TMPDIR)"' \
309 'TOPDIR = "$(TOPDIR)"' \
310 'CROSS_COMPILE_ENV_BLACKLIST = "$(CROSS_COMPILE_ENV_BLACKLIST)"' \
313 .cross-compile-$(MACHINE).env: $(DEPDIR)/.cross-compile.env.$(MACHINE).$(CROSS_COMPILE_ENV_HASH) $(CONFFILES_BITBAKE)
314 @test -d $(TOPDIR) || (echo 'The directory "$(TOPDIR)" does not exist. Is "$(MACHINE)" a valid machine? Try running "make MACHINE=$(MACHINE)" first.' && exit 1)
315 @echo '[*] Generating $@'
316 @echo '# Automatically generated file. Do not edit!' > $@
317 @($(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)
320 @test -d $(@D) || mkdir -p $(@D)
321 @$(RM) $(basename $@).*