From ad7b38a4fa9bb990e899c892bb953a91d2ac13f8 Mon Sep 17 00:00:00 2001 From: LAN-TW Date: Sat, 30 Nov 2013 21:46:12 +0800 Subject: =?UTF-8?q?bash=5Finclude:=20compile=5Fall=20=E5=8A=A0=E5=85=A5=20?= =?UTF-8?q?CXXFLAGS=20=E5=92=8C=E8=87=AA=E5=8B=95=E5=81=B5=E6=B8=AC?= =?UTF-8?q?=E5=9F=B7=E8=A1=8C=E6=AA=94=E5=89=AF=E6=AA=94=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bash_include | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'bash_include') diff --git a/bash_include b/bash_include index 4ff99d6..60164b3 100644 --- a/bash_include +++ b/bash_include @@ -144,14 +144,18 @@ function compile_all () local noask=0 local mycc="${CC}" local mycxx="${CXX}" + local myexe="`get_executable_extension`" local newCFLAGS + local newCXXFLAGS local newLDFLAGS [ "$1" = '' ] && echo "Which file(s) do you want to compile? " && return 1 [ "$1" = "-n" ] && noask=1 if [ "$noask" = "0" ]; then read -e -p "CFLAGS: " -i "$CFLAGS" newCFLAGS + read -e -p "CXXFLAGS: " -i "$CXXFLAGS" newCXXFLAGS read -e -p "LDFLAGS: " -i "$LDFLAGS" newLDFLAGS [ "$newCFLAGS" '!=' '' ] && CFLAGS=$newCFLAGS + [ "$newCXXFLAGS" '!=' '' ] && CXXFLAGS=$newCXXFLAGS [ "$newLDFLAGS" '!=' '' ] && LDFLAGS=$newLDFLAGS else shift @@ -160,8 +164,8 @@ function compile_all () [ -z "${mycxx}" ] && mycxx=c++ while [ "$1" '!=' '' ] do - local targetfile="`echo "$1" | cut -d . -f 1`" - local suffix="`echo "$1" | cut -d . -f 2`" + local targetfile="`echo "$1" | sed 's|\(.*\)\..*|\1|'`$myexe" + local suffix="`echo "$1" | sed 's|.*\.\(.*\)|\1|'`" if [ -f "$1" ]; then true else @@ -177,7 +181,7 @@ function compile_all () ;; cpp|cxx|cc|C) echo "[${mycxx}] $1 -> $targetfile" - ${mycxx} $CFLAGS "$1" $LDFLAGS -o "$targetfile" + ${mycxx} $CXXFLAGS "$1" $LDFLAGS -o "$targetfile" ;; *) printf "$1: Unknown suffix (\e[1;33mskipped\e[0m)\n" @@ -1410,10 +1414,17 @@ function gen_ms_inet_shortcut () { function check_command_existent () { - which "$1" &> /dev/null + type "$1" &> /dev/null return $? } +function get_executable_extension () +{ + local lsloc="`command which ls`" + local lsalt="`echo ${lsloc}.* | cut -d ' ' -f 1`" + cmp "$lsloc" "$lsalt" &> /dev/null && echo ${lsalt:${#lsloc}} && return +} + function rpmdu () { local div_base=1 local div_name="KB" @@ -1659,6 +1670,7 @@ function help_function () x check_command_existent program x is_file_type filename type [-- sudo_prefix ...] x get_file_size filename [-- sudo_prefix ...] + x get_executable_extension x get_terminal_size x split_arguments [arguments ...] -- cgit v1.2.3