summaryrefslogtreecommitdiff
path: root/scripts/include/common.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/include/common.sh')
-rw-r--r--scripts/include/common.sh104
1 files changed, 88 insertions, 16 deletions
diff --git a/scripts/include/common.sh b/scripts/include/common.sh
index d57879b..382f8a5 100644
--- a/scripts/include/common.sh
+++ b/scripts/include/common.sh
@@ -165,9 +165,19 @@ function run_cmake {
}
function run_make {
- echo "make"
- make
+ if [[ "${jobs}" == "" ]]; then
+ if [ -f "/proc/cpuinfo" ]; then
+ jobs="$(cat /proc/cpuinfo|grep processor|wc -l)"
+ else
+ jobs="1"
+ fi
+ fi
+ j=" -j${jobs}"
+
+ echo "make$j"
+ make$j
check_error $?
+ unset j
}
function run_make_install {
@@ -244,44 +254,52 @@ function run_switch_branch {
}
function repack_paths {
- if [[ "$1" == "" ]]; then
+ envvar="$1"
+ if [[ "$2" != "" ]]; then
+ envvar="$2"
+ fi
+ if [[ "$envvar" == "" ]]; then
return
fi
IFS=":"
packedpaths=""
- for var in $1
+ for var in $envvar
do
packedpaths="${packedpaths}${bindir}/$var:"
done
unset IFS
- echo "export $2=\"${packedpaths}\$$2\"" >>"${envfile}"
+ echo "export $3=\"${packedpaths}\$$3\"" >>"${envfile}"
check_error $?
}
function repack_flags {
- if [[ "$1" == "" ]]; then
+ envvar="$1"
+ if [[ "$2" != "" ]]; then
+ envvar="$2"
+ fi
+ if [[ "$envvar" == "" ]]; then
return
fi
IFS=":"
packedpaths=""
- for var in $1
+ for var in $envvar
do
- packedpaths="${packedpaths}${3}${bindir}/$var "
+ packedpaths="${packedpaths}${4}${bindir}/$var "
done
unset IFS
- echo "export $2=\"${packedpaths}\$$2\"" >>"${envfile}"
+ echo "export $3=\"${packedpaths}\$$3\"" >>"${envfile}"
check_error $?
}
function package_use {
echo "package_use"
- repack_paths "$ENV_PATH" "PATH"
- repack_paths "$ENV_LD_LIBRARY_PATH" "LD_LIBRARY_PATH"
- repack_paths "$ENV_PKG_CONFIG_PATH" "PKG_CONFIG_PATH"
- repack_paths "$ENV_MANPATH" "MANPATH"
- repack_paths "$ENV_ACLOCAL_PATH" "ACLOCAL_PATH"
- repack_flags "$ENV_LDFLAGS_PATH" "LDFLAGS" "-L"
- repack_flags "$ENV_CPPFLAGS_PATH" "CPPFLAGS" "-I"
+ repack_paths "$ENV_PATH" "$OVERRIDE_ENV_PATH" "PATH"
+ repack_paths "$ENV_LD_LIBRARY_PATH" "$OVERRIDE_ENV_LD_LIBRARY_PATH" "LD_LIBRARY_PATH"
+ repack_paths "$ENV_PKG_CONFIG_PATH" "$OVERRIDE_ENV_PKG_CONFIG_PATH" "PKG_CONFIG_PATH"
+ repack_paths "$ENV_MANPATH" "$OVERRIDE_ENV_MANPATH" "MANPATH"
+ repack_paths "$ENV_ACLOCAL_PATH" "$OVERRIDE_ENV_ACLOCAL_PATH" "ACLOCAL_PATH"
+ repack_flags "$ENV_LDFLAGS_PATH" "$OVERRIDE_ENV_LDFLAGS_PATH" "LDFLAGS" "-L"
+ repack_flags "$ENV_CPPFLAGS_PATH" "$OVERRIDE_ENV_CPPFLAGS_PATH" "CPPFLAGS" "-I"
}
function common_use_package {
@@ -299,6 +317,56 @@ function common_use_package {
check_error $?
}
+function common_use_packages {
+ cd "${scriptsdir}"
+ check_error $?
+
+ export envname="$1"
+ export installname0="${installname}"
+ export envfile="../env/run${envname}.sh"
+ echo "#!/bin/bash" >"${envfile}"
+ check_error $?
+ echo "" >>"${envfile}"
+ shift
+ names="$*"
+ IFS=" "
+ for package in $names
+ do
+ export installname="${installname0}"
+ unset ENV_PATH
+ unset ENV_LD_LIBRARY_PATH
+ unset ENV_PKG_CONFIG_PATH
+ unset ENV_MANPATH
+ unset ENV_ACLOCAL_PATH
+ unset ENV_LDFLAGS_PATH
+ unset ENV_CPPFLAGS_PATH
+
+ common_package_init
+ common_build_init
+ common_run_package
+ package_use
+ check_error $?
+ done
+ unset IFS
+ echo "\$*" >>"${envfile}"
+ check_error $?
+ chmod 0755 "${envfile}"
+ check_error $?
+}
+
+function common_update_source_all {
+ cd ../src/
+ check_error $?
+ files="*"
+ for package in $files
+ do
+ cd ../scripts/
+ ./updatesrc.sh $package
+ check_error $?
+ done
+ unset files
+}
+
function package_get_source {
echo "package_get_source"
run_clone "${SRCURL}"
@@ -360,3 +428,7 @@ function package_build {
run_make
run_make_install
}
+
+function include {
+ source "./$1.sh"
+}