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)
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 SSTATE_DIR = $(CURDIR)/sstate-cache
60 TMPDIR = $(CURDIR)/tmp
61 DEPDIR = $(CURDIR)/.deps
64 $(CURDIR)/meta-bsp/$(MACHINE) \
65 $(CURDIR)/meta-bsp/common \
66 $(CURDIR)/meta-opendreambox \
67 $(CURDIR)/meta-openembedded/meta-oe \
68 $(CURDIR)/openembedded-core/meta
72 conf/opendreambox.conf \
73 $(TOPDIR)/conf/bblayers.conf \
74 $(TOPDIR)/conf/local.conf
77 $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH) \
78 $(DEPDIR)/.opendreambox.conf.$(OPENDREAMBOX_CONF_HASH) \
79 $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH) \
80 $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH)
83 GIT_REMOTE := $(shell $(GIT) remote)
84 GIT_USER_NAME := $(shell $(GIT) config user.name)
85 GIT_USER_EMAIL := $(shell $(GIT) config user.email)
87 hash = $(shell echo $(1) | $(XSUM) | awk '{print $$1}')
93 [ -d $@ ] || $(MAKE) $(MFLAGS) update
95 init: $(BBLAYERS) $(CONFFILES)
100 @echo " * Update the SDK"
101 @echo " $$ $(MAKE) update"
103 @echo " * Build the PDF documentation (doc/opendreambox.pdf, requires pdfTeX):"
104 @echo " $$ $(MAKE) doc"
106 @echo " * View the documentation in text format:"
107 @echo " $$ view doc/opendreambox.txt"
109 @echo " * Select a new target machine:"
110 @echo " $$ echo MACHINE=dm800se >> conf/make.conf"
111 @echo " [Valid values: dm800, dm8000, dm500hd, dm800se, dm7020hd, dm7020hdv2, dm800sev2, dm500hdv2]"
113 @echo " * Build a firmware image for the selected target machine:"
114 @echo " $$ $(MAKE) image"
116 @echo " * Build a firmware image for a different target machine:"
117 @echo " $$ $(MAKE) image MACHINE=dm800se"
118 @echo " [Valid values: dm800, dm8000, dm500hd, dm800se, dm7020hd, dm7020hdv2, dm800sev2, dm500hdv2]"
120 @echo " * Download all source files at once:"
121 @echo " $$ $(MAKE) download"
123 @echo " * Set up the environment to build recipes manually:"
124 @echo " $$ source bitbake.env"
125 @echo " $$ cd build/$(MACHINE)"
126 @echo " $$ bitbake <target>"
127 @echo " [Replace <target> with a recipe name, e.g. $(MAKE_IMAGE_BB) or enigma2]"
129 @echo "Your current settings:"
130 @echo " MACHINE = $(USER_MACHINE)"
132 @echo " BB_NUMBER_THREADS = $(BB_NUMBER_THREADS)"
133 @echo " PARALLEL_MAKE = $(PARALLEL_MAKE)"
135 @echo "Trouble finding a recipe? Try ./scripts/drepo grep 'search string'"
136 @echo "or ./scripts/drepo find -name \"*recipe*\"."
138 @if [ -z "$(GIT_USER_NAME)" -o -z "$(GIT_USER_EMAIL)" ]; then \
139 echo "Before doing any commits, please configure your name and email"; \
140 echo "address using the following commands:"; \
142 echo " $$ $(GIT) config user.name \"Your Name\""; \
143 echo " $$ $(GIT) config user.email \"mail@example.com\""; \
145 echo "Git has been configured for $(GIT_USER_NAME) <$(GIT_USER_EMAIL)>."; \
146 echo "Please submit patches to <enigma2-devel@lists.elitedvb.net>."; \
150 @echo "[*] Please run '$(MAKE) help' to display further information!"
153 @echo '[*] Deleting generated configuration files'
154 @$(RM) $(CONFFILES) $(CONFDEPS)
155 @$(MAKE) $(MFLAGS) -C doc clean
158 @echo '[*] Deleting dependencies directory'
160 @echo '[*] Deleting download directory'
162 @echo '[*] Deleting tmp directory'
164 @echo '[*] Deleting sstate directory'
165 @$(RM) -r $(SSTATE_DIR)
166 @echo '[*] Deleting build directory'
167 @$(RM) -r $(BUILD_DIR)
168 @echo '[*] Deleting git submodules'
169 @$(GIT) submodule foreach 'rm -rf .* * 2>/dev/null || true'
172 @$(MAKE) $(MFLAGS) -C doc
175 @echo '[*] Building image for $(USER_MACHINE)'
176 @. $(CURDIR)/bitbake.env && cd $(TOPDIR) && bitbake $(MAKE_IMAGE_BB)
179 @echo '[*] Downloading sources'
180 @. $(CURDIR)/bitbake.env && cd $(TOPDIR) && bitbake -cfetchall -k $(MAKE_IMAGE_BB)
183 @echo '[*] Updating Git repositories...'
184 @HASH=`$(XSUM) $(MAKEFILE_LIST)`; \
185 if [ -n "$(GIT_REMOTE)" ]; then \
186 $(GIT) pull --ff-only || $(GIT) pull --rebase; \
188 if [ "$$HASH" != "`$(XSUM) $(MAKEFILE_LIST)`" ]; then \
189 echo '[*] Makefile changed. Restarting...'; \
190 $(MAKE) $(MFLAGS) --no-print-directory $(MAKECMDGOALS); \
192 $(GIT) submodule sync && \
193 $(GIT) submodule update --init && \
194 echo "[*] The Dreambox SDK is now up-to-date."; \
197 .PHONY: all clean doc help image init update usage
199 MACHINE_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-$(MACHINE)-ext.conf
200 DISTRO_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-ext.conf
202 BITBAKE_ENV_HASH := $(call hash, \
203 'BITBAKE_ENV_VERSION = "0"' \
204 'CURDIR = "$(CURDIR)"' \
207 bitbake.env: $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH)
208 @echo '[*] Generating $@'
209 @echo '# Automatically generated file. Do not edit!' > $@
210 @echo 'export PATH=$(CURDIR)/openembedded-core/scripts:$(CURDIR)/bitbake/bin:$${PATH}' >> $@
212 OPENDREAMBOX_CONF_HASH := $(call hash, \
213 'OPENDREAMBOX_CONF_VERSION = "1"' \
214 'CURDIR = "$(CURDIR)"' \
215 'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' \
216 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' \
217 'DL_DIR = "$(DL_DIR)"' \
218 'SSTATE_DIR = "$(SSTATE_DIR)"' \
219 'TMPDIR = "$(TMPDIR)"' \
222 conf/opendreambox.conf: $(DEPDIR)/.opendreambox.conf.$(OPENDREAMBOX_CONF_HASH)
223 @echo '[*] Generating $@'
224 @test -d $(@D) || mkdir -p $(@D)
225 @echo '# Automatically generated file. Do not edit!' > $@
226 @echo 'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' >> $@
227 @echo 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' >> $@
228 @echo 'DL_DIR = "$(DL_DIR)"' >> $@
229 @echo 'SSTATE_DIR = "$(SSTATE_DIR)"' >> $@
230 @echo 'TMPDIR = "$(TMPDIR)"' >> $@
231 @echo 'BB_GENERATE_MIRROR_TARBALLS = "0"' >> $@
232 @echo 'BBINCLUDELOGS = "yes"' >> $@
233 @echo 'CONF_VERSION = "1"' >> $@
234 @echo 'DISTRO = "opendreambox"' >> $@
235 @echo 'EXTRA_IMAGE_FEATURES = "debug-tweaks"' >> $@
236 @echo 'USER_CLASSES = "buildstats"' >> $@
238 LOCAL_CONF_HASH := $(call hash, \
239 'LOCAL_CONF_VERSION = "0"' \
240 'CURDIR = "$(CURDIR)"' \
241 'TOPDIR = "$(TOPDIR)"' \
242 'MACHINE = "$(MACHINE)"' \
245 $(TOPDIR)/conf/local.conf: $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH)
246 @echo '[*] Generating $@'
247 @test -d $(@D) || mkdir -p $(@D)
248 @echo '# Automatically generated file. Do not edit!' > $@
249 @echo 'TOPDIR = "$(TOPDIR)"' >> $@
250 @echo 'MACHINE = "$(MACHINE)"' >> $@
251 @echo 'require $(CURDIR)/conf/opendreambox.conf' >> $@
252 @echo 'include $(DISTRO_INCLUDE_CONF)' >> $@
253 @echo 'include $(MACHINE_INCLUDE_CONF)' >> $@
255 BBLAYERS_CONF_HASH := $(call hash, \
256 'BBLAYERS_CONF_VERSION = "0"' \
257 'CURDIR = "$(CURDIR)"' \
258 'BBLAYERS = "$(BBLAYERS)"' \
261 $(TOPDIR)/conf/bblayers.conf: $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH)
262 @echo '[*] Generating $@'
263 @test -d $(@D) || mkdir -p $(@D)
264 @echo '# Automatically generated file. Do not edit!' > $@
265 @echo 'LCONF_VERSION = "4"' >> $@
266 @echo 'BBFILES = ""' >> $@
267 @echo 'BBLAYERS = "$(BBLAYERS)"' >> $@
268 @echo 'include $(DISTRO_INCLUDE_CONF)' >> $@
269 @echo 'include $(MACHINE_INCLUDE_CONF)' >> $@
272 @test -d $(@D) || mkdir -p $(@D)
273 @$(RM) $(basename $@).*