disable tool build, needs c++, not used right now
[openadk.git] / scripts / scan-tools.sh
blob2ad569de03f5f7568a027cc61d9969aa4a87a9cb
1 # This file is part of the OpenADK project. OpenADK is copyrighted
2 # material, please see the LICENCE file in the top-level directory.
4 shopt -s extglob
5 topdir=$(pwd)
6 opath=$PATH
7 out=0
8 if [ -z $(which gmake 2>/dev/null ) ];then
9 makecmd=$(which make 2>/dev/null )
10 else
11 makecmd=$(which gmake 2>/dev/null )
14 if [[ $NO_ERROR != @(0|1) ]]; then
15 echo Please do not invoke this script directly!
16 exit 1
19 set -e
20 rm -rf $topdir/tmp
21 mkdir -p $topdir/tmp
22 cd $topdir/tmp
24 os=$(uname)
26 rm -f foo
27 echo >FOO
28 if [[ -e foo ]]; then
29 cat >&2 <<-EOF
30 ERROR: OpenADK cannot be built in a case-insensitive file system.
31 EOF
32 case $os in
33 CYG*)
34 echo "Building OpenADK on $os needs a small registry change."
35 echo 'http://cygwin.com/cygwin-ug-net/using-specialnames.html'
37 Darwin*)
38 echo "Building OpenADK on $os needs a case-sensitive disk partition."
39 echo "For Snow Leopard and above you can use diskutil to resize your existing disk."
40 echo "For older versions you might consider to use a disk image."
41 echo "Example: sudo diskutil resizeVolume disk0s2 90G 1 jhfsx adk 30G"
43 esac
44 exit 1
46 rm -f FOO
48 case $os in
49 Linux)
51 FreeBSD)
53 MirBSD)
55 CYG*)
57 NetBSD)
59 OpenBSD)
61 Darwin*)
64 # unsupported
65 echo "Building OpenADK on $os is currently unsupported."
66 echo "Sorry."
67 exit 1
69 esac
71 set +e
73 cat >Makefile <<'EOF'
74 include ${TOPDIR}/prereq.mk
75 HOSTCFLAGS+= -O2
76 all: run-test
78 test: test.c
79 ${HOSTCC} ${HOSTCFLAGS} -o $@ $^ ${LDADD}
81 run-test: test
82 ./test
83 EOF
84 cat >test.c <<-'EOF'
85 #include <stdio.h>
86 int
87 main()
89 printf("Yay! Native compiler works.\n");
90 return (0);
92 EOF
93 X=$($makecmd TOPDIR=$topdir 2>&1)
94 if [[ $X != *@(Native compiler works)* ]]; then
95 echo "$X" | sed 's/^/| /'
96 echo Cannot compile a simple test programme.
97 echo You must install a host make and C compiler,
98 echo usually GCC, to proceed.
99 echo
100 out=1
102 rm test 2>/dev/null
104 if ! which tar >/dev/null 2>&1; then
105 echo You must install tar to continue.
106 echo
107 out=1
110 if ! which gzip >/dev/null 2>&1; then
111 echo You must install gzip to continue.
112 echo
113 out=1
116 if ! which lzma >/dev/null 2>&1; then
117 echo You must install lzma to continue.
118 echo
119 out=1
122 if ! which bzip2 >/dev/null 2>&1; then
123 echo You must install bzip2 to continue.
124 echo
125 out=1
128 if ! which patch >/dev/null 2>&1; then
129 echo You must install patch to continue.
130 echo
131 out=1
134 cat >test.c <<-'EOF'
135 #include <stdio.h>
136 #include <zlib.h>
138 #ifndef STDIN_FILENO
139 #define STDIN_FILENO 0
140 #endif
143 main()
145 gzFile zstdin;
146 char buf[1024];
147 int i;
149 zstdin = gzdopen(STDIN_FILENO, "rb");
150 i = gzread(zstdin, buf, sizeof (buf));
151 if ((i > 0) && (i < sizeof (buf)))
152 buf[i] = '\0';
153 buf[sizeof (buf) - 1] = '\0';
154 printf("%s\n", buf);
155 return (0);
158 X=$(echo 'Yay! Native compiler works.' | gzip | \
159 $makecmd TOPDIR=$topdir LDADD=-lz 2>&1)
160 if [[ $X != *@(Native compiler works)* ]]; then
161 echo "$X" | sed 's/^/| /'
162 echo Cannot compile a libz test programm.
163 echo You must install the zlib development package,
164 echo usually called libz-dev, and the run-time library.
165 echo
166 out=1
169 if [[ ! -s /usr/include/ncurses.h ]]; then
170 if [[ ! -s /usr/include/curses.h ]]; then
171 if [[ ! -s /usr/include/ncurses/ncurses.h ]]; then
172 echo Install ncurses header files, please.
173 echo
174 out=1
179 if ! which gawk >/dev/null 2>&1; then
180 echo You must install GNU awk to continue.
181 echo
182 out=1
185 if ! which sed >/dev/null 2>&1; then
186 echo You must install GNU sed to continue.
187 echo
188 out=1
191 if ! sed --version 2>/dev/null|grep GNU >/dev/null;then
192 if ! which gsed >/dev/null 2>&1; then
193 echo You must install GNU sed to continue.
194 echo
195 out=1
199 if ! which wget >/dev/null 2>&1; then
200 echo You must install wget to continue.
201 echo
202 out=1
205 if ! which file >/dev/null 2>&1; then
206 echo You must install \"file\" to continue.
207 echo
208 out=1
211 if ! which perl >/dev/null 2>&1; then
212 echo You must install perl to continue.
213 echo
214 out=1
217 if ! which m4 >/dev/null 2>&1; then
218 echo "You must install m4 (macro processor) to continue."
219 echo
220 out=1
223 if ! which pkg-config >/dev/null 2>&1; then
224 echo "You need pkg-config to continue."
225 echo
226 out=1
229 cd $topdir
230 rm -rf tmp
232 exit $out