Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
#
Lucio Andrés Illanes Albornoz (arab, vxp) 820be1
# . ./build.vars and set -o errexit -o noglob are assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
#
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
# Order: no-complex, native
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
Lucio Andrés Illanes Albornoz (arab, vxp) 672107
# Git clone what we need.
Lucio Andrés Illanes Albornoz (arab, vxp) 672107
fetch_git lazy ${GITROOT}/lazy;
Lucio Andrés Illanes Albornoz (arab, vxp) 672107
Lucio Andrés Illanes Albornoz (arab, vxp) 6e940c
export lz_arch=${ARCH} lz_cflags_debug=-O2 lz_target=${TARGET};
lalbornoz 340f4c
Lucio Andrés Illanes Albornoz (arab, vxp) 9ba5d3
if [ "${3}" = no-complex ]; then
lalbornoz 340f4c
	# Musl: build (no-complex)
Lucio Andrés Illanes Albornoz (arab, vxp) 6e940c
	_install=install_no_complex;
Lucio Andrés Illanes Albornoz (arab, vxp) c49754
	set_build_dir musl-${PKG_MUSL_VERSION}-${3} cross;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	if ! is_build_script_done fetch; then
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		fetch http://www.musl-libc.org/releases/musl-${PKG_MUSL_VERSION}.tar.gz	\
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
			${PKG_MUSL_SHA256SUM};
Lucio Andrés Illanes Albornoz (arab, vxp) afe7b9
		secure_rm mmglue;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		fetch_git mmglue ${GITROOT}/mmglue;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		set_build_script_done fetch -extract;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	if ! is_build_script_done extract; then
Lucio Andrés Illanes Albornoz (arab, vxp) afe7b9
		secure_rm musl-${PKG_MUSL_VERSION};
Lucio Andrés Illanes Albornoz (arab, vxp) 820be1
		tar -xf ${DLCACHEDIR}/musl-${PKG_MUSL_VERSION}.tar.gz;
Lucio Andrés Illanes Albornoz (arab, vxp) 820be1
		set +o noglob; cp -R -- mmglue/* musl-${PKG_MUSL_VERSION}/; set -o noglob;
Lucio Andrés Illanes Albornoz (arab, vxp) 951620
		set_build_script_done extract -patch;
Lucio Andrés Illanes Albornoz (arab, vxp) 951620
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 951620
	if ! is_build_script_done patch; then
Lucio Andrés Illanes Albornoz (arab, vxp) 951620
		patch -b -d musl-${PKG_MUSL_VERSION} -p1	\
Lucio Andrés Illanes Albornoz (arab, vxp) 951620
			< ${MIDIPIX_BUILD_PWD}/musl-${PKG_MUSL_VERSION}.local.patch;
Lucio Andrés Illanes Albornoz (arab, vxp) 951620
		set_build_script_done patch -configure;
lalbornoz 340f4c
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 9ba5d3
elif [ "${3}" = native ]; then
lalbornoz 340f4c
	# Musl: build (full)
Lucio Andrés Illanes Albornoz (arab, vxp) 6e940c
	_install=install;
Lucio Andrés Illanes Albornoz (arab, vxp) 9ba5d3
	set_build_dir musl-${PKG_MUSL_VERSION} "${3}";
Lucio Andrés Illanes Albornoz (arab, vxp) 9ba5d3
elif [ "${3}" = full ]; then
lalbornoz 340f4c
	# Musl: build (full)
Lucio Andrés Illanes Albornoz (arab, vxp) 6e940c
	_install=install;
Lucio Andrés Illanes Albornoz (arab, vxp) c49754
	set_build_dir musl-${PKG_MUSL_VERSION} cross;
lalbornoz 340f4c
fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
if ! is_build_script_done configure; then
Lucio Andrés Illanes Albornoz (arab, vxp) afe7b9
	secure_rm ${PKG_BUILD_DIR};
Lucio Andrés Illanes Albornoz (arab, vxp) afe7b9
	insecure_mkdir ${PKG_BUILD_DIR};
Lucio Andrés Illanes Albornoz (arab, vxp) afe7b9
	secure_cd ${PKG_BUILD_DIR};
Lucio Andrés Illanes Albornoz (arab, vxp) 13421a
	env	lz_cflags_cmdline="${PKG_MUSL_CFLAGS_CONFIGURE_EXTRA}"	\
Lucio Andrés Illanes Albornoz (arab, vxp) 13421a
		lz_debug="yes"						\
Lucio Andrés Illanes Albornoz (arab, vxp) f9c386
	../lazy/lazy				\
Lucio Andrés Illanes Albornoz (arab, vxp) f9c386
		-a ${ARCH}			\
Lucio Andrés Illanes Albornoz (arab, vxp) f9c386
		-c gcc				\
Lucio Andrés Illanes Albornoz (arab, vxp) 820be1
		-f ${PKG_PREFIX}		\
Lucio Andrés Illanes Albornoz (arab, vxp) f9c386
		-n musl				\
Lucio Andrés Illanes Albornoz (arab, vxp) f9c386
		-p ../musl-${PKG_MUSL_VERSION}	\
Lucio Andrés Illanes Albornoz (arab, vxp) f9c386
		-t ${lz_target}			\
lalbornoz 340f4c
		-x config;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	set_build_script_done configure clean -build;
lalbornoz 340f4c
else
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	cd ${PKG_BUILD_DIR};
lalbornoz 340f4c
fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
if ! is_build_script_done clean; then
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	make ${MAKEFLAGS} clean;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	set_build_script_done clean -build;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
if ! is_build_script_done build; then
Lucio Andrés Illanes Albornoz (arab, vxp) f9c386
	./lazy	-e ${_install}			\
lalbornoz 340f4c
		-x build;
Lucio Andrés Illanes Albornoz (arab, vxp) b8dc4b
	[ "${3}" = native ] &&			\
Lucio Andrés Illanes Albornoz (arab, vxp) 820be1
		ln -sf -- ../lib/libc.so ${PKG_PREFIX}/bin/ldd;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	set_build_script_done build finish;
lalbornoz 340f4c
fi;
lalbornoz 340f4c
lalbornoz 340f4c
# vim:filetype=sh