aboutsummaryrefslogtreecommitdiff
blob: 286e4581cb8aa256c58190f751220dc8bd1cda75 (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
# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

src_prepare() {
	default

	# flag cleanup
	sed -i -r \
		-e 's:[[:space:]]?-(Werror|Os|falign-(functions|jumps|loops|labels)=1|fomit-frame-pointer)\>::g' \
		Makefile.flags || gen_die

	sed -i \
		-e 's:-static-libgcc::' \
		Makefile.flags || die

	cp "${TEMP}"/busybox-config "${S}"/.config \
		|| die "Failed top copy '${TEMP}/busybox-config' to '${S}/.config'!"

	cp "${TEMP}"/busybox-config "${S}"/.config.gk_orig \
		|| die "Failed top copy '${TEMP}/busybox-config' to '${S}/.config.gk_orig'!"
}

bbmake() {
	local args=(
		V=1
		CROSS_COMPILE="${CHOST}-"
		AR="${AR}"
		CC="${CC}"
		HOSTCC="${BUILD_CC}"
		HOSTCFLAGS="${BUILD_CFLAGS}"
		PKG_CONFIG="${PKG_CONFIG}"
	)
	make "${args[@]}" "$@"
}

src_configure() {
	tc-export AR CC BUILD_CC PKG_CONFIG
	BUILD_CFLAGS=${CFLAGS}
	BUILD_CFLAGS+=" -D_FILE_OFFSET_BITS=64"
	gkexec "yes '' | bbmake V=1 oldconfig" 1
}

src_compile() {
	gkexec bbmake busybox
}

src_install() {
	#gkmake CONFIG_PREFIX="${D}" install
	mkdir "${D}"/bin || die "Failed to create '${D}/bin'!"

	cp -a busybox "${D}"/bin/ \
		|| die "Failed to copy '${S}/busybox' to '${D}/bin/'!"

	"${STRIP}" --strip-all "${D}"/bin/busybox \
		|| die "Failed to strip '${D}/bin/busybox'!"

	mkdir "${D}"/configs || die "Failed to create '${D}/configs'!"
	cp -a --target-directory="${D}"/configs \
		"${S}"/.config \
		"${S}"/.config.gk_orig \
		|| die "Failed to copy '${S}/.config{,gk_orig}' to '${D}/configs'!"
}