midipix / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone
Blob Blame History Raw
#
# 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