summaryrefslogtreecommitdiffhomepage
path: root/subr
diff options
context:
space:
mode:
Diffstat (limited to 'subr')
-rw-r--r--subr/ex_pkg_env.subr56
-rw-r--r--subr/ex_pkg_restart.subr3
-rw-r--r--subr/pkg_configure.subr160
-rw-r--r--subr/pkg_configure_autotools.subr7
-rw-r--r--subr/pkg_fetch_clean.subr2
5 files changed, 173 insertions, 55 deletions
diff --git a/subr/ex_pkg_env.subr b/subr/ex_pkg_env.subr
index 5048c939..c7d40dce 100644
--- a/subr/ex_pkg_env.subr
+++ b/subr/ex_pkg_env.subr
@@ -61,8 +61,10 @@ exp_pkg_env_defaults() {
# Return: zero (0) on success, non-zero (>0) on failure
#
exp_pkg_env_set() {
- local _build_vars_default="${1}" _group_name="${2}" _nounset="${3}"\
- _pkg_name="${4}" _var_prefixes="" _vars_set="" _vname="" IFS IFS0;
+ local _build_vars_default="${1}" _group_name="${2}" _nounset="${3}" \
+ _pkg_name="${4}" _cmd_name="" _var_prefixes="" _vars_set="" \
+ _vname="" IFS IFS0;
+
rtl_set_vars _vars_set BUILD_TYPE "DEFAULT ${_group_name} PKG_${_pkg_name}";
rtl_set_vars _vars_set INHERIT_FROM "PKG_${_pkg_name}";
_var_prefixes="$(rtl_toupper "DEFAULT DEFAULT_${PKG_BUILD_TYPE} ${_group_name}")";
@@ -85,48 +87,13 @@ exp_pkg_env_set() {
"$(set | sed -ne '/^PKG_[^=]*=/s/=.*$//p' | paste -s -d " ")" \
"${_vars_set}");
fi;
-};
-ex_pkg_env_sofort() {
- local _pkg_base_dir="${1}" _pkg_sofort_force="${2}" _pkg_subdir="${3}" \
- _vname="" _vname_new="" _vval="" _vval_old="";
-
- if [ -d "${_pkg_base_dir}/${_pkg_subdir}/sofort" ] \
- || [ "${_pkg_sofort_force:-0}" -eq 1 ]; then
- for _vname in \
- PKG_SOFORT_NATIVE_CC \
- PKG_SOFORT_NATIVE_CFLAGS \
- PKG_SOFORT_NATIVE_CXX \
- PKG_SOFORT_NATIVE_CXXFLAGS \
- PKG_SOFORT_NATIVE_LD \
- PKG_SOFORT_NATIVE_LDFLAGS; do
- _vname_new="PKG_${_vname#PKG_SOFORT_}";
- rtl_set_var_unsafe "${_vname_new}" "";
- done;
- for _vname in \
- PKG_SOFORT_NATIVE_CC \
- PKG_SOFORT_NATIVE_CFLAGS \
- PKG_SOFORT_NATIVE_CFLAGS_EXTRA \
- PKG_SOFORT_NATIVE_CXX \
- PKG_SOFORT_NATIVE_CXXFLAGS \
- PKG_SOFORT_NATIVE_CXXFLAGS_EXTRA \
- PKG_SOFORT_NATIVE_LD \
- PKG_SOFORT_NATIVE_LDFLAGS \
- PKG_SOFORT_NATIVE_LDFLAGS_EXTRA; do
- if _vval="$(rtl_get_var_unsafe "${_vname}")" \
- && [ -n "${_vval}" ]; then
- _vname_new="${_vname#PKG_SOFORT_}";
- case "${_vname}" in
- *_EXTRA)
- _vval_old="$(rtl_get_var_unsafe "${_vname_new%_EXTRA}")";
- rtl_set_var_unsafe "${_vname_new%_EXTRA}" "${_vval_old:+${_vval_old} }${_vval}"; ;;
- *)
- rtl_set_var_unsafe "${_vname_new}" "${_vval}"; ;;
- esac;
- export "${_vname_new}";
- fi;
- done;
- fi; return 0;
+ for _vname in AR CC CXX PKG_CONFIG RANLIB; do
+ if eval [ '"${PKG_'"${_vname}"':+1}"' = 1 ]\
+ && eval [ '"${PKG_'"${_vname}"'#/}"' = '"${_cmd_name:=${PKG_'"${_vname}"'}}"' ]; then
+ eval PKG_${_vname}='$(which "${_cmd_name}")';
+ fi; _cmd_name="";
+ done;
};
#
@@ -146,8 +113,7 @@ ex_pkg_env() {
_nounset="${4}" _pkg_name="${5}" _restart_at="${6}" _workdir="${7}" _vname="";
rtl_fileop source_opt "vars/${_pkg_name}.vars" "${_group_name}/${_pkg_name}.${_group_name}";
if ! exp_pkg_env_set "${_build_vars_default}" "${_group_name}" "${_nounset}" "${_pkg_name}"\
- || ! exp_pkg_env_defaults "${_build_steps_default}" "${_pkg_name}" "${_workdir}"\
- || ! ex_pkg_env_sofort "${PKG_BASE_DIR:-}" "${PKG_SOFORT_FORCE:-0}" "${PKG_SUBDIR:-}"; then
+ || ! exp_pkg_env_defaults "${_build_steps_default}" "${_pkg_name}" "${_workdir}"; then
return 1;
fi;
};
diff --git a/subr/ex_pkg_restart.subr b/subr/ex_pkg_restart.subr
index b45851f2..d6f2bee5 100644
--- a/subr/ex_pkg_restart.subr
+++ b/subr/ex_pkg_restart.subr
@@ -280,8 +280,7 @@ ex_pkg_process_restart_spec() {
if [ "${_epprs_step}" = "${_epprs_step1}" ]; then
eval ${_epprs_rspec_at}='${'"${_epprs_rspec_at}"':+${'"${_epprs_rspec_at}"'},}finish';
fi;
- fi;
- eval echo '${'"${_epprs_rspec}"'}'; ;;
+ fi; ;;
esac; rtl_llift3 "${_epprs_rspec}" "," " " || _epprs_rc=1;
else
_epprs_rc=1;
diff --git a/subr/pkg_configure.subr b/subr/pkg_configure.subr
index c57b342b..ea265076 100644
--- a/subr/pkg_configure.subr
+++ b/subr/pkg_configure.subr
@@ -2,19 +2,27 @@
# set +o errexit -o noglob -o nounset is assumed.
#
-pkg_configure() {
+pkgp_configure_autotools() {
local _libtool="" _rc=0;
- if [ -x "${PKG_CONFIGURE:-}" ]; then
+
+ if ! [ -x "${PKG_CONFIGURE:-}" ]; then
+ return 2;
+ elif [ -d "${PKG_BASE_DIR}/${PKG_SUBDIR}/sofort" ]\
+ || [ "${PKG_CONFIGURE_TYPE:-}" = "sofort" ]; then
+ return 2;
+ else
case "${PKG_LIBTOOL:-}" in
"") _libtool=""; ;;
none) _libtool=""; ;;
*) _libtool="${PKG_LIBTOOL}"; ;;
esac;
- rtl_export_vars \
+
+ rtl_export_vars \
PKG_CONFIG "${PKG_PKG_CONFIG:-}" \
PKG_CONFIG_LIBDIR "${PKG_PKG_CONFIG_LIBDIR:-}" \
PYTHON "${PKG_PYTHON:-}" \
${_libtool:+MAKE} ${_libtool:+"make LIBTOOL=${_libtool}"};
+
AR="${PKG_AR}" \
CC="${PKG_CC}" \
RANLIB="${PKG_RANLIB}" \
@@ -23,8 +31,9 @@ pkg_configure() {
CXXFLAGS="${PKG_CXXFLAGS_CONFIGURE:-}${PKG_CXXFLAGS_CONFIGURE_EXTRA:+ ${PKG_CXXFLAGS_CONFIGURE_EXTRA}}" \
LDFLAGS="${PKG_LDFLAGS_CONFIGURE:-}${PKG_LDFLAGS_CONFIGURE_EXTRA:+ ${PKG_LDFLAGS_CONFIGURE_EXTRA}}" \
"${PKG_CONFIGURE}" ${PKG_CONFIGURE_ARGS:-} ${PKG_CONFIGURE_ARGS_EXTRA:-} ${PKG_CONFIGURE_ARGS_EXTRA_DEBUG:-};
- _rc="${?}"
- rtl_export_vars -u \
+ _rc=$((${?} ? 1 : ${_rc}));
+
+ rtl_export_vars -u \
PKG_CONFIG "${PKG_PKG_CONFIG:-}" \
PKG_CONFIG_LIBDIR "${PKG_PKG_CONFIG_LIBDIR:-}" \
PYTHON "${PKG_PYTHON:-}" \
@@ -33,4 +42,143 @@ pkg_configure() {
fi;
};
-# vim:filetype=sh
+pkgp_configure_cmake() {
+ local _cmake_args_auto"" _build_type="" _IFS0="${IFS:- }" _rc=0 IFS;
+
+ if [ "${PKG_CMAKE_LISTFILE:+1}" != 1 ]\
+ || ! [ -e "${PKG_BASE_DIR}/${PKG_SUBDIR}/${PKG_CMAKE_LISTFILE}" ]; then
+ _rc=2;
+ else
+ rtl_fileop rm config.cache || return 1;
+ rtl_export_vars \
+ PKG_CONFIG "${PKG_PKG_CONFIG:-}" \
+ PKG_CONFIG_LIBDIR "${PKG_PKG_CONFIG_LIBDIR:-}" \
+ PYTHON "${PKG_PYTHON:-}";
+
+ case "${BUILD_KIND}" in
+ debug) _build_type="debug"; ;;
+ release|*) _build_type="release"; ;;
+ esac;
+
+ _cmake_args_auto="
+ -DCMAKE_AR=${PKG_AR}
+ -DCMAKE_BUILD_TYPE=${_build_type}
+ -DCMAKE_C_COMPILER=${PKG_CC}
+ -DCMAKE_C_FLAGS=${PKG_CFLAGS_CONFIGURE:-}${PKG_CFLAGS_CONFIGURE_EXTRA:+ ${PKG_CFLAGS_CONFIGURE_EXTRA}}
+ -DCMAKE_CPP_FLAGS=${PKG_CPPFLAGS_CONFIGURE:-}${PKG_CPPFLAGS_CONFIGURE_EXTRA:+ ${PKG_CPPFLAGS_CONFIGURE_EXTRA}}
+ -DCMAKE_CXX_COMPILER=${PKG_CXX}
+ -DCMAKE_CXX_FLAGS=${PKG_CXXFLAGS_CONFIGURE:-}${PKG_CXXFLAGS_CONFIGURE_EXTRA:+ ${PKG_CXXFLAGS_CONFIGURE_EXTRA}}
+ -DCMAKE_EXE_LINKER_FLAGS=${PKG_LDFLAGS_CONFIGURE:-}${PKG_LDFLAGS_CONFIGURE_EXTRA:+ ${PKG_LDFLAGS_CONFIGURE_EXTRA}}
+ -DCMAKE_FIND_ROOT_PATH=${PKG_PREFIX}
+ -DCMAKE_INSTALL_PREFIX=
+ -DCMAKE_LINKER=$(which "ld")
+ -DCMAKE_MODULE_LINKER_FLAGS=${PKG_LDFLAGS_CONFIGURE:-}${PKG_LDFLAGS_CONFIGURE_EXTRA:+ ${PKG_LDFLAGS_CONFIGURE_EXTRA}}
+ -DCMAKE_RANLIB=${PKG_RANLIB}
+ -DCMAKE_SHARED_LINKER_FLAGS=${PKG_LDFLAGS_CONFIGURE:-}${PKG_LDFLAGS_CONFIGURE_EXTRA:+ ${PKG_LDFLAGS_CONFIGURE_EXTRA}}
+ -DPKG_CONFIG_EXECUTABLE=${PKG_PKG_CONFIG}" || return 1;
+
+ case "${PKG_BUILD_TYPE}" in
+ host|cross)
+ ;;
+ native)
+ _cmake_args_auto="${_cmake_args_auto:+${_cmake_args_auto}}
+ -DCMAKE_LINKER=$(which "${PKG_TARGET}-ld")
+ -DCMAKE_SYSROOT=${PKG_PREFIX}
+ -DCMAKE_SYSTEM_NAME=Midipix" || return 1;
+
+ case "${ARCH}" in
+ nt32) _cmake_args_auto="${_cmake_args_auto:+${_cmake_args_auto}}
+ -DCMAKE_SYSTEM_PROCESSOR=i686"; ;;
+ nt64) _cmake_args_auto="${_cmake_args_auto:+${_cmake_args_auto}}
+ -DCMAKE_SYSTEM_PROCESSOR=x86_64"; ;;
+ esac; ;;
+ esac;
+
+ IFS="
+ "; "${PKG_CMAKE}" \
+ ${_cmake_args_auto} \
+ ${PKG_CMAKE_ARGS:-} \
+ ${PKG_CMAKE_ARGS_EXTRA:-} \
+ "${PKG_BASE_DIR}/${PKG_SUBDIR}";
+ _rc=$((${?} ? ${?} : ${_rc})); IFS="${_IFS0}";
+
+ rtl_export_vars -u \
+ PKG_CONFIG "${PKG_PKG_CONFIG:-}" \
+ PKG_CONFIG_LIBDIR "${PKG_PKG_CONFIG_LIBDIR:-}" \
+ PYTHON "${PKG_PYTHON:-}";
+ fi;
+ return "${_rc}";
+};
+
+pkgp_configure_sofort() {
+ local _rc=0 _vname="" _vnames="" _vval="";
+
+ if ! [ -x "${PKG_CONFIGURE:-}" ]; then
+ return 2;
+ elif ! [ -d "${PKG_BASE_DIR}/${PKG_SUBDIR}/sofort" ]\
+ && ! [ "${PKG_CONFIGURE_TYPE:-}" = "sofort" ]; then
+ return 2;
+ else
+ for _vname in AR CC CXX LD RANLIB; do
+ if eval [ '"${PKG_'"${_vname}"':+1}"' = 1 ]; then
+ _vnames="${_vnames:+${_vnames} }${_vname}";
+ eval ${_vname}='${PKG_'"${_vname}"'}'; export ${_vname};
+ fi;
+ if eval [ '"${PKG_SOFORT_NATIVE_'"${_vname}"':+1}"' = 1 ]; then
+ _vnames="${_vnames:+${_vnames} }NATIVE_${_vname}";
+ eval NATIVE_${_vname}='${PKG_SOFORT_NATIVE_'"${_vname}"'}'; export NATIVE_${_vname};
+ fi;
+ done;
+ for _vname in CFLAGS CPPFLAGS CXXFLAGS LDFLAGS; do
+ if eval [ '"${PKG_'"${_vname}"'_CONFIGURE:+1}"' = 1 ]; then
+ eval _vval='${PKG_'"${_vname}"'_CONFIGURE}';
+ if eval [ '"${PKG_'"${_vname}"'_CONFIGURE_EXTRA:+1}"' = 1 ]; then
+ eval _vval='${_vval:+${_vval} }${PKG_'"${_vname}"'_CONFIGURE_EXTRA}';
+ fi;
+ _vnames="${_vnames:+${_vnames} }${_vname} ${_vname}_SHARED ${_vname}_STATIC";
+ eval ${_vname}='${_vval}'\; ${_vname}_SHARED='${_vval}'\; ${_vname}_STATIC='${_vval}';
+ export ${_vname} ${_vname}_SHARED ${_vname}_STATIC;
+ fi;
+ if eval [ '"${PKG_SOFORT_NATIVE_'"${_vname}"':+1}"' = 1 ]; then
+ eval _vval='${PKG_SOFORT_NATIVE_'"${_vname}"'}';
+ if eval [ '"${PKG_SOFORT_NATIVE_'"${_vname}"'_EXTRA:+1}"' = 1 ]; then
+ eval _vval='${_vval:+${_vval} }${PKG_SOFORT_NATIVE_'"${_vname}"'_EXTRA}';
+ fi;
+ _vnames="${_vnames:+${_vnames} }NATIVE_${_vname}";
+ eval NATIVE_${_vname}='${_vval}'; export NATIVE_${_vname};
+ fi;
+ done;
+
+ RANLIB="${PKG_RANLIB}" \
+ "${PKG_CONFIGURE}" \
+ ${PKG_CONFIGURE_ARGS:-} \
+ ${PKG_CONFIGURE_ARGS_EXTRA:-} \
+ ${PKG_CONFIGURE_ARGS_EXTRA_DEBUG:-};
+ _rc=$((${?} ? 1 : ${_rc}));
+
+ for _vname in ${_vnames}; do
+ unset "${_vname}";
+ done;
+ return "${_rc}";
+ fi;
+};
+
+pkg_configure() {
+ local _rc=0 _type="";
+
+ for _type in autotools sofort cmake; do
+ if [ "${PKG_CONFIGURE_TYPE:+1}" = 1 ]\
+ && [ "${PKG_CONFIGURE_TYPE}" != "${_type}" ]; then
+ continue;
+ else
+ pkgp_configure_${_type} "${@}"; _rc="${?}";
+ case "${_rc}" in
+ 0|1) return "${_rc}"; ;;
+ 2) _rc=0; continue; ;;
+ esac;
+ fi;
+ done;
+ return "${_rc}";
+};
+
+# vim:filetype=sh textwidth=0
diff --git a/subr/pkg_configure_autotools.subr b/subr/pkg_configure_autotools.subr
index 421be28b..c91a08a3 100644
--- a/subr/pkg_configure_autotools.subr
+++ b/subr/pkg_configure_autotools.subr
@@ -4,7 +4,12 @@
pkg_configure_autotools() {
local _config_cache="" _fname="" _subdir_tgt="";
- ex_pkg_env_sofort "${PKG_BASE_DIR}" "${PKG_SOFORT_FORCE:-0}" "${PKG_SUBDIR:-}";
+
+ if [ "${PKG_CONFIGURE_TYPE:+1}" = 1 ]\
+ && [ "${PKG_CONFIGURE_TYPE}" != "autotools" ]; then
+ return 0;
+ fi;
+
if rtl_exists_any "${PKG_BASE_DIR}/${PKG_SUBDIR}" \
"config.guess" "configure.ac" "configure.in" "configure";
then rtl_export_vars PKG_CONFIG "${PKG_PKG_CONFIG:-}" PKG_CONFIG_LIBDIR "${PKG_PKG_CONFIG_LIBDIR:-}";
diff --git a/subr/pkg_fetch_clean.subr b/subr/pkg_fetch_clean.subr
index a56196cb..52797068 100644
--- a/subr/pkg_fetch_clean.subr
+++ b/subr/pkg_fetch_clean.subr
@@ -8,7 +8,7 @@ pkg_fetch_clean() {
if [ -n "${PKG_URLS_GIT:-}" ]; then
if [ -n "${PKG_SUBDIR:-}" ]\
&& [ "${PKG_SUBDIR}" != "${PKG_URLS_GIT%%=*}" ]; then
- rtl_fileopm rm "${PKG_SUBDIR}";
+ rtl_fileop rm "${PKG_SUBDIR}";
fi;
for _dname in ${PKG_URLS_GIT}; do
_dname="${_dname%%=*}"; rtl_fileop rm "${_dname}";