use fixed SRCREV 1e99787f3387d3dd1e6167af73597674bf8fe37d.
[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 # Note: You can override all variables by storing them
23 # in an external file called "make.conf".
24 -include conf/make.conf
25
26 # Target platform:
27 # vusolo, bm750, vuuno, vuultimo, vusolo2
28 #
29 # This only sets the default value. All platforms now use a shared build
30 # directory. Run "MACHINE=vuultimo bitbake vuplus-image" to build an image
31 # for the vuultimo, if it is not the default.
32 MACHINE ?= vusolose
33
34 MULTI_TEMPORARILY ?= NO
35
36 # Adjust according to the number CPU cores to use for parallel build.
37 # Default: Number of processors in /proc/cpuinfo, if present, or 1.
38 NR_CPU := $(shell [ -f /proc/cpuinfo ] && grep -c '^processor\s*:' /proc/cpuinfo || echo 1)
39 BB_NUMBER_THREADS ?= $(NR_CPU)
40 PARALLEL_MAKE ?= -j $(NR_CPU)
41
42 XSUM ?= md5sum
43
44 BUILD_DIR = $(CURDIR)/build
45 TOPDIR = $(BUILD_DIR)/$(MACHINE)
46 DL_DIR = $(CURDIR)/sources
47
48 ifeq ($(MULTI_TEMPORARILY), YES)
49 SSTATE_DIR = $(TOPDIR)/sstate-cache
50 TMPDIR = $(TOPDIR)/tmp
51 DEPDIR = $(TOPDIR)/.deps
52 else
53 SSTATE_DIR = $(BUILD_DIR)/sstate-cache
54 TMPDIR = $(BUILD_DIR)/tmp
55 DEPDIR = $(BUILD_DIR)/.deps
56 endif
57
58 BBLAYERS ?= \
59         $(CURDIR)/meta-bsp/$(MACHINE) \
60         $(CURDIR)/meta-bsp/common \
61         $(CURDIR)/meta-openvuplus \
62         $(CURDIR)/meta-openembedded/meta-oe \
63         $(CURDIR)/meta-openembedded/meta-networking \
64         $(CURDIR)/meta-openembedded/meta-multimedia \
65         $(CURDIR)/meta-openembedded/meta-filesystems \
66         $(CURDIR)/meta-openembedded/meta-python \
67         $(CURDIR)/openembedded-core/meta
68
69 CONFFILES = \
70         $(TOPDIR)/bitbake.env \
71         $(TOPDIR)/conf/bblayers.conf \
72         $(TOPDIR)/conf/local.conf
73
74 CONFDEPS = \
75         $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH) \
76         $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH) \
77         $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH)
78
79 GIT ?= git
80 GIT_REMOTE := $(shell $(GIT) remote)
81 GIT_USER_NAME := $(shell $(GIT) config user.name)
82 GIT_USER_EMAIL := $(shell $(GIT) config user.email)
83
84 hash = $(shell echo $(1) | $(XSUM) | awk '{print $$1}')
85
86 .DEFAULT_GOAL := all
87 all: init usage
88
89 $(BBLAYERS):
90         [ -d $@ ] || $(MAKE) $(MFLAGS) update
91
92 init: $(BBLAYERS) $(CONFFILES)
93         @if [ ! -e $(CURDIR)/sources ]; then mkdir -p $(CURDIR)/sources; fi
94
95 help:
96         @echo "Your options:"
97         @echo
98         @echo "  * Update the SDK"
99         @echo "      $$ $(MAKE) update"
100         @echo
101         @echo "  * Select a new target machine:"
102         @echo "      $$ echo MACHINE=vuultimo >> conf/make.conf"
103         @echo "    [Valid values: vusolo, bm750, vuuno, vuultimo, vusolo2]"
104         @echo
105         @echo "  * Build a firmware image for the selected target machine:"
106         @echo "      $$ $(MAKE) image"
107         @echo
108         @echo "  * Build a firmware image for a different target machine:"
109         @echo "      $$ $(MAKE) image MACHINE=vuultimo"
110         @echo "    [Valid values: vusolo, bm750, vuuno, vuultimo, vusolo2]"
111         @echo
112         @echo "  * Download all source files at once:"
113         @echo "      $$ $(MAKE) download"
114         @echo
115         @echo "  * Set up the environment to build recipes manually:"
116         @echo "      $$ cd $(BUILD_DIR)"
117         @echo "      $$ source bitbake.env"
118         @echo "      $$ bitbake <target>"
119         @echo "    [Replace <target> with a recipe name, e.g. vuplus-image or enigma2]"
120         @echo
121         @echo "Your current settings:"
122         @echo "  MACHINE = $(MACHINE)"
123         @echo
124         @echo "  BB_NUMBER_THREADS = $(BB_NUMBER_THREADS)"
125         @echo "  PARALLEL_MAKE = $(PARALLEL_MAKE)"
126         @echo
127         @echo "Trouble finding a recipe? Try ./scripts/drepo grep 'search string'"
128         @echo "or ./scripts/drepo find -name \"*recipe*\"."
129         @echo
130
131 usage:
132         @echo "[*] Please run '$(MAKE) help' to display further information!"
133
134 clean:
135         @echo '[*] Deleting generated configuration files'
136         @$(RM) $(CONFFILES) $(CONFDEPS)
137
138 distclean: clean
139         @echo '[*] Deleting dependencies directory'
140         @$(RM) -r $(DEPDIR)
141         @echo '[*] Deleting download directory'
142         @$(RM) -r $(DL_DIR)
143         @echo '[*] Deleting tmp directory'
144         @$(RM) -r $(TMPDIR)
145         @echo '[*] Deleting sstate directory'
146         @$(RM) -r $(SSTATE_DIR)
147         @echo '[*] Deleting build directory'
148         @$(RM) -r $(BUILD_DIR)
149         @echo '[*] Deleting git submodules'
150         @$(GIT) submodule foreach 'rm -rf .* * 2>/dev/null || true'
151
152 image: init
153         @echo '[*] Building image for $(MACHINE)'
154         @. $(TOPDIR)/bitbake.env && cd $(TOPDIR) && bitbake vuplus-image
155
156 download: init
157         @echo '[*] Downloading sources'
158         @. $(TOPDIR)/bitbake.env && cd $(TOPDIR) && bitbake -cfetchall -k vuplus-image
159
160 update:
161         @echo '[*] Updating Git repositories...'
162         @HASH=`$(XSUM) $(MAKEFILE_LIST)`; \
163         if [ -n "$(GIT_REMOTE)" ]; then \
164                 $(GIT) pull --ff-only || $(GIT) pull --rebase; \
165         fi; \
166         if [ "$$HASH" != "`$(XSUM) $(MAKEFILE_LIST)`" ]; then \
167                 echo '[*] Makefile changed. Restarting...'; \
168                 $(MAKE) $(MFLAGS) --no-print-directory $(MAKECMDGOALS); \
169         else \
170                 $(GIT) submodule sync && \
171                 $(GIT) submodule update --init && \
172                 echo "[*] The Vuplus SDK is now up-to-date."; \
173         fi
174
175 .PHONY: all clean help image init update usage
176
177 MACHINE_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-$(MACHINE)-ext.conf
178 DISTRO_INCLUDE_CONF = $(CURDIR)/conf/$(basename $(@F))-ext.conf
179
180 BITBAKE_ENV_HASH := $(call hash, \
181         'BITBAKE_ENV_VERSION = "0"' \
182         'CURDIR = "$(CURDIR)"' \
183         )
184
185 $(TOPDIR)/bitbake.env: $(DEPDIR)/.bitbake.env.$(BITBAKE_ENV_HASH)
186         @echo '[*] Generating $@'
187         @test -d $(@D) || mkdir -p $(@D)
188         @echo '# Automatically generated file. Do not edit!' > $@
189         @echo 'export PATH=$(CURDIR)/openembedded-core/scripts:$(CURDIR)/bitbake/bin:$${PATH}' >> $@
190
191 LOCAL_CONF_HASH := $(call hash, \
192         'LOCAL_CONF_VERSION = "0"' \
193         'CURDIR = "$(CURDIR)"' \
194         'TOPDIR = "$(TOPDIR)"' \
195         'MACHINE = "$(MACHINE)"' \
196         'OPENVUPLUS_CONF_VERSION = "1"' \
197         'CURDIR = "$(CURDIR)"' \
198         'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' \
199         'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' \
200         'DL_DIR = "$(DL_DIR)"' \
201         'SSTATE_DIR = "$(SSTATE_DIR)"' \
202         'TMPDIR = "$(TMPDIR)"' \
203         )
204
205 $(TOPDIR)/conf/local.conf: $(DEPDIR)/.local.conf.$(MACHINE).$(LOCAL_CONF_HASH)
206         @echo '[*] Generating $@'
207         @test -d $(@D) || mkdir -p $(@D)
208         @echo '# Automatically generated file. Do not edit!' > $@
209         @echo 'TOPDIR = "$(TOPDIR)"' >> $@
210         @echo 'MACHINE = "$(MACHINE)"' >> $@
211         @echo 'BB_NUMBER_THREADS = "$(BB_NUMBER_THREADS)"' >> $@
212         @echo 'PARALLEL_MAKE = "$(PARALLEL_MAKE)"' >> $@
213         @echo 'DL_DIR = "$(DL_DIR)"' >> $@
214         @echo 'SSTATE_DIR = "$(SSTATE_DIR)"' >> $@
215         @echo 'TMPDIR = "$(TMPDIR)"' >> $@
216         @echo 'BB_GENERATE_MIRROR_TARBALLS = "0"' >> $@
217         @echo 'BBINCLUDELOGS = "yes"' >> $@
218         @echo 'CONF_VERSION = "1"' >> $@
219         @echo 'DISTRO = "vuplus"' >> $@
220         @echo 'EXTRA_IMAGE_FEATURES = "debug-tweaks"' >> $@
221         @echo 'USER_CLASSES = "buildstats"' >> $@
222         @echo 'include $(DISTRO_INCLUDE_CONF)' >> $@
223         @echo 'include $(MACHINE_INCLUDE_CONF)' >> $@
224         @echo 'INHERIT += "rm_work"' >> $@
225
226 BBLAYERS_CONF_HASH := $(call hash, \
227         'BBLAYERS_CONF_VERSION = "0"' \
228         'CURDIR = "$(CURDIR)"' \
229         'BBLAYERS = "$(BBLAYERS)"' \
230         )
231
232 $(TOPDIR)/conf/bblayers.conf: $(DEPDIR)/.bblayers.conf.$(MACHINE).$(BBLAYERS_CONF_HASH)
233         @echo '[*] Generating $@'
234         @test -d $(@D) || mkdir -p $(@D)
235         @echo '# Automatically generated file. Do not edit!' > $@
236         @echo 'LCONF_VERSION = "4"' >> $@
237         @echo 'BBFILES = ""' >> $@
238         @echo 'BBLAYERS = "$(BBLAYERS)"' >> $@
239         @echo 'include $(DISTRO_INCLUDE_CONF)' >> $@
240         @echo 'include $(MACHINE_INCLUDE_CONF)' >> $@
241
242 $(CONFDEPS):
243         @test -d $(@D) || mkdir -p $(@D)
244         @$(RM) $(basename $@).*
245         @touch $@