check & install tools autoly
# xmake getter
# usage: bash <(curl -s <my location>) [branch]
+if [ 0 -ne $(id -u) ]
+then
+ sudoprefix=sudo
+else
+ sudoprefix=
+fi
+test_tools()
+{
+ {
+ git --version &&
+ make --version &&
+ {
+ cc --version ||
+ gcc --version ||
+ clang --version
+ }
+ } >/dev/null 2>&1
+}
+install_tools()
+{
+ { apt-get --version >/dev/null 2>&1 && $sudoprefix apt-get install -y git build-essential; } ||
+ { yum --version >/dev/null 2>&1 && $sudoprefix yum install -y git 'Development Tools'; } ||
+ { zypper --version >/dev/null 2>&1 && $sudoprefix zypper install -n git && $sudoprefix zypper install -n -t pattern devel_C_C++; } ||
+ { pacman -V >/dev/null 2>&1 && $sudoprefix pacman -S --noconfirm git base-devel; }
+}
+test_tools || { install_tools && test_tools; } ||
+{
+ rv=$?
+ echo 'Dependencies Installation Fail'
+ exit $rv
+}
branch=
if [ x != x$1 ];then branch="-b $1";fi
git clone --depth=1 $branch https://github.com/tboox/xmake.git /tmp/$$xmake_getter || exit $?
@@ -26,11 +57,8 @@ done
if [ x$prefix != x ]
then
make -C /tmp/$$xmake_getter --no-print-directory install prefix="$prefix"|| exit $?
-elif [ 0 -eq $(id -u) ]
-then
- make -C /tmp/$$xmake_getter --no-print-directory install || exit $?
else
- sudo make -C /tmp/$$xmake_getter --no-print-directory install || exit $?
+ $sudoprefix make -C /tmp/$$xmake_getter --no-print-directory install || exit $?
fi
rm -rf /tmp/$$xmake_getter
xmake --version
