build.sh 874 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash
  2. mkdir -p build build/bin build/lib
  3. cd build
  4. if [ " $1" == " " ]; then
  5. compiler="gcc"
  6. elif [ $1 == "--help" -o $1 == "-help" -o $1 == "--h" -o $1 == "-h" ]; then
  7. echo "usage: $0 [compiler] [compiler path]"
  8. echo " compiler: specify the compiler you are using, default: gcc"
  9. echo " compiler path: specify the compiler path you are using"
  10. echo " eg:"
  11. echo " ./build.sh"
  12. echo " ./build.sh arm-linux-gnueabihf-gcc"
  13. echo " ./build.sh /usr/bin/arm-linux-gnueabihf-gcc"
  14. echo " ./build.sh arm-linux-gnueabihf-gcc /usr/bin"
  15. exit
  16. else
  17. if [ " $2" == " " ]; then
  18. compiler=$1
  19. else
  20. compiler=$2/$1
  21. fi
  22. fi
  23. path=$(which $compiler)
  24. if [ " $path" == " " ]; then
  25. echo -e "\033[31mNo $compiler compiler found in the system\033[0m"
  26. exit
  27. fi
  28. cmake .. "-DCMAKE_C_COMPILER=$path"
  29. make