-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
516 lines (444 loc) · 20.4 KB
/
Makefile
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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
# Yocto/Docker Build System Setup
# by [email protected] 2018-2021 Evologics GmbH
# by [email protected] Evologics GmbH
# by [email protected] Evologics GmbH
# This project helps make build system for embedded platform by using docker and yocto.
#
# TODO: add Makefile to build-* directory, to call ../Makefile. which detected
# if make runned inside docker, call same commands with bitbake, but without docker
# Uncomment this if you want use local builded docker image
#USE_LOCAL_DOCKER_IMAGE=1
# Comment this if you don't want create symlinks in project root directory to useful directories
CREATE_USEFUL_SYMLINKS = 1
YOCTO_RELEASE = thud
DOCKER_REGISTRY = docker.evologics.de
DOCKER_IMAGE = evologics/yocto:$(YOCTO_RELEASE)
SSTATE_CACHE_DIR = share/$(YOCTO_RELEASE)/$(MACHINE)/sstate-cache
################### begin build enviroment variable #########################
# Change this if you have shared 'downloads' directory for yocto
LOCAL_CONF_OPT_DL_DIR = $$$${TOPDIR}/../share/downloads
# Change this if you have shared 'sstate-cache' directory for yocto
LOCAL_CONF_OPT_SSTATE_DIR = $$$${TOPDIR}/../$(SSTATE_CACHE_DIR)
# Change this if you want point tmp dir to RAM disk
LOCAL_CONF_OPT_TMPDIR = $$$${TOPDIR}/tmp
LOCAL_CONF_OPT_BB_NUMBER_THREADS = 8
LOCAL_CONF_OPT_PARALLEL_MAKE = -j 8
PROJ_TOP_DIR := $(abspath $(dir $(firstword $(MAKEFILE_LIST))))
# Folders with source and build files
SOURCES_DIR = sources
BUILD_DIR ?= build-$(MACHINE)
# If layer branch not set with "branch=" option, YOCTO_RELEASE will be used.
# If layer has no such branch, 'master' branch will be used.
GIT_CLONE = git clone
# Usefull for CI/CD to fetch less data
#GIT_CLONE = git clone --single-branch
ifneq ($(wildcard /usr/bin/time),)
TIME = /usr/bin/time -f "real %e user %U sys %S"
endif
################### end build enviroment variable ###########################
DOCKER_WORK_DIR = /work
DOCKER_BIND = -v $$(pwd):$(DOCKER_WORK_DIR) \
-v /etc/localtime:/etc/localtime:ro \
-e HOST_UID=$(shell id -u) \
-e HOST_GID=$(shell id -g) \
-e USER=$(USER) \
-h $(DOCKER_HOST_NAME) \
$(DOCKER_SSH_AUTH_SOCK) \
--add-host=$(DOCKER_HOST_NAME):127.0.0.1 \
--network=host
ifneq ($(SSH_AUTH_SOCK),)
DOCKER_SSH_AUTH_SOCK = -v $(dir $(SSH_AUTH_SOCK)):$(dir $(SSH_AUTH_SOCK)) -e SSH_AUTH_SOCK=$(SSH_AUTH_SOCK)
endif
# Docker settings
ifneq ($(USE_LOCAL_DOCKER_IMAGE),)
DOCKER_IMAGE := $(DOCKER_IMAGE)
else
DOCKER_IMAGE := $(DOCKER_REGISTRY)/$(DOCKER_IMAGE)
endif
# Cmdline to run docker.
DOCKER_RUN = docker run -it --rm $(DOCKER_BIND) \
--workdir=$(DOCKER_WORK_DIR)/$(BUILD_DIR) \
$(DOCKER_IMAGE)
# If the file "home/.use_home" exists, bind "home" folder to the container.
ifneq (,$(wildcard home/.use_home))
DOCKER_BIND += -v $$(pwd)/home/:/home/$(USER)/
else
DOCKER_BIND += -v $(HOME)/.ssh:/home/$(USER)/.ssh \
-v $(HOME)/.git:/home/$(USER)/.git \
-v $(HOME)/.bash_history:/home/$(USER)/.bash_history \
-v $(HOME)/.screenrc:/home/$(USER)/.screenrc \
-v $(HOME)/.tmux.conf:/home/$(USER)/.tmux.conf
endif
DOCKER_HOST_NAME=build-$(subst :,-,$(subst /,-,$(MACHINE)))
################### begin helpers #########################
# Filter out duplicated words in list
uniq = $(strip $(if $1,$(firstword $1) $(call uniq,$(filter-out $(firstword $1),$1))))
# Reverse list
reverse = $(if $(1),$(call reverse,$(wordlist 2,$(words $(1)),$(1)))) $(firstword $(1))
# Just comma to use in macroses
comma := ,
# Start recording variables which will go to the local.conf file
# If you want do redefine the variable VAR previously set, first use:
#undefine VAR
# Otherwise it will not be recorded and will not show up in local.conf
define local_conf_options_begin
$(eval __VARIABLES_OLD := $(sort $(.VARIABLES)))
endef
define local_conf_options_set
$(if $(findstring pend, $(1)), \
$(eval LOCAL_CONF_OPT += '$(1) = " $(2) "'), \
$(eval LOCAL_CONF_OPT += '$(1) = "$(2)"') \
)
endef
# Actually add recorded variables to LOCAL_CONF_OPT
define local_conf_options_end
$(if $(__VARIABLES_OLD), \
$(foreach v, $(sort $(.VARIABLES)), \
$(if $(filter-out __VARIABLES_OLD $(__VARIABLES_OLD),$(v)), \
$(call local_conf_options_set,$(v),$($v)) \
) \
) \
$(eval undefine __VARIABLES_OLD) \
,)
endef
################### end helpers ###########################
# Include saved configs
-include .config.mk
-include .build-host-config.mk
# Use default MACHINE_CONFIG if it`s not defined
MACHINE_CONFIG ?= default
# Do not attempt to include something if running for bash completion
# __BASH_MAKE_COMPLETION__will be set to 1 starting from bash-completion v2.2
ifneq ($(__BASH_MAKE_COMPLETION__),1)
# Help and targets starting with 'list-*' and 'image-*' do not need MACHINE set
ifneq ($(filter-out help list-% image-%,$(MAKECMDGOALS)),)
ifeq ($(MACHINE),)
ifneq ($(shell test -t 0 && echo tty),)
ROOT_DIR:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
$(shell $(ROOT_DIR)/lazyconf.sh > $$(tty))
-include .config.mk
else
$(info Available machines are:)
$(foreach m_name, $(filter-out %common, $(notdir $(wildcard machine/*))), $(info $(m_name)))
$(error Variable MACHINE must be set!)
endif
endif
# Include machine config with a possibility to override everything above
include machine/$(MACHINE)/$(MACHINE_CONFIG).mk
endif
endif
# Trick to remove duplicates from LAYERS
$(eval LAYERS = $(sort $(LAYERS)))
# Iterate over lines in LAYERS and fill necessary variables
$(foreach line, $(addprefix url=, $(LAYERS)), \
$(eval line_sep = $(subst ;, ,$(line))) \
$(eval name := $(lastword $(subst /, ,$(firstword $(line_sep))))) \
$(eval name := $(name:%.git=%)) \
$(foreach property, $(line_sep), \
$(eval LAYER_$(name)_$(property)) \
) \
\
$(eval dir := $(addprefix $(SOURCES_DIR)/, $(name))) \
$(eval subdirs_sep = $(subst $(comma), ,$(LAYER_$(name)_subdirs))) \
\
$(eval LAYER_$(name)_branch ?= $(YOCTO_RELEASE)) \
\
$(if $(value LAYER_$(name)_subdirs), \
$(foreach subdir, $(subdirs_sep), \
$(eval LAYERS_DIR += $(addsuffix /$(subdir), $(dir))) \
$(eval LAYER_$(subdir)_url := $(LAYER_$(name)_url)) \
$(eval LAYER_$(subdir)_branch := $(LAYER_$(name)_branch)) \
) \
, \
$(eval LAYERS_DIR += $(dir)) \
) \
$(if $(value LAYER_$(name)_patches), \
$(eval LAYER_$(name)_patches := \
$(addprefix $(PROJ_TOP_DIR)/patches/$(name)/, \
$(subst $(comma), ,$(LAYER_$(name)_patches)))), \
) \
)
# Put LOCAL_CONF_OPT_* to LOCAL_CONF_OPT
$(foreach v, $(filter LOCAL_CONF_OPT_%,$(.VARIABLES)),\
$(call local_conf_options_set,$(subst LOCAL_CONF_OPT_,,$(v)),$($v)) \
)
# help-section: Generic targets
# help: Show help
help:
@echo Variables:
@echo 'USE_LOCAL_DOCKER_IMAGE=1 - Use local builded docker image. Disabled by default'
@echo 'CREATE_USEFUL_SYMLINKS=1 - Create symbolic links to useful directories. Enabled by default'
@echo
@echo LOCAL_CONF_OPT_DL_DIR=\''$(LOCAL_CONF_OPT_DL_DIR)'\'
@echo LOCAL_CONF_OPT_SSTATE_DIR=\''$(LOCAL_CONF_OPT_SSTATE_DIR)'\'
@echo LOCAL_CONF_OPT_TMPDIR=\''$(LOCAL_CONF_OPT_TMPDIR)'\'
@echo LOCAL_CONF_OPT_BB_NUMBER_THREADS=\''$(LOCAL_CONF_OPT_BB_NUMBER_THREADS)'\'
@echo LOCAL_CONF_OPT_PARALLEL_MAKE=\''$(LOCAL_CONF_OPT_PARALLEL_MAKE)'\'
@echo
@echo YOCTO_RELEASE=$(YOCTO_RELEASE)
@echo DOCKER_REGISTRY=$(DOCKER_REGISTRY)
@echo DOCKER_IMAGE=$(DOCKER_IMAGE)
@# Parse Makefile to find "help-section: " and "help: " tockens, and show them
@sed -n -e 's/^# help-section: \(.*\)/printf "\n### %s\n" "\1"/p;t' \
-e 's/^# help: \(.*\)/\1/;t z' -e b -e ':z' \
-e 'N;s/\(.*\)\n\([^:]*\):.*/printf "%-20s - %s\\n" "\2" "\1"/p' \
$(firstword $(MAKEFILE_LIST)) | sh
@echo ''
@echo 'Also docker can be run directly:'
@echo '$$ $(DOCKER_RUN)'
@echo ''
@echo 'And then build:'
@echo 'docker$$ bitbake core-image-minimal meta-toolchain meta-extsdk-toolchain'
@echo ''
@echo '=== Usefull tips ===='
@echo 'Build binaries and images for RoadRunner on BertaD2 baseboard in separate build directory'
@echo '$$ make MACHINE=sama5d2-roadrunner-bertad2-qspi BUILD_DIR=build-bertad2-qspi IMAGE_NAME=acme-minimal-image all'
@echo 'Result binaryes and images you can find at $(BUILD_DIR)/tmp/deploy/'
@echo ''
@echo 'Rebuild kernel'
@echo '$$ make devshell CMD="bitbake virtual/kernel"'
@echo ''
@echo 'Build binaries, images, SDK and updater for RoadRunner on EvoTiny by bitbake in interactive docker shell'
@echo '$$ make MACHINE=sama5d2-roadrunner-evo devshell'
@echo ''
@echo 'Build everything by using metapackage'
@echo 'docker$$ bitbake world-roadrunner-evo'
@echo ''
@echo 'Or run manually'
@echo 'docker$$ bitbake virtual/kernel evologics-base-image swupdate-images-evo meta-toolchain '\
'packagegroup-erlang-embedded evologics-base-image:do_populate_sdk evologics-base-image:do_populate_sdk_ext'
@echo ''
@echo 'Update package index of local repository'
@echo 'docker$$ bitbake package-index'
@echo ''
@echo 'Modify the source for an existing recipe'
@echo 'docker$$ devtool modify virtual/kernel'
@echo ''
@echo 'Configure kernel'
@echo 'docker$$ bitbake virtual/kernel -fc menuconfig'
@echo 'docker$$ bitbake virtual/kernel -fc diffconfig'
@echo ''
@echo 'Create new recipe'
@echo 'docker$$ devtool add liblxc https://linuxcontainers.org/downloads/lxc/lxc-4.0.9.tar.gz'
@echo ''
@echo 'Deploy to target for testing'
@echo 'docker$$ devtool deploy-target dtach [email protected]'
@echo ''
@echo 'Apply changes from external source tree to recipe'
@echo 'docker$$ devtool update-recipe --force-patch-refresh --append /work/sources/meta-evo linux-at91'
@echo ''
@echo 'Remove a recipe from workspace'
@echo 'docker$$ devtool reset linux-at91'
@echo ''
@echo 'Finish working on a recipe in workspace (update-recipe + reset)'
@echo 'docker$$ devtool finish linux-at91 /work/sources/meta-evo'
.PHONY: help
.build-host-config.mk:
@test -t 1 && echo Creating config .build-host-config.mk
@echo 'LOCAL_CONF_OPT_DL_DIR ?= $(LOCAL_CONF_OPT_DL_DIR)' > .build-host-config.mk
@echo 'LOCAL_CONF_OPT_SSTATE_DIR ?= $(LOCAL_CONF_OPT_SSTATE_DIR)' >> .build-host-config.mk
@echo 'LOCAL_CONF_OPT_TMPDIR ?= $(LOCAL_CONF_OPT_TMPDIR)' >> .build-host-config.mk
@echo 'LOCAL_CONF_OPT_BB_NUMBER_THREADS ?= $(LOCAL_CONF_OPT_BB_NUMBER_THREADS)' >> .build-host-config.mk
@echo 'LOCAL_CONF_OPT_PARALLEL_MAKE ?= $(LOCAL_CONF_OPT_PARALLEL_MAKE)' >> .build-host-config.mk
# help: Download docker image, yocto and meta layers and build image \$(IMAGE_NAME) for machine \$(MACHINE)
all: image-check $(PROJ_TOP_DIR)/$(SOURCES_DIR) $(LAYERS_DIR) $(BUILD_DIR) configure $(TARGET_ALL_DEPEND)
@$(TIME) $(DOCKER_RUN) "bitbake $(IMAGE_NAME) $(MACHINE_BITBAKE_TARGETS)"
@echo 'Result binaries and images you can find at $(BUILD_DIR)/tmp/deploy/'
.PHONY: all
# help: Invoke developer shell without checking TARGET_ALL_DEPEND. Can run command in CMD variable
devshell-force: | image-check $(PROJ_TOP_DIR)/$(SOURCES_DIR) $(LAYERS_DIR) $(BUILD_DIR) configure
# help: Invoke developer shell. Can run command in CMD variable
devshell: | $(TARGET_ALL_DEPEND) devshell-force
@$(DOCKER_RUN) $(CMD)
.PHONY: devshell
$(PROJ_TOP_DIR)/$(SOURCES_DIR):
@$(GIT_CLONE) -b $(YOCTO_RELEASE) git://git.yoctoproject.org/poky.git $(PROJ_TOP_DIR)/$(SOURCES_DIR)
@if [ -n "$(LAYER_poky_patches)" ]; then \
cd $(PROJ_TOP_DIR)/$(SOURCES_DIR); \
git am $(PROJ_TOP_DIR)/patches/$(LAYER_poky_patches); \
fi
$(call uniq,$(LAYERS_DIR)):
@cd $(PROJ_TOP_DIR)/$(SOURCES_DIR) && \
($(GIT_CLONE) -b $(LAYER_$(@F)_branch) $(LAYER_$(@F)_url) || $(GIT_CLONE) $(LAYER_$(@F)_url))
@if [ -n "$(LAYER_$(@F)_srcrev)" ]; then \
cd $(PROJ_TOP_DIR)/$(SOURCES_DIR)/$(@F); \
git checkout $(LAYER_$(@F)_srcrev); \
fi
@if [ -n "$(LAYER_$(@F)_patches)" ]; then \
cd $(PROJ_TOP_DIR)/$(SOURCES_DIR)/$(@F); \
git am $(LAYER_$(@F)_patches); \
fi
$(BUILD_DIR):
@mkdir -p $(BUILD_DIR)
ifneq ($(CREATE_USEFUL_SYMLINKS),)
SYMLINK_TO_DIR_images = build/tmp/deploy/images/$(MACHINE)
SYMLINK_TO_DIR_ipk = build/tmp/deploy/ipk
SYMLINK_TO_DIR_sdk = build/tmp/deploy/sdk
SYMLINK_TO_DIR_kernel-source = build/tmp/work-shared/$(MACHINE)/kernel-source
SYMLINK_TO_DIR_kernel-build-artifacts = build/tmp/work-shared/$(MACHINE)/kernel-build-artifacts
$(foreach v, $(filter SYMLINK_TO_DIR_%,$(.VARIABLES)),\
$(eval USEFUL_SYMLINKS += $(patsubst SYMLINK_TO_DIR_%,%,$(v))) \
)
$(USEFUL_SYMLINKS):
@ln -fsT $(SYMLINK_TO_DIR_$(@F)) $(@F)
endif
# help: Configure build system
configure: $(BUILD_DIR)/conf/local.conf
LOCAL_CONF_MARK = \#=== This block automatically generated. Do not change nothing there ===
# Build directory is created by oe-init-build-env script,
# which is called every run from container entrypoint script
$(BUILD_DIR)/conf/local.conf: $(PROJ_TOP_DIR)/$(SOURCES_DIR) $(LAYERS_DIR) $(BUILD_DIR) $(USEFUL_SYMLINKS)
@#Update symlink to build directory, in case it was changed by lazyconf
@ln -sfT $(BUILD_DIR) build
@# if local.conf do not exist, it will be created by oe-init-build-env in docker/entrypoint.sh
@[ -f $(BUILD_DIR)/conf/local.conf ] && echo Update $@ || $(DOCKER_RUN) "echo Create $@"
@sed -i '/$(LOCAL_CONF_MARK)/,/$(LOCAL_CONF_MARK)/d' $(BUILD_DIR)/conf/local.conf
@echo '$(LOCAL_CONF_MARK)' >> $(BUILD_DIR)/conf/local.conf
@printf "%s\n" $(LOCAL_CONF_OPT) >> $(BUILD_DIR)/conf/local.conf
@echo '$(LOCAL_CONF_MARK)' >> $(BUILD_DIR)/conf/local.conf
@$(DOCKER_RUN) "bitbake-layers add-layer $(addprefix $(DOCKER_WORK_DIR)/,$(LAYERS_DIR))"
@echo Update .config.mk
@echo "MACHINE ?= $(MACHINE)" > .config.mk
@echo "MACHINE_CONFIG ?= $(MACHINE_CONFIG)" >> .config.mk
# help-section: List targets
# help: Show available machines
list-machine:
@ls -1 machine/ | grep -v common | sed '/$(MACHINE)[-.]/! s/\b$(MACHINE)\b/ * &/g'
.PHONY: list-machine
# help: Show available configs for a given machine
list-config:
@echo " * $(MACHINE):"
@ls -1 machine/$(MACHINE)/ | grep .mk | sed 's/.mk\b//g' | sed '/$(MACHINE_CONFIG)[-.]/! s/\b$(MACHINE_CONFIG)\b/ * &/g'
.PHONY: list-config
# help-section: Layers manipulation targets
# help: Add one or multiple layers
add-layer: configure $(LAYERS_DIR)
@for LAYER in $(LAYERS_DIR); do \
$(DOCKER_RUN) "bitbake-layers add-layer $(DOCKER_WORK_DIR)/$$LAYER"; \
done
.PHONY: add-layer
# WARNING: by default will be removed all layers. Dirty repo will be not removed'
# help: Remove one or multiple layers. Necessary parameter: LAYERS='layer1 layer2'
remove-layer: configure
@echo "REMOVING: $(LAYERS_DIR)"
@for LAYER in $(LAYERS_DIR); do \
cd $(PROJ_TOP_DIR)/$$LAYER; \
DIR="$(git rev-parse --show-toplevel)";\
[ -d "$$DIR" ] && cd $$DIR; \
if ! git diff --quiet; then \
echo "Layer $$LAYER are dirty. Will not remove"; \
exit 1; \
fi; \
done
@echo -n "Press Ctrl-C to cancel"
@for i in $$(seq 1 5); do echo -n "." && sleep 1; done
@echo
@for LAYER in $(call reverse,$(LAYERS_DIR)); do \
echo Removing $(DOCKER_WORK_DIR)/$$LAYER; \
$(DOCKER_RUN) "bitbake-layers remove-layer $(DOCKER_WORK_DIR)/$$LAYER && \
rm -rf $(PROJ_TOP_DIR)/$$LAYER"; \
done
.PHONY: remove-layers
# help: Remove bblayers.conf and local.conf files
clean-bbconfigs: clean-links
rm -f $(BUILD_DIR)/conf/local.conf $(BUILD_DIR)/conf/bblayers.conf deploy-images
.PHONY: clean-bbconfigs
# help: Remove useful symbolic links
clean-links:
@rm -f build $(USEFUL_SYMLINKS)
.PHONY: clean-links
# help: Remove resulting target images and packages
clean-deploy:
rm -rf $(BUILD_DIR)/tmp/deploy
.PHONY: clean-deploy
# help: Remove sstate-cache, all generated files and directories in build directory
cleanall:
rm -rf $(BUILD_DIR)/tmp $(PROJ_TOP_DIR)/share/$(YOCTO_RELEASE)/$(MACHINE)/sstate-cache
.PHONY: cleanall
# help: Remove build, source directory and .config.mk
distclean: clean-links
rm -rf $(BUILD_DIR) $(PROJ_TOP_DIR)/$(SOURCES_DIR) .config.mk
.PHONY: distclean
# help-section Working with repository
# help: Rebuild package index of repository. This is needed after package adding/removing'
package-index:
@$(DOCKER_RUN) bitbake package-index
.PHONY: package-index
#help: Start webserver for repository sharing. Package index will be rebuilded also
ipk-server: package-index
$(eval IP := $(shell ip a | sed -n '/dynamic/s/.*inet \([^/]*\).*/\1/p;T;q'))
$(eval PORT := 8080)
@echo 'Assuming address $(IP):$(PORT)'
@echo ''
@echo 'Add following lines to /etc/opkg/opkg.conf'
@echo ''
@# NOTE: path/*/. is trick to match only directory
$(eval ipk-archs := $(patsubst %/.,%,$(wildcard $(BUILD_DIR)/tmp/deploy/ipk/*/.)))
@# filter out directory with -dummy- in name
$(eval dummy-filter := $(patsubst %/.,%,$(wildcard $(BUILD_DIR)/tmp/deploy/ipk/*-dummy-*/.)))
$(eval ipk-archs := $(filter-out $(dummy-filter),$(ipk-archs)))
@$(foreach arch, $(ipk-archs), \
$(eval arch_strip := $(lastword $(subst /, ,$(arch)))) \
echo 'src/gz $(arch_strip) http://$(IP):$(PORT)/ipk/$(arch_strip)'; \
)
@echo ''
@cd $(BUILD_DIR)/tmp/deploy/; \
python3 -m http.server $(PORT) || \
python2 -m SimpleHTTPServer $(PORT)
.PHONY: ipk-server
# help-section: Working with docker image
# help: Build docker image
image-build:
@cd docker && docker build -t $(DOCKER_IMAGE) .
.PHONY: image-build
# help: Clean docker image and containers
image-clean: docker-check
@docker container ls | awk '"$(DOCKER_IMAGE)$(suffix $@)" == $$1 && "$(YOCTO_RELEASE)" == $$2{print $$1":"$$2}' | \
xargs --no-run-if-empty docker container rm
@docker inspect --type=image $(DOCKER_IMAGE) > /dev/null 2>&1 && \
docker image rm $(DOCKER_IMAGE)$(suffix $@) || exit 0
.PHONY: image-clean
# help: Checking exising docker image, and if not - build or pull it
image-check: docker-check
ifneq ($(USE_LOCAL_DOCKER_IMAGE),)
@if ! docker inspect $(DOCKER_IMAGE) > /dev/null 2>&1; then \
echo WARNING: docker image $(DOCKER_IMAGE) do not exist. Build one>&2; \
$(MAKE) image-build; \
fi
else
@if ! docker inspect $(DOCKER_IMAGE) > /dev/null 2>&1; then \
echo WARNING: docker image $(DOCKER_IMAGE) do not exist. Pull one>&2; \
$(MAKE) image-pull; \
fi
.PHONY: image-check
# help: Pull docker image from registry
image-pull: docker-check registry-login
@docker pull $(DOCKER_IMAGE)
.PHONY: image-pull
# help: Push docker image to registry
image-push: docker-check registry-login
@docker push $(DOCKER_IMAGE)
endif
.PHONY: image-push
# help: Check if dockerd is running
docker-check:
@docker ps > /dev/null
.PHONY: docker-check
sdk-build: image-check $(PROJ_TOP_DIR)/$(SOURCES_DIR) $(LAYERS_DIR) $(BUILD_DIR) configure $(TARGET_ALL_DEPEND)
@$(TIME) $(DOCKER_RUN) "bitbake $(IMAGE_NAME) -c do_populate_sdk"
.PHONY: sdk-build
sdk-dockerize: sdk-build
@ln -f sdk/*$(IMAGE_NAME)*.sh docker/sdk
@cd docker && \
docker build -f yocto-sdk-atomic.Dockerfile -t $(DOCKER_REGISTRY)/evologics/build-$(MACHINE) . && \
{ echo "Image created"; rm sdk; } || \
{ echo "Failed to create an image"; rm sdk; exit 1; }
.PHONY: sdk-dockerize
sdk-devshell: sdk-dockerize
$(eval CMD := /bin/bash)
@docker run -it --rm $(DOCKER_REGISTRY)/evologics/build-$(MACHINE) $(CMD)
.PHONY: sdk-devshell
# help: Login to \$(DOCKER_REGISTRY) registry
registry-login:
@docker login $(DOCKER_REGISTRY)
.PHONY: registry-login