mkconfig 587 B

12345678910111213141516171819202122232425262728293031
  1. #!/bin/bash
  2. TARGET_LIST=("nspire" "sfml")
  3. create_configuration() {
  4. echo "Creating $1 configuration"
  5. rm config.mk -f
  6. echo "include platform/$1/rules.mk" >> config.mk
  7. }
  8. is_valid_target() {
  9. for item in "${TARGET_LIST[@]}"; do
  10. [[ $1 == "$item" ]] && return 0
  11. done
  12. return 1
  13. }
  14. old_PS3=PS3
  15. PS3='#? '
  16. # If $1 isn't set
  17. if [[ -z ${1+z} ]]; then
  18. echo "Platform:"
  19. select TARGET in "${TARGET_LIST[@]}"; do
  20. create_configuration "$TARGET"
  21. [[ $TARGET == "" ]] || break
  22. done
  23. # else use it as a platform selection
  24. else
  25. is_valid_target "$1" && create_configuration "$1"
  26. fi
  27. PS3=old_PS3