summaryrefslogtreecommitdiffhomepage
path: root/subr/pkg_configure_autotools.subr
blob: 7c1ee329293bf8bab784c843f849577d531b9adf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#
# set +o errexit -o noglob is assumed.
#

pkg_configure_autotools() {
	local _config_cache="" _fname="" _subdir_tgt="";
	if ex_rtl_exists_any "${PKG_BASE_DIR}/${PKG_SUBDIR}"							\
			"config.guess" "configure.ac" "configure.in" "configure";
	then	ex_rtl_export_vars PKG_CONFIG "${PKG_PKG_CONFIG}" PKG_CONFIG_PATH "${PKG_PKG_CONFIG_PATH}";
		if [ -e "${PKG_BASE_DIR}/${PKG_SUBDIR}/configure.ac" ]\
		&& [ ! -e "${PKG_BASE_DIR}/${PKG_SUBDIR}/configure" ]; then
			for _fname in bootstrap bootstrap.sh autogen.sh; do
				if [ -e "${PKG_BASE_DIR}/${PKG_SUBDIR}/${_fname}" ]; then
					for _subdir_tgt in \
							"${PKG_BASE_DIR}/${PKG_SUBDIR}/build-aux"		\
							"${PKG_BASE_DIR}/${PKG_SUBDIR}";
					do	if [ -e "${_subdir_tgt}" ]; then
							ex_rtl_fileop install -m 0700				\
								"${MIDIPIX_BUILD_PWD}/etc/config.sub"		\
								"${_subdir_tgt}/config.sub" || return "${?}" && break;
						fi;
					done;
					(ex_rtl_fileop cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" &&			\
						/bin/sh "${_fname}") || return "${?}" && break;
				fi;
			done;
			(ex_rtl_fileop cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" && autoconf) || return "${?}";
		fi;
		for _fname in $(find "${PKG_BASE_DIR}/${PKG_SUBDIR}" -name config.sub); do
			if ! ex_rtl_fileop mv "${_fname}" "${_fname}.orig"\
			|| ! ex_rtl_fileop install -m 0700 "${MIDIPIX_BUILD_PWD}/etc/config.sub" "${_fname}"; then
				return 1;
			fi;
		done
		if [ "${PKG_BUILD_TYPE}" != host ]; then
			if ! ex_rtl_fileop touch "${PKG_BUILD_DIR}/config.cache"; then
				return 1;
			else	for _config_cache in \
						"${PKG_CONFIG_CACHE}"						\
						"${PKG_CONFIG_CACHE_LOCAL}"					\
						"${PKG_CONFIG_CACHE_EXTRA}";
				do	echo "${_config_cache}"							|\
						tr " " "\n" >> "${PKG_BUILD_DIR}/config.cache" || return "${?}";
				done;
				sed -i"" "s,%PREFIX%,${PKG_PREFIX},g" "${PKG_BUILD_DIR}/config.cache" || return "${?}";
			fi;
		fi;
		ex_rtl_export_vars -u PKG_CONFIG "${PKG_PKG_CONFIG}" PKG_CONFIG_PATH "${PKG_PKG_CONFIG_PATH}";
	fi;
};

# vim:filetype=sh