Blame pkg.build

Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
#
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
# . ./build.vars and set -o errexit are assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
#
Lucio Andrés Illanes Albornoz (arab, vxp) f9c386
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
parse_with_pkg_name ${SCRIPT_FNAME%[0-9][0-9]*} ${2} ${PKG_BUILD_NAMES};
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
if ! is_build_script_done fetch; then
Lucio Andrés Illanes Albornoz (arab, vxp) a41d08
	if test_cmd pkg_${PKG_NAME}_fetch; then
Lucio Andrés Illanes Albornoz (arab, vxp) a41d08
		pkg_${PKG_NAME}_fetch;
Lucio Andrés Illanes Albornoz (arab, vxp) fa26ee
	else
Lucio Andrés Illanes Albornoz (arab, vxp) a41d08
		if [ "${PKG_URL_TYPE:-wget}" = wget ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) a41d08
			fetch "${PKG_URL}" ${PKG_SHA256SUM};
Lucio Andrés Illanes Albornoz (arab, vxp) a41d08
		else
Lucio Andrés Illanes Albornoz (arab, vxp) a41d08
			fetch_git ${PKG_SUBDIR} ${PKG_URL} "${PKG_GIT_ARGS_EXTRA}";
Lucio Andrés Illanes Albornoz (arab, vxp) a41d08
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d3841
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	set_build_script_done fetch -extract;
lalbornoz 340f4c
fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
if test_cmd pkg_${PKG_NAME}_finish; then
Lucio Andrés Illanes Albornoz (arab, vxp) f9c386
	pkg_${PKG_NAME}_finish; exit 0;
Lucio Andrés Illanes Albornoz (arab, vxp) 9ba5d3
elif [ "${PKG_URL_TYPE:-wget}" = wget ] &&\
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
! is_build_script_done extract; then
Lucio Andrés Illanes Albornoz (arab, vxp) 96b309
	rm_if_exists ${PKG_SUBDIR};
Lucio Andrés Illanes Albornoz (arab, vxp) 9d8145
	if [ "${PKG_FNAME##*.tar.}" = "bz2" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 9d8145
		bunzip2 -d < ${PKG_FNAME} | tar -xf -;
Lucio Andrés Illanes Albornoz (arab, vxp) 9d8145
	elif [ "${PKG_FNAME##*.tar.}" = "gz" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 9d8145
		gunzip -d < ${PKG_FNAME} | tar -xf -;
Lucio Andrés Illanes Albornoz (arab, vxp) 9d8145
	elif [ "${PKG_FNAME##*.tar.}" = "xz" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 9d8145
		xz -d < ${PKG_FNAME} | tar -xf -;
Lucio Andrés Illanes Albornoz (arab, vxp) 9d8145
	elif [ "${PKG_FNAME##*.t}" = "bz2" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 9d8145
		bunzip2 -d < ${PKG_FNAME} | tar -xf -;
Lucio Andrés Illanes Albornoz (arab, vxp) 9d8145
	elif [ "${PKG_FNAME##*.t}" = "gz" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 9d8145
		gunzip -d < ${PKG_FNAME} | tar -xf -;
Lucio Andrés Illanes Albornoz (arab, vxp) 9d8145
	elif [ "${PKG_FNAME##*.t}" = "xz" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 9d8145
		xz -d < ${PKG_FNAME} | tar -xf -;
Lucio Andrés Illanes Albornoz (arab, vxp) 9d8145
	else
Lucio Andrés Illanes Albornoz (arab, vxp) 9d8145
		tar -xf ${PKG_FNAME};
Lucio Andrés Illanes Albornoz (arab, vxp) 9d8145
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 5a3901
	if test_cmd pkg_${PKG_NAME}_extract_post; then
Lucio Andrés Illanes Albornoz (arab, vxp) 5a3901
		pkg_${PKG_NAME}_extract_post;
Lucio Andrés Illanes Albornoz (arab, vxp) 5a3901
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	set_build_script_done extract -build_dir;
lalbornoz 340f4c
fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
if [ -z "${PKG_BUILD_DIR}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	set_build_dir ${PKG_SUBDIR} ${PKG_BUILD_TYPE:-native};
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
if ! is_build_script_done build_dir; then
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	[ ${PKG_SUBDIR} != ${PKG_BUILD_DIR} ] &&\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		rm_if_exists -m ${PKG_BUILD_DIR};
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	set_build_script_done build_dir -patch;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
if ! is_build_script_done patch; then
Lucio Andrés Illanes Albornoz (arab, vxp) 6d967c
	if [ ${PKG_AUTOGEN:-0} -eq 1 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 6d967c
		cd ${PKG_SUBDIR} &&				\
Lucio Andrés Illanes Albornoz (arab, vxp) 8afad0
		install -m 0700 ${MIDIPIX_BUILD_PWD}/config.sub build-aux/ &&\
Lucio Andrés Illanes Albornoz (arab, vxp) 6d967c
				./autogen.sh && cd ${OLDPWD};
Lucio Andrés Illanes Albornoz (arab, vxp) 5bc428
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	for PATCH_FNAME in portage/${PKG_SUBDIR}.midipix.patch	\
Lucio Andrés Illanes Albornoz (arab, vxp) 8afad0
			${MIDIPIX_BUILD_PWD}/${PKG_SUBDIR}.local.patch	\
Lucio Andrés Illanes Albornoz (arab, vxp) 8afad0
			${MIDIPIX_BUILD_PWD}/${PKG_SUBDIR}.local@${BUILD_HNAME}.patch; do
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		[ -r ${PATCH_FNAME} ] &&\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			patch -b -d ${PKG_SUBDIR} -p1 < ${PATCH_FNAME};
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	done; unset PATCH_FNAME;
Lucio Andrés Illanes Albornoz (arab, vxp) f9c386
	if [ -n "${PKG_PATCHES_EXTRA_URL}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		apply_patches ${PKG_PATCHES_EXTRA_URL} ${PKG_SUBDIR};
Lucio Andrés Illanes Albornoz (arab, vxp) f9c386
		if [ -n "${PKG_PATCHES_EXTRA_MANIFEST}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) f9c386
			compare_hash_manifest ${PKG_PATCHES_EXTRA_MANIFEST};
Lucio Andrés Illanes Albornoz (arab, vxp) f9c386
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 680d83
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	[ -x ${PKG_SUBDIR}/configure ] &&			\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		cp portage/config.cache ${PKG_BUILD_DIR}/;
Lucio Andrés Illanes Albornoz (arab, vxp) 2dd87f
	if [ ${PKG_LIBTOOL_MIDIPIX:-0} -eq 1 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) ce7607
		cp portage/libtool.midipix ${PKG_SUBDIR}/;
Lucio Andrés Illanes Albornoz (arab, vxp) 2dd87f
		sed -i.orig -e "/^libdir=/s/libdir='/libdir='\$PKG_PREFIX\//"\
Lucio Andrés Illanes Albornoz (arab, vxp) 2dd87f
			${PKG_SUBDIR}/libtool.midipix;
Lucio Andrés Illanes Albornoz (arab, vxp) 840cbd
		if [ ${PKG_LIBTOOL_MIDIPIX_FIX:-0} -eq 1 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 840cbd
			sed -i.orig.orig									\
Lucio Andrés Illanes Albornoz (arab, vxp) 840cbd
				-e '/^\s\+test \"\$inst_prefix_dir\" = \"\$destdir\" && \\$/{s/^/#/;n;s/^/#/}'	\
Lucio Andrés Illanes Albornoz (arab, vxp) 840cbd
				${PKG_SUBDIR}/libtool.midipix;
Lucio Andrés Illanes Albornoz (arab, vxp) 840cbd
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 2dd87f
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	set_build_script_done patch -configure;
lalbornoz 340f4c
fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
cd ${PKG_BUILD_DIR};
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
if [ -x ../${PKG_SUBDIR}/configure ]\
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
&& ! is_build_script_done configure; then
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	if test_cmd pkg_${PKG_NAME}_configure_pre; then
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		pkg_${PKG_NAME}_configure_pre;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	AR="${PKG_AR_CONFIGURE}" CC="${PKG_CC_CONFIGURE}"\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	CFLAGS="${PKG_CFLAGS_CONFIGURE}${PKG_CFLAGS_CONFIGURE_EXTRA:+ ${PKG_CFLAGS_CONFIGURE_EXTRA}}"\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	LDFLAGS="${PKG_LDFLAGS_CONFIGURE}${PKG_LDFLAGS_CONFIGURE_EXTRA:+ ${PKG_LDFLAGS_CONFIGURE_EXTRA}}"\
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	../${PKG_SUBDIR}/configure				\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		${PKG_CONFIGURE_ARGS} ${PKG_CONFIGURE_ARGS_EXTRA};
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) 1d0876
	set_build_script_done clean;
lalbornoz 340f4c
fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
if [ ${PKG_NO_CLEAN:-0} -eq 0 ]\
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
&& ! is_build_script_done clean; then
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	make 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) c688c1
	if test_cmd pkg_${PKG_NAME}_build; then
Lucio Andrés Illanes Albornoz (arab, vxp) c688c1
		pkg_${PKG_NAME}_build;
Lucio Andrés Illanes Albornoz (arab, vxp) c688c1
	else
Lucio Andrés Illanes Albornoz (arab, vxp) 11ee19
		if [ "${PKG_SLIBTOOL}" != "none" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 11ee19
			export MAKE="make LIBTOOL=${PKG_SLIBTOOL:-slibtool}";
Lucio Andrés Illanes Albornoz (arab, vxp) 11ee19
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) c688c1
		run_cmd_unsplit make					\
Lucio Andrés Illanes Albornoz (arab, vxp) c688c1
			${PKG_MAKEFLAGS_BUILD}				\
Lucio Andrés Illanes Albornoz (arab, vxp) c688c1
			${PKG_MAKEFLAGS_BUILD_EXTRA}			\
Lucio Andrés Illanes Albornoz (arab, vxp) c688c1
			"${PKG_AR_BUILD:+AR=${PKG_AR_BUILD}}"		\
Lucio Andrés Illanes Albornoz (arab, vxp) c688c1
			"${PKG_CC_BUILD:+CC=${PKG_CC_BUILD}}"		\
Lucio Andrés Illanes Albornoz (arab, vxp) c688c1
			"${PKG_CFLAGS_BUILD:+CFLAGS=${PKG_CFLAGS_BUILD}}"\
Lucio Andrés Illanes Albornoz (arab, vxp) c688c1
			"${PKG_CFLAGS_BUILD_EXTRA:+CFLAGS+=${PKG_CFLAGS_BUILD_EXTRA}}"\
Lucio Andrés Illanes Albornoz (arab, vxp) c688c1
			"${PKG_LDFLAGS_BUILD:+LDFLAGS=${PKG_LDFLAGS_BUILD}}"\
Lucio Andrés Illanes Albornoz (arab, vxp) c688c1
			"${PKG_LDFLAGS_BUILD_EXTRA:+LDFLAGS+=${PKG_LDFLAGS_BUILD_EXTRA}}";
Lucio Andrés Illanes Albornoz (arab, vxp) c688c1
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	set_build_script_done build -install;
lalbornoz 340f4c
fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
if ! is_build_script_done install; then
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	if test_cmd pkg_${PKG_NAME}_install; then
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		pkg_${PKG_NAME}_install;
Lucio Andrés Illanes Albornoz (arab, vxp) f9c386
	else
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		run_cmd_unsplit make				\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			${PKG_MAKEFLAGS_INSTALL}		\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			${PKG_MAKEFLAGS_INSTALL_EXTRA}		\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			"${PKG_AR_INSTALL:+AR=${PKG_AR_INSTALL}}"\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			"${PKG_CC_INSTALL:+CC=${PKG_CC_INSTALL}}"\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			"${PKG_CC_INSTALL:+CC=${PKG_CC_INSTALL}}"\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			"${PKG_CFLAGS_INSTALL:+CFLAGS=${PKG_CFLAGS_INSTALL}}"\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			"${PKG_CFLAGS_INSTALL_EXTRA:+CFLAGS+=${PKG_CFLAGS_INSTALL_EXTRA}}"\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			"${PKG_LDFLAGS_INSTALL:+LDFLAGS=${PKG_LDFLAGS_INSTALL}}"\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			"${PKG_LDFLAGS_INSTALL_EXTRA:+LDFLAGS+=${PKG_LDFLAGS_INSTALL_EXTRA}}"\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			"${PKG_RANLIB_INSTALL:+RANLIB=${PKG_RANLIB_INSTALL}}"\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			${PKG_INSTALL_TARGET:=install};
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		if [ -n "${PKG_PREFIX_EXTRA}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			run_cmd_unsplit make			\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
				${PKG_MAKEFLAGS_INSTALL}	\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
				${PKG_MAKEFLAGS_INSTALL_EXTRA}	\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
				"${PKG_AR_INSTALL:+AR=${PKG_AR_INSTALL}}"\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
				"${PKG_CC_INSTALL:+CC=${PKG_CC_INSTALL}}"\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
				"${PKG_CC_INSTALL:+CC=${PKG_CC_INSTALL}}"\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
				"${PKG_CFLAGS_INSTALL:+CFLAGS=${PKG_CFLAGS_INSTALL}}"\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
				"${PKG_CFLAGS_INSTALL_EXTRA:+CFLAGS+=${PKG_CFLAGS_INSTALL_EXTRA}}"\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
				"${PKG_LDFLAGS_INSTALL:+LDFLAGS=${PKG_LDFLAGS_INSTALL}}"\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
				"${PKG_LDFLAGS_INSTALL_EXTRA:+LDFLAGS+=${PKG_LDFLAGS_INSTALL_EXTRA}}"\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
				"${PKG_RANLIB_INSTALL:+RANLIB=${PKG_RANLIB_INSTALL}}"\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
				${PKG_PREFIX_EXTRA}		\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
				${PKG_INSTALL_TARGET:=install};
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		if test_cmd pkg_${PKG_NAME}_install_post; then
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			pkg_${PKG_NAME}_install_post;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) f9c386
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 95bf77
	find ${PKG_PREFIX}/lib -type f -name \*.la -exec rm -f {} \;
Lucio Andrés Illanes Albornoz (arab, vxp) 86c0f5
	if [ ${PKG_LIBFILES_FIX:-0} -eq 1 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 951620
		env TARGET="${TARGET}"				\
Lucio Andrés Illanes Albornoz (arab, vxp) 86c0f5
		find . \( -name '*.so' -or -name '*.so.[0-9]'	\
Lucio Andrés Illanes Albornoz (arab, vxp) 86c0f5
			-or -name '*.so.[0-9].[0-9]' -or	\
Lucio Andrés Illanes Albornoz (arab, vxp) 86c0f5
			-name '*.so.[0-9].[0-9].[0-9]' \)	\
Lucio Andrés Illanes Albornoz (arab, vxp) 86c0f5
			-exec sh -c '				\
Lucio Andrés Illanes Albornoz (arab, vxp) 86c0f5
		SO_PNAME={}; SO_PNAME=${SO_PNAME#./};		\
Lucio Andrés Illanes Albornoz (arab, vxp) 86c0f5
		if [ "${SO_PNAME##*.}" = "so" ]; then		\
Lucio Andrés Illanes Albornoz (arab, vxp) 86c0f5
			SO_NAME=${SO_PNAME%%.*};		\
Lucio Andrés Illanes Albornoz (arab, vxp) 86c0f5
		else	SO_NAME=${SO_PNAME}; fi;		\
Lucio Andrés Illanes Albornoz (arab, vxp) 86c0f5
		echo perk -epdlltool ${SO_PNAME} \> ${SO_NAME}.def;					\
Lucio Andrés Illanes Albornoz (arab, vxp) 86c0f5
		perk -epdlltool ${SO_PNAME} > ${SO_NAME}.def;						\
Lucio Andrés Illanes Albornoz (arab, vxp) 951620
		echo ${TARGET}-dlltool -l ${SO_NAME}.lib.a -D ${SO_PNAME} -d ${SO_NAME}.def;		\
Lucio Andrés Illanes Albornoz (arab, vxp) 951620
		${TARGET}-dlltool -l ${SO_NAME}.lib.a -D ${SO_PNAME} -d ${SO_NAME}.def;			\
Lucio Andrés Illanes Albornoz (arab, vxp) 86c0f5
		echo cp ${SO_NAME}.lib.a '"${PKG_PREFIX}/lib"';						\
Lucio Andrés Illanes Albornoz (arab, vxp) 86c0f5
		cp ${SO_NAME}.lib.a '"${PKG_PREFIX}/lib" \;;
Lucio Andrés Illanes Albornoz (arab, vxp) 86c0f5
Lucio Andrés Illanes Albornoz (arab, vxp) 86c0f5
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	set_build_script_done install -finish;
lalbornoz 340f4c
fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
set_build_script_done finish;
lalbornoz 340f4c
lalbornoz 340f4c
# vim:filetype=sh