added new target for ALix2D13
[openadk.git] / scripts / scan-tools.sh
blob743f316b00b38c4c3e17c088b37c72b2393676b8
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 rm -f foo
25 echo >FOO
26 if [[ -e foo ]]; then
27 cat >&2 <<-EOF
28 ERROR: OpenADK cannot be built in a case-insensitive file system.
29 EOF
30 exit 1
32 rm -f FOO
34 os=$(uname)
35 case $os in
36 Linux)
37 # supported with no extra quirks at the moment
39 FreeBSD)
40 # supported with no extra quirks at the moment
42 MirBSD)
43 # supported with no extra quirks at the moment
45 CYG*)
46 echo "Building OpenADK on $os needs a small registry change."
47 echo 'See http://www.cygwin.com/1.7/cygwin-ug-net/using-specialnames.html'
49 NetBSD)
50 echo "Building OpenADK on $os is currently unsupported."
51 echo "Sorry."
52 echo
53 echo There are unresolved issues relating to ncurses not
54 echo being included in NetBSD®, and these provided by pkgsrc®
55 echo lack important header files.
57 OpenBSD)
58 # supported with no extra quirks at the moment
59 # although some packages' autoconf scripts may
60 # not properly recognise OpenBSD
63 # unsupported
64 echo "Building OpenADK on $os is currently unsupported."
65 echo "Sorry."
66 exit 1
68 esac
70 set +e
72 cat >Makefile <<'EOF'
73 include ${TOPDIR}/prereq.mk
74 HOSTCFLAGS+= -O2
75 all: run-test
77 test: test.c
78 ${HOSTCC} ${HOSTCFLAGS} -o $@ $^ ${LDADD}
80 run-test: test
81 ./test
82 EOF
83 cat >test.c <<-'EOF'
84 #include <stdio.h>
85 int
86 main()
88 printf("Yay! Native compiler works.\n");
89 return (0);
91 EOF
92 X=$($makecmd TOPDIR=$topdir 2>&1)
93 if [[ $X != *@(Native compiler works)* ]]; then
94 echo "$X" | sed 's/^/| /'
95 echo Cannot compile a simple test programme.
96 echo You must install a host make and C compiler,
97 echo usually GCC, to proceed.
98 echo
99 out=1
101 rm test 2>/dev/null
103 #if ! which cpp >/dev/null 2>&1; then
104 # echo You must install a C preprocessor to continue.
105 # echo
106 # out=1
109 if ! which tar >/dev/null 2>&1; then
110 echo You must install GNU tar to continue.
111 echo
112 out=1
115 if ! (tar --version | grep GNU) >/dev/null 2>&1;then
116 if ! which gtar >/dev/null 2>&1; then
117 echo You must install GNU tar to continue.
118 echo
119 out=1
123 if ! which gzip >/dev/null 2>&1; then
124 echo You must install gzip to continue.
125 echo
126 out=1
129 if ! which lzma >/dev/null 2>&1; then
130 echo You must install lzma to continue.
131 echo
132 out=1
135 if ! which bzip2 >/dev/null 2>&1; then
136 echo You must install bzip2 to continue.
137 echo
138 out=1
141 if ! which cpio >/dev/null 2>&1; then
142 echo You must install cpio to continue.
143 echo
144 out=1
147 if ! which unzip >/dev/null 2>&1; then
148 echo You must install unzip to continue.
149 echo
150 out=1
153 if ! which patch >/dev/null 2>&1; then
154 echo You must install patch to continue.
155 echo
156 out=1
159 cat >test.c <<-'EOF'
160 #include <stdio.h>
161 #include <zlib.h>
163 #ifndef STDIN_FILENO
164 #define STDIN_FILENO 0
165 #endif
168 main()
170 gzFile zstdin;
171 char buf[1024];
172 int i;
174 zstdin = gzdopen(STDIN_FILENO, "rb");
175 i = gzread(zstdin, buf, sizeof (buf));
176 if ((i > 0) && (i < sizeof (buf)))
177 buf[i] = '\0';
178 buf[sizeof (buf) - 1] = '\0';
179 printf("%s\n", buf);
180 return (0);
183 X=$(echo 'Yay! Native compiler works.' | gzip | \
184 $makecmd TOPDIR=$topdir LDADD=-lz 2>&1)
185 if [[ $X != *@(Native compiler works)* ]]; then
186 echo "$X" | sed 's/^/| /'
187 echo Cannot compile a libz test programm.
188 echo You must install the zlib development package,
189 echo usually called libz-dev, and the run-time library.
190 echo
191 out=1
194 [[ -s /usr/include/ncurses.h ]] || if [[ -s /usr/pkg/include/ncurses.h ]]; then
195 echo 'HOSTCFLAGS+= -isystem /usr/pkg/include' >>$topdir/prereq.mk
196 echo 'HOSTLDFLAGS+=-L/usr/pkg/lib -Wl,-rpath -Wl,/usr/pkg/lib' >>$topdir/prereq.mk
197 else
198 echo Install ncurses header files, please.
199 echo
200 out=1
203 if ! which gawk >/dev/null 2>&1; then
204 echo You must install GNU awk to continue.
205 echo
206 out=1
209 if ! which sed >/dev/null 2>&1; then
210 echo You must install GNU sed to continue.
211 echo
212 out=1
215 if ! sed --version 2>/dev/null|grep GNU >/dev/null;then
216 if ! which gsed >/dev/null 2>&1; then
217 echo You must install GNU sed to continue.
218 echo
219 out=1
223 if ! which wget >/dev/null 2>&1; then
224 echo You must install wget to continue.
225 echo
226 out=1
229 if ! which autoconf >/dev/null 2>&1; then
230 echo You must install autoconf to continue.
231 echo
232 out=1
235 if ! which automake >/dev/null 2>&1; then
236 echo You must install automake to continue.
237 echo
238 out=1
241 if ! which libtool >/dev/null 2>&1; then
242 echo You must install libtool to continue.
243 echo
244 out=1
247 if ! which file >/dev/null 2>&1; then
248 echo You must install \"file\" to continue.
249 echo
250 out=1
253 if ! which perl >/dev/null 2>&1; then
254 echo You must install perl to continue.
255 echo
256 out=1
259 cd $topdir
260 rm -rf tmp
262 exit $out