Blob Blame History Raw
#
# Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 LucĂ­a Andrea Illanes Albornoz <lucia@luciaillanes.de>
# set +o errexit -o noglob -o nounset is assumed.
#

pkgp_configure_autotools() {
	local _ppca_rc=0;

	if ! [ -x "${PKG_CONFIGURE:-}" ]; then
		_ppca_rc=2;
	elif [ -d "${PKG_BASE_DIR}/${PKG_SUBDIR}/sofort" ]\
	||   [ "${PKG_CONFIGURE_TYPE:-}" = "sofort" ];
	then
		_ppca_rc=2;
	else
		ex_rtl_configure								\
			"${PKG_AR}" "${PKG_CC}" "${PKG_CONFIGURE}" "${PKG_CXX}" "${PKG_LD}"	\
			"${PKG_LIBTOOL}" "${PKG_PKG_CONFIG}" "${PKG_PYTHON:-}" "${PKG_RANLIB}"	\
			--									\
			"${PKG_CONFIGURE_ARGS:-}" "${PKG_CONFIGURE_ARGS_EXTRA:-}"		\
			"${PKG_CONFIGURE_ARGS_LIST:-}" "${PKG_CONFIGURE_ARGS_EXTRA_LIST:-}"	\
			--									\
			"${PKG_CFLAGS_CONFIGURE:-}" "${PKG_CFLAGS_CONFIGURE_EXTRA:-}"		\
			"${PKG_CPPFLAGS_CONFIGURE:-}" "${PKG_CPPFLAGS_CONFIGURE_EXTRA:-}"	\
			"${PKG_CXXFLAGS_CONFIGURE:-}" "${PKG_CXXFLAGS_CONFIGURE_EXTRA:-}"	\
			"${PKG_LDFLAGS_CONFIGURE:-}" "${PKG_LDFLAGS_CONFIGURE_EXTRA:-}"		\
			"${PKG_PKG_CONFIG_LIBDIR:-}"						\
			;
		_ppca_rc=$((${?} ? 1 : ${_ppca_rc}));
	fi;

	return "${_ppca_rc}";
};

pkgp_configure_cmake() {
	local _ppcc_build_type="" _ppcc_rc=0 _ppcc_system_name="" _ppcc_system_processor="";

	if [ "${PKG_CMAKE_LISTFILE:+1}" != 1 ]\
	|| ! [ -e "${PKG_BASE_DIR}/${PKG_SUBDIR}/${PKG_CMAKE_LISTFILE}" ]; then
		_ppcc_rc=2;
	else
		case "${BUILD_KIND}" in
		debug)		_ppcc_build_type="Debug"; ;;
		release)	_ppcc_build_type="Release"; ;;
		*)		return 1; ;;
		esac;

		case "${PKG_BUILD_TYPE}" in
		native)
			_ppcc_system_name="Midipix";
			case "${ARCH}" in
			nt32)	_ppcc_system_processor="i686"; ;;
			nt64)	_ppcc_system_processor="x86_64"; ;;
			esac;
		esac;

		ex_rtl_configure_cmake								\
			"${PKG_AR}" "${PKG_CC}" "${ARG_CCACHE:-}" "${PKG_CMAKE}" "${PKG_CXX}"	\
			"${PKG_LD}" "${PKG_PKG_CONFIG}" "${PKG_PYTHON:-}" "${PKG_RANLIB}"	\
			--									\
			"${_ppcc_build_type}" "${PKG_BUILD_TYPE}" "${PKG_CMAKE_ARGS:-}"		\
			"${PKG_CMAKE_ARGS_EXTRA:-}" "${PKG_PREFIX}"				\
			"${PKG_BASE_DIR}/${PKG_SUBDIR}" "${_ppcc_system_name}"			\
			"${_ppcc_system_processor}"						\
			--									\
			"${PKG_CFLAGS_CONFIGURE:-}" "${PKG_CFLAGS_CONFIGURE_EXTRA:-}"		\
			"${PKG_CPPFLAGS_CONFIGURE:-}" "${PKG_CPPFLAGS_CONFIGURE_EXTRA:-}"	\
			"${PKG_CXXFLAGS_CONFIGURE:-}" "${PKG_CXXFLAGS_CONFIGURE_EXTRA:-}"	\
			"${PKG_LDFLAGS_CONFIGURE:-}" "${PKG_LDFLAGS_CONFIGURE_EXTRA:-}"		\
			"${PKG_PKG_CONFIG_LIBDIR:-}"						\
			;
		_ppcc_rc=$((${?} ? 1 : ${_ppcc_rc}));
	fi;

	return "${_ppcc_rc}";
};

pkgp_configure_sofort() {
	local _ppcs_rc=0;

	if ! [ -x "${PKG_CONFIGURE:-}" ]; then
		_ppcs_rc=2;
	elif ! [ -d "${PKG_BASE_DIR}/${PKG_SUBDIR}/sofort" ]\
	&&   ! [ "${PKG_CONFIGURE_TYPE:-}" = "sofort" ]; then
		_ppcs_rc=2;
	else
		ex_rtl_configure_sofort									\
			"${PKG_AR}" "${PKG_CC}" "${PKG_CONFIGURE}" "${PKG_CXX}"				\
			"${PKG_LD}" "${PKG_RANLIB}"							\
			--										\
			"${PKG_NATIVE_AR:-}" "${PKG_NATIVE_CC:-}" "${PKG_NATIVE_CXX:-}"			\
			"${PKG_NATIVE_LD:-}" "${PKG_NATIVE_RANLIB:-}"					\
			--										\
			"${PKG_CONFIGURE_ARGS:-}" "${PKG_CONFIGURE_ARGS_EXTRA:-}"			\
			--										\
			"${PKG_CFLAGS_CONFIGURE:-}" "${PKG_CFLAGS_CONFIGURE_EXTRA:-}"			\
			"${PKG_CPPFLAGS_CONFIGURE:-}" "${PKG_CPPFLAGS_CONFIGURE_EXTRA:-}"		\
			"${PKG_CXXFLAGS_CONFIGURE:-}" "${PKG_CXXFLAGS_CONFIGURE_EXTRA:-}"		\
			"${PKG_LDFLAGS_CONFIGURE:-}" "${PKG_LDFLAGS_CONFIGURE_EXTRA:-}"			\
			--										\
			"${PKG_SOFORT_NATIVE_CFLAGS:-}" "${PKG_SOFORT_NATIVE_CFLAGS_EXTRA:-}"		\
			"${PKG_SOFORT_NATIVE_CPPFLAGS:-}" "${PKG_SOFORT_NATIVE_CPPFLAGS_EXTRA:-}"	\
			"${PKG_SOFORT_NATIVE_CXXFLAGS:-}" "${PKG_SOFORT_NATIVE_CXXFLAGS_EXTRA:-}"	\
			"${PKG_SOFORT_NATIVE_LDFLAGS:-}" "${PKG_SOFORT_NATIVE_LDFLAGS_EXTRA:-}"		\
			;
		_ppcs_rc=$((${?} ? 1 : ${_ppcs_rc}));
	fi;

	return "${_ppcs_rc}";
};

pkg_configure() {
	local	_pc_group_name="${1}" _pc_pkg_name="${2}" _pc_restart_at="${3}"	\
		_pc_rc=0 _pc_type="";

	for _pc_type in autotools cmake sofort; do
		if [ "${PKG_CONFIGURE_TYPE:+1}" = 1 ]\
		&& [ "${PKG_CONFIGURE_TYPE}" != "${_pc_type}" ]; then
			continue;
		else
			pkgp_configure_${_pc_type} "${@}"; _pc_rc="${?}";
			case "${_pc_rc}" in
			0|1)	return "${_pc_rc}"; ;;
			2)	_pc_rc=0; continue; ;;
			esac;
		fi;
	done;
	return "${_pc_rc}";
};

# vim:filetype=sh textwidth=0