add new firefox appliance config, finetune the other
[openadk.git] / scripts / scan-tools.sh
blobb55c08a1f60a11129b55066029a173fb641fb4ac
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)
50 MirBSD)
52 CYG*)
54 NetBSD)
56 OpenBSD)
57 if ! which gmake >/dev/null 2>&1; then
58 echo You must install GNU make to continue.
59 echo
60 out=1
63 Darwin*)
64 clang=1
67 # unsupported
68 echo "Building OpenADK on $os is currently unsupported."
69 echo "Sorry."
70 exit 1
72 esac
74 set +e
76 if [ -z $(which gmake 2>/dev/null ) ];then
77 makecmd=$(which make 2>/dev/null )
78 else
79 makecmd=$(which gmake 2>/dev/null )
82 if [ $clang -ne 1 ];then
83 HCFLAGS=-static-libgcc
86 cat >Makefile <<'EOF'
87 include ${ADK_TOPDIR}/prereq.mk
88 all: run-test
90 test: test.c
91 ${HOST_CC} $(HCFLAGS) -o $@ $^ ${LDADD}
93 run-test: test
94 ./test
95 EOF
96 cat >test.c <<-'EOF'
97 #include <stdio.h>
98 int
99 main()
101 printf("Yay! Native compiler works.\n");
102 return (0);
105 X=$($makecmd ADK_TOPDIR=$topdir 2>&1)
106 if [[ $X != *@(Native compiler works)* ]]; then
107 echo "$X" | sed 's/^/| /'
108 echo Cannot compile a simple test programme.
109 echo You must install a host make and C compiler,
110 echo usually GCC, to proceed.
111 echo
112 out=1
114 rm test 2>/dev/null
116 if ! which shasum >/dev/null 2>&1; then
117 echo You must install shasum to continue.
118 echo
119 out=1
122 if ! which gzip >/dev/null 2>&1; then
123 echo You must install gzip to continue.
124 echo
125 out=1
128 cat >test.c <<-'EOF'
129 #include <stdio.h>
130 #include <zlib.h>
132 #ifndef STDIN_FILENO
133 #define STDIN_FILENO 0
134 #endif
137 main()
139 gzFile zstdin;
140 char buf[1024];
141 int i;
143 zstdin = gzdopen(STDIN_FILENO, "rb");
144 i = gzread(zstdin, buf, sizeof (buf));
145 if ((i > 0) && (i < sizeof (buf)))
146 buf[i] = '\0';
147 buf[sizeof (buf) - 1] = '\0';
148 printf("%s\n", buf);
149 return (0);
152 X=$(echo 'Yay! Native compiler works.' | gzip | \
153 $makecmd ADK_TOPDIR=$topdir LDADD=-lz 2>&1)
154 if [[ $X != *@(Native compiler works)* ]]; then
155 echo "$X" | sed 's/^/| /'
156 echo Cannot compile a libz test programm.
157 echo You must install the zlib development package,
158 echo usually called libz-dev, and the run-time library.
159 echo
160 out=1
163 if [[ ! -s /usr/include/ncurses.h ]]; then
164 if [[ ! -s /usr/include/curses.h ]]; then
165 if [[ ! -s /usr/include/ncurses/ncurses.h ]]; then
166 if [[ ! -s /usr/local/opt/ncurses/include/ncursesw/ncurses.h ]]; then
167 echo Install ncurses header files, please.
168 echo
169 out=1
175 if ! which wget >/dev/null 2>&1; then
176 echo You must install wget to continue.
177 echo
178 out=1
181 if ! which perl >/dev/null 2>&1; then
182 echo You must install perl to continue.
183 echo
184 out=1
187 if ! which g++ >/dev/null 2>&1; then
188 echo "You need a C++ compiler to continue."
189 echo
190 out=1
193 # always required, but can be provided by host
194 host_build_bc=0
195 if which bc >/dev/null 2>&1; then
196 if ! echo quit|bc -q 2>/dev/null >/dev/null;then
197 host_build_bc=1
199 else
200 host_build_bc=1
203 host_build_bison=0
204 if ! which bison >/dev/null 2>&1; then
205 host_build_bison=1
208 host_build_bzip2=0
209 if ! which bzip2 >/dev/null 2>&1; then
210 host_build_bzip2=1
213 host_build_file=0
214 if ! which file >/dev/null 2>&1; then
215 host_build_file=1
218 host_build_flex=0
219 if ! which flex >/dev/null 2>&1; then
220 host_build_flex=1
223 host_build_m4=0
224 if ! which m4 >/dev/null 2>&1; then
225 host_build_m4=1
228 host_build_mksh=0
229 if ! which mksh >/dev/null 2>&1; then
230 host_build_mksh=1
233 host_build_patch=0
234 if ! which patch >/dev/null 2>&1; then
235 host_build_patch=1
238 host_build_pkgconf=0
239 if ! which pkgconf >/dev/null 2>&1; then
240 host_build_pkgconf=1
243 host_build_tar=0
244 if which tar >/dev/null 2>&1; then
245 if ! tar --version 2>/dev/null|grep GNU >/dev/null;then
246 host_build_tar=1
248 else
249 host_build_tar=1
252 host_build_findutils=0
253 if ! which gxargs >/dev/null 2>&1; then
254 if which xargs >/dev/null 2>&1; then
255 if ! xargs --version 2>/dev/null|grep GNU >/dev/null;then
256 host_build_findutils=1
261 if ! which gfind >/dev/null 2>&1; then
262 if which find >/dev/null 2>&1; then
263 if ! find --version 2>/dev/null|grep GNU >/dev/null;then
264 host_build_findutils=1
269 host_build_grep=0
270 if which grep >/dev/null 2>&1; then
271 if ! grep --version 2>/dev/null|grep GNU >/dev/null;then
272 host_build_grep=1
276 host_build_gawk=0
277 if ! which gawk >/dev/null 2>&1; then
278 host_build_gawk=1
281 host_build_sed=0
282 if ! which gsed >/dev/null 2>&1; then
283 if which sed >/dev/null 2>&1; then
284 if ! sed --version 2>/dev/null|grep GNU >/dev/null;then
285 host_build_sed=1
290 host_build_xz=0
291 if ! which xz >/dev/null 2>&1; then
292 host_build_xz=1
295 # optional
296 host_build_cdrtools=0
297 if ! which mkisofs >/dev/null 2>&1; then
298 host_build_cdrtools=1
301 host_build_ccache=0
302 if ! which ccache >/dev/null 2>&1; then
303 host_build_ccache=1
306 host_build_genext2fs=0
307 if ! which genext2fs >/dev/null 2>&1; then
308 host_build_genext2fs=1
311 host_build_lzma=0
312 if ! which lzma >/dev/null 2>&1; then
313 host_build_lzma=1
316 host_build_lz4=0
317 if ! which lz4c >/dev/null 2>&1; then
318 host_build_lz4=1
321 host_build_lzop=0
322 if ! which lzop >/dev/null 2>&1; then
323 host_build_lzop=1
326 host_build_qemu=0
327 if ! which qemu-img >/dev/null 2>&1; then
328 host_build_qemu=1
331 echo "config ADK_HOST_BUILD_TOOLS" > $topdir/target/config/Config.in.prereq
332 printf "\t%s\n" "boolean" >> $topdir/target/config/Config.in.prereq
333 printf "\t%s\n" "default y" >> $topdir/target/config/Config.in.prereq
334 # always required
335 if [ $host_build_bc -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_BC" >> $topdir/target/config/Config.in.prereq ;fi
336 if [ $host_build_bison -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_BISON" >> $topdir/target/config/Config.in.prereq ;fi
337 if [ $host_build_bzip2 -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_BZIP2" >> $topdir/target/config/Config.in.prereq ;fi
338 if [ $host_build_file -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_FILE" >> $topdir/target/config/Config.in.prereq ;fi
339 if [ $host_build_flex -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_FLEX" >> $topdir/target/config/Config.in.prereq ;fi
340 if [ $host_build_gawk -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_GAWK" >> $topdir/target/config/Config.in.prereq ;fi
341 if [ $host_build_grep -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_GREP" >> $topdir/target/config/Config.in.prereq ;fi
342 if [ $host_build_m4 -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_M4" >> $topdir/target/config/Config.in.prereq ;fi
343 if [ $host_build_mksh -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_MKSH" >> $topdir/target/config/Config.in.prereq ;fi
344 if [ $host_build_patch -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_PATCH" >> $topdir/target/config/Config.in.prereq ;fi
345 if [ $host_build_pkgconf -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_PKGCONF" >> $topdir/target/config/Config.in.prereq ;fi
346 if [ $host_build_findutils -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_FINDUTILS" >> $topdir/target/config/Config.in.prereq ;fi
347 if [ $host_build_sed -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_SED" >> $topdir/target/config/Config.in.prereq ;fi
348 if [ $host_build_tar -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_TAR" >> $topdir/target/config/Config.in.prereq ;fi
349 if [ $host_build_xz -eq 1 ];then printf "\t%s\n" "select ADK_HOST_BUILD_XZ" >> $topdir/target/config/Config.in.prereq ;fi
350 # optional
351 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
352 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
353 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
354 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
355 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
356 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
357 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
359 cd $topdir
360 rm -rf tmp
362 exit $out