forked from thesofproject/sof
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GNUmakefile
329 lines (257 loc) · 10.9 KB
/
GNUmakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
# SPDX-License-Identifier: BSD-3-Clause
# Copyright(c) 2021 Intel Corporation
.DEFAULT_GOAL := stage
.PHONY: clean stage rsync tarball
.PHONY: signed unsigned ldicts topologies tools build_tools
.PHONY: compare signed_dummies
# Override ?= variables in config.mk
-include config.mk
# List of /lib/firmware/sof/ images and symbolic links currently
# released by Intel.
# To find aliases, try in a Linux kernel git clone:
#
# git grep 'sof-.*\.ri' -- sound/soc/
# ALIAS_OTHER_KEY_list += adl adl-s rpl rpl-s
# Not supported in the main branch anymore, go to stable-v2.3
# UNSIGNED_list += bdw byt cht
# SIGNED_list += apl cnl icl jsl
# ALIAS_SAME_KEY_list += glk cfl cml
# ALIAS_OTHER_KEY_list += ehl
# Much older platforms
# UNSIGNED_list += hsw sue
# SIGNED_list += kbl skl
ALIAS_list := ${ALIAS_SAME_KEY_list} ${ALIAS_OTHER_KEY_list}
$(info UNSIGNED_list = ${UNSIGNED_list} )
$(info SIGNED_list = ${SIGNED_list} )
$(info ALIAS_list = ${ALIAS_list} )
target_of_imx := imx8
ifeq (,${TOOLCHAIN})
ifeq (,${XTENSA_TOOLS_ROOT})
TOOLCHAIN := gcc
else
TOOLCHAIN := xcc
endif
endif
TREE_OPTS ?= --sort=size --dirsfirst
INSTALL_OPTS ?= -D -p -m 0664
# Keep SOF_VERSION optional
SOF_VERSION ?= $(shell git describe --dirty)
ifneq (${SOF_VERSION},)
VERSION_DIR := ${SOF_VERSION}/
VERSION_SUFFIX := -${SOF_VERSION}
endif
################################
### Top-level directories ####
################################
# Our input: build_*_?cc/ directories
BUILDS_ROOT ?= ${CURDIR}/../installer-builds
BUILD_TOOLS ?= ${BUILDS_ROOT}/build_tools
STAGING_SOF ?= staging/sof
STAGING_SOF_VERSION := ${STAGING_SOF}${VERSION_SUFFIX}
STAGING_SOF_TPLG ?= staging/sof-tplg
STAGING_TOOLS ?= staging/tools
stage: signed unsigned ldicts aliases topologies tools
ifneq (${STAGING_SOF_VERSION},${STAGING_SOF})
ln -sfT sof${VERSION_SUFFIX} ${STAGING_SOF}
test -e ${STAGING_SOF}
endif
@file ${STAGING_SOF}
@tree ${TREE_OPTS} ${STAGING_SOF_VERSION}
COMMUNITY := ${STAGING_SOF_VERSION}/community
INTEL_SIGNED := ${STAGING_SOF_VERSION}/intel-signed
${COMMUNITY} ${INTEL_SIGNED} ${BUILDS_ROOT} ${STAGING_SOF_VERSION}:
mkdir -p $@
# The noise for incremental, do-nothing builds is incredible otherwise,
# especially for build_tools
GNUMAKEFLAGS = --no-print-directory
#####################################
### rsync to local or remote ####
#####################################
# Default value
FW_DESTDIR ?= /lib/firmware/intel/
# The rsync target does not depend on any other target so:
# - it's possible to deploy a staging _subset_, e.g.: only topologies
# only,...
# - "sudo make rsync" never builds as root by accident
rsync:
# The --mkpath option is too recent, dealing with both remote and local
# would be complicated and this is also a safety against typos.
# The destination directory must already exist
rsync -a --info=progress2 staging/sof* "${FW_DESTDIR}"
ifneq (${USER_DESTDIR},)
# TODO: add more user space binaries: sof-ctl, probes,...
# absorbe scripts/sof-target-install.sh
cd ${BUILD_TOOLS} && rsync -a ${TOOLS_RELPATHS} ${USER_DESTDIR}
endif
clean:
${RM} -r ${STAGING_SOF}* ${STAGING_SOF_TPLG}* ${STAGING_TOOLS}*
${RM} ${BUILDS_ROOT}/staging_sof_tree.txt
cleanall: clean
${RM} -r "${BUILD_TOOLS}/" "${BUILDS_ROOT}"/build_*_?cc/
#####################################
### tarball ####
#####################################
tarball: stage
cd staging && tar cfz sof-build${VERSION_SUFFIX}.tgz \
sof${VERSION_SUFFIX} sof-tplg${VERSION_SUFFIX} \
tools${VERSION_SUFFIX}
#####################################
### Stage tools ####
#####################################
# This is only for the tarball, rsync takes the RELPATHS shortcut
tools: build_tools
mkdir -p ${STAGING_TOOLS}${VERSION_SUFFIX}
cd ${BUILD_TOOLS} && \
cp -p ${TOOLS_RELPATHS} ${CURDIR}/${STAGING_TOOLS}${VERSION_SUFFIX}
##########################################################
### Stage sof-*.ri firmware files and symbolic links ####
##########################################################
#
# 1. Stages all *.ri files
#
# 2. Create symbolic links, including (broken) intel-signed symbolic
# links that must be fixed in a final release, otherwise the release
# is incomplete. To check all symlinks: file $(find -type l)
#
# '%' is the platform name
SIGNED_FWS := ${SIGNED_list:%=${COMMUNITY}/sof-%.ri}
# $(info SIGNED_FWS = ${SIGNED_FWS})
signed: ${SIGNED_FWS}
${SIGNED_FWS}: ${COMMUNITY}/sof-%.ri: \
${BUILDS_ROOT}/build_%_${TOOLCHAIN}/sof.ri \
| ${COMMUNITY} ${INTEL_SIGNED}
install ${INSTALL_OPTS} $< $@
ln -sfT intel-signed/sof-$*.ri ${STAGING_SOF_VERSION}/sof-$*.ri
# '%' is the platform name
UNSIGNED_FWS := ${UNSIGNED_list:%=${STAGING_SOF_VERSION}/sof-%.ri}
# $(info UNSIGNED_FWS = ${UNSIGNED_FWS})
unsigned: ${UNSIGNED_FWS}
${UNSIGNED_FWS}: ${STAGING_SOF_VERSION}/sof-%.ri: \
${BUILDS_ROOT}/build_%_${TOOLCHAIN}/sof.ri
install ${INSTALL_OPTS} $< $@
BUILD_SOF_RIS := \
${UNSIGNED_list:%=${BUILDS_ROOT}/build_%_${TOOLCHAIN}/sof.ri} \
${SIGNED_list:%=${BUILDS_ROOT}/build_%_${TOOLCHAIN}/sof.ri}
# When the build is not deterministic use this to reduce noise when testing
# this Makefile.
# Also very useful with XCC, see next comment.
ifneq (true,${BUILD_ONLY_ONCE})
.PHONY: ${BUILD_SOF_RIS}
endif
# Incremental builds are not possible with XCC because the entire
# toolchain requires $XTENSA_SYSTEM but CMake does not support
# build-time environment variables. In the future we could move the
# XTENSA_SYSTEM values out of xtensa-build-all.sh and into some shared
# config file included here.
${BUILD_SOF_RIS}: ${BUILDS_ROOT}/build_%_${TOOLCHAIN}/sof.ri: | ${BUILDS_ROOT}
cd ${BUILDS_ROOT} && bdir="$$(dirname $@)" && \
if [ -e $${bdir}/build.ninja -o -e $${bdir}/Makefile ] && \
[ xcc != "${TOOLCHAIN}" ] ; then \
cmake --build $${bdir} -- bin; else \
$(CURDIR)/../scripts/xtensa-build-all.sh -i "${IPC_VERSION}" $*; fi
########################################
### Stage *.ldc logger dictionaries ###
########################################
# '%' is the platform name
LDICTS := ${UNSIGNED_list:%=${STAGING_SOF_VERSION}/sof-%.ldc} \
${SIGNED_list:%=${STAGING_SOF_VERSION}/sof-%.ldc}
# $(info LDICTS = ${LDICTS})
ldicts: ${LDICTS}
${LDICTS}: ${STAGING_SOF_VERSION}/sof-%.ldc: \
${BUILDS_ROOT}/build_%_${TOOLCHAIN}/sof.ri
if test -e ${BUILDS_ROOT}/build_$*_${TOOLCHAIN}/sof.ldc; then \
install ${INSTALL_OPTS} ${BUILDS_ROOT}/build_$*_${TOOLCHAIN}/sof.ldc $@ ; \
else printf '# CONFIG_TRACE was disabled\n' > $@; fi
#######################################
### Platform -> platform aliases ####
#######################################
# '%' is the platform name
COMM_ALIASES := ${ALIAS_list:%=${STAGING_SOF_VERSION}/community/sof-%.ri}
DICT_ALIASES := ${ALIAS_list:%=${STAGING_SOF_VERSION}/sof-%.ldc}
${COMM_ALIASES}: ${STAGING_SOF_VERSION}/community/sof-%.ri: | ${COMMUNITY}
ln -sfT sof-${target_of_$*}.ri $@
${DICT_ALIASES}: ${STAGING_SOF_VERSION}/sof-%.ldc: | ${STAGING_SOF_VERSION}
ln -sfT sof-${target_of_$*}.ldc $@
# ->intel-signed/ symlinks for platform aliases. The other, identical
# looking ->intel-signed/ symlinks for the other, "normal" platforms are
# created here but by the signed: target.
#
# Some have the same key, others just the code. We don't make any
# difference, no platform re-direction here, this is merely pointing at
# ->intel-signed/same.ri
SIGNED_ALIASES := ${ALIAS_list:%=${STAGING_SOF_VERSION}/sof-%.ri}
${SIGNED_ALIASES}: ${STAGING_SOF_VERSION}/sof-%.ri: | ${STAGING_SOF_VERSION}
ln -sfT intel-signed/sof-$*.ri $@
# Platform indirection inside the intel-signed/ directory
SIGNED_PLATFORM_ALIASES := ${ALIAS_SAME_KEY_list:%=${INTEL_SIGNED}/sof-%.ri}
${SIGNED_PLATFORM_ALIASES}: ${INTEL_SIGNED}/sof-%.ri: | ${INTEL_SIGNED}
ln -sfT sof-${target_of_$*}.ri $@
aliases: ${COMM_ALIASES} ${DICT_ALIASES} ${SIGNED_ALIASES} \
${SIGNED_PLATFORM_ALIASES}
##################################
### Stage sof-tplg/ topologies ###
##################################
# The build is not deterministic; use this to reduce noise when testing
# this Makefile
ifneq (true,${BUILD_ONLY_ONCE})
.PHONY: ${BUILD_TOOLS}
endif
# Deploy and release only "official", top-level topology files starting
# with the 'sof-' prefix to avoid any experimental stuff.
topologies: ${BUILD_TOOLS}
install ${INSTALL_OPTS} -t ${STAGING_SOF_TPLG}${VERSION_SUFFIX}/ \
${BUILD_TOOLS}/topology/sof-*.tplg
ifneq (,${VERSION_SUFFIX})
ln -sfT sof-tplg${VERSION_SUFFIX} ${STAGING_SOF_TPLG}
test -e ${STAGING_SOF_TPLG}
endif
@file ${STAGING_SOF_TPLG}
@tree ${TREE_OPTS} ${STAGING_SOF_TPLG}${VERSION_SUFFIX} | \
head -n 10; printf '├── ...\n..\n'
######################
### build-tools.sh ###
######################
TOOLS_RELPATHS := ctl/sof-ctl logger/sof-logger probes/sof-probes
TOOLS_TARGETS := sof-ctl sof-logger sof-probes
TOOLS_FLAGS := -c -l -p
.PHONY: build_tools
build_tools: ${BUILD_TOOLS}
# We could use more targets rather than "set -e" with a multi-lines "for" loop.
# That would be more flexible but also quite verbose.
${BUILD_TOOLS}:
set -e; if test -e ${BUILD_TOOLS}/build.ninja || \
test -e ${BUILD_TOOLS}/Makefile; then \
for i in topologies ${TOOLS_TARGETS}; do \
cmake --build ${BUILD_TOOLS} -- $$i; done; else \
BUILD_TOOLS_DIR=${BUILD_TOOLS} ../scripts/build-tools.sh -T ${TOOLS_FLAGS} ; \
fi
####################
### Self-Testing ###
####################
COMPARE_REFS ?= /lib/firmware/intel
checktree:
cd ${STAGING_SOF_VERSION} && \
tree -a -v --dirsfirst . > ${BUILDS_ROOT}/staging_sof_tree.txt
diff -u tests/staging_sof${IPC_VERSION}_ref.txt ${BUILDS_ROOT}/staging_sof_tree.txt
# Check two random topologies are there
test -f ${STAGING_SOF_TPLG}/sof-imx8-wm8960.tplg
for t in sof-ctl sof-logger sof-probes; do \
test -f ${STAGING_TOOLS}${VERSION_SUFFIX}/$${t}; done
# Useful for testing this Makefile. COMPARE_REFS can be /lib/firmware,
# sof-bin, a previous version of this Makefile,...
# As the first arguments maybe symbolic links, their trailing slash is
# critical.
compare: stage
! diff -qr --no-dereference ${COMPARE_REFS}/sof/ \
${STAGING_SOF_VERSION}/ \
| grep -v ' differ$$' # || true
! diff -qr --no-dereference ${COMPARE_REFS}/sof-tplg/ \
${STAGING_SOF_TPLG}${VERSION_SUFFIX}/ \
| grep -v ' differ$$'
# Invoke this manually to check symbolic links are correct
SIGNED_DUMMIES := ${SIGNED_list:%=${INTEL_SIGNED}/sof-%.ri} \
${ALIAS_OTHER_KEY_list:%=${INTEL_SIGNED}/sof-%.ri}
signed_dummies: ${SIGNED_DUMMIES}
! file $$(find staging -type l) | grep -i broken
${SIGNED_DUMMIES}: | ${INTEL_SIGNED}
touch $@