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

Last change on this file since de3cb1f5 was 5486644, checked in by Thorsten Glaser <tg@…>, 19 years ago

add checks for texinfo (makeinfo), closes: #167 #170 #171

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

  • Property mode set to 100644
File size: 7.3 KB
Line 
1#!/usr/bin/env bash
2# $FreeWRT: src/share/misc/licence.template,v 1.20 2006/12/11 21:04:56 tg Rel $
3#-
4# Copyright (c) 2006, 2007
5# Thorsten Glaser <tg@mirbsd.de>
6#
7# Provided that these terms and disclaimer and all copyright notices
8# are retained or reproduced in an accompanying document, permission
9# is granted to deal in this work without restriction, including un-
10# limited rights to use, publicly perform, distribute, sell, modify,
11# merge, give away, or sublicence.
12#
13# Advertising materials mentioning features or use of this work must
14# display the following acknowledgement:
15# This product includes material provided by Thorsten Glaser.
16# This acknowledgement does not need to be reprinted if this work is
17# linked into a bigger work whose licence does not allow such clause
18# and the author of this work is given due credit in the bigger work
19# or its accompanying documents, where such information is generally
20# kept, provided that said credits are retained.
21#
22# This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to
23# the utmost extent permitted by applicable law, neither express nor
24# implied; without malicious intent or gross negligence. In no event
25# may a licensor, author or contributor be held liable for indirect,
26# direct, other damage, loss, or other issues arising in any way out
27# of dealing in the work, even if advised of the possibility of such
28# damage or existence of a defect, except proven that it results out
29# of said person's immediate fault when using the work as intended.
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
52
53os=$(uname)
54case $os in
55Linux)
56 # supported with no extra quirks at the moment
57 ;;
58OpenBSD)
59 # supported with no extra quirks at the moment
60 # although some packages' autoconf scripts may
61 # not properly recognise OpenBSD
62 ;;
63MirBSD)
64 # needs a little quirk, because the autoconf
65 # version of some packages doesn't recognise
66 # it as valid OS, and as build (not host) OS
67 # faking OpenBSD is close enough
68 rm -f $topdir/lbin/uname
69 sed -e 's!@@FromOS@@!MirBSD!g' -e 's!@@ToOS@@!OpenBSD!g' \
70 -e "s!@@PROG@@!$($topdir/lbin/which uname)!g" \
71 <$topdir/scripts/uname.fake >$topdir/lbin/uname
72 chmod 555 $topdir/lbin/uname
73 ;;
74*)
75 # unsupported
76 echo "Building FreeWRT on $os is currently unsupported."
77 echo "Sorry."
78 echo
79 case $os in
80 Darwin|Cyg*)
81 echo "The most prominent issue is that filesystems"
82 echo "can be case-insensitive. Some macros are missing."
83 echo
84 ;;
85 NetBSD|FreeBSD|DragonFly)
86 echo "Building should succeed with relatively few"
87 echo "patches, but perl must live in /usr/bin for"
88 echo "now in FreeWRT, which should indeed be fixed."
89 echo
90 ;;
91 esac
92 echo "If you need FreeWRT building on $os, please contact"
93 echo "the development team; there may be contractors available"
94 echo "for this task. If you intend on turning $os into one of"
95 echo "the supported build OSes, please contact us as well so"
96 echo "that we can feed back your enhancements into FreeWRT."
97 exit 1
98 ;;
99esac
100
101set +e
102cat >Makefile <<'EOF'
103include $(TOPDIR)/lbin/prereq.mk
104all: run-test
105
106test: test.c
107 ${HOSTCC} ${HOSTCFLAGS} -o $@ $^ ${LDADD}
108
109run-test: test
110 ./test
111EOF
112cat >test.c <<-'EOF'
113 #include <stdio.h>
114 int
115 main()
116 {
117 printf("Yay! Native compiler works.\n");
118 return (0);
119 }
120EOF
121X=$(gmake TOPDIR=$topdir 2>&1)
122if [[ $X != *@(Native compiler works)* ]]; then
123 echo Cannot compile a simple test programme.
124 echo You must install GNU make and a host C compiler,
125 echo usually GCC, to proceed.
126 out=1
127fi
128rm test*
129
130X=$(gmake --version 2>&1 | grep '^GNU Make' | \
131 sed -e 's/GNU Make //' -e 's/version //' -e 's/, by.*$//')
132[[ $X = +([0-9]).+([0-9]).+([0-9]) ]] && X=${X%.*}
133if [[ $X = +([0-9]).+([0-9]) ]]; then
134 let major=${X%.*}
135 let minor=${X#*.}
136elif [[ $X = +([0-9]).+([0-9])beta* ]]; then
137 # Beta version is not "the real thing"
138 let major=${X%.*}
139 X=${X%beta*}
140 let minor=${X#*.}-1
141else
142 echo Cannot determine GNU make version number.
143 out=1
144fi
145if (( (major < 3) || ((major == 3) && (minor < 81)) )); then
146 echo GNU make $major.$minor too old.
147 echo Please install GNU make 3.81 or higher to continue.
148 if [[ $NO_ERROR = 1 || -s /etc/debian_version || \
149 -s /etc/fedora-release ]]; then
150 echo WARNING: should abort here, continuing...
151 else
152 echo You can override this check, see http://www.freewrt.org/trac/wiki/Documentation/FAQ for details.
153 out=1
154 fi
155fi
156
157if ! which flex >/dev/null 2>&1; then
158 echo You must install flex to continue.
159 out=1
160else
161 echo '%%' | flex -
162 if fgrep _POSIX_SOURCE lex.yy.c; then
163 echo Your lexer \(flex\) contains a broken skeleton.
164 if [[ $NO_ERROR = 1 ]]; then
165 echo WARNING: continue at your own risk.
166 echo Some packages may be broken.
167 else
168 echo You can continue the build by issuing \'make prereq-noerror\'
169 echo However, several packages may faild to build correctly.
170 out=1
171 fi
172 fi
173fi
174
175if ! which bison >/dev/null 2>&1; then
176 echo You must install GNU Bison to continue.
177 echo While you can install any version, it is '*STRONGLY*' suggested
178 echo to install GNU Bison version 2.3 because of its bug fixes.
179 out=1
180fi
181X=$(bison --version 2>&1 | fgrep 'GNU Bison' | sed 's/^[^0-9]*//')
182V=old
183if [[ $X = +([0-9]).+([0-9]) ]]; then
184 let major=${X%.*}
185 let minor=${X#*.}
186 if (( (major > 2) || ((major == 2) && (minor >= 3)) )); then
187 V=new
188 fi
189fi
190if [[ $V = old ]]; then
191 echo It is suggested to upgrade your copy of bison to
192 echo GNU Bison 2.3 because of its bug fixes.
193fi
194
195if ! which gzip >/dev/null 2>&1; then
196 echo You must install gzip to continue.
197 out=1
198fi
199
200if ! which bzip2 >/dev/null 2>&1; then
201 echo You must install bzip2 to continue.
202 out=1
203fi
204
205if ! which unzip >/dev/null 2>&1; then
206 echo You must install unzip to continue, sorry.
207 out=1
208fi
209
210if ! which patch >/dev/null 2>&1; then
211 echo You must install patch \(from Larry Wall\) to continue.
212 out=1
213fi
214
215cat >test.c <<-'EOF'
216 #include <stdio.h>
217 #include <zlib.h>
218
219 #ifndef STDIN_FILENO
220 #define STDIN_FILENO 0
221 #endif
222
223 int
224 main()
225 {
226 gzFile zstdin;
227 char buf[1024];
228 int i;
229
230 zstdin = gzdopen(STDIN_FILENO, "rb");
231 i = gzread(zstdin, buf, sizeof (buf));
232 if ((i > 0) && (i < sizeof (buf)))
233 buf[i] = '\0';
234 buf[sizeof (buf) - 1] = '\0';
235 printf("%s\n", buf);
236 return (0);
237 }
238EOF
239X=$(echo 'Yay! Native compiler works.' | gzip | \
240 gmake TOPDIR=$topdir LDADD=-lz 2>&1)
241if [[ $X != *@(Native compiler works)* ]]; then
242 echo Cannot compile a libz test programme.
243 echo You must install the zlib development package,
244 echo usually called libz-dev, and the run-time library.
245 out=1
246fi
247
248if [[ ! -s /usr/include/ncurses.h ]]; then
249 echo Install ncurses header files, please.
250 out=1
251fi
252
253if ! which g++ >/dev/null 2>&1; then
254 echo You must install the host GNU C++ compiler to continue.
255 out=1
256fi
257
258#if ! which perl >/dev/null 2>&1; then
259if [[ "$(which perl 2>/dev/null)" != /usr/bin/perl ]]; then
260 echo You must install Perl in /usr/bin to continue.
261 out=1
262fi
263
264if ! which wget >/dev/null 2>&1; then
265 echo You must install GNU wget to continue.
266 out=1
267fi
268
269if ! which makeinfo >/dev/null 2>&1; then
270 echo You must install GNU texinfo to continue.
271 out=1
272fi
273
274
275cd $topdir
276rm -rf lbin/tmp
277exit $out
Note: See TracBrowser for help on using the repository browser.