]> git.ipfire.org Git - thirdparty/squid.git/blob - test-suite/buildtest.sh
b9683df3e17d1dd3a74110759b84bd7e46978650
[thirdparty/squid.git] / test-suite / buildtest.sh
1 #!/bin/sh
2 #
3 ## Copyright (C) 1996-2014 The Squid Software Foundation and contributors
4 ##
5 ## Squid software is distributed under GPLv2+ license and includes
6 ## contributions from numerous individuals and organizations.
7 ## Please see the COPYING and CONTRIBUTORS files for details.
8 ##
9
10 # Configure and run a test build against any given set of configure options
11 # or compile-time flags.
12 #
13 # Should be run from the source package root directory with paths relative to there.
14 #
15
16 config="${1}"
17 base="`dirname ${0}`"
18
19 # cache_file may be set by environment variable
20 configcache=""
21 if [ -n "$cache_file" ]; then
22 configcache="--cache-file=$cache_file"
23 fi
24
25 #if we are on Linux, let's try parallelizing
26 if [ -z "$pjobs" -a -e /proc/cpuinfo ]; then
27 ncpus=`grep '^processor' /proc/cpuinfo | tail -1|awk '{print $3}'`
28 ncpus=`expr ${ncpus} + 1`
29 pjobs="-j${ncpus}"
30 fi
31 #if we are on FreeBSD, let's try parallelizing
32 if [ -z "$pjobs" -a -x /sbin/sysctl ]; then
33 ncpus=`sysctl kern.smp.cpus | cut -f2 -d" "`
34 if [ $? -eq 0 -a -n "$ncpus" -a "$ncpus" -gt 1 ]; then
35 pjobs="-j${ncpus}"
36 fi
37 fi
38
39 if test -e ${config} ; then
40 echo "BUILD: ${config}"
41 . ${config}
42 else
43 echo -n "BUILD ERROR: Unable to locate test configuration '${config}' from " && pwd
44 exit 1;
45 fi
46
47 #
48 # empty all the existing code, reconfigure and builds test code
49 # but skip if we have no files to remove.
50 FILECOUNT=`ls -1 | grep -c .`
51 if test "${FILECOUNT}" != "0" ; then
52 ${MAKE:-make} -k distclean || echo "distclean done. errors are unwanted but okay here."
53 ls -la .
54 rm -fr ./src/fs/aufs/.deps src/fs/diskd/.deps
55 fi
56
57 #
58 # above command currently encounters dependancy problems on cleanup.
59 #
60 # do not build any of the install's ...
61 #
62 # eval is need to correctly handle quoted arguments
63 eval "$base/../configure ${DISTCHECK_CONFIGURE_FLAGS} ${configcache}" \
64 2>&1 && \
65 ${MAKE:-make} ${pjobs} ${MAKETEST} 2>&1
66
67 # Remember and then explicitly return the result of the last command
68 # to the script caller. Probably not needed on most or all platforms.
69 result=$?
70 exit ${result}