summaryrefslogtreecommitdiffstats
path: root/build
blob: 0c8fb2aa56442d62a2985cff09cd22e4874e19cd (plain)
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
#!/usr/bin/make -f

include ../source.mk
include ../basever.mk

V = 1
KBUILD_ARCH = $$(oh-architecture "$${OPK_HOST_ARCH}")
JOBS = $$(printf '%s\n' /sys/devices/system/cpu/cpu[0-9]* | wc -l)

# ProteanOS's GCC is currently broken: "-print-file-name=include" simply prints
# "include".
nsif_shell = $$(shell $$(CC) -print-file-name=include)
nsif_gcc_v = $$($(CC) -v 2>&1 | sed -n '$$s/^gcc version \([0-9]\)\..*$$/\1/p;')
nsif_inc = /usr/include/$(OPK_HOST_ARCH)/gcc/$(nsif_gcc_v)
nsif_sed = 's|^\(NOSTDINC_FLAGS += .*\) $(nsif_shell)$$|\1 '"$(nsif_inc)|;"

nop:
	@:

menuconfig mrproper:
	oh-autobuild -T $@

build:
	set -e; \
	if [ 'x$(OPK_HOST_PLAT)' != 'xdev' ]; then \
		printf '%s\n' '$(OPK_SOURCE_VERSION)' | sed 's/^.*-/-/;' \
			1>src/localversion; \
		if ! [ -e src/Makefile.orig ]; then \
			mv src/Makefile src/Makefile.orig; \
			sed $(nsif_sed) src/Makefile.orig 1>src/Makefile; \
		fi; \
		read img_src img_dest <image; \
		oh-autobuild -T "$${img_src}" -- \
			-j "$${JOBS:-$(JOBS)}" \
			V=$(V) \
			KBUILD_BUILD_VERSION=0 \
			KBUILD_BUILD_TIMESTAMP="$$(TZ=UTC0 \
				date -d '@$(SOURCE_DATE_EPOCH)' '+%Y-%m-%d')"; \
	fi
	touch $@

install: build
	set -e; \
	if [ 'x$(OPK_HOST_PLAT)' != 'xdev' ]; then \
		read img_src img_dest <image; \
		install -D "src/arch/$(KBUILD_ARCH)/boot/$${img_src}" \
			linux-image-$(VER).data/boot/$${img_dest}; \
		ln -sf /boot/$${img_dest} linux-image-$(VER).data/$${img_dest};\
		install -D src/System.map \
			linux-sysmap-$(VER).data/boot/System.map; \
		mkdir -p linux-image-$(VER).data/etc/kernel/preinst.d \
			linux-image-$(VER).data/etc/kernel/postinst.d \
			linux-image-$(VER).data/etc/kernel/prerm.d \
			linux-image-$(VER).data/etc/kernel/postrm.d; \
	fi
	oh-autoinstall -T headers_install -- \
		INSTALL_HDR_PATH="$${PWD}/linux-libc-dev-common-$(VER).data/usr"
	find linux-libc-dev-common-$(VER).data/usr/include \
		\( -name .install -o -name ..install.cmd \
		-o -name .check -o -name ..check.cmd \) \
		-a -exec rm -f '{}' ';'
	mkdir linux-libc-dev-$(VER).data/usr/include/$(OPK_HOST_ARCH)
	mv linux-libc-dev-common-$(VER).data/usr/include/asm \
		linux-libc-dev-$(VER).data/usr/include/$(OPK_HOST_ARCH)/asm