summaryrefslogtreecommitdiffstats
path: root/build
blob: 8be616a5e3e0694aaf00a48c46fac1349dbd3e3b (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
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
#! /usr/bin/make -f

include ../source.mk

config_enabled = \
	config_enabled() \
	{ \
		[ "x$${1}" = 'x-' ] && return 0; \
		grep "^CONFIG_$${1}=y$$" <src/.config >/dev/null 2>&1; \
	}
install_init_script = \
	install_init_script() \
	{ \
		script="$${1}"; \
		shift; \
		install -p -m 0755 "../src.etc/init.d/$${script}" \
			"dest/etc/init.d/$${script}"; \
		for link; do \
			ln -s "../init.d/$${script}" \
				"dest/etc/rc.d/$${link}$${script}"; \
		done; \
	}

nop:
	@:

menuconfig mrproper:
	oh-autobuild -T $@

build:
	KCONFIG_NOTIMESTAMP=1 oh-autobuild -- -j $${JOBS:-1}
	touch $@

install: build
	oh-autoinstall
	oh-fixperms
	oh-strip
	chmod u+s dest/bin/busybox
	mkdir -p dest/usr/share/busybox
	set -e; exec 3>dest/usr/share/busybox/alternatives; \
	for f in dest/bin/* dest/sbin/* dest/usr/bin/* dest/usr/sbin/*; do \
		mv "$${f}" "$${f}.busybox"; \
		printf '%s\n' "$${f#dest}" >&3; \
	done; \
	exec 3>&-
	set -e; $(config_enabled); $(install_init_script); \
	if config_enabled INIT; then \
		exec 3>dest/usr/share/busybox/init-scripts; \
		ln -sf /sbin/init dest/init; \
		install -d -m 0755 dest/etc; \
		install -p -m 0644 inittab dest/etc/inittab; \
		install -d -m 0755 dest/etc/init.d dest/etc/rc.d; \
		install -p -m 0755 ../src.etc/init.d/rc dest/etc/init.d/rc; \
		install -p -m 0755 ../src.etc/rc.common dest/etc/rc.common; \
		ln -sf rc dest/etc/init.d/rcS; \
		ln -sf rc dest/etc/init.d/rcK; \
		while read -r config script links; do \
			if [ "x$${links%abled}" = "x$${links}" ]; then \
				config_enabled "$${config}" && \
					install_init_script "$${script}" \
						$${links}; \
			else \
				config_enabled "$${config}" && \
					install_init_script "$${script}"; \
				printf '%s %s\n' "$${script}" "$${links}" >&3; \
			fi; \
		done <../scripts; \
		exec 3>&-; \
	fi; \
	if config_enabled HTTPD; then \
		install -d -m 0755 dest/var/www; \
	fi; \
	if config_enabled IFUP && config_enabled IFDOWN; then \
		install -d -m 0755 dest/etc; \
		for dir in '' if-pre-up.d if-up.d if-down.d if-post-down.d; do \
			install -d -m 0755 "dest/etc/network/$${dir}"; \
		done; \
		install -m 0644 ../src.etc/network/functions \
			dest/etc/network/; \
		while read -r config hook; do \
			for dir in if-pre-up.d if-up.d if-down.d \
				if-post-down.d; do \
				[ -f "../src.etc/network/$${dir}/$${hook}" ] \
					|| continue; \
				config_enabled "$${config}" && install -m 0755 \
					"../src.etc/network/$${dir}/$${hook}" \
					"dest/etc/network/$${dir}"; \
			done; \
		done <../network-hooks; \
	fi; \
	if config_enabled UDHCPC; then \
		install -d -m 0755 dest/usr/share/udhcpc; \
		install -p -m 0755 ../src.usr/share/udhcpc/default.script \
			dest/usr/share/udhcpc/default.script; \
	fi; \
	if config_enabled FEATURE_WGET_OPENSSL; then \
		printf 'Extra-Depends: wolfutil\n' >>busybox.substvars; \
	else \
		printf 'Extra-Depends:\n' >>busybox.substvars; \
	fi
	oh-installfiles
	oh-shlibdeps