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 # dm500hdv2, dm520, dm800sev2, dm820,
33 # dm7020hd, dm7020hdv2, dm7080, dm8000
35 # This only sets the default value. All platforms now use a shared build
36 # directory. Run "MACHINE=dm800sev2 bitbake dreambox-image" to build an image
37 # for the dm800sev2, if it is not the default.
40 USER_MACHINE := $(MACHINE)
42 MAKE_IMAGE_BB ?= dreambox-image
44 # Adjust according to the number CPU cores to use for parallel build.
45 # Default: Number of processors in /proc/cpuinfo, if present, or 1.
46 NR_CPU := $(shell [ -f /proc/cpuinfo ] && grep -c '^processor\s*:' /proc/cpuinfo || echo 1)
47 BB_NUMBER_THREADS ?= $(NR_CPU)
48 PARALLEL_MAKE ?= -j $(NR_CPU)
53 BUILD_DIR = $(CURDIR)/build
54 TOPDIR = $(BUILD_DIR)/$(MACHINE)
55 DL_DIR = $(CURDIR)/sources
56 PERSISTENT_DIR = $(CURDIR)/persist-cache
57 SSTATE_DIR = $(CURDIR)/sstate-cache
58 TMPDIR = $(TOPDIR)/tmp
59 DEPDIR = $(CURDIR)/.deps
61 BITBAKE = . $(CURDIR)/bitbake.env && cd $(TOPDIR) && $(NICE) bitbake
64 $(CURDIR)/meta-dreambox \
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 \
74 $(CURDIR)/openembedded-core/meta
78 conf/opendreambox.conf \
79 $(TOPDIR)/conf/bblayers.conf \
80 $(TOPDIR)/conf/local.conf
83 .cross-compile-$(MACHINE).env
86 $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH) \
87 $(DEPDIR)/.opendreambox.conf.$(OPENDREAMBOX_CONF_HASH) \
88 $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH) \
89 $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH) \
90 $(DEPDIR)/.cross-compile.env.$(MACHINE).$(CROSS_COMPILE_ENV_HASH)
93 conf/opendreambox.conf \
94 openembedded-core/meta/conf/bitbake.conf \
96 conf/bblayers-ext.conf \
97 conf/bblayers-$(MACHINE)-ext.conf \
99 conf/local-$(MACHINE)-ext.conf)
102 GIT_REMOTE := $(shell $(GIT) remote)
103 GIT_USER_NAME := $(shell $(GIT) config user.name)
104 GIT_USER_EMAIL := $(shell $(GIT) config user.email)
106 hash = $(shell echo $(1) | $(XSUM) | awk '{print $$1}')
112 [ -d $@ ] || $(MAKE) $(MFLAGS) update
114 init: $(BBLAYERS) $(CONFFILES_AUTO)
117 @echo "Your options:"
119 @echo " * Update the SDK"
120 @echo " $$ $(MAKE) update"
122 @echo " * Build the PDF documentation (doc/opendreambox.pdf, requires pdfTeX):"
123 @echo " $$ $(MAKE) doc"
125 @echo " * View the documentation in text format:"
126 @echo " $$ view doc/opendreambox.txt"
128 @echo " * Select a new target machine:"
129 @echo " $$ echo MACHINE=dm800sev2 >> conf/make.conf"
130 @echo " [Valid values: dm500hdv2, dm800sev2, dm820, dm7020hd, dm7020hdv2, dm7080, dm8000]"
132 @echo " * Build a firmware image for the selected target machine:"
133 @echo " $$ $(MAKE) image"
135 @echo " * Build a firmware image for a different target machine:"
136 @echo " $$ $(MAKE) image MACHINE=dm800sev2"
137 @echo " [Valid values: dm500hdv2, dm520, dm800sev2, dm820, dm7020hd, dm7020hdv2, dm7080, dm8000]"
139 @echo " * Download all source files at once:"
140 @echo " $$ $(MAKE) download"
142 @echo " * Set up the environment to build recipes manually:"
143 @echo " $$ source bitbake.env"
144 @echo " $$ cd build/$(MACHINE)"
145 @echo " $$ bitbake <target>"
146 @echo " [Replace <target> with a recipe name, e.g. $(MAKE_IMAGE_BB) or enigma2]"
148 @echo "Your current settings:"
149 @echo " MACHINE = $(USER_MACHINE)"
151 @echo " BB_NUMBER_THREADS = $(BB_NUMBER_THREADS)"
152 @echo " PARALLEL_MAKE = $(PARALLEL_MAKE)"
154 @echo "Trouble finding a recipe? Try ./scripts/drepo grep 'search string'"
155 @echo "or ./scripts/drepo find -name \"*recipe*\"."
157 @if [ -z "$(GIT_USER_NAME)" -o -z "$(GIT_USER_EMAIL)" ]; then \
158 echo "Before doing any commits, please configure your name and email"; \
159 echo "address using the following commands:"; \
161 echo " $$ $(GIT) config user.name \"Your Name\""; \
162 echo " $$ $(GIT) config user.email \"mail@example.com\""; \
164 echo "Git has been configured for $(GIT_USER_NAME) <$(GIT_USER_EMAIL)>."; \
165 echo "Please submit patches to <enigma2-devel@lists.elitedvb.net>."; \
169 @echo "[*] Please run '$(MAKE) help' to display further information!"
172 @echo '[*] Deleting generated configuration files'
173 @$(RM) $(CONFFILES_AUTO) $(CONFFILES_MANUAL) $(CONFDEPS)
174 @$(MAKE) $(MFLAGS) -C doc clean
177 @echo '[*] Deleting dependencies directory'
179 @echo '[*] Deleting download directory'
181 @echo '[*] Deleting tmp directory'
183 @echo '[*] Deleting sstate directory'
184 @$(RM) -r $(SSTATE_DIR)
185 @echo '[*] Deleting persistent directory'
186 @$(RM) -r $(PERSISTENT_DIR)
187 @echo '[*] Deleting build directory'
188 @$(RM) -r $(BUILD_DIR)
189 @echo '[*] Deleting git submodules'
190 @$(GIT) submodule foreach 'rm -rf .* * 2>/dev/null || true'
192 # function to convert simple space separated list to csv
196 csv = $(subst $(space),$(comma),$(strip $1))
198 sstate-cache-clean: init
199 @echo '[*] Cleaning up sstate-cache'
200 @. $(CURDIR)/bitbake.env && sstate-cache-management.sh --cache-dir=$(SSTATE_DIR) --stamps-dir=$(call csv,$(wildcard $(CURDIR)/build/*/tmp*/stamps)) -v
203 @$(MAKE) $(MFLAGS) -C doc
205 dreambox-image enigma2 package-index: init
206 @echo '[*] Building $@ for $(USER_MACHINE)'
210 @echo '[*] Building $@ for $(USER_MACHINE)'
211 @$(BITBAKE) $(MAKE_IMAGE_BB)
214 @echo '[*] Building $@ for $(USER_MACHINE)'
215 @$(BITBAKE) dreambox-$@
218 @echo '[*] Building $@ for $(USER_MACHINE)'
219 @$(BITBAKE) linux-dreambox-rescue
222 @echo '[*] Downloading sources'
223 @$(BITBAKE) -cfetchall -k $(MAKE_IMAGE_BB)
226 @echo '[*] Updating Git repositories...'
227 @HASH=`$(XSUM) $(MAKEFILE_LIST)`; \
228 if [ -n "$(GIT_REMOTE)" ]; then \
229 $(GIT) pull --ff-only || $(GIT) pull --rebase || exit 1; \
231 if [ "$$HASH" != "`$(XSUM) $(MAKEFILE_LIST)`" ]; then \
232 echo '[*] Makefile changed. Restarting...'; \
233 $(MAKE) $(MFLAGS) --no-print-directory $(MAKECMDGOALS); \
235 $(GIT) submodule sync && \
236 $(GIT) submodule update --init && \
237 echo "[*] The Dreambox SDK is now up-to-date."; \
240 .PHONY: all clean doc help image init update usage
242 MACHINE_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-$(MACHINE)-ext.conf
243 DISTRO_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-ext.conf
245 BB_ENV_EXTRAWHITE = MACHINE DISTRO TCMODE TCLIBC HTTP_PROXY http_proxy \
246 HTTPS_PROXY https_proxy FTP_PROXY ftp_proxy FTPS_PROXY ftps_proxy ALL_PROXY \
247 all_proxy NO_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY \
248 SDKMACHINE BB_NUMBER_THREADS BB_NO_NETWORK PARALLEL_MAKE GIT_PROXY_COMMAND \
249 SOCKS5_PASSWD SOCKS5_USER SCREENDIR STAMPS_DIR
251 BITBAKE_ENV_HASH := $(call hash, \
252 'BITBAKE_ENV_VERSION = "0"' \
253 'BB_ENV_EXTRAWHITE = "$(BB_ENV_EXTRAWHITE)"' \
254 'CURDIR = "$(CURDIR)"' \
257 bitbake.env: $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH)
258 @echo '[*] Generating $@'
259 @echo '# Automatically generated file. Do not edit!' > $@
260 @echo 'export BB_ENV_EXTRAWHITE="$(BB_ENV_EXTRAWHITE)"' >> $@
261 @echo 'export PATH="$(CURDIR)/openembedded-core/scripts:$(CURDIR)/bitbake/bin:$${PATH}"' >> $@
263 OPENDREAMBOX_CONF_HASH := $(call hash, \
264 'OPENDREAMBOX_CONF_VERSION = "2"' \
265 'CURDIR = "$(CURDIR)"' \
266 'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' \
267 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' \
268 'DL_DIR = "$(DL_DIR)"' \
269 'PERSISTENT_DIR = "$(PERSISTENT_DIR)"' \
270 'SSTATE_DIR = "$(SSTATE_DIR)"' \
271 'BB_GENERATE_MIRROR_TARBALLS = "$(BB_GENERATE_MIRROR_TARBALLS)"' \
272 'BBINCLUDELOGS = "$(BBINCLUDELOGS)"' \
273 'CONF_VERSION = "$(CONF_VERSION)"' \
274 'DISTRO = "$(DISTRO)"' \
275 'USER_CLASSES = "$(USER_CLASSES)"' \
276 'PATCHRESOLVE = "$(PATCHRESOLVE)"' \
277 'PRSERV_HOST = "$(PRSERV_HOST)"' \
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 'USER_CLASSES = "buildstats"' >> $@
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 CROSS_COMPILE_ENV_BLACKLIST = \
339 HOME LOGNAME PWD SHELL SSH_AGENT_PID SSH_AUTH_SOCK TERM USER
341 CROSS_COMPILE_ENV_HASH := $(call hash, \
342 'CROSS_COMPILE_ENV_VERSION = "0"' \
343 'CURDIR = "$(CURDIR)"' \
344 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' \
345 'TMPDIR = "$(TMPDIR)"' \
346 'TOPDIR = "$(TOPDIR)"' \
347 'CROSS_COMPILE_ENV_BLACKLIST = "$(CROSS_COMPILE_ENV_BLACKLIST)"' \
350 .cross-compile-$(MACHINE).env: $(DEPDIR)/.cross-compile.env.$(MACHINE).$(CROSS_COMPILE_ENV_HASH) $(CONFFILES_BITBAKE)
351 @test -d $(TOPDIR) || (echo 'The directory "$(TOPDIR)" does not exist. Is "$(MACHINE)" a valid machine? Try running "make MACHINE=$(MACHINE)" first.' && exit 1)
352 @echo '[*] Generating $@'
353 @echo '# Automatically generated file. Do not edit!' > $@
354 @($(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)
357 @test -d $(@D) || mkdir -p $(@D)
358 @$(RM) $(basename $@).*