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)/.opendreambox.conf.$(OPENDREAMBOX_CONF_HASH) \
91 $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH) \
92 $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH) \
93 $(DEPDIR)/.Makefile.$(MACHINE).$(MAKEFILE_HASH) \
94 $(DEPDIR)/.cross-compile.env.$(MACHINE).$(CROSS_COMPILE_ENV_HASH)
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_AUTHOR_NAME ?= $(shell $(GIT) config user.name)
108 GIT_AUTHOR_EMAIL ?= $(shell $(GIT) config user.email)
110 hash = $(shell echo $(1) | $(XSUM) | awk '{print $$1}')
116 [ -d $@ ] || $(MAKE) $(MFLAGS) update
119 @[ `(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)
121 init: gcccheck $(BBLAYERS) $(CONFFILES_AUTO)
124 @echo "Your options:"
126 @echo " * Update the SDK"
127 @echo " $$ $(MAKE) update"
129 @echo " * Build the PDF documentation (doc/opendreambox.pdf, requires pdfTeX):"
130 @echo " $$ $(MAKE) doc"
132 @echo " * View the documentation in text format:"
133 @echo " $$ view doc/opendreambox.txt"
135 @echo " * Select a new target machine:"
136 @echo " $$ echo MACHINE=dm820 >> conf/make.conf"
137 @echo " [Valid values: dm520, dm820, dm900, dm920, dm7080]"
139 @echo " * Build a firmware image for the selected target machine:"
140 @echo " $$ $(MAKE) image"
142 @echo " * Build a firmware image for a different target machine:"
143 @echo " $$ $(MAKE) image MACHINE=dm820"
144 @echo " [Valid values: dm520, dm820, dm900, dm920, dm7080]"
146 @echo " * Download all source files at once:"
147 @echo " $$ $(MAKE) download"
149 @echo " * Set up the environment to build recipes manually:"
150 @echo " $$ source bitbake.env"
151 @echo " $$ cd build/$(MACHINE)"
152 @echo " $$ bitbake <target>"
153 @echo " [Replace <target> with a recipe name, e.g. $(MAKE_IMAGE_BB) or enigma2]"
155 @echo "Your current settings:"
156 @echo " MACHINE = $(USER_MACHINE)"
158 @echo " BB_NUMBER_THREADS = $(BB_NUMBER_THREADS)"
159 @echo " PARALLEL_MAKE = $(PARALLEL_MAKE)"
161 @echo "Trouble finding a recipe? Try ./scripts/drepo grep 'search string'"
162 @echo "or ./scripts/drepo find -name \"*recipe*\"."
164 @if [ -z "$(GIT_AUTHOR_NAME)" -o -z "$(GIT_AUTHOR_EMAIL)" ]; then \
165 echo "Before doing any commits, please configure your name and email"; \
166 echo "address using the following commands:"; \
168 echo " $$ $(GIT) config user.name \"Your Name\""; \
169 echo " $$ $(GIT) config user.email \"mail@example.com\""; \
171 echo "Git has been configured for $(GIT_AUTHOR_NAME) <$(GIT_AUTHOR_EMAIL)>."; \
172 echo "Please submit patches to <enigma2-devel@lists.elitedvb.net>."; \
176 @echo "[*] Please run '$(MAKE) help' to display further information!"
179 @echo '[*] Deleting generated configuration files'
180 @$(RM) $(CONFFILES_AUTO) $(CONFFILES_MANUAL) $(CONFDEPS)
181 @$(MAKE) $(MFLAGS) -C doc clean
184 @echo '[*] Deleting dependencies directory'
186 @echo '[*] Deleting download directory'
188 @echo '[*] Deleting tmp directory'
190 @echo '[*] Deleting sstate directory'
191 @$(RM) -r $(SSTATE_DIR)
192 @echo '[*] Deleting persistent directory'
193 @$(RM) -r $(PERSISTENT_DIR)
194 @echo '[*] Deleting build directory'
195 @$(RM) -r $(BUILD_DIR)
196 @echo '[*] Deleting git submodules'
197 @$(GIT) submodule foreach 'rm -rf .* * 2>/dev/null || true'
199 # function to convert simple space separated list to csv
203 csv = $(subst $(space),$(comma),$(strip $1))
205 sstate-cache-clean: init
206 @echo '[*] Cleaning up sstate-cache'
207 @. $(CURDIR)/bitbake.env && sstate-cache-management.sh --cache-dir=$(SSTATE_DIR) --stamps-dir=$(call csv,$(wildcard $(CURDIR)/build/*/tmp*/stamps)) -v
210 @$(MAKE) $(MFLAGS) -C doc
212 dreambox-image enigma2 package-index: init
213 @echo '[*] Building $@ for $(USER_MACHINE)'
217 @echo '[*] Building $@ for $(USER_MACHINE)'
218 @$(BITBAKE) $(MAKE_IMAGE_BB)
221 @echo '[*] Building $@ for $(USER_MACHINE)'
222 @$(BITBAKE) dreambox-$@
225 @echo '[*] Building $@ for $(USER_MACHINE)'
226 @$(BITBAKE) linux-dreambox
229 @echo '[*] Downloading sources'
230 @$(BITBAKE) -cfetchall -k $(MAKE_IMAGE_BB)
233 @echo '[*] Updating Git repositories...'
234 @HASH=`$(XSUM) $(MAKEFILE_LIST)`; \
235 if [ -n "$(GIT_REMOTE)" ]; then \
236 $(GIT) pull --ff-only || $(GIT) pull --rebase || exit 1; \
238 if [ "$$HASH" != "`$(XSUM) $(MAKEFILE_LIST)`" ]; then \
239 echo '[*] Makefile changed. Restarting...'; \
240 $(MAKE) $(MFLAGS) --no-print-directory $(MAKECMDGOALS); \
242 $(GIT) submodule sync && \
243 $(GIT) submodule update --init && \
244 echo "[*] The Dreambox SDK is now up-to-date."; \
247 .PHONY: all clean doc gcccheck help image init update usage
249 MACHINE_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-$(MACHINE)-ext.conf
250 DISTRO_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-ext.conf
252 BB_ENV_EXTRAWHITE = MACHINE DISTRO TCMODE TCLIBC HTTP_PROXY http_proxy \
253 HTTPS_PROXY https_proxy FTP_PROXY ftp_proxy FTPS_PROXY ftps_proxy ALL_PROXY \
254 all_proxy NO_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY \
255 SDKMACHINE BB_NUMBER_THREADS BB_NO_NETWORK PARALLEL_MAKE GIT_PROXY_COMMAND \
256 SOCKS5_PASSWD SOCKS5_USER SCREENDIR STAMPS_DIR BBPATH_EXTRA BB_SETSCENE_ENFORCE
258 BITBAKE_ENV_HASH := $(call hash, \
259 'BITBAKE_ENV_VERSION = "0"' \
260 'BB_ENV_EXTRAWHITE = "$(BB_ENV_EXTRAWHITE)"' \
261 'CURDIR = "$(CURDIR)"' \
264 bitbake.env: $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH)
265 @echo '[*] Generating $@'
266 @echo '# Automatically generated file. Do not edit!' > $@
267 @echo 'export BB_ENV_EXTRAWHITE="$(BB_ENV_EXTRAWHITE)"' >> $@
268 @echo 'export PATH="$(CURDIR)/openembedded-core/scripts:$(CURDIR)/bitbake/bin:$${PATH}"' >> $@
270 OPENDREAMBOX_CONF_HASH := $(call hash, \
271 'OPENDREAMBOX_CONF_VERSION = "2"' \
272 'CURDIR = "$(CURDIR)"' \
273 'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' \
274 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' \
275 'DL_DIR = "$(DL_DIR)"' \
276 'PERSISTENT_DIR = "$(PERSISTENT_DIR)"' \
277 'SSTATE_DIR = "$(SSTATE_DIR)"' \
280 conf/opendreambox.conf: $(DEPDIR)/.opendreambox.conf.$(OPENDREAMBOX_CONF_HASH)
281 @echo '[*] Generating $@'
282 @test -d $(@D) || mkdir -p $(@D)
283 @echo '# Automatically generated file. Do not edit!' > $@
284 @echo 'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' >> $@
285 @echo 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' >> $@
286 @echo 'DL_DIR = "$(DL_DIR)"' >> $@
287 @echo 'PERSISTENT_DIR = "$(PERSISTENT_DIR)"' >> $@
288 @echo 'SSTATE_DIR = "$(SSTATE_DIR)"' >> $@
289 @echo 'BB_GENERATE_MIRROR_TARBALLS = "0"' >> $@
290 @echo 'BBINCLUDELOGS = "yes"' >> $@
291 @echo 'CONF_VERSION = "1"' >> $@
292 @echo 'DISTRO = "opendreambox"' >> $@
293 @echo 'PATCHRESOLVE = "noop"' >> $@
294 @echo 'PRSERV_HOST = "localhost:0"' >> $@
296 LOCAL_CONF_HASH := $(call hash, \
297 'LOCAL_CONF_VERSION = "0"' \
298 'CURDIR = "$(CURDIR)"' \
299 'TOPDIR = "$(TOPDIR)"' \
300 'MACHINE = "$(MACHINE)"' \
301 'TMPDIR = "$(TMPDIR)"' \
302 'DISTRO_INCLUDE_CONF = "$(DISTRO_INCLUDE_CONF)"' \
303 'MACHINE_INCLUDE_CONF = "$(MACHINE_INCLUDE_CONF)"' \
306 $(TOPDIR)/conf/local.conf: $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH)
307 @echo '[*] Generating $@'
308 @test -d $(@D) || mkdir -p $(@D)
309 @echo '# Automatically generated file. Do not edit!' > $@
310 @echo 'TOPDIR = "$(TOPDIR)"' >> $@
311 @echo 'MACHINE = "$(MACHINE)"' >> $@
312 @echo 'TMPDIR = "$(TMPDIR)"' >> $@
313 @echo 'require $(CURDIR)/conf/opendreambox.conf' >> $@
314 @echo 'include $(DISTRO_INCLUDE_CONF)' >> $@
315 @echo 'include $(MACHINE_INCLUDE_CONF)' >> $@
317 BBLAYERS_CONF_HASH := $(call hash, \
318 'BBLAYERS_CONF_VERSION = "0"' \
319 'CURDIR = "$(CURDIR)"' \
320 'LCONF_VERSION = "$(LCONF_VERSION)"' \
321 'BBFILES = "$(BBFILES)"' \
322 'BBLAYERS = "$(BBLAYERS)"' \
323 'DISTRO_INCLUDE_CONF = "$(DISTRO_INCLUDE_CONF)"' \
324 'MACHINE_INCLUDE_CONF = "$(MACHINE_INCLUDE_CONF)"' \
327 $(TOPDIR)/conf/bblayers.conf: $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH)
328 @echo '[*] Generating $@'
329 @test -d $(@D) || mkdir -p $(@D)
330 @echo '# Automatically generated file. Do not edit!' > $@
331 @echo 'LCONF_VERSION = "4"' >> $@
332 @echo 'BBFILES = ""' >> $@
333 @echo 'BBLAYERS = "$(BBLAYERS)"' >> $@
334 @echo 'include $(DISTRO_INCLUDE_CONF)' >> $@
335 @echo 'include $(MACHINE_INCLUDE_CONF)' >> $@
337 MAKEFILE_HASH := $(call hash, \
338 'CURDIR = "$(CURDIR)"' \
341 $(TOPDIR)/Makefile: $(DEPDIR)/.Makefile.$(MACHINE).$(MAKEFILE_HASH)
342 @echo '[*] Generating $@'
343 @test -d $(@D) || mkdir -p $(@D)
344 @printf '%%::\n\tMACHINE=$(MACHINE) $$(MAKE) -C $(CURDIR) $$(MAKECMDGOALS)\n' > $@
346 $(TOPDIR)/bitbake.env:
347 @echo '[*] Generating $@'
348 @test -d $(@D) || mkdir -p $(@D)
349 @echo '. ../../bitbake.env' > $@
351 CROSS_COMPILE_ENV_BLACKLIST = \
352 HOME LOGNAME PWD SHELL SSH_AGENT_PID SSH_AUTH_SOCK TERM USER
354 CROSS_COMPILE_ENV_HASH := $(call hash, \
355 'CROSS_COMPILE_ENV_VERSION = "0"' \
356 'CURDIR = "$(CURDIR)"' \
357 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' \
358 'TMPDIR = "$(TMPDIR)"' \
359 'TOPDIR = "$(TOPDIR)"' \
360 'CROSS_COMPILE_ENV_BLACKLIST = "$(CROSS_COMPILE_ENV_BLACKLIST)"' \
363 .cross-compile-$(MACHINE).env: $(DEPDIR)/.cross-compile.env.$(MACHINE).$(CROSS_COMPILE_ENV_HASH) $(CONFFILES_BITBAKE)
364 @test -d $(TOPDIR) || (echo 'The directory "$(TOPDIR)" does not exist. Is "$(MACHINE)" a valid machine? Try running "make MACHINE=$(MACHINE)" first.' && exit 1)
365 @echo '[*] Generating $@'
366 @($(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)
369 @test -d $(@D) || mkdir -p $(@D)
370 @$(RM) $(filter-out $@,$(wildcard $(basename $@).*))
371 @test -e $@ || touch $@