Alternative library and kernel for add-in development on fx-9860G and fx-CG50 under Linux.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

configure 4.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. #! /bin/bash
  2. #
  3. # Basic configuration
  4. #
  5. # Target platform
  6. target=
  7. toolchain=
  8. # Build options
  9. prefix=
  10. cflags=
  11. # Behavior
  12. boot_log=
  13. no_syscalls=
  14. static_gray=
  15. # Size limits
  16. atexit_max=
  17. # Output files
  18. output="Makefile.cfg"
  19. #
  20. # Help screen
  21. #
  22. help()
  23. {
  24. cat << EOF
  25. Configuration script for the gint library.
  26. Usage: $0 [options...]
  27. You should build out-of-tree by creating a build directory and configuring from
  28. there.
  29. Target selection:
  30. --target=fx9860g|fxcg50
  31. fx9860g covers all fx-9860G II-like monochromes models that support add-ins
  32. or can be flashed with an OS that does. This includes SH3 and SH4 machines.
  33. Default toolchain is 'sh3eb-elf'.
  34. fxcg50 covers just the fx-CG 50; there is some unofficial compatibility with
  35. fx-CG 10/20. All of these are SH4-only.
  36. Default toolchain is 'sh4eb-elf'.
  37. Build options:
  38. --toolchain=TRIPLET Build with a different toolchain
  39. --prefix=PREFIX Install prefix (PREFIX/lib and PREFIX/include are used)
  40. --cflags=FLAGS Additional compiler flags at end of command
  41. Library options (disabled by default):
  42. --boot-log Display a boot debug log at startup if a key is pressed
  43. Used to investigate unstabilities.
  44. --no-syscalls Cut off all syscalls (this will break things)
  45. Only use this option if you have a good idea of which.
  46. --static-gray Allocate gray VRAMs in static RAM instead of the heap
  47. May help when --no-syscalls is on.
  48. Size limits:
  49. --atexit-max=NUM Number of exit handlers in atexit()'s array [16]
  50. Deprecated options (to be removed):
  51. -events-queue-size=<n>
  52. Size of event queue (this mechanism is likely to
  53. disappear in future versions) [64]
  54. EOF
  55. exit 0
  56. }
  57. if [[ "$@" == "--help" ]]; then
  58. help
  59. exit 1
  60. fi
  61. if [[ -f make/Makefile ]]; then
  62. echo "error: you should configure from a build directory, like this:" >&2
  63. echo " mkdir build && cd build && ../configure [options..]" >&2
  64. exit 1
  65. fi
  66. #
  67. # Parsing arguments
  68. #
  69. fail=false
  70. for arg; do case "$arg" in
  71. -h | -? | --help)
  72. help;;
  73. --target=*)
  74. case ${arg#*=} in
  75. "fx9860g")
  76. target=fx9860g
  77. toolchain=${toolchain:-sh3eb-elf};;
  78. "fxcg50")
  79. target=fxcg50
  80. toolchain=${toolchain:-sh4eb-elf};;
  81. *)
  82. echo "error: invalid target '$target'"
  83. fail=true
  84. esac;;
  85. --toolchain=*)
  86. toolchain=${arg#*=};;
  87. --prefix=*)
  88. prefix=${arg#*=};;
  89. --cflags=*)
  90. cflags=${arg#*=};;
  91. --boot-log)
  92. boot_log=true;;
  93. --no-syscalls)
  94. no_syscalls=true;;
  95. --static-gray)
  96. static_gray=true;;
  97. --atexit-max=*)
  98. n=${arg#*=}
  99. if [[ $n =~ ([0-9])+ ]]; then
  100. atexit_max=$n
  101. else
  102. echo -e "error: -atexit-max expects an integer value"
  103. fail=true
  104. fi;;
  105. --atexit-max)
  106. echo "error: '$arg' expects a value (see '$0 --help')";
  107. fail=true;;
  108. -events-queue-size=*)
  109. echo "warning: support for '-events-queue-size' has been removed";;
  110. *)
  111. echo "error: unrecognized argument '$arg'";
  112. fail=true;;
  113. esac; done
  114. #
  115. # Checking mandatory arguments
  116. #
  117. if [[ -z "$target" ]]; then
  118. echo "error: no target specified! (see '$0 --help')"
  119. fail=true;
  120. fi
  121. if $fail; then
  122. echo "note: output file $output has not been changed."
  123. exit 1
  124. fi
  125. # If no prefix is specified, install to the GCC's build folder
  126. if [[ -z "$prefix" ]]; then
  127. echo "No prefix specified, let's ask the compiler:"
  128. echo " $toolchain-gcc --print-search-dirs | grep install | sed 's/install: //'"
  129. inst=$($toolchain-gcc --print-search-dirs | grep install | sed 's/install: //')
  130. if [[ $? != 0 ]]; then
  131. echo "Call returned $?, giving up."
  132. fi
  133. echo "Got '$inst'".
  134. if [[ ! -d $inst ]]; then
  135. echo "Directory does not exist (or is not a directory), giving up."
  136. exit 1
  137. fi
  138. echo ""
  139. prefix=$inst
  140. fi
  141. #
  142. # Output config
  143. #
  144. output_config()
  145. {
  146. mod=${target/98/fx}
  147. echo "CONFIG.TARGET = ${mod:2:2}"
  148. echo "CONFIG.TARGET.LONG = $target"
  149. [[ $prefix ]] && echo "PREFIX = $prefix"
  150. [[ $toolchain ]] && echo "CONFIG.TOOLCHAIN = $toolchain"
  151. [[ $cflags ]] && echo "CONFIG.CFLAGS = $cflags"
  152. echo -n "CONFIG.MACROS ="
  153. echo -n " -D$(echo $target | tr 'a-z' 'A-Z')"
  154. [[ "$boot_log" ]] && echo -n " -DGINT_BOOT_LOG"
  155. [[ "$no_syscalls" ]] && echo -n " -DGINT_NO_SYSCALLS"
  156. [[ "$static_gray" ]] && echo -n " -DGINT_STATIC_GRAY"
  157. [[ "$atexit_max" ]] && echo -n " -DATEXIT_MAX=$atexit_max"
  158. echo ""
  159. }
  160. output_config > $output
  161. src="Makefile"
  162. dst="../make/Makefile"
  163. [[ -L $src && $(readlink $src) == $dst ]] && rm $src
  164. ln -s $dst $src
  165. echo "Configuration saved in $output, ready to make!"