-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathMakefile
More file actions
112 lines (95 loc) · 4.06 KB
/
Copy pathMakefile
File metadata and controls
112 lines (95 loc) · 4.06 KB
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
# NOTE: Docker Server to fetch docker images
DOCKER_SERVER ?= "docker.io"
# To make the build reproducible, we fix the kernel headers
# version, but leave opportunity to update it.
KVER_DOCKER ?= v6.1
ifdef KVER
KVER_DOCKER = ${KVER}
endif
KVER ?= $(shell uname -r)
KDIR ?= /lib/modules/$(KVER)/build
# the tag of the image we base on
DOCKER_IN_CONFIG_HASH ?= kver-$(subst .,-,${KVER_DOCKER})
DOCKER_IN_TAG ?= config_${DOCKER_IN_CONFIG_HASH}
# how to tag the outgoing image (for more detailed description
# see the bosch-linux-ext-modules-buld repository Makefile)
DOCKER_OUT_CONFIG_HASH ?= ${DOCKER_IN_CONFIG_HASH}
DOCKER_OUT_TAG ?= config_${DOCKER_OUT_CONFIG_HASH}
# NOTE: don't change this unless you're sure what you're doing
# cause by this tag the dependent components refer to the current
# component
TARGET_STAGE = iccom
TEST_TARGET_STAGE = iccom-test
# ${1} the target docker stage to reach
# ${2}: the path (name) for the newly created Docker image
# ${3}: the tag for the newly created Docker image
define docker_build
cd $$PWD && docker build \
--build-arg DOCKER_IN_TAG=${DOCKER_IN_TAG} \
--build-arg DOCKER_SERVER=${DOCKER_SERVER} \
--tag "${2}:${3}" \
--target ${1} \
--progress=plain \
. \
&& echo "docker-image: \033[0;32mOK\033[0m"
endef
.PHONY: test docker-image
# Creates the ICCom & Full Duplex Test Transport Test Build
default:
$(MAKE) -C ${KDIR} M=$$PWD \
CONFIG_BOSCH_ICCOM=m \
CONFIG_ICCOM_VERSION=$(git rev-parse HEAD) \
CONFIG_BOSCH_FD_TEST_TRANSPORT=m \
CONFIG_BOSCH_ICCOM_TTY=m \
CONFIG_BOSCH_ICCOM_SOCKETS=m
# Cleans ICCom & Full Duplex Test Transport Test Build
clean:
$(MAKE) -C ${KDIR} M=$$PWD clean
# Install to current machine
install:
$(MAKE) -C $(KDIR) M=$$PWD modules_install
cp $$PWD/include/linux/iccom.h \
/usr/src/linux-headers-${KVER}/include/linux/iccom.h
# Try to remove the installed driver from current machine
uninstall:
rm -f /usr/src/linux-headers-${KVER}/include/linux/iccom.h
rm -f /lib/modules/${KVER}/extra/src/iccom.ko
rm -f /lib/modules/${KVER}/extra/src/fd_test_transport.ko
# Build Docker deployed image (Docker image with built and installed ICCom)
# This will build the reusable Docker Stage for
# other components to build the external kernel modules
docker-image:
@echo
@echo ' Building for kernel: ${KVER}'
@echo
@echo ' ************************************************************************'
@echo ' | NOTE: |'
@echo ' | |'
@echo ' | The docker image build will be based on the |'
@echo ' | * docker.io/bosch-linux-full-duplex-interface:config_kver-vA-B |'
@echo ' | docker image (NOTE: A and B are kernel major and minor version |'
@echo ' | numbers), to get it you need to clone |'
@echo ' | * bosch-linux-full-duplex-interface repository |'
@echo ' | and then run "make KVER=vA.B test" in the root of the repo. |'
@echo ' | |'
@echo ' ************************************************************************'
@echo
$(call docker_build, ${TARGET_STAGE},${TARGET_STAGE},${DOCKER_OUT_TAG})
# test if the image is really working
test: docker-image
$(call docker_build, ${TEST_TARGET_STAGE},${TEST_TARGET_STAGE},${DOCKER_OUT_TAG})
# test for supported/relevant kernel versions
testall:
$(MAKE) KVER=v5.12 test
$(MAKE) KVER=v6.1 test
# $(MAKE) KVER=v6.6 test
$(MAKE) KVER=v6.12 test
# Will remove the docker image generated by the build
# and all dangling images as well
clean-docker-images:
docker rmi ${TARGET_STAGE} --force
docker rmi ${TEST_TARGET_STAGE} --force
docker image prune --force
docker system prune --force
print-output-docker-image-tag:
@echo "${TARGET_STAGE}:${DOCKER_OUT_TAG}"