scan-tools.sh 5.0 KB

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