3 # Copyright (c) 2010-2014 Dream Property 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 # dm500hd, dm500hdv2, dm800se, dm800sev2, dm7020hd, dm7020hdv2, dm7080, dm8000
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-initramfs \
74 $(CURDIR)/meta-openembedded/meta-multimedia \
75 $(CURDIR)/meta-openembedded/meta-networking \
76 $(CURDIR)/meta-openembedded/meta-ruby \
77 $(CURDIR)/openembedded-core/meta
81 conf/opendreambox.conf \
82 $(TOPDIR)/conf/bblayers.conf \
83 $(TOPDIR)/conf/local.conf
86 .cross-compile-$(MACHINE).env
89 $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH) \
90 $(DEPDIR)/.opendreambox.conf.$(OPENDREAMBOX_CONF_HASH) \
91 $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH) \
92 $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH) \
93 $(DEPDIR)/.cross-compile.env.$(MACHINE).$(CROSS_COMPILE_ENV_HASH)
96 conf/opendreambox.conf \
97 openembedded-core/meta/conf/bitbake.conf \
99 conf/bblayers-ext.conf \
100 conf/bblayers-$(MACHINE)-ext.conf \
101 conf/local-ext.conf \
102 conf/local-$(MACHINE)-ext.conf)
105 GIT_REMOTE := $(shell $(GIT) remote)
106 GIT_USER_NAME := $(shell $(GIT) config user.name)
107 GIT_USER_EMAIL := $(shell $(GIT) config user.email)
109 hash = $(shell echo $(1) | $(XSUM) | awk '{print $$1}')
115 [ -d $@ ] || $(MAKE) $(MFLAGS) update
117 init: $(BBLAYERS) $(CONFFILES_AUTO)
120 @echo "Your options:"
122 @echo " * Update the SDK"
123 @echo " $$ $(MAKE) update"
125 @echo " * Build the PDF documentation (doc/opendreambox.pdf, requires pdfTeX):"
126 @echo " $$ $(MAKE) doc"
128 @echo " * View the documentation in text format:"
129 @echo " $$ view doc/opendreambox.txt"
131 @echo " * Select a new target machine:"
132 @echo " $$ echo MACHINE=dm800sev2 >> conf/make.conf"
133 @echo " [Valid values: dm500hd, dm500hdv2, dm800se, dm800sev2, dm7020hd, dm7020hdv2, dm7080, dm8000]"
135 @echo " * Build a firmware image for the selected target machine:"
136 @echo " $$ $(MAKE) image"
138 @echo " * Build a firmware image for a different target machine:"
139 @echo " $$ $(MAKE) image MACHINE=dm800sev2"
140 @echo " [Valid values: dm500hd, dm500hdv2, dm800se, dm800sev2, dm7020hd, dm7020hdv2, dm7080, dm8000]"
142 @echo " * Download all source files at once:"
143 @echo " $$ $(MAKE) download"
145 @echo " * Set up the environment to build recipes manually:"
146 @echo " $$ source bitbake.env"
147 @echo " $$ cd build/$(MACHINE)"
148 @echo " $$ bitbake <target>"
149 @echo " [Replace <target> with a recipe name, e.g. $(MAKE_IMAGE_BB) or enigma2]"
151 @echo "Your current settings:"
152 @echo " MACHINE = $(USER_MACHINE)"
154 @echo " BB_NUMBER_THREADS = $(BB_NUMBER_THREADS)"
155 @echo " PARALLEL_MAKE = $(PARALLEL_MAKE)"
157 @echo "Trouble finding a recipe? Try ./scripts/drepo grep 'search string'"
158 @echo "or ./scripts/drepo find -name \"*recipe*\"."
160 @if [ -z "$(GIT_USER_NAME)" -o -z "$(GIT_USER_EMAIL)" ]; then \
161 echo "Before doing any commits, please configure your name and email"; \
162 echo "address using the following commands:"; \
164 echo " $$ $(GIT) config user.name \"Your Name\""; \
165 echo " $$ $(GIT) config user.email \"mail@example.com\""; \
167 echo "Git has been configured for $(GIT_USER_NAME) <$(GIT_USER_EMAIL)>."; \
168 echo "Please submit patches to <enigma2-devel@lists.elitedvb.net>."; \
172 @echo "[*] Please run '$(MAKE) help' to display further information!"
175 @echo '[*] Deleting generated configuration files'
176 @$(RM) $(CONFFILES_AUTO) $(CONFFILES_MANUAL) $(CONFDEPS)
177 @$(MAKE) $(MFLAGS) -C doc clean
180 @echo '[*] Deleting dependencies directory'
182 @echo '[*] Deleting download directory'
184 @echo '[*] Deleting tmp directory'
186 @echo '[*] Deleting sstate directory'
187 @$(RM) -r $(SSTATE_DIR)
188 @echo '[*] Deleting persistent directory'
189 @$(RM) -r $(PERSISTENT_DIR)
190 @echo '[*] Deleting build directory'
191 @$(RM) -r $(BUILD_DIR)
192 @echo '[*] Deleting git submodules'
193 @$(GIT) submodule foreach 'rm -rf .* * 2>/dev/null || true'
195 # function to convert simple space separated list to csv
199 csv = $(subst $(space),$(comma),$(strip $1))
201 sstate-cache-clean: init
202 @echo '[*] Cleaning up sstate-cache'
203 @. $(CURDIR)/bitbake.env && sstate-cache-management.sh --cache-dir=$(SSTATE_DIR) --stamps-dir=$(call csv,$(wildcard $(CURDIR)/build/*/tmp*/stamps)) -v
206 @$(MAKE) $(MFLAGS) -C doc
208 dreambox-image enigma2 package-index: init
209 @echo '[*] Building $@ for $(USER_MACHINE)'
213 @echo '[*] Building $@ for $(USER_MACHINE)'
214 @$(BITBAKE) $(MAKE_IMAGE_BB)
217 @echo '[*] Downloading sources'
218 @$(BITBAKE) -cfetchall -k $(MAKE_IMAGE_BB)
221 @echo '[*] Updating Git repositories...'
222 @HASH=`$(XSUM) $(MAKEFILE_LIST)`; \
223 if [ -n "$(GIT_REMOTE)" ]; then \
224 $(GIT) pull --ff-only || $(GIT) pull --rebase; \
226 if [ "$$HASH" != "`$(XSUM) $(MAKEFILE_LIST)`" ]; then \
227 echo '[*] Makefile changed. Restarting...'; \
228 $(MAKE) $(MFLAGS) --no-print-directory $(MAKECMDGOALS); \
230 $(GIT) submodule sync && \
231 $(GIT) submodule update --init && \
232 echo "[*] The Dreambox SDK is now up-to-date."; \
235 .PHONY: all clean doc help image init update usage
237 MACHINE_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-$(MACHINE)-ext.conf
238 DISTRO_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-ext.conf
240 BITBAKE_ENV_HASH := $(call hash, \
241 'BITBAKE_ENV_VERSION = "0"' \
242 'CURDIR = "$(CURDIR)"' \
245 bitbake.env: $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH)
246 @echo '[*] Generating $@'
247 @echo '# Automatically generated file. Do not edit!' > $@
248 @echo 'export PATH=$(CURDIR)/openembedded-core/scripts:$(CURDIR)/bitbake/bin:$${PATH}' >> $@
250 OPENDREAMBOX_CONF_HASH := $(call hash, \
251 'OPENDREAMBOX_CONF_VERSION = "2"' \
252 'CURDIR = "$(CURDIR)"' \
253 'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' \
254 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' \
255 'DL_DIR = "$(DL_DIR)"' \
256 'PERSISTENT_DIR = "$(PERSISTENT_DIR)"' \
257 'SSTATE_DIR = "$(SSTATE_DIR)"' \
260 conf/opendreambox.conf: $(DEPDIR)/.opendreambox.conf.$(OPENDREAMBOX_CONF_HASH)
261 @echo '[*] Generating $@'
262 @test -d $(@D) || mkdir -p $(@D)
263 @echo '# Automatically generated file. Do not edit!' > $@
264 @echo 'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' >> $@
265 @echo 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' >> $@
266 @echo 'DL_DIR = "$(DL_DIR)"' >> $@
267 @echo 'PERSISTENT_DIR = "$(PERSISTENT_DIR)"' >> $@
268 @echo 'SSTATE_DIR = "$(SSTATE_DIR)"' >> $@
269 @echo 'BB_GENERATE_MIRROR_TARBALLS = "0"' >> $@
270 @echo 'BBINCLUDELOGS = "yes"' >> $@
271 @echo 'CONF_VERSION = "1"' >> $@
272 @echo 'DISTRO = "opendreambox"' >> $@
273 @echo 'EXTRA_IMAGE_FEATURES = "debug-tweaks"' >> $@
274 @echo 'USER_CLASSES = "buildstats"' >> $@
275 @echo 'PATCHRESOLVE = "noop"' >> $@
276 @echo 'PRSERV_HOST = "localhost:0"' >> $@
278 LOCAL_CONF_HASH := $(call hash, \
279 'LOCAL_CONF_VERSION = "0"' \
280 'CURDIR = "$(CURDIR)"' \
281 'TOPDIR = "$(TOPDIR)"' \
282 'MACHINE = "$(MACHINE)"' \
283 'TMPDIR = "$(TMPDIR)"' \
286 $(TOPDIR)/conf/local.conf: $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH)
287 @echo '[*] Generating $@'
288 @test -d $(@D) || mkdir -p $(@D)
289 @echo '# Automatically generated file. Do not edit!' > $@
290 @echo 'TOPDIR = "$(TOPDIR)"' >> $@
291 @echo 'MACHINE = "$(MACHINE)"' >> $@
292 @echo 'TMPDIR = "$(TMPDIR)"' >> $@
293 @echo 'require $(CURDIR)/conf/opendreambox.conf' >> $@
294 @echo 'include $(DISTRO_INCLUDE_CONF)' >> $@
295 @echo 'include $(MACHINE_INCLUDE_CONF)' >> $@
297 BBLAYERS_CONF_HASH := $(call hash, \
298 'BBLAYERS_CONF_VERSION = "0"' \
299 'CURDIR = "$(CURDIR)"' \
300 'BBLAYERS = "$(BBLAYERS)"' \
303 $(TOPDIR)/conf/bblayers.conf: $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH)
304 @echo '[*] Generating $@'
305 @test -d $(@D) || mkdir -p $(@D)
306 @echo '# Automatically generated file. Do not edit!' > $@
307 @echo 'LCONF_VERSION = "4"' >> $@
308 @echo 'BBFILES = ""' >> $@
309 @echo 'BBLAYERS = "$(BBLAYERS)"' >> $@
310 @echo 'include $(DISTRO_INCLUDE_CONF)' >> $@
311 @echo 'include $(MACHINE_INCLUDE_CONF)' >> $@
313 CROSS_COMPILE_ENV_BLACKLIST = \
314 HOME LOGNAME PWD SHELL SSH_AGENT_PID SSH_AUTH_SOCK TERM USER
316 CROSS_COMPILE_ENV_HASH := $(call hash, \
317 'CROSS_COMPILE_ENV_VERSION = "0"' \
318 'CURDIR = "$(CURDIR)"' \
319 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' \
320 'TMPDIR = "$(TMPDIR)"' \
321 'TOPDIR = "$(TOPDIR)"' \
322 'CROSS_COMPILE_ENV_BLACKLIST = "$(CROSS_COMPILE_ENV_BLACKLIST)"' \
325 .cross-compile-$(MACHINE).env: $(DEPDIR)/.cross-compile.env.$(MACHINE).$(CROSS_COMPILE_ENV_HASH) $(CONFFILES_BITBAKE)
326 @test -d $(TOPDIR) || (echo 'The directory "$(TOPDIR)" does not exist. Is "$(MACHINE)" a valid machine? Try running "make MACHINE=$(MACHINE)" first.' && exit 1)
327 @echo '[*] Generating $@'
328 @echo '# Automatically generated file. Do not edit!' > $@
329 @($(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)
332 @test -d $(@D) || mkdir -p $(@D)
333 @$(RM) $(basename $@).*