summaryrefslogtreecommitdiffhomepage
path: root/subr/pkg_configure_autotools.subr
blob: 15d76566e17ed6e0e7c334769b09458273c35010 (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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#
# set +o errexit -o noglob -o nounset is assumed.
#

pkg_configure_autotools() {
	local _config_cache="" _config_guest_fname="" _fname="" _subdir_tgt="";

	if [ "${PKG_CONFIGURE_TYPE:+1}" = 1 ]\
	&& [ "${PKG_CONFIGURE_TYPE}" != "autotools" ]; then
		return 0;
	fi;

	if [ "${PKG_AUTOCONF_CONFIG_GUESS:-midipix}" = "midipix" ]; then
		_config_guest_fname="config.guess";
	else
		_config_guest_fname="";
	fi;

	if rtl_exists_any "${PKG_BASE_DIR}/${PKG_SUBDIR}"							\
			${_config_guest_fname:+"${_config_guest_fname}"}					\
			"configure.ac" "configure.in" "configure";
	then	rtl_export_vars PKG_CONFIG "${PKG_PKG_CONFIG:-}" PKG_CONFIG_LIBDIR "${PKG_PKG_CONFIG_LIBDIR:-}";
		if [ "${PKG_FORCE_AUTORECONF:-0}" -eq 1 ]\
		&& ! (cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" && autoreconf -fiv); then
			return 1;
		fi;
		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
							if ! rtl_fileop install -m 0700				\
									"${MIDIPIX_BUILD_PWD}/etc/config.sub"	\
									"${_subdir_tgt}/config.sub"; then
								return 1;
							fi;
							if [ "${PKG_AUTOCONF_CONFIG_GUESS:-midipix}" = "midipix" ]; then
								if ! rtl_fileop install -m 0700			\
										"${MIDIPIX_BUILD_PWD}/etc/config.guess"\
										"${_subdir_tgt}/config.guess"; then
									return 1;
								else
									break;
								fi;
							fi;
						fi;
					done;
					if ! (rtl_fileop cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" &&			\
							/bin/sh "${_fname}"); then
						return 1;
					else
						break;
					fi;
				fi;
			done;
			if ! (rtl_fileop cd "${PKG_BASE_DIR}/${PKG_SUBDIR}" && autoconf); then
				return 1;
			fi;
		fi;
		for _fname in $(find "${PKG_BASE_DIR}/${PKG_SUBDIR}" -name config.sub); do
			if ! rtl_fileop mv "${_fname}" "${_fname}.orig"\
			|| ! rtl_fileop install -m 0700 "${MIDIPIX_BUILD_PWD}/etc/config.sub" "${_fname}"; then
				return 1;
			fi;
		done;
		if [ "${PKG_AUTOCONF_CONFIG_GUESS:-midipix}" = "midipix" ]; then
			for _fname in $(find "${PKG_BASE_DIR}/${PKG_SUBDIR}" -name config.guess); do
				if ! rtl_fileop mv "${_fname}" "${_fname}.orig"\
				|| ! rtl_fileop install -m 0700 "${MIDIPIX_BUILD_PWD}/etc/config.guess" "${_fname}"; then
					return 1;
				fi;
			done;
		fi;
		if [ "${PKG_BUILD_TYPE}" != host ]; then
			if ! 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	if [ -n "${_config_cache}" ]\
					&& ! printf "%s\n" "${_config_cache}"					|\
							tr " " "\n" >> "${PKG_BUILD_DIR}/config.cache"; then
						return 1;
					fi;
				done;
				if ! sed -i"" "s,%PREFIX%,${PKG_PREFIX},g" "${PKG_BUILD_DIR}/config.cache"; then
					return 1;
				fi;
			fi;
		fi;
		rtl_export_vars -u PKG_CONFIG "${PKG_PKG_CONFIG:-}" PKG_CONFIG_LIBDIR "${PKG_PKG_CONFIG_LIBDIR:-}";
	fi;
};

# vim:filetype=sh