Create ak-kill-9pserver.sh that kills ufs server
[akaros.git] / scripts / ak-scripts / ak-rebuild-cross-compiler.sh
1 #!/usr/bin/env bash
2 #
3 # Copyright (c) 2015 Google Inc.
4 # Kevin Klues <klueska@cs.berkeley.edu>
5 # See LICENSE for details.
6
7 inst_dir_default="\"\${ARCH}_INSTDIR based on the configured architecture in akaros_root\""
8
9 function short_description() {
10         echo "Rebuild the Akaros cross compiler and all of its dependencies"
11 }
12
13 function usage() {
14         echo "Usage:"
15         echo "    ${cmd} -h | --help"
16         echo "    ${cmd} [ --akaros-root=<ak> ]"
17         echo "    ${cmd//?/ } [ --inst-dir=<dir> ]"
18         echo ""
19         echo "Options:"
20         echo "    -h --help                Display this screen and exit"
21         echo "    --akaros-root=<ak>       The path to the root of the akaros tree"
22         echo "                             [default: \$AKAROS_ROOT]"
23         echo "    --inst-dir=<dir>         The installation path of the cross compiler"
24         echo "                             [default: ${inst_dir_default} ]"
25 }
26
27 function main() {
28         # Check the sanity of our incoming variables
29         check_vars akaros_root inst_dir
30         check_dirs akaros_root
31
32         # Set some local variables
33         local arch="$(basename $(readlink ${akaros_root}/kern/include/arch))"
34         if [ "${arch}" = "x86" ]; then
35                 arch="x86_64"
36         fi
37         local make_jobs=$(expr `cat /proc/cpuinfo | grep processor | wc -l` - 1)
38
39         # Set real default of $inst_dir
40         if [ "${inst_dir}" != "${inst_dir_default}" ]; then
41                 inst_dir="$(eval echo \$${arch^^}_INSTDIR)"
42         fi
43
44         # Rebuild the cross compiler
45         cd "${akaros_root}"
46         eval ${arch^^}_INSTDIR=${inst_dir} \
47                 make -j ${make_jobs} xcc-upgrade-from-scratch
48         cd - > /dev/null
49 }