scan-tools.sh 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. # This file is part of the OpenADK project. OpenADK is copyrighted
  2. # material, please see the LICENCE file in the top-level directory.
  3. shopt -s extglob
  4. topdir=$(pwd)
  5. opath=$PATH
  6. out=0
  7. if [ -z $(which gmake 2>/dev/null ) ];then
  8. makecmd=$(which make 2>/dev/null )
  9. else
  10. makecmd=$(which gmake 2>/dev/null )
  11. fi
  12. if [[ $NO_ERROR != @(0|1) ]]; then
  13. echo Please do not invoke this script directly!
  14. exit 1
  15. fi
  16. set -e
  17. rm -rf $topdir/tmp
  18. mkdir -p $topdir/tmp
  19. cd $topdir/tmp
  20. rm -f foo
  21. echo >FOO
  22. if [[ -e foo ]]; then
  23. cat >&2 <<-EOF
  24. ERROR: OpenADK cannot be built in a case-insensitive file system.
  25. EOF
  26. exit 1
  27. fi
  28. rm -f FOO
  29. os=$(uname)
  30. case $os in
  31. Linux)
  32. # supported with no extra quirks at the moment
  33. ;;
  34. FreeBSD)
  35. # supported with no extra quirks at the moment
  36. ;;
  37. MirBSD)
  38. # supported with no extra quirks at the moment
  39. ;;
  40. CYG*)
  41. echo "Building OpenADK on $os needs a small registry change."
  42. echo 'http://cygwin.com/cygwin-ug-net/using-specialnames.html'
  43. echo "You can ignore this message, when you already done the change"
  44. sleep 3
  45. ;;
  46. NetBSD)
  47. # supported with no extra quirks at the moment
  48. ;;
  49. OpenBSD)
  50. # supported with no extra quirks at the moment
  51. # although some packages' autoconf scripts may
  52. # not properly recognise OpenBSD
  53. ;;
  54. Darwin*)
  55. echo "Building OpenADK on $os needs a case-sensitive disk partition."
  56. echo "For Snow Leopard and above you can use diskutil to resize your existing disk."
  57. echo "For older versions you might consider to use a disk image"
  58. echo "Example: sudo diskutil resizeVolume disk0s2 90G 1 jhfsx adk 30G"
  59. ;;
  60. *)
  61. # unsupported
  62. echo "Building OpenADK on $os is currently unsupported."
  63. echo "Sorry."
  64. exit 1
  65. ;;
  66. esac
  67. set +e
  68. cat >Makefile <<'EOF'
  69. include ${TOPDIR}/prereq.mk
  70. HOSTCFLAGS+= -O2
  71. all: run-test
  72. test: test.c
  73. ${HOSTCC} ${HOSTCFLAGS} -o $@ $^ ${LDADD}
  74. run-test: test
  75. ./test
  76. EOF
  77. cat >test.c <<-'EOF'
  78. #include <stdio.h>
  79. int
  80. main()
  81. {
  82. printf("Yay! Native compiler works.\n");
  83. return (0);
  84. }
  85. EOF
  86. X=$($makecmd TOPDIR=$topdir 2>&1)
  87. if [[ $X != *@(Native compiler works)* ]]; then
  88. echo "$X" | sed 's/^/| /'
  89. echo Cannot compile a simple test programme.
  90. echo You must install a host make and C compiler,
  91. echo usually GCC, to proceed.
  92. echo
  93. out=1
  94. fi
  95. rm test 2>/dev/null
  96. if ! which tar >/dev/null 2>&1; then
  97. echo You must install GNU tar to continue.
  98. echo
  99. out=1
  100. fi
  101. if ! (tar --version | grep GNU) >/dev/null 2>&1;then
  102. if ! which gtar >/dev/null 2>&1; then
  103. if ! which gnutar >/dev/null 2>&1; then
  104. echo You must install GNU tar to continue.
  105. echo
  106. out=1
  107. fi
  108. fi
  109. fi
  110. if ! which gzip >/dev/null 2>&1; then
  111. echo You must install gzip to continue.
  112. echo
  113. out=1
  114. fi
  115. if ! which lzma >/dev/null 2>&1; then
  116. echo You must install lzma to continue.
  117. echo
  118. out=1
  119. fi
  120. if ! which bzip2 >/dev/null 2>&1; then
  121. echo You must install bzip2 to continue.
  122. echo
  123. out=1
  124. fi
  125. if ! which patch >/dev/null 2>&1; then
  126. echo You must install patch to continue.
  127. echo
  128. out=1
  129. fi
  130. cat >test.c <<-'EOF'
  131. #include <stdio.h>
  132. #include <zlib.h>
  133. #ifndef STDIN_FILENO
  134. #define STDIN_FILENO 0
  135. #endif
  136. int
  137. main()
  138. {
  139. gzFile zstdin;
  140. char buf[1024];
  141. int i;
  142. zstdin = gzdopen(STDIN_FILENO, "rb");
  143. i = gzread(zstdin, buf, sizeof (buf));
  144. if ((i > 0) && (i < sizeof (buf)))
  145. buf[i] = '\0';
  146. buf[sizeof (buf) - 1] = '\0';
  147. printf("%s\n", buf);
  148. return (0);
  149. }
  150. EOF
  151. X=$(echo 'Yay! Native compiler works.' | gzip | \
  152. $makecmd TOPDIR=$topdir LDADD=-lz 2>&1)
  153. if [[ $X != *@(Native compiler works)* ]]; then
  154. echo "$X" | sed 's/^/| /'
  155. echo Cannot compile a libz test programm.
  156. echo You must install the zlib development package,
  157. echo usually called libz-dev, and the run-time library.
  158. echo
  159. out=1
  160. fi
  161. if [[ ! -s /usr/include/ncurses.h ]]; then
  162. if [[ ! -s /usr/include/curses.h ]]; then
  163. if [[ ! -s /usr/include/ncurses/ncurses.h ]]; then
  164. echo Install ncurses header files, please.
  165. echo
  166. out=1
  167. fi
  168. fi
  169. fi
  170. if ! which gawk >/dev/null 2>&1; then
  171. echo You must install GNU awk to continue.
  172. echo
  173. out=1
  174. fi
  175. if ! which sed >/dev/null 2>&1; then
  176. echo You must install GNU sed to continue.
  177. echo
  178. out=1
  179. fi
  180. if ! sed --version 2>/dev/null|grep GNU >/dev/null;then
  181. if ! which gsed >/dev/null 2>&1; then
  182. echo You must install GNU sed to continue.
  183. echo
  184. out=1
  185. fi
  186. fi
  187. if ! which wget >/dev/null 2>&1; then
  188. echo You must install wget to continue.
  189. echo
  190. out=1
  191. fi
  192. if ! which file >/dev/null 2>&1; then
  193. echo You must install \"file\" to continue.
  194. echo
  195. out=1
  196. fi
  197. if ! which perl >/dev/null 2>&1; then
  198. echo You must install perl to continue.
  199. echo
  200. out=1
  201. fi
  202. if ! which m4 >/dev/null 2>&1; then
  203. echo "You must install m4 (macro processor) to continue."
  204. echo
  205. out=1
  206. fi
  207. cd $topdir
  208. rm -rf tmp
  209. exit $out