source: freewrt/scripts/scan-tools.sh@ 99d4f9d3

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

add missing checks for gzip(1) existence and workability

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

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