Lucio Andrés Illanes Albornoz (arab, vxp) 570129
#
Lucio Andrés Illanes Albornoz e1d469
# set +o errexit -o noglob -o nounset is assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
# Order: stage1_host, runtime_host, libstdcpp_v3_host, full_host, full
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
# Order: stage1_mingw32, native_mingw32
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
#
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
Lucio Andrés Illanes Albornoz b6a9a1
#
Lucio Andrés Illanes Albornoz b6a9a1
# Private subroutines
Lucio Andrés Illanes Albornoz b6a9a1
#
e9fa07
e9fa07
pkgp_gcc_build_dir() { PKG_BUILD_DIR="${1}-${2}-${PKG_TARGET}"; return 0; };
Lucio Andrés Illanes Albornoz b6a9a1
pkgp_gcc_state_set() {
Lucio Andrés Illanes Albornoz b6a9a1
	printf "step unknown %s %s\n" "${PKG_NAME}" "${1}" >&3;
Lucio Andrés Illanes Albornoz f3f7e8
	ex_pkg_state_set "${PKG_NAME}" "${1}" ${2:+"${2}"};
e9fa07
	return 0;
Lucio Andrés Illanes Albornoz b6a9a1
};
Lucio Andrés Illanes Albornoz b6a9a1
Lucio Andrés Illanes Albornoz b6a9a1
pkgp_gcc_configure() {
Lucio Andrés Illanes Albornoz b6a9a1
	if ! rtl_fileop rm "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"		\
Lucio Andrés Illanes Albornoz b6a9a1
	|| ! rtl_fileop mkdir "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"	\
Lucio Andrés Illanes Albornoz b6a9a1
	|| ! rtl_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"		\
Lucio Andrés Illanes Albornoz b6a9a1
	|| ! "../cbb-gcc-${PKG_VERSION}/configure" "${@}"		\
Lucio Andrés Illanes Albornoz b6a9a1
			--disable-bootstrap				\
Lucio Andrés Illanes Albornoz b6a9a1
			--disable-libmudflap				\
Lucio Andrés Illanes Albornoz b6a9a1
			--disable-multilib				\
Lucio Andrés Illanes Albornoz b6a9a1
			--disable-nls					\
Lucio Andrés Illanes Albornoz b6a9a1
			--disable-obsolete				\
Lucio Andrés Illanes Albornoz b6a9a1
			--disable-symvers				\
Lucio Andrés Illanes Albornoz b6a9a1
			--enable-canonical-system-headers		\
Lucio Andrés Illanes Albornoz b6a9a1
			--enable-__cxa_atexit				\
Lucio Andrés Illanes Albornoz b6a9a1
			--enable-debug					\
Lucio Andrés Illanes Albornoz b6a9a1
			--enable-gnu-indirect-function			\
Lucio Andrés Illanes Albornoz b6a9a1
			--enable-gnu-unique-object			\
Lucio Andrés Illanes Albornoz b6a9a1
			--enable-initfini-array				\
Lucio Andrés Illanes Albornoz b6a9a1
			--enable-languages=c,c++,fortran,objc,lto	\
Lucio Andrés Illanes Albornoz b6a9a1
			--enable-libstdcxx-debug			\
Lucio Andrés Illanes Albornoz b6a9a1
			--enable-lto					\
Lucio Andrés Illanes Albornoz b6a9a1
			--enable-multiarch				\
Lucio Andrés Illanes Albornoz b6a9a1
			--enable-secureplt				\
Lucio Andrés Illanes Albornoz b6a9a1
			--enable-shared					\
Lucio Andrés Illanes Albornoz b6a9a1
			--enable-threads=posix				\
Lucio Andrés Illanes Albornoz b6a9a1
			--target="${PKG_TARGET}"			\
Lucio Andrés Illanes Albornoz b6a9a1
			--with-fpmath=sse; then
Lucio Andrés Illanes Albornoz b6a9a1
		return 1;
Lucio Andrés Illanes Albornoz b6a9a1
	else
Lucio Andrés Illanes Albornoz 370e98
		pkgp_gcc_state_set "configure" "build";
Lucio Andrés Illanes Albornoz b6a9a1
	fi;
e9fa07
	return 0;
Lucio Andrés Illanes Albornoz b6a9a1
};
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
Lucio Andrés Illanes Albornoz (arab, vxp) d4754c
pkgp_gcc_setup_env() {
Lucio Andrés Illanes Albornoz b6a9a1
	local _vname="";
e9fa07
Lucio Andrés Illanes Albornoz b6a9a1
	for _vname in	CFLAGS CFLAGS_FOR_BUILD CPPFLAGS_FOR_BUILD			\
Lucio Andrés Illanes Albornoz b6a9a1
			CXXFLAGS CXXFLAGS_FOR_BUILD; do
Lucio Andrés Illanes Albornoz b6a9a1
		export "${_vname}=${GCCFLAGS}";
Lucio Andrés Illanes Albornoz b6a9a1
	done;
Lucio Andrés Illanes Albornoz b6a9a1
	for _vname in	CFLAGS_FOR_TARGET CPPFLAGS_FOR_TARGET CXXFLAGS_FOR_TARGET	\
Lucio Andrés Illanes Albornoz b6a9a1
			LIBCFLAGS_FOR_TARGET XGCC_FLAGS_FOR_TARGET; do
Lucio Andrés Illanes Albornoz b6a9a1
		export "${_vname}=${GCCTARGET_FLAGS}";
Lucio Andrés Illanes Albornoz b6a9a1
	done;
Lucio Andrés Illanes Albornoz b6a9a1
	for _vname in	cbb_cflags_for_stage1 cbb_cflags_for_stage2			\
Lucio Andrés Illanes Albornoz b6a9a1
			cbb_cflags_for_stage3 cbb_cflags_for_stage4; do
Lucio Andrés Illanes Albornoz b6a9a1
		export "${_vname}=${CFLAGS_FOR_BUILD}" ;
Lucio Andrés Illanes Albornoz b6a9a1
	done;
e9fa07
	return 0;
Lucio Andrés Illanes Albornoz b6a9a1
};
Lucio Andrés Illanes Albornoz b6a9a1
Lucio Andrés Illanes Albornoz b6a9a1
pkgp_gcc_setup_vars() {
Lucio Andrés Illanes Albornoz b6a9a1
	local _unwind_midipix_h="";
Lucio Andrés Illanes Albornoz b6a9a1
	export cbb_target="${PKG_TARGET}" MAKE="make LIBTOOL=slibtool";
Lucio Andrés Illanes Albornoz b6a9a1
	_unwind_midipix_h="$(readlink -f "${PKG_BASE_DIR}/cbb-gcc-${PKG_VERSION}/gcc/unwind-midipix.h")";
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) 36ab93
	case "${PKG_NAME}" in
e9fa07
Lucio Andrés Illanes Albornoz b6a9a1
	gcc_full)
Lucio Andrés Illanes Albornoz b6a9a1
		GCCTARGET_FLAGS="-DIN_TARGET_LIBRARY_BUILD --sysroot=${PKG_PREFIX}";
e9fa07
		rtl_lconcat \$GCCTARGET_FLAGS "--include=${_unwind_midipix_h}";
e9fa07
		rtl_lconcat \$GCCTARGET_FLAGS "-DTARGET_PERSONALITY_FUNCTION";
e9fa07
		rtl_lconcat \$GCCTARGET_FLAGS "-DTARGET_PERSONALITY_FUNCTION_MIDIPIX";
e9fa07
		rtl_lconcat \$GCCTARGET_FLAGS "${DEFAULT_CFLAGS_DEBUG_RUNTIME}";
e9fa07
		export	cbb_ldflags_for_target=--sysroot="${PKG_PREFIX}"		\
e9fa07
			cbb_sysroot_for_libgcc="${PKG_PREFIX}"				\
e9fa07
			cbb_xgcc_for_specs="${PKG_TARGET}-gcc"				\
e9fa07
			sysroot_headers_suffix="${PKG_PREFIX}";
e9fa07
		;;
e9fa07
Lucio Andrés Illanes Albornoz b6a9a1
	gcc_stage1_cross_mingw32)
Lucio Andrés Illanes Albornoz b6a9a1
		GCCTARGET_FLAGS="-DIN_TARGET_LIBRARY_BUILD --sysroot=${PREFIX_MINGW32} -midata";
e9fa07
		export	cbb_ldflags_for_target=--sysroot="${PREFIX_MINGW32}"		\
e9fa07
			cbb_neutral_libiberty=no					\
e9fa07
			cbb_sysroot_for_libgcc="${PREFIX_MINGW32}"			\
e9fa07
			cbb_xgcc_for_specs="${PKG_BASE_DIR}/${PKG_BUILD_DIR}/gcc/xgcc";
e9fa07
		;;
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	gcc_stage1_host)
Lucio Andrés Illanes Albornoz c2a378
		GCCTARGET_FLAGS="-DIN_TARGET_LIBRARY_BUILD --sysroot=${PREFIX_CROSS}";
e9fa07
		rtl_lconcat \$GCCTARGET_FLAGS "--include=${_unwind_midipix_h}";
e9fa07
		rtl_lconcat \$GCCTARGET_FLAGS "-DTARGET_PERSONALITY_FUNCTION";
e9fa07
		rtl_lconcat \$GCCTARGET_FLAGS "-DTARGET_PERSONALITY_FUNCTION_MIDIPIX";
e9fa07
		rtl_lconcat \$GCCTARGET_FLAGS "${DEFAULT_CFLAGS_DEBUG_RUNTIME}";
e9fa07
		export	cbb_ldflags_for_target="--sysroot=${PREFIX_CROSS}"		\
e9fa07
			cbb_neutral_libiberty="no"					\
e9fa07
			cbb_sysroot_for_libgcc="${PREFIX_CROSS}"			\
e9fa07
			cbb_xgcc_for_specs="${PKG_BASE_DIR}/${PKG_BUILD_DIR}/gcc/xgcc"	\
e9fa07
			LDFLAGS="${PKG_LDFLAGS_CONFIGURE}";
e9fa07
		;;
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	gcc_stage1_native_mingw32)
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		GCCTARGET_FLAGS="-DIN_TARGET_LIBRARY_BUILD --sysroot=${PKG_PREFIX} -midata";
e9fa07
		export	cbb_ldflags_for_target=--sysroot="${PKG_PREFIX}"		\
e9fa07
			cbb_neutral_libiberty=no					\
e9fa07
			cbb_sysroot_for_libgcc="${PKG_PREFIX}"				\
e9fa07
			cbb_xgcc_for_specs="${PKG_TARGET}-gcc";
e9fa07
		;;
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) f93712
	esac;
e9fa07
e9fa07
	rtl_lconcat2			\
e9fa07
		\$GCCFLAGS		\
e9fa07
		\$PKG_CFLAGS_CONFIGURE 	\
e9fa07
		"--include $(readlink -f "${PKG_BASE_DIR}/cbb-gcc-${PKG_VERSION}/libc/cbb-musl-pe.h")";
Lucio Andrés Illanes Albornoz (arab, vxp) d4754c
};
Lucio Andrés Illanes Albornoz (arab, vxp) d4754c
Lucio Andrés Illanes Albornoz b6a9a1
pkgp_gcc_stage1_all() {
e9fa07
	local	_group_name="${1}" _pkg_name="${2}" _restart_at="${3}"	\
e9fa07
		_rc=0;
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) 36ab93
	case "${PKG_NAME}" in
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	gcc_stage1_cross_mingw32)
e9fa07
		pkgp_gcc_build_dir "cbb-gcc-${PKG_VERSION}" mingw32;
e9fa07
		;;
e9fa07
Lucio Andrés Illanes Albornoz b6a9a1
	gcc_stage1_host)
Lucio Andrés Illanes Albornoz b6a9a1
		if ! rtl_fileop ln_symbolic . "${PREFIX_CROSS}/usr"\
Lucio Andrés Illanes Albornoz b6a9a1
		|| ! rtl_fileop mkdir "${PREFIX_CROSS}/usr/include"\
Lucio Andrés Illanes Albornoz b6a9a1
		|| ! pkgp_gcc_build_dir "cbb-gcc-${PKG_VERSION}" cross; then
Lucio Andrés Illanes Albornoz b6a9a1
			_rc=1;
e9fa07
		fi;
e9fa07
		;;
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	gcc_stage1_native_mingw32)
e9fa07
		pkgp_gcc_build_dir "cbb-gcc-${PKG_VERSION}" native;
e9fa07
		;;
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) f93712
	esac;
e9fa07
Lucio Andrés Illanes Albornoz b6a9a1
	if [ "${_rc}" -ne 0 ]; then
Lucio Andrés Illanes Albornoz b6a9a1
		return 1;
Lucio Andrés Illanes Albornoz b6a9a1
	fi;
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	if ! ex_pkg_state_test "${PKG_NAME}" fetch "${_restart_at}"; then
e9fa07
		if ! rtl_fetch_dlcache_subdir				\
e9fa07
				"${BUILD_DLCACHEDIR}" "${PKG_NAME}"	\
e9fa07
				"${PKG_INHERIT_FROM:-}";
e9fa07
		then
Lucio Andrés Illanes Albornoz 10ff54
			return 1;
Lucio Andrés Illanes Albornoz 10ff54
		elif ! rtl_fetch_urls_git									\
Lucio Andrés Illanes Albornoz 10ff54
				"${BUILD_DLCACHEDIR}/${PKG_NAME}" "${DEFAULT_GIT_ARGS}" "${PKG_BASE_DIR}"	\
Lucio Andrés Illanes Albornoz 10ff54
				"${PKG_NAME}" "${PKG_MIRRORS_GIT:-}"						\
Lucio Andrés Illanes Albornoz 10ff54
				"cbb-gcc-${PKG_VERSION}=${PKG_GITROOT}/cbb/cbb-gcc-${PKG_VERSION}"; then
Lucio Andrés Illanes Albornoz 10ff54
			return 1;
Lucio Andrés Illanes Albornoz 10ff54
		else
Lucio Andrés Illanes Albornoz 370e98
			pkgp_gcc_state_set "fetch" "patch";
Lucio Andrés Illanes Albornoz 10ff54
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 17e78c
	fi;
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	if ! ex_pkg_state_test "${PKG_NAME}" patch "${_restart_at}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) 0f5aa2
		if [ -e "${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME}.local.patch" ]; then
Lucio Andrés Illanes Albornoz b6a9a1
			patch -b -d "${PKG_BASE_DIR}" -p0 < "${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME}.local.patch" || return 1;
Lucio Andrés Illanes Albornoz (arab, vxp) 0f5aa2
		fi;
Lucio Andrés Illanes Albornoz 370e98
		pkgp_gcc_state_set "patch" "configure";
Lucio Andrés Illanes Albornoz (arab, vxp) d4754c
	fi;
e9fa07
e9fa07
	pkgp_gcc_setup_vars;
e9fa07
	pkgp_gcc_setup_env;
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	if ! ex_pkg_state_test "${PKG_NAME}" configure "${_restart_at}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) 36ab93
		case "${PKG_NAME}" in
e9fa07
Lucio Andrés Illanes Albornoz b6a9a1
		gcc_stage1_cross_mingw32)
Lucio Andrés Illanes Albornoz (arab, vxp) 03a637
			pkgp_gcc_configure				\
Lucio Andrés Illanes Albornoz b6a9a1
				--enable-sjlj-exceptions		\
Lucio Andrés Illanes Albornoz (arab, vxp) 36ab93
				--prefix="${PREFIX}"			\
Lucio Andrés Illanes Albornoz 292783
				--with-gmp="${PREFIX}"			\
Lucio Andrés Illanes Albornoz 292783
				--with-mpc="${PREFIX}"			\
Lucio Andrés Illanes Albornoz 292783
				--with-mpfr="${PREFIX}"			\
Lucio Andrés Illanes Albornoz b6a9a1
				--with-sysroot="${PREFIX_MINGW32}"	\
e9fa07
				--without-headers;
e9fa07
			;;
e9fa07
Lucio Andrés Illanes Albornoz b6a9a1
		gcc_stage1_host)
Lucio Andrés Illanes Albornoz (arab, vxp) 03a637
			pkgp_gcc_configure				\
Lucio Andrés Illanes Albornoz b6a9a1
				--disable-sjlj-exceptions		\
Lucio Andrés Illanes Albornoz (arab, vxp) 36ab93
				--prefix="${PREFIX}"			\
Lucio Andrés Illanes Albornoz 292783
				--with-gmp="${PREFIX}"			\
Lucio Andrés Illanes Albornoz 292783
				--with-mpc="${PREFIX}"			\
Lucio Andrés Illanes Albornoz 292783
				--with-mpfr="${PREFIX}"			\
e9fa07
				--with-sysroot="${PREFIX_CROSS}";
e9fa07
			;;
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		gcc_stage1_native_mingw32)
Lucio Andrés Illanes Albornoz (arab, vxp) d4754c
			pkgp_gcc_configure				\
Lucio Andrés Illanes Albornoz (arab, vxp) f93712
				--build=x86_64-unknown-linux-gnu	\
Lucio Andrés Illanes Albornoz (arab, vxp) d4754c
				--enable-sjlj-exceptions		\
Lucio Andrés Illanes Albornoz (arab, vxp) f93712
				--host=x86_64-nt64-midipix		\
Lucio Andrés Illanes Albornoz (arab, vxp) f93712
				--prefix=/				\
Lucio Andrés Illanes Albornoz (arab, vxp) 36ab93
				--with-elf="${PKG_PREFIX}"		\
Lucio Andrés Illanes Albornoz (arab, vxp) 36ab93
				--with-gmp="${PKG_PREFIX}"		\
Lucio Andrés Illanes Albornoz (arab, vxp) 36ab93
				--with-mpc="${PKG_PREFIX}"		\
Lucio Andrés Illanes Albornoz (arab, vxp) 36ab93
				--with-mpfr="${PKG_PREFIX}"		\
Lucio Andrés Illanes Albornoz (arab, vxp) f93712
				--with-sysroot=				\
e9fa07
				--without-headers;
e9fa07
			;;
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) 03a637
		esac;
e9fa07
Lucio Andrés Illanes Albornoz b6a9a1
		if [ "${?}" -ne 0 ]; then
Lucio Andrés Illanes Albornoz b6a9a1
			return 1;
Lucio Andrés Illanes Albornoz b6a9a1
		fi;
e9fa07
	else
e9fa07
		rtl_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}" || return 1;
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
	fi;
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	if ! ex_pkg_state_test "${PKG_NAME}" build "${_restart_at}"; then
Lucio Andrés Illanes Albornoz b6a9a1
		make ${PKG_MAKEFLAGS_BUILD} "all-gcc" || return 1;
Lucio Andrés Illanes Albornoz 370e98
		pkgp_gcc_state_set "build" "install_subdirs";
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
	fi;
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	if ! ex_pkg_state_test "${PKG_NAME}" install_subdirs "${_restart_at}"; then
e9fa07
		pkg_install_subdirs "${_group_name}" "${_pkg_name}" "${_restart_at}" || return 1;
Lucio Andrés Illanes Albornoz 370e98
		pkgp_gcc_state_set "install_subdirs" "install_make";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	fi;
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	if ! ex_pkg_state_test "${PKG_NAME}" install_make "${_restart_at}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) 36ab93
		case "${PKG_NAME}" in
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		gcc_stage1_cross_mingw32)
Lucio Andrés Illanes Albornoz b6a9a1
			make ${PKG_MAKEFLAGS_BUILD} "prefix=${PKG_DESTDIR}" "install-gcc"; ;;
e9fa07
Lucio Andrés Illanes Albornoz b6a9a1
		gcc_stage1_host)
Lucio Andrés Illanes Albornoz b6a9a1
			make ${PKG_MAKEFLAGS_BUILD} "prefix=${PKG_DESTDIR}" "install-gcc"; ;;
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		gcc_stage1_native_mingw32)
Lucio Andrés Illanes Albornoz b6a9a1
			make ${PKG_MAKEFLAGS_BUILD} "prefix=${PKG_DESTDIR}" "install-gcc"; ;;
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) 03a637
		esac;
e9fa07
Lucio Andrés Illanes Albornoz b6a9a1
		if [ "${?}" -ne 0 ]; then
Lucio Andrés Illanes Albornoz b6a9a1
			return 1;
e9fa07
		else
e9fa07
			case "$(uname -s)" in
Lucio Andrés Illanes Albornoz b6a9a1
			CYGWIN_*)
Lucio Andrés Illanes Albornoz b6a9a1
				if ! rtl_fileop ln_symbolic "${PKG_DESTDIR}/libexec/gcc/${PKG_TARGET}/${PKG_VERSION}/liblto_plugin.dll.a"\
Lucio Andrés Illanes Albornoz b6a9a1
				|| ! rtl_fileop ln_symbolic "${PKG_DESTDIR}/libexec/gcc/${PKG_TARGET}/${PKG_VERSION}/liblto_plugin.so"; then
Lucio Andrés Illanes Albornoz b6a9a1
					return 1;
Lucio Andrés Illanes Albornoz b6a9a1
				fi; ;;
Lucio Andrés Illanes Albornoz b6a9a1
			esac;
Lucio Andrés Illanes Albornoz 370e98
			pkgp_gcc_state_set "install_make" "install";
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	fi;
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	if ! ex_pkg_state_test "${PKG_NAME}" install "${_restart_at}"; then
e9fa07
		pkg_install "${_group_name}" "${_pkg_name}" "${_restart_at}" || return 1;
Lucio Andrés Illanes Albornoz f3f7e8
		pkgp_gcc_state_set "install";
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
	fi;
e9fa07
Lucio Andrés Illanes Albornoz f3f7e8
	pkgp_gcc_state_set "finish";
e9fa07
e9fa07
	return 0;
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
};
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
pkg_gcc_full_all() {
e9fa07
	local	_group_name="${1}" _pkg_name="${2}" _restart_at="${3}"	\
e9fa07
		_configure_host="" _vis_hide="vis_hide=-fvisibility=hidden";
Lucio Andrés Illanes Albornoz 3c2739
	export MAKE="make LIBTOOL=slibtool ${_vis_hide}";
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	pkgp_gcc_build_dir "cbb-gcc-${PKG_VERSION}" native;
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) 0580af
	if ! ex_pkg_state_test "${PKG_NAME}" fetch "${_restart_at}"; then
e9fa07
		if ! rtl_fetch_dlcache_subdir				\
e9fa07
				"${BUILD_DLCACHEDIR}" "${PKG_NAME}"	\
e9fa07
				"${PKG_INHERIT_FROM:-}";
e9fa07
		then
Lucio Andrés Illanes Albornoz 10ff54
			return 1;
Lucio Andrés Illanes Albornoz 10ff54
		elif ! rtl_fetch_urls_git						\
Lucio Andrés Illanes Albornoz 10ff54
				"${BUILD_DLCACHEDIR}/${PKG_NAME}" "${DEFAULT_GIT_ARGS}"	\
Lucio Andrés Illanes Albornoz 10ff54
				"${PKG_BASE_DIR}" "${PKG_NAME}"				\
Lucio Andrés Illanes Albornoz 10ff54
				"${PKG_MIRRORS_GIT:-}"					\
Lucio Andrés Illanes Albornoz 10ff54
				"cbb-gcc-${PKG_VERSION}=${PKG_GITROOT}/cbb/cbb-gcc-${PKG_VERSION}"; then
Lucio Andrés Illanes Albornoz 10ff54
			return 1;
Lucio Andrés Illanes Albornoz 10ff54
		else
Lucio Andrés Illanes Albornoz 370e98
			pkgp_gcc_state_set "fetch" "patch";
Lucio Andrés Illanes Albornoz 10ff54
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 0580af
	fi;
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) 0580af
	if ! ex_pkg_state_test "${PKG_NAME}" patch "${_restart_at}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) 0580af
		if [ -e "${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME}.local.patch" ]; then
Lucio Andrés Illanes Albornoz b6a9a1
			patch -b -d "${PKG_BASE_DIR}" -p0 < "${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME}.local.patch" || return 1;
Lucio Andrés Illanes Albornoz (arab, vxp) 0580af
		fi;
Lucio Andrés Illanes Albornoz 370e98
		pkgp_gcc_state_set "patch" "configure";
Lucio Andrés Illanes Albornoz (arab, vxp) 0580af
	fi;
e9fa07
e9fa07
	pkgp_gcc_setup_vars;
e9fa07
	pkgp_gcc_setup_env;
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	if ! ex_pkg_state_test "${PKG_NAME}" configure "${_restart_at}"; then
Lucio Andrés Illanes Albornoz b6a9a1
		rtl_fileop mkdir "${PKG_PREFIX}/${PKG_TARGET}" || return 1;
Lucio Andrés Illanes Albornoz (arab, vxp) 36ab93
		if [ \! -d "${PKG_PREFIX}/${PKG_TARGET}/usr" ]; then
Lucio Andrés Illanes Albornoz b6a9a1
			rtl_fileop ln_symbolic . "${PKG_PREFIX}/${PKG_TARGET}/usr" || return 1;
Lucio Andrés Illanes Albornoz (arab, vxp) d4754c
		fi;
e9fa07
Lucio Andrés Illanes Albornoz b6a9a1
		case "${ARCH}" in
Lucio Andrés Illanes Albornoz b6a9a1
		nt32)	_configure_host="i686-nt32-midipix"; ;;
Lucio Andrés Illanes Albornoz b6a9a1
		nt64)	_configure_host="x86_64-nt64-midipix"; ;;
Lucio Andrés Illanes Albornoz b6a9a1
		esac;
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) f93712
		pkgp_gcc_configure				\
Lucio Andrés Illanes Albornoz (arab, vxp) f93712
			--disable-sjlj-exceptions		\
Lucio Andrés Illanes Albornoz (arab, vxp) 36ab93
			--host="${_configure_host}"		\
Lucio Andrés Illanes Albornoz (arab, vxp) f93712
			--prefix=/				\
Lucio Andrés Illanes Albornoz (arab, vxp) 36ab93
			--with-elf="${PKG_PREFIX}"		\
Lucio Andrés Illanes Albornoz (arab, vxp) 36ab93
			--with-gmp="${PKG_PREFIX}"		\
Lucio Andrés Illanes Albornoz (arab, vxp) 36ab93
			--with-mpc="${PKG_PREFIX}"		\
Lucio Andrés Illanes Albornoz (arab, vxp) 36ab93
			--with-mpfr="${PKG_PREFIX}"		\
Lucio Andrés Illanes Albornoz b6a9a1
			--with-sysroot="" || return 1;
e9fa07
	else
e9fa07
		rtl_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}" || return 1;
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
	fi;
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	if ! ex_pkg_state_test "${PKG_NAME}" build "${_restart_at}"; then
Lucio Andrés Illanes Albornoz b6a9a1
		if ! make ${PKG_MAKEFLAGS_BUILD} "all-gcc"\
Lucio Andrés Illanes Albornoz b6a9a1
		|| ! make ${PKG_MAKEFLAGS_BUILD} "all-target-libgcc" ${_vis_hide}\
Lucio Andrés Illanes Albornoz b6a9a1
		|| ! make ${PKG_MAKEFLAGS_BUILD} "all-target-libstdc++-v3"\
Lucio Andrés Illanes Albornoz b6a9a1
		|| ! make ${PKG_MAKEFLAGS_BUILD} "all-target-libgfortran"\
Lucio Andrés Illanes Albornoz b6a9a1
		|| ! make ${PKG_MAKEFLAGS_BUILD} "all"; then
Lucio Andrés Illanes Albornoz b6a9a1
			return 1;
Lucio Andrés Illanes Albornoz 370e98
		else	pkgp_gcc_state_set "build" "install_subdirs";
Lucio Andrés Illanes Albornoz b6a9a1
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	fi;
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	if ! ex_pkg_state_test "${PKG_NAME}" install_subdirs "${_restart_at}"; then
e9fa07
		pkg_install_subdirs "${_group_name}" "${_pkg_name}" "${_restart_at}" || return 1;
Lucio Andrés Illanes Albornoz 370e98
		pkgp_gcc_state_set "install_subdirs" "install_make";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	fi;
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	if ! ex_pkg_state_test "${PKG_NAME}" install_make "${_restart_at}"; then
Lucio Andrés Illanes Albornoz b6a9a1
		make ${PKG_MAKEFLAGS_BUILD} "prefix=${PKG_DESTDIR}" "install" || return 1;
Lucio Andrés Illanes Albornoz 370e98
		pkgp_gcc_state_set "install_make" "install";
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
	fi;
e9fa07
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	if ! ex_pkg_state_test "${PKG_NAME}" install "${_restart_at}"; then
e9fa07
		pkg_install "${_group_name}" "${_pkg_name}" "${_restart_at}" || return 1;
Lucio Andrés Illanes Albornoz f3f7e8
		pkgp_gcc_state_set "install";
Lucio Andrés Illanes Albornoz b6a9a1
	fi;
e9fa07
Lucio Andrés Illanes Albornoz f3f7e8
	pkgp_gcc_state_set "finish";
e9fa07
e9fa07
	return 0;
Lucio Andrés Illanes Albornoz b6a9a1
};
Lucio Andrés Illanes Albornoz b6a9a1
Lucio Andrés Illanes Albornoz b6a9a1
pkg_gcc_full_host_all() {
e9fa07
	local _group_name="${1}" _pkg_name="${2}" _restart_at="${3}";
Lucio Andrés Illanes Albornoz b6a9a1
	export MAKE="make LIBTOOL=slibtool";
e9fa07
Lucio Andrés Illanes Albornoz b6a9a1
	if ! pkgp_gcc_build_dir "cbb-gcc-${PKG_VERSION}" cross\
Lucio Andrés Illanes Albornoz b6a9a1
	|| ! rtl_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; then
Lucio Andrés Illanes Albornoz b6a9a1
		return 1;
e9fa07
	else
e9fa07
		if ! ex_pkg_state_test "${PKG_NAME}" build "${_restart_at}"; then
Lucio Andrés Illanes Albornoz b6a9a1
			make ${PKG_MAKEFLAGS_BUILD} || return 1;
Lucio Andrés Illanes Albornoz 370e98
			pkgp_gcc_state_set "build" "install_subdirs";
Lucio Andrés Illanes Albornoz b6a9a1
		fi;
e9fa07
Lucio Andrés Illanes Albornoz b6a9a1
		if ! ex_pkg_state_test "${PKG_NAME}" install_subdirs "${_restart_at}"; then
e9fa07
			pkg_install_subdirs "${_group_name}" "${_pkg_name}" "${_restart_at}" || return 1;
Lucio Andrés Illanes Albornoz 370e98
			pkgp_gcc_state_set "install_subdirs" "install_make";
Lucio Andrés Illanes Albornoz b6a9a1
		fi;
e9fa07
Lucio Andrés Illanes Albornoz b6a9a1
		if ! ex_pkg_state_test "${PKG_NAME}" install_make "${_restart_at}"; then
Lucio Andrés Illanes Albornoz b6a9a1
			make ${PKG_MAKEFLAGS_BUILD} "prefix=${PKG_DESTDIR}" "install" || return 1;
Lucio Andrés Illanes Albornoz 370e98
			pkgp_gcc_state_set "install_make" "install";
Lucio Andrés Illanes Albornoz b6a9a1
		fi;
e9fa07
Lucio Andrés Illanes Albornoz b6a9a1
		if ! ex_pkg_state_test "${PKG_NAME}" install "${_restart_at}"; then
e9fa07
			pkg_install "${_group_name}" "${_pkg_name}" "${_restart_at}" || return 1;
Lucio Andrés Illanes Albornoz f3f7e8
			pkgp_gcc_state_set "install";
Lucio Andrés Illanes Albornoz b6a9a1
		fi;
e9fa07
Lucio Andrés Illanes Albornoz f3f7e8
		pkgp_gcc_state_set "finish";
Lucio Andrés Illanes Albornoz b6a9a1
	fi;
e9fa07
e9fa07
	return 0;
Lucio Andrés Illanes Albornoz b6a9a1
};
Lucio Andrés Illanes Albornoz b6a9a1
Lucio Andrés Illanes Albornoz b6a9a1
pkg_gcc_libstdcpp_v3_host_all() {
e9fa07
	local _group_name="${1}" _pkg_name="${2}" _restart_at="${3}";
Lucio Andrés Illanes Albornoz b6a9a1
	export MAKE="make LIBTOOL=slibtool";
e9fa07
Lucio Andrés Illanes Albornoz b6a9a1
	if ! pkgp_gcc_build_dir "cbb-gcc-${PKG_VERSION}" cross\
Lucio Andrés Illanes Albornoz b6a9a1
	|| ! rtl_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; then
Lucio Andrés Illanes Albornoz b6a9a1
		return 1;
e9fa07
	else
e9fa07
		if ! ex_pkg_state_test "${PKG_NAME}" build "${_restart_at}"; then
Lucio Andrés Illanes Albornoz b6a9a1
			make ${PKG_MAKEFLAGS_BUILD} "all-target-libstdc++-v3" || return 1;
Lucio Andrés Illanes Albornoz 370e98
			pkgp_gcc_state_set "build" "install_subdirs";
Lucio Andrés Illanes Albornoz b6a9a1
		fi;
e9fa07
Lucio Andrés Illanes Albornoz b6a9a1
		if ! ex_pkg_state_test "${PKG_NAME}" install_subdirs "${_restart_at}"; then
e9fa07
			pkg_install_subdirs "${_group_name}" "${_pkg_name}" "${_restart_at}" || return 1;
Lucio Andrés Illanes Albornoz 370e98
			pkgp_gcc_state_set "install_subdirs" "install_make";
Lucio Andrés Illanes Albornoz b6a9a1
		fi;
e9fa07
Lucio Andrés Illanes Albornoz b6a9a1
		if ! ex_pkg_state_test "${PKG_NAME}" install_make "${_restart_at}"; then
Lucio Andrés Illanes Albornoz b6a9a1
			make ${PKG_MAKEFLAGS_BUILD} "prefix=${PKG_DESTDIR}" "install-target-libstdc++-v3" || return 1;
Lucio Andrés Illanes Albornoz 370e98
			pkgp_gcc_state_set "install_make" "install";
Lucio Andrés Illanes Albornoz b6a9a1
		fi;
e9fa07
Lucio Andrés Illanes Albornoz b6a9a1
		if ! ex_pkg_state_test "${PKG_NAME}" install "${_restart_at}"; then
e9fa07
			pkg_install "${_group_name}" "${_pkg_name}" "${_restart_at}" || return 1;
Lucio Andrés Illanes Albornoz f3f7e8
			pkgp_gcc_state_set "install";
Lucio Andrés Illanes Albornoz b6a9a1
		fi;
e9fa07
Lucio Andrés Illanes Albornoz f3f7e8
		pkgp_gcc_state_set "finish";
Lucio Andrés Illanes Albornoz b6a9a1
	fi;
e9fa07
e9fa07
	return 0;
Lucio Andrés Illanes Albornoz b6a9a1
};
Lucio Andrés Illanes Albornoz b6a9a1
Lucio Andrés Illanes Albornoz b6a9a1
pkg_gcc_runtime_host_all() {
e9fa07
	local	_group_name="${1}" _pkg_name="${2}" _restart_at="${3}"	\
e9fa07
		_vis_hide="vis_hide=-fvisibility=hidden";
Lucio Andrés Illanes Albornoz b6a9a1
	export MAKE="make LIBTOOL=slibtool ${_vis_hide}";
e9fa07
Lucio Andrés Illanes Albornoz b6a9a1
	if ! pkgp_gcc_build_dir "cbb-gcc-${PKG_VERSION}" cross\
Lucio Andrés Illanes Albornoz b6a9a1
	|| ! rtl_fileop cd "${PKG_BASE_DIR}/${PKG_BUILD_DIR}"; then
Lucio Andrés Illanes Albornoz b6a9a1
		return 1;
e9fa07
	else
e9fa07
		if ! ex_pkg_state_test "${PKG_NAME}" build "${_restart_at}"; then
Lucio Andrés Illanes Albornoz b6a9a1
			make ${PKG_MAKEFLAGS_BUILD} "all-target-libgcc" ${_vis_hide} || return 1;
Lucio Andrés Illanes Albornoz 370e98
			pkgp_gcc_state_set "build" "install_subdirs";
Lucio Andrés Illanes Albornoz b6a9a1
		fi;
e9fa07
Lucio Andrés Illanes Albornoz b6a9a1
		if ! ex_pkg_state_test "${PKG_NAME}" install_subdirs "${_restart_at}"; then
e9fa07
			pkg_install_subdirs "${_group_name}" "${_pkg_name}" "${_restart_at}" || return 1;
Lucio Andrés Illanes Albornoz 370e98
			pkgp_gcc_state_set "install_subdirs" "install_make";
Lucio Andrés Illanes Albornoz b6a9a1
		fi;
e9fa07
Lucio Andrés Illanes Albornoz b6a9a1
		if ! ex_pkg_state_test "${PKG_NAME}" install_make "${_restart_at}"; then
Lucio Andrés Illanes Albornoz b6a9a1
			make ${PKG_MAKEFLAGS_BUILD} "prefix=${PKG_DESTDIR}" "install-target-libgcc" || return 1;
Lucio Andrés Illanes Albornoz 370e98
			pkgp_gcc_state_set "install_make" "install";
Lucio Andrés Illanes Albornoz b6a9a1
		fi;
e9fa07
Lucio Andrés Illanes Albornoz b6a9a1
		if ! ex_pkg_state_test "${PKG_NAME}" install "${_restart_at}"; then
e9fa07
			pkg_install "${_group_name}" "${_pkg_name}" "${_restart_at}" || return 1;
Lucio Andrés Illanes Albornoz f3f7e8
			pkgp_gcc_state_set "install";
Lucio Andrés Illanes Albornoz b6a9a1
		fi;
e9fa07
Lucio Andrés Illanes Albornoz f3f7e8
		pkgp_gcc_state_set "finish";
Lucio Andrés Illanes Albornoz b6a9a1
	fi;
e9fa07
e9fa07
	return 0;
Lucio Andrés Illanes Albornoz b6a9a1
};
Lucio Andrés Illanes Albornoz b6a9a1
Lucio Andrés Illanes Albornoz b6a9a1
pkg_gcc_stage1_all() {
Lucio Andrés Illanes Albornoz b6a9a1
	pkgp_gcc_stage1_all "${@}";
Lucio Andrés Illanes Albornoz b6a9a1
};
Lucio Andrés Illanes Albornoz b6a9a1
Lucio Andrés Illanes Albornoz b6a9a1
pkg_gcc_stage1_cross_mingw32_all() {
Lucio Andrés Illanes Albornoz b6a9a1
	if ! rtl_fileop ln_symbolic . "${PKG_PREFIX}/x86_64-w64-mingw32/mingw"\
Lucio Andrés Illanes Albornoz b6a9a1
	|| ! rtl_fileop mkdir "${PKG_DESTDIR}/x86_64-w64-mingw32"\
Lucio Andrés Illanes Albornoz b6a9a1
	|| ! rtl_fileop ln_symbolic . "${PKG_DESTDIR}/x86_64-w64-mingw32/mingw"\
Lucio Andrés Illanes Albornoz b6a9a1
	|| ! rtl_fileop mkdir "${PKG_PREFIX}/x86_64-w64-mingw32/include"\
Lucio Andrés Illanes Albornoz b6a9a1
	|| ! pkgp_gcc_stage1_all "${@}"; then
Lucio Andrés Illanes Albornoz b6a9a1
		return 1;
Lucio Andrés Illanes Albornoz b6a9a1
	fi;
e9fa07
	return 0;
Lucio Andrés Illanes Albornoz b6a9a1
};
Lucio Andrés Illanes Albornoz b6a9a1
Lucio Andrés Illanes Albornoz b6a9a1
pkg_gcc_stage1_host_all() {
Lucio Andrés Illanes Albornoz b6a9a1
	pkgp_gcc_stage1_all "${@}";
Lucio Andrés Illanes Albornoz b6a9a1
};
Lucio Andrés Illanes Albornoz b6a9a1
Lucio Andrés Illanes Albornoz b6a9a1
pkg_gcc_stage1_native_mingw32_all() {
Lucio Andrés Illanes Albornoz b6a9a1
	if ! rtl_fileop ln_symbolic . "${PKG_PREFIX}/x86_64-w64-mingw32/mingw"\
Lucio Andrés Illanes Albornoz b6a9a1
	|| ! rtl_fileop mkdir "${PKG_DESTDIR}/x86_64-w64-mingw32"\
Lucio Andrés Illanes Albornoz b6a9a1
	|| ! rtl_fileop ln_symbolic . "${PKG_DESTDIR}/x86_64-w64-mingw32/mingw"\
Lucio Andrés Illanes Albornoz b6a9a1
	|| ! rtl_fileop mkdir "${PKG_PREFIX}/x86_64-w64-mingw32/include"\
Lucio Andrés Illanes Albornoz b6a9a1
	|| ! pkgp_gcc_stage1_all "${@}"; then
Lucio Andrés Illanes Albornoz b6a9a1
		return 1;
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
	fi;
e9fa07
	return 0;
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
};
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
Lucio Andrés Illanes Albornoz bf9edf
# vim:filetype=sh textwidth=0