diff --git a/003.psxstub.vars b/003.psxstub.vars index 4683b7a..991f72a 100644 --- a/003.psxstub.vars +++ b/003.psxstub.vars @@ -4,8 +4,8 @@ pkg_psxstub_finish() { if ! is_build_script_done install; then - if [ "x${TARGET}" = "xi686-nt32-midipix" ]\ - || [ "x${TARGET}" = "xx86_64-nt64-midipix" ]; then + if [ "${TARGET}" = i686-nt32-midipix ]\ + || [ "${TARGET}" = x86_64-nt64-midipix ]; then cd psxstub; make ${MAKEFLAGS} DESTDIR=${PREFIX_LVL} TARGET=${TARGET} install; set_build_script_done install finish; diff --git a/006.musl.full.build b/006.musl.full.build index 7ce817c..bb31c22 100644 --- a/006.musl.full.build +++ b/006.musl.full.build @@ -6,7 +6,7 @@ export lz_arch=${ARCH} lz_cflags_debug=-O2 lz_target=${TARGET}; -if [ "x${3}" = "xno-complex" ]; then +if [ "${3}" = no-complex ]; then # Musl: build (no-complex) _install=install_no_complex; set_build_dir musl-${PKG_MUSL_VERSION}-${3} cross; @@ -24,11 +24,11 @@ if [ "x${3}" = "xno-complex" ]; then cp -R mmglue/* musl-${PKG_MUSL_VERSION}/; set_build_script_done extract -configure; fi; -elif [ "x${3}" = "xnative" ]; then +elif [ "${3}" = native ]; then # Musl: build (full) _install=install; - set_build_dir musl-${PKG_MUSL_VERSION} ${3}; -elif [ "x${3}" = "xfull" ]; then + set_build_dir musl-${PKG_MUSL_VERSION} "${3}"; +elif [ "${3}" = full ]; then # Musl: build (full) _install=install; set_build_dir musl-${PKG_MUSL_VERSION} cross; diff --git a/007.gcc.full.build b/007.gcc.full.build index 3e80eb2..d3f58b4 100644 --- a/007.gcc.full.build +++ b/007.gcc.full.build @@ -4,11 +4,11 @@ # Order: stage1, runtime, full, native -if [ "x${3}" = "xruntime" ]\ -|| [ "x${3}" = "xfull" ]; then +if [ "${3}" = runtime ]\ +|| [ "${3}" = full ]; then set_build_dir cbb-gcc-${PKG_GCC_VERSION} cross; cd ${PKG_BUILD_DIR}; - if [ "x${3}" = "xruntime" ]; then + if [ "${3}" = runtime ]; then # GCC, compiler runtime. if ! is_build_script_done build; then make ${MAKEFLAGS} all-target-libgcc; @@ -18,7 +18,7 @@ if [ "x${3}" = "xruntime" ]\ make ${MAKEFLAGS} install-target-libgcc; set_build_script_done install finish; fi; - elif [ "x${3}" = "xfull" ]; then + elif [ "${3}" = full ]; then # GCC, everything else. if ! is_build_script_done build1; then make ${MAKEFLAGS} all-target-libstdc++-v3; @@ -38,7 +38,7 @@ if [ "x${3}" = "xruntime" ]\ fi; fi; else - if [ "x${3}" = "xstage1" ]; then + if [ "${3}" = stage1 ]; then # GCC, stage1. if ! is_build_script_done fetch; then rm_if_exists cbb-gcc-${PKG_GCC_VERSION}; @@ -53,7 +53,7 @@ else cbb_neutral_libiberty=no \ cbb_xgcc_for_specs=${WORKDIR}/${PKG_BUILD_DIR}/gcc/xgcc; GCCTARGET_FLAGS="-DIN_TARGET_LIBRARY_BUILD --sysroot=${PREFIX_LVL}"; - elif [ "x${3}" = "xnative" ]; then + elif [ "${3}" = native ]; then # GCC, native. set_build_dir cbb-gcc-${PKG_GCC_VERSION} native; export cbb_ldflags_for_target=--sysroot=${PREFIX_LVL} \ @@ -68,12 +68,12 @@ else set_env_vars "${CFLAGS_FOR_BUILD}" cbb_cflags_for_stage1 cbb_cflags_for_stage2 cbb_cflags_for_stage3 cbb_cflags_for_stage4; export CFLAGS CXXFLAGS CFLAGS_FOR_BUILD CPPFLAGS_FOR_BUILD CXXFLAGS_FOR_BUILD CFLAGS_FOR_TARGET XGCC_FLAGS_FOR_TARGET CPPFLAGS_FOR_TARGET CXXFLAGS_FOR_TARGET LIBCFLAGS_FOR_TARGET; if ! is_build_script_done configure; then - if [ "x${3}" = "xstage1" ]; then + if [ "${3}" = stage1 ]; then mkdir -p ${PREFIX_LVL}/include; [ \! -d ${PREFIX_LVL}/usr ] && \ ln -s . ${PREFIX_LVL}/usr; _configure_args="--prefix=${PREFIX} --with-sysroot=${PREFIX_LVL}"; - elif [ "x${3}" = "xnative" ]; then + elif [ "${3}" = native ]; then mkdir -p ${PREFIX_LVL}/${TARGET}; if [ \! -d ${PREFIX_LVL}/${TARGET}/usr ]; then ln -s . ${PREFIX_LVL}/${TARGET}/usr; @@ -121,9 +121,9 @@ else set_build_script_done clean -build; fi; if ! is_build_script_done build; then - if [ "x${3}" = "xstage1" ]; then + if [ "${3}" = stage1 ]; then make ${MAKEFLAGS} all-gcc; - elif [ "x${3}" = "xnative" ]; then + elif [ "${3}" = native ]; then make ${MAKEFLAGS} all-gcc; make ${MAKEFLAGS} all-target-libgcc; make ${MAKEFLAGS} all-target-libstdc++-v3; @@ -132,9 +132,9 @@ else set_build_script_done build -install; fi; if ! is_build_script_done install; then - if [ "x${3}" = "xstage1" ]; then + if [ "${3}" = stage1 ]; then make ${MAKEFLAGS} install-gcc; - elif [ "x${3}" = "xnative" ]; then + elif [ "${3}" = native ]; then make ${MAKEFLAGS} DESTDIR=${PREFIX_LVL} install; fi; set_build_script_done install finish; diff --git a/build.sh b/build.sh index 9d70f59..da66b49 100755 --- a/build.sh +++ b/build.sh @@ -6,9 +6,9 @@ while [ ${#} -gt 0 ]; do case ${1} in -r) [ -n "${ARG_RESTART_SCRIPT}" ] && exec cat build.usage; - [ "x${2%%:*}" != "x${2}" ] \ - && { ARG_RESTART_SCRIPT=${2%%:*}; ARG_RESTART_SCRIPT_AT=${2##*:}; } \ - || { ARG_RESTART_SCRIPT=${2}; ARG_RESTART_SCRIPT_AT=ALL; }; + match_any "${2}" : \ + && { ARG_RESTART_SCRIPT="${2%%:*}"; ARG_RESTART_SCRIPT_AT="${2##*:}"; } \ + || { ARG_RESTART_SCRIPT="${2}"; ARG_RESTART_SCRIPT_AT=ALL; }; shift; ;; -t) [ ${ARG_TARBALL:-0} -eq 1 ] && exec cat build.usage; ARG_TARBALL=1; ;; @@ -38,7 +38,7 @@ for BUILD_LVL in 0 1 2 3; do continue; else unset BUILD_SCRIPT_RC; : $((BUILD_NBUILT+=1)); - if [ "x${ARG_RESTART_SCRIPT}" != "xALL" ]\ + if [ "${ARG_RESTART_SCRIPT}" != ALL ]\ && is_build_script_done finish "${BUILD_SCRIPT_FNAME%.build}"; then log_msg info "Skipped build script \`${BUILD_SCRIPT_FNAME}' (already built.)"; : $((BUILD_NSKIP+=1)); BUILD_SCRIPT_RC=0; continue; diff --git a/build.subr b/build.subr index c044fe2..9f7f540 100644 --- a/build.subr +++ b/build.subr @@ -10,12 +10,12 @@ get_var_dyn() { ${1}; }; get_var_unsafe() { eval echo \${${1}}; }; set_var_dyn() { eval ${1}\(\) \{ echo \"${2}\"\; \}; }; set_var_unsafe() { eval ${1}=\"${2}\"; }; -get_name_without_slash() { while [ "x${1%/}" != "x${1}" ]; do set -- ${1%/}; done; echo ${1}; }; +get_name_without_slash() { while [ "${1%/}" != ${1} ]; do set -- ${1%/}; done; echo ${1}; }; get_postfix_lrg() { echo "${1##*${2}}"; }; get_prefix_lrg() { echo "${1%%${2}*}"; }; get_postfix() { echo "${1#*${2}}"; }; get_prefix() { echo "${1%${2}*}"; }; -match_any() { [ "x${1#*${2}*}" != "x${1}" ]; }; +match_any() { [ "${1#*${2}*}" != "${1}" ]; }; push_IFS() { _pI_IFS="${IFS}"; IFS="${1}"; }; pop_IFS() { IFS="${_pI_IFS}"; unset _pI_IFS; }; set_build_dir() { PKG_BUILD_DIR=${1}-${2}-${TARGET}; }; @@ -91,7 +91,7 @@ clear_env_with_except() { _cewe_vfilter="${*}"; _cewe_unset_cmds="$(mktemp -q)"; export | while read _cewe_vspec; do set -- ${_cewe_vspec}; shift; - [ "x${1#*[^\"\'=a-zA-Z0-9_]}" != "x${1}" ] && continue; + [ "${1#*[^\"\'=a-zA-Z0-9_]}" != "${1}" ] && continue; if ! match_list "${_cewe_vfilter}" " " \ $(get_prefix_lrg ${1} =); then echo unset $(get_prefix_lrg ${1} =) >> ${_cewe_unset_cmds}; @@ -117,7 +117,7 @@ compare_hash() { # This corresponds to the hash output and caller-supplied # hash values. set -- $(openssl dgst -sha256 ${1}) ${2}; shift $((${#}-2)); - [ "x${1}" = "x${2}" ] || echo "${1}"; + [ "${1}" = "${2}" ] || echo "${1}"; }; compare_hash_manifest() { while [ ${#} -gt 0 ]; do @@ -147,7 +147,7 @@ set_build_script_done() { _sbsd_script_fname=${SCRIPT_FNAME##*/}; _sbsd_done_fname=${WORKDIR}/.${_sbsd_script_fname%.build}; while [ $# -ge 1 ]; do - if [ "x${1#-}" != "x${1}" ]; then + if [ "${1#-}" != "${1}" ]; then rm -f ${_sbsd_done_fname}.${1#-}; else touch ${_sbsd_done_fname}.${1}; @@ -190,7 +190,7 @@ log_msg() { match_list() { _ml_cmp="${3}"; push_IFS "${2}"; set -- ${1}; pop_IFS; while [ ${#} -gt 0 ]; do - if [ "x${1}" = "x${_ml_cmp}" ]; then + if [ "${1}" = "${_ml_cmp}" ]; then unset _ml_cmp; return 0; fi; shift; done; unset _ml_cmp; return 1; @@ -199,7 +199,7 @@ match_list() { parse_with_pkg_name() { PKG_LVL=${1}; PKG_NAME=${2}; shift 2; while [ ${#} -ge 0 ]; do - if [ "x${PKG_NAME}" = "x${1}" ]; then + if [ "${PKG_NAME}" = ${1} ]; then export_vars_subst PKG_LVL${PKG_LVL}_ PKG_ ${PKG_BUILD_VARS}; export_vars_subst PKG_$(echo ${PKG_NAME} | tr a-z A-Z)_ PKG_ ${PKG_BUILD_VARS}; [ -z "${PKG_URL}" ] && return 1; diff --git a/pkg.build b/pkg.build index 97e1a3f..98cb1ae 100644 --- a/pkg.build +++ b/pkg.build @@ -4,7 +4,7 @@ parse_with_pkg_name ${SCRIPT_FNAME%[0-9][0-9]*} ${2} ${PKG_BUILD_NAMES}; if ! is_build_script_done fetch; then - if [ "x${PKG_URL_TYPE:-wget}" = "xwget" ]; then + if [ "${PKG_URL_TYPE:-wget}" = wget ]; then rm_if_exists $(get_basename ${PKG_URL}); fetch ${PKG_URL} ${PKG_SHA256SUM}; else @@ -15,7 +15,7 @@ if ! is_build_script_done fetch; then fi; if test_cmd pkg_${PKG_NAME}_finish; then pkg_${PKG_NAME}_finish; exit 0; -elif [ "x${PKG_URL_TYPE:-wget}" = "xwget" ] &&\ +elif [ "${PKG_URL_TYPE:-wget}" = wget ] &&\ ! is_build_script_done extract; then rm_if_exists ${PKG_SUBDIR}; tar -axf ${PKG_FNAME};