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-golang \
65 $(CURDIR)/meta-opendreambox \
66 $(CURDIR)/meta-openembedded/meta-filesystems \
67 $(CURDIR)/meta-openembedded/meta-multimedia \
68 $(CURDIR)/meta-openembedded/meta-networking \
69 $(CURDIR)/meta-openembedded/meta-oe \
70 $(CURDIR)/meta-openembedded/meta-python \
71 $(CURDIR)/meta-openembedded/meta-ruby \
72 $(CURDIR)/meta-openembedded/meta-webserver \
74 $(CURDIR)/openembedded-core/meta
78 conf/opendreambox.conf \
80 $(TOPDIR)/bitbake.env \
81 $(TOPDIR)/conf/bblayers.conf \
82 $(TOPDIR)/conf/local.conf
85 .cross-compile-$(MACHINE).env
88 $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH) \
89 $(DEPDIR)/.opendreambox.conf.$(OPENDREAMBOX_CONF_HASH) \
90 $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH) \
91 $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH) \
92 $(DEPDIR)/.cross-compile.env.$(MACHINE).$(CROSS_COMPILE_ENV_HASH)
95 conf/opendreambox.conf \
96 openembedded-core/meta/conf/bitbake.conf \
98 conf/bblayers-ext.conf \
99 conf/bblayers-$(MACHINE)-ext.conf \
100 conf/local-ext.conf \
101 conf/local-$(MACHINE)-ext.conf)
104 GIT_REMOTE := $(shell $(GIT) remote)
105 GIT_AUTHOR_NAME ?= $(shell $(GIT) config user.name)
106 GIT_AUTHOR_EMAIL ?= $(shell $(GIT) config user.email)
108 hash = $(shell echo $(1) | $(XSUM) | awk '{print $$1}')
114 [ -d $@ ] || $(MAKE) $(MFLAGS) update
116 init: $(BBLAYERS) $(CONFFILES_AUTO)
119 @echo "Your options:"
121 @echo " * Update the SDK"
122 @echo " $$ $(MAKE) update"
124 @echo " * Build the PDF documentation (doc/opendreambox.pdf, requires pdfTeX):"
125 @echo " $$ $(MAKE) doc"
127 @echo " * View the documentation in text format:"
128 @echo " $$ view doc/opendreambox.txt"
130 @echo " * Select a new target machine:"
131 @echo " $$ echo MACHINE=dm820 >> conf/make.conf"
132 @echo " [Valid values: dm520, dm820, dm900, dm7080]"
134 @echo " * Build a firmware image for the selected target machine:"
135 @echo " $$ $(MAKE) image"
137 @echo " * Build a firmware image for a different target machine:"
138 @echo " $$ $(MAKE) image MACHINE=dm820"
139 @echo " [Valid values: dm520, dm820, dm900, dm7080]"
141 @echo " * Download all source files at once:"
142 @echo " $$ $(MAKE) download"
144 @echo " * Set up the environment to build recipes manually:"
145 @echo " $$ source bitbake.env"
146 @echo " $$ cd build/$(MACHINE)"
147 @echo " $$ bitbake <target>"
148 @echo " [Replace <target> with a recipe name, e.g. $(MAKE_IMAGE_BB) or enigma2]"
150 @echo "Your current settings:"
151 @echo " MACHINE = $(USER_MACHINE)"
153 @echo " BB_NUMBER_THREADS = $(BB_NUMBER_THREADS)"
154 @echo " PARALLEL_MAKE = $(PARALLEL_MAKE)"
156 @echo "Trouble finding a recipe? Try ./scripts/drepo grep 'search string'"
157 @echo "or ./scripts/drepo find -name \"*recipe*\"."
159 @if [ -z "$(GIT_AUTHOR_NAME)" -o -z "$(GIT_AUTHOR_EMAIL)" ]; then \
160 echo "Before doing any commits, please configure your name and email"; \
161 echo "address using the following commands:"; \
163 echo " $$ $(GIT) config user.name \"Your Name\""; \
164 echo " $$ $(GIT) config user.email \"mail@example.com\""; \
166 echo "Git has been configured for $(GIT_AUTHOR_NAME) <$(GIT_AUTHOR_EMAIL)>."; \
167 echo "Please submit patches to <enigma2-devel@lists.elitedvb.net>."; \
171 @echo "[*] Please run '$(MAKE) help' to display further information!"
174 @echo '[*] Deleting generated configuration files'
175 @$(RM) $(CONFFILES_AUTO) $(CONFFILES_MANUAL) $(CONFDEPS)
176 @$(MAKE) $(MFLAGS) -C doc clean
179 @echo '[*] Deleting dependencies directory'
181 @echo '[*] Deleting download directory'
183 @echo '[*] Deleting tmp directory'
185 @echo '[*] Deleting sstate directory'
186 @$(RM) -r $(SSTATE_DIR)
187 @echo '[*] Deleting persistent directory'
188 @$(RM) -r $(PERSISTENT_DIR)
189 @echo '[*] Deleting build directory'
190 @$(RM) -r $(BUILD_DIR)
191 @echo '[*] Deleting git submodules'
192 @$(GIT) submodule foreach 'rm -rf .* * 2>/dev/null || true'
194 # function to convert simple space separated list to csv
198 csv = $(subst $(space),$(comma),$(strip $1))
200 sstate-cache-clean: init
201 @echo '[*] Cleaning up sstate-cache'
202 @. $(CURDIR)/bitbake.env && sstate-cache-management.sh --cache-dir=$(SSTATE_DIR) --stamps-dir=$(call csv,$(wildcard $(CURDIR)/build/*/tmp*/stamps)) -v
205 @$(MAKE) $(MFLAGS) -C doc
207 dreambox-image enigma2 package-index: init
208 @echo '[*] Building $@ for $(USER_MACHINE)'
212 @echo '[*] Building $@ for $(USER_MACHINE)'
213 @$(BITBAKE) $(MAKE_IMAGE_BB)
216 @echo '[*] Building $@ for $(USER_MACHINE)'
217 @$(BITBAKE) dreambox-$@
220 @echo '[*] Building $@ for $(USER_MACHINE)'
221 @$(BITBAKE) linux-dreambox
224 @echo '[*] Downloading sources'
225 @$(BITBAKE) -cfetchall -k $(MAKE_IMAGE_BB)
228 @echo '[*] Updating Git repositories...'
229 @HASH=`$(XSUM) $(MAKEFILE_LIST)`; \
230 if [ -n "$(GIT_REMOTE)" ]; then \
231 $(GIT) pull --ff-only || $(GIT) pull --rebase || exit 1; \
233 if [ "$$HASH" != "`$(XSUM) $(MAKEFILE_LIST)`" ]; then \
234 echo '[*] Makefile changed. Restarting...'; \
235 $(MAKE) $(MFLAGS) --no-print-directory $(MAKECMDGOALS); \
237 $(GIT) submodule sync && \
238 $(GIT) submodule update --init && \
239 echo "[*] The Dreambox SDK is now up-to-date."; \
242 .PHONY: all clean doc help image init update usage
244 MACHINE_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-$(MACHINE)-ext.conf
245 DISTRO_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-ext.conf
247 BB_ENV_EXTRAWHITE = MACHINE DISTRO TCMODE TCLIBC HTTP_PROXY http_proxy \
248 HTTPS_PROXY https_proxy FTP_PROXY ftp_proxy FTPS_PROXY ftps_proxy ALL_PROXY \
249 all_proxy NO_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY \
250 SDKMACHINE BB_NUMBER_THREADS BB_NO_NETWORK PARALLEL_MAKE GIT_PROXY_COMMAND \
251 SOCKS5_PASSWD SOCKS5_USER SCREENDIR STAMPS_DIR BBPATH_EXTRA BB_SETSCENE_ENFORCE
253 BITBAKE_ENV_HASH := $(call hash, \
254 'BITBAKE_ENV_VERSION = "0"' \
255 'BB_ENV_EXTRAWHITE = "$(BB_ENV_EXTRAWHITE)"' \
256 'CURDIR = "$(CURDIR)"' \
259 bitbake.env: $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH)
260 @echo '[*] Generating $@'
261 @echo '# Automatically generated file. Do not edit!' > $@
262 @echo 'export BB_ENV_EXTRAWHITE="$(BB_ENV_EXTRAWHITE)"' >> $@
263 @echo 'export PATH="$(CURDIR)/openembedded-core/scripts:$(CURDIR)/bitbake/bin:$${PATH}"' >> $@
265 OPENDREAMBOX_CONF_HASH := $(call hash, \
266 'OPENDREAMBOX_CONF_VERSION = "2"' \
267 'CURDIR = "$(CURDIR)"' \
268 'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' \
269 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' \
270 'DL_DIR = "$(DL_DIR)"' \
271 'PERSISTENT_DIR = "$(PERSISTENT_DIR)"' \
272 'SSTATE_DIR = "$(SSTATE_DIR)"' \
275 conf/opendreambox.conf: $(DEPDIR)/.opendreambox.conf.$(OPENDREAMBOX_CONF_HASH)
276 @echo '[*] Generating $@'
277 @test -d $(@D) || mkdir -p $(@D)
278 @echo '# Automatically generated file. Do not edit!' > $@
279 @echo 'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' >> $@
280 @echo 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' >> $@
281 @echo 'DL_DIR = "$(DL_DIR)"' >> $@
282 @echo 'PERSISTENT_DIR = "$(PERSISTENT_DIR)"' >> $@
283 @echo 'SSTATE_DIR = "$(SSTATE_DIR)"' >> $@
284 @echo 'BB_GENERATE_MIRROR_TARBALLS = "0"' >> $@
285 @echo 'BBINCLUDELOGS = "yes"' >> $@
286 @echo 'CONF_VERSION = "1"' >> $@
287 @echo 'DISTRO = "opendreambox"' >> $@
288 @echo 'PATCHRESOLVE = "noop"' >> $@
289 @echo 'PRSERV_HOST = "localhost:0"' >> $@
291 LOCAL_CONF_HASH := $(call hash, \
292 'LOCAL_CONF_VERSION = "0"' \
293 'CURDIR = "$(CURDIR)"' \
294 'TOPDIR = "$(TOPDIR)"' \
295 'MACHINE = "$(MACHINE)"' \
296 'TMPDIR = "$(TMPDIR)"' \
297 'DISTRO_INCLUDE_CONF = "$(DISTRO_INCLUDE_CONF)"' \
298 'MACHINE_INCLUDE_CONF = "$(MACHINE_INCLUDE_CONF)"' \
301 $(TOPDIR)/conf/local.conf: $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH)
302 @echo '[*] Generating $@'
303 @test -d $(@D) || mkdir -p $(@D)
304 @echo '# Automatically generated file. Do not edit!' > $@
305 @echo 'TOPDIR = "$(TOPDIR)"' >> $@
306 @echo 'MACHINE = "$(MACHINE)"' >> $@
307 @echo 'TMPDIR = "$(TMPDIR)"' >> $@
308 @echo 'require $(CURDIR)/conf/opendreambox.conf' >> $@
309 @echo 'include $(DISTRO_INCLUDE_CONF)' >> $@
310 @echo 'include $(MACHINE_INCLUDE_CONF)' >> $@
312 BBLAYERS_CONF_HASH := $(call hash, \
313 'BBLAYERS_CONF_VERSION = "0"' \
314 'CURDIR = "$(CURDIR)"' \
315 'LCONF_VERSION = "$(LCONF_VERSION)"' \
316 'BBFILES = "$(BBFILES)"' \
317 'BBLAYERS = "$(BBLAYERS)"' \
318 'DISTRO_INCLUDE_CONF = "$(DISTRO_INCLUDE_CONF)"' \
319 'MACHINE_INCLUDE_CONF = "$(MACHINE_INCLUDE_CONF)"' \
322 $(TOPDIR)/conf/bblayers.conf: $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH)
323 @echo '[*] Generating $@'
324 @test -d $(@D) || mkdir -p $(@D)
325 @echo '# Automatically generated file. Do not edit!' > $@
326 @echo 'LCONF_VERSION = "4"' >> $@
327 @echo 'BBFILES = ""' >> $@
328 @echo 'BBLAYERS = "$(BBLAYERS)"' >> $@
329 @echo 'include $(DISTRO_INCLUDE_CONF)' >> $@
330 @echo 'include $(MACHINE_INCLUDE_CONF)' >> $@
333 @echo '[*] Generating $@'
334 @test -d $(@D) || mkdir -p $(@D)
335 @printf '%%::\n\tMACHINE=$(MACHINE) $$(MAKE) -C ../.. $$(MAKECMDGOALS)\n' > $@
337 $(TOPDIR)/bitbake.env:
338 @echo '[*] Generating $@'
339 @test -d $(@D) || mkdir -p $(@D)
340 @echo '. ../../bitbake.env' > $@
342 CROSS_COMPILE_ENV_BLACKLIST = \
343 HOME LOGNAME PWD SHELL SSH_AGENT_PID SSH_AUTH_SOCK TERM USER
345 CROSS_COMPILE_ENV_HASH := $(call hash, \
346 'CROSS_COMPILE_ENV_VERSION = "0"' \
347 'CURDIR = "$(CURDIR)"' \
348 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' \
349 'TMPDIR = "$(TMPDIR)"' \
350 'TOPDIR = "$(TOPDIR)"' \
351 'CROSS_COMPILE_ENV_BLACKLIST = "$(CROSS_COMPILE_ENV_BLACKLIST)"' \
354 .cross-compile-$(MACHINE).env: $(DEPDIR)/.cross-compile.env.$(MACHINE).$(CROSS_COMPILE_ENV_HASH) $(CONFFILES_BITBAKE)
355 @test -d $(TOPDIR) || (echo 'The directory "$(TOPDIR)" does not exist. Is "$(MACHINE)" a valid machine? Try running "make MACHINE=$(MACHINE)" first.' && exit 1)
356 @echo '[*] Generating $@'
357 @($(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)
360 @test -d $(@D) || mkdir -p $(@D)
361 @$(RM) $(basename $@).*