source: freewrt/scripts/scan-tools.sh@ 1e977a4

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

switch to paxmirabilis

ok wbx@

NB: not yet totally tested, but if anything breaks I'll fix it today/tonight

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

  • Property mode set to 100644
File size: 5.2 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' | sed 's/GNU Make //')
83if [[ $X = +([0-9]).+([0-9]) ]]; then
84 let major=${X%.*}
85 let minor=${X#*.}
86elif [[ $X = +([0-9]).+([0-9])beta* ]]; then
87 # Beta version is not "the real thing"
88 let major=${X%.*}
89 X=${X%beta*}
90 let minor=${X#*.}-1
91else
92 echo Cannot determine GNU make version number.
93 exit 1
94fi
95if (( (major < 3) || ((major == 3) && (minor < 81)) )); then
96 echo GNU make too old.
97 echo Please install GNU make 3.81 or higher to continue.
98 if [[ $NO_ERROR = 1 || -s /etc/debian_version ]]; then
99 echo WARNING: should abort here, continuing...
100 else
101 echo You can override this check, see http://www.freewrt.org/faq for details.
102 exit 1
103 fi
104fi
105
106if ! which flex >/dev/null 2>&1; then
107 echo You must install flex to continue.
108 exit 1
109fi
110
111if ! which bison >/dev/null 2>&1; then
112 echo You must install GNU Bison to continue.
113 echo While you can install any version, it is '*STRONGLY*' suggested
114 echo to install GNU Bison version 2.3 because of its bug fixes.
115 exit 1
116fi
117X=$(bison --version 2>&1 | fgrep 'GNU Bison' | sed 's/^[^0-9]*//')
118V=old
119if [[ $X = +([0-9]).+([0-9]) ]]; then
120 let major=${X%.*}
121 let minor=${X#*.}
122 if (( (major > 2) || ((major == 2) && (minor >= 3)) )); then
123 V=new
124 fi
125fi
126if [[ $V = old ]]; then
127 echo It is suggested to upgrade your copy of bison to
128 echo GNU Bison 2.3 because of its bug fixes.
129fi
130
131if ! which bzip2 >/dev/null 2>&1; then
132 echo You must install bzip2 to continue.
133 exit 1
134fi
135
136if ! which unzip >/dev/null 2>&1; then
137 echo You must install unzip to continue, sorry.
138 exit 1
139fi
140
141if ! which patch >/dev/null 2>&1; then
142 echo You must install patch \(from Larry Wall\) to continue.
143 exit 1
144fi
145
146cat >test.c <<-'EOF'
147 #include <stdio.h>
148 #include <zlib.h>
149
150 #ifndef STDIN_FILENO
151 #define STDIN_FILENO 0
152 #endif
153
154 int
155 main()
156 {
157 gzFile zstdin;
158 char buf[1024];
159 int i;
160
161 zstdin = gzdopen(STDIN_FILENO, "rb");
162 i = gzread(zstdin, buf, sizeof (buf));
163 if ((i > 0) && (i < sizeof (buf)))
164 buf[i] = '\0';
165 buf[sizeof (buf) - 1] = '\0';
166 printf("%s\n", buf);
167 return (0);
168 }
169EOF
170X=$(echo 'Yay! Native compiler works.' | gmake TOPDIR=$topdir LDADD=-lz 2>&1)
171if [[ $X != *@(Native compiler works)* ]]; then
172 echo Cannot compile a libz test programme.
173 echo You must install the zlib development package,
174 echo usually called libz-dev, and the run-time library.
175 exit 1
176fi
177
178if ! which g++ >/dev/null 2>&1; then
179 echo You must install the host GNU C++ compiler to continue.
180 exit 1
181fi
182
183#if ! which perl >/dev/null 2>&1; then
184if [[ "$(which perl 2>/dev/null)" != /usr/bin/perl ]]; then
185 echo You must install Perl in /usr/bin to continue.
186 exit 1
187fi
188
189if ! which python >/dev/null 2>&1; then
190 echo You must install Python to continue, sorry.
191 exit 1
192fi
193
194
195cd $topdir
196rm -rf lbin/tmp
197exit 0
Note: See TracBrowser for help on using the repository browser.