source: freewrt/scripts/scan-tools.sh@ 01fc702

freewrt_1_0 freewrt_2_0
Last change on this file since 01fc702 was 01fc702, checked in by Thorsten Glaser <tg@…>, 19 years ago
  • tell which version of make is too old
  • handle 3.79.1 (currently in fink)

NB: 3.79.1 and 3.80 on Mac OSX Tiger are both too old.

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

  • Property mode set to 100644
File size: 5.4 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
113if ! which bison >/dev/null 2>&1; then
114 echo You must install GNU Bison to continue.
115 echo While you can install any version, it is '*STRONGLY*' suggested
116 echo to install GNU Bison version 2.3 because of its bug fixes.
117 exit 1
118fi
119X=$(bison --version 2>&1 | fgrep 'GNU Bison' | sed 's/^[^0-9]*//')
120V=old
121if [[ $X = +([0-9]).+([0-9]) ]]; then
122 let major=${X%.*}
123 let minor=${X#*.}
124 if (( (major > 2) || ((major == 2) && (minor >= 3)) )); then
125 V=new
126 fi
127fi
128if [[ $V = old ]]; then
129 echo It is suggested to upgrade your copy of bison to
130 echo GNU Bison 2.3 because of its bug fixes.
131fi
132
133if ! which bzip2 >/dev/null 2>&1; then
134 echo You must install bzip2 to continue.
135 exit 1
136fi
137
138if ! which unzip >/dev/null 2>&1; then
139 echo You must install unzip to continue, sorry.
140 exit 1
141fi
142
143if ! which patch >/dev/null 2>&1; then
144 echo You must install patch \(from Larry Wall\) to continue.
145 exit 1
146fi
147
148cat >test.c <<-'EOF'
149 #include <stdio.h>
150 #include <zlib.h>
151
152 #ifndef STDIN_FILENO
153 #define STDIN_FILENO 0
154 #endif
155
156 int
157 main()
158 {
159 gzFile zstdin;
160 char buf[1024];
161 int i;
162
163 zstdin = gzdopen(STDIN_FILENO, "rb");
164 i = gzread(zstdin, buf, sizeof (buf));
165 if ((i > 0) && (i < sizeof (buf)))
166 buf[i] = '\0';
167 buf[sizeof (buf) - 1] = '\0';
168 printf("%s\n", buf);
169 return (0);
170 }
171EOF
172X=$(echo 'Yay! Native compiler works.' | gmake TOPDIR=$topdir LDADD=-lz 2>&1)
173if [[ $X != *@(Native compiler works)* ]]; then
174 echo Cannot compile a libz test programme.
175 echo You must install the zlib development package,
176 echo usually called libz-dev, and the run-time library.
177 exit 1
178fi
179
180if ! which g++ >/dev/null 2>&1; then
181 echo You must install the host GNU C++ compiler to continue.
182 exit 1
183fi
184
185#if ! which perl >/dev/null 2>&1; then
186if [[ "$(which perl 2>/dev/null)" != /usr/bin/perl ]]; then
187 echo You must install Perl in /usr/bin to continue.
188 exit 1
189fi
190
191if ! which python >/dev/null 2>&1; then
192 echo You must install Python to continue, sorry.
193 exit 1
194fi
195
196if ! which wget >/dev/null 2>&1; then
197 echo You must install GNU wget to continue.
198 exit 1
199fi
200
201
202cd $topdir
203rm -rf lbin/tmp
204exit 0
Note: See TracBrowser for help on using the repository browser.