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, dm920, 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-games \
65 $(CURDIR)/meta-golang \
66 $(CURDIR)/meta-opendreambox \
67 $(CURDIR)/meta-openembedded/meta-filesystems \
68 $(CURDIR)/meta-openembedded/meta-multimedia \
69 $(CURDIR)/meta-openembedded/meta-networking \
70 $(CURDIR)/meta-openembedded/meta-oe \
71 $(CURDIR)/meta-openembedded/meta-python \
72 $(CURDIR)/meta-openembedded/meta-ruby \
73 $(CURDIR)/meta-openembedded/meta-webserver \
75 $(CURDIR)/openembedded-core/meta
79 conf/opendreambox.conf \
81 $(TOPDIR)/bitbake.env \
82 $(TOPDIR)/conf/bblayers.conf \
83 $(TOPDIR)/conf/local.conf
86 .cross-compile-$(MACHINE).env
89 $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH) \
90 $(DEPDIR)/.bitbake.env.$(MACHINE).$(MAKEFILE_HASH) \
91 $(DEPDIR)/.opendreambox.conf.$(OPENDREAMBOX_CONF_HASH) \
92 $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH) \
93 $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH) \
94 $(DEPDIR)/.Makefile.$(MACHINE).$(MAKEFILE_HASH) \
95 $(DEPDIR)/.cross-compile.env.$(MACHINE).$(CROSS_COMPILE_ENV_HASH)
98 conf/opendreambox.conf \
99 openembedded-core/meta/conf/bitbake.conf \
101 conf/bblayers-ext.conf \
102 conf/bblayers-$(MACHINE)-ext.conf \
103 conf/local-ext.conf \
104 conf/local-$(MACHINE)-ext.conf)
107 GIT_REMOTE := $(shell $(GIT) remote)
108 GIT_AUTHOR_NAME ?= $(shell $(GIT) config user.name)
109 GIT_AUTHOR_EMAIL ?= $(shell $(GIT) config user.email)
111 hash = $(shell echo $(1) | $(XSUM) | awk '{print $$1}')
117 [ -d $@ ] || $(MAKE) $(MFLAGS) update
120 @[ `(gcc -dumpversion 2>/dev/null || echo 7) | sed -e 's/\..*//'` -lt 7 ] || (echo "GCC < 7 is required to build this version of opendreambox." && exit 1)
122 init: gcccheck $(BBLAYERS) $(CONFFILES_AUTO)
125 @echo "Your options:"
127 @echo " * Update the SDK"
128 @echo " $$ $(MAKE) update"
130 @echo " * Build the PDF documentation (doc/opendreambox.pdf, requires pdfTeX):"
131 @echo " $$ $(MAKE) doc"
133 @echo " * View the documentation in text format:"
134 @echo " $$ view doc/opendreambox.txt"
136 @echo " * Select a new target machine:"
137 @echo " $$ echo MACHINE=dm820 >> conf/make.conf"
138 @echo " [Valid values: dm520, dm820, dm900, dm920, dm7080]"
140 @echo " * Build a firmware image for the selected target machine:"
141 @echo " $$ $(MAKE) image"
143 @echo " * Build a firmware image for a different target machine:"
144 @echo " $$ $(MAKE) image MACHINE=dm820"
145 @echo " [Valid values: dm520, dm820, dm900, dm920, dm7080]"
147 @echo " * Download all source files at once:"
148 @echo " $$ $(MAKE) download"
150 @echo " * Set up the environment to build recipes manually:"
151 @echo " $$ source bitbake.env"
152 @echo " $$ cd build/$(MACHINE)"
153 @echo " $$ bitbake <target>"
154 @echo " [Replace <target> with a recipe name, e.g. $(MAKE_IMAGE_BB) or enigma2]"
156 @echo "Your current settings:"
157 @echo " MACHINE = $(USER_MACHINE)"
159 @echo " BB_NUMBER_THREADS = $(BB_NUMBER_THREADS)"
160 @echo " PARALLEL_MAKE = $(PARALLEL_MAKE)"
162 @echo "Trouble finding a recipe? Try ./scripts/drepo grep 'search string'"
163 @echo "or ./scripts/drepo find -name \"*recipe*\"."
165 @if [ -z "$(GIT_AUTHOR_NAME)" -o -z "$(GIT_AUTHOR_EMAIL)" ]; then \
166 echo "Before doing any commits, please configure your name and email"; \
167 echo "address using the following commands:"; \
169 echo " $$ $(GIT) config user.name \"Your Name\""; \
170 echo " $$ $(GIT) config user.email \"mail@example.com\""; \
172 echo "Git has been configured for $(GIT_AUTHOR_NAME) <$(GIT_AUTHOR_EMAIL)>."; \
173 echo "Please submit patches to <enigma2-devel@lists.elitedvb.net>."; \
177 @echo "[*] Please run '$(MAKE) help' to display further information!"
180 @echo '[*] Deleting generated configuration files'
181 @$(RM) $(CONFFILES_AUTO) $(CONFFILES_MANUAL) $(CONFDEPS)
182 @$(MAKE) $(MFLAGS) -C doc clean
185 @echo '[*] Deleting dependencies directory'
187 @echo '[*] Deleting download directory'
189 @echo '[*] Deleting tmp directory'
191 @echo '[*] Deleting sstate directory'
192 @$(RM) -r $(SSTATE_DIR)
193 @echo '[*] Deleting persistent directory'
194 @$(RM) -r $(PERSISTENT_DIR)
195 @echo '[*] Deleting build directory'
196 @$(RM) -r $(BUILD_DIR)
197 @echo '[*] Deleting git submodules'
198 @$(GIT) submodule foreach 'rm -rf .* * 2>/dev/null || true'
200 # function to convert simple space separated list to csv
204 csv = $(subst $(space),$(comma),$(strip $1))
206 sstate-cache-clean: init
207 @echo '[*] Cleaning up sstate-cache'
208 @. $(CURDIR)/bitbake.env && sstate-cache-management.sh --cache-dir=$(SSTATE_DIR) --stamps-dir=$(call csv,$(wildcard $(CURDIR)/build/*/tmp*/stamps)) -v
211 @$(MAKE) $(MFLAGS) -C doc
213 dreambox-image enigma2 package-index: init
214 @echo '[*] Building $@ for $(USER_MACHINE)'
218 @echo '[*] Building $@ for $(USER_MACHINE)'
219 @$(BITBAKE) $(MAKE_IMAGE_BB)
222 @echo '[*] Building $@ for $(USER_MACHINE)'
223 @$(BITBAKE) dreambox-$@
226 @echo '[*] Building $@ for $(USER_MACHINE)'
227 @$(BITBAKE) linux-dreambox
230 @echo '[*] Downloading sources'
231 @$(BITBAKE) -cfetchall -k $(MAKE_IMAGE_BB)
234 @echo '[*] Updating Git repositories...'
235 @HASH=`$(XSUM) $(MAKEFILE_LIST)`; \
236 if [ -n "$(GIT_REMOTE)" ]; then \
237 $(GIT) pull --ff-only || $(GIT) pull --rebase || exit 1; \
239 if [ "$$HASH" != "`$(XSUM) $(MAKEFILE_LIST)`" ]; then \
240 echo '[*] Makefile changed. Restarting...'; \
241 $(MAKE) $(MFLAGS) --no-print-directory $(MAKECMDGOALS); \
243 $(GIT) submodule sync && \
244 $(GIT) submodule update --init && \
245 echo "[*] The Dreambox SDK is now up-to-date."; \
248 .PHONY: all clean doc gcccheck help image init update usage
250 MACHINE_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-$(MACHINE)-ext.conf
251 DISTRO_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-ext.conf
253 BB_ENV_EXTRAWHITE = MACHINE DISTRO TCMODE TCLIBC HTTP_PROXY http_proxy \
254 HTTPS_PROXY https_proxy FTP_PROXY ftp_proxy FTPS_PROXY ftps_proxy ALL_PROXY \
255 all_proxy NO_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY \
256 SDKMACHINE BB_NUMBER_THREADS BB_NO_NETWORK PARALLEL_MAKE GIT_PROXY_COMMAND \
257 SOCKS5_PASSWD SOCKS5_USER SCREENDIR STAMPS_DIR BBPATH_EXTRA BB_SETSCENE_ENFORCE
259 BITBAKE_ENV_HASH := $(call hash, \
260 'BITBAKE_ENV_VERSION = "0"' \
261 'BB_ENV_EXTRAWHITE = "$(BB_ENV_EXTRAWHITE)"' \
262 'CURDIR = "$(CURDIR)"' \
265 bitbake.env: $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH)
266 @echo '[*] Generating $@'
267 @echo '# Automatically generated file. Do not edit!' > $@
268 @echo 'export BB_ENV_EXTRAWHITE="$(BB_ENV_EXTRAWHITE)"' >> $@
269 @echo 'export PATH="$(CURDIR)/openembedded-core/scripts:$(CURDIR)/bitbake/bin:$${PATH}"' >> $@
271 OPENDREAMBOX_CONF_HASH := $(call hash, \
272 'OPENDREAMBOX_CONF_VERSION = "2"' \
273 'CURDIR = "$(CURDIR)"' \
274 'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' \
275 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' \
276 'DL_DIR = "$(DL_DIR)"' \
277 'PERSISTENT_DIR = "$(PERSISTENT_DIR)"' \
278 'SSTATE_DIR = "$(SSTATE_DIR)"' \
281 conf/opendreambox.conf: $(DEPDIR)/.opendreambox.conf.$(OPENDREAMBOX_CONF_HASH)
282 @echo '[*] Generating $@'
283 @test -d $(@D) || mkdir -p $(@D)
284 @echo '# Automatically generated file. Do not edit!' > $@
285 @echo 'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' >> $@
286 @echo 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' >> $@
287 @echo 'DL_DIR = "$(DL_DIR)"' >> $@
288 @echo 'PERSISTENT_DIR = "$(PERSISTENT_DIR)"' >> $@
289 @echo 'SSTATE_DIR = "$(SSTATE_DIR)"' >> $@
290 @echo 'BB_GENERATE_MIRROR_TARBALLS = "0"' >> $@
291 @echo 'BBINCLUDELOGS = "yes"' >> $@
292 @echo 'CONF_VERSION = "1"' >> $@
293 @echo 'DISTRO = "opendreambox"' >> $@
294 @echo 'PATCHRESOLVE = "noop"' >> $@
295 @echo 'PRSERV_HOST = "localhost:0"' >> $@
297 LOCAL_CONF_HASH := $(call hash, \
298 'LOCAL_CONF_VERSION = "0"' \
299 'CURDIR = "$(CURDIR)"' \
300 'TOPDIR = "$(TOPDIR)"' \
301 'MACHINE = "$(MACHINE)"' \
302 'TMPDIR = "$(TMPDIR)"' \
303 'DISTRO_INCLUDE_CONF = "$(DISTRO_INCLUDE_CONF)"' \
304 'MACHINE_INCLUDE_CONF = "$(MACHINE_INCLUDE_CONF)"' \
307 $(TOPDIR)/conf/local.conf: $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH)
308 @echo '[*] Generating $@'
309 @test -d $(@D) || mkdir -p $(@D)
310 @echo '# Automatically generated file. Do not edit!' > $@
311 @echo 'TOPDIR = "$(TOPDIR)"' >> $@
312 @echo 'MACHINE = "$(MACHINE)"' >> $@
313 @echo 'TMPDIR = "$(TMPDIR)"' >> $@
314 @echo 'require $(CURDIR)/conf/opendreambox.conf' >> $@
315 @echo 'include $(DISTRO_INCLUDE_CONF)' >> $@
316 @echo 'include $(MACHINE_INCLUDE_CONF)' >> $@
318 BBLAYERS_CONF_HASH := $(call hash, \
319 'BBLAYERS_CONF_VERSION = "0"' \
320 'CURDIR = "$(CURDIR)"' \
321 'LCONF_VERSION = "$(LCONF_VERSION)"' \
322 'BBFILES = "$(BBFILES)"' \
323 'BBLAYERS = "$(BBLAYERS)"' \
324 'DISTRO_INCLUDE_CONF = "$(DISTRO_INCLUDE_CONF)"' \
325 'MACHINE_INCLUDE_CONF = "$(MACHINE_INCLUDE_CONF)"' \
328 $(TOPDIR)/conf/bblayers.conf: $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH)
329 @echo '[*] Generating $@'
330 @test -d $(@D) || mkdir -p $(@D)
331 @echo '# Automatically generated file. Do not edit!' > $@
332 @echo 'LCONF_VERSION = "4"' >> $@
333 @echo 'BBFILES = ""' >> $@
334 @echo 'BBLAYERS = "$(BBLAYERS)"' >> $@
335 @echo 'include $(DISTRO_INCLUDE_CONF)' >> $@
336 @echo 'include $(MACHINE_INCLUDE_CONF)' >> $@
338 MAKEFILE_HASH := $(call hash, \
339 'CURDIR = "$(CURDIR)"' \
342 $(TOPDIR)/Makefile: $(DEPDIR)/.Makefile.$(MACHINE).$(MAKEFILE_HASH)
343 @echo '[*] Generating $@'
344 @test -d $(@D) || mkdir -p $(@D)
345 @printf '%%::\n\tMACHINE=$(MACHINE) $$(MAKE) -C $(CURDIR) $$(MAKECMDGOALS)\n' > $@
347 $(TOPDIR)/bitbake.env: $(DEPDIR)/.bitbake.env.$(MACHINE).$(MAKEFILE_HASH)
348 @echo '[*] Generating $@'
349 @test -d $(@D) || mkdir -p $(@D)
350 @echo '. $(CURDIR)/bitbake.env' > $@
352 CROSS_COMPILE_ENV_BLACKLIST = \
353 HOME LOGNAME PWD SHELL SSH_AGENT_PID SSH_AUTH_SOCK TERM USER
355 CROSS_COMPILE_ENV_HASH := $(call hash, \
356 'CROSS_COMPILE_ENV_VERSION = "0"' \
357 'CURDIR = "$(CURDIR)"' \
358 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' \
359 'TMPDIR = "$(TMPDIR)"' \
360 'TOPDIR = "$(TOPDIR)"' \
361 'CROSS_COMPILE_ENV_BLACKLIST = "$(CROSS_COMPILE_ENV_BLACKLIST)"' \
364 .cross-compile-$(MACHINE).env: $(DEPDIR)/.cross-compile.env.$(MACHINE).$(CROSS_COMPILE_ENV_HASH) $(CONFFILES_BITBAKE)
365 @test -d $(TOPDIR) || (echo 'The directory "$(TOPDIR)" does not exist. Is "$(MACHINE)" a valid machine? Try running "make MACHINE=$(MACHINE)" first.' && exit 1)
366 @echo '[*] Generating $@'
367 @(BB_SRCREV_POLICY=cache $(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)
370 @test -d $(@D) || mkdir -p $(@D)
371 @$(RM) $(filter-out $@,$(wildcard $(basename $@).*))
372 @test -e $@ || touch $@