Add externs to avoid multiple definitions, and then add missing definitions.
[rrq/maintain_lilo.git] / checkit
1 #! /bin/sh
2 #
3 #  checkit:    Test for correct versions of utilities
4 #  (see the end of the file for bypassing these checks)
5 #
6 #  Copyright 2005-2007 John Coffman
7 #  Copyright 2009-2010 Joachim Wiedorn
8 #  All rights reserved.
9 #
10 #  Licensed under the terms contained in the file 'COPYING'
11 #  in the source directory.
12 #
13
14
15 ret=0
16 rc=0
17
18 # min. version of BCC, AD86, LD86
19 bccmin="0.16.14"
20
21 # min. version of GCC, CPP
22 gccmin="3.3.5"
23
24 vers_min() {
25         local M m p N n r
26
27         rc=0
28 # get our version major, minor, rev
29         M=`echo $1 | cut -d . -f 1`
30         m=`echo $1 | cut -d . -f 2`
31         p=`echo $1 | cut -d . -f 3`
32         if [ -z "$p" ]; then p=0; fi
33 #echo vers_min1 $M $m $p
34         N=`echo $2 | cut -d . -f 1`
35         n=`echo $2 | cut -d . -f 2`
36         r=`echo $2 | cut -d . -f 3`
37 #echo vers_min2 $N $n $r
38         if [ "$M" -lt "$N" ]; then rc=1
39         elif [ "$M" -gt "$N" ]; then rc=0
40         elif [ "$m" -lt "$n" ]; then rc=1
41         elif [ "$m" -gt "$n" ]; then rc=0
42         elif [ -z "$r" ]; then rc=0
43         elif [ "$p" -lt "$r" ]; then rc=1
44         fi
45 #echo vers_min returns $rc
46         return $rc
47 }
48
49 #echo
50 echo GCC version $gccmin or later is required
51 gcc -v 1>foo1 2>foo2
52 V=`cat foo1 foo2 | cut -d' ' -f1-3 | grep -i version | tr '-' ' ' | cut -d' ' -f 3`
53 rm -f foo1 foo2
54 if [ -z "$V" ]; then
55         echo gcc is not present
56         ret=1
57 else
58         vers_min $V $gccmin
59         echo gcc version $V
60         if [ $rc = 0 ]; then echo OKAY; else echo ERROR; ret=1; fi
61 fi
62
63 echo
64 echo AS86 version $bccmin or later is required
65 as86 -v 1>foo1 2>foo2
66 A=`cat foo1 foo2 | grep version | cut -d " " -f 3`
67 rm -f foo1 foo2
68 if [ -z "$A" ]; then
69         echo as86 is not present
70         ret=1
71 else
72         vers_min $A $bccmin
73         echo as86 version $A
74         if [ $rc = 0 ]; then echo OKAY; else echo ERROR; ret=1; fi
75 fi
76
77 echo
78 echo LD86 version $bccmin or later is required
79 ld86 -v 1>foo1 2>foo2
80 L=`cat foo1 foo2 | grep version | cut -d " " -f 3`
81 rm -f foo1 foo2
82 if [ -z "$L" ]; then
83         echo ld86 is not present
84         ret=1
85 else
86         vers_min $L $bccmin
87         echo ld86 version $L
88         if [ $rc = 0 ]; then echo OKAY; else echo ERROR; ret=1; fi
89 fi
90
91 echo
92 echo BCC version $bccmin or later is recommended
93 bcc -v 1>foo1 2>foo2
94 B=`cat foo1 foo2 | grep version | cut -d " " -f 3`
95 rm -f foo1 foo2
96 if [ -z "$B" ]; then
97         echo bcc is not present
98         echo You will not be able to make floppy2, diag2.img, or lilo.com
99 else
100         vers_min $B $bccmin
101         echo bcc version $B
102         if [ $rc = 0 ]; then echo OKAY; else echo ERROR; fi
103 fi
104 echo
105
106 #
107 # Uncomment the line below to bypass all the checks
108 #
109 #exit 0
110 exit $ret