Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
99 lines (83 loc) · 3.56 KB
/
Copy pathMakefile
File metadata and controls
99 lines (83 loc) · 3.56 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
# The builds should work like following:
#
# * The direct build and install
# * build against the `uname -r` kernel headers on host
# * install to the host
#
# * The docker-test
# * run the image against the predefined kernel headers
# by default, but with option to choose specific version
#
# * The docker-image
# * make the image for the predefined kernel headers
# by default, but with option to choose specific version
# Defines the kernel version to work with directly (not-in-docker
# build), normally this defaults to the host system kernel name.
KVER ?= `uname -r`
# Defines the kernel version to be used inside the docker
# environment - this is fixed to predefined by default,
# to keep the build reproducible.
KVER_DOCKER ?= 5.4.0-97-generic
# The default linux sources folder (fits only to Docker env
# of the linux-ext-modules-build-base image). To use it effectively
# set this variable explicitly.
LINUX_SRC_ROOT ?= "/repos/linux"
# 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
DOCKER_OUT_IMAGE_TAG ?= bosch-linux-full-duplex-interface
DOCKER_OUT_TEST_IMAGE_TAG ?= bosch-linux-full-duplex-interface-test
# To track the sources root dir
SRC_ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
define docker_build
cd $$PWD && docker build \
--build-arg kernel_version=${KVER_DOCKER} \
--tag ${1} \
--target ${1} \
--progress=plain \
. \
&& echo "docker-image: \033[0;32mOK\033[0m"
endef
.PHONY: test docker-image
# Build on current machine with given (current kernel by default) kernel
default:
@echo "Making against the ${KVER} kernel"
$(MAKE) -C /lib/modules/${KVER}/build M=$$PWD
# Install to current machine
install:
@echo "Installing headers to: " \
"/usr/src/linux-headers-${KVER}/include/linux/"
cp -v ${SRC_ROOT_DIR}/include/linux/full_duplex_interface.h \
/usr/src/linux-headers-${KVER}/include/linux/
# Install to the Linux kernel sources directly
install-to-src:
@echo "Installing headers to: ${LINUX_SRC_ROOT}/include/linux"
cp -v ${SRC_ROOT_DIR}/include/linux/full_duplex_interface.h \
${LINUX_SRC_ROOT}/include/linux/
# Try to remove the installed driver from current machine
uninstall:
@echo "Removing installed headers from: " \
"/usr/src/linux-headers-${KVER}/include/linux/"
rm /usr/src/linux-headers-${KVER}/include/linux/full_duplex_interface.h
# Removing installed files from the source tree
uninstall-from-src:
@echo "Removing installed headers from: ${LINUX_SRC_ROOT}/include/linux"
rm ${LINUX_SRC_ROOT}/include/linux/full_duplex_interface.h
# Build Docker deployed image (Docker image with built and installed
# Linux Full Duplex Interface) on the basis of linux-full-duplex-interface
docker-image:
$(call docker_build, ${DOCKER_OUT_IMAGE_TAG})
# Test ourselves in Docker environment (similar to docker-image, but
# usually builds various build configurations and if all fine, just removes
# the build artifacts)
test: docker-image
$(call docker_build, ${DOCKER_OUT_TEST_IMAGE_TAG})
# Will remove the docker image generated by the build
# and all dangling images as well
clean-docker-images:
docker rmi ${DOCKER_OUT_IMAGE_TAG} --force
docker rmi ${DOCKER_OUT_TEST_IMAGE_TAG} --force
docker image prune --force
docker system prune --force
print-output-docker-image-tag:
@echo "${DOCKER_OUT_IMAGE_TAG}"