scan-tools.sh 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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 'See http://www.cygwin.com/1.7/cygwin-ug-net/using-specialnames.html'
  43. ;;
  44. NetBSD)
  45. # supported with no extra quirks at the moment
  46. ;;
  47. OpenBSD)
  48. # supported with no extra quirks at the moment
  49. # although some packages' autoconf scripts may
  50. # not properly recognise OpenBSD
  51. ;;
  52. *)
  53. # unsupported
  54. echo "Building OpenADK on $os is currently unsupported."
  55. echo "Sorry."
  56. exit 1
  57. ;;
  58. esac
  59. set +e
  60. cat >Makefile <<'EOF'
  61. include ${TOPDIR}/prereq.mk
  62. HOSTCFLAGS+= -O2
  63. all: run-test
  64. test: test.c
  65. ${HOSTCC} ${HOSTCFLAGS} -o $@ $^ ${LDADD}
  66. run-test: test
  67. ./test
  68. EOF
  69. cat >test.c <<-'EOF'
  70. #include <stdio.h>
  71. int
  72. main()
  73. {
  74. printf("Yay! Native compiler works.\n");
  75. return (0);
  76. }
  77. EOF
  78. X=$($makecmd TOPDIR=$topdir 2>&1)
  79. if [[ $X != *@(Native compiler works)* ]]; then
  80. echo "$X" | sed 's/^/| /'
  81. echo Cannot compile a simple test programme.
  82. echo You must install a host make and C compiler,
  83. echo usually GCC, to proceed.
  84. echo
  85. out=1
  86. fi
  87. rm test 2>/dev/null
  88. #if ! which cpp >/dev/null 2>&1; then
  89. # echo You must install a C preprocessor to continue.
  90. # echo
  91. # out=1
  92. #fi
  93. if ! which tar >/dev/null 2>&1; then
  94. echo You must install GNU tar to continue.
  95. echo
  96. out=1
  97. fi
  98. if ! (tar --version | grep GNU) >/dev/null 2>&1;then
  99. if ! which gtar >/dev/null 2>&1; then
  100. echo You must install GNU tar to continue.
  101. echo
  102. out=1
  103. fi
  104. fi
  105. if ! which gzip >/dev/null 2>&1; then
  106. echo You must install gzip to continue.
  107. echo
  108. out=1
  109. fi
  110. if ! which lzma >/dev/null 2>&1; then
  111. echo You must install lzma to continue.
  112. echo
  113. out=1
  114. fi
  115. if ! which bzip2 >/dev/null 2>&1; then
  116. echo You must install bzip2 to continue.
  117. echo
  118. out=1
  119. fi
  120. if ! which cpio >/dev/null 2>&1; then
  121. echo You must install cpio to continue.
  122. echo
  123. out=1
  124. fi
  125. if ! which unzip >/dev/null 2>&1; then
  126. echo You must install unzip to continue.
  127. echo
  128. out=1
  129. fi
  130. if ! which patch >/dev/null 2>&1; then
  131. echo You must install patch to continue.
  132. echo
  133. out=1
  134. fi
  135. cat >test.c <<-'EOF'
  136. #include <stdio.h>
  137. #include <zlib.h>
  138. #ifndef STDIN_FILENO
  139. #define STDIN_FILENO 0
  140. #endif
  141. int
  142. main()
  143. {
  144. gzFile zstdin;
  145. char buf[1024];
  146. int i;
  147. zstdin = gzdopen(STDIN_FILENO, "rb");
  148. i = gzread(zstdin, buf, sizeof (buf));
  149. if ((i > 0) && (i < sizeof (buf)))
  150. buf[i] = '\0';
  151. buf[sizeof (buf) - 1] = '\0';
  152. printf("%s\n", buf);
  153. return (0);
  154. }
  155. EOF
  156. X=$(echo 'Yay! Native compiler works.' | gzip | \
  157. $makecmd TOPDIR=$topdir LDADD=-lz 2>&1)
  158. if [[ $X != *@(Native compiler works)* ]]; then
  159. echo "$X" | sed 's/^/| /'
  160. echo Cannot compile a libz test programm.
  161. echo You must install the zlib development package,
  162. echo usually called libz-dev, and the run-time library.
  163. echo
  164. out=1
  165. fi
  166. if [[ ! -s /usr/include/ncurses.h ]]; then
  167. if [[ ! -s /usr/include/curses.h ]]; then
  168. echo Install ncurses header files, please.
  169. echo
  170. out=1
  171. fi
  172. fi
  173. if ! which gawk >/dev/null 2>&1; then
  174. echo You must install GNU awk to continue.
  175. echo
  176. out=1
  177. fi
  178. if ! which sed >/dev/null 2>&1; then
  179. echo You must install GNU sed to continue.
  180. echo
  181. out=1
  182. fi
  183. if ! sed --version 2>/dev/null|grep GNU >/dev/null;then
  184. if ! which gsed >/dev/null 2>&1; then
  185. echo You must install GNU sed to continue.
  186. echo
  187. out=1
  188. fi
  189. fi
  190. if ! which wget >/dev/null 2>&1; then
  191. echo You must install wget to continue.
  192. echo
  193. out=1
  194. fi
  195. if ! which autoconf >/dev/null 2>&1; then
  196. echo You must install autoconf to continue.
  197. echo
  198. out=1
  199. fi
  200. if ! which automake >/dev/null 2>&1; then
  201. echo You must install automake to continue.
  202. echo
  203. out=1
  204. fi
  205. if ! which libtool >/dev/null 2>&1; then
  206. echo You must install libtool to continue.
  207. echo
  208. out=1
  209. fi
  210. if ! which file >/dev/null 2>&1; then
  211. echo You must install \"file\" to continue.
  212. echo
  213. out=1
  214. fi
  215. if ! which perl >/dev/null 2>&1; then
  216. echo You must install perl to continue.
  217. echo
  218. out=1
  219. fi
  220. cd $topdir
  221. rm -rf tmp
  222. exit $out