update driver(duo4k)
[vuplus_openvuplus_3.0] / Makefile
1 #!/usr/bin/make -f
2 #
3 # Permission is hereby granted, free of charge, to any person obtaining a copy
4 # of this software and associated documentation files (the "Software"), to deal
5 # in the Software without restriction, including without limitation the rights
6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 # copies of the Software, and to permit persons to whom the Software is
8 # furnished to do so, subject to the following conditions:
9 #
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
12 #
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 # THE SOFTWARE.
20 #
21
22 SHELL=/bin/bash
23
24 # Note: You can override all variables by storing them
25 # in an external file called "make.conf".
26 -include conf/make.conf
27
28 # Target platform:
29 # vusolo, bm750, vuuno, vuultimo, vusolo2
30 #
31 # This only sets the default value. All platforms now use a shared build
32 # directory. Run "MACHINE=vuultimo bitbake vuplus-image" to build an image
33 # for the vuultimo, if it is not the default.
34 MACHINE ?= vuuno4k
35
36 MULTI_TEMPORARILY ?= YES
37
38 # Adjust according to the number CPU cores to use for parallel build.
39 # Default: Number of processors in /proc/cpuinfo, if present, or 1.
40 NR_CPU := $(shell [ -f /proc/cpuinfo ] && grep -c '^processor\s*:' /proc/cpuinfo || echo 1)
41 BB_NUMBER_THREADS ?= $(NR_CPU)
42 PARALLEL_MAKE ?= -j $(NR_CPU)
43
44 XSUM ?= md5sum
45
46 BUILD_DIR = $(CURDIR)/build
47 TOPDIR = $(BUILD_DIR)/$(MACHINE)
48 DL_DIR = $(CURDIR)/sources
49
50 ifeq ($(MULTI_TEMPORARILY), YES)
51 SSTATE_DIR = $(TOPDIR)/sstate-cache
52 TMPDIR = $(TOPDIR)/tmp
53 DEPDIR = $(TOPDIR)/.deps
54 else
55 SSTATE_DIR = $(BUILD_DIR)/sstate-cache
56 TMPDIR = $(BUILD_DIR)/tmp
57 DEPDIR = $(BUILD_DIR)/.deps
58 endif
59
60 BBLAYERS ?= \
61         $(CURDIR)/meta-bsp \
62         $(CURDIR)/meta-openvuplus \
63         $(CURDIR)/meta-openembedded/meta-oe \
64         $(CURDIR)/meta-openembedded/meta-networking \
65         $(CURDIR)/meta-openembedded/meta-multimedia \
66         $(CURDIR)/meta-openembedded/meta-filesystems \
67         $(CURDIR)/meta-openembedded/meta-python \
68         $(CURDIR)/openembedded-core/meta
69
70 CONFFILES = \
71         $(TOPDIR)/bitbake.env \
72         $(TOPDIR)/conf/bblayers.conf \
73         $(TOPDIR)/conf/local.conf
74
75 CONFDEPS = \
76         $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH) \
77         $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH) \
78         $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH)
79
80 GIT ?= git
81 GIT_REMOTE := $(shell $(GIT) remote)
82 GIT_USER_NAME := $(shell $(GIT) config user.name)
83 GIT_USER_EMAIL := $(shell $(GIT) config user.email)
84
85 hash = $(shell echo $(1) | $(XSUM) | awk '{print $$1}')
86
87 .DEFAULT_GOAL := all
88 all: init usage
89
90 $(BBLAYERS):
91         [ -d $@ ] || $(MAKE) $(MFLAGS) update
92
93 init: $(BBLAYERS) $(CONFFILES)
94         @if [ ! -e $(CURDIR)/sources ]; then mkdir -p $(CURDIR)/sources; fi
95
96 help:
97         @echo "Your options:"
98         @echo
99         @echo "  * Update the SDK"
100         @echo "      $$ $(MAKE) update"
101         @echo
102         @echo "  * Select a new target machine:"
103         @echo "      $$ echo MACHINE=vuultimo >> conf/make.conf"
104         @echo "    [Valid values: vusolo, bm750, vuuno, vuultimo, vusolo2]"
105         @echo
106         @echo "  * Build a firmware image for the selected target machine:"
107         @echo "      $$ $(MAKE) image"
108         @echo
109         @echo "  * Build a firmware image for a different target machine:"
110         @echo "      $$ $(MAKE) image MACHINE=vuultimo"
111         @echo "    [Valid values: vusolo, bm750, vuuno, vuultimo, vusolo2]"
112         @echo
113         @echo "  * Download all source files at once:"
114         @echo "      $$ $(MAKE) download"
115         @echo
116         @echo "  * Set up the environment to build recipes manually:"
117         @echo "      $$ cd $(BUILD_DIR)"
118         @echo "      $$ source bitbake.env"
119         @echo "      $$ bitbake <target>"
120         @echo "    [Replace <target> with a recipe name, e.g. vuplus-image or enigma2]"
121         @echo
122         @echo "Your current settings:"
123         @echo "  MACHINE = $(MACHINE)"
124         @echo
125         @echo "  BB_NUMBER_THREADS = $(BB_NUMBER_THREADS)"
126         @echo "  PARALLEL_MAKE = $(PARALLEL_MAKE)"
127         @echo
128         @echo "Trouble finding a recipe? Try ./scripts/drepo grep 'search string'"
129         @echo "or ./scripts/drepo find -name \"*recipe*\"."
130         @echo
131
132 usage:
133         @echo "[*] Please run '$(MAKE) help' to display further information!"
134
135 clean:
136         @echo '[*] Deleting generated configuration files'
137         @$(RM) $(CONFFILES) $(CONFDEPS)
138
139 distclean: clean
140         @echo '[*] Deleting dependencies directory'
141         @$(RM) -r $(DEPDIR)
142         @echo '[*] Deleting download directory'
143         @$(RM) -r $(DL_DIR)
144         @echo '[*] Deleting tmp directory'
145         @$(RM) -r $(TMPDIR)
146         @echo '[*] Deleting sstate directory'
147         @$(RM) -r $(SSTATE_DIR)
148         @echo '[*] Deleting build directory'
149         @$(RM) -r $(BUILD_DIR)
150         @echo '[*] Deleting git submodules'
151         @$(GIT) submodule foreach 'rm -rf .* * 2>/dev/null || true'
152
153 image: init
154         @echo '[*] Building image for $(MACHINE)'
155         @. $(TOPDIR)/bitbake.env && cd $(TOPDIR) && bitbake vuplus-image
156
157 download: init
158         @echo '[*] Downloading sources'
159         @. $(TOPDIR)/bitbake.env && cd $(TOPDIR) && bitbake -cfetchall -k vuplus-image
160
161 update:
162         @echo '[*] Updating Git repositories...'
163         @HASH=`$(XSUM) $(MAKEFILE_LIST)`; \
164         if [ -n "$(GIT_REMOTE)" ]; then \
165                 $(GIT) pull --ff-only || $(GIT) pull --rebase; \
166         fi; \
167         if [ "$$HASH" != "`$(XSUM) $(MAKEFILE_LIST)`" ]; then \
168                 echo '[*] Makefile changed. Restarting...'; \
169                 $(MAKE) $(MFLAGS) --no-print-directory $(MAKECMDGOALS); \
170         else \
171                 $(GIT) submodule sync && \
172                 $(GIT) submodule update --init && \
173                 echo "[*] The Vuplus SDK is now up-to-date."; \
174         fi
175
176 .PHONY: all clean help image init update usage
177
178 MACHINE_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-$(MACHINE)-ext.conf
179 DISTRO_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-ext.conf
180
181 BITBAKE_ENV_HASH := $(call hash, \
182         'BITBAKE_ENV_VERSION = "0"' \
183         'CURDIR = "$(CURDIR)"' \
184         )
185
186 $(TOPDIR)/bitbake.env: $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH)
187         @echo '[*] Generating $@'
188         @test -d $(@D) || mkdir -p $(@D)
189         @echo '# Automatically generated file. Do not edit!' > $@
190         @echo 'export PATH=$(CURDIR)/openembedded-core/scripts:$(CURDIR)/bitbake/bin:$${PATH}' >> $@
191
192 LOCAL_CONF_HASH := $(call hash, \
193         'LOCAL_CONF_VERSION = "0"' \
194         'CURDIR = "$(CURDIR)"' \
195         'TOPDIR = "$(TOPDIR)"' \
196         'MACHINE = "$(MACHINE)"' \
197         'OPENVUPLUS_CONF_VERSION = "1"' \
198         'CURDIR = "$(CURDIR)"' \
199         'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' \
200         'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' \
201         'DL_DIR = "$(DL_DIR)"' \
202         'SSTATE_DIR = "$(SSTATE_DIR)"' \
203         'TMPDIR = "$(TMPDIR)"' \
204         )
205
206 $(TOPDIR)/conf/local.conf: $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH)
207         @echo '[*] Generating $@'
208         @test -d $(@D) || mkdir -p $(@D)
209         @echo '# Automatically generated file. Do not edit!' > $@
210         @echo 'TOPDIR = "$(TOPDIR)"' >> $@
211         @echo 'MACHINE = "$(MACHINE)"' >> $@
212         @echo 'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' >> $@
213         @echo 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' >> $@
214         @echo 'DL_DIR = "$(DL_DIR)"' >> $@
215         @echo 'SSTATE_DIR = "$(SSTATE_DIR)"' >> $@
216         @echo 'TMPDIR = "$(TMPDIR)"' >> $@
217         @echo 'BB_GENERATE_MIRROR_TARBALLS = "0"' >> $@
218         @echo 'BBINCLUDELOGS = "yes"' >> $@
219         @echo 'CONF_VERSION = "1"' >> $@
220         @echo 'DISTRO = "vuplus"' >> $@
221         @echo 'EXTRA_IMAGE_FEATURES = "debug-tweaks"' >> $@
222         @echo 'USER_CLASSES = "buildstats"' >> $@
223         @echo 'include $(DISTRO_INCLUDE_CONF)' >> $@
224         @echo 'include $(MACHINE_INCLUDE_CONF)' >> $@
225         @if [ "$(MULTI_TEMPORARILY)" == "YES" ] ; then \
226                 echo "DEPLOY_DIR_IMAGE = \"\$${DEPLOY_DIR}/images\"" >> $@; \
227         fi
228         @echo 'INHERIT += "rm_work"' >> $@
229
230 BBLAYERS_CONF_HASH := $(call hash, \
231         'BBLAYERS_CONF_VERSION = "0"' \
232         'CURDIR = "$(CURDIR)"' \
233         'BBLAYERS = "$(BBLAYERS)"' \
234         )
235
236 $(TOPDIR)/conf/bblayers.conf: $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH)
237         @echo '[*] Generating $@'
238         @test -d $(@D) || mkdir -p $(@D)
239         @echo '# Automatically generated file. Do not edit!' > $@
240         @echo 'LCONF_VERSION = "4"' >> $@
241         @echo 'BBFILES = ""' >> $@
242         @echo 'BBLAYERS = "$(BBLAYERS)"' >> $@
243         @echo 'include $(DISTRO_INCLUDE_CONF)' >> $@
244         @echo 'include $(MACHINE_INCLUDE_CONF)' >> $@
245
246 $(CONFDEPS):
247         @test -d $(@D) || mkdir -p $(@D)
248         @$(RM) $(basename $@).*
249         @touch $@