summaryrefslogtreecommitdiffhomepage
path: root/vars/musl.vars
blob: 147e6766724b623b9e40673f8e4edffa2ae257bb (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
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
#
# set -o errexit -o noglob are assumed.
# Order: no_complex_host, full_host, full
#

pkgp_musl_build_dir() {
	PKG_BUILD_DIR="${1}-${2}-${PKG_TARGET}";
};

pkgp_musl_configure() {
	ex_rtl_fileop rm "${PKG_BASE_DIR}/${PKG_BUILD_DIR}";
	ex_rtl_fileop mkdir "${PKG_BASE_DIR}/${PKG_BUILD_DIR}";
	ex_rtl_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}";
	env	lz_cflags_cmdline=""		\
		lz_debug="yes"			\
	../lazy/lazy				\
		-a "${ARCH}"			\
		-c gcc				\
		-f "${PKG_DESTDIR}"		\
		-n musl				\
		-p "../musl-${PKG_VERSION}"	\
		-t "${lz_target}"		\
		-x config;
};

pkg_musl_no_complex_host_all() {
	local _install _restart_at="${1}";
	PKG_MUSL_VERSION="${PKG_VERSION}";
	# Git clone what we need.
	ex_rtl_fetch_urls_git "${PKG_BASE_DIR}" "lazy=${DEFAULT_GITROOT}/lazy";
	export lz_arch="${ARCH}" lz_cflags_debug="-O2" lz_target="${PKG_TARGET}";
	# Musl: build (no-complex)
	_install=install_no_complex;
	pkgp_musl_build_dir "musl-${PKG_VERSION}" cross;
	if ! ex_pkg_state_test "${PKG_NAME}" fetch "${_restart_at}"; then
		ex_rtl_fetch_url_wget							\
			"http://www.musl-libc.org/releases/musl-${PKG_VERSION}.tar.gz"	\
			"${PKG_MUSL_NO_COMPLEX_SHA256SUM}";
		ex_rtl_fileop rm "${PKG_BASE_DIR}/mmglue";
		ex_rtl_fetch_urls_git "${PKG_BASE_DIR}" "mmglue=${DEFAULT_GITROOT}/mmglue";
		ex_pkg_state_set "${PKG_NAME}" fetch -extract;
	fi;
	if ! ex_pkg_state_test "${PKG_NAME}" extract "${_restart_at}"; then
		ex_rtl_fileop rm "musl-${PKG_VERSION}";
		tar -C "${PKG_BASE_DIR}" -xf "${BUILD_DLCACHEDIR}/musl-${PKG_VERSION}.tar.gz";
		set +o noglob;
		 ex_rtl_fileop cp ${PKG_BASE_DIR}/mmglue/* "${PKG_BASE_DIR}/musl-${PKG_VERSION}/";
		set -o noglob;
		ex_pkg_state_set "${PKG_NAME}" extract -configure;
	fi;
	if ! ex_pkg_state_test "${PKG_NAME}" configure "${_restart_at}"; then
		pkgp_musl_configure;
		ex_pkg_state_set "${PKG_NAME}" configure -build;
	else
		ex_rtl_fileop cd "${PKG_BUILD_DIR}";
	fi;
	if ! ex_pkg_state_test "${PKG_NAME}" install_subdirs "${_restart_at}"; then
		pkg_install_subdirs;
		ex_pkg_state_set "${PKG_NAME}" install_subdirs -build;
	fi;
	if ! ex_pkg_state_test "${PKG_NAME}" build "${_restart_at}"; then
		./lazy -e "${_install}" -x build;
		ex_pkg_state_set "${PKG_NAME}" build -install;
	fi;
	if ! ex_pkg_state_test "${PKG_NAME}" install "${_restart_at}"; then
		pkg_install;
		ex_pkg_state_set "${PKG_NAME}" install finish;
	fi;
};

pkg_musl_full_host_all() {
	local _install _restart_at="${1}";
	# Git clone what we need.
	ex_rtl_fetch_urls_git "${PKG_BASE_DIR}" "lazy=${DEFAULT_GITROOT}/lazy";
	export lz_arch="${ARCH}" lz_cflags_debug="-O2" lz_target="${PKG_TARGET}";
	# Musl: build (full)
	_install=install;
	pkgp_musl_build_dir "musl-${PKG_VERSION}" cross;
	if ! ex_pkg_state_test "${PKG_NAME}" configure "${_restart_at}"; then
		pkgp_musl_configure;
		ex_pkg_state_set "${PKG_NAME}" configure -build;
	else
		ex_rtl_fileop cd "${PKG_BUILD_DIR}";
	fi;
	if ! ex_pkg_state_test "${PKG_NAME}" install_subdirs "${_restart_at}"; then
		pkg_install_subdirs;
		ex_pkg_state_set "${PKG_NAME}" install_subdirs -build;
	fi;
	if ! ex_pkg_state_test "${PKG_NAME}" build "${_restart_at}"; then
		./lazy -e "${_install}" -x build;
		ex_pkg_state_set "${PKG_NAME}" build -install;
	fi;
	if ! ex_pkg_state_test "${PKG_NAME}" install "${_restart_at}"; then
		pkg_install;
		ex_pkg_state_set "${PKG_NAME}" install finish;
	fi;
};

pkg_musl_full_all() {
	local _install _restart_at="${1}";
	# Git clone what we need.
	ex_rtl_fetch_urls_git "${PKG_BASE_DIR}" "lazy=${DEFAULT_GITROOT}/lazy";
	export lz_arch="${ARCH}" lz_cflags_debug="-O2" lz_target="${PKG_TARGET}";
	# Musl: build (full)
	_install=install;
	pkgp_musl_build_dir "musl-${PKG_VERSION}" native;
	if ! ex_pkg_state_test "${PKG_NAME}" configure "${_restart_at}"; then
		pkgp_musl_configure;
		ex_pkg_state_set "${PKG_NAME}" configure -build;
	else
		ex_rtl_fileop cd "${PKG_BUILD_DIR}";
	fi;
	if ! ex_pkg_state_test "${PKG_NAME}" install_subdirs "${_restart_at}"; then
		pkg_install_subdirs;
		ex_pkg_state_set "${PKG_NAME}" install_subdirs -build;
	fi;
	if ! ex_pkg_state_test "${PKG_NAME}" build "${_restart_at}"; then
		./lazy -e "${_install}" -x build;
		ex_rtl_fileop ln_symbolic ../lib/libc.so "${PKG_DESTDIR}/bin/ldd";
		ex_pkg_state_set "${PKG_NAME}" build -install;
	fi;
	if ! ex_pkg_state_test "${PKG_NAME}" install "${_restart_at}"; then
		pkg_install;
		ex_pkg_state_set "${PKG_NAME}" install finish;
	fi;
};

# vim:filetype=sh