From 8ee843a21869a1dc38a7fc7b543b7a5a1231a4e9 Mon Sep 17 00:00:00 2001 From: Lucio Andrés Illanes Albornoz (arab, vxp) Date: Feb 06 2017 01:26:49 +0000 Subject: build.sh, {subr,vars}/*: general cleanup. --- diff --git a/build.sh b/build.sh index 8a057c5..8991b60 100755 --- a/build.sh +++ b/build.sh @@ -78,7 +78,7 @@ for BUILD_TARGET_LC in $(subst_tgts invariants ${BUILD_TARGETS_META:-world}); do || lmatch "${ARG_RESTART_AT}" , "${1%:*}"; then _pkg_step_cmds="pkg_${PKG_NAME}_${1%:*} pkg_${1%:*}"; fi; - elif ! is_build_script_done ${PKG_NAME} ${1%:*}; then + elif ! is_build_script_done "${PKG_NAME}" "${1%:*}"; then _pkg_step_cmds="pkg_${PKG_NAME}_${1%:*} pkg_${1%:*}"; fi; ;; optional) diff --git a/subr/build.subr b/subr/build.subr index 35b8a22..5b67079 100644 --- a/subr/build.subr +++ b/subr/build.subr @@ -7,7 +7,7 @@ get_var_unsafe() { eval echo \${${1}}; }; set_var_unsafe() { [ -n "${2}" ] && eval ${1}=\"${2}\" || return 0; }; pop_IFS() { IFS="${_pI_IFS}"; unset _pI_IFS; }; push_IFS() { _pI_IFS="${IFS}"; IFS="${1}"; }; -set_build_dir() { PKG_BUILD_DIR=${1}-${2}-${PKG_TARGET}; }; +set_build_dir() { PKG_BUILD_DIR="${1}-${2}-${PKG_TARGET}"; }; test_cmd() { command -v "${1}" >/dev/null; }; build_fileop() { @@ -78,7 +78,7 @@ install_files() { }; is_build_script_done() { - local _done_fname="${WORKDIR}/.${1}.${2}" _restart_at="${2}"; + local _done_fname="${WORKDIR}/.${1}.${2}" _restart_at="${3}"; if [ -z "${_restart_at}" ]; then if [ -e "${_done_fname}" ]; then return 0; # Skip diff --git a/subr/pkg_000000.subr b/subr/pkg_000000.subr deleted file mode 100644 index 17a48fc..0000000 --- a/subr/pkg_000000.subr +++ /dev/null @@ -1,40 +0,0 @@ -# -# set -o errexit -o noglob are assumed. -# - -pkg_000000() { - local _pkg_name_uc _vars_fname _vname _build_uc __ _log_env_vars; - _pkg_name_uc="$(echo ${PKG_NAME} | tr a-z A-Z)"; - for _vars_fname in vars/${PKG_NAME}.vars; do - [ -e "${_vars_fname}" ] && . "${_vars_fname}"; - done; - for _vname in PREFIX ${PKG_BUILD_VARS}; do - _build_uc="$(echo ${BUILD} | tr a-z A-Z)"; - for __ in "DEFAULT_${_vname}" \ - "${BUILD_TARGET}_${_vname}" \ - "PKG_${_pkg_name_uc}_${_vname}" \ - "PKG_${_pkg_name_uc}_${_vname}_${_build_uc}"; do - set_var_unsafe "PKG_${_vname}" "$(get_var_unsafe ${__})"; - done; - done; - if [ -z "${PKG_URL}" -a -z "${PKG_URLS_GIT}" -a -z "${PKG_VERSION}" ]; then - log_msg failexit "Error: package \`${PKG_NAME}' missing in build.vars."; - else - [ -n "${PKG_ENV_VARS_EXTRA}" ] && set_env_vars_with_sep : "${PKG_ENV_VARS_EXTRA}"; - [ -z "${PKG_FNAME}" ] && PKG_FNAME="${PKG_URL##*/}"; - [ -z "${PKG_SUBDIR}" ] && PKG_SUBDIR="${PKG_FNAME%%.tar*}"; - [ -z "${PKG_TARGET}" ] && PKG_TARGET="${TARGET}"; - [ -z "${MIDIPIX_BUILD_PWD}" ] && MIDIPIX_BUILD_PWD="$(pwd)"; - fi; - for __ in $(set); do - if [ "${__#PKG_${_pkg_name_uc}}" != "${__}" ]; then - _log_env_vars="${_log_env_vars:+${_log_env_vars} }${__%%=*}"; - fi; - done; - if [ -n "${_log_env_vars}" ]; then - log_env_vars "build" ${_log_env_vars}; - fi; - build_fileop cd "${WORKDIR}"; -}; - -# vim:filetype=sh diff --git a/subr/pkg_autoconf.subr b/subr/pkg_autoconf.subr index 5260bf1..65f7c2d 100644 --- a/subr/pkg_autoconf.subr +++ b/subr/pkg_autoconf.subr @@ -4,36 +4,36 @@ pkg_autoconf() { local __; - if [ -e ${PKG_SUBDIR}/configure -o \ - -e ${PKG_SUBDIR}/configure.ac -o \ - -e ${PKG_SUBDIR}/configure.in -o \ - -e ${PKG_SUBDIR}/config.guess ]; then - find ${PKG_SUBDIR} -name config.sub \ + if [ -e "../${PKG_SUBDIR}/configure" -o \ + -e "../${PKG_SUBDIR}/configure.ac" -o \ + -e "../${PKG_SUBDIR}/configure.in" -o \ + -e "../${PKG_SUBDIR}/config.guess" ]; then + find "../${PKG_SUBDIR}" -name config.sub \ -exec echo mv -- {} {}.orig \; \ -exec mv -- {} {}.orig \; \ - -exec echo install -m 0700 ${MIDIPIX_BUILD_PWD}/etc/config.sub {} \; \ - -exec install -m 0700 ${MIDIPIX_BUILD_PWD}/etc/config.sub {} \;; - if [ -e ${PKG_SUBDIR}/configure.ac -a \ - ! -e ${PKG_SUBDIR}/configure ]; then - if [ -e ${PKG_SUBDIR}/autogen.sh ]; then - for __ in ${PKG_SUBDIR}/build-aux ${PKG_SUBDIR}; do - if [ -e ${__} ]; then + -exec echo install -m 0700 "${MIDIPIX_BUILD_PWD}/etc/config.sub" {} \; \ + -exec install -m 0700 "${MIDIPIX_BUILD_PWD}/etc/config.sub" {} \;; + if [ -e "../${PKG_SUBDIR}/configure.ac" ]\ + && [ ! -e "../${PKG_SUBDIR}/configure" ]; then + if [ -e "../${PKG_SUBDIR}/autogen.sh" ]; then + for __ in "../${PKG_SUBDIR}/build-aux" "../${PKG_SUBDIR}"; do + if [ -e "${__}" ]; then echo install -m 0700 \ - ${MIDIPIX_BUILD_PWD}/etc/config.sub \ - ${__}/config.sub; + "${MIDIPIX_BUILD_PWD}/etc/config.sub" \ + "${__}/config.sub"; install -m 0700 \ - ${MIDIPIX_BUILD_PWD}/etc/config.sub \ - ${__}/config.sub; + "${MIDIPIX_BUILD_PWD}/etc/config.sub" \ + "${__}/config.sub"; break; fi; done; - (build_fileop cd ${PKG_SUBDIR} && ${SHELL} ./autogen.sh) || exit 1; + (build_fileop cd "../${PKG_SUBDIR}" && "${SHELL}" ./autogen.sh) || exit 1; else - (build_fileop cd ${PKG_SUBDIR} && autoconf) || exit 1; + (build_fileop cd "../${PKG_SUBDIR}" && autoconf) || exit 1; fi; fi; - for __ in ${PKG_BUILD_DIR} ${PKG_CONFIG_CACHE_EXTRA}; do - build_fileop cp ${MIDIPIX_BUILD_PWD}/etc/config.cache ${__}/; + for __ in . ${PKG_CONFIG_CACHE_EXTRA}; do + build_fileop cp "${MIDIPIX_BUILD_PWD}/etc/config.cache" "${__}/"; done; fi; }; diff --git a/subr/pkg_build_dir.subr b/subr/pkg_build_dir.subr index 3285521..13e96ab 100644 --- a/subr/pkg_build_dir.subr +++ b/subr/pkg_build_dir.subr @@ -4,11 +4,12 @@ pkg_build_dir() { if [ -z "${PKG_BUILD_DIR}" ]; then - set_build_dir ${PKG_SUBDIR} ${PKG_BUILD_TYPE:-native}; + set_build_dir "${PKG_SUBDIR}" "${PKG_BUILD_TYPE:-native}"; fi; if [ ! -d "${PKG_BUILD_DIR}" ]; then - build_fileop mkdir ${PKG_BUILD_DIR}; + build_fileop mkdir "${PKG_BUILD_DIR}"; fi; + build_fileop cd "${PKG_BUILD_DIR}"; }; # vim:filetype=sh diff --git a/subr/pkg_configure.subr b/subr/pkg_configure.subr index 528d300..fc70f39 100644 --- a/subr/pkg_configure.subr +++ b/subr/pkg_configure.subr @@ -3,10 +3,16 @@ # pkg_configure() { - if [ ${__no_autoconf:-0} -eq 0 ]; then - CFLAGS="${PKG_CFLAGS_CONFIGURE}${PKG_CFLAGS_CONFIGURE_EXTRA:+ ${PKG_CFLAGS_CONFIGURE_EXTRA}}"\ - LDFLAGS="${PKG_LDFLAGS_CONFIGURE}${PKG_LDFLAGS_CONFIGURE_EXTRA:+ ${PKG_LDFLAGS_CONFIGURE_EXTRA}}"\ - ${PKG_CONFIGURE} \ + if [ -n "${PKG_CONFIGURE}" ]; then + PKG_CONFIGURE="../${PKG_CONFIGURE}"; + else + PKG_CONFIGURE="../${PKG_SUBDIR}/configure"; + fi; + if [ -x "${PKG_CONFIGURE}" ]; then + export CFLAGS_FOR_BUILD="${HOST_TOOLCHAIN_CFLAGS_CONFIGURE_DEFAULT}"; + CFLAGS="${PKG_CFLAGS_CONFIGURE}${PKG_CFLAGS_CONFIGURE_EXTRA:+ ${PKG_CFLAGS_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}; fi; }; diff --git a/subr/pkg_patch.subr b/subr/pkg_patch.subr index 63e1b45..8cb173f 100644 --- a/subr/pkg_patch.subr +++ b/subr/pkg_patch.subr @@ -4,21 +4,21 @@ pkg_patch() { local _patch_fname; - if [ -d ${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME} ]; then + if [ -d "${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME}" ]; then set +o noglob; - for _patch_fname in ${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME}/*.patch; do - patch -b -d ${PKG_SUBDIR} -p1 < ${_patch_fname}; + for _patch_fname in "${MIDIPIX_BUILD_PWD}/patches/${PKG_NAME}/*.patch"; do + patch -b -d "../${PKG_SUBDIR}" -p1 < "${_patch_fname}"; done; set -o noglob; fi; for _patch_fname in \ - ${MIDIPIX_BUILD_PWD}/../${PKG_SUBDIR}.local.patch \ - ${MIDIPIX_BUILD_PWD}/../${PKG_SUBDIR}.local@${BUILD_HNAME}.patch \ - ${WORKDIR}/chainport/${PKG_SUBDIR}.midipix.patch \ - ${MIDIPIX_BUILD_PWD}/patches/${PKG_SUBDIR}.local.patch \ - ${MIDIPIX_BUILD_PWD}/patches/${PKG_SUBDIR}.local@${BUILD_HNAME}.patch; do + "${MIDIPIX_BUILD_PWD}/../${PKG_SUBDIR}.local.patch" \ + "${MIDIPIX_BUILD_PWD}/../${PKG_SUBDIR}.local@${BUILD_HNAME}.patch" \ + "${WORKDIR}/chainport/${PKG_SUBDIR}.midipix.patch" \ + "${MIDIPIX_BUILD_PWD}/patches/${PKG_SUBDIR}.local.patch" \ + "${MIDIPIX_BUILD_PWD}/patches/${PKG_SUBDIR}.local@${BUILD_HNAME}.patch"; do if [ -r "${_patch_fname}" ]; then - patch -b -d ${PKG_SUBDIR} -p1 < ${_patch_fname}; + patch -b -d "../${PKG_SUBDIR}" -p1 < "${_patch_fname}"; fi; done; }; diff --git a/subr/pkg_patch_pre.subr b/subr/pkg_patch_pre.subr index 64f60f1..298acd7 100644 --- a/subr/pkg_patch_pre.subr +++ b/subr/pkg_patch_pre.subr @@ -5,13 +5,13 @@ pkg_patch_pre() { local __; for __ in \ - ${MIDIPIX_BUILD_PWD}/../${PKG_SUBDIR}_pre.local.patch \ - ${MIDIPIX_BUILD_PWD}/../${PKG_SUBDIR}_pre.local@${BUILD_HNAME}.patch \ - ${WORKDIR}/chainport/${PKG_SUBDIR}_pre.midipix.patch \ - ${MIDIPIX_BUILD_PWD}/patches/${PKG_SUBDIR}_pre.local.patch \ - ${MIDIPIX_BUILD_PWD}/patches/${PKG_SUBDIR}_pre.local@${BUILD_HNAME}.patch; do + "${MIDIPIX_BUILD_PWD}/../${PKG_SUBDIR}_pre.local.patch" \ + "${MIDIPIX_BUILD_PWD}/../${PKG_SUBDIR}_pre.local@${BUILD_HNAME}.patch" \ + "${WORKDIR}/chainport/${PKG_SUBDIR}_pre.midipix.patch" \ + "${MIDIPIX_BUILD_PWD}/patches/${PKG_SUBDIR}_pre.local.patch" \ + "${MIDIPIX_BUILD_PWD}/patches/${PKG_SUBDIR}_pre.local@${BUILD_HNAME}.patch"; do if [ -r "${__}" ]; then - patch -b -d ${PKG_SUBDIR} -p1 < ${__}; + patch -b -d "${PKG_SUBDIR}" -p1 < "${__}"; fi; done; }; diff --git a/subr/pkg_setup_env.subr b/subr/pkg_setup_env.subr index 34dfa1f..60d5aec 100644 --- a/subr/pkg_setup_env.subr +++ b/subr/pkg_setup_env.subr @@ -3,32 +3,52 @@ # pkg_setup_env() { - PKG_SUBDIR_PATH=${PWD}/${PKG_SUBDIR#/}; - if [ -z "${PKG_CONFIGURE}" ]; then - PKG_CONFIGURE=${PKG_SUBDIR_PATH}/configure; + local _pkg_name_uc _vars_fname _vname _build_uc __ _log_env_vars; + _pkg_name_uc="$(echo ${PKG_NAME} | tr a-z A-Z)"; + for _vars_fname in vars/${PKG_NAME}.vars; do + [ -e "${_vars_fname}" ] && . "${_vars_fname}"; + done; + for _vname in PREFIX ${PKG_BUILD_VARS}; do + _build_uc="$(echo ${BUILD} | tr a-z A-Z)"; + for __ in "DEFAULT_${_vname}" \ + "${BUILD_TARGET}_${_vname}" \ + "PKG_${_pkg_name_uc}_${_vname}" \ + "PKG_${_pkg_name_uc}_${_vname}_${_build_uc}"; do + set_var_unsafe "PKG_${_vname}" "$(get_var_unsafe ${__})"; + done; + done; + if [ -z "${PKG_URL}" -a -z "${PKG_URLS_GIT}" -a -z "${PKG_VERSION}" ]; then + log_msg failexit "Error: package \`${PKG_NAME}' missing in build.vars."; else - PKG_CONFIGURE=${PWD}/${PKG_CONFIGURE#/}; + [ -n "${PKG_ENV_VARS_EXTRA}" ] && set_env_vars_with_sep : "${PKG_ENV_VARS_EXTRA}"; + [ -z "${PKG_FNAME}" ] && PKG_FNAME="${PKG_URL##*/}"; + [ -z "${PKG_SUBDIR}" ] && PKG_SUBDIR="${PKG_FNAME%%.tar*}"; + [ -z "${PKG_TARGET}" ] && PKG_TARGET="${TARGET}"; + [ -z "${MIDIPIX_BUILD_PWD}" ] && MIDIPIX_BUILD_PWD="$(pwd)"; fi; - if [ "${PKG_BUILD_TYPE}" = "host" ]; then - export AR=ar; - export CC=gcc; - export CXX=g++; - export RANLIB=ranlib; - else - export AR=${PKG_TARGET}-ar; - export CC=${PKG_TARGET}-gcc; - export CXX=${PKG_TARGET}-g++; - export RANLIB=${PKG_TARGET}-ranlib; + for __ in $(set); do + if [ "${__#PKG_${_pkg_name_uc}}" != "${__}" ]; then + _log_env_vars="${_log_env_vars:+${_log_env_vars} }${__%%=*}"; + fi; + done; + if [ -n "${_log_env_vars}" ]; then + log_env_vars "build" ${_log_env_vars}; fi; - if [ -x ${PKG_CONFIGURE} ]; then - export CFLAGS_FOR_BUILD="${HOST_TOOLCHAIN_CFLAGS_CONFIGURE_DEFAULT}"; + build_fileop cd "${WORKDIR}"; + if [ "${PKG_BUILD_TYPE}" = "host" ]; then + export AR="ar"; + export CC="gcc"; + export CXX="g++"; + export RANLIB="ranlib"; else - __no_autoconf=1; + export AR="${PKG_TARGET}-ar"; + export CC="${PKG_TARGET}-gcc"; + export CXX="${PKG_TARGET}-g++"; + export RANLIB="${PKG_TARGET}-ranlib"; fi; if [ "${PKG_SLIBTOOL}" != "default" ]; then export MAKE="make LIBTOOL=${PKG_SLIBTOOL:-slibtool}"; fi; - build_fileop cd ${PKG_BUILD_DIR}; }; # vim:filetype=sh diff --git a/subr/post_sha256sums.subr b/subr/post_sha256sums.subr index befd2d1..b3a11b1 100644 --- a/subr/post_sha256sums.subr +++ b/subr/post_sha256sums.subr @@ -8,7 +8,7 @@ post_sha256sums() { if [ -e "${PREFIX}/SHA256SUMS" ]; then build_fileop mv "${PREFIX}/SHA256SUMS" "${PREFIX}/SHA256SUMS.last"; fi; - for __ in $(find "${PREFIX_NATIVE}" -type f -perm +011 -name bin/\* lib/\*); do + for __ in $(find "${PREFIX_NATIVE}" -type f -perm +011 -name bin/\* -name lib/\*); do sha256sum "${__}"; done > "${PREFIX}/SHA256SUMS"; }; diff --git a/vars/build.vars b/vars/build.vars index 45c36c6..908105c 100644 --- a/vars/build.vars +++ b/vars/build.vars @@ -40,7 +40,7 @@ fi; : ${BUILD_LOG_FNAME:=${PREFIX}/build.log}; : ${BUILD_LOG_LAST_FNAME:=${PREFIX}/build.log.last}; : ${BUILD_STATUS_IN_PROGRESS_FNAME:=${PREFIX}/BUILD_IN_PROGRESS}; -: ${BUILD_STEPS:="000000:always all:abstract disabled:always fetch:main extract:main build_dir:always patch_pre:main autoconf:main patch:main setup_env:always distclean:optional configure:main clean:optional build:main install:main finish:always"}; +: ${BUILD_STEPS:="setup_env:always all:abstract disabled:always fetch:main extract:main patch_pre:main distclean:optional build_dir:always autoconf:main patch:main configure:main clean:optional build:main install:main finish:always"}; : ${CHECK_PREREQ_CMDS:="aclocal autoconf autopoint awk basename bunzip2 find flex gcc git groff gunzip install ld libtool lzma make makeinfo msgfmt nl nroff openssl paste patch python sed sha256sum sort tar tee tic tr uname wget xz"}; : ${CHECK_PREREQ_FILES:="/usr/include/gmpxx.h /usr/include/mpc.h /usr/include/mpfr.h"}; : ${CHECK_PREREQ_FILES_DYNAMIC:='/usr/share/groff/$(groff -v 2>/dev/null | awk '\''/^GNU groff version /{print $NF}'\'')/tmac/e.tmac'}; @@ -115,7 +115,7 @@ HOST_TOOLCHAIN_PREFIX="${PREFIX_CROSS}"; : ${PKG_GCC_STAGE1_CROSS_X86_64_W64_MINGW32_TARGET:=x86_64-w64-mingw32}; : ${PKG_GCC_STAGE1_VERSION:=4.6.4}; : ${PKG_PSXSTUB_URLS_GIT:="psxstub=${GITROOT}/psxstub"}; -: ${PKG_PSXSTUB_BUILD_STEPS:="000000:always fetch:main install:main"}; +: ${PKG_PSXSTUB_BUILD_STEPS:="setup_env:always fetch:main install:main"}; : ${PKG_PSXSTUB_SUBDIR:=psxstub}; : ${PKG_MUSL_NO_COMPLEX_VERSION:=1.1.12}; : ${PKG_GCC_RUNTIME_VERSION:=4.6.4};