]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/gdb_mbuild.sh
* gdb_mbuild.sh: New file.
[thirdparty/binutils-gdb.git] / gdb / gdb_mbuild.sh
CommitLineData
3ed93867
RE
1#!/bin/sh
2
3# Multi-build script for testing compilation of all maintained configs of GDB.
4# Copyright (C) 2002 Free Software Foundation, Inc.
5# Contributed by Richard Earnshaw (rearnsha@arm.com)
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 2 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, write to the Free Software
19# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
21usage() {
22 echo "Usage: gdb_mbuild.sh <srcdir> <builddir> [<parjobs>]"
23 echo " Environment variables examined (with default if not defined):"
24 echo " AWK (awk) -- must be GNU awk"
25 echo " MAKE (make)"
26 echo
27 echo " Note: Everything in <builddir>/gdb-allcross will be blown away.
28 exit 1;
29}
30
31if [ $# -ne 2 -a $# -ne 3 ] ; then
32 usage
33fi
34
35### COMMAND LINE PARAMETERS
36
37# Where the sources live
38srcdir=$1
39
40# Where the builds occur
41buildbase=$2
42
43# Number of parallel make jobs (you probably want about 2 jobs per cpu for
44# maximum throughput)
45if [ $# -eq 3 ]; then
46 par=$3
47else
48 par="1"
49fi
50
51### ENVIRONMENT PARAMETERS
52# Must be GNU awk
53awk=${AWK:-awk}
54
55# Version of make to use
56make=${MAKE:-make}
57
58
59# Where builds will live
60builddir=${buildbase}/gdb-allcross
61
62# Where logs will go. NB. Must not be a sub-dir of builddir or you will loose
63# them.
64logdir=${buildbase}/gdb-logdir
65
66# Where to look for the list of targets to test
67maintainers=${srcdir}/gdb/MAINTAINERS
68
69# Get the list of targets and the build options
70alltarg=`${awk} < "${maintainers}" '
71 $2 ~ /--target=.*/ {
72 targets = gensub (/^.*--target=/, "", 1, $2)
73 warnings = gensub (/[)]*$/, "", 1, $3)
74 split (targets, targ, /,/)
75 for (i in targ) {
76 print targ[i], warnings
77 }
78 }'`
79
80# Back up the log files
81cd ${logdir}
82
83if [ -f build.out ]
84then
85 mv build.out build.old
86fi
87if [ -f config.out ]
88then
89 mv config.out config.old
90fi
91if [ -f fail.sum ]
92then
93 mv fail.sum fail.old
94fi
95
96if [ ! -d ${builddir} ]
97then
98 echo ${builddir} does not exist
99 exit 1
100fi
101
102cd ${builddir}
103rm -rf *
104
105MAKE=${make}
106export MAKE
107
108jobs=1
109# For each target, configure and build it.
110while read targ opts
111do
112 if [ ${opts} != "broken" ]
113 then
114 trap 'echo cleaning up ...; rm -rf ${builddir}/*; exit 1' 1 2 15
115 echo ${targ}
116 mkdir ${targ}
117 cd ${targ}
118 ${srcdir}/configure --target=$targ \
119 --enable-gdb-build-warnings=$opts \
120 >> ${logdir}/config.tout.$targ 2>&1 &
121 cd ..
122 jobs=`expr ${jobs} + 1`
123 if [ ${jobs} -gt ${par} ]
124 then
125 wait
126 jobs=1
127 fi
128 fi
129done << EOF
130$alltarg
131EOF
132
133wait
134
135cat ${logdir}/config.tout.* > ${logdir}/config.out
136rm -f ${logdir}/config.tout.*
137
138for targ in *
139do
140 cd $targ
141 if ${make} -j ${par} all-gdb >> ${logdir}/build.out 2>&1
142 then
143 true
144 else
145 echo ">>>>>>>>>>>>>" >> ${logdir}/fail.sum
146 echo "$targ (${opts})" >> ${logdir}/fail.sum
147 tail -20 ${logdir}/build.out >> ${logdir}/fail.sum
148 echo >> ${logdir}/fail.sum
149 echo $targ build failed
150 fi
151 rm -rf *
152 cd ..
153done