]> git.ipfire.org Git - ipfire-3.x.git/blob - tools/make-check
Add presence check of automake for toolchain build
[ipfire-3.x.git] / tools / make-check
1 #!/bin/bash
2 ###############################################################################
3 # #
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2007 Michael Tremer & Christian Schmidt #
6 # #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
11 # #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
16 # #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
19 # #
20 ###############################################################################
21
22 check_common() {
23 local NAME=$1
24 if [ -n "$3" ]; then
25 local RVER=$2
26 local COMMAND=$3
27 else
28 local COMMAND=$2
29 fi
30
31 local EXTRA=$4
32
33 RANDOM=$$
34 TMPFILE=/tmp/ipfire-check-$RANDOM
35
36 echo -ne "${BOLD}Checking for $NAME${NORMAL}"
37
38 [ -n "$RVER" ] && echo -n " (Requires at least $RVER)"
39
40 bash -c "$COMMAND" >$TMPFILE 2>&1
41
42 if ! grep -q "command not found" < $TMPFILE; then
43 beautify message DONE
44 else
45 rm -f $TMPFILE 2>/dev/null
46 exiterror "$NAME not found!"
47 fi
48
49 [ -n "$EXTRA" ] && echo -n "$EXTRA"
50
51 cat $TMPFILE
52 rm -f $TMPFILE 2>/dev/null
53 echo # Empty line
54 }
55
56 check_toolchain() {
57 check_common "GNU autoconf" "2.63" "autoconf --version | head -n1"
58 check_common "GNU Bash" "2.05a" "bash --version | head -n1 | cut -d\" \" -f2-4"
59 check_common "/bin/sh links bash?" "if ! which sh; then echo \"command not found\"; fi"
60 check_common "GNU Binutils" "2.12" "ld --version | head -n1 | cut -d\" \" -f3-" "Binutils: "
61 check_common "GNU Bison" "1.875" "bison --version | head -n1"
62 #check_common "/usr/bin/yacc links bison?" "if ! which yacc; then echo \"command not found\"; fi"
63 check_common "Bzip2" "1.0.2" "bzip2 --version 2>&1 < /dev/null | head -n1 | cut -d\" \" -f1,6-"
64 check_common "Coreutils" "5.0" "chown --version | head -n1 | cut -d\")\" -f2" "Coreutils:"
65 check_common "Diffutils" "2.8" "diff --version | head -n1"
66 check_common "Findutils" "4.1.20" "find --version | head -n1"
67 check_common "GNU awk" "3.0" "gawk --version | head -n1"
68 check_common "/bin/awk links gawk?" "if ! which awk; then echo \"command not found\"; fi"
69 check_common "GNU CC" "3.0.1" "gcc --version | head -n1"
70 check_common "GNU C++" "3.0.1" "g++ --version | head -n1"
71 check_common "GNU libc" "2.2.5" "/lib/libc.so.6 | head -n1 | cut -d\" \" -f1-7"
72 check_common "GNU Grep" "2.5" "grep --version | head -n1"
73 check_common "GNU zip" "1.2.4" "gzip --version | head -n1"
74 check_common "Linux 2.6" "2.6.x" "uname -r" "Linux: "
75 check_common "GNU make" "3.79.1" "make --version | head -n1"
76 check_common "Patch" "2.5.4" "patch --version | head -n1"
77 check_common "GNU sed" "3.0.2" "sed --version | head -n1"
78 check_common "GNU tar" "1.14" "tar --version | head -n1"
79 check_common "GNU Texinfo" "4.8" "makeinfo --version | head -n1"
80 check_common "GNU m4" "1.4.8" "m4 --version | head -n1"
81 check_common "GNU libtool" "libtool --version | head -n1"
82 check_common "GNU automake" "automake --version | head -n1"
83 }
84
85 check_build() {
86 check_common "Python" "python -V"
87 check_common "GNU make" "3.79.1" "make --version | head -n1"
88 check_common "Git" "git --version"
89 check_common "GNU which" "which --version | head -n1"
90 }
91
92 check_code() {
93 ACTION=$1
94 ARGS="--recurse"
95
96 echo -n " Running code checks"
97
98 case "$ACTION" in
99 --fix)
100 echo -n " and fix"
101 ;;
102 "")
103 ARGS+=" --dryrun"
104 ;;
105 *)
106 exiterror "This is not a valid option: $ACTION"
107 ;;
108 esac
109
110 echo -n "..." # End the line
111
112 python $BASEDIR/tools/code-beautify $ARGS $BASEDIR/{config,doc,lfs,src,tools}
113 if [ "$?" -eq "0" ]; then
114 beautify message DONE
115 else
116 beautify message FAIL
117 exit 1
118 fi
119 }
120
121 check_sanity() {
122
123 echo "Checking sanity of working directory..."
124
125 rootfiles_check $*
126 check_code $*
127
128 }
129
130 check_user() {
131 if [ -z $IPFIRE_USER ]; then
132 echo -n "You have to setup IPFIRE_USER first. See .config for details."
133 beautify message FAIL
134 exit 1
135 fi
136 }
137
138 check_loop() {
139 for i in $(seq 0 7); do
140 if [ -e /dev/loop/$i ] || [ -e /dev/loop$i ]; then
141 return 0
142 fi
143 done
144 return 1
145 }
146
147 CPU_FLAGS=$(grep ^flags /proc/cpuinfo)
148 check_cpu() {
149 FLAG=$1;
150 grep -q $FLAG <<< $CPU_FLAGS
151 return $?
152 }
153
154 check_supported_target() {
155 local FLAGS
156 if [ "$1" = "via-c7" ]; then
157 FLAGS="sse sse2 pni"
158 elif [ "$1" = "via-c3" ]; then
159 FLAGS="3dnow"
160 elif [ "$1" = "atom" ]; then
161 FLAGS="mmx sse sse2 pni ssse3"
162 elif [ "$1" = "core2duo" ]; then
163 FLAGS="sse2"
164 fi
165 for j in $FLAGS; do
166 if ! check_cpu $j; then
167 echo "Your system doesn't support needed cpu feature \"$j\" to build target $1." >&2
168 return 1
169 fi
170 done
171 return 0
172 }
173
174 check_supported_targets() {
175 for i in ${1-$POSSIBLE_TARGETS}; do
176 check_supported_target $i 2>/dev/null
177 [ "$?" -eq "0" ] && echo -n "$i "
178 done
179 echo # new line
180 }