source: freewrt/scripts/scan-tools.sh@ 8d0450f

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

require GNU tar and install it as tar, for now

ok wbx@

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

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