uclibc: enable bessel functions
[openadk.git] / scripts / scan-tools.sh
blob8557179df3dd1ef2de1564f4869f9e06a5e652ce
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 clang=0
10 if [[ $NO_ERROR != @(0|1) ]]; then
11 echo Please do not invoke this script directly!
12 exit 1
15 set -e
16 rm -rf $topdir/tmp
17 mkdir -p $topdir/tmp
18 cd $topdir/tmp
20 os=$(uname)
22 rm -f foo
23 echo >FOO
24 if [[ -e foo ]]; then
25 cat >&2 <<-EOF
26 ERROR: OpenADK cannot be built in a case-insensitive file system.
27 EOF
28 case $os in
29 CYG*)
30 echo "Building OpenADK on $os needs a small registry change."
31 echo 'http://cygwin.com/cygwin-ug-net/using-specialnames.html'
33 Darwin*)
34 echo "Building OpenADK on $os needs a case-sensitive disk partition."
35 echo "For Snow Leopard and above you can use diskutil to resize your existing disk."
36 echo "Example: sudo diskutil resizeVolume disk0s2 90G 1 jhfsx adk 30G"
37 echo "For older versions you might consider to use a disk image:"
38 echo "hdiutil create -type SPARSE -fs 'Case-sensitive Journaled HFS+' -size 30g ~/openadk.dmg"
40 esac
41 exit 1
43 rm -f FOO
45 case $os in
46 Linux)
48 FreeBSD)
49 if ! which gmake >/dev/null 2>&1; then
50 echo You must install GNU make to continue.
51 echo
52 out=1
54 clang=1
56 MirBSD)
58 CYG*)
60 NetBSD)
62 OpenBSD)
63 if ! which gmake >/dev/null 2>&1; then
64 echo You must install GNU make to continue.
65 echo
66 out=1
69 Darwin*)
70 clang=1
73 # unsupported
74 echo "Building OpenADK on $os is currently unsupported."
75 echo "Sorry."
76 exit 1
78 esac
80 set +e
82 if [ -z $(which gmake 2>/dev/null ) ];then
83 makecmd=$(which make 2>/dev/null )
84 else
85 makecmd=$(which gmake 2>/dev/null )
88 cat >Makefile <<'EOF'
89 include ${ADK_TOPDIR}/prereq.mk
90 all: run-test
92 test: test.c
93 ${HOST_CC} ${HOST_CFLAGS} -o $@ $^ ${LDADD}
95 run-test: test
96 ./test
97 EOF
98 cat >test.c <<-'EOF'
99 #include <stdio.h>
101 main()
103 printf("Yay! Native compiler works.\n");
104 return (0);
107 if [[ $clang -eq 0 ]]; then
108 X=$($makecmd ADK_TOPDIR=$topdir LDADD=-lgcc 2>&1)
109 if [[ $X != *@(Native compiler works)* ]]; then
110 echo Cannot compile with shared libgcc use static one.
111 HOST_CFLAGS=-static-libgcc
112 echo "HOST_CFLAGS:=-O0 -g0 -static-libgcc" >> $topdir/prereq.mk
113 echo "HOST_CXXFLAGS:=-O0 -g0 -static-libgcc" >> $topdir/prereq.mk
114 else
115 echo "HOST_CFLAGS:=-O0 -g0" >> $topdir/prereq.mk
116 echo "HOST_CXXFLAGS:=-O0 -g0" >> $topdir/prereq.mk
118 else
119 echo "HOST_CFLAGS:=-O0 -g0" >> $topdir/prereq.mk
120 echo "HOST_CXXFLAGS:=-O0 -g0" >> $topdir/prereq.mk
123 X=$($makecmd ADK_TOPDIR=$topdir HOST_CFLAGS=${HOST_CFLAGS} 2>&1)
124 if [[ $X != *@(Native compiler works)* ]]; then
125 echo "$X" | sed 's/^/| /'
126 echo Cannot compile a simple test programme.
127 echo You must install a host make and C compiler,
128 echo usually GCC, to proceed.
129 echo
130 out=1
132 rm test 2>/dev/null
134 if ! which shasum >/dev/null 2>&1; then
135 if ! which sha256sum >/dev/null 2>&1; then
136 if ! which cksum >/dev/null 2>&1; then
137 echo You must install shasum or sha256sum or cksum to continue.
138 echo
139 out=1
144 if ! which gzip >/dev/null 2>&1; then
145 echo You must install gzip to continue.
146 echo
147 out=1
150 cat >test.c <<-'EOF'
151 #include <stdio.h>
152 #include <zlib.h>
154 #ifndef STDIN_FILENO
155 #define STDIN_FILENO 0
156 #endif
159 main()
161 gzFile zstdin;
162 char buf[1024];
163 int i;
165 zstdin = gzdopen(STDIN_FILENO, "rb");
166 i = gzread(zstdin, buf, sizeof (buf));
167 if ((i > 0) && (i < sizeof (buf)))
168 buf[i] = '\0';
169 buf[sizeof (buf) - 1] = '\0';
170 printf("%s\n", buf);
171 return (0);
174 X=$(echo 'Yay! Native compiler works.' | gzip | \
175 $makecmd ADK_TOPDIR=$topdir LDADD=-lz HOST_CFLAGS=${HOST_CFLAGS} 2>&1)
176 if [[ $X != *@(Native compiler works)* ]]; then
177 echo "$X" | sed 's/^/| /'
178 echo Cannot compile a libz test programm.
179 echo You must install the zlib development package,
180 echo usually called libz-dev, and the run-time library.
181 echo
182 out=1
185 if [[ ! -s /usr/include/ncursesw/curses.h && \
186 ! -s /usr/include/ncurses.h && \
187 ! -s /usr/include/curses.h && \
188 ! -s /usr/include/ncurses/ncurses.h && \
189 ! -s /usr/local/opt/ncurses/include/ncursesw/ncurses.h ]]; then
190 echo Install ncurses header files, please.
191 echo
192 out=1
195 if ! which wget >/dev/null 2>&1; then
196 echo You must install wget to continue.
197 echo
198 out=1
201 if ! which perl >/dev/null 2>&1; then
202 echo You must install perl to continue.
203 echo
204 out=1
207 if ! which g++ >/dev/null 2>&1; then
208 if ! which clang++ >/dev/null 2>&1; then
209 echo "You need a C++ compiler to continue."
210 echo
211 out=1
215 # always required, but can be provided by host
216 host_build_bc=0
217 if which bc >/dev/null 2>&1; then
218 if ! echo quit|bc -q 2>/dev/null >/dev/null; then
219 host_build_bc=1
220 else
221 if bc -v 2>&1| grep -q BSD >/dev/null 2>&1; then
222 host_build_bc=1
225 else
226 host_build_bc=1
229 host_build_bison=0
230 if ! which bison >/dev/null 2>&1; then
231 host_build_bison=1
234 host_build_bzip2=0
235 if ! which bzip2 >/dev/null 2>&1; then
236 host_build_bzip2=1
239 host_build_file=0
240 if ! which file >/dev/null 2>&1; then
241 host_build_file=1
244 host_build_flex=0
245 if ! which flex >/dev/null 2>&1; then
246 host_build_flex=1
249 host_build_m4=0
250 if ! which m4 >/dev/null 2>&1; then
251 host_build_m4=1
254 host_build_mksh=0
255 if ! which mksh >/dev/null 2>&1; then
256 host_build_mksh=1
259 host_build_patch=0
260 if ! which patch >/dev/null 2>&1; then
261 host_build_patch=1
264 host_build_pkgconf=0
265 if ! which pkgconf >/dev/null 2>&1; then
266 host_build_pkgconf=1
269 host_build_tar=0
270 if which tar >/dev/null 2>&1; then
271 if ! tar --version 2>/dev/null|grep GNU >/dev/null;then
272 host_build_tar=1
274 else
275 host_build_tar=1
278 host_build_findutils=0
279 if ! which gxargs >/dev/null 2>&1; then
280 if which xargs >/dev/null 2>&1; then
281 if ! xargs --version 2>/dev/null|grep GNU >/dev/null;then
282 host_build_findutils=1
287 if which find >/dev/null 2>&1; then
288 if ! find --version 2>/dev/null|grep GNU >/dev/null;then
289 host_build_findutils=1
293 host_build_grep=0
294 if which grep >/dev/null 2>&1; then
295 if ! grep --version 2>/dev/null|grep GNU >/dev/null;then
296 host_build_grep=1
300 host_build_gawk=0
301 if ! which gawk >/dev/null 2>&1; then
302 host_build_gawk=1
305 host_build_sed=0
306 if which sed >/dev/null 2>&1; then
307 if ! sed --version 2>/dev/null|grep GNU >/dev/null;then
308 host_build_sed=1
312 host_build_xz=0
313 if ! which xz >/dev/null 2>&1; then
314 host_build_xz=1
317 # optional
318 host_build_cdrtools=0
319 if ! which mkisofs >/dev/null 2>&1; then
320 host_build_cdrtools=1
323 host_build_ccache=0
324 if ! which ccache >/dev/null 2>&1; then
325 host_build_ccache=1
328 host_build_genext2fs=0
329 if ! which genext2fs >/dev/null 2>&1; then
330 host_build_genext2fs=1
333 host_build_lzma=0
334 if ! which lzma >/dev/null 2>&1; then
335 host_build_lzma=1
338 host_build_lz4=0
339 if ! which lz4c >/dev/null 2>&1; then
340 host_build_lz4=1
343 host_build_lzop=0
344 if ! which lzop >/dev/null 2>&1; then
345 host_build_lzop=1
348 host_build_qemu=0
349 if ! which qemu-img >/dev/null 2>&1; then
350 host_build_qemu=1
353 echo "config ADK_HOST_BUILD_TOOLS" > $topdir/target/config/Config.in.prereq
354 printf "\t%s\n" "bool" >> $topdir/target/config/Config.in.prereq
355 printf "\t%s\n" "default y" >> $topdir/target/config/Config.in.prereq
356 # always required
357 if [ $host_build_bc -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_BC" >> $topdir/target/config/Config.in.prereq ;fi
358 if [ $host_build_bison -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_BISON" >> $topdir/target/config/Config.in.prereq ;fi
359 if [ $host_build_bzip2 -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_BZIP2" >> $topdir/target/config/Config.in.prereq ;fi
360 if [ $host_build_file -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_FILE" >> $topdir/target/config/Config.in.prereq ;fi
361 if [ $host_build_flex -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_FLEX" >> $topdir/target/config/Config.in.prereq ;fi
362 if [ $host_build_gawk -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_GAWK" >> $topdir/target/config/Config.in.prereq ;fi
363 if [ $host_build_grep -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_GREP" >> $topdir/target/config/Config.in.prereq ;fi
364 if [ $host_build_m4 -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_M4" >> $topdir/target/config/Config.in.prereq ;fi
365 if [ $host_build_mksh -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_MKSH" >> $topdir/target/config/Config.in.prereq ;fi
366 if [ $host_build_patch -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_PATCH" >> $topdir/target/config/Config.in.prereq ;fi
367 if [ $host_build_pkgconf -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_PKGCONF" >> $topdir/target/config/Config.in.prereq ;fi
368 if [ $host_build_findutils -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_FINDUTILS" >> $topdir/target/config/Config.in.prereq ;fi
369 if [ $host_build_sed -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_SED" >> $topdir/target/config/Config.in.prereq ;fi
370 if [ $host_build_tar -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_TAR" >> $topdir/target/config/Config.in.prereq ;fi
371 if [ $host_build_xz -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_XZ" >> $topdir/target/config/Config.in.prereq ;fi
372 # optional
373 if [ $host_build_ccache -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_CCACHE if ADK_HOST_NEED_CCACHE" >> $topdir/target/config/Config.in.prereq ;fi
374 if [ $host_build_cdrtools -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_CDRTOOLS if ADK_HOST_NEED_CDRTOOLS" >> $topdir/target/config/Config.in.prereq ;fi
375 if [ $host_build_genext2fs -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_GENEXT2FS if ADK_HOST_NEED_GENEXT2FS" >> $topdir/target/config/Config.in.prereq ;fi
376 if [ $host_build_lzma -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_LZMA if ADK_HOST_NEED_LZMA" >> $topdir/target/config/Config.in.prereq ;fi
377 if [ $host_build_lz4 -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_LZ4 if ADK_HOST_NEED_LZ4" >> $topdir/target/config/Config.in.prereq ;fi
378 if [ $host_build_lzop -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_LZOP if ADK_HOST_NEED_LZOP" >> $topdir/target/config/Config.in.prereq ;fi
379 if [ $host_build_qemu -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_QEMU if ADK_HOST_NEED_QEMU" >> $topdir/target/config/Config.in.prereq ;fi
381 cd $topdir
382 rm -rf tmp
384 exit $out