#!/bin/sh source /etc/kInc.conf # Link folders # $1 - target to link # $2 - source to link function fsLink() { echo "[Link] $2 => $1" $kJunk $1 $2 >nul } # Link folders # $1 - target to unlink function fsUnLink() { echo "[UnLink] $1" $kJunk -d $1 >nul } # Return alias for current cpu get_arch() { local arch=${1:-${c_cpu}}; [[ ! $arch ]] && arch=generic echo ${arch} } # Return platform CFLAGS for ARCH/BIT get_c_flags() { # $1 == alias of arch (default "generic") # $2 == bit 32/64 (default 32) local arch=${1:-${c_cpu}}; local bits=${2:-${c_bit}} [[ ! $arch ]] && arch=generic [[ ! $bits ]] && bits=32 o1="c_common_${bits}"; o2="c_tune_${arch}_${bits}" _out="${!o1} ${!o2}" echo ${_out} } # Return prefix for cross-compile # "" -- for 32-bit; "x86_64-pc-mingw32" -- for 64-bit get_arch_cross() { # $1 == bit 32/64 (default 32) local _ret="" local bits=${1:-${c_bit}} [[ ! $bits ]] && bits=32 [[ $bits = 64 ]] && _ret="${c_arch_64}" echo "${_ret}" } # Make cross-prefixed tool name (e.g. gcc/x86_64-pc-mingw-gcc) make_cross() { # $1 == name of tool # $2 == bit 32/64 (default 32) local _tool=$1 local _ret="$(get_arch_cross $2)" [[ -n ${_ret} ]] && _ret="${_ret}-" echo "${_ret}${_tool}" } # Return install prefix ("/mingw_new") get_prefix() { echo "${kNewMingw_dst}" } # Return triplet for build ABI (i686-pc-mingw32/x86_64-pc-mingw32) get_arch_triplet() { local bits=${1:-${c_bit}} [[ -z $bits ]] && bits=32 arch_triplet="c_arch_${bits}" echo ${!arch_triplet} } # Revert patch with check patch_revert() { # $1 == working dir # $2 == patch-file # $3 == patch-flag-name local oo=`pwd` cd $1 [[ -f $3 ]] && echo "!Revert patch: $2" && patch -R -u -l -p 1 -i $2 && rm -f $3 cd ${oo} } # Apply patch with check patch_checked() { # $1 == working dir # $2 == patch-file # $3 == patch-flag-name patch_revert $1 $2 $3 local oo=`pwd` cd $1 echo "!Apply patch: $2" && patch -u -l -p 1 -i $2 && echo $2 >$3 cd ${oo} }