dreambox-dvb-modules: update dm7020hd, dm8000, dm800se, dm500hd hw drivers to 20120711
[opendreambox.git] / Makefile
1 #!/usr/bin/make -f
2 #
3 # Copyright (c) 2010-2012 Dream Multimedia GmbH, Germany
4 #                         http://www.dream-multimedia-tv.de/
5 # Authors:
6 #   Andreas Oberritter <obi@opendreambox.org>
7 #
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:
14 #
15 # The above copyright notice and this permission notice shall be included in
16 # all copies or substantial portions of the Software.
17 #
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
24 # THE SOFTWARE.
25 #
26
27 # Note: You can override all variables by storing them
28 # in an external file called "make.conf".
29 -include conf/make.conf
30
31 # Target platform:
32 # dm500hd, dm800, dm800se, dm7020hd, dm8000
33 #
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.
37 MACHINE ?= dm7020hd
38
39 # Adjust according to the number CPU cores to use for parallel build.
40 # Default: Number of processors in /proc/cpuinfo, if present, or 1.
41 NR_CPU := $(shell [ -f /proc/cpuinfo ] && grep -c '^processor\s*:' /proc/cpuinfo || echo 1)
42 BB_NUMBER_THREADS ?= $(NR_CPU)
43 PARALLEL_MAKE ?= -j $(NR_CPU)
44
45 XSUM ?= md5sum
46
47 BUILD_DIR = $(CURDIR)/build
48 TOPDIR = $(BUILD_DIR)/$(MACHINE)
49 DL_DIR = $(CURDIR)/sources
50 SSTATE_DIR = $(CURDIR)/sstate-cache
51 TMPDIR = $(CURDIR)/tmp
52 DEPDIR = $(CURDIR)/.deps
53
54 BBLAYERS ?= \
55         $(CURDIR)/meta-bsp/$(MACHINE) \
56         $(CURDIR)/meta-bsp/common \
57         $(CURDIR)/meta-opendreambox \
58         $(CURDIR)/meta-openembedded/meta-oe \
59         $(CURDIR)/openembedded-core/meta
60
61 CONFFILES = \
62         bitbake.env \
63         conf/opendreambox.conf \
64         $(TOPDIR)/conf/bblayers.conf \
65         $(TOPDIR)/conf/local.conf
66
67 CONFDEPS = \
68         $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH) \
69         $(DEPDIR)/.opendreambox.conf.$(OPENDREAMBOX_CONF_HASH) \
70         $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH) \
71         $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH)
72
73 GIT ?= git
74 GIT_REMOTE := $(shell $(GIT) remote)
75 GIT_USER_NAME := $(shell $(GIT) config user.name)
76 GIT_USER_EMAIL := $(shell $(GIT) config user.email)
77
78 hash = $(shell echo $(1) | $(XSUM) | awk '{print $$1}')
79
80 .DEFAULT_GOAL := all
81 all: init usage
82
83 $(BBLAYERS):
84         [ -d $@ ] || $(MAKE) $(MFLAGS) update
85
86 init: $(BBLAYERS) $(CONFFILES)
87
88 help:
89         @echo "Your options:"
90         @echo
91         @echo "  * Update the SDK"
92         @echo "      $$ $(MAKE) update"
93         @echo
94         @echo "  * Build the PDF documentation (doc/opendreambox.pdf, requires pdfTeX):"
95         @echo "      $$ $(MAKE) doc"
96         @echo
97         @echo "  * View the documentation in text format:"
98         @echo "      $$ view doc/opendreambox.txt"
99         @echo
100         @echo "  * Select a new target machine:"
101         @echo "      $$ echo MACHINE=dm800se >> conf/make.conf"
102         @echo "    [Valid values: dm500hd, dm800, dm800se, dm7020hd, dm8000]"
103         @echo
104         @echo "  * Build a firmware image for the selected target machine:"
105         @echo "      $$ $(MAKE) image"
106         @echo
107         @echo "  * Build a firmware image for a different target machine:"
108         @echo "      $$ $(MAKE) image MACHINE=dm800se"
109         @echo "    [Valid values: dm500hd, dm800, dm800se, dm7020hd, dm8000]"
110         @echo
111         @echo "  * Download all source files at once:"
112         @echo "      $$ $(MAKE) download"
113         @echo
114         @echo "  * Set up the environment to build recipes manually:"
115         @echo "      $$ source bitbake.env"
116         @echo "      $$ cd build/$(MACHINE)"
117         @echo "      $$ bitbake <target>"
118         @echo "    [Replace <target> with a recipe name, e.g. dreambox-image or enigma2]"
119         @echo
120         @echo "Your current settings:"
121         @echo "  MACHINE = $(MACHINE)"
122         @echo
123         @echo "  BB_NUMBER_THREADS = $(BB_NUMBER_THREADS)"
124         @echo "  PARALLEL_MAKE = $(PARALLEL_MAKE)"
125         @echo
126         @echo "Trouble finding a recipe? Try ./scripts/drepo grep 'search string'"
127         @echo "or ./scripts/drepo find -name \"*recipe*\"."
128         @echo
129         @if [ -z "$(GIT_USER_NAME)" -o -z "$(GIT_USER_EMAIL)" ]; then \
130                 echo "Before doing any commits, please configure your name and email"; \
131                 echo "address using the following commands:"; \
132                 echo; \
133                 echo "  $$ $(GIT) config user.name \"Your Name\""; \
134                 echo "  $$ $(GIT) config user.email \"mail@example.com\""; \
135         else \
136                 echo "Git has been configured for $(GIT_USER_NAME) <$(GIT_USER_EMAIL)>."; \
137                 echo "Please submit patches to <enigma2-devel@lists.elitedvb.net>."; \
138         fi
139
140 usage:
141         @echo "[*] Please run '$(MAKE) help' to display further information!"
142
143 clean:
144         @echo '[*] Deleting generated configuration files'
145         @$(RM) $(CONFFILES) $(CONFDEPS)
146         @$(MAKE) $(MFLAGS) -C doc clean
147
148 distclean: clean
149         @echo '[*] Deleting dependencies directory'
150         @$(RM) -r $(DEPDIR)
151         @echo '[*] Deleting download directory'
152         @$(RM) -r $(DL_DIR)
153         @echo '[*] Deleting tmp directory'
154         @$(RM) -r $(TMPDIR)
155         @echo '[*] Deleting sstate directory'
156         @$(RM) -r $(SSTATE_DIR)
157         @echo '[*] Deleting build directory'
158         @$(RM) -r $(BUILD_DIR)
159         @echo '[*] Deleting git submodules'
160         @$(GIT) submodule foreach 'rm -rf .* * 2>/dev/null || true'
161
162 doc:
163         @$(MAKE) $(MFLAGS) -C doc
164
165 image: init
166         @echo '[*] Building image for $(MACHINE)'
167         @. $(CURDIR)/bitbake.env && cd $(TOPDIR) && bitbake dreambox-image
168
169 download: init
170         @echo '[*] Downloading sources'
171         @. $(CURDIR)/bitbake.env && cd $(TOPDIR) && bitbake -cfetchall -k dreambox-image
172
173 update:
174         @echo '[*] Updating Git repositories...'
175         @HASH=`$(XSUM) $(MAKEFILE_LIST)`; \
176         if [ -n "$(GIT_REMOTE)" ]; then \
177                 $(GIT) pull --ff-only || $(GIT) pull --rebase; \
178         fi; \
179         if [ "$$HASH" != "`$(XSUM) $(MAKEFILE_LIST)`" ]; then \
180                 echo '[*] Makefile changed. Restarting...'; \
181                 $(MAKE) $(MFLAGS) --no-print-directory $(MAKECMDGOALS); \
182         else \
183                 $(GIT) submodule sync && \
184                 $(GIT) submodule update --init && \
185                 echo "[*] The Dreambox SDK is now up-to-date."; \
186         fi
187
188 .PHONY: all clean doc help image init update usage
189
190 MACHINE_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-$(MACHINE)-ext.conf
191 DISTRO_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-ext.conf
192
193 BITBAKE_ENV_HASH := $(call hash, \
194         'BITBAKE_ENV_VERSION = "0"' \
195         'CURDIR = "$(CURDIR)"' \
196         )
197
198 bitbake.env: $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH)
199         @echo '[*] Generating $@'
200         @echo '# Automatically generated file. Do not edit!' > $@
201         @echo 'export PATH=$(CURDIR)/openembedded-core/scripts:$(CURDIR)/bitbake/bin:$${PATH}' >> $@
202
203 OPENDREAMBOX_CONF_HASH := $(call hash, \
204         'OPENDREAMBOX_CONF_VERSION = "1"' \
205         'CURDIR = "$(CURDIR)"' \
206         'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' \
207         'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' \
208         'DL_DIR = "$(DL_DIR)"' \
209         'SSTATE_DIR = "$(SSTATE_DIR)"' \
210         'TMPDIR = "$(TMPDIR)"' \
211         )
212
213 conf/opendreambox.conf: $(DEPDIR)/.opendreambox.conf.$(OPENDREAMBOX_CONF_HASH)
214         @echo '[*] Generating $@'
215         @test -d $(@D) || mkdir -p $(@D)
216         @echo '# Automatically generated file. Do not edit!' > $@
217         @echo 'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' >> $@
218         @echo 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' >> $@
219         @echo 'DL_DIR = "$(DL_DIR)"' >> $@
220         @echo 'SSTATE_DIR = "$(SSTATE_DIR)"' >> $@
221         @echo 'TMPDIR = "$(TMPDIR)"' >> $@
222         @echo 'BB_GENERATE_MIRROR_TARBALLS = "0"' >> $@
223         @echo 'BBINCLUDELOGS = "yes"' >> $@
224         @echo 'CONF_VERSION = "1"' >> $@
225         @echo 'DISTRO = "opendreambox"' >> $@
226         @echo 'EXTRA_IMAGE_FEATURES = "debug-tweaks"' >> $@
227         @echo 'USER_CLASSES = "buildstats"' >> $@
228
229 LOCAL_CONF_HASH := $(call hash, \
230         'LOCAL_CONF_VERSION = "0"' \
231         'CURDIR = "$(CURDIR)"' \
232         'TOPDIR = "$(TOPDIR)"' \
233         'MACHINE = "$(MACHINE)"' \
234         )
235
236 $(TOPDIR)/conf/local.conf: $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH)
237         @echo '[*] Generating $@'
238         @test -d $(@D) || mkdir -p $(@D)
239         @echo '# Automatically generated file. Do not edit!' > $@
240         @echo 'TOPDIR = "$(TOPDIR)"' >> $@
241         @echo 'MACHINE = "$(MACHINE)"' >> $@
242         @echo 'require $(CURDIR)/conf/opendreambox.conf' >> $@
243         @echo 'include $(DISTRO_INCLUDE_CONF)' >> $@
244         @echo 'include $(MACHINE_INCLUDE_CONF)' >> $@
245
246 BBLAYERS_CONF_HASH := $(call hash, \
247         'BBLAYERS_CONF_VERSION = "0"' \
248         'CURDIR = "$(CURDIR)"' \
249         'BBLAYERS = "$(BBLAYERS)"' \
250         )
251
252 $(TOPDIR)/conf/bblayers.conf: $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH)
253         @echo '[*] Generating $@'
254         @test -d $(@D) || mkdir -p $(@D)
255         @echo '# Automatically generated file. Do not edit!' > $@
256         @echo 'LCONF_VERSION = "4"' >> $@
257         @echo 'BBFILES = ""' >> $@
258         @echo 'BBLAYERS = "$(BBLAYERS)"' >> $@
259         @echo 'include $(DISTRO_INCLUDE_CONF)' >> $@
260         @echo 'include $(MACHINE_INCLUDE_CONF)' >> $@
261
262 $(CONFDEPS):
263         @test -d $(@D) || mkdir -p $(@D)
264         @$(RM) $(basename $@).*
265         @touch $@