]> git.ipfire.org Git - thirdparty/squid.git/blob - test-suite/buildtest.sh
SourceFormat Enforcement
[thirdparty/squid.git] / test-suite / buildtest.sh
1 #!/bin/sh
2 #
3 ## Copyright (C) 1996-2017 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 action="${1}"
17 config="${2}"
18 base="`dirname ${0}`"
19
20 # cache_file may be set by environment variable
21 configcache=""
22 if [ -n "$cache_file" ]; then
23 configcache="--cache-file=$cache_file"
24 fi
25
26 #if we are on Linux, let's try parallelizing
27 if [ -z "$pjobs" -a -e /proc/cpuinfo ]; then
28 ncpus=`grep '^processor' /proc/cpuinfo | tail -1|awk '{print $3}'`
29 ncpus=`expr ${ncpus} + 1`
30 pjobs="-j${ncpus}"
31 fi
32 #if we are on FreeBSD, let's try parallelizing
33 if [ -z "$pjobs" -a -x /sbin/sysctl ]; then
34 ncpus=`sysctl kern.smp.cpus | cut -f2 -d" "`
35 if [ $? -eq 0 -a -n "$ncpus" -a "$ncpus" -gt 1 ]; then
36 pjobs="-j${ncpus}"
37 fi
38 fi
39
40 if test -e ${config} ; then
41 echo "BUILD: ${config}"
42 . ${config}
43 else
44 echo -n "BUILD ERROR: Unable to locate test configuration '${config}' from " && pwd
45 exit 1;
46 fi
47
48 # override the layers MAKETEST default
49 if test "x${action}" != "x"; then
50 MAKETEST="${action}"
51 fi
52
53 #
54 # empty all the existing code, reconfigure and builds test code
55 # but skip if we have no files to remove.
56 FILECOUNT=`ls -1 | grep -c .`
57 if test "${FILECOUNT}" != "0" ; then
58 ${MAKE:-make} -k distclean || echo "distclean done. errors are unwanted but okay here."
59 ls -la .
60 rm -fr ./src/fs/aufs/.deps src/fs/diskd/.deps
61 fi
62
63 #
64 # above command currently encounters dependancy problems on cleanup.
65 #
66 # do not build any of the install's ...
67 #
68 # eval is need to correctly handle quoted arguments
69 eval "$base/../configure ${DISTCHECK_CONFIGURE_FLAGS} ${configcache}" \
70 2>&1 && \
71 ${MAKE:-make} ${pjobs} ${MAKETEST} 2>&1
72
73 # Remember and then explicitly return the result of the last command
74 # to the script caller. Probably not needed on most or all platforms.
75 result=$?
76 exit ${result}