3 # Copyright (c) 2016 Dream Property GmbH, Germany
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 # dm520, dm820, dm900, dm7080
34 # This only sets the default value. All platforms now use a shared build
35 # directory. Run "MACHINE=dm820 bitbake dreambox-image" to build an image
36 # for the dm820, if it is not the default.
39 USER_MACHINE := $(MACHINE)
41 MAKE_IMAGE_BB ?= dreambox-image
43 # Adjust according to the number CPU cores to use for parallel build.
44 # Default: Number of processors in /proc/cpuinfo, if present, or 1.
45 NR_CPU := $(shell [ -f /proc/cpuinfo ] && grep -c '^processor\s*:' /proc/cpuinfo || echo 1)
46 BB_NUMBER_THREADS ?= $(NR_CPU)
47 PARALLEL_MAKE ?= -j $(NR_CPU)
52 BUILD_DIR = $(CURDIR)/build
53 TOPDIR = $(BUILD_DIR)/$(MACHINE)
54 DL_DIR = $(CURDIR)/sources
55 PERSISTENT_DIR = $(CURDIR)/persist-cache
56 SSTATE_DIR = $(CURDIR)/sstate-cache
57 TMPDIR = $(TOPDIR)/tmp
58 DEPDIR = $(CURDIR)/.deps
60 BITBAKE = . $(CURDIR)/bitbake.env && cd $(TOPDIR) && $(NICE) bitbake
63 $(CURDIR)/meta-dreambox \
64 $(CURDIR)/meta-opendreambox \
65 $(CURDIR)/meta-openembedded/meta-filesystems \
66 $(CURDIR)/meta-openembedded/meta-multimedia \
67 $(CURDIR)/meta-openembedded/meta-networking \
68 $(CURDIR)/meta-openembedded/meta-oe \
69 $(CURDIR)/meta-openembedded/meta-python \
70 $(CURDIR)/meta-openembedded/meta-ruby \
71 $(CURDIR)/meta-openembedded/meta-webserver \
73 $(CURDIR)/openembedded-core/meta
77 conf/opendreambox.conf \
79 $(TOPDIR)/bitbake.env \
80 $(TOPDIR)/conf/bblayers.conf \
81 $(TOPDIR)/conf/local.conf
84 .cross-compile-$(MACHINE).env
87 $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH) \
88 $(DEPDIR)/.opendreambox.conf.$(OPENDREAMBOX_CONF_HASH) \
89 $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH) \
90 $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH) \
91 $(DEPDIR)/.cross-compile.env.$(MACHINE).$(CROSS_COMPILE_ENV_HASH)
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_AUTHOR_NAME ?= $(shell $(GIT) config user.name)
105 GIT_AUTHOR_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=dm820 >> conf/make.conf"
131 @echo " [Valid values: dm520, dm820, dm900, dm7080]"
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=dm820"
138 @echo " [Valid values: dm520, dm820, dm900, dm7080]"
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_AUTHOR_NAME)" -o -z "$(GIT_AUTHOR_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_AUTHOR_NAME) <$(GIT_AUTHOR_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 # function to convert simple space separated list to csv
197 csv = $(subst $(space),$(comma),$(strip $1))
199 sstate-cache-clean: init
200 @echo '[*] Cleaning up sstate-cache'
201 @. $(CURDIR)/bitbake.env && sstate-cache-management.sh --cache-dir=$(SSTATE_DIR) --stamps-dir=$(call csv,$(wildcard $(CURDIR)/build/*/tmp*/stamps)) -v
204 @$(MAKE) $(MFLAGS) -C doc
206 dreambox-image enigma2 package-index: init
207 @echo '[*] Building $@ for $(USER_MACHINE)'
211 @echo '[*] Building $@ for $(USER_MACHINE)'
212 @$(BITBAKE) $(MAKE_IMAGE_BB)
215 @echo '[*] Building $@ for $(USER_MACHINE)'
216 @$(BITBAKE) dreambox-$@
219 @echo '[*] Building $@ for $(USER_MACHINE)'
220 @$(BITBAKE) linux-dreambox
223 @echo '[*] Downloading sources'
224 @$(BITBAKE) -cfetchall -k $(MAKE_IMAGE_BB)
227 @echo '[*] Updating Git repositories...'
228 @HASH=`$(XSUM) $(MAKEFILE_LIST)`; \
229 if [ -n "$(GIT_REMOTE)" ]; then \
230 $(GIT) pull --ff-only || $(GIT) pull --rebase || exit 1; \
232 if [ "$$HASH" != "`$(XSUM) $(MAKEFILE_LIST)`" ]; then \
233 echo '[*] Makefile changed. Restarting...'; \
234 $(MAKE) $(MFLAGS) --no-print-directory $(MAKECMDGOALS); \
236 $(GIT) submodule sync && \
237 $(GIT) submodule update --init && \
238 echo "[*] The Dreambox SDK is now up-to-date."; \
241 .PHONY: all clean doc help image init update usage
243 MACHINE_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-$(MACHINE)-ext.conf
244 DISTRO_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-ext.conf
246 BB_ENV_EXTRAWHITE = MACHINE DISTRO TCMODE TCLIBC HTTP_PROXY http_proxy \
247 HTTPS_PROXY https_proxy FTP_PROXY ftp_proxy FTPS_PROXY ftps_proxy ALL_PROXY \
248 all_proxy NO_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY \
249 SDKMACHINE BB_NUMBER_THREADS BB_NO_NETWORK PARALLEL_MAKE GIT_PROXY_COMMAND \
250 SOCKS5_PASSWD SOCKS5_USER SCREENDIR STAMPS_DIR BBPATH_EXTRA BB_SETSCENE_ENFORCE
252 BITBAKE_ENV_HASH := $(call hash, \
253 'BITBAKE_ENV_VERSION = "0"' \
254 'BB_ENV_EXTRAWHITE = "$(BB_ENV_EXTRAWHITE)"' \
255 'CURDIR = "$(CURDIR)"' \
258 bitbake.env: $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH)
259 @echo '[*] Generating $@'
260 @echo '# Automatically generated file. Do not edit!' > $@
261 @echo 'export BB_ENV_EXTRAWHITE="$(BB_ENV_EXTRAWHITE)"' >> $@
262 @echo 'export PATH="$(CURDIR)/openembedded-core/scripts:$(CURDIR)/bitbake/bin:$${PATH}"' >> $@
264 OPENDREAMBOX_CONF_HASH := $(call hash, \
265 'OPENDREAMBOX_CONF_VERSION = "2"' \
266 'CURDIR = "$(CURDIR)"' \
267 'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' \
268 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' \
269 'DL_DIR = "$(DL_DIR)"' \
270 'PERSISTENT_DIR = "$(PERSISTENT_DIR)"' \
271 'SSTATE_DIR = "$(SSTATE_DIR)"' \
274 conf/opendreambox.conf: $(DEPDIR)/.opendreambox.conf.$(OPENDREAMBOX_CONF_HASH)
275 @echo '[*] Generating $@'
276 @test -d $(@D) || mkdir -p $(@D)
277 @echo '# Automatically generated file. Do not edit!' > $@
278 @echo 'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' >> $@
279 @echo 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' >> $@
280 @echo 'DL_DIR = "$(DL_DIR)"' >> $@
281 @echo 'PERSISTENT_DIR = "$(PERSISTENT_DIR)"' >> $@
282 @echo 'SSTATE_DIR = "$(SSTATE_DIR)"' >> $@
283 @echo 'BB_GENERATE_MIRROR_TARBALLS = "0"' >> $@
284 @echo 'BBINCLUDELOGS = "yes"' >> $@
285 @echo 'CONF_VERSION = "1"' >> $@
286 @echo 'DISTRO = "opendreambox"' >> $@
287 @echo 'PATCHRESOLVE = "noop"' >> $@
288 @echo 'PRSERV_HOST = "localhost:0"' >> $@
290 LOCAL_CONF_HASH := $(call hash, \
291 'LOCAL_CONF_VERSION = "0"' \
292 'CURDIR = "$(CURDIR)"' \
293 'TOPDIR = "$(TOPDIR)"' \
294 'MACHINE = "$(MACHINE)"' \
295 'TMPDIR = "$(TMPDIR)"' \
296 'DISTRO_INCLUDE_CONF = "$(DISTRO_INCLUDE_CONF)"' \
297 'MACHINE_INCLUDE_CONF = "$(MACHINE_INCLUDE_CONF)"' \
300 $(TOPDIR)/conf/local.conf: $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH)
301 @echo '[*] Generating $@'
302 @test -d $(@D) || mkdir -p $(@D)
303 @echo '# Automatically generated file. Do not edit!' > $@
304 @echo 'TOPDIR = "$(TOPDIR)"' >> $@
305 @echo 'MACHINE = "$(MACHINE)"' >> $@
306 @echo 'TMPDIR = "$(TMPDIR)"' >> $@
307 @echo 'require $(CURDIR)/conf/opendreambox.conf' >> $@
308 @echo 'include $(DISTRO_INCLUDE_CONF)' >> $@
309 @echo 'include $(MACHINE_INCLUDE_CONF)' >> $@
311 BBLAYERS_CONF_HASH := $(call hash, \
312 'BBLAYERS_CONF_VERSION = "0"' \
313 'CURDIR = "$(CURDIR)"' \
314 'LCONF_VERSION = "$(LCONF_VERSION)"' \
315 'BBFILES = "$(BBFILES)"' \
316 'BBLAYERS = "$(BBLAYERS)"' \
317 'DISTRO_INCLUDE_CONF = "$(DISTRO_INCLUDE_CONF)"' \
318 'MACHINE_INCLUDE_CONF = "$(MACHINE_INCLUDE_CONF)"' \
321 $(TOPDIR)/conf/bblayers.conf: $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH)
322 @echo '[*] Generating $@'
323 @test -d $(@D) || mkdir -p $(@D)
324 @echo '# Automatically generated file. Do not edit!' > $@
325 @echo 'LCONF_VERSION = "4"' >> $@
326 @echo 'BBFILES = ""' >> $@
327 @echo 'BBLAYERS = "$(BBLAYERS)"' >> $@
328 @echo 'include $(DISTRO_INCLUDE_CONF)' >> $@
329 @echo 'include $(MACHINE_INCLUDE_CONF)' >> $@
332 @echo '[*] Generating $@'
333 @test -d $(@D) || mkdir -p $(@D)
334 @printf '%%::\n\tMACHINE=$(MACHINE) $$(MAKE) -C ../.. $$(MAKECMDGOALS)\n' > $@
336 $(TOPDIR)/bitbake.env:
337 @echo '[*] Generating $@'
338 @test -d $(@D) || mkdir -p $(@D)
339 @echo '. ../../bitbake.env' > $@
341 CROSS_COMPILE_ENV_BLACKLIST = \
342 HOME LOGNAME PWD SHELL SSH_AGENT_PID SSH_AUTH_SOCK TERM USER
344 CROSS_COMPILE_ENV_HASH := $(call hash, \
345 'CROSS_COMPILE_ENV_VERSION = "0"' \
346 'CURDIR = "$(CURDIR)"' \
347 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' \
348 'TMPDIR = "$(TMPDIR)"' \
349 'TOPDIR = "$(TOPDIR)"' \
350 'CROSS_COMPILE_ENV_BLACKLIST = "$(CROSS_COMPILE_ENV_BLACKLIST)"' \
353 .cross-compile-$(MACHINE).env: $(DEPDIR)/.cross-compile.env.$(MACHINE).$(CROSS_COMPILE_ENV_HASH) $(CONFFILES_BITBAKE)
354 @test -d $(TOPDIR) || (echo 'The directory "$(TOPDIR)" does not exist. Is "$(MACHINE)" a valid machine? Try running "make MACHINE=$(MACHINE)" first.' && exit 1)
355 @echo '[*] Generating $@'
356 @($(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) > $@.tmp && [ -s $@.tmp ] && mv $@.tmp $@ || ($(RM) $@.tmp && echo 'Failed! Please verify that no instance of bitbake is currently running for this machine.' && exit 1)
359 @test -d $(@D) || mkdir -p $(@D)
360 @$(RM) $(basename $@).*