summaryrefslogtreecommitdiffhomepage
path: root/subr.pkg/pkg_configure.subr
blob: f712c2e77857bb360743d1f128b659e2faa0413f (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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
#
# 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"; ;;
		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_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 _ppcs_vname="" _ppcs_vnames="" _ppcs_vval="";

	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
		for _ppcs_vname in AR CC CCLD CXX RANLIB; do
			if eval [ '"${PKG_'"${_ppcs_vname}"':+1}"' = 1 ]; then
				if [ "${_ppcs_vname}" = CCLD ]; then
					_ppcs_vnames="${_ppcs_vnames:+${_ppcs_vnames} }LD";
					eval LD='${PKG_'"${_ppcs_vname}"'}'; export LD;
				else
					_ppcs_vnames="${_ppcs_vnames:+${_ppcs_vnames} }${_ppcs_vname}";
					eval ${_ppcs_vname}='${PKG_'"${_ppcs_vname}"'}'; export ${_ppcs_vname};
				fi;
			fi;

			if eval [ '"${PKG_SOFORT_NATIVE_'"${_ppcs_vname}"':+1}"' = 1 ]; then
				_ppcs_vnames="${_ppcs_vnames:+${_ppcs_vnames} }NATIVE_${_ppcs_vname}";
				eval NATIVE_${_ppcs_vname}='${PKG_SOFORT_NATIVE_'"${_ppcs_vname}"'}'; export NATIVE_${_ppcs_vname};
			fi;
		done;

		for _ppcs_vname in CFLAGS CPPFLAGS CXXFLAGS LDFLAGS; do
			if eval [ '"${PKG_'"${_ppcs_vname}"'_CONFIGURE:+1}"' = 1 ]; then
				eval _ppcs_vval='${PKG_'"${_ppcs_vname}"'_CONFIGURE}';
				if eval [ '"${PKG_'"${_ppcs_vname}"'_CONFIGURE_EXTRA:+1}"' = 1 ]; then
					eval _ppcs_vval='${_ppcs_vval:+${_ppcs_vval} }${PKG_'"${_ppcs_vname}"'_CONFIGURE_EXTRA}';
				fi;
				_ppcs_vnames="${_ppcs_vnames:+${_ppcs_vnames} }${_ppcs_vname} ${_ppcs_vname}_SHARED ${_ppcs_vname}_STATIC";
				eval ${_ppcs_vname}='${_ppcs_vval}'\; ${_ppcs_vname}_SHARED='${_ppcs_vval}'\; ${_ppcs_vname}_STATIC='${_ppcs_vval}';
				export ${_ppcs_vname} ${_ppcs_vname}_SHARED ${_ppcs_vname}_STATIC;
			fi;

			if eval [ '"${PKG_SOFORT_NATIVE_'"${_ppcs_vname}"':+1}"' = 1 ]; then
				eval _ppcs_vval='${PKG_SOFORT_NATIVE_'"${_ppcs_vname}"'}';
				if eval [ '"${PKG_SOFORT_NATIVE_'"${_ppcs_vname}"'_EXTRA:+1}"' = 1 ]; then
					eval _ppcs_vval='${_ppcs_vval:+${_ppcs_vval} }${PKG_SOFORT_NATIVE_'"${_ppcs_vname}"'_EXTRA}';
				fi;
				_ppcs_vnames="${_ppcs_vnames:+${_ppcs_vnames} }NATIVE_${_ppcs_vname}";
				eval NATIVE_${_ppcs_vname}='${_ppcs_vval}'; export NATIVE_${_ppcs_vname};
			fi;
		done;

		RANLIB="${PKG_RANLIB}"				\
			"${PKG_CONFIGURE}"			\
				${PKG_CONFIGURE_ARGS:-}		\
				${PKG_CONFIGURE_ARGS_EXTRA:-};
		_ppcs_rc=$((${?} ? 1 : ${_ppcs_rc}));

		for _ppcs_vname in ${_ppcs_vnames}; do
			unset "${_ppcs_vname}";
		done;
	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 sofort cmake; 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