midipix / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone
Blob Blame History Raw
#
# . ./build.vars and set -o errexit are assumed.
#

parse_with_pkg_name ${SCRIPT_FNAME%[0-9][0-9]*} ${2} ${PKG_BUILD_NAMES};
if ! is_build_script_done fetch; then
	if [ "${PKG_URL_TYPE:-wget}" = wget ]; then
		fetch ${PKG_URL} ${PKG_SHA256SUM};
	else
		fetch_git ${PKG_SUBDIR} ${PKG_URL} "${PKG_GIT_ARGS_EXTRA}";
	fi;
	set_build_script_done fetch -extract;
fi;
if test_cmd pkg_${PKG_NAME}_finish; then
	pkg_${PKG_NAME}_finish; exit 0;
elif [ "${PKG_URL_TYPE:-wget}" = wget ] &&\
! is_build_script_done extract; then
	rm_if_exists ${PKG_SUBDIR};
	tar -axf ${PKG_FNAME};
	set_build_script_done extract -build_dir;
fi;
if [ -z "${PKG_BUILD_DIR}" ]; then
	set_build_dir ${PKG_SUBDIR} ${PKG_BUILD_TYPE:-native};
fi;
if ! is_build_script_done build_dir; then
	[ ${PKG_SUBDIR} != ${PKG_BUILD_DIR} ] &&\
		rm_if_exists -m ${PKG_BUILD_DIR};
	set_build_script_done build_dir -patch;
fi;
if ! is_build_script_done patch; then
	for PATCH_FNAME in portage/${PKG_SUBDIR}.midipix.patch	\
			${_PWD}/${PKG_SUBDIR}.local.patch	\
			${_PWD}/${PKG_SUBDIR}.local@${BUILD_HNAME}.patch; do
		[ -r ${PATCH_FNAME} ] &&\
			patch -b -d ${PKG_SUBDIR} -p1 < ${PATCH_FNAME};
	done; unset PATCH_FNAME;
	if [ -n "${PKG_PATCHES_EXTRA_URL}" ]; then
		apply_patches ${PKG_PATCHES_EXTRA_URL} ${PKG_SUBDIR};
		if [ -n "${PKG_PATCHES_EXTRA_MANIFEST}" ]; then
			compare_hash_manifest ${PKG_PATCHES_EXTRA_MANIFEST};
		fi;
	fi;
	[ -x ${PKG_SUBDIR}/configure ] &&			\
		cp portage/config.cache ${PKG_BUILD_DIR}/;
	if [ ${PKG_LIBTOOL_MIDIPIX:-0} -eq 1 ]; then
		cp portage/libtool.midipix ${PKG_SUBDIR}/;
		sed -i.orig -e "/^libdir=/s/libdir='/libdir='\$PKG_PREFIX\//"\
			${PKG_SUBDIR}/libtool.midipix;
		if [ ${PKG_LIBTOOL_MIDIPIX_FIX:-0} -eq 1 ]; then
			sed -i.orig.orig									\
				-e '/^\s\+test \"\$inst_prefix_dir\" = \"\$destdir\" && \\$/{s/^/#/;n;s/^/#/}'	\
				${PKG_SUBDIR}/libtool.midipix;
		fi;
	fi;
	set_build_script_done patch -configure;
fi;
cd ${PKG_BUILD_DIR};
if [ -x ../${PKG_SUBDIR}/configure ]\
&& ! is_build_script_done configure; then
	if test_cmd pkg_${PKG_NAME}_configure_pre; then
		pkg_${PKG_NAME}_configure_pre;
	fi;
	AR="${PKG_AR_CONFIGURE}" CC="${PKG_CC_CONFIGURE}"\
	CFLAGS="${PKG_CFLAGS_CONFIGURE}${PKG_CFLAGS_CONFIGURE_EXTRA:+ ${PKG_CFLAGS_CONFIGURE_EXTRA}}"\
	LDFLAGS="${PKG_LDFLAGS_CONFIGURE}${PKG_LDFLAGS_CONFIGURE_EXTRA:+ ${PKG_LDFLAGS_CONFIGURE_EXTRA}}"\
	../${PKG_SUBDIR}/configure				\
		${PKG_CONFIGURE_ARGS} ${PKG_CONFIGURE_ARGS_EXTRA};
	set_build_script_done configure clean -build;
else
	set_build_script_done clean;
fi;
if [ ${PKG_NO_CLEAN:-0} -eq 0 ]\
&& ! is_build_script_done clean; then
	make clean;
	set_build_script_done clean -build;
fi;
if ! is_build_script_done build; then
	run_cmd_unsplit make					\
		${PKG_MAKEFLAGS_BUILD}				\
		${PKG_MAKEFLAGS_BUILD_EXTRA}			\
		"${PKG_AR_BUILD:+AR=${PKG_AR_BUILD}}"		\
		"${PKG_CC_BUILD:+CC=${PKG_CC_BUILD}}"		\
		"${PKG_CFLAGS_BUILD:+CFLAGS=${PKG_CFLAGS_BUILD}}"\
		"${PKG_CFLAGS_BUILD_EXTRA:+CFLAGS+=${PKG_CFLAGS_BUILD_EXTRA}}"\
		"${PKG_LDFLAGS_BUILD:+LDFLAGS=${PKG_LDFLAGS_BUILD}}"\
		"${PKG_LDFLAGS_BUILD_EXTRA:+LDFLAGS+=${PKG_LDFLAGS_BUILD_EXTRA}}";
	set_build_script_done build -install;
fi;
if ! is_build_script_done install; then
	if test_cmd pkg_${PKG_NAME}_install; then
		pkg_${PKG_NAME}_install;
	else
		run_cmd_unsplit make				\
			${PKG_MAKEFLAGS_INSTALL}		\
			${PKG_MAKEFLAGS_INSTALL_EXTRA}		\
			"${PKG_AR_INSTALL:+AR=${PKG_AR_INSTALL}}"\
			"${PKG_CC_INSTALL:+CC=${PKG_CC_INSTALL}}"\
			"${PKG_CC_INSTALL:+CC=${PKG_CC_INSTALL}}"\
			"${PKG_CFLAGS_INSTALL:+CFLAGS=${PKG_CFLAGS_INSTALL}}"\
			"${PKG_CFLAGS_INSTALL_EXTRA:+CFLAGS+=${PKG_CFLAGS_INSTALL_EXTRA}}"\
			"${PKG_LDFLAGS_INSTALL:+LDFLAGS=${PKG_LDFLAGS_INSTALL}}"\
			"${PKG_LDFLAGS_INSTALL_EXTRA:+LDFLAGS+=${PKG_LDFLAGS_INSTALL_EXTRA}}"\
			"${PKG_RANLIB_INSTALL:+RANLIB=${PKG_RANLIB_INSTALL}}"\
			${PKG_INSTALL_TARGET:=install};
		if [ -n "${PKG_PREFIX_EXTRA}" ]; then
			run_cmd_unsplit make			\
				${PKG_MAKEFLAGS_INSTALL}	\
				${PKG_MAKEFLAGS_INSTALL_EXTRA}	\
				"${PKG_AR_INSTALL:+AR=${PKG_AR_INSTALL}}"\
				"${PKG_CC_INSTALL:+CC=${PKG_CC_INSTALL}}"\
				"${PKG_CC_INSTALL:+CC=${PKG_CC_INSTALL}}"\
				"${PKG_CFLAGS_INSTALL:+CFLAGS=${PKG_CFLAGS_INSTALL}}"\
				"${PKG_CFLAGS_INSTALL_EXTRA:+CFLAGS+=${PKG_CFLAGS_INSTALL_EXTRA}}"\
				"${PKG_LDFLAGS_INSTALL:+LDFLAGS=${PKG_LDFLAGS_INSTALL}}"\
				"${PKG_LDFLAGS_INSTALL_EXTRA:+LDFLAGS+=${PKG_LDFLAGS_INSTALL_EXTRA}}"\
				"${PKG_RANLIB_INSTALL:+RANLIB=${PKG_RANLIB_INSTALL}}"\
				${PKG_PREFIX_EXTRA}		\
				${PKG_INSTALL_TARGET:=install};
		fi;
		if test_cmd pkg_${PKG_NAME}_install_post; then
			pkg_${PKG_NAME}_install_post;
		fi;
	fi;
	find ${PKG_PREFIX}/lib -type f -name \*.la -exec rm -f {} \;
	set_build_script_done install -finish;
fi;
set_build_script_done finish;

# vim:filetype=sh