Blame subr.pkg/pkg_configure.subr

Lucio Andrés Illanes Albornoz (arab, vxp) 570129
#
8d7a8a
# Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 LucĂ­a Andrea Illanes Albornoz <lucia@luciaillanes.de>
Lucio Andrés Illanes Albornoz e1d469
# set +o errexit -o noglob -o nounset is assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
#
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
Lucio Andrés Illanes Albornoz b9a715
pkgp_configure_autotools() {
e9fa07
	local _ppca_libtool="" _ppca_rc=0;
Lucio Andrés Illanes Albornoz b9a715
Lucio Andrés Illanes Albornoz b9a715
	if ! [ -x "${PKG_CONFIGURE:-}" ]; then
e9fa07
		_ppca_rc=2;
Lucio Andrés Illanes Albornoz b9a715
	elif [ -d "${PKG_BASE_DIR}/${PKG_SUBDIR}/sofort" ]\
e9fa07
	||   [ "${PKG_CONFIGURE_TYPE:-}" = "sofort" ];
e9fa07
	then
e9fa07
		_ppca_rc=2;
Lucio Andrés Illanes Albornoz b9a715
	else
Lucio Andrés Illanes Albornoz 7ab7cc
		case "${PKG_LIBTOOL:-}" in
e9fa07
		"")	_ppca_libtool=""; ;;
e9fa07
		none)	_ppca_libtool=""; ;;
e9fa07
		*)	_ppca_libtool="${PKG_LIBTOOL}"; ;;
Lucio Andrés Illanes Albornoz 7ab7cc
		esac;
Lucio Andrés Illanes Albornoz b9a715
e9fa07
		rtl_export_vars						\
e9fa07
			PKG_CONFIG "${PKG_PKG_CONFIG:-}"		\
e9fa07
			PKG_CONFIG_LIBDIR "${PKG_PKG_CONFIG_LIBDIR:-}"	\
e9fa07
			PYTHON "${PKG_PYTHON:-}"			\
e9fa07
			${_ppca_libtool:+MAKE} ${_ppca_libtool:+"make LIBTOOL=${_ppca_libtool}"};
Lucio Andrés Illanes Albornoz b9a715
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		AR="${PKG_AR}"												\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		CC="${PKG_CC}"												\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		RANLIB="${PKG_RANLIB}"											\
Lucio Andrés Illanes Albornoz e1d469
		CFLAGS="${PKG_CFLAGS_CONFIGURE:-}${PKG_CFLAGS_CONFIGURE_EXTRA:+ ${PKG_CFLAGS_CONFIGURE_EXTRA}}"		\
Lucio Andrés Illanes Albornoz e1d469
		CPPFLAGS="${PKG_CFLAGS_CONFIGURE:-}${PKG_CFLAGS_CONFIGURE_EXTRA:+ ${PKG_CFLAGS_CONFIGURE_EXTRA}}"	\
Lucio Andrés Illanes Albornoz e1d469
		CXXFLAGS="${PKG_CXXFLAGS_CONFIGURE:-}${PKG_CXXFLAGS_CONFIGURE_EXTRA:+ ${PKG_CXXFLAGS_CONFIGURE_EXTRA}}"	\
Lucio Andrés Illanes Albornoz e1d469
		LDFLAGS="${PKG_LDFLAGS_CONFIGURE:-}${PKG_LDFLAGS_CONFIGURE_EXTRA:+ ${PKG_LDFLAGS_CONFIGURE_EXTRA}}"	\
Lucio Andrés Illanes Albornoz e1d469
		"${PKG_CONFIGURE}" ${PKG_CONFIGURE_ARGS:-} ${PKG_CONFIGURE_ARGS_EXTRA:-} ${PKG_CONFIGURE_ARGS_EXTRA_DEBUG:-};
e9fa07
		_ppca_rc=$((${?} ? 1 : ${_ppca_rc}));
e9fa07
e9fa07
		rtl_export_vars	-u					\
e9fa07
			PKG_CONFIG "${PKG_PKG_CONFIG:-}"		\
e9fa07
			PKG_CONFIG_LIBDIR "${PKG_PKG_CONFIG_LIBDIR:-}"	\
e9fa07
			PYTHON "${PKG_PYTHON:-}"			\
e9fa07
			${_ppca_libtool:+MAKE} ${_ppca_libtool:+"make LIBTOOL=${_ppca_libtool}"};
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
	fi;
e9fa07
e9fa07
	return "${_ppca_rc}";
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
};
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
Lucio Andrés Illanes Albornoz b9a715
pkgp_configure_cmake() {
e9fa07
	local _ppcc_cmake_args_auto"" _ppcc_build_type="" _ppcc_IFS0="${IFS:- 	}" _ppcc_rc=0 IFS;
Lucio Andrés Illanes Albornoz b9a715
Lucio Andrés Illanes Albornoz b9a715
	if [ "${PKG_CMAKE_LISTFILE:+1}" != 1 ]\
Lucio Andrés Illanes Albornoz b9a715
	|| ! [ -e "${PKG_BASE_DIR}/${PKG_SUBDIR}/${PKG_CMAKE_LISTFILE}" ]; then
e9fa07
		_ppcc_rc=2;
Lucio Andrés Illanes Albornoz b9a715
	else
Lucio Andrés Illanes Albornoz b9a715
		rtl_fileop rm config.cache || return 1;
Lucio Andrés Illanes Albornoz b9a715
		rtl_export_vars							\
Lucio Andrés Illanes Albornoz b9a715
			PKG_CONFIG		"${PKG_PKG_CONFIG:-}"		\
Lucio Andrés Illanes Albornoz b9a715
			PKG_CONFIG_LIBDIR	"${PKG_PKG_CONFIG_LIBDIR:-}"	\
Lucio Andrés Illanes Albornoz b9a715
			PYTHON			"${PKG_PYTHON:-}";
Lucio Andrés Illanes Albornoz b9a715
Lucio Andrés Illanes Albornoz b9a715
		case "${BUILD_KIND}" in
e9fa07
		debug)		_ppcc_build_type="debug"; ;;
e9fa07
		release|*)	_ppcc_build_type="release"; ;;
Lucio Andrés Illanes Albornoz b9a715
		esac;
Lucio Andrés Illanes Albornoz b9a715
e9fa07
		_ppcc_cmake_args_auto="
Lucio Andrés Illanes Albornoz b9a715
			-DCMAKE_AR=${PKG_AR}
e9fa07
			-DCMAKE_BUILD_TYPE=${_ppcc_build_type}
Lucio Andrés Illanes Albornoz b9a715
			-DCMAKE_C_COMPILER=${PKG_CC}
Lucio Andrés Illanes Albornoz b9a715
			-DCMAKE_C_FLAGS=${PKG_CFLAGS_CONFIGURE:-}${PKG_CFLAGS_CONFIGURE_EXTRA:+ ${PKG_CFLAGS_CONFIGURE_EXTRA}}
Lucio Andrés Illanes Albornoz b9a715
			-DCMAKE_CPP_FLAGS=${PKG_CPPFLAGS_CONFIGURE:-}${PKG_CPPFLAGS_CONFIGURE_EXTRA:+ ${PKG_CPPFLAGS_CONFIGURE_EXTRA}}
Lucio Andrés Illanes Albornoz b9a715
			-DCMAKE_CXX_COMPILER=${PKG_CXX}
Lucio Andrés Illanes Albornoz b9a715
			-DCMAKE_CXX_FLAGS=${PKG_CXXFLAGS_CONFIGURE:-}${PKG_CXXFLAGS_CONFIGURE_EXTRA:+ ${PKG_CXXFLAGS_CONFIGURE_EXTRA}}
Lucio Andrés Illanes Albornoz b9a715
			-DCMAKE_EXE_LINKER_FLAGS=${PKG_LDFLAGS_CONFIGURE:-}${PKG_LDFLAGS_CONFIGURE_EXTRA:+ ${PKG_LDFLAGS_CONFIGURE_EXTRA}}
Lucio Andrés Illanes Albornoz b9a715
			-DCMAKE_FIND_ROOT_PATH=${PKG_PREFIX}
Lucio Andrés Illanes Albornoz b9a715
			-DCMAKE_INSTALL_PREFIX=
Lucio Andrés Illanes Albornoz b9a715
			-DCMAKE_LINKER=$(which "ld")
Lucio Andrés Illanes Albornoz b9a715
			-DCMAKE_MODULE_LINKER_FLAGS=${PKG_LDFLAGS_CONFIGURE:-}${PKG_LDFLAGS_CONFIGURE_EXTRA:+ ${PKG_LDFLAGS_CONFIGURE_EXTRA}}
Lucio Andrés Illanes Albornoz b9a715
			-DCMAKE_RANLIB=${PKG_RANLIB}
Lucio Andrés Illanes Albornoz b9a715
			-DCMAKE_SHARED_LINKER_FLAGS=${PKG_LDFLAGS_CONFIGURE:-}${PKG_LDFLAGS_CONFIGURE_EXTRA:+ ${PKG_LDFLAGS_CONFIGURE_EXTRA}}
Lucio Andrés Illanes Albornoz b9a715
			-DPKG_CONFIG_EXECUTABLE=${PKG_PKG_CONFIG}" || return 1;
Lucio Andrés Illanes Albornoz b9a715
Lucio Andrés Illanes Albornoz b9a715
		case "${PKG_BUILD_TYPE}" in
Lucio Andrés Illanes Albornoz b9a715
		host|cross)
Lucio Andrés Illanes Albornoz b9a715
			;;
e9fa07
Lucio Andrés Illanes Albornoz b9a715
		native)
e9fa07
			_ppcc_cmake_args_auto="${_ppcc_cmake_args_auto:+${_ppcc_cmake_args_auto}}
Lucio Andrés Illanes Albornoz b9a715
				-DCMAKE_LINKER=$(which "${PKG_TARGET}-ld")
Lucio Andrés Illanes Albornoz b9a715
				-DCMAKE_SYSROOT=${PKG_PREFIX}
Lucio Andrés Illanes Albornoz b9a715
				-DCMAKE_SYSTEM_NAME=Midipix" || return 1;
Lucio Andrés Illanes Albornoz b9a715
Lucio Andrés Illanes Albornoz b9a715
			case "${ARCH}" in
e9fa07
			nt32)	_ppcc_cmake_args_auto="${_ppcc_cmake_args_auto:+${_ppcc_cmake_args_auto}}
Lucio Andrés Illanes Albornoz b9a715
					-DCMAKE_SYSTEM_PROCESSOR=i686"; ;;
e9fa07
			nt64)	_ppcc_cmake_args_auto="${_ppcc_cmake_args_auto:+${_ppcc_cmake_args_auto}}
Lucio Andrés Illanes Albornoz b9a715
					-DCMAKE_SYSTEM_PROCESSOR=x86_64"; ;;
Lucio Andrés Illanes Albornoz b9a715
			esac; ;;
e9fa07
Lucio Andrés Illanes Albornoz b9a715
		esac;
Lucio Andrés Illanes Albornoz b9a715
Lucio Andrés Illanes Albornoz b9a715
		IFS="
e9fa07
	";	"${PKG_CMAKE}"				\
e9fa07
			${_ppcc_cmake_args_auto}	\
e9fa07
			${PKG_CMAKE_ARGS:-}		\
e9fa07
			${PKG_CMAKE_ARGS_EXTRA:-}	\
Lucio Andrés Illanes Albornoz b9a715
		       	"${PKG_BASE_DIR}/${PKG_SUBDIR}";
e9fa07
		_ppcc_rc=$((${?} ? ${?} : ${_ppcc_rc})); IFS="${_ppcc_IFS0}";
Lucio Andrés Illanes Albornoz b9a715
Lucio Andrés Illanes Albornoz b9a715
		rtl_export_vars	-u						\
Lucio Andrés Illanes Albornoz b9a715
			PKG_CONFIG		"${PKG_PKG_CONFIG:-}"		\
Lucio Andrés Illanes Albornoz b9a715
			PKG_CONFIG_LIBDIR	"${PKG_PKG_CONFIG_LIBDIR:-}"	\
Lucio Andrés Illanes Albornoz b9a715
			PYTHON			"${PKG_PYTHON:-}";
Lucio Andrés Illanes Albornoz b9a715
	fi;
e9fa07
e9fa07
	return "${_ppcc_rc}";
Lucio Andrés Illanes Albornoz b9a715
};
Lucio Andrés Illanes Albornoz b9a715
Lucio Andrés Illanes Albornoz b9a715
pkgp_configure_sofort() {
e9fa07
	local _ppcs_rc=0 _ppcs_vname="" _ppcs_vnames="" _ppcs_vval="";
Lucio Andrés Illanes Albornoz b9a715
Lucio Andrés Illanes Albornoz b9a715
	if ! [ -x "${PKG_CONFIGURE:-}" ]; then
e9fa07
		_ppcs_rc=2;
Lucio Andrés Illanes Albornoz b9a715
	elif ! [ -d "${PKG_BASE_DIR}/${PKG_SUBDIR}/sofort" ]\
Lucio Andrés Illanes Albornoz b9a715
	&&   ! [ "${PKG_CONFIGURE_TYPE:-}" = "sofort" ]; then
e9fa07
		_ppcs_rc=2;
Lucio Andrés Illanes Albornoz b9a715
	else
e9fa07
		for _ppcs_vname in AR CC CXX LD RANLIB; do
e9fa07
			if eval [ '"${PKG_'"${_ppcs_vname}"':+1}"' = 1 ]; then
e9fa07
				_ppcs_vnames="${_ppcs_vnames:+${_ppcs_vnames} }${_ppcs_vname}";
e9fa07
				eval ${_ppcs_vname}='${PKG_'"${_ppcs_vname}"'}'; export ${_ppcs_vname};
Lucio Andrés Illanes Albornoz b9a715
			fi;
e9fa07
e9fa07
			if eval [ '"${PKG_SOFORT_NATIVE_'"${_ppcs_vname}"':+1}"' = 1 ]; then
e9fa07
				_ppcs_vnames="${_ppcs_vnames:+${_ppcs_vnames} }NATIVE_${_ppcs_vname}";
e9fa07
				eval NATIVE_${_ppcs_vname}='${PKG_SOFORT_NATIVE_'"${_ppcs_vname}"'}'; export NATIVE_${_ppcs_vname};
Lucio Andrés Illanes Albornoz b9a715
			fi;
Lucio Andrés Illanes Albornoz b9a715
		done;
e9fa07
e9fa07
		for _ppcs_vname in CFLAGS CPPFLAGS CXXFLAGS LDFLAGS; do
e9fa07
			if eval [ '"${PKG_'"${_ppcs_vname}"'_CONFIGURE:+1}"' = 1 ]; then
e9fa07
				eval _ppcs_vval='${PKG_'"${_ppcs_vname}"'_CONFIGURE}';
e9fa07
				if eval [ '"${PKG_'"${_ppcs_vname}"'_CONFIGURE_EXTRA:+1}"' = 1 ]; then
e9fa07
					eval _ppcs_vval='${_ppcs_vval:+${_ppcs_vval} }${PKG_'"${_ppcs_vname}"'_CONFIGURE_EXTRA}';
Lucio Andrés Illanes Albornoz b9a715
				fi;
e9fa07
				_ppcs_vnames="${_ppcs_vnames:+${_ppcs_vnames} }${_ppcs_vname} ${_ppcs_vname}_SHARED ${_ppcs_vname}_STATIC";
e9fa07
				eval ${_ppcs_vname}='${_ppcs_vval}'\; ${_ppcs_vname}_SHARED='${_ppcs_vval}'\; ${_ppcs_vname}_STATIC='${_ppcs_vval}';
e9fa07
				export ${_ppcs_vname} ${_ppcs_vname}_SHARED ${_ppcs_vname}_STATIC;
Lucio Andrés Illanes Albornoz b9a715
			fi;
e9fa07
e9fa07
			if eval [ '"${PKG_SOFORT_NATIVE_'"${_ppcs_vname}"':+1}"' = 1 ]; then
e9fa07
				eval _ppcs_vval='${PKG_SOFORT_NATIVE_'"${_ppcs_vname}"'}';
e9fa07
				if eval [ '"${PKG_SOFORT_NATIVE_'"${_ppcs_vname}"'_EXTRA:+1}"' = 1 ]; then
e9fa07
					eval _ppcs_vval='${_ppcs_vval:+${_ppcs_vval} }${PKG_SOFORT_NATIVE_'"${_ppcs_vname}"'_EXTRA}';
Lucio Andrés Illanes Albornoz b9a715
				fi;
e9fa07
				_ppcs_vnames="${_ppcs_vnames:+${_ppcs_vnames} }NATIVE_${_ppcs_vname}";
e9fa07
				eval NATIVE_${_ppcs_vname}='${_ppcs_vval}'; export NATIVE_${_ppcs_vname};
Lucio Andrés Illanes Albornoz b9a715
			fi;
Lucio Andrés Illanes Albornoz b9a715
		done;
Lucio Andrés Illanes Albornoz b9a715
Lucio Andrés Illanes Albornoz b9a715
		RANLIB="${PKG_RANLIB}"				\
Lucio Andrés Illanes Albornoz b9a715
			"${PKG_CONFIGURE}"			\
Lucio Andrés Illanes Albornoz b9a715
				${PKG_CONFIGURE_ARGS:-}		\
Lucio Andrés Illanes Albornoz b9a715
				${PKG_CONFIGURE_ARGS_EXTRA:-}	\
Lucio Andrés Illanes Albornoz b9a715
				${PKG_CONFIGURE_ARGS_EXTRA_DEBUG:-};
e9fa07
		_ppcs_rc=$((${?} ? 1 : ${_ppcs_rc}));
Lucio Andrés Illanes Albornoz b9a715
e9fa07
		for _ppcs_vname in ${_ppcs_vnames}; do
e9fa07
			unset "${_ppcs_vname}";
Lucio Andrés Illanes Albornoz b9a715
		done;
Lucio Andrés Illanes Albornoz b9a715
	fi;
e9fa07
e9fa07
	return "${_ppcs_rc}";
Lucio Andrés Illanes Albornoz b9a715
};
Lucio Andrés Illanes Albornoz b9a715
Lucio Andrés Illanes Albornoz b9a715
pkg_configure() {
e9fa07
	local	_pc_group_name="${1}" _pc_pkg_name="${2}" _pc_restart_at="${3}"	\
e9fa07
		_pc_rc=0 _pc_type="";
Lucio Andrés Illanes Albornoz b9a715
e9fa07
	for _pc_type in autotools sofort cmake; do
Lucio Andrés Illanes Albornoz b9a715
		if [ "${PKG_CONFIGURE_TYPE:+1}" = 1 ]\
e9fa07
		&& [ "${PKG_CONFIGURE_TYPE}" != "${_pc_type}" ]; then
Lucio Andrés Illanes Albornoz b9a715
			continue;
Lucio Andrés Illanes Albornoz b9a715
		else
e9fa07
			pkgp_configure_${_pc_type} "${@}"; _pc_rc="${?}";
e9fa07
			case "${_pc_rc}" in
e9fa07
			0|1)	return "${_pc_rc}"; ;;
e9fa07
			2)	_pc_rc=0; continue; ;;
Lucio Andrés Illanes Albornoz b9a715
			esac;
Lucio Andrés Illanes Albornoz b9a715
		fi;
Lucio Andrés Illanes Albornoz b9a715
	done;
e9fa07
	return "${_pc_rc}";
Lucio Andrés Illanes Albornoz b9a715
};
Lucio Andrés Illanes Albornoz b9a715
Lucio Andrés Illanes Albornoz b9a715
# vim:filetype=sh textwidth=0