source: freewrt/scripts/scan-tools.sh@ fdd4f59

freewrt_1_0 freewrt_2_0
Last change on this file since fdd4f59 was fa281a9, checked in by Thorsten Glaser <tg@…>, 19 years ago

instead of aborting as soon as an error is found,
try to do as many checks as possible (taking into
account that e.g. if the compiler, make or gzip are
not found, some later tests will fail too)

after discussion with wbx@ some days ago

also remove the confusing redundant clause,
spotted by nbd, ok wbx@

git-svn-id: svn://www.freewrt.org/trunk/freewrt@358 afb5a338-a214-0410-bd46-81f09a774fd1

  • Property mode set to 100644
File size: 5.7 KB
Line 
1#!/usr/bin/env bash
2# $FreeWRT: src/share/misc/licence.template,v 1.8 2006/06/16 23:03:39 tg Rel $
3#-
4# Copyright (c) 2006
5# Thorsten Glaser <tg@mirbsd.de>
6#
7# Licensee is hereby permitted to deal in this work without restric-
8# tion, including unlimited rights to use, publicly perform, modify,
9# merge, distribute, sell, give away or sublicence, provided all co-
10# pyright notices above, these terms and the disclaimer are retained
11# in all redistributions or reproduced in accompanying documentation
12# or other materials provided with binary redistributions.
13#
14# All advertising materials mentioning features or use of this soft-
15# ware must display the following acknowledgement:
16# This product includes material provided by Thorsten Glaser.
17# This acknowledgement does not need to be reprinted if this work is
18# linked into a bigger work whose licence does not allow such clause
19# and the author of this work is given due credit in the bigger work
20# or its documentation.
21#
22# Licensor offers the work "AS IS" and WITHOUT WARRANTY of any kind,
23# express, or implied, to the maximum extent permitted by applicable
24# law, without malicious intent or gross negligence; in no event may
25# licensor, an author or contributor be held liable for any indirect
26# or other damage, or direct damage except proven a consequence of a
27# direct error of said person and intended use of this work, loss or
28# other issues arising in any way out of its use, even if advised of
29# the possibility of such damage or existence of a nontrivial bug.
30#-
31# Scan for prerequisite host tools.
32
33if test -z "$BASH_VERSION"; then
34 echo FreeWRT requires GNU bash to be installed, sorry.
35 exit 1
36fi
37
38shopt -s extglob
39topdir=$(pwd)
40export PATH=$topdir/lbin:$PATH
41out=0
42
43if [[ $NO_ERROR != @(0|1) ]]; then
44 echo Please do not invoke this script directly!
45 exit 1
46fi
47
48set -e
49rm -rf $topdir/lbin/tmp
50mkdir -p $topdir/lbin/tmp
51cd $topdir/lbin/tmp
52set +e
53cat >Makefile <<'EOF'
54include $(TOPDIR)/lbin/prereq.mk
55all: run-test
56
57test: test.c
58 ${HOSTCC} ${HOSTCFLAGS} -o $@ $^ ${LDADD}
59
60run-test: test
61 ./test
62EOF
63cat >test.c <<-'EOF'
64 #include <stdio.h>
65 int
66 main()
67 {
68 printf("Yay! Native compiler works.\n");
69 return (0);
70 }
71EOF
72X=$(gmake TOPDIR=$topdir 2>&1)
73if [[ $X != *@(Native compiler works)* ]]; then
74 echo Cannot compile a simple test programme.
75 echo You must install GNU make and a host C compiler,
76 echo usually GCC, to proceed.
77 out=1
78fi
79rm test*
80
81X=$(gmake --version 2>&1 | grep '^GNU Make' | \
82 sed -e 's/GNU Make //' -e 's/version //' -e 's/, by.*$//')
83[[ $X = +([0-9]).+([0-9]).+([0-9]) ]] && X=${X%.*}
84if [[ $X = +([0-9]).+([0-9]) ]]; then
85 let major=${X%.*}
86 let minor=${X#*.}
87elif [[ $X = +([0-9]).+([0-9])beta* ]]; then
88 # Beta version is not "the real thing"
89 let major=${X%.*}
90 X=${X%beta*}
91 let minor=${X#*.}-1
92else
93 echo Cannot determine GNU make version number.
94 out=1
95fi
96if (( (major < 3) || ((major == 3) && (minor < 81)) )); then
97 echo GNU make $major.$minor too old.
98 echo Please install GNU make 3.81 or higher to continue.
99 if [[ $NO_ERROR = 1 || -s /etc/debian_version ]]; then
100 echo WARNING: should abort here, continuing...
101 else
102 echo You can override this check, see http://www.freewrt.org/faq for details.
103 out=1
104 fi
105fi
106
107if ! which flex >/dev/null 2>&1; then
108 echo You must install flex to continue.
109 out=1
110fi
111
112echo '%%' | flex -
113if fgrep _POSIX_SOURCE lex.yy.c; then
114 echo Your lexer \(flex\) contains a broken skeleton.
115 if [[ $NO_ERROR = 1 ]]; then
116 echo WARNING: continue at your own risk.
117 echo Some packages may be broken.
118 else
119 echo You can continue the build by issuing \'make prereq-noerror\'
120 echo However, several packages may faild to build correctly.
121 out=1
122 fi
123fi
124
125if ! which bison >/dev/null 2>&1; then
126 echo You must install GNU Bison to continue.
127 echo While you can install any version, it is '*STRONGLY*' suggested
128 echo to install GNU Bison version 2.3 because of its bug fixes.
129 out=1
130fi
131X=$(bison --version 2>&1 | fgrep 'GNU Bison' | sed 's/^[^0-9]*//')
132V=old
133if [[ $X = +([0-9]).+([0-9]) ]]; then
134 let major=${X%.*}
135 let minor=${X#*.}
136 if (( (major > 2) || ((major == 2) && (minor >= 3)) )); then
137 V=new
138 fi
139fi
140if [[ $V = old ]]; then
141 echo It is suggested to upgrade your copy of bison to
142 echo GNU Bison 2.3 because of its bug fixes.
143fi
144
145if ! which gzip >/dev/null 2>&1; then
146 echo You must install gzip to continue.
147 out=1
148fi
149
150if ! which bzip2 >/dev/null 2>&1; then
151 echo You must install bzip2 to continue.
152 out=1
153fi
154
155if ! which unzip >/dev/null 2>&1; then
156 echo You must install unzip to continue, sorry.
157 out=1
158fi
159
160if ! which patch >/dev/null 2>&1; then
161 echo You must install patch \(from Larry Wall\) to continue.
162 out=1
163fi
164
165cat >test.c <<-'EOF'
166 #include <stdio.h>
167 #include <zlib.h>
168
169 #ifndef STDIN_FILENO
170 #define STDIN_FILENO 0
171 #endif
172
173 int
174 main()
175 {
176 gzFile zstdin;
177 char buf[1024];
178 int i;
179
180 zstdin = gzdopen(STDIN_FILENO, "rb");
181 i = gzread(zstdin, buf, sizeof (buf));
182 if ((i > 0) && (i < sizeof (buf)))
183 buf[i] = '\0';
184 buf[sizeof (buf) - 1] = '\0';
185 printf("%s\n", buf);
186 return (0);
187 }
188EOF
189X=$(echo 'Yay! Native compiler works.' | gzip | \
190 gmake TOPDIR=$topdir LDADD=-lz 2>&1)
191if [[ $X != *@(Native compiler works)* ]]; then
192 echo Cannot compile a libz test programme.
193 echo You must install the zlib development package,
194 echo usually called libz-dev, and the run-time library.
195 out=1
196fi
197
198if ! which g++ >/dev/null 2>&1; then
199 echo You must install the host GNU C++ compiler to continue.
200 out=1
201fi
202
203#if ! which perl >/dev/null 2>&1; then
204if [[ "$(which perl 2>/dev/null)" != /usr/bin/perl ]]; then
205 echo You must install Perl in /usr/bin to continue.
206 out=1
207fi
208
209if ! which python >/dev/null 2>&1; then
210 echo You must install Python to continue, sorry.
211 out=1
212fi
213
214if ! which wget >/dev/null 2>&1; then
215 echo You must install GNU wget to continue.
216 out=1
217fi
218
219
220cd $topdir
221rm -rf lbin/tmp
222exit $out
Note: See TracBrowser for help on using the repository browser.