-
Notifications
You must be signed in to change notification settings - Fork 36
/
Makefile
213 lines (149 loc) · 7.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
KERNEL ?= $(patsubst %/,%,$(dir $(wildcard armv7l/*-*/.latest)))
-include $(KERNEL)/include.mk
# Default variables
REVISION ?= manual
KERNELS ?= $(wildcard x86_64/*-* armv7l/*-* aarch64/*-*)
KERNEL_ARCH ?= $(shell echo $(KERNEL) | cut -d/ -f1)
-include $(KERNEL_ARCH)/include.mk
KERNEL_VERSION ?= $(shell echo $(KERNEL) | cut -d/ -f2 | cut -d- -f1)
KERNEL_FLAVOR ?= $(shell echo $(KERNEL) | cut -d/ -f2 | cut -d- -f2)
KERNEL_FULL ?= $(KERNEL_ARCH)-$(KERNEL_VERSION)-$(KERNEL_FLAVOR)-$(REVISION)
DOCKER_BUILDER ?= moul/kernel-builder:latest
CONCURRENCY_LEVEL ?= $(shell expr 1 + `nproc || sysctl -n hw.ncpu`)
J ?= -j $(CONCURRENCY_LEVEL)
S3_TARGET ?= s3://$(shell whoami)/$(KERNEL_FULL)/
STORE_HOSTNAME ?= store.scw.42.am
STORE_USERNAME ?= $(shell whoami)
STORE_TARGET ?= $(STORE_HOSTNAME):store/kernels/$(KERNEL_FULL)
CHECKOUT_TARGET ?= refs/tags/v$(KERNEL_VERSION)
LOCALVERSION ?= -$(KERNEL_FLAVOR)-$(REVISION)
KBUILD_BUILD_USER ?= $(shell whoami)
KBUILD_BUILD_HOST ?= $(shell hostname)
CCACHE_DIR ?= $(PWD)/ccache
LINUX_PATH=/usr/src/linux
KERNEL_TYPE ?= mainline
ENTER_COMMAND ?= (git show-ref refs/tags/v$(KERNEL_VERSION) >/dev/null || git fetch --tags) && git checkout $(CHECKOUT_TARGET) && git log HEAD^..HEAD
SHELL_EXEC_CMD ?= make -f rules.mk shell
TRAVIS_TAG ?=
all: help
.PHONY: help
help:
@echo 'General purpose commands'
@echo ' menuconfig KERNEL=4.0.5-std run "make menuconfig" in the builder container'
@echo ' oldconfig KERNEL=4.0.5-std run "make oldconfig" in the builder container'
@echo ' olddefconfig KERNEL=4.0.5-std run "make olddefconfig" in the builder container'
@echo ' build KERNEL=4.0.5-std run "make build" in the builder container'
@echo ' shell KERNEL=4.0.5-std open a shell in the kernel builder image'
@echo ' diff KERNEL=4.0.5-std show diffs between 2 .config files'
@echo ' publish_on_s3 S3_TARGET=s3://me/ publish uImage, dtbs, lib, modules on s3'
@echo ' publish_on_store STORE_TARGET=str.io/me publish uImage, dtbs, lib, modules on store'
@echo ' create KERNEL=5.1.2-std create a new kernel directory'
print-%:
@echo $* = $($*)
info:
@echo "KERNEL $(KERNEL)"
@echo "KERNEL_FLAVOR $(KERNEL_FLAVOR)"
@echo "KERNEL_FULL $(KERNEL_FULL)"
@echo "KERNEL_TYPE $(KERNEL_TYPE)"
@echo "KERNEL_VERSION $(KERNEL_VERSION)"
@echo "KERNEL_ARCH $(KERNEL_ARCH)"
@echo "ARCH_CONFIG $(ARCH_CONFIG)"
@echo "CONCURRENCY_LEVEL $(CONCURRENCY_LEVEL)"
@echo "DOCKER_ENV $(DOCKER_ENV)"
@echo "DOCKER_VOLUMES $(DOCKER_VOLUMES)"
@echo "LINUX_PATH $(LINUX_PATH)"
@echo "DOCKER_BUILDER $(DOCKER_BUILDER)"
@echo "ENTER_COMMAND $(ENTER_COMMAND)"
@echo "S3_TARGET $(S3_TARGET)"
bump-builder:
docker pull $(DOCKER_BUILDER)
create:
@test -d ./$(KERNEL) && echo " Kernel $(KERNEL) already exists !" && exit 1 || true
mkdir -p $(KERNEL)
touch $(KERNEL)/.config $(KERNEL)/patch.sh
@echo " Now you can generate a default configuration using:"
@echo " - make mvebu_v7_defconfig KERNEL=$(KERNEL)"
shell menuconfig:: local_assets
docker run -it $(DOCKER_ENV) $(DOCKER_VOLUMES) $(DOCKER_BUILDER) \
make -f rules.mk ENTER_COMMAND="$(ENTER_COMMAND)" J="$(J)" enter $@ leave
oldconfig olddefconfig $(ARCH_CONFIG)_defconfig dtbs diff cache_stats uImage build bzImage:: local_assets
docker run -i $(DOCKER_ENV) $(DOCKER_VOLUMES) $(DOCKER_BUILDER) \
make -f rules.mk ENTER_COMMAND="$(ENTER_COMMAND)" J="$(J)" enter $@ leave
shell_exec::
docker exec -it `docker ps -f image=$(DOCKER_BUILDER) -f event=start -lq` $(SHELL_EXEC_CMD)
publish_uImage_on_s3: dist/$(KERNEL_FULL)/uImage
s3cmd put --acl-public $< $(S3_TARGET)
wget --read-timeout=3 --tries=0 -O - $(shell s3cmd info $(S3_TARGET)uImage | grep URL | awk '{print $$2}') >/dev/null
publish_on_s3: dist/$(KERNEL_FULL)/dtbs/_ dist/$(KERNEL_FULL)/lib.tar.gz dist/$(KERNEL_FULL)/include.tar.gz
cd dist/$(KERNEL_FULL) && \
for file in lib.tar.gz include.tar.gz uImage* *zImage* config* vmlinuz* build.txt modules.order modules.builtin kernel.release System.map Module.symvers dtbs/*; do \
s3cmd put --acl-public $$file $(S3_TARGET); \
sleep 5; \
done
publish_on_store: dist/$(KERNEL_FULL)/lib.tar.gz dist/$(KERNEL_FULL)/include.tar.gz
ssh $(shell echo "$(STORE_TARGET)" | cut -d: -f1) mkdir -p $(shell echo "$(STORE_TARGET)" | cut -d: -f2)
cd dist/$(KERNEL_FULL) && \
for file in lib.tar.gz include.tar.gz uImage* *zImage* config* vmlinuz* build.txt modules.order modules.builtin kernel.release System.map Module.symvers dtbs/*; do \
if [ -f $$file ]; then \
scp $$file $(STORE_TARGET)/; \
fi; \
done
publish_on_store_ftp: dist/$(KERNEL_FULL)/dtbs/_ dist/$(KERNEL_FULL)/lib.tar.gz dist/$(KERNEL_FULL)/include.tar.gz
cd dist/$(KERNEL_FULL) && \
for file in lib.tar.gz include.tar.gz uImage* *zImage* config* vmlinuz* build.txt modules.order modules.builtin kernel.release System.map Module.symvers dtbs/*; do \
curl -T "$$file" --netrc ftp://$(STORE_HOSTNAME)/kernels/$(KERNEL_FULL)/; \
done
publish_on_store_sftp: dist/$(KERNEL_FULL)/dtbs/_ dist/$(KERNEL_FULL)/lib.tar.gz dist/$(KERNEL_FULL)/include.tar.gz
cd dist/$(KERNEL_FULL) && \
for file in lib.tar.gz include.tar.gz uImage* *zImage* config* vmlinuz* build.txt modules.order modules.builtin kernel.release System.map Module.symvers dtbs/*; do \
lftp -u $(STORE_USERNAME) -p 2222 sftp://$(STORE_HOSTNAME) -e "mkdir store/kernels/$(KERNEL_FULL); cd store/kernels/$(KERNEL_FULL); put $$file; bye"; \
done
dist/$(KERNEL_FULL)/dtbs/_:
mkdir -p dist/$(KERNEL_FULL)/dtbs
touch $@
dist/$(KERNEL_FULL)/lib.tar.gz: dist/$(KERNEL_FULL)/lib
tar -C dist/$(KERNEL_FULL) -cvzf $@ lib
dist/$(KERNEL_FULL)/include.tar.gz: dist/$(KERNEL_FULL)/include
tar -C dist/$(KERNEL_FULL) -cvzf $@ include
# dist/$(KERNEL_FULL)/lib dist/$(KERNEL_FULL)/include: build
clean:
rm -rf dist/$(KERNEL_FULL)
fclean: clean
rm -rf dist ccache
local_assets: $(KERNEL)/.config $(KERNEL)/patch.sh dist/$(KERNEL_FULL) ccache
$(KERNEL)/patch.sh: $(KERNEL)
touch $@
chmod +x $@
$(KERNEL)/.config:
@echo "💣 💀 ⚠️ WARNING: Kernel '$(KERNEL)' is not yet initialized."
exit 1
dist/$(KERNEL_FULL) ccache $(KERNEL):
mkdir -p $@
.PHONY: all build run menuconfig clean fclean ccache_stats
## Travis
travis_common:
#for file in */.config; do bash -n $$file; done
find . -name "*.bash" | xargs bash -n
make -n
tools/docker-checkconfig.sh:
curl -sLo $@ https://raw.githubusercontent.com/docker/docker/master/contrib/check-config.sh
chmod +x $@
tools/lxc-checkconfig.sh:
curl -sLo $@ https://raw.githubusercontent.com/dotcloud/lxc/master/src/lxc/lxc-checkconfig.in
chmod +x $@
travis_kernel: local_assets tools/lxc-checkconfig.sh tools/docker-checkconfig.sh
bash -n $(KERNEL)/.config
# Optional checks, these checks won't fail but we can see the detail in the Travis build result
CONFIG=$(KERNEL)/.config GREP=grep ./tools/lxc-checkconfig.sh || true
CONFIG=$(KERNEL)/.config ./tools/docker-checkconfig.sh || true
./tools/verify_kernel_config.pl $(KERNEL_ARCH)-$(KERNEL_TYPE) $(KERNEL)/.config
# Disabling make oldconfig check for now because of the memory limit on travis CI builds
# ./run $(MAKE) oldconfig
# travis_common + travis_kernel for each kernels
travis_check: travis_common
echo $(KERNELS)
for kernel in $(KERNELS); do \
make travis_kernel KERNEL=$$kernel || exit 1; \
done
travis_build:
$(MAKE) build KERNEL=$(shell echo $(TRAVIS_TAG) | cut -d- -f1,2) REVISION=$(shell echo $(TRAVIS_TAG) | cut -d- -f3)