3 # Copyright (c) 2010-2012 Dream Multimedia 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 # dm800, dm8000, dm500hd, dm800se, dm7020hd, dm500hdv2, dm800sev2, dm7020hdv2
34 # This only sets the default value. All platforms now use a shared build
35 # directory. Run "MACHINE=dm800se bitbake dreambox-image" to build an image
36 # for the dm800se, if it is not the default.
39 USER_MACHINE := $(MACHINE)
41 ifeq ($(MACHINE),dm7020hdv2)
42 override MACHINE := dm7020hd
43 MAKE_IMAGE_BB ?= dreambox-image-dm7020hdv2
46 MAKE_IMAGE_BB ?= dreambox-image
48 # Adjust according to the number CPU cores to use for parallel build.
49 # Default: Number of processors in /proc/cpuinfo, if present, or 1.
50 NR_CPU := $(shell [ -f /proc/cpuinfo ] && grep -c '^processor\s*:' /proc/cpuinfo || echo 1)
51 BB_NUMBER_THREADS ?= $(NR_CPU)
52 PARALLEL_MAKE ?= -j $(NR_CPU)
56 BUILD_DIR = $(CURDIR)/build
57 TOPDIR = $(BUILD_DIR)/$(MACHINE)
58 DL_DIR = $(CURDIR)/sources
59 PERSISTENT_DIR = $(CURDIR)/persist-cache
60 SSTATE_DIR = $(CURDIR)/sstate-cache
61 TMPDIR = $(CURDIR)/tmp
62 DEPDIR = $(CURDIR)/.deps
65 $(wildcard $(CURDIR)/meta-bsp/$(MACHINE)) \
66 $(CURDIR)/meta-bsp/common \
67 $(CURDIR)/meta-opendreambox \
68 $(CURDIR)/meta-openembedded/meta-oe \
69 $(CURDIR)/meta-openembedded/meta-multimedia \
70 $(CURDIR)/meta-openembedded/meta-networking \
71 $(CURDIR)/openembedded-core/meta
75 conf/opendreambox.conf \
76 $(TOPDIR)/conf/bblayers.conf \
77 $(TOPDIR)/conf/local.conf
80 $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH) \
81 $(DEPDIR)/.opendreambox.conf.$(OPENDREAMBOX_CONF_HASH) \
82 $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH) \
83 $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH)
86 GIT_REMOTE := $(shell $(GIT) remote)
87 GIT_USER_NAME := $(shell $(GIT) config user.name)
88 GIT_USER_EMAIL := $(shell $(GIT) config user.email)
90 hash = $(shell echo $(1) | $(XSUM) | awk '{print $$1}')
96 [ -d $@ ] || $(MAKE) $(MFLAGS) update
98 init: $(BBLAYERS) $(CONFFILES)
101 @echo "Your options:"
103 @echo " * Update the SDK"
104 @echo " $$ $(MAKE) update"
106 @echo " * Build the PDF documentation (doc/opendreambox.pdf, requires pdfTeX):"
107 @echo " $$ $(MAKE) doc"
109 @echo " * View the documentation in text format:"
110 @echo " $$ view doc/opendreambox.txt"
112 @echo " * Select a new target machine:"
113 @echo " $$ echo MACHINE=dm800se >> conf/make.conf"
114 @echo " [Valid values: dm800, dm8000, dm500hd, dm800se, dm7020hd, dm7020hdv2, dm800sev2, dm500hdv2]"
116 @echo " * Build a firmware image for the selected target machine:"
117 @echo " $$ $(MAKE) image"
119 @echo " * Build a firmware image for a different target machine:"
120 @echo " $$ $(MAKE) image MACHINE=dm800se"
121 @echo " [Valid values: dm800, dm8000, dm500hd, dm800se, dm7020hd, dm7020hdv2, dm800sev2, dm500hdv2]"
123 @echo " * Download all source files at once:"
124 @echo " $$ $(MAKE) download"
126 @echo " * Set up the environment to build recipes manually:"
127 @echo " $$ source bitbake.env"
128 @echo " $$ cd build/$(MACHINE)"
129 @echo " $$ bitbake <target>"
130 @echo " [Replace <target> with a recipe name, e.g. $(MAKE_IMAGE_BB) or enigma2]"
132 @echo "Your current settings:"
133 @echo " MACHINE = $(USER_MACHINE)"
135 @echo " BB_NUMBER_THREADS = $(BB_NUMBER_THREADS)"
136 @echo " PARALLEL_MAKE = $(PARALLEL_MAKE)"
138 @echo "Trouble finding a recipe? Try ./scripts/drepo grep 'search string'"
139 @echo "or ./scripts/drepo find -name \"*recipe*\"."
141 @if [ -z "$(GIT_USER_NAME)" -o -z "$(GIT_USER_EMAIL)" ]; then \
142 echo "Before doing any commits, please configure your name and email"; \
143 echo "address using the following commands:"; \
145 echo " $$ $(GIT) config user.name \"Your Name\""; \
146 echo " $$ $(GIT) config user.email \"mail@example.com\""; \
148 echo "Git has been configured for $(GIT_USER_NAME) <$(GIT_USER_EMAIL)>."; \
149 echo "Please submit patches to <enigma2-devel@lists.elitedvb.net>."; \
153 @echo "[*] Please run '$(MAKE) help' to display further information!"
156 @echo '[*] Deleting generated configuration files'
157 @$(RM) $(CONFFILES) $(CONFDEPS)
158 @$(MAKE) $(MFLAGS) -C doc clean
161 @echo '[*] Deleting dependencies directory'
163 @echo '[*] Deleting download directory'
165 @echo '[*] Deleting tmp directory'
167 @echo '[*] Deleting sstate directory'
168 @$(RM) -r $(SSTATE_DIR)
169 @echo '[*] Deleting persistent directory'
170 @$(RM) -r $(PERSISTENT_DIR)
171 @echo '[*] Deleting build directory'
172 @$(RM) -r $(BUILD_DIR)
173 @echo '[*] Deleting git submodules'
174 @$(GIT) submodule foreach 'rm -rf .* * 2>/dev/null || true'
176 sstate-cache-clean: init
177 @echo '[*] Cleaning up sstate-cache'
178 @. $(CURDIR)/bitbake.env && sstate-cache-management.sh --cache-dir=$(SSTATE_DIR) --stamps-dir=$(TMPDIR)/stamps -v || true
181 @$(MAKE) $(MFLAGS) -C doc
184 @echo '[*] Building image for $(USER_MACHINE)'
185 @. $(CURDIR)/bitbake.env && cd $(TOPDIR) && bitbake $(MAKE_IMAGE_BB)
188 @echo '[*] Downloading sources'
189 @. $(CURDIR)/bitbake.env && cd $(TOPDIR) && bitbake -cfetchall -k $(MAKE_IMAGE_BB)
192 @echo '[*] Updating Git repositories...'
193 @HASH=`$(XSUM) $(MAKEFILE_LIST)`; \
194 if [ -n "$(GIT_REMOTE)" ]; then \
195 $(GIT) pull --ff-only || $(GIT) pull --rebase; \
197 if [ "$$HASH" != "`$(XSUM) $(MAKEFILE_LIST)`" ]; then \
198 echo '[*] Makefile changed. Restarting...'; \
199 $(MAKE) $(MFLAGS) --no-print-directory $(MAKECMDGOALS); \
201 $(GIT) submodule sync && \
202 $(GIT) submodule update --init && \
203 echo "[*] The Dreambox SDK is now up-to-date."; \
206 .PHONY: all clean doc help image init update usage
208 MACHINE_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-$(MACHINE)-ext.conf
209 DISTRO_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-ext.conf
211 BITBAKE_ENV_HASH := $(call hash, \
212 'BITBAKE_ENV_VERSION = "0"' \
213 'CURDIR = "$(CURDIR)"' \
216 bitbake.env: $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH)
217 @echo '[*] Generating $@'
218 @echo '# Automatically generated file. Do not edit!' > $@
219 @echo 'export PATH=$(CURDIR)/openembedded-core/scripts:$(CURDIR)/bitbake/bin:$${PATH}' >> $@
221 OPENDREAMBOX_CONF_HASH := $(call hash, \
222 'OPENDREAMBOX_CONF_VERSION = "2"' \
223 'CURDIR = "$(CURDIR)"' \
224 'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' \
225 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' \
226 'DL_DIR = "$(DL_DIR)"' \
227 'PERSISTENT_DIR = "$(PERSISTENT_DIR)"' \
228 'SSTATE_DIR = "$(SSTATE_DIR)"' \
229 'TMPDIR = "$(TMPDIR)"' \
232 conf/opendreambox.conf: $(DEPDIR)/.opendreambox.conf.$(OPENDREAMBOX_CONF_HASH)
233 @echo '[*] Generating $@'
234 @test -d $(@D) || mkdir -p $(@D)
235 @echo '# Automatically generated file. Do not edit!' > $@
236 @echo 'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' >> $@
237 @echo 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' >> $@
238 @echo 'DL_DIR = "$(DL_DIR)"' >> $@
239 @echo 'PERSISTENT_DIR = "$(PERSISTENT_DIR)"' >> $@
240 @echo 'SSTATE_DIR = "$(SSTATE_DIR)"' >> $@
241 @echo 'TMPDIR = "$(TMPDIR)"' >> $@
242 @echo 'BB_GENERATE_MIRROR_TARBALLS = "0"' >> $@
243 @echo 'BBINCLUDELOGS = "yes"' >> $@
244 @echo 'CONF_VERSION = "1"' >> $@
245 @echo 'DISTRO = "opendreambox"' >> $@
246 @echo 'EXTRA_IMAGE_FEATURES = "debug-tweaks"' >> $@
247 @echo 'USER_CLASSES = "buildstats"' >> $@
248 @echo 'PATCHRESOLVE = "noop"' >> $@
249 @echo 'PRSERV_HOST = "localhost:0"' >> $@
251 LOCAL_CONF_HASH := $(call hash, \
252 'LOCAL_CONF_VERSION = "0"' \
253 'CURDIR = "$(CURDIR)"' \
254 'TOPDIR = "$(TOPDIR)"' \
255 'MACHINE = "$(MACHINE)"' \
258 $(TOPDIR)/conf/local.conf: $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH)
259 @echo '[*] Generating $@'
260 @test -d $(@D) || mkdir -p $(@D)
261 @echo '# Automatically generated file. Do not edit!' > $@
262 @echo 'TOPDIR = "$(TOPDIR)"' >> $@
263 @echo 'MACHINE = "$(MACHINE)"' >> $@
264 @echo 'require $(CURDIR)/conf/opendreambox.conf' >> $@
265 @echo 'include $(DISTRO_INCLUDE_CONF)' >> $@
266 @echo 'include $(MACHINE_INCLUDE_CONF)' >> $@
268 BBLAYERS_CONF_HASH := $(call hash, \
269 'BBLAYERS_CONF_VERSION = "0"' \
270 'CURDIR = "$(CURDIR)"' \
271 'BBLAYERS = "$(BBLAYERS)"' \
274 $(TOPDIR)/conf/bblayers.conf: $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH)
275 @echo '[*] Generating $@'
276 @test -d $(@D) || mkdir -p $(@D)
277 @echo '# Automatically generated file. Do not edit!' > $@
278 @echo 'LCONF_VERSION = "4"' >> $@
279 @echo 'BBFILES = ""' >> $@
280 @echo 'BBLAYERS = "$(BBLAYERS)"' >> $@
281 @echo 'include $(DISTRO_INCLUDE_CONF)' >> $@
282 @echo 'include $(MACHINE_INCLUDE_CONF)' >> $@
285 @test -d $(@D) || mkdir -p $(@D)
286 @$(RM) $(basename $@).*